narou 1.1.0.rc1 → 1.1.0.rc2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of narou might be problematic. Click here for more details.
- data/.gitignore +1 -1
- data/ChangeLog.md +22 -0
- data/README.md +24 -288
- data/lib/command/convert.rb +7 -3
- data/lib/command/download.rb +1 -2
- data/lib/command/init.rb +3 -2
- data/lib/command/setting.rb +1 -0
- data/lib/command/update.rb +7 -5
- data/lib/converterbase.rb +89 -65
- data/lib/downloader.rb +60 -10
- data/lib/loadconverter.rb +5 -15
- data/lib/novelconverter.rb +11 -4
- data/lib/novelsetting.rb +4 -4
- data/lib/sitesetting.rb +3 -0
- data/lib/version.rb +1 -1
- data/preset/custom_chuki_tag.txt +1 -6
- data/preset/vertical_font.css +4 -2
- data/preset/xhtml_nav.vm +109 -0
- data/template/novel.txt.erb +1 -7
- data/webnovel/ncode.syosetu.com.yaml +1 -0
- data/webnovel/novel18.syosetu.com.yaml +1 -0
- metadata +4 -3
- data/ChangeLog.txt +0 -12
data/lib/loadconverter.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
require_relative "converterbase"
|
7
7
|
require_relative "helper"
|
8
8
|
|
9
|
-
|
9
|
+
BlankConverter = Class.new(ConverterBase) {}
|
10
10
|
|
11
11
|
$converter_container = {}
|
12
12
|
|
@@ -66,24 +66,14 @@ def load_converter(title, archive_path)
|
|
66
66
|
require converter_path
|
67
67
|
end
|
68
68
|
else
|
69
|
-
return
|
69
|
+
return BlankConverter
|
70
70
|
end
|
71
71
|
conv = $converter_container[title]
|
72
72
|
if conv
|
73
73
|
return conv
|
74
74
|
else
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
return Class.new(Converter) {}
|
75
|
+
warn "converter.rbは見つかりましたが、`converter'で登録されていないようです。" +
|
76
|
+
"変換処理は converter \"#{title}\" として登録する必要があります"
|
77
|
+
return BlankConverter
|
79
78
|
end
|
80
79
|
end
|
81
|
-
|
82
|
-
# 書式の古い converter.rb を書き換える
|
83
|
-
def renewal_deprecated_converter(title, converter_path)
|
84
|
-
src = open(converter_path, "r:BOM|UTF-8") { |fp| fp.read }
|
85
|
-
src.gsub!("class Converter < ConverterBase", %!converter "#{title}" do!)
|
86
|
-
src.gsub!("def before_convert", "def before")
|
87
|
-
src.gsub!("def after_convert", "def after")
|
88
|
-
File.write(converter_path, src)
|
89
|
-
end
|
data/lib/novelconverter.rb
CHANGED
@@ -96,8 +96,14 @@ class NovelConverter
|
|
96
96
|
end
|
97
97
|
|
98
98
|
ext_option = ""
|
99
|
-
|
100
|
-
|
99
|
+
device_option = ""
|
100
|
+
if device
|
101
|
+
case device.name
|
102
|
+
when "Kobo"
|
103
|
+
ext_option = "-ext " + device.ebook_file_ext
|
104
|
+
when "Kindle"
|
105
|
+
device_option = "-device kindle"
|
106
|
+
end
|
101
107
|
end
|
102
108
|
|
103
109
|
pwd = Dir.pwd
|
@@ -111,7 +117,7 @@ class NovelConverter
|
|
111
117
|
aozoraepub3_dir = File.dirname(aozoraepub3_path)
|
112
118
|
|
113
119
|
Dir.chdir(aozoraepub3_dir)
|
114
|
-
command = %!java -cp #{aozoraepub3_basename} AozoraEpub3 -enc UTF-8 -of
|
120
|
+
command = %!java -cp #{aozoraepub3_basename} AozoraEpub3 -enc UTF-8 -of #{device_option} ! +
|
115
121
|
%!#{cover_option} #{dst_option} #{ext_option} "#{abs_srcpath}"!
|
116
122
|
if Helper.os_windows?
|
117
123
|
command = "cmd /c " + command.encode(Encoding::Windows_31J)
|
@@ -247,7 +253,8 @@ class NovelConverter
|
|
247
253
|
# 変換処理メイン
|
248
254
|
#
|
249
255
|
def convert_main(text = nil)
|
250
|
-
|
256
|
+
print "ID:#{@novel_id} " if @novel_id
|
257
|
+
puts "#{@novel_title} の変換を開始"
|
251
258
|
sections = []
|
252
259
|
@cover_chuki = create_cover_chuki
|
253
260
|
|
data/lib/novelsetting.rb
CHANGED
@@ -27,7 +27,7 @@ class NovelSetting
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def initialize(archive_path)
|
30
|
-
@archive_path = archive_path
|
30
|
+
@archive_path = File.expand_path(archive_path)
|
31
31
|
load_settings
|
32
32
|
set_attribute
|
33
33
|
load_replace_pattern
|
@@ -124,7 +124,7 @@ class NovelSetting
|
|
124
124
|
{
|
125
125
|
name: "kanji_num_with_units_lower_digit_zero",
|
126
126
|
value: 2,
|
127
|
-
help: "〇(ゼロ)
|
127
|
+
help: "〇(ゼロ)が最低この数字以上付いてないと千・万などをつける対象にしない"
|
128
128
|
},
|
129
129
|
{
|
130
130
|
name: "enable_alphabet_force_zenkaku",
|
@@ -132,9 +132,9 @@ class NovelSetting
|
|
132
132
|
help: "アルファベットを強制的に全角にする。falseの場合英文は半角、それ以外は全角になる"
|
133
133
|
},
|
134
134
|
{
|
135
|
-
name: "
|
135
|
+
name: "enable_half_indent_bracket",
|
136
136
|
value: true,
|
137
|
-
help: "
|
137
|
+
help: "行頭鍵カッコに二分アキを挿入する"
|
138
138
|
},
|
139
139
|
{
|
140
140
|
name: "enable_auto_indent",
|
data/lib/sitesetting.rb
CHANGED
@@ -53,6 +53,9 @@ class SiteSetting
|
|
53
53
|
|
54
54
|
def replace_group_values(key, option_values = {})
|
55
55
|
dest = option_values[key] || @match_values[key] || @yaml_setting[key]
|
56
|
+
if dest.kind_of?(TrueClass) || dest.kind_of?(FalseClass)
|
57
|
+
return dest
|
58
|
+
end
|
56
59
|
return nil unless dest
|
57
60
|
values = @yaml_setting.merge(@match_values).merge(option_values)
|
58
61
|
result = dest.dup
|
data/lib/version.rb
CHANGED
data/preset/custom_chuki_tag.txt
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
### Narou.rb embedded custom chuki ###
|
2
2
|
|
3
3
|
####カスタム注記
|
4
|
-
|
4
|
+
二分アキ <div class="half_em_space"> </div> 1
|
5
5
|
一字下げ <div class="pt1"> </div> 1
|
6
6
|
二字下げ <div class="pt2"> </div> 1
|
7
7
|
三字下げ <div class="pt3"> </div> 1
|
@@ -13,10 +13,5 @@
|
|
13
13
|
ここで後書き終わり </div><div class="clear"></div> 1
|
14
14
|
濁点 <span class="dakuten">
|
15
15
|
濁点終わり </span>
|
16
|
-
リンク開始 <a href="
|
17
|
-
リンクアドレスここまで ">
|
18
|
-
リンク終了 </a>
|
19
|
-
ここからキンドル左右中央 <div class="kindle_outer"><div class="kindle_inner"> 1
|
20
|
-
ここでキンドル左右中央終わり </div></div> 1
|
21
16
|
|
22
17
|
### Narou.rb embedded custom chuki ###
|
data/preset/vertical_font.css
CHANGED
@@ -13,6 +13,8 @@ body {
|
|
13
13
|
.b { font-weight: bold; }
|
14
14
|
.i { font-style: italic; }
|
15
15
|
|
16
|
+
rt { font-size: 0.6em; }
|
17
|
+
|
16
18
|
/* カスタム注記用 */
|
17
19
|
|
18
20
|
/* 濁点フォント */
|
@@ -25,8 +27,8 @@ body {
|
|
25
27
|
font-family: "DakutenAokinMincho" !important;
|
26
28
|
}
|
27
29
|
|
28
|
-
/*
|
29
|
-
.
|
30
|
+
/* 二分アキ */
|
31
|
+
.half_em_space { text-indent: 0.5em; }
|
30
32
|
|
31
33
|
/* パラメーター(折り返しあり) */
|
32
34
|
.custom_parameter_block {
|
data/preset/xhtml_nav.vm
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE html>
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2011/epub" lang="ja" xml:lang="ja">
|
4
|
+
<head>
|
5
|
+
<title>${title}</title>
|
6
|
+
<style type="text/css">
|
7
|
+
.hidden { display: none; }
|
8
|
+
#if (${bookInfo.TocVertical})
|
9
|
+
@page {margin:.5em .5em 0 0;}
|
10
|
+
html {
|
11
|
+
writing-mode: vertical-rl;
|
12
|
+
-webkit-writing-mode: vertical-rl;
|
13
|
+
-epub-writing-mode: vertical-rl;
|
14
|
+
}
|
15
|
+
h1 {font-size:1.5em; padding-top:1em;}
|
16
|
+
li {list-style:disc; list-style-type: none; padding:0 .25em 0 0; line-height:1.75em;}
|
17
|
+
li a {text-decoration:none; border-right-width:1px; border-right-style:solid; padding-right: 1px;}
|
18
|
+
.tcy span {
|
19
|
+
width: 1em;
|
20
|
+
text-combine: horizontal;
|
21
|
+
-webkit-text-combine: horizontal;
|
22
|
+
-epub-text-combine: horizontal;
|
23
|
+
}
|
24
|
+
#else
|
25
|
+
@page {margin:.5em 0 0 .5em;}
|
26
|
+
html {
|
27
|
+
writing-mode:horizontal-tb;
|
28
|
+
-webkit-writing-mode:horizontal-tb;
|
29
|
+
-epub-writing-mode:horizontal-tb;
|
30
|
+
}
|
31
|
+
h1 {font-size:1.5em; text-align:center;}
|
32
|
+
li {padding:.25em 0 0 0; list-style:disc; list-style-type: none; line-height:1.75em;}
|
33
|
+
li a {text-decoration:none; border-bottom-width:1px; border-bottom-style:solid; padding-right: 1px;}
|
34
|
+
#end
|
35
|
+
</style>
|
36
|
+
</head>
|
37
|
+
|
38
|
+
<body>
|
39
|
+
## epub3 landmarks nav ==========================
|
40
|
+
<nav epub:type="landmarks" id="landmarks" hidden="" class="hidden">
|
41
|
+
<ol>
|
42
|
+
#if (${bookInfo.InsertCoverPage})
|
43
|
+
<li><a epub:type="cover" href="cover.xhtml">表紙</a></li>
|
44
|
+
#end
|
45
|
+
#if (${bookInfo.InsertTocPage})
|
46
|
+
<li><a epub:type="toc" href="nav.xhtml">目次</a></li>
|
47
|
+
#end
|
48
|
+
#foreach (${chapter} in ${chapters})
|
49
|
+
#if (${chapter.SectionId} == "title")
|
50
|
+
<li><a epub:type="title-page" href="title.xhtml">扉</a></li>
|
51
|
+
#else
|
52
|
+
<li><a epub:type="bodymatter" href="${chapter.SectionId}.xhtml">本文</a></li>
|
53
|
+
#break
|
54
|
+
#end
|
55
|
+
#end
|
56
|
+
</ol>
|
57
|
+
</nav>
|
58
|
+
## epub3 toc nav ================================
|
59
|
+
<nav epub:type="toc" id="toc">
|
60
|
+
<h1>目 次</h1>
|
61
|
+
<ol>
|
62
|
+
#if (${bookInfo.InsertCoverPage} && ${bookInfo.InsertCoverPageToc})
|
63
|
+
<li class="chapter" id="toccover"><a href="cover.xhtml">${cover_name}</a></li>
|
64
|
+
#end
|
65
|
+
#set ($idx=0)
|
66
|
+
#set ($nest_level=0)
|
67
|
+
#foreach(${chapter} in ${chapters})
|
68
|
+
#if ($chapter.ChapterName)
|
69
|
+
#set ($idx=$idx+1)
|
70
|
+
#if ($chapter.ChapterId)
|
71
|
+
#set ($chapter_anchor="#"+$chapter.ChapterId)
|
72
|
+
#else
|
73
|
+
#set ($chapter_anchor="")
|
74
|
+
#end
|
75
|
+
## enable nested toc ------------------------
|
76
|
+
#if (${navNest})
|
77
|
+
#if (${idx} > 1)
|
78
|
+
#if (${chapter.ChapterLevel} > ${nest_level})
|
79
|
+
<ol>
|
80
|
+
#elseif (${chapter.ChapterLevel} == ${nest_level})
|
81
|
+
</li>
|
82
|
+
#elseif (${chapter.ChapterLevel} < ${nest_level})
|
83
|
+
#set ($loop_count=$nest_level - $chapter.ChapterLevel - 1)
|
84
|
+
#foreach (${i} in [0..${loop_count}])
|
85
|
+
</li>
|
86
|
+
</ol>
|
87
|
+
#end
|
88
|
+
</li>
|
89
|
+
#end
|
90
|
+
#end
|
91
|
+
<li class="chapter" id="toc${idx}"><a href="${chapter.SectionId}.xhtml$!{chapter_anchor}">${chapter.ChapterName}</a>
|
92
|
+
#set ($nest_level=$chapter.ChapterLevel)
|
93
|
+
## disable nested toc -----------------------
|
94
|
+
#else
|
95
|
+
<li class="chapter" id="toc${idx}"><a href="${chapter.SectionId}.xhtml$!{chapter_anchor}">${chapter.ChapterName}</a></li>
|
96
|
+
#end
|
97
|
+
#end
|
98
|
+
#end
|
99
|
+
#if (${navNest})
|
100
|
+
#foreach (${end} in [${nest_level}..0])
|
101
|
+
</li>
|
102
|
+
</ol>
|
103
|
+
#end
|
104
|
+
#else
|
105
|
+
</ol>
|
106
|
+
#end
|
107
|
+
</nav>
|
108
|
+
</body>
|
109
|
+
</html>
|
data/template/novel.txt.erb
CHANGED
@@ -6,24 +6,18 @@
|
|
6
6
|
[#区切り線]
|
7
7
|
<%= toc["story"] %>
|
8
8
|
|
9
|
-
掲載ページ:
|
9
|
+
掲載ページ: <a href="<%= toc["toc_url"] %>"><%= toc["toc_url"] %></a>
|
10
10
|
[#区切り線]
|
11
11
|
|
12
12
|
<% sections.each_with_index do |section, i| -%>
|
13
13
|
[#改ページ]
|
14
14
|
<% if section["chapter"] != "" -%>
|
15
15
|
[#ページの左右中央]
|
16
|
-
<% if device && device.name == "Kindle" -%>
|
17
|
-
[#ここからキンドル左右中央]
|
18
|
-
<% end -%>
|
19
16
|
<%= toc["title"] %>
|
20
17
|
|
21
18
|
[#ここから大見出し]<%= section["chapter"] %>[#ここで大見出し終わり]
|
22
19
|
|
23
20
|
|
24
|
-
<% if device && device.name == "Kindle" -%>
|
25
|
-
[#ここでキンドル左右中央終わり]
|
26
|
-
<% end -%>
|
27
21
|
[#改ページ]
|
28
22
|
<% end -%>
|
29
23
|
[#3字下げ][#ここから中見出し]<%= section["subtitle"].rstrip %>[#ここで中見出し終わり]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: narou
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.0.
|
4
|
+
version: 1.1.0.rc2
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-07 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: 小説家になろうで公開されている小説の管理、及び電子書籍データへの変換を支援します。縦書用に特化されており、横書き用に特化されたWEB小説を違和感なく縦書で読むことが出来るようになります。
|
15
15
|
email:
|
@@ -21,7 +21,7 @@ extra_rdoc_files: []
|
|
21
21
|
files:
|
22
22
|
- .gitattributes
|
23
23
|
- .gitignore
|
24
|
-
- ChangeLog.
|
24
|
+
- ChangeLog.md
|
25
25
|
- Gemfile
|
26
26
|
- README.md
|
27
27
|
- Rakefile
|
@@ -78,6 +78,7 @@ files:
|
|
78
78
|
- preset/bordersymbols.txt
|
79
79
|
- preset/custom_chuki_tag.txt
|
80
80
|
- preset/vertical_font.css
|
81
|
+
- preset/xhtml_nav.vm
|
81
82
|
- template/converter.rb.erb
|
82
83
|
- template/diff.txt.erb
|
83
84
|
- template/novel.txt.erb
|