narou 3.1.11 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of narou might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2ed0bc835e65c8fa3742828b718929dffafa3889
4
- data.tar.gz: 23f4dea8c8760736965aa2215a318a6da0e5d013
3
+ metadata.gz: 285c63133d8dca6cefd1e1ecacb249faac17eede
4
+ data.tar.gz: 797a6d1755244ef7063276e4acd5b618d4acf393
5
5
  SHA512:
6
- metadata.gz: 955798f4decda316da8de616815d6d94729a33781d817f04b52ce84fd51342b2c889aaec2e3090c0bc1bc0b56b869ee7f7da91872e3066c66a69c184d95f6e76
7
- data.tar.gz: 41f897947418f62c3d36984bd7d266edd84761feda9af1d3ca2ec3751b225e43b243f7fd7b56a6b8b4303d0bec2a3ec212f03689addaf708553f6041581352cd
6
+ metadata.gz: fd39cd8fcbe7946d5773271eeca57f6467967eb18fe5183ca0455db2647a24025b3162940c51bdb070980457f0e20004e9c1906f92061ba446721b1f490598e1
7
+ data.tar.gz: d94a9d9d9ccc4060f6910c6b0687d399477a92ce8172d6dca640dabce743512cafa2080801d844d10640aedad563619ddd20e9bda5e76239307121041c1b736b
data/.gitignore CHANGED
@@ -29,6 +29,7 @@ misc/
29
29
  hotentry/
30
30
  replace.txt
31
31
  tags
32
+ trace_dump.txt
32
33
 
33
34
  \#*\#
34
35
 
@@ -60,4 +61,5 @@ spec/reports
60
61
  test/tmp
61
62
  test/version_tmp
62
63
  tmp
64
+ document
63
65
 
@@ -116,10 +116,10 @@ Style/PredicateName:
116
116
  Style/GlobalVars:
117
117
  Enabled: false
118
118
 
119
- Style/IndentHash:
119
+ Layout/IndentHash:
120
120
  Enabled: false
121
121
 
122
- Style/LeadingCommentSpace:
122
+ Layout/LeadingCommentSpace:
123
123
  Enabled: true
124
124
 
125
125
  Style/LineEndConcatenation:
@@ -161,13 +161,13 @@ Style/RedundantSelf:
161
161
  SignalException:
162
162
  EnforcedStyle: only_raise
163
163
 
164
- Style/SpaceAfterComma:
164
+ Layout/SpaceAfterComma:
165
165
  Enabled: true
166
166
 
167
- Style/SpaceAroundOperators:
167
+ Layout/SpaceAroundOperators:
168
168
  Enabled: true
169
169
 
170
- Style/SpaceInsideRangeLiteral:
170
+ Layout/SpaceInsideRangeLiteral:
171
171
  Enabled: true
172
172
 
173
173
  Style/SpecialGlobalVars:
@@ -179,10 +179,10 @@ Style/StringLiterals:
179
179
  Style/SymbolProc:
180
180
  Enabled: true
181
181
 
182
- Style/Tab:
182
+ Layout/Tab:
183
183
  Enabled: true
184
184
 
185
- Style/TrailingBlankLines:
185
+ Layout/TrailingBlankLines:
186
186
  Enabled: false
187
187
 
188
188
  Style/TrailingCommaInLiteral:
@@ -209,11 +209,14 @@ Style/MutableConstant:
209
209
  Lint/UnderscorePrefixedVariableName:
210
210
  Enabled: false
211
211
 
212
- Style/EmptyLinesAroundClassBody:
212
+ Layout/EmptyLinesAroundClassBody:
213
213
  Enabled: false
214
214
 
215
215
  Style/FrozenStringLiteralComment:
216
216
  Enabled: false
217
217
 
218
- Style/MultilineOperationIndentation:
218
+ Layout/MultilineOperationIndentation:
219
+ Enabled: false
220
+
221
+ Layout/IndentHeredoc:
219
222
  Enabled: false
