review 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +36 -0
- data/.rubocop.yml +1 -0
- data/ChangeLog +102 -0
- data/README.rdoc +2 -2
- data/bin/review-check +18 -16
- data/bin/review-compile +49 -42
- data/bin/review-epubmaker +23 -993
- data/bin/review-epubmaker-legacy +1024 -0
- data/bin/review-index +17 -15
- data/bin/review-init +39 -9
- data/bin/review-pdfmaker +124 -89
- data/bin/review-preproc +16 -14
- data/bin/review-vol +17 -15
- data/debian/docs +1 -1
- data/doc/catalog.rdoc +34 -0
- data/doc/format.rdoc +16 -2
- data/doc/libepubmaker/{config.yaml → config.yml} +63 -19
- data/doc/quickstart.rdoc +1 -1
- data/doc/{sample.yaml → sample.yml} +0 -0
- data/lib/epubmaker.rb +1 -1
- data/lib/epubmaker/content.rb +9 -1
- data/lib/epubmaker/epubv2.rb +59 -7
- data/lib/epubmaker/epubv3.rb +14 -9
- data/lib/epubmaker/producer.rb +68 -27
- data/lib/epubmaker/resource.rb +3 -1
- data/lib/lineinput.rb +2 -2
- data/lib/review/book/base.rb +125 -24
- data/lib/review/book/chapter.rb +42 -0
- data/lib/review/book/compilable.rb +23 -4
- data/lib/review/book/image_finder.rb +64 -0
- data/lib/review/book/index.rb +64 -50
- data/lib/review/book/page_metric.rb +1 -1
- data/lib/review/builder.rb +19 -12
- data/lib/review/catalog.rb +47 -0
- data/lib/review/compiler.rb +3 -2
- data/lib/review/configure.rb +5 -3
- data/lib/review/epubmaker.rb +130 -46
- data/lib/review/ewbbuilder.rb +27 -31
- data/lib/review/extentions/string.rb +4 -4
- data/lib/review/htmlbuilder.rb +140 -79
- data/lib/review/htmllayout.rb +26 -4
- data/lib/review/htmlutils.rb +20 -1
- data/lib/review/i18n.rb +5 -2
- data/lib/review/{i18n.yaml → i18n.yml} +4 -2
- data/lib/review/idgxmlbuilder.rb +65 -39
- data/lib/review/latexbuilder.rb +72 -24
- data/lib/review/latexutils.rb +3 -1
- data/lib/review/makerhelper.rb +8 -2
- data/lib/review/preprocessor.rb +20 -20
- data/lib/review/review.tex.erb +4 -0
- data/lib/review/sec_counter.rb +9 -11
- data/lib/review/tocparser.rb +2 -2
- data/lib/review/tocprinter.rb +12 -12
- data/lib/review/topbuilder.rb +15 -15
- data/lib/review/version.rb +1 -1
- data/lib/uuid.rb +7 -7
- data/review.gemspec +2 -2
- data/rubocop-todo.yml +443 -0
- data/test/sample-book/src/config.yml +2 -2
- data/test/sample-book/src/{main.css → style.css} +0 -0
- data/test/test_book.rb +46 -48
- data/test/test_book_chapter.rb +25 -13
- data/test/test_builder.rb +3 -3
- data/test/test_catalog.rb +107 -0
- data/test/test_epubmaker.rb +6 -6
- data/test/test_htmlbuilder.rb +160 -39
- data/test/test_htmlutils.rb +22 -0
- data/test/test_i18n.rb +2 -2
- data/test/test_idgxmlbuilder.rb +33 -47
- data/test/test_image_finder.rb +82 -0
- data/test/test_inaobuilder.rb +1 -1
- data/test/test_latexbuilder.rb +35 -39
- data/test/test_lineinput.rb +2 -2
- data/test/test_markdownbuilder.rb +2 -2
- data/test/test_topbuilder.rb +39 -23
- metadata +23 -14
- data/bin/review-epubmaker-ng +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ede64a20eecee63934877cb311e35313c6ffeb75
|
4
|
+
data.tar.gz: 629a36d714fd028da9d7b7fda334406f6f128843
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2b09524e28687e28c86df4cb5971bb999e09813db2c52fe1d4af4e25bb3f00ce66eb4570c21a907ca3d3f9d708fde6a82b101c3b8564f34c62ec01976ad19a8
|
7
|
+
data.tar.gz: 0623f1131de71a1bfcc388c78fd2bce77ad191ba8c338d82f6390c92172457707220a18e626c24e5965dba643bf40aab7d2041a8759eae2de883b4d3d4b281bb
|
data/.gitignore
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/rdoc/
|
21
|
+
|
22
|
+
## Environment normalisation:
|
23
|
+
/.bundle/
|
24
|
+
/lib/bundler/man/
|
25
|
+
|
26
|
+
# for a library or gem, you might want to ignore these files since the code is
|
27
|
+
# intended to run in multiple environments; otherwise, check them in:
|
28
|
+
# Gemfile.lock
|
29
|
+
# .ruby-version
|
30
|
+
# .ruby-gemset
|
31
|
+
|
32
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
33
|
+
.rvmrc
|
34
|
+
|
35
|
+
# IntelliJ
|
36
|
+
.idea
|
data/.rubocop.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
inherit_from: rubocop-todo.yml
|
data/ChangeLog
CHANGED
@@ -1,3 +1,105 @@
|
|
1
|
+
Sun Jun 29 10:40:02 2014 Kenshi Muto <kmuto@debian.org>
|
2
|
+
|
3
|
+
* Now review-epubmaker-ng becomes review-epubmaker.
|
4
|
+
Previous review-epubmaker is renamed to review-epubmaker-legacy.
|
5
|
+
We believe new review-epubmaker has a compatibility with
|
6
|
+
previous version, but please inform us if you meet a different
|
7
|
+
behavior. See doc/libepubmaker/config.yml for details of
|
8
|
+
configurations.
|
9
|
+
|
10
|
+
Fri Jun 27 22:49:17 2014 Kenshi Muto <kmuto@debian.org>
|
11
|
+
|
12
|
+
* lib/epubmaker/epubv2.rb: insert dummy <span> element with
|
13
|
+
double-width space in tree toc when <li> element has only
|
14
|
+
child <ol> element. Closes #285.
|
15
|
+
|
16
|
+
Tue Jun 17 10:36:31 2014 Masayoshi Takahashi <takahashimm@gmail.com>
|
17
|
+
|
18
|
+
* lib/review/book/base.rb:
|
19
|
+
remove (rarely used) features.
|
20
|
+
* ignore ./config.rb file
|
21
|
+
* ignore ./lib/review/* files
|
22
|
+
* ignore ./*/*.re and ./*/*/*.re files
|
23
|
+
|
24
|
+
Wed Jun 11 20:15:00 2014 KADO Masanori <kdmsnr@gmail.com>
|
25
|
+
|
26
|
+
* lib/review/book/base.rb (ReVIEW::Book::Base#config):
|
27
|
+
Rename method and instance variable from param to config.
|
28
|
+
|
29
|
+
Sun Jun 8 22:55:39 2014 Kenshi Muto <kmuto@debian.org>
|
30
|
+
|
31
|
+
* lib/review/htmlbuilder.rb, lib/review/htmlutils.rb,
|
32
|
+
test/test_htmlbuilder.rb, test/test_htmlutils.rb:
|
33
|
+
normalize html ID. ID must be /\A[a-z][0-9a-z_.-]*/
|
34
|
+
with case insensitive.
|
35
|
+
|
36
|
+
Sun Jun 8 22:04:29 2014 Kenshi Muto <kmuto@debian.org>
|
37
|
+
|
38
|
+
* bin/review-epubmaker, bin/review-pdfmaker,
|
39
|
+
lib/review/epubmaker.rb, lib/review/makerhelper.rb:
|
40
|
+
review-*maker calls review-compile of exactly same
|
41
|
+
directory. Closes #228, #288.
|
42
|
+
|
43
|
+
Sat Jun 7 00:37:17 2014 Kenshi Muto <kmuto@debian.org>
|
44
|
+
|
45
|
+
* lib/review/htmlbuilder.rb:
|
46
|
+
use the value of htmlext variable for html file
|
47
|
+
extension, instead of static ".html".
|
48
|
+
|
49
|
+
Sat Jun 7 00:06:37 2014 Kenshi Muto <kmuto@debian.org>
|
50
|
+
|
51
|
+
* lib/epubmaker/content.rb, lib/epubmaker/epubv3.rb,
|
52
|
+
lib/review/epubmaker.rb:
|
53
|
+
add properties='svg' attribute to OPF item of HTML
|
54
|
+
which links SVG file (to satisfy EPUB3 spec.)
|
55
|
+
|
56
|
+
Wed Jun 4 12:05:36 2014 Kenshi Muto <kmuto@debian.org>
|
57
|
+
|
58
|
+
* add safe mode.
|
59
|
+
This feature checks a numeric value of REVIEW_SAFE_MODE
|
60
|
+
environment variable.
|
61
|
+
bit1(+1) : blocks any hooks of epubmaker.
|
62
|
+
bit2(+2) : blocks review-ext.rb.
|
63
|
+
bit3(+4) : blocks user's custom html layouts.
|
64
|
+
|
65
|
+
Mon Jun 2 14:23:28 2014 Kenshi Muto <kmuto@debian.org>
|
66
|
+
|
67
|
+
* doc/libepubmaker/config.yml, lib/epubmaker/producer.rb,
|
68
|
+
lib/review/epubmaker.rb: implement strict image finder mode
|
69
|
+
for review-epubmaker-ng.
|
70
|
+
review-epubmaker-ng picks up the images which are used in each
|
71
|
+
HTMLs and CSSs by declareing 'verify_target_images: true' in yml.
|
72
|
+
|
73
|
+
Thu May 28 00:51:08 2014 Masayoshi Takahashi <takahashimm@gmail.com>
|
74
|
+
|
75
|
+
* lib/review/book/image_finder.rb:
|
76
|
+
add new class ReVIEW::Book::ImageFinder extracted from ReVIEW::Book::Index
|
77
|
+
|
78
|
+
Index#find_pathes moves to ImageFinder#find_path, and select only one (first) path
|
79
|
+
because rest pathes is not used.
|
80
|
+
ImageFinder is an independent class, so you can get image pathes without ImageIndex.
|
81
|
+
|
82
|
+
|
83
|
+
Sat Apr 12 16:31:11 2014 Masayoshi Takahashi <takahashimm@gmail.com>
|
84
|
+
|
85
|
+
* lib/review/book/index.rb: allow same @<icon>s in one document (remove warning)
|
86
|
+
|
87
|
+
Thu Apr 3 19:03:03 2014 Kenshi Muto <kmuto@debian.org>
|
88
|
+
|
89
|
+
* change all .yaml to .yml. (#244)
|
90
|
+
locale.yaml is still supported for backward compatibility.
|
91
|
+
(but locale.yml is preferred.)
|
92
|
+
|
93
|
+
Thu Apr 3 18:41:42 2014 Kenshi Muto <kmuto@debian.org>
|
94
|
+
|
95
|
+
* lib/review/latexbuilder.rb: escape idx string.
|
96
|
+
|
97
|
+
Thu Apr 3 09:53:26 2014 Kenshi Muto <kmuto@debian.org>
|
98
|
+
|
99
|
+
* lib/epubmaker: add zip_addpath parameter to include
|
100
|
+
extra pathes in ePUB file.
|
101
|
+
* Rename sample YAML file's extension from .yaml to .yml.
|
102
|
+
|
1
103
|
Wed Apr 2 22:34:56 2014 Masayoshi Takahashi <takahashimm@gmail.com>
|
2
104
|
|
3
105
|
* Release 1.2.0.
|
data/README.rdoc
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
{<img src="https://secure.travis-ci.org/kmuto/review.png"/>}[http://travis-ci.org/kmuto/review]
|
4
4
|
{<img src="https://badge.fury.io/rb/review.png" alt="Gem Version" />}[http://badge.fury.io/rb/review]
|
5
5
|
|
6
|
-
Re:VIEW is
|
6
|
+
Re:VIEW is an easy-to-use digital publishing system for books and ebooks.
|
7
7
|
|
8
8
|
== Format
|
9
9
|
|
@@ -47,4 +47,4 @@ LGPL. See COPYING file.
|
|
47
47
|
|
48
48
|
== Copyright
|
49
49
|
|
50
|
-
Copyright (c) 2006-2014 Minero Aoki, Kenshi Muto, Masayoshi Takahashi.
|
50
|
+
Copyright (c) 2006-2014 Minero Aoki, Kenshi Muto, Masayoshi Takahashi, Masanori Kado.
|
data/bin/review-check
CHANGED
@@ -32,40 +32,42 @@ end
|
|
32
32
|
|
33
33
|
def main
|
34
34
|
$KCODE = 'UTF-8' unless defined?(Encoding)
|
35
|
-
@
|
35
|
+
@config = ReVIEW::Configure.values
|
36
|
+
@config.merge!({
|
36
37
|
"inencoding" => "UTF-8",
|
37
38
|
"outencoding" => "UTF-8"
|
38
|
-
}
|
39
|
+
})
|
39
40
|
|
40
41
|
modes = nil
|
41
42
|
files = ARGV unless ARGV.empty?
|
42
|
-
|
43
|
-
|
44
|
-
|
43
|
+
opts = OptionParser.new
|
44
|
+
opts.version = ReVIEW::VERSION
|
45
|
+
opts.on('--inencoding=ENCODING', 'Set input encoding. (UTF-8, EUC, JIS, and SJIS)') {|enc|
|
46
|
+
@config["inencoding"] = enc
|
45
47
|
}
|
46
|
-
|
47
|
-
@
|
48
|
+
opts.on('--outencoding=ENCODING', 'Set output encoding. (UTF-8[default], EUC, JIS, and SJIS)') {|enc|
|
49
|
+
@config["outencoding"] = enc
|
48
50
|
}
|
49
|
-
|
51
|
+
opts.on('-a', '--all-chapters', 'Check all chapters.') {
|
50
52
|
files = ReVIEW.book.chapters.map {|ent| ent.path }
|
51
53
|
}
|
52
|
-
|
54
|
+
opts.on('-s', '--section N', 'Check section N. (deprecated)') {|n|
|
53
55
|
ents = ReVIEW.env.parts[Integer(n) - 1] or
|
54
56
|
raise ReVIEW::ApplicationError, "section #{n} not exist"
|
55
57
|
files = ents.map {|ent| ent.path }
|
56
58
|
}
|
57
|
-
|
59
|
+
opts.on('--text', 'Check text.') {
|
58
60
|
(modes ||= []).push :text
|
59
61
|
}
|
60
|
-
|
61
|
-
puts
|
62
|
+
opts.on('--help', 'print this message and quit.') {
|
63
|
+
puts opts.help
|
62
64
|
exit 0
|
63
65
|
}
|
64
66
|
begin
|
65
|
-
|
67
|
+
opts.parse!
|
66
68
|
rescue OptionParser::ParseError => err
|
67
69
|
$stderr.puts err.message
|
68
|
-
$stderr.puts
|
70
|
+
$stderr.puts opts.help
|
69
71
|
exit 1
|
70
72
|
end
|
71
73
|
unless files
|
@@ -95,7 +97,7 @@ def check_text(files)
|
|
95
97
|
next if neg and neg =~ s
|
96
98
|
str, offset = find_line(para, re)
|
97
99
|
out = sprintf("%s:%d: %s\n", path, lineno + offset, str)
|
98
|
-
print convert_outencoding(out, @
|
100
|
+
print convert_outencoding(out, @config["outencoding"])
|
99
101
|
end
|
100
102
|
end
|
101
103
|
}
|
@@ -137,7 +139,7 @@ end
|
|
137
139
|
def each_paragraph(f)
|
138
140
|
$ReVIEW_utils_word_ok = nil
|
139
141
|
while line = f.gets
|
140
|
-
line = convert_inencoding(line, @
|
142
|
+
line = convert_inencoding(line, @config["inencoding"])
|
141
143
|
|
142
144
|
case line
|
143
145
|
when /\A\#@ok\((.*)\)/
|
data/bin/review-compile
CHANGED
@@ -45,7 +45,8 @@ def _main
|
|
45
45
|
check_only = false
|
46
46
|
output_filename = nil
|
47
47
|
|
48
|
-
|
48
|
+
config = ReVIEW::Configure.values
|
49
|
+
config.merge!({
|
49
50
|
"secnolevel" => 2, # for IDGXML and HTML
|
50
51
|
"tableopt" => nil, # for IDGXML
|
51
52
|
"nolf" => nil, # for IDGXML
|
@@ -60,71 +61,75 @@ def _main
|
|
60
61
|
"footnotetext" => false,
|
61
62
|
"htmlext" => "html",
|
62
63
|
"htmlversion" => 4,
|
63
|
-
}
|
64
|
+
})
|
64
65
|
|
65
|
-
|
66
|
-
|
67
|
-
|
66
|
+
opts = OptionParser.new
|
67
|
+
opts.version = ReVIEW::VERSION
|
68
|
+
opts.banner = "Usage: #{File.basename($0)} [--target=FMT]"
|
69
|
+
opts.on('--yaml=YAML', 'Read configurations from YAML file.') do |yaml|
|
68
70
|
require 'yaml'
|
69
|
-
|
71
|
+
config = config.merge(YAML.load_file(yaml))
|
70
72
|
end
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
73
|
+
opts.on('--inencoding=ENCODING', 'Set input encoding. (UTF-8, EUC, JIS, and SJIS)') {|enc| config["inencoding"] = enc }
|
74
|
+
opts.on('--outencoding=ENCODING', 'Set output encoding. (UTF-8[default], EUC, JIS, and SJIS)') {|enc| config["outencoding"] = enc }
|
75
|
+
opts.on('-c', '--check', 'Check manuscript') { check_only = true }
|
76
|
+
opts.on('--level=LVL', 'Section level to append number.') {|lvl| config["secnolevel"] = lvl.to_i }
|
77
|
+
opts.on('--toclevel=LVL', 'Section level to append number.') {|lvl| config["toclevel"] = lvl.to_i }
|
78
|
+
opts.on('--nolfinxml', 'Do not insert LF in XML. (idgxml)') { config["nolf"] = true }
|
79
|
+
opts.on('--structuredxml', 'Produce XML with structured sections. (idgxml)') { config["structuredxml"] = true }
|
80
|
+
opts.on('--table=WIDTH', 'Default table width. (idgxml)') {|tbl| config["tableopt"] = tbl }
|
81
|
+
opts.on('--listinfo', 'Append listinfo tag to lists to indicate begin/end. (idgxml)') { config["listinfo"] = true }
|
82
|
+
opts.on('--chapref="before,middle,after"', 'Chapref decoration.') {|cdec| config["chapref"] = cdec }
|
83
|
+
opts.on('--subdirmode', 'Use chapter/id.ext path style to find images. (deprecated)') do
|
82
84
|
STDERR.puts "Warning: --subdirmode is deprecated. Images are automatically detected."
|
83
85
|
end
|
84
|
-
|
86
|
+
opts.on('--singledirmode', 'Use id.ext path style to find images. (deprecated)') do
|
85
87
|
STDERR.puts "Warning: --singledirmode is deprecated. Images are automatically detected."
|
86
88
|
end
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
89
|
+
opts.on('--chapterlink', 'make chapref hyperlink') { config["chapterlink"] = true }
|
90
|
+
opts.on('--stylesheet=file', 'Stylesheet file for HTML (comma separated)') {|files| config["stylesheet"] = files.split(/\s*,\s*/) }
|
91
|
+
opts.on('--mathml', 'Use MathML for TeX equation in HTML') do
|
92
|
+
config["mathml"] = true
|
91
93
|
require 'math_ml'
|
92
94
|
require "math_ml/symbol/character_reference"
|
93
95
|
end
|
94
|
-
|
96
|
+
opts.on('--htmlversion=VERSION', 'HTML version.') do |v|
|
95
97
|
v = v.to_i
|
96
|
-
|
98
|
+
config["htmlversion"] = v if v == 4 || v == 5
|
97
99
|
end
|
98
|
-
|
100
|
+
opts.on('--epubversion=VERSION', 'EPUB version.') do |v|
|
99
101
|
v = v.to_i
|
100
|
-
|
102
|
+
config["epubversion"] = v if v == 2 || v == 3
|
101
103
|
end
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
104
|
+
opts.on('--hdnumberingmode', 'Output numbering headlines. (deprecated)') { config["hdnumberingmode"] = true }
|
105
|
+
opts.on('--deprecated-blocklines', 'Disable paragrahs in block tags. Treat physical line as a paragraph. (deprecated)') { config["deprecated-blocklines"] = true }
|
106
|
+
opts.on('--target=FMT', 'Target format.') {|fmt| target = fmt } unless target
|
107
|
+
opts.on('--footnotetext',
|
106
108
|
'Use footnotetext and footnotemark instead of footnote (latex)') {
|
107
|
-
|
109
|
+
config["footnotetext"] = true
|
108
110
|
}
|
109
|
-
|
110
|
-
|
111
|
+
opts.on('--draft', 'use draft mode(inline comment)') { config["draft"] = true }
|
112
|
+
opts.on('-a', '--all', 'Compile all chapters.') do
|
111
113
|
mode = :dir
|
112
114
|
basedir = nil
|
113
115
|
end
|
114
|
-
|
116
|
+
opts.on('--directory=DIR', 'Compile all chapters in DIR.') do |path|
|
115
117
|
mode = :dir
|
116
118
|
basedir = path
|
117
119
|
end
|
118
|
-
|
120
|
+
opts.on('--output-file=FILENAME', 'Write all results into file instead of stdout.') do |filename|
|
119
121
|
output_filename = filename
|
120
122
|
end
|
121
|
-
|
122
|
-
|
123
|
-
|
123
|
+
opts.on('--tabwidth=WIDTH', 'tab width') {|width| config["tabwidth"] = width.to_i }
|
124
|
+
opts.on('--catalogfile=FILENAME', 'Set catalog file') do |catalogfile|
|
125
|
+
config["catalogfile"] = catalogfile
|
126
|
+
end
|
127
|
+
opts.on('--help', 'Prints this message and quit.') do
|
128
|
+
puts opts.help
|
124
129
|
exit 0
|
125
130
|
end
|
126
131
|
begin
|
127
|
-
|
132
|
+
opts.parse!
|
128
133
|
unless target
|
129
134
|
if check_only
|
130
135
|
target = 'html'
|
@@ -134,13 +139,14 @@ def _main
|
|
134
139
|
end
|
135
140
|
rescue OptionParser::ParseError => err
|
136
141
|
error err.message
|
137
|
-
$stderr.puts
|
142
|
+
$stderr.puts opts.help
|
138
143
|
exit 1
|
139
144
|
end
|
140
145
|
|
141
146
|
begin
|
142
|
-
|
143
|
-
|
147
|
+
config["builder"] = target
|
148
|
+
|
149
|
+
ReVIEW.book.config = config
|
144
150
|
compiler = ReVIEW::Compiler.new(load_strategy_class(target, check_only))
|
145
151
|
case mode
|
146
152
|
when :files
|
@@ -151,6 +157,7 @@ def _main
|
|
151
157
|
|
152
158
|
begin
|
153
159
|
ReVIEW::Book::Chapter.intern_pathes(ARGV).each do |chap|
|
160
|
+
chap.book.config = config
|
154
161
|
result = compiler.compile(chap)
|
155
162
|
if output_filename
|
156
163
|
write output_filename, result
|
data/bin/review-epubmaker
CHANGED
@@ -1,1014 +1,44 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# encoding: utf-8
|
3
3
|
#
|
4
|
-
# Copyright (c) 2010-
|
4
|
+
# Copyright (c) 2010-2013 Kenshi Muto and Masayoshi Takahashi
|
5
5
|
#
|
6
6
|
# This program is free software.
|
7
7
|
# You can distribute or modify this program under the terms of
|
8
8
|
# the GNU LGPL, Lesser General Public License version 2.1.
|
9
9
|
# For details of the GNU LGPL, see the file "COPYING".
|
10
10
|
#
|
11
|
-
|
12
|
-
require 'tmpdir'
|
13
|
-
require 'fileutils'
|
14
|
-
require 'yaml'
|
15
|
-
require 'optparse'
|
16
|
-
require 'rexml/document'
|
17
|
-
require 'time'
|
18
|
-
|
19
11
|
require 'pathname'
|
20
|
-
|
12
|
+
require 'optparse'
|
21
13
|
bindir = Pathname.new(__FILE__).realpath.dirname
|
22
14
|
$LOAD_PATH.unshift((bindir + '../lib').realpath)
|
15
|
+
require 'review/epubmaker'
|
16
|
+
require 'review/version'
|
23
17
|
|
24
|
-
|
25
|
-
require 'review'
|
26
|
-
require 'review/i18n'
|
27
|
-
|
28
|
-
require 'review/htmlutils'
|
29
|
-
include ReVIEW::HTMLUtils
|
30
|
-
|
31
|
-
$essential_files = ['top', 'toc', 'colophon']
|
32
|
-
def main
|
33
|
-
if ARGV.size != 1
|
34
|
-
puts "Usage: #{$0} configfile"
|
35
|
-
exit 0
|
36
|
-
end
|
37
|
-
|
38
|
-
yamlfile = ARGV[0]
|
39
|
-
values = ReVIEW::Configure.values.merge(YAML.load_file(yamlfile))
|
40
|
-
bookname = values["bookname"]
|
41
|
-
$essential_files <<= bookname
|
42
|
-
tmp = values["debug"].nil? ? Dir.mktmpdir : "."
|
43
|
-
@bookdir = "#{tmp}/#{bookname}-epub"
|
44
|
-
@epubversion = values["epubversion"] || 2
|
45
|
-
@htmlversion = values["htmlversion"] || 4
|
46
|
-
if @epubversion == 3
|
47
|
-
## if epubversion is 3, htmlversion should be 5
|
48
|
-
@htmlversion = 5
|
49
|
-
end
|
50
|
-
|
51
|
-
if File.exist?("#{bookname}.epub")
|
52
|
-
STDERR.puts "#{bookname}.epub exists. Please remove or rename first."
|
53
|
-
exit 1
|
54
|
-
end
|
55
|
-
if File.exist?(@bookdir)
|
56
|
-
STDERR.puts "#{@bookdir} directory exists. Please remove or rename first."
|
57
|
-
exit 1
|
58
|
-
end
|
59
|
-
|
60
|
-
@identifier = values["urnid"].nil? ? "urn:uuid:#{UUID.create}" : values["urnid"]
|
61
|
-
|
62
|
-
Dir.mkdir(@bookdir)
|
63
|
-
|
64
|
-
# MIME type
|
65
|
-
File.open("#{@bookdir}/mimetype", "w") {|f|
|
66
|
-
f.write "application/epub+zip"
|
67
|
-
}
|
68
|
-
|
69
|
-
Dir.mkdir("#{@bookdir}/OEBPS")
|
70
|
-
# XHTML
|
71
|
-
@manifeststr = ""
|
72
|
-
@ncxstr = ""
|
73
|
-
@tocdesc = Array.new
|
74
|
-
|
75
|
-
basedir = Dir.pwd
|
76
|
-
base_path = Pathname.new(basedir)
|
77
|
-
ReVIEW::Book.load(basedir).parts.each do |part|
|
78
|
-
if part.name.present?
|
79
|
-
if part.file?
|
80
|
-
filename = (base_path + part.path).to_s
|
81
|
-
output_chaps_by_file(filename, values)
|
82
|
-
htmlfile = File.basename(filename.chomp.strip,".*")+".html"
|
83
|
-
else
|
84
|
-
htmlfile = "part_#{part.number}.html"
|
85
|
-
make_part_page(part, htmlfile, values)
|
86
|
-
file_id = "part_#{part.number}"
|
87
|
-
part_name = "#{ReVIEW::I18n.t("part", part.number)} #{part.name.strip}"
|
88
|
-
@tocdesc << [1, htmlfile, nil, part_name]
|
89
|
-
@manifeststr << %Q(<item id="rv-#{file_id}" href="#{htmlfile}" media-type="application/xhtml+xml" />\n)
|
90
|
-
@ncxstr << %Q(<itemref idref="rv-#{file_id}" />\n)
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
part.chapters.each do |chap|
|
95
|
-
filename = Pathname.new(chap.path).relative_path_from(base_path).to_s
|
96
|
-
output_chaps_by_file(filename, values)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
# images
|
101
|
-
if File.exist?("images")
|
102
|
-
allow_exts = values["image_ext"] || %w(png gif jpg jpeg svg ttf woff otf)
|
103
|
-
Dir.mkdir("#{@bookdir}/OEBPS/images")
|
104
|
-
image_files = ReVIEW::MakerHelper.copy_images_to_dir("images", "#{@bookdir}/OEBPS/images", :exts=>allow_exts)
|
105
|
-
image_files.each do |image_file|
|
106
|
-
dirname = File.dirname(image_file)
|
107
|
-
fname = File.basename(image_file)
|
108
|
-
figid = getFigId(dirname.gsub(%r|/|,'-')+"-"+fname)
|
109
|
-
mime = nil
|
110
|
-
fname_pattern = /\.(#{allow_exts.join("|")})$/i
|
111
|
-
next unless fname =~ fname_pattern
|
112
|
-
case fname.downcase.match(fname_pattern)[1]
|
113
|
-
when "png"
|
114
|
-
mime = "image/png"
|
115
|
-
when "gif"
|
116
|
-
mime = "image/gif"
|
117
|
-
when "jpg", "jpeg"
|
118
|
-
mime = "image/jpeg"
|
119
|
-
when "svg"
|
120
|
-
mime = "image/svg+xml"
|
121
|
-
when "ttf", "otf"
|
122
|
-
mime = "application/vnd.ms-opentype"
|
123
|
-
when "woff"
|
124
|
-
mime = "application/font-woff"
|
125
|
-
else
|
126
|
-
raise "unsupported type #{fname}"
|
127
|
-
end
|
128
|
-
if @epubversion == 3 && File.join("images",values["coverimage"]) == image_file
|
129
|
-
properties = ' properties="cover-image"'
|
130
|
-
end
|
131
|
-
@manifeststr << %Q(<item id="#{figid}" href="#{image_file}"#{properties} media-type="#{mime}" />\n)
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
# fonts
|
136
|
-
fontdir = values["fontdir"] || "fonts"
|
137
|
-
if File.exist?(fontdir)
|
138
|
-
font_ext = values["font_ext"]
|
139
|
-
Dir.mkdir("#{@bookdir}/OEBPS/#{fontdir}")
|
140
|
-
font_files = ReVIEW::MakerHelper.copy_images_to_dir(fontdir, "#{@bookdir}/OEBPS/#{fontdir}", :exts=>font_ext)
|
141
|
-
font_files.each do |font_file|
|
142
|
-
dirname = File.dirname(font_file)
|
143
|
-
fname = File.basename(font_file)
|
144
|
-
font_id = "font-"+fname
|
145
|
-
mime = nil
|
146
|
-
fname_pattern = /\.(#{font_ext.join("|")})$/i
|
147
|
-
next unless fname =~ fname_pattern
|
148
|
-
case fname.downcase.match(fname_pattern)[1]
|
149
|
-
when "svg"
|
150
|
-
mime = "image/svg+xml"
|
151
|
-
when "ttf", "otf"
|
152
|
-
mime = "application/vnd.ms-opentype"
|
153
|
-
when "woff"
|
154
|
-
mime = "application/font-woff"
|
155
|
-
else
|
156
|
-
raise "unsupported type #{fname}"
|
157
|
-
end
|
158
|
-
@manifeststr << %Q(<item id="#{font_id}" href="#{font_file}" media-type="#{mime}" />\n)
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
# container
|
163
|
-
Dir.mkdir("#{@bookdir}/META-INF")
|
164
|
-
File.open("#{@bookdir}/META-INF/container.xml", "w") {|f|
|
165
|
-
f.puts <<EOT
|
166
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
167
|
-
<container xmlns="urn:oasis:names:tc:opendocument:xmlns:container" version="1.0">
|
168
|
-
<rootfiles>
|
169
|
-
<rootfile full-path="OEBPS/#{bookname}.opf" media-type="application/oebps-package+xml" />
|
170
|
-
</rootfiles>
|
171
|
-
</container>
|
172
|
-
EOT
|
173
|
-
}
|
174
|
-
|
175
|
-
# opf (meta info)
|
176
|
-
if @epubversion == 3
|
177
|
-
make_opf_filev3(values, bookname)
|
178
|
-
else
|
179
|
-
make_opf_file(values, bookname)
|
180
|
-
end
|
181
|
-
|
182
|
-
# ncx (toc)
|
183
|
-
if values["toc"]
|
184
|
-
File.open("#{@bookdir}/OEBPS/#{bookname}.ncx", "w") {|f|
|
185
|
-
f.puts <<EOT
|
186
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
187
|
-
<ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1">
|
188
|
-
<head>
|
189
|
-
<meta name="dtb:uid" content="#{@identifier}"/>
|
190
|
-
<meta name="dtb:depth" content="1"/>
|
191
|
-
<meta name="dtb:totalPageCount" content="0"/>
|
192
|
-
<meta name="dtb:maxPageNumber" content="0"/>
|
193
|
-
</head>
|
194
|
-
<docTitle>
|
195
|
-
<text>#{values["booktitle"]}</text>
|
196
|
-
</docTitle>
|
197
|
-
<docAuthor>
|
198
|
-
<text>#{values["aut"].nil? ? "" : values["aut"]}</text>
|
199
|
-
</docAuthor>
|
200
|
-
<navMap>
|
201
|
-
<navPoint id="top" playOrder="1">
|
202
|
-
<navLabel>
|
203
|
-
<text>#{values["booktitle"]}</text>
|
204
|
-
</navLabel>
|
205
|
-
<content src="#{bookname}.html"/>
|
206
|
-
</navPoint>
|
207
|
-
EOT
|
208
|
-
|
209
|
-
nav_count = 2
|
210
|
-
|
211
|
-
if values["mytoc"]
|
212
|
-
f.puts <<EOT
|
213
|
-
<navPoint id="toc" playOrder="2">
|
214
|
-
<navLabel>
|
215
|
-
<text>目次</text>
|
216
|
-
</navLabel>
|
217
|
-
<content src="toc.html"/>
|
218
|
-
</navPoint>
|
219
|
-
EOT
|
220
|
-
nav_count = 3
|
221
|
-
end
|
222
|
-
|
223
|
-
@tocdesc.each {|item|
|
224
|
-
level, file, id, content = item
|
225
|
-
# values["level"]
|
226
|
-
next if level > values["toclevel"].to_i
|
227
|
-
indent = ""
|
228
|
-
if level > values["secnolevel"].to_i
|
229
|
-
indent = "- "
|
230
|
-
end
|
231
|
-
fragment_id = (id ? '#'+id : '')
|
232
|
-
f.puts <<EOT
|
233
|
-
<navPoint id="navPoint-#{nav_count}" playOrder="#{nav_count}">
|
234
|
-
<navLabel>
|
235
|
-
<text>#{indent}#{strip_html(content)}</text>
|
236
|
-
</navLabel>
|
237
|
-
<content src="#{file}#{fragment_id}"/>
|
238
|
-
</navPoint>
|
239
|
-
EOT
|
240
|
-
nav_count += 1
|
241
|
-
}
|
242
|
-
f.puts <<EOT
|
243
|
-
</navMap>
|
244
|
-
</ncx>
|
245
|
-
EOT
|
246
|
-
}
|
247
|
-
end
|
248
|
-
|
249
|
-
# Cover page
|
250
|
-
File.open("#{@bookdir}/OEBPS/#{bookname}.html", "w") {|f|
|
251
|
-
f.puts <<EOT
|
252
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
253
|
-
EOT
|
254
|
-
doctype = make_doctype()
|
255
|
-
f.puts doctype
|
256
|
-
f.puts <<EOT
|
257
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="ja">
|
258
|
-
<head>
|
259
|
-
EOT
|
260
|
-
if @htmlversion == 4
|
261
|
-
f.puts <<EOT
|
262
|
-
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
|
263
|
-
<meta http-equiv="Content-Style-Type" content="text/css"/>
|
264
|
-
<link rel="stylesheet" type="text/css" href="#{values["stylesheet"]}"/>
|
265
|
-
<meta name="generator" content="Re:VIEW EPUB Maker"/>
|
266
|
-
EOT
|
267
|
-
else
|
268
|
-
f.puts <<EOT
|
269
|
-
<meta charset="UTF-8" />
|
270
|
-
<link rel="stylesheet" type="text/css" href="#{values["stylesheet"]}"/>
|
271
|
-
<meta name="generator" content="Re:VIEW EPUB Maker"/>
|
272
|
-
EOT
|
273
|
-
end
|
274
|
-
f.puts <<EOT
|
275
|
-
<title>#{values["booktitle"]}</title>
|
276
|
-
</head>
|
277
|
-
<body>
|
278
|
-
EOT
|
279
|
-
if !values["coverfile"].nil? && File.exist?(values["coverfile"])
|
280
|
-
File.open(values["coverfile"]) {|f2|
|
281
|
-
f2.each_line {|l|
|
282
|
-
f.puts l
|
283
|
-
}
|
284
|
-
}
|
285
|
-
else
|
286
|
-
f.puts <<EOT
|
287
|
-
<h1>#{values["booktitle"]}</h1>
|
288
|
-
EOT
|
289
|
-
end
|
290
|
-
|
291
|
-
f.puts <<EOT
|
292
|
-
</body>
|
293
|
-
</html>
|
294
|
-
EOT
|
295
|
-
}
|
296
|
-
|
297
|
-
if values["backcoverfile"]
|
298
|
-
make_backcover_image(bookname, values)
|
299
|
-
end
|
18
|
+
rv = ReVIEW::EPUBMaker.new
|
300
19
|
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
f.puts doctype
|
308
|
-
f.puts <<EOT
|
309
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="ja">
|
310
|
-
<head>
|
311
|
-
EOT
|
312
|
-
if @htmlversion == 4
|
313
|
-
f.puts <<EOT
|
314
|
-
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
|
315
|
-
<meta http-equiv="Content-Style-Type" content="text/css"/>
|
316
|
-
<link rel="stylesheet" type="text/css" href="#{values["stylesheet"]}"/>
|
317
|
-
<meta name="generator" content="Re:VIEW EPUB Maker"/>
|
318
|
-
EOT
|
319
|
-
else
|
320
|
-
f.puts <<EOT
|
321
|
-
<meta charset="UTF-8" />
|
322
|
-
<link rel="stylesheet" type="text/css" href="#{values["stylesheet"]}"/>
|
323
|
-
<meta name="generator" content="Re:VIEW EPUB Maker"/>
|
324
|
-
EOT
|
325
|
-
end
|
326
|
-
f.puts <<EOT
|
327
|
-
<title>#{values["booktitle"]}</title>
|
328
|
-
</head>
|
329
|
-
<body>
|
330
|
-
EOT
|
331
|
-
if !values["titlepagefile"].nil? && File.exist?(values["titlepagefile"])
|
332
|
-
File.open(values["titlepagefile"]) {|f2|
|
333
|
-
f2.each_line {|l|
|
334
|
-
f.puts l
|
335
|
-
}
|
336
|
-
}
|
337
|
-
else
|
338
|
-
f.puts <<EOT
|
339
|
-
<h1 class="tp-title">#{values["booktitle"]}</h1>
|
340
|
-
EOT
|
341
|
-
if values["aut"]
|
342
|
-
f.puts <<EOT
|
343
|
-
<p>
|
344
|
-
<br />
|
345
|
-
<br />
|
346
|
-
</p>
|
347
|
-
<h2 class="tp-author">#{values["aut"]}</h2>
|
348
|
-
EOT
|
349
|
-
end
|
350
|
-
if values["prt"]
|
351
|
-
f.puts <<EOT
|
352
|
-
<p>
|
353
|
-
<br />
|
354
|
-
<br />
|
355
|
-
<br />
|
356
|
-
<br />
|
357
|
-
</p>
|
358
|
-
<h3 class="tp-publisher">#{values["prt"]}</h3>
|
359
|
-
EOT
|
360
|
-
end
|
361
|
-
end
|
362
|
-
|
363
|
-
f.puts <<EOT
|
364
|
-
</body>
|
365
|
-
</html>
|
366
|
-
EOT
|
367
|
-
}
|
368
|
-
|
369
|
-
# Additional toc page
|
370
|
-
if values["toc"] && values["mytoc"]
|
371
|
-
File.open("#{@bookdir}/OEBPS/toc.html", "w") {|f|
|
372
|
-
if @epubversion == 3
|
373
|
-
listelm = "ol"
|
374
|
-
else
|
375
|
-
listelm = "ul"
|
376
|
-
end
|
377
|
-
f.puts <<EOT
|
378
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
379
|
-
EOT
|
380
|
-
doctype = make_doctype()
|
381
|
-
f.puts doctype
|
382
|
-
f.puts <<EOT
|
383
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="ja">
|
384
|
-
<head>
|
385
|
-
EOT
|
386
|
-
if @htmlversion == 4
|
387
|
-
f.puts <<EOT
|
388
|
-
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
|
389
|
-
<meta http-equiv="Content-Style-Type" content="text/css"/>
|
390
|
-
<link rel="stylesheet" type="text/css" href="#{values["stylesheet"]}"/>
|
391
|
-
<meta name="generator" content="Re:VIEW EPUB Maker"/>
|
392
|
-
EOT
|
393
|
-
else
|
394
|
-
f.puts <<EOT
|
395
|
-
<meta charset="UTF-8" />
|
396
|
-
<link rel="stylesheet" type="text/css" href="#{values["stylesheet"]}"/>
|
397
|
-
<meta name="generator" content="Re:VIEW EPUB Maker"/>
|
398
|
-
EOT
|
399
|
-
end
|
400
|
-
f.puts <<EOT
|
401
|
-
<title>目次</title>
|
402
|
-
</head>
|
403
|
-
<body>
|
404
|
-
EOT
|
405
|
-
f.puts %q(<nav epub:type="toc" id="toc">) if @epubversion == 3
|
406
|
-
f.puts <<EOT
|
407
|
-
<h1>目次</h1>
|
408
|
-
<#{listelm} class=\"toc-h1\">
|
409
|
-
EOT
|
410
|
-
current = 1
|
411
|
-
init_item = true
|
412
|
-
@tocdesc.each {|item|
|
413
|
-
level, file, id, content = item
|
414
|
-
# values["level"]
|
415
|
-
next if level > values["toclevel"].to_i
|
416
|
-
if level > current
|
417
|
-
current += 1
|
418
|
-
f.puts ""
|
419
|
-
f.puts "<#{listelm} class=\"toc-h#{current}\">"
|
420
|
-
while current < level
|
421
|
-
current += 1
|
422
|
-
f.puts "<li>"
|
423
|
-
f.puts "<#{listelm} class=\"toc-h#{current}\">"
|
424
|
-
end
|
425
|
-
elsif level < current
|
426
|
-
current -= 1
|
427
|
-
f.puts "</li>"
|
428
|
-
f.puts "</#{listelm}>"
|
429
|
-
f.puts "</li>"
|
430
|
-
while current > level
|
431
|
-
current -= 1
|
432
|
-
f.puts "</#{listelm}>"
|
433
|
-
f.puts "</li>"
|
434
|
-
end
|
435
|
-
elsif init_item
|
436
|
-
# noop
|
437
|
-
else
|
438
|
-
f.puts "</li>"
|
439
|
-
end
|
440
|
-
fragment_id = (id ? '#'+id : '')
|
441
|
-
f.write "<li><a href=\"#{file}#{fragment_id}\">#{strip_html(content)}</a>"
|
442
|
-
init_item = false
|
443
|
-
}
|
444
|
-
|
445
|
-
(current - 1).downto(1) {|n|
|
446
|
-
f.puts "</li>"
|
447
|
-
f.puts "</#{listelm}>"
|
448
|
-
}
|
449
|
-
if !init_item
|
450
|
-
f.puts "</li>"
|
451
|
-
end
|
452
|
-
|
453
|
-
f.puts "</#{listelm}>"
|
454
|
-
f.puts %q(</nav>) if @epubversion == 3
|
455
|
-
f.puts <<EOT
|
456
|
-
</body>
|
457
|
-
</html>
|
458
|
-
EOT
|
459
|
-
}
|
460
|
-
end
|
461
|
-
|
462
|
-
# stylesheet
|
463
|
-
if File.exist?(values["stylesheet"])
|
464
|
-
FileUtils.cp values["stylesheet"], "#{@bookdir}/OEBPS/#{values["stylesheet"]}"
|
465
|
-
else
|
466
|
-
File.open("#{@bookdir}/OEBPS/#{values["stylesheet"]}", "w") {|f|
|
467
|
-
f.puts <<EOT
|
468
|
-
/* sample style sheet for epub */
|
469
|
-
@charset "utf-8";
|
470
|
-
|
471
|
-
body {
|
472
|
-
}
|
473
|
-
EOT
|
474
|
-
}
|
475
|
-
end
|
476
|
-
|
477
|
-
# Colophon page
|
478
|
-
if values["colophon"]
|
479
|
-
make_colophon_page(tmp, bookname, values)
|
480
|
-
end
|
481
|
-
|
482
|
-
# hook
|
483
|
-
if !values["posthook"].nil? && !values["posthook"].empty? && FileTest.executable?(values["posthook"])
|
484
|
-
fork {
|
485
|
-
exec(values["posthook"], @bookdir, Dir.pwd, yamlfile)
|
486
|
-
}
|
487
|
-
Process.waitall
|
488
|
-
end
|
489
|
-
|
490
|
-
# Zip epubファイルの作成。mimetypeは圧縮しないようにする
|
491
|
-
fork {
|
492
|
-
basedir = Dir.pwd
|
493
|
-
Dir.chdir(@bookdir) {|d|
|
494
|
-
exec("zip", "-0X", "#{basedir}/#{bookname}.epub", "mimetype")
|
495
|
-
}
|
496
|
-
}
|
497
|
-
Process.waitall
|
498
|
-
fork {
|
499
|
-
basedir = Dir.pwd
|
500
|
-
Dir.chdir(@bookdir) {|d|
|
501
|
-
exec("zip", "-Xr9D", "#{basedir}/#{bookname}.epub", "META-INF", "OEBPS")
|
502
|
-
}
|
503
|
-
}
|
504
|
-
Process.waitall
|
505
|
-
|
506
|
-
FileUtils.rm_r(tmp) if values["debug"].nil?
|
20
|
+
opts = OptionParser.new
|
21
|
+
opts.version = ReVIEW::VERSION
|
22
|
+
opts.banner = "Usage: #{File.basename($0)} [options] YAML_filename [export_filename]"
|
23
|
+
opts.on('--help', 'Prints this message and quit.') do
|
24
|
+
puts opts.help
|
25
|
+
exit 0
|
507
26
|
end
|
508
27
|
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
28
|
+
begin
|
29
|
+
opts.parse!
|
30
|
+
rescue OptionParser::ParseError => err
|
31
|
+
$stderr.puts err.message
|
32
|
+
$stderr.puts opts.help
|
33
|
+
exit 1
|
515
34
|
end
|
516
35
|
|
517
36
|
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
522
|
-
<package version="2.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId">
|
523
|
-
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
|
524
|
-
<dc:title>#{values["booktitle"]}</dc:title>
|
525
|
-
EOT
|
526
|
-
|
527
|
-
f.puts %Q(<dc:creator opf:role="aut">#{values["aut"]}</dc:creator>) unless values["aut"].nil? # FIXME: support multiple members
|
528
|
-
|
529
|
-
f.puts %Q(<dc:publisher>#{values["prt"]}</dc:publisher>) unless values["prt"].nil?
|
530
|
-
|
531
|
-
f.puts %Q(<dc:date>#{values["date"]}</dc:date>) unless values["date"].nil?
|
532
|
-
f.puts %Q(<dc:rights>#{values["rights"]}</dc:rights>) unless values["rights"].nil?
|
533
|
-
|
534
|
-
f.puts %Q(<dc:contributor opf:role="asn">#{values["asn"]}</dc:contributor>) unless values["asn"].nil?
|
535
|
-
f.puts %Q(<dc:contributor opf:role="ant">#{values["ant"]}</dc:contributor>) unless values["ant"].nil?
|
536
|
-
f.puts %Q(<dc:contributor opf:role="clb">#{values["clb"]}</dc:contributor>) unless values["clb"].nil?
|
537
|
-
f.puts %Q(<dc:contributor opf:role="edt">#{values["edt"]}</dc:contributor>) unless values["edt"].nil?
|
538
|
-
f.puts %Q(<dc:contributor opf:role="dsr">#{values["dsr"]}</dc:contributor>) unless values["dsr"].nil?
|
539
|
-
f.puts %Q(<dc:contributor opf:role="ill">#{values["ill"]}</dc:contributor>) unless values["ill"].nil?
|
540
|
-
f.puts %Q(<dc:contributor opf:role="pht">#{values["pht"]}</dc:contributor>) unless values["pht"].nil?
|
541
|
-
f.puts %Q(<dc:contributor opf:role="trl">#{values["trl"]}</dc:contributor>) unless values["trl"].nil?
|
542
|
-
|
543
|
-
f.puts %Q(<dc:description>#{values["description"]}</dc:description>) unless values["description"].nil?
|
544
|
-
|
545
|
-
if values["coverimage"]
|
546
|
-
f.puts %Q(<meta name="cover" content="#{getFigId("images-"+values["coverimage"])}"/>)
|
547
|
-
end
|
548
|
-
f.puts <<EOT
|
549
|
-
<dc:language>ja</dc:language>
|
550
|
-
<dc:identifier id="BookId">#{@identifier}</dc:identifier>
|
551
|
-
</metadata>
|
552
|
-
<manifest>
|
553
|
-
EOT
|
554
|
-
|
555
|
-
if values["toc"]
|
556
|
-
f.puts <<EOT
|
557
|
-
<item id="ncx" href="#{bookname}.ncx" media-type="application/x-dtbncx+xml" />
|
558
|
-
EOT
|
559
|
-
end
|
560
|
-
|
561
|
-
f.puts <<EOT
|
562
|
-
<item id="style" href="#{values["stylesheet"]}" media-type="text/css" />
|
563
|
-
<item id="#{bookname}" href="#{bookname}.html" media-type="application/xhtml+xml" />
|
564
|
-
<item id="top" href="top.html" media-type="application/xhtml+xml" />
|
565
|
-
EOT
|
566
|
-
|
567
|
-
if values["toc"] && values["mytoc"]
|
568
|
-
f.puts <<EOT
|
569
|
-
<item id="toc" href="toc.html" media-type="application/xhtml+xml" />
|
570
|
-
EOT
|
571
|
-
end
|
572
|
-
|
573
|
-
f.puts @manifeststr
|
574
|
-
if values["colophon"]
|
575
|
-
f.puts <<EOT
|
576
|
-
<item id="colophon" href="colophon.html" media-type="application/xhtml+xml" />
|
577
|
-
EOT
|
578
|
-
end
|
579
|
-
if values["backcoverfile"]
|
580
|
-
f.puts <<EOT
|
581
|
-
<item id="backcover" href="#{values["backcoverfile"]}" media-type="application/xhtml+xml" />
|
582
|
-
EOT
|
583
|
-
end
|
584
|
-
|
585
|
-
if values["cover_linear"] && values["cover_linear"] != "no"
|
586
|
-
cover_linear = "yes"
|
587
|
-
else
|
588
|
-
cover_linear = "no"
|
589
|
-
end
|
590
|
-
|
591
|
-
f.puts <<EOT
|
592
|
-
</manifest>
|
593
|
-
<spine toc="ncx">
|
594
|
-
<itemref idref="#{bookname}" linear="#{cover_linear}" />
|
595
|
-
<itemref idref="top" />
|
596
|
-
EOT
|
597
|
-
|
598
|
-
if values["toc"] && values["mytoc"]
|
599
|
-
f.puts <<EOT
|
600
|
-
<itemref idref="toc" />
|
601
|
-
EOT
|
602
|
-
end
|
603
|
-
|
604
|
-
f.puts @ncxstr
|
605
|
-
if values["colophon"]
|
606
|
-
f.puts <<EOT
|
607
|
-
<itemref idref="colophon" />
|
608
|
-
EOT
|
609
|
-
end
|
610
|
-
if values["backcoverfile"]
|
611
|
-
f.puts <<EOT
|
612
|
-
<itemref idref="backcover" />
|
613
|
-
EOT
|
614
|
-
end
|
615
|
-
f.puts <<EOT
|
616
|
-
</spine>
|
617
|
-
<guide>
|
618
|
-
EOT
|
619
|
-
|
620
|
-
if values["titlepage"]
|
621
|
-
f.puts <<EOT
|
622
|
-
<reference type="cover" title="表紙" href="#{bookname}.html"/>
|
623
|
-
<reference type="title-page" title="Title Page" href="top.html"/>
|
624
|
-
EOT
|
625
|
-
end
|
626
|
-
|
627
|
-
if values["toc"] && values["mytoc"]
|
628
|
-
f.puts <<EOT
|
629
|
-
<reference type="toc" title="目次" href="toc.html"/>
|
630
|
-
EOT
|
631
|
-
end
|
632
|
-
f.puts <<EOT
|
633
|
-
</guide>
|
634
|
-
</package>
|
635
|
-
EOT
|
636
|
-
}
|
637
|
-
end
|
638
|
-
|
639
|
-
def make_opf_filev3(values, bookname)
|
640
|
-
File.open("#{@bookdir}/OEBPS/#{bookname}.opf", "w") {|f|
|
641
|
-
f.puts <<EOT
|
642
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
643
|
-
<package version="3.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId">
|
644
|
-
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
|
645
|
-
<dc:title>#{values["booktitle"]}</dc:title>
|
646
|
-
EOT
|
647
|
-
unless values["aut"].nil? # FIXME: support multiple members
|
648
|
-
f.puts %Q(<dc:creator id="author">#{values["aut"]}</dc:creator>)
|
649
|
-
f.puts %Q(<meta refines="#author" property="role" scheme="marc:relators" id="role">aut</meta>)
|
650
|
-
end
|
651
|
-
f.puts %Q(<dc:publisher id="publisher">#{values["prt"]}</dc:publisher>) unless values["prt"].nil?
|
652
|
-
|
653
|
-
f.puts %Q(<dc:date>#{values["date"]}</dc:date>) unless values["date"].nil?
|
654
|
-
f.puts %Q(<dc:rights>#{values["rights"]}</dc:rights>) unless values["rights"].nil?
|
655
|
-
|
656
|
-
%w(asn ant clb edt dsr ill pht trl).each do |attr|
|
657
|
-
unless values[attr].nil?
|
658
|
-
f.puts %Q(<dc:contributor id="#{attr}">#{values[attr]}</dc:contributor>)
|
659
|
-
f.puts %Q(<meta refines='##{attr}' property='role' scheme='marc:relators'>#{attr}</meta>)
|
660
|
-
end
|
661
|
-
end
|
662
|
-
f.puts %Q(<dc:description>#{values["description"]}</dc:description>) unless values["description"].nil?
|
663
|
-
f.puts %Q(<meta property="dcterms:modified">#{Time.now.utc.iso8601(0)}</meta>)
|
664
|
-
if values["coverimage"]
|
665
|
-
f.puts %Q(<meta name="cover" content="#{getFigId("images-"+values["coverimage"])}"/>)
|
666
|
-
end
|
667
|
-
f.puts <<EOT
|
668
|
-
<dc:language>ja</dc:language>
|
669
|
-
<dc:identifier id="BookId">#{@identifier}</dc:identifier>
|
670
|
-
</metadata>
|
671
|
-
<manifest>
|
672
|
-
EOT
|
673
|
-
|
674
|
-
if values["toc"]
|
675
|
-
f.puts <<EOT
|
676
|
-
<item id="ncx" href="#{bookname}.ncx" media-type="application/x-dtbncx+xml" />
|
677
|
-
EOT
|
678
|
-
end
|
679
|
-
|
680
|
-
f.puts <<EOT
|
681
|
-
<item id="style" href="#{values["stylesheet"]}" media-type="text/css" />
|
682
|
-
<item id="#{bookname}" href="#{bookname}.html" media-type="application/xhtml+xml" />
|
683
|
-
<item id="top" href="top.html" media-type="application/xhtml+xml" />
|
684
|
-
EOT
|
685
|
-
|
686
|
-
if values["toc"] && values["mytoc"]
|
687
|
-
f.puts <<EOT
|
688
|
-
<item id="toc" href="toc.html" properties="nav" media-type="application/xhtml+xml" />
|
689
|
-
EOT
|
690
|
-
end
|
691
|
-
|
692
|
-
f.puts @manifeststr
|
693
|
-
if values["colophon"]
|
694
|
-
f.puts <<EOT
|
695
|
-
<item id="colophon" href="colophon.html" media-type="application/xhtml+xml" />
|
696
|
-
EOT
|
697
|
-
end
|
698
|
-
|
699
|
-
if values["backcoverfile"]
|
700
|
-
f.puts <<EOT
|
701
|
-
<item id="backcover" href="#{values["backcoverfile"]}" media-type="application/xhtml+xml" />
|
702
|
-
EOT
|
703
|
-
end
|
704
|
-
|
705
|
-
if values["cover_linear"] && values["cover_linear"] != "no"
|
706
|
-
cover_linear = "yes"
|
707
|
-
else
|
708
|
-
cover_linear = "no"
|
709
|
-
end
|
710
|
-
|
711
|
-
f.puts <<EOT
|
712
|
-
</manifest>
|
713
|
-
<spine toc="ncx">
|
714
|
-
<itemref idref="#{bookname}" linear="#{cover_linear}" />
|
715
|
-
<itemref idref="top" />
|
716
|
-
EOT
|
717
|
-
|
718
|
-
if values["toc"] && values["mytoc"]
|
719
|
-
f.puts <<EOT
|
720
|
-
<itemref idref="toc" />
|
721
|
-
EOT
|
722
|
-
end
|
723
|
-
|
724
|
-
f.puts @ncxstr
|
725
|
-
if values["colophon"]
|
726
|
-
f.puts <<EOT
|
727
|
-
<itemref idref="colophon" />
|
728
|
-
EOT
|
729
|
-
end
|
730
|
-
if values["backcoverfile"]
|
731
|
-
f.puts <<EOT
|
732
|
-
<itemref idref="backcover" />
|
733
|
-
EOT
|
734
|
-
end
|
735
|
-
f.puts <<EOT
|
736
|
-
</spine>
|
737
|
-
<guide>
|
738
|
-
EOT
|
739
|
-
|
740
|
-
if values["titlepage"]
|
741
|
-
f.puts <<EOT
|
742
|
-
<reference type="cover" title="表紙" href="#{bookname}.html"/>
|
743
|
-
<reference type="title-page" title="Title Page" href="top.html"/>
|
744
|
-
EOT
|
745
|
-
end
|
746
|
-
|
747
|
-
if values["toc"] && values["mytoc"]
|
748
|
-
f.puts <<EOT
|
749
|
-
<reference type="toc" title="目次" href="toc.html"/>
|
750
|
-
EOT
|
751
|
-
end
|
752
|
-
f.puts <<EOT
|
753
|
-
</guide>
|
754
|
-
</package>
|
755
|
-
EOT
|
756
|
-
}
|
757
|
-
end
|
758
|
-
|
759
|
-
|
760
|
-
def output_chaps(chapsfile, values)
|
761
|
-
File.open(chapsfile) {|chaps|
|
762
|
-
chaps.each_line {|l|
|
763
|
-
next if l =~ /^#/
|
764
|
-
output_chaps_by_file(l, values)
|
765
|
-
}
|
766
|
-
}
|
767
|
-
end
|
768
|
-
|
769
|
-
def output_chaps_by_file(l, values)
|
770
|
-
file_id = File.basename(l.chomp.strip,".*")
|
771
|
-
if (idx = $essential_files.index(file_id))
|
772
|
-
if idx == $essential_files.size - 1
|
773
|
-
STDERR.puts "#{file_id} is book name. Please rename #{l.chomp.strip}."
|
774
|
-
else
|
775
|
-
STDERR.puts "#{file_id} is special name. Please rename #{l.chomp.strip}."
|
776
|
-
end
|
777
|
-
exit 1
|
778
|
-
end
|
779
|
-
filename = "#{file_id}.html"
|
780
|
-
fork {
|
781
|
-
STDOUT.reopen("#{@bookdir}/OEBPS/#{filename}")
|
782
|
-
exec("review-compile --target=html --level=#{values["secnolevel"]} --htmlversion=#{values["htmlversion"]} --epubversion=#{values["epubversion"]} #{values["params"]} #{l}")
|
783
|
-
}
|
784
|
-
Process.waitall
|
785
|
-
getanchors("#{@bookdir}/OEBPS/#{filename}")
|
786
|
-
if @epubversion == 3 && include_mathml?("#{@bookdir}/OEBPS/#{filename}")
|
787
|
-
@manifeststr << %Q(<item id="rv-#{file_id}" href="#{filename}" properties="mathml" media-type="application/xhtml+xml" />\n)
|
788
|
-
else
|
789
|
-
@manifeststr << %Q(<item id="rv-#{file_id}" href="#{filename}" media-type="application/xhtml+xml" />\n)
|
790
|
-
end
|
791
|
-
@ncxstr << %Q(<itemref idref="rv-#{file_id}" />\n)
|
37
|
+
if ARGV.size < 1 || !File.exist?(ARGV[0])
|
38
|
+
puts opts.help
|
39
|
+
exit 1
|
792
40
|
end
|
793
41
|
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
return true
|
798
|
-
}
|
799
|
-
return false
|
800
|
-
}
|
801
|
-
rescue
|
802
|
-
false
|
803
|
-
end
|
804
|
-
|
805
|
-
def getFigId(filename)
|
806
|
-
figid = filename.sub(/\.(png|gif|jpg|jpeg|svg)$/, '')
|
807
|
-
"fig-#{figid}"
|
808
|
-
end
|
809
|
-
|
810
|
-
def getTitle(filename)
|
811
|
-
File.open(filename) {|f|
|
812
|
-
return REXML::Document.new(f).elements["//html/head/title"].text
|
813
|
-
}
|
814
|
-
end
|
815
|
-
|
816
|
-
def getanchors(filename)
|
817
|
-
File.open(filename) {|f|
|
818
|
-
file = filename.sub(/.+\//, '')
|
819
|
-
f.each_line {|l|
|
820
|
-
if l =~ /\A<h(\d)[^>]*><a id=\"(.+?)\"><\/a>(.+?)<\/h/
|
821
|
-
# level, ID, content
|
822
|
-
@tocdesc << [$1.to_i, file, $2, $3]
|
823
|
-
end
|
824
|
-
}
|
825
|
-
}
|
826
|
-
end
|
827
|
-
|
828
|
-
def make_colophon_page(tmp,bookname,values)
|
829
|
-
|
830
|
-
header = <<EOT
|
831
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
832
|
-
EOT
|
833
|
-
header += make_doctype()
|
834
|
-
header += <<EOT
|
835
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="ja">
|
836
|
-
<head>
|
837
|
-
EOT
|
838
|
-
if @htmlversion == 4
|
839
|
-
header += <<EOT
|
840
|
-
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
|
841
|
-
<meta http-equiv="Content-Style-Type" content="text/css"/>
|
842
|
-
<link rel="stylesheet" type="text/css" href="#{values["stylesheet"]}"/>
|
843
|
-
<meta name="generator" content="Re:VIEW EPUB Maker"/>
|
844
|
-
EOT
|
845
|
-
else
|
846
|
-
header += <<EOT
|
847
|
-
<meta charset="UTF-8" />
|
848
|
-
<link rel="stylesheet" type="text/css" href="#{values["stylesheet"]}"/>
|
849
|
-
<meta name="generator" content="Re:VIEW EPUB Maker"/>
|
850
|
-
EOT
|
851
|
-
end
|
852
|
-
header += <<EOT
|
853
|
-
<title>#{values["booktitle"]}</title>
|
854
|
-
</head>
|
855
|
-
<body>
|
856
|
-
EOT
|
857
|
-
|
858
|
-
footer = <<EOT
|
859
|
-
</body>
|
860
|
-
</html>
|
861
|
-
EOT
|
862
|
-
|
863
|
-
colophon_path = "#{@bookdir}/OEBPS/colophon.html"
|
864
|
-
colophon = values["colophon"]
|
865
|
-
if colophon.kind_of?(String) && File.exist?(colophon)
|
866
|
-
File.open(colophon_path, "w") {|f|
|
867
|
-
f.puts header
|
868
|
-
File.open(values["colophon"]) {|f2|
|
869
|
-
f2.each_line {|l|
|
870
|
-
f.puts l
|
871
|
-
}
|
872
|
-
}
|
873
|
-
f.puts footer
|
874
|
-
}
|
875
|
-
else
|
876
|
-
File.open(colophon_path, "w") {|f|
|
877
|
-
f.puts header
|
878
|
-
f.puts <<EOT
|
879
|
-
<div class="colophon">
|
880
|
-
<p class="title">#{values["booktitle"]}</p>
|
881
|
-
EOT
|
882
|
-
if values["pubhistory"]
|
883
|
-
f.puts %Q[<div class="pubhistory">\n<p>#{values["pubhistory"].gsub(/\n/,"<br />")}</p>\n</div>]
|
884
|
-
end
|
885
|
-
|
886
|
-
f.puts <<EOT
|
887
|
-
<table>
|
888
|
-
EOT
|
889
|
-
f.puts %Q[<tr>\n <th>著 者</th><td>#{values["aut"]}</td>\n</tr>] if values["aut"]
|
890
|
-
f.puts %Q[<tr>\n <th>監 修</th><td>#{values["csl"]}</td>\n</tr>] if values["csl"]
|
891
|
-
f.puts %Q[<tr>\n <th>翻 訳</th><td>#{values["trl"]}</td>\n</tr>] if values["trl"]
|
892
|
-
f.puts %Q[<tr>\n <th>デザイン</th><td>#{values["dsr"]}</td>\n</tr>] if values["dsr"]
|
893
|
-
f.puts %Q[<tr>\n <th>イラスト</th><td>#{values["ill"]}</td>\n</tr>] if values["ill"]
|
894
|
-
f.puts %Q[<tr>\n <th>表 紙</th><td>#{values["cov"]}</td>\n</tr>] if values["cov"]
|
895
|
-
f.puts %Q[<tr>\n <th>編 集</th><td>#{values["edt"]}</td>\n</tr>] if values["edt"]
|
896
|
-
f.puts %Q[<tr>\n <th>発行所</th><td>#{values["prt"]}</td>\n</tr>] if values["prt"]
|
897
|
-
f.puts <<EOT
|
898
|
-
</table>
|
899
|
-
EOT
|
900
|
-
if values["rights"]
|
901
|
-
f.puts %Q[<p class="copyright">#{values["rights"]}</p>]
|
902
|
-
end
|
903
|
-
|
904
|
-
f.puts "</div>"
|
905
|
-
f.puts footer
|
906
|
-
}
|
907
|
-
end
|
908
|
-
end
|
909
|
-
|
910
|
-
def make_part_page(part, filename, values)
|
911
|
-
File.open("#{@bookdir}/OEBPS/#{filename}", "w") {|f|
|
912
|
-
f.puts <<-EOT
|
913
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
914
|
-
EOT
|
915
|
-
doctype = make_doctype()
|
916
|
-
f.puts doctype
|
917
|
-
if @htmlversion == 4
|
918
|
-
header = <<-EOT
|
919
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="ja">
|
920
|
-
<head>
|
921
|
-
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
|
922
|
-
<meta http-equiv="Content-Style-Type" content="text/css"/>
|
923
|
-
<link rel="stylesheet" type="text/css" href="#{values["stylesheet"]}"/>
|
924
|
-
<meta name="generator" content="Re:VIEW EPUB Maker"/>
|
925
|
-
<title>#{values["booktitle"]}</title>
|
926
|
-
</head>
|
927
|
-
EOT
|
928
|
-
else
|
929
|
-
header = <<-EOT
|
930
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="ja">
|
931
|
-
<head>
|
932
|
-
<meta charset="UTF-8" />
|
933
|
-
<link rel="stylesheet" type="text/css" href="#{values["stylesheet"]}"/>
|
934
|
-
<meta name="generator" content="Re:VIEW EPUB Maker"/>
|
935
|
-
<title>#{values["booktitle"]}</title>
|
936
|
-
</head>
|
937
|
-
EOT
|
938
|
-
end
|
939
|
-
f.puts header
|
940
|
-
|
941
|
-
f.puts <<-EOT
|
942
|
-
<body>
|
943
|
-
<h1 class="part-number">#{ReVIEW::I18n.t("part", part.number)}</h1>
|
944
|
-
EOT
|
945
|
-
|
946
|
-
if part.name.strip.present?
|
947
|
-
f.puts <<-EOT
|
948
|
-
<h2 class="part-title">#{part.name.strip}</h2>
|
949
|
-
EOT
|
950
|
-
end
|
951
|
-
|
952
|
-
f.puts <<-EOT
|
953
|
-
</body>
|
954
|
-
</html>
|
955
|
-
EOT
|
956
|
-
}
|
957
|
-
end
|
958
|
-
|
959
|
-
def make_backcover_image(bookname, values)
|
960
|
-
backcoverfile = values["backcoverfile"]
|
961
|
-
File.open("#{@bookdir}/OEBPS/#{backcoverfile}", "w") {|f|
|
962
|
-
f.puts <<EOT
|
963
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
964
|
-
EOT
|
965
|
-
doctype = make_doctype()
|
966
|
-
f.puts doctype
|
967
|
-
f.puts <<EOT
|
968
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="ja">
|
969
|
-
<head>
|
970
|
-
EOT
|
971
|
-
if @htmlversion == 4
|
972
|
-
f.puts <<EOT
|
973
|
-
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
|
974
|
-
<meta http-equiv="Content-Style-Type" content="text/css"/>
|
975
|
-
<link rel="stylesheet" type="text/css" href="#{values["stylesheet"]}"/>
|
976
|
-
<meta name="generator" content="Re:VIEW EPUB Maker"/>
|
977
|
-
EOT
|
978
|
-
else
|
979
|
-
f.puts <<EOT
|
980
|
-
<meta charset="UTF-8" />
|
981
|
-
<link rel="stylesheet" type="text/css" href="#{values["stylesheet"]}"/>
|
982
|
-
<meta name="generator" content="Re:VIEW EPUB Maker"/>
|
983
|
-
EOT
|
984
|
-
end
|
985
|
-
f.puts <<EOT
|
986
|
-
<title>#{values["booktitle"]}</title>
|
987
|
-
</head>
|
988
|
-
<body>
|
989
|
-
EOT
|
990
|
-
if File.exist?(backcoverfile)
|
991
|
-
File.open(backcoverfile) {|f2|
|
992
|
-
f2.each_line {|l|
|
993
|
-
f.puts l
|
994
|
-
}
|
995
|
-
}
|
996
|
-
else
|
997
|
-
f.puts <<EOT
|
998
|
-
<div id="back-cover-image" class="full">
|
999
|
-
<img src="images/#{backcoverfile}" alt="back-cover"/>
|
1000
|
-
</div>
|
1001
|
-
EOT
|
1002
|
-
end
|
1003
|
-
|
1004
|
-
f.puts <<EOT
|
1005
|
-
</body>
|
1006
|
-
</html>
|
1007
|
-
EOT
|
1008
|
-
}
|
1009
|
-
end
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
main
|
42
|
+
yaml_file = ARGV[0]
|
43
|
+
bookname = ARGV[1]
|
44
|
+
rv.produce(yaml_file, bookname)
|