From 5d45a6bd77d47432f8f83cc9d02a744f9ab9965d Mon Sep 17 00:00:00 2001 From: "OHASHI, Norikazu" Date: Fri, 24 May 2019 21:43:30 +0900 Subject: [PATCH] =?utf8?q?=E8=94=B5=E6=9B=B8=E3=83=AA=E3=82=B9=E3=83=88?= =?utf8?q?=E3=81=AE=E3=83=AA=E3=82=BB=E3=83=83=E3=83=88=E3=81=8C=E4=B8=8A?= =?utf8?q?=E6=89=8B=E3=81=8F=E3=81=84=E3=81=8B=E3=81=AA=E3=81=84=E3=81=AE?= =?utf8?q?=E3=82=92=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- sinatra/app/controllers/web_gui.rb | 35 +++++++++++++++++++---------- sinatra/app/views/book_list.haml | 3 +++ sinatra/app/views/scss/classes.scss | 1 + sinatra/app/views/scss/layout.scss | 2 +- sinatra/app/views/scss/list.scss | 2 +- 5 files changed, 29 insertions(+), 14 deletions(-) diff --git a/sinatra/app/controllers/web_gui.rb b/sinatra/app/controllers/web_gui.rb index dd58a47..5880a5d 100644 --- a/sinatra/app/controllers/web_gui.rb +++ b/sinatra/app/controllers/web_gui.rb @@ -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 diff --git a/sinatra/app/views/book_list.haml b/sinatra/app/views/book_list.haml index 27aee3d..a406808 100644 --- a/sinatra/app/views/book_list.haml +++ b/sinatra/app/views/book_list.haml @@ -12,6 +12,9 @@ %h3 #{user_name} さんの蔵書一覧は以下となります。 +.message + 登録されている蔵書は #{full_size}冊になります。 + .find_form %form{:action => "/book_list/find", :method => "post"} %table diff --git a/sinatra/app/views/scss/classes.scss b/sinatra/app/views/scss/classes.scss index 5b53f01..4eadf8b 100644 --- a/sinatra/app/views/scss/classes.scss +++ b/sinatra/app/views/scss/classes.scss @@ -5,6 +5,7 @@ font-family: "Sawarabi Mincho"; font-size: 1em; text-align: left; + padding: 2px; } .formstyle { diff --git a/sinatra/app/views/scss/layout.scss b/sinatra/app/views/scss/layout.scss index 68259ac..0a1c041 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: 45em; + height: 50em; padding: 5px 0px; overflow: auto; } diff --git a/sinatra/app/views/scss/list.scss b/sinatra/app/views/scss/list.scss index 5285946..d699f52 100644 --- a/sinatra/app/views/scss/list.scss +++ b/sinatra/app/views/scss/list.scss @@ -1,7 +1,7 @@ @charset "utf-8"; .book_list{ max-height: 32em; - margin: auto; + margin: 5px; padding: 2px; width: 98%; overflow: auto; -- 2.19.2