narou 2.8.2 → 2.8.3
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 +4 -4
- data/ChangeLog.md +44 -0
- data/Gemfile +2 -1
- data/commitversion +1 -1
- data/lib/command/setting.rb +20 -5
- data/lib/command/version.rb +1 -2
- data/lib/command/web.rb +64 -7
- data/lib/downloader.rb +4 -1
- data/lib/narou.rb +20 -0
- data/lib/novelconverter.rb +1 -1
- data/lib/version.rb +1 -1
- data/lib/web/appserver.rb +67 -15
- data/lib/web/public/resources/narou.library.js +93 -12
- data/lib/web/public/resources/narou.ui.js +152 -52
- data/lib/web/pushserver.rb +14 -3
- data/lib/web/views/_about.haml +188 -0
- data/lib/web/views/{diff_list.haml → _diff_list.haml} +0 -0
- data/lib/web/views/{edit_replace_txt.haml → _edit_replace_txt.haml} +4 -4
- data/lib/web/views/_rebooting.haml +18 -0
- data/lib/web/views/help.haml +2 -2
- data/lib/web/views/index.haml +13 -2
- data/lib/web/views/layout.haml +3 -2
- data/lib/web/views/novels/setting.haml +14 -3
- data/lib/web/views/settings.haml +2 -2
- data/lib/web/views/style.scss +44 -11
- data/narou.rb +7 -8
- data/preset/ncode.syosetu.com/n5115cq/converter.rb +30 -0
- data/preset/ncode.syosetu.com/n8725k/converter.rb +1 -1
- data/spec/generator/convert_spec_gen.rb +2 -0
- data/webnovel/novel18.syosetu.com.yaml +1 -0
- metadata +7 -5
- data/lib/web/views/about.haml +0 -85
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b383b0dfd3d47fda5cdf319be4bb15615e4757c
|
4
|
+
data.tar.gz: 432a626b225f55fa99fe5450016e4108f768ad22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac05edc568f56fa3e46f6d2f4bfb6a9444e21c5eb28deb5f44aefb7e92aae70ddeb2c8ae3c896d8c7296f331b6d901d0818f1dd74589014144bdbdd20317a897
|
7
|
+
data.tar.gz: 123cb7ed8fbbff11d8dd07abebf90efcb1dde78462cda154f259de434c396a62a5b21054d1e9ff58069cd7f9384aaa1ccdd8900c476ed724e92ac1154add0013
|
data/ChangeLog.md
CHANGED
@@ -2,6 +2,50 @@
|
|
2
2
|
更新履歴 - ChangeLog
|
3
3
|
====================
|
4
4
|
|
5
|
+
2.9.0 : develop
|
6
|
+
------------------
|
7
|
+
#### WEB UI
|
8
|
+
- メニュー(歯車アイコン)に「サーバを再起動」を追加しました。WEB UIから直接WEB
|
9
|
+
UIサーバを再起動できるようになります
|
10
|
+
- 「Narou.rbについて」ダイアログで最新バージョンを確認できた場合に、その場で
|
11
|
+
システムの更新及び再起動が出来るようになりました
|
12
|
+
- 小説リスト部分で右クリックすることで個別メニューを呼び出せるようになりました
|
13
|
+
- 各小説をそれぞれ個別に更新出来るボタンを追加しました
|
14
|
+
- 一部のボタンのアイコンを変更しました
|
15
|
+
- 個別メニューから「更新」した場合は、凍結状態に関わらず更新出来るようになり
|
16
|
+
ました
|
17
|
+
- ツールチップを表示してしばらくしたら自動で閉じるようにしました
|
18
|
+
- タグの並び順をソートするようにしました
|
19
|
+
- 「表示」メニューに「変換設定ページは新規タブで開く」を追加しました
|
20
|
+
|
21
|
+
#### 追加機能
|
22
|
+
- `narou setting 変数名` コマンドで現在の設定値を確認出来るようになりました。
|
23
|
+
(例 `narou s device`)
|
24
|
+
- 変換プリセットを追加しました
|
25
|
+
- n5115cq 最果てのパラディン
|
26
|
+
|
27
|
+
#### 仕様変更
|
28
|
+
- 変換処理で body や introduction 等を処理して最後に subtitle を変換していた
|
29
|
+
のを先に subtitle を処理するように変更しました
|
30
|
+
- converter.rb でサブタイトルで本文の処理内容を調整したい場合に今までの処理順
|
31
|
+
では不可能だったため
|
32
|
+
|
33
|
+
#### 修正
|
34
|
+
- Windows において、WEB UI の「Narou.rbについて」ダイアログで最新バージョンの
|
35
|
+
確認に失敗する場合がある問題に対応しました
|
36
|
+
- WEB UI の小説リストの項目を入れ替えた後に各種ボタンが反応しなくなるのを修正
|
37
|
+
- 凍結済み小説を強制更新した際に凍結が解除されてしまう場合があったのを修正
|
38
|
+
- thin などがすでにインストール済みの場合に narou web コマンドで WEB UI サーバ
|
39
|
+
を起動できない場合があるので、必ず WEBrick で起動するようにしました
|
40
|
+
|
41
|
+
|
42
|
+
2.8.3 : 2016/03/01
|
43
|
+
------------------
|
44
|
+
#### HotFix
|
45
|
+
- ノクターン・ムーンライト・ミッドナイトノベルズの認証方法変更に対応しました
|
46
|
+
+ 404エラーがでて凍結されてしまった場合、凍結を解除したあと再度更新して下さい
|
47
|
+
|
48
|
+
|
5
49
|
2.8.2 : 2016/02/05
|
6
50
|
------------------
|
7
51
|
#### HotFix
|
data/Gemfile
CHANGED
data/commitversion
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.8.2
|
1
|
+
2.8.2-50-gc0146d3
|
data/lib/command/setting.rb
CHANGED
@@ -38,11 +38,17 @@ module Command
|
|
38
38
|
|
39
39
|
@opt.separator <<-EOS
|
40
40
|
|
41
|
+
これ以外にも設定出来る項目があります。確認する場合は
|
42
|
+
narou setting -a コマンドを参照して下さい
|
43
|
+
|
41
44
|
Examples:
|
42
|
-
narou setting --list
|
43
|
-
narou setting convert.no-open=true
|
44
|
-
narou setting convert.no-epub=
|
45
|
-
narou setting
|
45
|
+
narou setting --list # 現在の設置値一覧を表示
|
46
|
+
narou setting convert.no-open=true # 値を設定する
|
47
|
+
narou setting convert.no-epub= # 右辺に何も書かないとその設定を削除出来る
|
48
|
+
narou setting device # 変数名だけ書くと現在の値を確認出来る
|
49
|
+
|
50
|
+
narou s convert.copy-to=C:/dropbox/mobi
|
51
|
+
# パスにスペースが含まれる場合はダブルクウォーテーションで囲う
|
46
52
|
narou s convert.copy-to="C:\\Documents and Settings\\user\\epub"
|
47
53
|
|
48
54
|
Options:
|
@@ -134,6 +140,15 @@ module Command
|
|
134
140
|
deleted
|
135
141
|
end
|
136
142
|
|
143
|
+
def output_value(name, settings)
|
144
|
+
scope = get_scope_of_variable_name(name)
|
145
|
+
if scope
|
146
|
+
puts settings[scope][name]
|
147
|
+
else
|
148
|
+
output_error("#{name} という変数は存在しません", name)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
137
152
|
def execute(argv)
|
138
153
|
super
|
139
154
|
if @options["burn"]
|
@@ -158,7 +173,7 @@ module Command
|
|
158
173
|
next
|
159
174
|
end
|
160
175
|
if value.nil?
|
161
|
-
|
176
|
+
output_value(name, settings)
|
162
177
|
next
|
163
178
|
end
|
164
179
|
scope = get_scope_of_variable_name(name)
|
data/lib/command/version.rb
CHANGED
@@ -14,8 +14,7 @@ module Command
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def self.create_version_string
|
17
|
-
|
18
|
-
commitversion = File.exist?(cv_path) ? File.read(cv_path) : `git describe --always`.strip + "(develop)"
|
17
|
+
commitversion = Narou.commit_version || `git describe --always`.strip + "(develop)"
|
19
18
|
"#{::Version} build #{commitversion}"
|
20
19
|
end
|
21
20
|
end
|
data/lib/command/web.rb
CHANGED
@@ -69,7 +69,35 @@ module Command
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def execute(argv)
|
72
|
-
|
72
|
+
if argv.delete("--boot")
|
73
|
+
@rebooted = !!argv.delete("--reboot")
|
74
|
+
super
|
75
|
+
boot
|
76
|
+
else
|
77
|
+
argv << "--backtrace" if $display_backtrace
|
78
|
+
argv << "--no-color" if $disable_color
|
79
|
+
argv << "--boot"
|
80
|
+
argv_copy = argv.dup
|
81
|
+
begin
|
82
|
+
loop do
|
83
|
+
if $development
|
84
|
+
system(RbConfig.ruby, "-x", $0, "web", *argv)
|
85
|
+
else
|
86
|
+
system("narou", "web", *argv)
|
87
|
+
end
|
88
|
+
break unless $?.exitstatus == Narou::EXIT_REQUEST_REBOOT
|
89
|
+
argv = argv_copy.dup
|
90
|
+
argv.push("--no-browser", "--reboot")
|
91
|
+
end
|
92
|
+
rescue Interrupt => e
|
93
|
+
# 中断されてコンソールへの入力が可能になってから、WEBrick が終了するまで
|
94
|
+
# タイムラグがあって表示がごちゃまぜになるので、終わるのを少し待つ
|
95
|
+
sleep 3
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def boot
|
73
101
|
require_relative "../web/all"
|
74
102
|
confirm_of_first
|
75
103
|
params = Narou::AppServer.create_address(@options["port"])
|
@@ -83,18 +111,20 @@ module Command
|
|
83
111
|
puts
|
84
112
|
|
85
113
|
push_server.run
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
Helper.open_browser(address)
|
90
|
-
end
|
91
|
-
end
|
114
|
+
open_browser_when_server_boot(address)
|
115
|
+
send_rebooted_event_when_connection_recover(push_server)
|
116
|
+
|
92
117
|
$stdout = Narou::StreamingLogger.new(push_server)
|
93
118
|
ProgressBar.push_server = push_server
|
94
119
|
Narou::AppServer.push_server = push_server
|
95
120
|
Narou::Worker.instance.start
|
121
|
+
send_hello_message
|
122
|
+
|
96
123
|
Narou::AppServer.run!
|
97
124
|
push_server.quit
|
125
|
+
if Narou::AppServer.request_reboot?
|
126
|
+
exit Narou::EXIT_REQUEST_REBOOT
|
127
|
+
end
|
98
128
|
rescue Errno::EADDRINUSE => e
|
99
129
|
Helper.open_browser(address) unless @options["no-browser"]
|
100
130
|
STDOUT.puts <<-EOS
|
@@ -107,6 +137,33 @@ module Command
|
|
107
137
|
EOS
|
108
138
|
exit Narou::EXIT_ERROR_CODE
|
109
139
|
end
|
140
|
+
|
141
|
+
def open_browser_when_server_boot(address)
|
142
|
+
return if @options["no-browser"]
|
143
|
+
Thread.new do
|
144
|
+
sleep 0.2 until Narou::AppServer.running?
|
145
|
+
Helper.open_browser(address)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
def send_rebooted_event_when_connection_recover(push_server)
|
150
|
+
return unless @rebooted
|
151
|
+
Thread.new do |th|
|
152
|
+
timeout = Time.now + 20
|
153
|
+
# WebSocketのコネクションが回復するまで待つ
|
154
|
+
until push_server.connections.count != 0
|
155
|
+
sleep 0.2
|
156
|
+
th.kill if Time.now > timeout
|
157
|
+
end
|
158
|
+
puts "<yellow>再起動が完了しました。</yellow>".termcolor
|
159
|
+
push_server.send_all(:"server.rebooted")
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
def send_hello_message
|
164
|
+
puts "<white>Narou.rb version #{::Version}</white>".termcolor
|
165
|
+
end
|
166
|
+
|
110
167
|
end
|
111
168
|
end
|
112
169
|
|
data/lib/downloader.rb
CHANGED
@@ -782,7 +782,7 @@ class Downloader
|
|
782
782
|
$stdout.silence do
|
783
783
|
Command::Tag.execute!(%W(#{@id} --add 404 --color white --no-overwrite-color))
|
784
784
|
end
|
785
|
-
Command::Freeze.execute!([@id])
|
785
|
+
Command::Freeze.execute!([@id, "--on"])
|
786
786
|
end
|
787
787
|
else
|
788
788
|
@stream.error "何らかの理由により目次が取得できませんでした(#{e.message})"
|
@@ -1112,6 +1112,9 @@ class Downloader
|
|
1112
1112
|
end
|
1113
1113
|
sleep(WAITING_TIME_FOR_503)
|
1114
1114
|
retry
|
1115
|
+
elsif e.message =~ /^404/
|
1116
|
+
@stream.error "#{url} がダウンロード出来ませんでした。時間をおいて再度試してみてください"
|
1117
|
+
exit Narou::EXIT_ERROR_CODE
|
1115
1118
|
else
|
1116
1119
|
raise
|
1117
1120
|
end
|
data/lib/narou.rb
CHANGED
@@ -21,6 +21,7 @@ module Narou
|
|
21
21
|
GLOBAL_REPLACE_NAME = "replace.txt"
|
22
22
|
EXIT_ERROR_CODE = 127
|
23
23
|
EXIT_INTERRUPT = 126
|
24
|
+
EXIT_REQUEST_REBOOT = 125
|
24
25
|
|
25
26
|
UPDATE_SORT_KEYS = {
|
26
27
|
"id" => "ID", "last_update" => "更新日", "title" => "タイトル", "author" => "作者名",
|
@@ -275,5 +276,24 @@ module Narou
|
|
275
276
|
type == 2 ? "短編" : "連載"
|
276
277
|
end
|
277
278
|
|
279
|
+
#
|
280
|
+
# Narou.rb gem の最新バージョン番号を取得する
|
281
|
+
#
|
282
|
+
# rubygems公式APIによる取得は、WindowsでのSSL証明書問題で取得出来ない
|
283
|
+
# 環境があるため、gemコマンド経由で取得する
|
284
|
+
#
|
285
|
+
def latest_version
|
286
|
+
response = `gem search ^narou$`.split("\n")
|
287
|
+
if response.last =~ /\Anarou \((.+?)\)\z/
|
288
|
+
$1
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
def commit_version
|
293
|
+
cv_path = File.expand_path("commitversion", get_script_dir)
|
294
|
+
File.read(cv_path) if File.exist?(cv_path)
|
295
|
+
end
|
296
|
+
memoize :commit_version
|
297
|
+
|
278
298
|
end
|
279
299
|
end
|
data/lib/novelconverter.rb
CHANGED
@@ -623,6 +623,7 @@ class NovelConverter
|
|
623
623
|
section["chapter"] = @converter.convert(section["chapter"], "chapter")
|
624
624
|
end
|
625
625
|
@inspector.subtitle = section["subtitle"]
|
626
|
+
section["subtitle"] = @converter.convert(section["subtitle"], "subtitle")
|
626
627
|
element = section["element"]
|
627
628
|
data_type = element.delete("data_type") || "text"
|
628
629
|
element.each do |text_type, elm_text|
|
@@ -632,7 +633,6 @@ class NovelConverter
|
|
632
633
|
end
|
633
634
|
element[text_type] = @converter.convert(elm_text, text_type)
|
634
635
|
end
|
635
|
-
section["subtitle"] = @converter.convert(section["subtitle"], "subtitle")
|
636
636
|
sections << section
|
637
637
|
end
|
638
638
|
@use_dakuten_font = @converter.use_dakuten_font
|
data/lib/version.rb
CHANGED
data/lib/web/appserver.rb
CHANGED
@@ -6,10 +6,8 @@
|
|
6
6
|
require "socket"
|
7
7
|
require "sinatra/base"
|
8
8
|
require "sinatra/json"
|
9
|
-
if $
|
10
|
-
|
11
|
-
require "pry"
|
12
|
-
end
|
9
|
+
require "sinatra/reloader" if $development
|
10
|
+
require "better_errors" if $debug
|
13
11
|
require "tilt/erubis"
|
14
12
|
require "tilt/haml"
|
15
13
|
require "tilt/sass"
|
@@ -25,7 +23,7 @@ module Narou::ServerHelpers
|
|
25
23
|
# タグをHTMLで装飾する
|
26
24
|
#
|
27
25
|
def decorate_tags(tags)
|
28
|
-
tags.map do |tag|
|
26
|
+
tags.sort.map do |tag|
|
29
27
|
%!<span class="tag label label-#{Command::Tag.get_color(tag)}" data-tag="#{escape_html(tag)}">#{escape_html(tag)}</span>!
|
30
28
|
end.join(" ")
|
31
29
|
end
|
@@ -106,9 +104,13 @@ module Narou::ServerHelpers
|
|
106
104
|
end
|
107
105
|
|
108
106
|
class Narou::AppServer < Sinatra::Base
|
109
|
-
register Sinatra::Reloader if $
|
107
|
+
register Sinatra::Reloader if $development
|
110
108
|
helpers Narou::ServerHelpers
|
111
109
|
|
110
|
+
@@request_reboot = false
|
111
|
+
@@already_update_system = false
|
112
|
+
@@gem_update_last_log = ""
|
113
|
+
|
112
114
|
configure do
|
113
115
|
set :app_file, __FILE__
|
114
116
|
set :erb, trim: "-"
|
@@ -119,13 +121,31 @@ class Narou::AppServer < Sinatra::Base
|
|
119
121
|
Command::Version.create_version_string
|
120
122
|
end
|
121
123
|
|
122
|
-
set :environment, :production unless $
|
124
|
+
set :environment, :production unless $development
|
125
|
+
set :server, :webrick
|
126
|
+
|
127
|
+
if $debug
|
128
|
+
use BetterErrors::Middleware
|
129
|
+
BetterErrors.application_root = Narou.get_script_dir
|
130
|
+
end
|
123
131
|
end
|
124
132
|
|
125
133
|
def self.push_server=(server)
|
126
134
|
@@push_server = server
|
127
135
|
end
|
128
136
|
|
137
|
+
def self.push_server
|
138
|
+
@@push_server
|
139
|
+
end
|
140
|
+
|
141
|
+
def self.request_reboot
|
142
|
+
@@request_reboot = true
|
143
|
+
end
|
144
|
+
|
145
|
+
def self.request_reboot?
|
146
|
+
@@request_reboot
|
147
|
+
end
|
148
|
+
|
129
149
|
#
|
130
150
|
# サーバのアドレスを生成
|
131
151
|
#
|
@@ -291,7 +311,7 @@ class Narou::AppServer < Sinatra::Base
|
|
291
311
|
get "/about" do
|
292
312
|
@narourb_version = settings.version
|
293
313
|
@ruby_version = build_ruby_version
|
294
|
-
haml :
|
314
|
+
haml :_about, layout: false
|
295
315
|
end
|
296
316
|
|
297
317
|
post "/shutdown" do
|
@@ -299,6 +319,36 @@ class Narou::AppServer < Sinatra::Base
|
|
299
319
|
"シャットダウンしました。再起動するまで操作は出来ません"
|
300
320
|
end
|
301
321
|
|
322
|
+
post "/reboot" do
|
323
|
+
self.class.request_reboot
|
324
|
+
self.class.quit!
|
325
|
+
haml :_rebooting, layout: false
|
326
|
+
end
|
327
|
+
|
328
|
+
post "/update_system" do
|
329
|
+
Thread.new do
|
330
|
+
buffer = `gem update --no-document narou`
|
331
|
+
@@gem_update_last_log = buffer.strip!
|
332
|
+
if buffer =~ /Nothing to update\z/
|
333
|
+
@@push_server.send_all("server.update.nothing" => buffer)
|
334
|
+
elsif buffer.include?("Gems updated: narou")
|
335
|
+
@@already_update_system = true
|
336
|
+
@@push_server.send_all("server.update.success" => buffer)
|
337
|
+
else
|
338
|
+
@@push_server.send_all("server.update.failure" => buffer)
|
339
|
+
end
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
343
|
+
post "/gem_update_last_log" do
|
344
|
+
content_type "text/plain"
|
345
|
+
@@gem_update_last_log
|
346
|
+
end
|
347
|
+
|
348
|
+
post "/check_already_update_system" do
|
349
|
+
json({ result: @@already_update_system })
|
350
|
+
end
|
351
|
+
|
302
352
|
before "/novels/:id/*" do
|
303
353
|
@id = params[:id]
|
304
354
|
not_found unless @id =~ /^\d+$/
|
@@ -376,12 +426,16 @@ class Narou::AppServer < Sinatra::Base
|
|
376
426
|
ext = device ? device.ebook_file_ext : ".epub"
|
377
427
|
path = Narou.get_ebook_file_path(@id, ext)
|
378
428
|
if File.exist?(path)
|
379
|
-
send_file(path, filename: File.basename(path))
|
429
|
+
send_file(path, filename: File.basename(path), type: "application/octet-stream")
|
380
430
|
else
|
381
431
|
not_found
|
382
432
|
end
|
383
433
|
end
|
384
434
|
|
435
|
+
not_found do
|
436
|
+
"not found"
|
437
|
+
end
|
438
|
+
|
385
439
|
# -------------------------------------------------------------------------------
|
386
440
|
# API's
|
387
441
|
# -------------------------------------------------------------------------------
|
@@ -411,7 +465,7 @@ class Narou::AppServer < Sinatra::Base
|
|
411
465
|
tags.include?("end") ? "完結" : nil,
|
412
466
|
tags.include?("404") ? "削除" : nil,
|
413
467
|
].compact.join(", "),
|
414
|
-
download: %!<a href="/novels/#{id}/download" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-
|
468
|
+
download: %!<a href="/novels/#{id}/download" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-download-alt"></span></a>!,
|
415
469
|
frozen: Narou.novel_frozen?(id),
|
416
470
|
new_arrivals_date: data["new_arrivals_date"].tap { |m| break m.to_i if m },
|
417
471
|
general_lastup: data["general_lastup"].tap { |m| break m.to_i if m }
|
@@ -529,7 +583,7 @@ class Narou::AppServer < Sinatra::Base
|
|
529
583
|
target = params["target"] or return ""
|
530
584
|
id = Downloader.get_id_by_target(target) or return ""
|
531
585
|
@list = Command::Diff.new.get_diff_list(id)
|
532
|
-
haml :
|
586
|
+
haml :_diff_list, layout: false
|
533
587
|
end
|
534
588
|
|
535
589
|
post "/api/diff_clean" do
|
@@ -566,7 +620,7 @@ class Narou::AppServer < Sinatra::Base
|
|
566
620
|
get "/api/tag_list" do
|
567
621
|
result = '<div><span class="tag label label-default" data-tag="">タグ検索を解除</span></div>'
|
568
622
|
tagname_list = Command::Tag.get_tag_list.keys
|
569
|
-
tagname_list.each do |tagname|
|
623
|
+
tagname_list.sort.each do |tagname|
|
570
624
|
result << "<div>#{decorate_tags([tagname])} " \
|
571
625
|
"<span class='select-color-button' data-target-tag='#{h tagname}'>" \
|
572
626
|
"<span class='#{Command::Tag.get_color(tagname)}'>a</span></span></div>"
|
@@ -683,9 +737,7 @@ class Narou::AppServer < Sinatra::Base
|
|
683
737
|
end
|
684
738
|
|
685
739
|
get "/api/version/latest.json" do
|
686
|
-
|
687
|
-
fp.read
|
688
|
-
end
|
740
|
+
json({ version: Narou.latest_version })
|
689
741
|
end
|
690
742
|
|
691
743
|
# -------------------------------------------------------------------------------
|
@@ -184,21 +184,28 @@ var Narou = (function() {
|
|
184
184
|
});
|
185
185
|
},
|
186
186
|
|
187
|
-
on: function(event, block) {
|
187
|
+
on: function(event, block, once) {
|
188
188
|
if (typeof block !== "function") {
|
189
189
|
$.error("need a function");
|
190
190
|
}
|
191
191
|
var stack = this.events[event] || [];
|
192
|
-
stack.push(block);
|
192
|
+
stack.push([block, once]);
|
193
193
|
this.events[event] = stack;
|
194
194
|
},
|
195
195
|
|
196
|
+
one: function(event, block) {
|
197
|
+
this.on(event, block, true);
|
198
|
+
},
|
199
|
+
|
196
200
|
trigger: function(event, data) {
|
197
201
|
var self = this;
|
198
202
|
var stack = this.events[event] || [];
|
199
|
-
|
200
|
-
|
201
|
-
|
203
|
+
this.events[event] =
|
204
|
+
_.reject(stack, function(pair) {
|
205
|
+
var block = pair[0], once = pair[1];
|
206
|
+
block.call(self, data);
|
207
|
+
return once;
|
208
|
+
});
|
202
209
|
},
|
203
210
|
|
204
211
|
send: function(json) {
|
@@ -224,7 +231,7 @@ var Narou = (function() {
|
|
224
231
|
this.target_id = target_id;
|
225
232
|
if (!this.closed) {
|
226
233
|
// メニューを開いた状態で直接ボタンを押した場合に一旦閉じるイベントを起こさせる
|
227
|
-
|
234
|
+
this.close();
|
228
235
|
}
|
229
236
|
this.closed = false;
|
230
237
|
var caller = function() {
|
@@ -241,6 +248,10 @@ var Narou = (function() {
|
|
241
248
|
});
|
242
249
|
},
|
243
250
|
|
251
|
+
close: function() {
|
252
|
+
$(document).trigger("click");
|
253
|
+
},
|
254
|
+
|
244
255
|
openConsoleDialog: function(callback) {
|
245
256
|
if (typeof callback !== "function") return;
|
246
257
|
var $console_dialog = $("#console-dialog");
|
@@ -303,12 +314,18 @@ var Narou = (function() {
|
|
303
314
|
var self = this;
|
304
315
|
$("#context-menu-setting").on("click", function(e) {
|
305
316
|
e.preventDefault();
|
306
|
-
|
317
|
+
var setting_page_path = "/novels/" + self.target_id + "/setting";
|
318
|
+
if (storage.get("open_new_tab_setting_pages")) {
|
319
|
+
window.open(setting_page_path);
|
320
|
+
}
|
321
|
+
else {
|
322
|
+
location.href = setting_page_path;
|
323
|
+
}
|
307
324
|
});
|
308
325
|
$("#context-menu-update").on("click", function(e) {
|
309
326
|
e.preventDefault();
|
310
327
|
self.openConsoleDialog(function() {
|
311
|
-
self.action.
|
328
|
+
self.action.updateForce(self.target_id);
|
312
329
|
});
|
313
330
|
});
|
314
331
|
$("#context-menu-send").on("click", function(e) {
|
@@ -457,10 +474,10 @@ var Narou = (function() {
|
|
457
474
|
|
458
475
|
updateGeneralLastup: function() {
|
459
476
|
bootbox.dialog({
|
460
|
-
title:
|
461
|
-
message: "
|
462
|
-
"最新話掲載日は通常時の
|
463
|
-
"掲載日だけを調べて、選択的に
|
477
|
+
title: "最新話掲載日の更新",
|
478
|
+
message: "凍結済みを除く各小説の最新話掲載日のみを更新して反映させます。<br>" +
|
479
|
+
"最新話掲載日は通常時のUpdateでも更新されるので、手動で更新する必要は基本的にはありません。<br>" +
|
480
|
+
"掲載日だけを調べて、選択的にUpdateをかけるなど、用途を理解した上で小説サイトのサーバーに負荷をかけない範囲でご利用下さい。",
|
464
481
|
backdrop: true,
|
465
482
|
buttons: {
|
466
483
|
cancel: {
|
@@ -606,6 +623,70 @@ var Narou = (function() {
|
|
606
623
|
});
|
607
624
|
});
|
608
625
|
},
|
626
|
+
|
627
|
+
rebootDialog: function() {
|
628
|
+
var self = this;
|
629
|
+
bootbox.dialog({
|
630
|
+
title: '<span class="glyphicon glyphicon-refresh"></span> 再起動',
|
631
|
+
message: "<p>Narou.rb WEB UI サーバを再起動します。<br>" +
|
632
|
+
"バージョンを更新してある場合は最新バージョンで立ち上がります。</p>" +
|
633
|
+
"<p class=text-danger>アップデート中や変換中の小説がある場合は中断されます。<br>" +
|
634
|
+
"終わったかどうか確認しましょう。</p>",
|
635
|
+
backdrop: true,
|
636
|
+
buttons: {
|
637
|
+
danger: {
|
638
|
+
label: "再起動",
|
639
|
+
className: "btn-danger",
|
640
|
+
callback: function() {
|
641
|
+
self.reboot();
|
642
|
+
}
|
643
|
+
},
|
644
|
+
main: {
|
645
|
+
label: "キャンセル",
|
646
|
+
className: "btn-default",
|
647
|
+
}
|
648
|
+
}
|
649
|
+
});
|
650
|
+
},
|
651
|
+
|
652
|
+
reboot: function() {
|
653
|
+
$.post("/reboot", function(data) {
|
654
|
+
bootbox.hideAll();
|
655
|
+
bootbox.dialog({
|
656
|
+
title: "",
|
657
|
+
closeButton: false,
|
658
|
+
message: data
|
659
|
+
});
|
660
|
+
});
|
661
|
+
},
|
662
|
+
|
663
|
+
checkUpdatedSystem: function(funcs) {
|
664
|
+
$.post("/check_already_update_system", function(data) {
|
665
|
+
if (data.result) {
|
666
|
+
$.post("/gem_update_last_log", function(log) {
|
667
|
+
funcs.already_updated(log);
|
668
|
+
});
|
669
|
+
}
|
670
|
+
else {
|
671
|
+
funcs.not_updated();
|
672
|
+
}
|
673
|
+
});
|
674
|
+
},
|
675
|
+
|
676
|
+
updateSystem: function(callback) {
|
677
|
+
var notification = Notification.instance();
|
678
|
+
notification.one("server.update.success", function(log) {
|
679
|
+
callback("success", log);
|
680
|
+
});
|
681
|
+
notification.one("server.update.nothing", function(log) {
|
682
|
+
callback("nothing", log);
|
683
|
+
});
|
684
|
+
notification.one("server.update.failure", function(log) {
|
685
|
+
callback("failure", log);
|
686
|
+
});
|
687
|
+
$.post("/update_system");
|
688
|
+
},
|
689
|
+
|
609
690
|
});
|
610
691
|
|
611
692
|
/*************************************************************************
|