Skip to content

Commit 1ad5145

Browse files
committed
now the build system will generate ebooks for the en-uk version as well.
1 parent ef03a1e commit 1ad5145

13 files changed

+630
-59
lines changed

Makefile

Lines changed: 6 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,13 @@
1-
ver=$(shell date +'%Y.%m.%d')
2-
name=agentzh-nginx-tutorials-zhcn
3-
zhcn_tutfiles=$(sort $(wildcard zh-cn/*.tut))
4-
zhcn_wikifiles=$(patsubst %.tut,wiki/%.wiki,$(zhcn_tutfiles))
5-
zhcn_htmlfiles=$(patsubst %.tut,html/%.html,$(zhcn_tutfiles))
1+
.PHONY: all zhcn enuk clean
62

7-
.PHONY: all mobi clean epub pdf html
3+
all: zhcn enuk
84

9-
.PRECIOUS: $(zhcn_wikifiles) $(zhcn_htmlfiles)
5+
zhcn:
6+
$(MAKE) -f ebooks.mk
107

11-
all: mobi epub pdf html
12-
13-
mobi: $(name).mobi
14-
15-
epub: $(name).epub
16-
17-
pdf: $(name).pdf
18-
19-
html: $(name).html
20-
21-
%.pdf: $(name).html
22-
ebook-convert $< $@ \
23-
--margin-bottom 30 \
24-
--margin-top 30 \
25-
--margin-left 20 \
26-
--margin-right 20 \
27-
--no-chapters-in-toc \
28-
--book-producer 'agentzh' \
29-
--output-profile kindle \
30-
--title "agentzh的Nginx教程($(ver)版)" --publisher 'agentzh' \
31-
--language "cn" --authors 'agentzh'
32-
33-
%.mobi: $(name).html
34-
ebook-convert $< $@ \
35-
--output-profile kindle_dx --no-inline-toc \
36-
--title "agentzh的Nginx教程($(ver)版)" --publisher '章亦春 (agentzh)' \
37-
--language "cn" --authors '章亦春 (agentzh)'
38-
39-
%.epub: $(name).html
40-
ebook-convert $< $@ \
41-
--no-default-epub-cover \
42-
--output-profile kindle_dx \
43-
--title "agentzh的Nginx教程($(ver)版)" --publisher '章亦春 (agentzh)' \
44-
--language "cn" --authors '章亦春 (agentzh)'
45-
46-
$(name).html: $(zhcn_htmlfiles)
47-
./utils/gen-html-index.pl -v $(ver) -o $@ $^
48-
49-
html/%.html: wiki/%.wiki
50-
mkdir -p $(dir $@)
51-
./utils/wiki2html.pl -o $@ $<
52-
53-
wiki/%.wiki: %.tut
54-
mkdir -p $(dir $@)
55-
./utils/tut2wiki.pl -o $@ $<
8+
enuk:
9+
$(MAKE) -f ebooks.mk lang=$@ lang2=en src=en-uk title="agentzh's Nginx Tutorials"
5610

5711
clean:
5812
rm -rf html/ wiki/ index*.html *.mobi *.epub *.pdf
5913

60-
#test: ; echo $(zhcn_htmlfiles)
61-

ebooks.mk

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
lang=zhcn
2+
lang2=cn
3+
src=zh-cn
4+
ver=$(shell date +'%Y.%m.%d')
5+
title=agentzh的Nginx教程($(ver)版)
6+
name=agentzh-nginx-tutorials-$(lang)
7+
tutfiles=$(sort $(wildcard $(src)/*.tut))
8+
wikifiles=$(patsubst %.tut,wiki/%.wiki,$(tutfiles))
9+
htmlfiles=$(patsubst %.tut,html/%.html,$(tutfiles))
10+
11+
.PHONY: all mobi epub pdf html
12+
13+
.PRECIOUS: $(wikifiles) $(htmlfiles)
14+
15+
all: mobi epub pdf html
16+
17+
mobi: $(name).mobi
18+
19+
epub: $(name).epub
20+
21+
pdf: $(name).pdf
22+
23+
html: $(name).html
24+
25+
%.pdf: $(name).html
26+
ebook-convert $< $@ \
27+
--margin-bottom 30 \
28+
--margin-top 30 \
29+
--margin-left 20 \
30+
--margin-right 20 \
31+
--no-chapters-in-toc \
32+
--book-producer 'agentzh' \
33+
--output-profile kindle \
34+
--title "$(title)" --publisher 'agentzh' \
35+
--language $(lang2) --authors 'agentzh'
36+
37+
%.mobi: $(name).html
38+
ebook-convert $< $@ \
39+
--output-profile kindle_dx --no-inline-toc \
40+
--title "$(title)" --publisher 'agentzh' \
41+
--language $(lang2) --authors 'agentzh'
42+
43+
%.epub: $(name).html
44+
ebook-convert $< $@ \
45+
--no-default-epub-cover \
46+
--output-profile kindle_dx \
47+
--title "$(title)" --publisher 'agentzh' \
48+
--language $(lang2) --authors 'agentzh'
49+
50+
$(name).html: $(htmlfiles)
51+
./utils/gen-html-index-$(lang2).pl -v $(ver) -o $@ $^
52+
53+
html/%.html: wiki/%.wiki ./utils/wiki2html-$(lang2).pl
54+
mkdir -p $(dir $@)
55+
./utils/wiki2html-$(lang2).pl -o $@ $<
56+
57+
wiki/%.wiki: %.tut ./utils/tut2wiki-$(lang2).pl
58+
mkdir -p $(dir $@)
59+
./utils/tut2wiki-$(lang2).pl -o $@ $<
60+
61+
#test: ; echo $(htmlfiles)
62+

en-uk/01-NginxVariables03.tut

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ are
178178
called "indexed" in Nginx core. Otherwise they are called "non-indexed"
179179
.
180180

181-
As we learnt from L<vartut/ (02)>, the variable category like L<$arg_XXX>
181+
As we learnt from L<vartut/(02)>, the variable category like L<$arg_XXX>
182182
are non-indexed,
183183
the read and write of those variables are executed through "set/get handlers"
184184
, i.e. by calculating

en-uk/01-NginxVariables08.tut

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ cornerstone elements which bridge every other Nginx modules. Nginx variables
163163
are everywhere
164164
in the coming tutorials, understand them is absolutely necessary.
165165

166-
In the coming tutorial L<Nginx command execution ordering>, we will be
166+
In the coming tutorial "L<Nginx Directive Execution Order>", we will be
167167
discussing in detail
168168
the Nginx execution ordering and the phases every request traverses. It'
169169
s indispensable to

en-uk/02-NginxDirectiveExecOrder01.tut

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ and remove its timestamp etc) :
141141

142142
It barely makes any senses, does it? So let me interpret. Command
143143
L<ngx_rewrite/set> dumps two lines of debug info which start with
144-
C<http script>, the first line tells the value which command L<ngex_rewrite/set>
144+
C<http script>, the first line tells the value which command L<ngx_rewrite/set>
145145
has possessed, and the second line being the variable name it
146146
will be given to, so for the leading filtered log:
147147

@@ -234,7 +234,7 @@ a module which misses the applicable phase in the document, you can write
234234
to its authors right away and ask for it. However, we shall be reminded,
235235
not every command has an applicable phase. Examples are command L<ngx_geo/geo>
236236
introduced in L<vartut/Nginx Variables (01)> and command L<ngx_map/map>
237-
introduced in L<vartut/Nginx Variables (04>. These commands, who have no
237+
introduced in L<vartut/Nginx Variables (04)>. These commands, who have no
238238
explicit applicable phase, are declarative and unrelated to the conception
239239
of
240240
execution ordering. Igor Sysoev, the author of Nginx, has made the statements

en-uk/02-NginxDirectiveExecOrder03.tut

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ offers the caliber to stuff in any potentially mind twisted Lua code.
105105

106106
After phase C<rewrite>, Nginx has another phase called C<access>.
107107
The commands provided by 3rd party module L<ngx_auth_request>, which is
108-
discussed in L<vartut/Nginx Varaibles (05)>, execute in phase C<access>.
108+
discussed in L<vartut/Nginx Variables (05)>, execute in phase C<access>.
109109
Commands registered in C<access> phase mostly carry out ACL functionalities,
110110
such as guarding user clearance, checking user origins, examining source
111111
IP validity etc.
File renamed without changes.

utils/gen-html-index-en.pl

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#!/usr/bin/env perl
2+
3+
use encoding 'utf8';
4+
use strict;
5+
use warnings;
6+
7+
use Getopt::Std;
8+
9+
my %opts;
10+
getopts('o:v:', \%opts) or usage();
11+
12+
my $outfile = $opts{o};
13+
my $ver = $opts{v} or usage();
14+
15+
my @nums = qw(
16+
00 01 02 03 04 05 06 07 08 09
17+
10 11 12 13 14 15 16 17 18 19
18+
20
19+
);
20+
21+
my @infiles = @ARGV;
22+
23+
my $res = <<_EOC_;
24+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh" lang="zh">
25+
<head>
26+
<title>agentzh's Nginx Tutorials (version $ver)</title>
27+
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
28+
</head>
29+
<body><h2>agentzh's Nginx Tutorials (version $ver)</h2>
30+
<h3>Table of Contents</h3>
31+
_EOC_
32+
33+
$res .= "<ul>\n";
34+
for my $infile (@ARGV) {
35+
(my $base = $infile) =~ s{.*/|\.html$}{}g;
36+
37+
if ($infile =~ /Foreword(\d+)/) {
38+
my $n = $1;
39+
if ($n eq '01') {
40+
$res .= <<_EOC_;
41+
<li><a href="#$base">Foreword</a></li>
42+
_EOC_
43+
} elsif ($n eq '02') {
44+
$res .= <<_EOC_;
45+
<li><a href="#$base">Nginx 教程的连载计划</a></li>
46+
_EOC_
47+
} else {
48+
die "unknown infile: $infile";
49+
}
50+
51+
} elsif ($infile =~ /NginxVariables(\d+)/) {
52+
my $num = +$1;
53+
my $n = $nums[$num];
54+
#$infile =~ s{.*/}{}g;
55+
$res .= <<_EOC_;
56+
<li><a href="#$base">Nginx Variables ($n)</a></li>
57+
_EOC_
58+
59+
} elsif ($infile =~ /DirectiveExecOrder(\d+)/) {
60+
my $num = +$1;
61+
my $n = $nums[$num];
62+
#$infile =~ s{.*/}{}g;
63+
$res .= <<_EOC_;
64+
<li><a href="#$base">Nginx Directive Execution Order ($n)</a></li>
65+
_EOC_
66+
67+
} else {
68+
die "Unknown file $infile";
69+
}
70+
}
71+
72+
$res .= "</ul>\n";
73+
74+
for my $infile (@ARGV) {
75+
open my $in, $infile
76+
or die "Cannot open $infile for reading: $!\n";
77+
$res .= do { local $/; <$in> };
78+
close $in;
79+
}
80+
81+
$res .= "</body></html>";
82+
83+
if ($outfile) {
84+
open my $out, ">:encoding(UTF-8)", $outfile
85+
or die "Cannot open $outfile for writing: $!\n";
86+
87+
print $out $res;
88+
close $out;
89+
90+
} else {
91+
print $res;
92+
}
93+
94+
sub usage {
95+
die "Usage: $0 -v <version> [-o <outfile>] <infile>\n";
96+
}
97+

utils/prefix.pl

100644100755
File mode changed.
File renamed without changes.

0 commit comments

Comments
 (0)