@@ -1,7 +1,47 @@
1
- 
2
- 更新履歴 - ChangeLog
1
+ 更新履歴 - ChangeLog
3
2
  ====================
4
3
 
4
+ 3.2.0: 2018/05/16
5
+ ------------------
6
+ #### 追加機能
7
+ - 小説の行の高さを設定することで行間を調整することが出来る機能を追加しました。
8
+ init コマンドを使用することで調整が可能です
9
+ + `narou init` とコマンドを打ち込んだ場合、AozoraEpub3フォルダの場所を聞かれ
10
+ たあとに、行の高さを尋ねられるので入力します
11
+ + オプションで指定する場合は `narou init -p :keep -l 1.8` の様に指定します
12
+ + 設定後に convert した小説から反映されます
13
+ - 小説の作品名及び作者名、ファイル名を制御する設定が個別設定に追加されました
14
+ + novel_author, novel_title, output_filename の3項目が追加
15
+ + novel_author 及び novel_title は作品データ内及び出力ファイル名に影響
16
+ + output_filename は全ての設定を無視して出力ファイル名を強制変更(拡張子不要)
17
+ - 小説の分割を行う設定 `slice_size` が追加されました。slice_size で指定した
18
+ 話数で小説を分割します
19
+
20
+ #### WEB UI 関連
21
+ - 「文字数」と「平均文字数」の項目を追加しました。
22
+ 『表示>表示する項目を設定』メニューから設定出来ます
23
+ + 文字数はダウンロードや更新をかけた際に反映されます
24
+ + 小説家になろう系列、ハーメルン、カクヨムのサイトに対応しています
25
+ - 小説リスト内の作者名及び掲載サイト名をクリックした時に、フィルターに自動的に
26
+ 入力されるようになりました
27
+ - テーマ設定名を `webui.theme` に変更しました。テーマ機能を使っている場合は
28
+ 再度環境設定から設定をお願いします(環境設定>WEB UI)
29
+ - 小説リストを更新するタイミングを選択する設定`webui.table.reload-timing`を
30
+ 追加しました
31
+ - 「表示」の「全ての項目を表示」及び「表示設定を全てリセット」に確認ダイアログ
32
+ が表示されるようにしました
33
+
34
+ #### 仕様変更
35
+ - 個別設定の機能から enable_double_dash_to_image を削除しました
36
+
37
+ #### 修正内容
38
+ - server-digest-auth.enableを有効にしてもユーザー名とパスワードが未設定の場合は
39
+ 認証がかからない様に変更
40
+ - ハーメルンのサブタイトルにルビが振られた小説が正常にダウンロード出来ない場合
41
+ がある
42
+ - カクヨムの小説がダウンロードできなくなったことへの対応
43
+
44
+
5
45
  3.1.11: 2017/11/21
6
46
  ------------------
7
47
  #### 追加機能
data/README.md CHANGED
@@ -33,30 +33,45 @@ Narou.rb ― 「小説家になろう」「小説を読もう!」ダウンロ
33
33
  更新履歴 - ChangeLog
34
34
  --------------------
35
35
 
36
- 3.1.11: 2017/11/21
36
+ 3.2.0: 2018/05/16
37
37
  ------------------
38
38
  #### 追加機能
39
- - trace コマンドを追加しました。エラー発生時の詳細ログを表示できます
40
-
41
- #### 修正内容
42
- - ダイジェストを検知した場合の選択肢で、選んだ順番によってクラッシュする場合が
43
- ある不具合
39
+ - 小説の行の高さを設定することで行間を調整することが出来る機能を追加しました。
40
+ init コマンドを使用することで調整が可能です
41
+ + `narou init` とコマンドを打ち込んだ場合、AozoraEpub3フォルダの場所を聞かれ
42
+ たあとに、行の高さを尋ねられるので入力します
43
+ + オプションで指定する場合は `narou init -p :keep -l 1.8` の様に指定します
44
+ + 設定後に convert した小説から反映されます
45
+ - 小説の作品名及び作者名、ファイル名を制御する設定が個別設定に追加されました
46
+ + novel_author, novel_title, output_filename の3項目が追加
47
+ + novel_author 及び novel_title は作品データ内及び出力ファイル名に影響
48
+ + output_filename は全ての設定を無視して出力ファイル名を強制変更(拡張子不要)
49
+ - 小説の分割を行う設定 `slice_size` が追加されました。slice_size で指定した
50
+ 話数で小説を分割します
44
51
 
