sc2epub 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +3 -0
- data/lib/sc2epub.rb +1 -1
- data/lib/sc2epub/converter.rb +3 -1
- data/lib/sc2epub/main.rb +15 -5
- data/lib/sc2epub/template.rb +7 -1
- data/lib/sc2epub/template/xhtml.tmpl +3 -2
- metadata +3 -3
data/CHANGES
CHANGED
data/lib/sc2epub.rb
CHANGED
data/lib/sc2epub/converter.rb
CHANGED
@@ -31,7 +31,9 @@ class Sc2epub::Converter
|
|
31
31
|
items = ''; c=0;
|
32
32
|
nvitems = ''
|
33
33
|
cover = File::join(File::dirname(__FILE__), 'cover.jpg')
|
34
|
-
|
34
|
+
#prettify = File::join(File::dirname(__FILE__), 'prettify')
|
35
|
+
#::FileUtils::cp_r(prettify, output)
|
36
|
+
::FileUtils::cp(cover, output)
|
35
37
|
@indexes.each do |data|
|
36
38
|
title = data[:name]
|
37
39
|
link = data[:src]
|
data/lib/sc2epub/main.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
class Sc2epub::Main
|
2
2
|
require 'optparse'
|
3
3
|
def main
|
4
|
-
|
5
|
-
output = ARGV[1]
|
6
|
-
opts = OptionParser.new("Usage: #{File::basename($0)} SOURCE_DIR OUTPUT_DIR PROJECT_NAME")
|
4
|
+
opts = OptionParser.new("Usage: #{File::basename($0)} SOURCE_DIR [OUTPUT_DIR] [PROJECT_NAME]")
|
7
5
|
opts.on("-v", "--version", "show version") do
|
8
6
|
puts "%s %s" %[File.basename($0), Sc2epub::VERSION]
|
9
7
|
puts "ruby %s" % RUBY_VERSION
|
@@ -20,10 +18,22 @@ class Sc2epub::Main
|
|
20
18
|
puts opts
|
21
19
|
exit
|
22
20
|
end
|
23
|
-
|
21
|
+
opts.parse!
|
22
|
+
if ARGV.size < 1
|
24
23
|
puts opts
|
25
24
|
exit
|
26
25
|
end
|
26
|
+
input = ARGV[0]
|
27
|
+
if ARGV.size < 2
|
28
|
+
output = File::basename(input) + '-epub'
|
29
|
+
else
|
30
|
+
output = ARGV[1]
|
31
|
+
end
|
32
|
+
if ARGV.size < 3
|
33
|
+
project = File::basename(input)
|
34
|
+
else
|
35
|
+
project = ARGV[2]
|
36
|
+
end
|
27
37
|
user = ENV['USER']
|
28
38
|
env = {
|
29
39
|
:author => user,
|
@@ -32,6 +42,6 @@ class Sc2epub::Main
|
|
32
42
|
Dir::mkdir(output) unless FileTest::exists? output
|
33
43
|
@converter = Sc2epub::Converter::new(env, input, output)
|
34
44
|
@converter.doroot(input)
|
35
|
-
@converter.dogenerate(
|
45
|
+
@converter.dogenerate(project)
|
36
46
|
end
|
37
47
|
end
|
data/lib/sc2epub/template.rb
CHANGED
@@ -13,6 +13,7 @@ EOS
|
|
13
13
|
TEMPLATE_ITEM = "<item id=\"%(id)\" media-type=\"text/x-oeb1-document\" href=\"%(link)\"></item>"
|
14
14
|
TEMPLATE_CONTAINER = 'container.tmpl'
|
15
15
|
def initialize
|
16
|
+
@map = {}
|
16
17
|
@dir = File::join(File::dirname(__FILE__), 'template')
|
17
18
|
end
|
18
19
|
def container params
|
@@ -44,7 +45,12 @@ EOS
|
|
44
45
|
end
|
45
46
|
def dotemplate template, params
|
46
47
|
if template.rindex('.tmpl')
|
47
|
-
|
48
|
+
if @map.has_key? template
|
49
|
+
t = @map[template]
|
50
|
+
else
|
51
|
+
t = open(File::join(@dir, template)){|io|io.read}
|
52
|
+
@map[template] = t
|
53
|
+
end
|
48
54
|
else
|
49
55
|
t = template
|
50
56
|
end
|
@@ -1,8 +1,9 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
2
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja-JP" lang="ja-JP"><head><title>%(title)</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><head
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja-JP" lang="ja-JP"><head><title>%(title)</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><head/>
|
4
|
+
<body>
|
4
5
|
<h1>%(title)</h1>
|
5
|
-
<pre>
|
6
|
+
<pre class="prettyprint">
|
6
7
|
%(body)
|
7
8
|
</pre>
|
8
9
|
</body>
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 8
|
9
|
+
version: 0.0.8
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- takada-at
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-11-
|
17
|
+
date: 2010-11-28 00:00:00 +09:00
|
18
18
|
default_executable: sc2epub
|
19
19
|
dependencies: []
|
20
20
|
|