From: OHASHI, Norikazu Date: Tue, 27 Apr 2021 14:10:46 +0000 (+0900) Subject: 書影が未登録な書籍を検索出きるように対応, 蔵書一覧の検索条件を可視化,起動/停止スクリプトの修正 X-Git-Url: http://www.wald-der-katze.sakura.ne.jp/git/gitweb.cgi?a=commitdiff_plain;h=726e7cab7baee72a1db3bc9446e248f6f8a37e64;p=book_server.git 書影が未登録な書籍を検索出きるように対応, 蔵書一覧の検索条件を可視化,起動/停止スクリプトの修正 --- 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