52
+ #### WEB UI 関連
53
+ - 「文字数」と「平均文字数」の項目を追加しました。
54
+ 『表示>表示する項目を設定』メニューから設定出来ます
55
+ + 文字数はダウンロードや更新をかけた際に反映されます
56
+ + 小説家になろう系列、ハーメルン、カクヨムのサイトに対応しています
57
+ - 小説リスト内の作者名及び掲載サイト名をクリックした時に、フィルターに自動的に
58
+ 入力されるようになりました
59
+ - テーマ設定名を `webui.theme` に変更しました。テーマ機能を使っている場合は
60
+ 再度環境設定から設定をお願いします(環境設定>WEB UI)
61
+ - 小説リストを更新するタイミングを選択する設定`webui.table.reload-timing`を
62
+ 追加しました
63
+ - 「表示」の「全ての項目を表示」及び「表示設定を全てリセット」に確認ダイアログ
64
+ が表示されるようにしました
45
65
 
46
- 3.1.10: 2017/11/20
47
- ------------------
48
66
  #### 仕様変更
49
- - httpでダウンロードしたとしても目次アドレスをhttpsに強制切り替えを行います
50
- (SSL対応サイトのみ)
67
+ - 個別設定の機能から enable_double_dash_to_image を削除しました
51
68
 
52
69
  #### 修正内容
53
- - アドレスがhttpとhttpsの違いだけで、同じ小説を別の小説として扱われてしまう
54
- - gem ライブラリのアップデートにより mail コマンドが動かなくなっていた
55
- - ハーメルンのアドレス変更に対応
56
- - 「DLボタン設置」ブックマークレットをhttpsアドレス下でも動くように修正
57
- + ヘルプページからブックマークレットの再取得が必要です。古いものは動きません
58
- + 最近のブラウザじゃないとたぶん動きません
59
- - Arcadiaでカテゴリがない古い小説をダウンロード出来ない場合がある
70
+ - server-digest-auth.enableを有効にしてもユーザー名とパスワードが未設定の場合は
71
+ 認証がかからない様に変更
72
+ - ハーメルンのサブタイトルにルビが振られた小説が正常にダウンロード出来ない場合
73
+ がある
74
+ - カクヨムの小説がダウンロードできなくなったことへの対応
60
75
 
61
76
  ----
62
77
 
@@ -189,8 +189,17 @@ module Command
189
189
  end
190
190
 
191
191
  if File.file?(target.to_s)
192
+ using_send_command = false
193
+ # not remove output files for text file conversion
192
194
  res = convert_txt(target)
193
195
  else
196
+ using_send_command = true
197
+ # remove output files for novel conversion
198
+ NovelConverter.extensions_of_converted_files(@device).each do |ext|
199
+ ebook_paths = Narou.get_ebook_file_paths(target, ext)
200
+ NovelConverter.clean_up_temp_files(ebook_paths)
201
+ end
202
+ # start novel conversion
194
203
  @argument_target_type = :novel
195
204
  unless Downloader.novel_exists?(target)
196
205
  error "#{target} は存在しません"
@@ -206,15 +215,21 @@ module Command
206
215
  @options["yokogaki"] = NovelSetting.load(target)["enable_yokogaki"]
207
216
  end
208
217
  next unless res
209
- @converted_txt_path = res[:converted_txt_path]
210
- @use_dakuten_font = res[:use_dakuten_font]
218
+ array_of_converted_txt_path = res[:converted_txt_paths]
219
+ ebook_file = nil
220
+ array_of_converted_txt_path.each do |converted_txt_path|
221
+ @converted_txt_path = converted_txt_path
222
+ @use_dakuten_font = res[:use_dakuten_font]
211
223
 
