--- /dev/null
+# frozen_string_literal: true
+
+source "https://rubygems.org"
+
+git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
+
+# gem "rails"
+
+gem 'sinatra'
+gem 'rack-cache'
+gem 'haml'
+gem 'logger'
+gem 'activerecord'
+gem 'mysql2'
+gem 'rexml'
+gem 'bcrypt'
+gem 'httpclient'
+gem 'sass'
+gem 'scss'
+gem 'coffee-script'
+gem 'unicorn'
+# gem 'mini_racer'
# @params [Hash] Upload用パラメータ
# @return [Hash] Uploadデータ情報
def getUploadData(upload_param)
+ if (upload_param == nil)
+ return nil
+ end
upload_data = Hash.new
file = upload_param[:tempfile]
upload_data[:mime_type] = upload_param[:type]
# 更新用の書籍情報を作成する。
# @param [Hash] params Postで取得した全パラメータ
# @return [Hash] 更新用書籍情報
- def makeBookInfo(params)
+ def makeBookInfo(params, image_f)
book_info = Hash.new
params.each do |key, value|
case key
# 対象キーは書籍情報ではないので飛す
next
end
- if ((key == 'cover_uriD') && (image_f))
+ if ((key == 'cover_uri') && (image_f))
# 登録するイメージがあるのでURIの登録は飛す
next
end
image_f = (params[:cover_base64] != nil)
# 書籍の設定情報を選出
- book_info = makeBookInfo(params)
+ book_info = makeBookInfo(params, image_f)
begin
isbn = book_info[:isbn]
user = UserAccount.getUser(id)
@id = id
@username = user.full_name
- @book_info = BookManager.searchISBN(isbn, id)
+ if (isbn != nil && isbn.length > 0)
+ @book_info = BookManager.searchISBN(isbn, id)
+ end
@is_admin = UserAccount.checkAdmin(id)
rescue UserAccount::NotFoundInstanceError
raise WebError.new(status: 404, message: "ユーザ情報が存在しません。")
rescue BookManager::FailedGetInstance
raise WebError.new(status: 500, message: "ISBNによる書籍検索に失敗しました。", refs: "/book_regist")
end
+ if (isbn == nil || isbn.length == 0)
+ @book_info = Hash.new
+ @warning = "ISBNを入力してください。"
+ elsif (@book_info[:title] == nil )
+ @warning = "ISBN探索にて対象の書籍が見付かりませんでした。"
+ end
goPage :book_regist
end
@book_info[:cover_base64] = base64
@book_info[:mime_type] = mime_type
@book_info[:cover_uri] = "data:" + mime_type + ";base64," + base64
+ else
+ @warning = "書影のファイルを指定してください"
end
goPage :book_regist
end
end
parsons = getParsonsFromNDL(creators)
book_hash = {
- search_type: SEARCH_ON_OPENNDL,
+ search_type: SEARCH_ON_NDL,
isbn: isbn,
title: book.elements['dcterms:title'] != nil ? book.elements['dcterms:title'].text : nil,
volume: book.elements['dcndl:volume/rdf:Description/rdf:value'] != nil ? book.elements['dcndl:volume/rdf:Description/rdf:value'].text.gsub(/[^\d]/, "").to_i : nil,
- # encoding: utf-8
- is_admin = @is_admin; id = @id; book_info = @book_info
- update_f = @update_f; is_admin_books = @is_admin_books
-- if book_info[:title] != nil
+- warning = @warning
+- if book_info[:title] != nil && book_info[:title].length > 0
- isbn_regist_f = true
- else
- isbn_regist_f = false
- else
新規に蔵書の情報を登録することができます。
-- if !isbn_regist_f
+- if update_f
.message
「ISBN探索」を押下すると、該当する本の情報が取得できます。
(取得できない場合は、更新されません)
.message
「書影Upload」を押下すると、本の書影を登録できます。
-
+
+- if warning
+ .warning
+ #{warning}
%hr
%label{ :for => 'isbn' }
%span
ISBN:
- %input{ :name => 'isbn', :type => 'text', :class => 'input_text', :id => 'isbn', :value => book_info[:isbn], :readonly => isbn_regist_f, :required => isbn_regist_f}
- %input{ :type => 'submit', :class => 'side_button', :value => 'ISBN探索', :formaction => '/book_search_isbn', :disabled => isbn_regist_f}
+ %input{ :name => 'isbn', :type => 'text', :class => 'input_text', :id => 'isbn', :value => book_info[:isbn], :readonly => update_f, :required => isbn_regist_f}
+ %input{ :type => 'submit', :class => 'side_button', :value => 'ISBN探索', :formaction => '/book_search_isbn', :disabled => update_f}
.item
%label{ :for => 'title' }
padding: 2px;
}
+.warning {
+ margin-left: 10px;
+ margin-right: 10px;
+ font-family: 'Sawarabi Mincho';
+ font-size: 1em;
+ text-align: left;
+ padding: 2px;
+ color: #ee827c;
+}
+
.formstyle {
margin: 0, auto;
# 書籍管理サーバベース処理
# @author OHASHI, Norikazu
+require 'bundler/setup'
require 'sinatra/base'
require_relative './app/controllers/web_gui'
# require 'app/controllers/restful_api'
--- /dev/null
+# coding: utf-8
+require 'fileutils'
+
+@dir = File.dirname(__FILE__)
+
+worker_processes 2 # CPUのコア数に揃える
+working_directory @dir
+
+timeout 300
+listen 8080
+
+@pid_path = File.join(@dir, "tmp/pids")
+FileUtils.mkdir_p(@pid_path)
+pid File.join(@pid_path, "unicorn.pid") #pidを保存するファイル
+
+@log_path = File.join(@dir, "log")
+FileUtils.mkdir_p(@log_path)
+# unicornは標準出力には何も吐かないのでログ出力を忘れずに
+stderr_path File.join(@log_path,"unicorn.stderr.log")
+stdout_path File.join(@log_path,"unicorn.stdout.log")
--- /dev/null
+#!/bin/sh
+
+if [ -z $BOOK_SERVER_PATH ]
+then
+ BOOK_SERVER_PATH="."
+fi
+(cd $BOOK_SERVER_PATH; bundle exec unicorn -c unicorn.rb -D)
--- /dev/null
+#!/bin/sh
+
+if [ -z $BOOK_SERVER_PATH ]
+then
+ BOOK_SERVER_PATH="."
+fi
+(cd $BOOK_SERVER_PATH; kill `cat tmp/pids/unicorn.pid`)