Permalink
Browse files

now the build system will generate ebooks for the en-uk version as well.

  • Loading branch information...
agentzh committed Mar 23, 2012
1 parent ef03a1e commit 1ad5145e303aac4f5b04af30661075e2ac1d9794
View
@@ -1,61 +1,13 @@
-ver=$(shell date +'%Y.%m.%d')
-name=agentzh-nginx-tutorials-zhcn
-zhcn_tutfiles=$(sort $(wildcard zh-cn/*.tut))
-zhcn_wikifiles=$(patsubst %.tut,wiki/%.wiki,$(zhcn_tutfiles))
-zhcn_htmlfiles=$(patsubst %.tut,html/%.html,$(zhcn_tutfiles))
+.PHONY: all zhcn enuk clean
-.PHONY: all mobi clean epub pdf html
+all: zhcn enuk
-.PRECIOUS: $(zhcn_wikifiles) $(zhcn_htmlfiles)
+zhcn:
+ $(MAKE) -f ebooks.mk
-all: mobi epub pdf html
-
-mobi: $(name).mobi
-
-epub: $(name).epub
-
-pdf: $(name).pdf
-
-html: $(name).html
-
-%.pdf: $(name).html
- ebook-convert $< $@ \
- --margin-bottom 30 \
- --margin-top 30 \
- --margin-left 20 \
- --margin-right 20 \
- --no-chapters-in-toc \
- --book-producer 'agentzh' \
- --output-profile kindle \
- --title "agentzh的Nginx教程($(ver)版)" --publisher 'agentzh' \
- --language "cn" --authors 'agentzh'
-
-%.mobi: $(name).html
- ebook-convert $< $@ \
- --output-profile kindle_dx --no-inline-toc \
- --title "agentzh的Nginx教程($(ver)版)" --publisher '章亦春 (agentzh)' \
- --language "cn" --authors '章亦春 (agentzh)'
-
-%.epub: $(name).html
- ebook-convert $< $@ \
- --no-default-epub-cover \
- --output-profile kindle_dx \
- --title "agentzh的Nginx教程($(ver)版)" --publisher '章亦春 (agentzh)' \
- --language "cn" --authors '章亦春 (agentzh)'
-
-$(name).html: $(zhcn_htmlfiles)
- ./utils/gen-html-index.pl -v $(ver) -o $@ $^
-
-html/%.html: wiki/%.wiki
- mkdir -p $(dir $@)
- ./utils/wiki2html.pl -o $@ $<
-
-wiki/%.wiki: %.tut
- mkdir -p $(dir $@)
- ./utils/tut2wiki.pl -o $@ $<
+enuk:
+ $(MAKE) -f ebooks.mk lang=$@ lang2=en src=en-uk title="agentzh's Nginx Tutorials"
clean:
rm -rf html/ wiki/ index*.html *.mobi *.epub *.pdf
-#test: ; echo $(zhcn_htmlfiles)
-
View
@@ -0,0 +1,62 @@
+lang=zhcn
+lang2=cn
+src=zh-cn
+ver=$(shell date +'%Y.%m.%d')
+title=agentzh的Nginx教程($(ver)版)
+name=agentzh-nginx-tutorials-$(lang)
+tutfiles=$(sort $(wildcard $(src)/*.tut))
+wikifiles=$(patsubst %.tut,wiki/%.wiki,$(tutfiles))
+htmlfiles=$(patsubst %.tut,html/%.html,$(tutfiles))
+
+.PHONY: all mobi epub pdf html
+
+.PRECIOUS: $(wikifiles) $(htmlfiles)
+
+all: mobi epub pdf html
+
+mobi: $(name).mobi
+
+epub: $(name).epub
+
+pdf: $(name).pdf
+
+html: $(name).html
+
+%.pdf: $(name).html
+ ebook-convert $< $@ \
+ --margin-bottom 30 \
+ --margin-top 30 \
+ --margin-left 20 \
+ --margin-right 20 \
+ --no-chapters-in-toc \
+ --book-producer 'agentzh' \
+ --output-profile kindle \
+ --title "$(title)" --publisher 'agentzh' \
+ --language $(lang2) --authors 'agentzh'
+
+%.mobi: $(name).html
+ ebook-convert $< $@ \
+ --output-profile kindle_dx --no-inline-toc \
+ --title "$(title)" --publisher 'agentzh' \
+ --language $(lang2) --authors 'agentzh'
+
+%.epub: $(name).html
+ ebook-convert $< $@ \
+ --no-default-epub-cover \
+ --output-profile kindle_dx \
+ --title "$(title)" --publisher 'agentzh' \
+ --language $(lang2) --authors 'agentzh'
+
+$(name).html: $(htmlfiles)
+ ./utils/gen-html-index-$(lang2).pl -v $(ver) -o $@ $^
+
+html/%.html: wiki/%.wiki ./utils/wiki2html-$(lang2).pl
+ mkdir -p $(dir $@)
+ ./utils/wiki2html-$(lang2).pl -o $@ $<
+
+wiki/%.wiki: %.tut ./utils/tut2wiki-$(lang2).pl
+ mkdir -p $(dir $@)
+ ./utils/tut2wiki-$(lang2).pl -o $@ $<
+
+#test: ; echo $(htmlfiles)
+
@@ -178,7 +178,7 @@ are
called "indexed" in Nginx core. Otherwise they are called "non-indexed"
.
-As we learnt from L<vartut/ (02)>, the variable category like L<$arg_XXX>
+As we learnt from L<vartut/(02)>, the variable category like L<$arg_XXX>
are non-indexed,
the read and write of those variables are executed through "set/get handlers"
, i.e. by calculating
@@ -163,7 +163,7 @@ cornerstone elements which bridge every other Nginx modules. Nginx variables
are everywhere
in the coming tutorials, understand them is absolutely necessary.
-In the coming tutorial L<Nginx command execution ordering>, we will be
+In the coming tutorial "L<Nginx Directive Execution Order>", we will be
discussing in detail
the Nginx execution ordering and the phases every request traverses. It'
s indispensable to
@@ -141,7 +141,7 @@ and remove its timestamp etc) :
It barely makes any senses, does it? So let me interpret. Command
L<ngx_rewrite/set> dumps two lines of debug info which start with
-C<http script>, the first line tells the value which command L<ngex_rewrite/set>
+C<http script>, the first line tells the value which command L<ngx_rewrite/set>
has possessed, and the second line being the variable name it
will be given to, so for the leading filtered log:
@@ -234,7 +234,7 @@ a module which misses the applicable phase in the document, you can write
to its authors right away and ask for it. However, we shall be reminded,
not every command has an applicable phase. Examples are command L<ngx_geo/geo>
introduced in L<vartut/Nginx Variables (01)> and command L<ngx_map/map>
-introduced in L<vartut/Nginx Variables (04>. These commands, who have no
+introduced in L<vartut/Nginx Variables (04)>. These commands, who have no
explicit applicable phase, are declarative and unrelated to the conception
of
execution ordering. Igor Sysoev, the author of Nginx, has made the statements
@@ -105,7 +105,7 @@ offers the caliber to stuff in any potentially mind twisted Lua code.
After phase C<rewrite>, Nginx has another phase called C<access>.
The commands provided by 3rd party module L<ngx_auth_request>, which is
-discussed in L<vartut/Nginx Varaibles (05)>, execute in phase C<access>.
+discussed in L<vartut/Nginx Variables (05)>, execute in phase C<access>.
Commands registered in C<access> phase mostly carry out ACL functionalities,
such as guarding user clearance, checking user origins, examining source
IP validity etc.
File renamed without changes.
View
@@ -0,0 +1,97 @@
+#!/usr/bin/env perl
+
+use encoding 'utf8';
+use strict;
+use warnings;
+
+use Getopt::Std;
+
+my %opts;
+getopts('o:v:', \%opts) or usage();
+
+my $outfile = $opts{o};
+my $ver = $opts{v} or usage();
+
+my @nums = qw(
+ 00 01 02 03 04 05 06 07 08 09
+ 10 11 12 13 14 15 16 17 18 19
+ 20
+);
+
+my @infiles = @ARGV;
+
+my $res = <<_EOC_;
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh" lang="zh">
+ <head>
+ <title>agentzh's Nginx Tutorials (version $ver)</title>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+ </head>
+ <body><h2>agentzh's Nginx Tutorials (version $ver)</h2>
+ <h3>Table of Contents</h3>
+_EOC_
+
+$res .= "<ul>\n";
+for my $infile (@ARGV) {
+ (my $base = $infile) =~ s{.*/|\.html$}{}g;
+
+ if ($infile =~ /Foreword(\d+)/) {
+ my $n = $1;
+ if ($n eq '01') {
+ $res .= <<_EOC_;
+ <li><a href="#$base">Foreword</a></li>
+_EOC_
+ } elsif ($n eq '02') {
+ $res .= <<_EOC_;
+ <li><a href="#$base">Nginx 教程的连载计划</a></li>
+_EOC_
+ } else {
+ die "unknown infile: $infile";
+ }
+
+ } elsif ($infile =~ /NginxVariables(\d+)/) {
+ my $num = +$1;
+ my $n = $nums[$num];
+ #$infile =~ s{.*/}{}g;
+ $res .= <<_EOC_;
+ <li><a href="#$base">Nginx Variables ($n)</a></li>
+_EOC_
+
+ } elsif ($infile =~ /DirectiveExecOrder(\d+)/) {
+ my $num = +$1;
+ my $n = $nums[$num];
+ #$infile =~ s{.*/}{}g;
+ $res .= <<_EOC_;
+ <li><a href="#$base">Nginx Directive Execution Order ($n)</a></li>
+_EOC_
+
+ } else {
+ die "Unknown file $infile";
+ }
+}
+
+$res .= "</ul>\n";
+
+for my $infile (@ARGV) {
+ open my $in, $infile
+ or die "Cannot open $infile for reading: $!\n";
+ $res .= do { local $/; <$in> };
+ close $in;
+}
+
+$res .= "</body></html>";
+
+if ($outfile) {
+ open my $out, ">:encoding(UTF-8)", $outfile
+ or die "Cannot open $outfile for writing: $!\n";
+
+ print $out $res;
+ close $out;
+
+} else {
+ print $res;
+}
+
+sub usage {
+ die "Usage: $0 -v <version> [-o <outfile>] <infile>\n";
+}
+
View
0 utils/prefix.pl 100644 → 100755
No changes.
File renamed without changes.
Oops, something went wrong.

0 comments on commit 1ad5145

Please sign in to comment.