212
- ebook_file = hook_call(:convert_txt_to_ebook_file)
213
- next if ebook_file.nil?
214
- if ebook_file
215
- copied_file_path = copy_to_converted_file(ebook_file)
216
- send_file_to_device(ebook_file)
224
+ ebook_file = hook_call(:convert_txt_to_ebook_file)
225
+ next if ebook_file.nil?
226
+ if ebook_file
227
+ copy_to_converted_file(ebook_file)
228
+ send_file_to_device(ebook_file) unless using_send_command
229
+ end
217
230
  end
231
+ send_file_to_device(ebook_file) if
232
+ using_send_command && ebook_file
218
233
 
219
234
  if @options["no-open"].! && Narou.web?.!
220
235
  Helper.open_directory(File.dirname(@converted_txt_path), "小説の保存フォルダを開きますか")
@@ -19,42 +19,52 @@ module Command
19
19
  def initialize
20
20
  super("[options]")
21
21
  if Narou.already_init?
22
- initialize_already_init
22
+ opt_message(<<-MSG)
23
+ ・AozoraEpub3 の再設定を行います。
24
+ MSG
23
25
  else
24
- initialize_init_yet
26
+ opt_message(<<-MSG)
27
+ ・現在のフォルダを小説格納用フォルダとして初期化します。
28
+ ・初期化されるまでは他のコマンドは使えません。
29
+ MSG
25
30
  end
26
31
  @opt.on("-p", "--path FOLDER", "指定したフォルダの AozoraEpub3 を利用する") { |dirname|
27
32
  # no check here since global_setting is not loaded yet
28
- @aozora_dirname = dirname
33
+ @options["aozora_dirname"] = dirname
29
34
  }
35
+ @opt.on("-l", "--line-height SIZE", "行の高さを変更する(単位em)。オススメは1.6〜1.8程度") do |line_height|
36
+ begin
37
+ @options["line_height"] = Helper.string_cast_to_type(line_height, :float)
38
+ rescue Helper::InvalidVariableType => e
39
+ error e.message
40
+ exit Narou::EXIT_ERROR_CODE
41
+ end
42
+ end
30
43
  end
31
44
 
32
- def initialize_init_yet
33
- @opt.separator <<-EOS
34
-
35
- ・現在のフォルダを小説格納用フォルダとして初期化します。
36
- ・初期化されるまでは他のコマンドは使えません。
45
+ def opt_message(description)
46
+ @opt.separator <<-MSG
37
47
 
48
+ #{description}
38
49
  Examples:
39
50
  narou init
40
51
  narou init -p /opt/narou/aozora # AozoraEpub3 のフォルダを直接指定
52
+ narou init -p :keep # 設定済みと同じ場所を指定(既に初期化済の場合)
41
53
 
42
- Options:
43
- EOS
44
- end
45
-
46
- def initialize_already_init
47
- @opt.separator <<-EOS
54
+ # 行の高さの調整
55
+ narou init --line-height 1.8 # 行の高さを1.8emに設定(1.8文字分相当)
56
+ # 行の高さなので、行間を1文字分あけたいという場合は 1+1 で 2 を指定する
57
+ # (デフォルト 1.6)
58
+ # 参考情報:Kindle Voyage で文字サイズ4番目の大きさの場合、
59
+ # 1.6em : 1ページに15行
60
+ # 1.8em : 1ページに13行
61
+ # の表示行数になる
48
62
 
49
- ・AozoraEpub3 の再設定を行います。
50
-
51
- Examples:
52
- narou init
53
- narou init -p /opt/narou/aozora # AozoraEpub3 のフォルダを直接指定
54
- narou init -p :keep # 設定済みと同じ場所を指定
63
+ # 入力を省略したい場合、-p と -l を両方指定してやる必要あり
64
+ narou init -p /path/to/aozora -l 1.8
55
65
 
56
66
  Options:
57
- EOS
67
+ MSG
58
68
  end
59
69
 
