From 726e7cab7baee72a1db3bc9446e248f6f8a37e64 Mon Sep 17 00:00:00 2001 From: "OHASHI, Norikazu" Date: Tue, 27 Apr 2021 23:10:46 +0900 Subject: [PATCH] =?utf8?q?=E6=9B=B8=E5=BD=B1=E3=81=8C=E6=9C=AA=E7=99=BB?= =?utf8?q?=E9=8C=B2=E3=81=AA=E6=9B=B8=E7=B1=8D=E3=82=92=E6=A4=9C=E7=B4=A2?= =?utf8?q?=E5=87=BA=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E5=AF=BE?= =?utf8?q?=E5=BF=9C,=20=E8=94=B5=E6=9B=B8=E4=B8=80=E8=A6=A7=E3=81=AE?= =?utf8?q?=E6=A4=9C=E7=B4=A2=E6=9D=A1=E4=BB=B6=E3=82=92=E5=8F=AF=E8=A6=96?= =?utf8?q?=E5=8C=96,=E8=B5=B7=E5=8B=95/=E5=81=9C=E6=AD=A2=E3=82=B9?= =?utf8?q?=E3=82=AF=E3=83=AA=E3=83=97=E3=83=88=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- create_table.sql | 5 ++-- sinatra/app/controllers/web_gui.rb | 1 + sinatra/app/models/books_db.rb | 14 +++++++--- sinatra/app/views/book_list.haml | 44 ++++++++++++++++++------------ sinatra/app/views/book_regist.haml | 2 +- sinatra/app/views/scss/layout.scss | 2 +- start.sh | 7 ++++- stop.sh | 6 +++- 8 files changed, 54 insertions(+), 27 deletions(-) diff --git a/create_table.sql b/create_table.sql index 96d8196..ce9606b 100644 --- a/create_table.sql +++ b/create_table.sql @@ -43,9 +43,10 @@ CREATE TABLE book_covers ( create_at DATETIME NOT NULL, update_at DATETIME NOT NULL); -CREATE VIEW book_fulls (isbn, title, volume, author, publisher, pubdate, user_id) AS +CREATE VIEW book_fulls (isbn, title, volume, author, publisher, pubdate, + user_id, cover_uri) AS SELECT B.isbn AS isbn, B.title AS title, B.volume AS volume, B.author AS author, B.publisher AS publisher, B.pubdate AS pubdate, - C.user_id AS user_id + C.user_id AS user_id, B.cover_uri AS cover_uri FROM (books AS B left join book_collections AS C ON((B.isbn = C.isbn))); diff --git a/sinatra/app/controllers/web_gui.rb b/sinatra/app/controllers/web_gui.rb index 1689bff..bf01e35 100644 --- a/sinatra/app/controllers/web_gui.rb +++ b/sinatra/app/controllers/web_gui.rb @@ -699,6 +699,7 @@ class WebGui < Sinatra::Base position[:step], find_status) @start = position[:start] @step = position[:step] + @find_status = find_status if (@book_list == nil) raise WebError.new(status: 404, message: "対象の蔵書が見つかりません。", refs: "/user_home") end diff --git a/sinatra/app/models/books_db.rb b/sinatra/app/models/books_db.rb index a42b176..ef4de4e 100644 --- a/sinatra/app/models/books_db.rb +++ b/sinatra/app/models/books_db.rb @@ -622,11 +622,17 @@ class BookManager if (find_books == nil) break end - if (value =~ /^\/(.+)\/$/) - reg_value = $~[1] - find_books = find_books.with_regexp(key, reg_value) + if (key == :image_unregist) + # 書影の有無を確認するための検索 + find_books = find_books.where(cover_uri: nil) else - find_books = find_books.where(key => value) + # 通常の要素検索 + if (value =~ /^\/(.+)\/$/) + reg_value = $~[1] + find_books = find_books.with_regexp(key, reg_value) + else + find_books = find_books.where(key => value) + end end end end diff --git a/sinatra/app/views/book_list.haml b/sinatra/app/views/book_list.haml index 5560023..9a4699f 100644 --- a/sinatra/app/views/book_list.haml +++ b/sinatra/app/views/book_list.haml @@ -1,6 +1,26 @@ - # encoding: utf-8 - user_name = @username; book_list = @book_list - start = @start; step = @step; index = @start; full_size = @full_size +:ruby + find_keys = { + :title => '書名', :author => '著者', :publisher => '出版社', + :original_author => '原作', :illustrator => '作画', :translator => '翻訳', + :supervisor => '監修', :series => '単行本シリーズ', + :image_unregist => '書影未登録' + } + +- find_params = nil +- if @find_status + - @find_status.each do |key, value| + - if value.empty? + - find_str = "#{find_keys[key]}" + - else + - find_str = "#{find_keys[key]} = #{value}" + - if find_params + - find_params += ", " + find_str + - else + - find_params = find_str + - if start + step >= full_size - next_step = 0 - else @@ -16,7 +36,10 @@ #{user_name} さんの蔵書一覧は以下となります。 .message - 登録されている蔵書は #{full_size}冊になります。 + - if find_params == nil + 登録されている蔵書は #{full_size}冊になります。 + - else + 「#{find_params}」の条件にマッチする蔵書は #{full_size}冊になります。 .find_form %form{:action => "/book_list/find", :method => "post"} @@ -31,22 +54,9 @@ %tr %td %select{ :name => 'kind', :class => 'pulldown', :id => 'kind'} - %option{ :value => 'title' } - 書名 - %option{ :value => 'author' } - 著者 - %option{ :value => 'publisher' } - 出版社 - %option{ :value => 'original_author'} - 原作 - %option{ :value => 'illustrator' } - 作画 - %option{ :value => 'translator' } - 翻訳 - %option{ :value => 'supervisor' } - 監修 - %option{ :value => 'series' } - 単行本シリーズ + - find_keys.each do | key, value | + %option{ :value => key.to_s } + #{value} %td %input{ :type => 'text', :class => 'input_text', :name => 'find_value', :id => 'find_value', :size => 40} %td diff --git a/sinatra/app/views/book_regist.haml b/sinatra/app/views/book_regist.haml index f8f64d7..a99e3f9 100644 --- a/sinatra/app/views/book_regist.haml +++ b/sinatra/app/views/book_regist.haml @@ -21,7 +21,7 @@ 「ISBN探索」を押下すると、該当する本の情報が取得できます。 .message - 「書影Upload」を押下すると、本の書影を登録できます。 + 画層ファイルを指定して、「書影Upload」を押下すると、本の書影を登録できます。 - if warning .warning diff --git a/sinatra/app/views/scss/layout.scss b/sinatra/app/views/scss/layout.scss index 31c8765..d1a36f5 100644 --- a/sinatra/app/views/scss/layout.scss +++ b/sinatra/app/views/scss/layout.scss @@ -35,7 +35,7 @@ background: #f8e58c; align-items: center; text-align: center; - height: 50em; + height: 52em; padding: 5px 0px; overflow: auto; } diff --git a/start.sh b/start.sh index 9b94269..5d4d6f6 100755 --- a/start.sh +++ b/start.sh @@ -4,4 +4,9 @@ if [ -z $BOOK_SERVER_PATH ] then BOOK_SERVER_PATH="." fi -(cd $BOOK_SERVER_PATH; bundle exec unicorn -c unicorn.rb -D) +PID_FILE="$BOOK_SERVER_PATH/tmp/pids/unicorn.pid" +EXEC_STR="bundle exec unicorn -c unicorn.rb -D" +if [ ! -e $PID_FILE ] +then + (cd $BOOK_SERVER_PATH; $EXEC_STR) +fi diff --git a/stop.sh b/stop.sh index 509dfa7..e82dc7c 100755 --- a/stop.sh +++ b/stop.sh @@ -4,4 +4,8 @@ if [ -z $BOOK_SERVER_PATH ] then BOOK_SERVER_PATH="." fi -(cd $BOOK_SERVER_PATH; kill `cat tmp/pids/unicorn.pid`) +PID_FILE="$BOOK_SERVER_PATH/tmp/pids/unicorn.pid" +if [ -e $PID_FILE ] +then + (cd $BOOK_SERVER_PATH; kill `cat $PID_FILE`) +fi -- 2.19.2