蔵書リストのリセットが上手くいかないのを修正。
authorOHASHI, Norikazu <katz@neko-mori.sakura.ne.jp>
Fri, 24 May 2019 12:43:30 +0000 (21:43 +0900)
committerOHASHI, Norikazu <katz@neko-mori.sakura.ne.jp>
Fri, 24 May 2019 12:43:30 +0000 (21:43 +0900)
sinatra/app/controllers/web_gui.rb
sinatra/app/views/book_list.haml
sinatra/app/views/scss/classes.scss
sinatra/app/views/scss/layout.scss
sinatra/app/views/scss/list.scss

index dd58a47..5880a5d 100644 (file)
@@ -2,6 +2,7 @@
 # Web GUI用コントローラ
 # @author OHASHI, Norikazu
 
+require 'rack/cache'
 require 'sinatra/base'
 require 'sinatra'
 require 'haml'
@@ -27,6 +28,16 @@ class WebGui < Sinatra::Base
     end
   end
 
+  set :root, File.join(File.dirname(__FILE__), '..')
+  set :views, Proc.new {File.join(root, "views")}
+  set :public_dir, Proc.new {File.join(root, "../public")}
+  set :haml, :format => :html5
+  set :environment, :production
+  
+  use Rack::Session::Cookie,
+      :expire_after => 1200,
+      :secret => 'change'
+
   helpers do
     # ページIDを保存して、viewに渡す
     # @params [Symble] pageId 表示するページID 
@@ -48,23 +59,15 @@ class WebGui < Sinatra::Base
     end
   end
   
-  set :root, File.join(File.dirname(__FILE__), '..')
-  set :views, Proc.new {File.join(root, "views")}
-  set :public_dir, Proc.new {File.join(root, "../public")}
-  set :haml, :format => :html5
-  set :environment, :production
-  
-  use Rack::Session::Cookie,
-      :expire_after => 1200,
-      :secret => 'change'
-
   # スタイルシート
   get '/css/style.css' do
+    cache_control :public, :must_revalidate, :max_age => 120
     scss :'scss/style'
   end
 
   # javaScript
   get '/scripts/check_form.js' do
+    cache_control :public, :must_revalidate, :max_age => 120
     coffee :'coffee/check_form'
   end
 
@@ -127,6 +130,7 @@ class WebGui < Sinatra::Base
   # ユーザ用ホームページ
   # @raise [WebError] セッションの期限切れ
   get '/user_home' do
+    cache_control :public, :must_revalidate, :max_age => 30
     id = session[:userId]
     if (id == nil)
       raise WebError.new(status: 408, message: "セッション期限切れです。再ログインをしてください。")
@@ -197,6 +201,7 @@ class WebGui < Sinatra::Base
 
   # 蔵書の登録
   get '/book_regist' do
+    cache_control :public, :must_revalidate, :max_age => 30
     id = session[:userId]
     book_update_f = false
     session[:book_update_f] = book_update_f
@@ -216,6 +221,7 @@ class WebGui < Sinatra::Base
 
   # 蔵書の編集
   get '/book_edit/:isbn' do
+    cache_control :public, :must_revalidate, :max_age => 30
     id = session[:userId]
     book_update_f = true
     session[:book_update_f] = book_update_f
@@ -378,6 +384,7 @@ class WebGui < Sinatra::Base
 
   # 書影の表示
   get '/book_image/:hash' do
+    cache_control :public, :must_revalidate, :max_age => 30
     image_hash = params[:hash]
     book_cover = BookManager.getBookCover(image_hash)
     
@@ -391,6 +398,7 @@ class WebGui < Sinatra::Base
 
   # 蔵書情報の取得
   get '/book_info/:isbn' do
+    cache_control :public, :must_revalidate, :max_age => 30
     id = session[:userId]
     isbn = params[:isbn]
     if (id == nil)
@@ -418,7 +426,7 @@ class WebGui < Sinatra::Base
     if (id == nil)
       raise WebError.new(status: 408, message: "セッション期限切れです。再ログインをしてください。")
     end
-    session[:list_status] = {position: {start:0, step: 10},
+    session[:list_status] = {position: {start: 0, step: 10},
                              find_status: nil}
     redirect "/book_list/main"
   end
@@ -430,7 +438,7 @@ class WebGui < Sinatra::Base
       raise WebError.new(status: 408, message: "セッション期限切れです。再ログインをしてください。")
     end
     step = params[:step].to_i
-    session[:list_status][:position][:step] = step
+    session[:list_status][:position] = {start: 0, step: step}
     redirect "/book_list/main"
   end
   
@@ -517,6 +525,7 @@ class WebGui < Sinatra::Base
 
   # 蔵書の削除
   get '/book_delete/:isbn' do
+    cache_control :public, :must_revalidate, :max_age => 30
     id = session[:userId]
     isbn  = params[:isbn]
     if (id == nil)
@@ -537,6 +546,7 @@ class WebGui < Sinatra::Base
 
   # 蔵書の削除
   get '/book_delete/result/:isbn' do
+    cache_control :public, :must_revalidate, :max_age => 30
     id = session[:userId]
     isbn  = params[:isbn]
     begin
@@ -551,6 +561,7 @@ class WebGui < Sinatra::Base
   
   # ログアウトページ
   get '/logout' do
+    cache_control :public, :must_revalidate, :max_age => 30
     # 最終ログイン情報登録
     goPage :logout
   end
index 27aee3d..a406808 100644 (file)
@@ -12,6 +12,9 @@
 %h3
   #{user_name} さんの蔵書一覧は以下となります。
 
+.message
+  登録されている蔵書は #{full_size}冊になります。
+  
 .find_form
   %form{:action => "/book_list/find", :method => "post"}
     %table
index 5b53f01..4eadf8b 100644 (file)
@@ -5,6 +5,7 @@
     font-family: "Sawarabi Mincho";
     font-size: 1em;
     text-align: left;
+    padding: 2px;
 }
 
 .formstyle {
index 68259ac..0a1c041 100644 (file)
@@ -35,7 +35,7 @@
     background: #f8e58c;
     align-items: center;
     text-align: center;
-    height: 45em;
+    height: 50em;
     padding: 5px 0px;
     overflow: auto;
 }
index 5285946..d699f52 100644 (file)
@@ -1,7 +1,7 @@
 @charset "utf-8";
 .book_list{
     max-height: 32em;
-    margin: auto;
+    margin: 5px;
     padding: 2px;
     width: 98%;
     overflow: auto;