60
70
  def execute(argv)
@@ -81,8 +91,8 @@ module Command
81
91
  puts "<bold><red>#{"!!!WARNING!!!".center(70)}</red></bold>".termcolor
82
92
  puts "AozoraEpub3の構成ファイルを書き換えます。narouコマンド用に別途新規インストールしておくことをオススメします"
83
93
  end
84
- if @aozora_dirname
85
- path = normalize_aozoraepub3_path(@aozora_dirname)
94
+ if @options["aozora_dirname"]
95
+ path = normalize_aozoraepub3_path(@options["aozora_dirname"])
86
96
  print "\n<bold><green>指定されたフォルダにAozoraEpub3がありません。</green></bold>\n".termcolor unless path
87
97
  end
88
98
  aozora_path = path || ask_aozoraepub3_path
@@ -90,19 +100,21 @@ module Command
90
100
  puts "設定をスキップしました。あとで " + "<bold><yellow>narou init</yellow></bold>".termcolor + " で再度設定出来ます"
91
101
  return
92
102
  end
103
+ line_height = @options["line_height"] || ask_line_height
93
104
  puts
94
- rewrite_aozoraepub3_files(aozora_path)
105
+ rewrite_aozoraepub3_files(aozora_path, line_height)
95
106
  @global_setting["aozoraepub3dir"] = aozora_path
107
+ @global_setting["line-height"] = line_height
96
108
  @global_setting.save
97
109
  puts "<bold><green>AozoraEpub3の設定を終了しました</green></bold>".termcolor
98
110
  end
99
111
 
100
- def rewrite_aozoraepub3_files(aozora_path)
112
+ def rewrite_aozoraepub3_files(aozora_path, line_height)
101
113
  # chuki_tag.txt の書き換え
102
114
  custom_chuki_tag_path = File.join(Narou.get_preset_dir, "custom_chuki_tag.txt")
103
115
  chuki_tag_path = File.join(aozora_path, "chuki_tag.txt")
104
- custom_chuki_tag = open(custom_chuki_tag_path, "r:BOM|UTF-8") { |fp| fp.read }
105
- chuki_tag = open(chuki_tag_path, "r:BOM|UTF-8") { |fp| fp.read }
116
+ custom_chuki_tag = File.read(custom_chuki_tag_path, mode: "r:BOM|UTF-8")
117
+ chuki_tag = File.read(chuki_tag_path, mode: "r:BOM|UTF-8")
106
118
  embedded_mark = "### Narou.rb embedded custom chuki ###"
107
119
  if chuki_tag =~ /#{embedded_mark}/
