書影が未登録な書籍を検索出きるように対応, 蔵書一覧の検索条件を可視化,起動/停止スクリプトの修正
authorOHASHI, Norikazu <katz@neko-mori.sakura.ne.jp>
Tue, 27 Apr 2021 14:10:46 +0000 (23:10 +0900)
committerOHASHI, Norikazu <katz@neko-mori.sakura.ne.jp>
Tue, 27 Apr 2021 14:10:46 +0000 (23:10 +0900)
create_table.sql
sinatra/app/controllers/web_gui.rb
sinatra/app/models/books_db.rb
sinatra/app/views/book_list.haml
sinatra/app/views/book_regist.haml
sinatra/app/views/scss/layout.scss
start.sh
stop.sh

index 96d8196..ce9606b 100644 (file)
@@ -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)));
index 1689bff..bf01e35 100644 (file)
@@ -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
index a42b176..ef4de4e 100644 (file)
@@ -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
index 5560023..9a4699f 100644 (file)
@@ -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
       #{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"}
           %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
index f8f64d7..a99e3f9 100644 (file)
@@ -21,7 +21,7 @@
         「ISBN探索」を押下すると、該当する本の情報が取得できます。
 
     .message
-      「書影Upload」を押下すると、本の書影を登録できます。
+      画層ファイルを指定して、「書影Upload」を押下すると、本の書影を登録できます。
 
     - if warning
       .warning
index 31c8765..d1a36f5 100644 (file)
@@ -35,7 +35,7 @@
     background: #f8e58c;
     align-items: center;
     text-align: center;
-    height: 50em;
+    height: 52em;
     padding: 5px 0px;
     overflow: auto;
 }
index 9b94269..5d4d6f6 100755 (executable)
--- 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 (executable)
--- 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