108
120
  chuki_tag.gsub!(/#{embedded_mark}.+#{embedded_mark}/m, custom_chuki_tag)
@@ -120,7 +132,7 @@ module Command
120
132
  src.size.times do |i|
121
133
  src_full_path = File.join(Narou.get_preset_dir, src[i])
122
134
  dst_full_path = File.join(aozora_path, dst[i])
123
- FileUtils.install(src_full_path, dst_full_path)
135
+ Helper.erb_copy(src_full_path, dst_full_path, binding)
124
136
  puts dst_full_path
125
137
  end
126
138
  end
@@ -133,7 +145,7 @@ module Command
133
145
  print "(現在の場所:#{@global_setting["aozoraepub3dir"]}"
134
146
  end
135
147
  print ")\n>"
136
- while input = $stdin.gets
148
+ while (input = $stdin.gets)
137
149
  break if input.strip! == ""
138
150
  checked_input = normalize_aozoraepub3_path(input)
139
151
  return checked_input if checked_input
@@ -143,6 +155,30 @@ module Command
143
155
  nil
144
156
  end
145
157
 
158
+ def ask_line_height
159
+ line_height = Narou.line_height
160
+ puts
161
+ puts(<<-MSG.termcolor)
162
+ <bold><green>行間の調整を行います。小説の行の高さを設定して下さい(単位 em):</green></bold>
163
+ 1em = 1文字分の高さ
164
+ 行の高さ=1文字分の高さ+行間の高さ
165
+ オススメは 1.6 〜 1.8 程度。1.6 で若干行間狭め。1.8 だと一般的な小説程度。2.0 くらいにするとかなりスカスカ
166
+ (未入力で #{line_height} を採用)
167
+ MSG
168
+ print ">"
169
+ while (input = $stdin.gets)
170
+ break if input.strip! == ""
171
+ begin
172
+ line_height = Helper.string_cast_to_type(input, :float)
173
+ break
174
+ rescue Helper::InvalidVariableType => e
175
+ error e.message
176
+ print "<bold><green>もう一度入力して下さい:</green></bold>\n&gt;".termcolor
177
+ end
178
+ end
179
+ line_height
180
+ end
181
+
146
182
  def normalize_aozoraepub3_path(input)
147
183
  if Helper.os_windows?
148
184
  input.force_encoding(Encoding::Windows_31J).encode!(Encoding::UTF_8)
@@ -63,10 +63,10 @@ module Command
63
63
  tagname_to_ids(argv)
64
64
  argv.each do |target|
65
65
  if target == "hotentry"
66
- ebook_path = Update.get_newest_hotentry_file_path(device)
66
+ ebook_paths = [Update.get_newest_hotentry_file_path(device)]
67
67
  display_target = "hotentry"
68
68
  else
69
- ebook_path = Narou.get_ebook_file_path(target, device ? device.ebook_file_ext : ".epub")
69
+ ebook_paths = Narou.get_ebook_file_paths(target, device ? device.ebook_file_ext : ".epub")
70
70
  data = Downloader.get_data_by_target(target)
71
71
  if send_all && !@options["force"]
72
72
  new_arrivals_date = data["new_arrivals_date"] || Time.now
@@ -75,12 +75,12 @@ module Command
75
75
  end
76
76
  end
77
77
  end
78
- unless ebook_path
78
+ unless ebook_paths[0]
79
79
  error "#{target} は存在しません" unless send_all
80
80
  next
81
81
  end
82
- unless File.exist?(ebook_path)
83
- error "まだファイル(#{File.basename(ebook_path)})が無いようです" unless send_all
82
+ unless File.exist?(ebook_paths[0])
83
+ error "まだファイル(#{File.basename(ebook_paths[0])})が無いようです" unless send_all
84
84
  next
85
85
  end
86
86
  if target == "hotentry"
@@ -92,23 +92,25 @@ module Command
92
92
  end
93
93
  puts "<bold><green>#{display_target}</green></bold>".termcolor
94
94
  print "メールを送信しています"
95
- exit_mail = false
96
- mail_result = nil
97
- Thread.new do
98
- mail_result = mailer.send(id, File.basename(ebook_path), ebook_path)
99
- exit_mail = true
100
- end
101
- until exit_mail
102
- print "."
103
- sleep(0.5)
104
- end
105
- puts
106
- if mail_result
107
- puts File.basename(ebook_path) + " をメールで送信しました"
108
- database[id]["last_mail_date"] = Time.now if target != "hotentry"
109
- else
110
- error "#{mailer.error_message}"
111
- exit Narou::EXIT_ERROR_CODE # next しても次も失敗する可能性が高いのでここで終了
95
+ ebook_paths.each do |ebook_path|
96
+ exit_mail = false
97
+ mail_result = nil
98
+ Thread.new do
99
+ mail_result = mailer.send(id, File.basename(ebook_path), ebook_path)
100
+ exit_mail = true
101
+ end
102
+ until exit_mail
103
+ print "."
104
+ sleep(0.5)
105
+ end
106
+ puts
107
+ if mail_result
108
+ puts File.basename(ebook_path) + " をメールで送信しました"
109
+ database[id]["last_mail_date"] = Time.now if target != "hotentry"
110
+ else
111
+ error mailer.error_message
112
+ exit Narou::EXIT_ERROR_CODE # next しても次も失敗する可能性が高いのでここで終了
113
+ end
112
114
  end
113
115
  end
114
116
  rescue Interrupt