user_role INTEGER NOT NULL,
create_at DATETIME NOT NULL,
update_at DATETIME NOT NULL);
+
+CREATE TABLE books (
+ isbn VARCHAR(14) NOT NULL PRIMARY KEY,
+ title VARCHAR(255) NOT NULL,
+ volume INTEGER,
+ series VARCHAR(255),
+ author VARCHAR(127),
+ orignal_author VARCHAR(127),
+ translator VARCHAR(127),
+ supervisor VARCHAR(127),
+ publisher VARCHAR(127),
+ pubdate DATE,
+ cover TEXT,
+ create_at DATETIME NOT NULL,
+ update_at DATETIME NOT NULL);
+
+CREATE TABLE book_collections (
+ isbn VARCHAR(14) NOT NULL,
+ user_id INTEGER NOT NULL,
+ summary TEXT,
+ rank INTEGER,
+ create_at DATETIME NOT NULL,
+ update_at DATETIME NOT NULL
+ PRIMARY KEY(isbn, user_id));
+
+CREATE TABLE book_covers (
+ key_hash VARCHAR(60) NOT NULL PRIMARY KEY,
+ isbn VARCHAR(14) NOT NULL UNIQUE,
+ mime_type VARCHAR(255) NOT NULL,
+ shadow LONGBLOB NOT NULL,
+ create_at DATETIME NOT NULL,
+ update_at DATETIME NOT NULL);
| 1 | isbn | VARCHAR(14) | NOT NULL, PRIMARY KEY | ISBNコード |
| 2 | title | VARCHAR(255) | NOT NULL | 書名 |
| 3 | volume | INTEGER | | 巻数 |
-| 4 | author | VARCHAR(127) | | 著者名 |
-| 5 | orignal_author | VARCHAR(127) | | 原著者 |
-| 6 | translator | VARCHAR(127) | | 翻訳者 |
-| 7 | publisher | VARCHAR(127) | | 出版社 |
-| 8 | book_shadow | TEXT | | 書影(URL) |
-| 9 | creat_at | DATETIME | NOT NULL | 登録日時 |
-| 10 | update_at | DATETIME | NOT NULL | 更新日時 |
+| 4 | series | VARCHAR(255) | | シリーズ名 |
+| 5 | author | VARCHAR(127) | | 著者名 |
+| 6 | orignal_author | VARCHAR(127) | | 原著者 |
+| 7 | translator | VARCHAR(127) | | 翻訳者 |
+| 8 | supervisor | VARCHAR(127) | | 監修者 |
+| 9 | publisher | VARCHAR(127) | | 出版社 |
+| 10 | pubdate | DATE | | 出版日 |
+| 11 | cover | TEXT | | 書影(URL) |
+| 12 | creat_at | DATETIME | NOT NULL | 登録日時 |
+| 13 | update_at | DATETIME | NOT NULL | 更新日時 |
### 蔵書管理テーブル (book\_collections)
| 項番 | カラム名 | 型 | 属性 | 概要 |
注: isdn + user_id で複合キーとする。
-### 書影管理テーブル (book\_shadows)
+### 書影管理テーブル (book\_covers)
| 項番 | カラム名 | 型 | 属性 | 概要 |
| --: | --- | --- | --- | --- |
| 1 | key_hash | VARCHAR(60) | NOT NULL, PRIMARY KEY | SHA125 HASH (アクセスキー) |
| 6 | update_at | DATETIME | NOT NULL | 更新日時 |
注: 画像をロードした場合の管理用
+
+### NewsReleaseテーブル (news\_Relases)
+| 項番 | カラム名 | 型 | 属性 | 概要 |
+| --: | --- | --- | --- | --- |
+| 1 | id | INTAGER | NOT NULL, AUTO_INCREMENT, PRIMARY KEY | ReleaseId |
+| 2 | message | TEXT | NOT NULL | メッセージ |
+| 3 | creat_at | DATETIME | NOT NULL | 登録日時 |
+| 4 | update_at | DATETIME | NOT NULL | 更新日時 |
+
+## 使用RestAPI
+### openBD
+
+#### 参照URI
+[openBD](https://openbd.jp)
+
+#### API仕様
+ * 書誌情報取得:
+ /get?isbn=ISBN,ISBN
+ * 収録範囲の取得:
+ /coverage
+ * JSONスキーマの取得:
+ /schema
+
@params = params
end
end
+
+ helpers do
+ # ページIDを保存して、viewに渡す
+ # @params [Simbole] pageId 表示するページID
+ def goPage(pageId)
+ @pageId = pageId
+ haml pageId
+ end
+ end
set :root, File.join(File.dirname(__FILE__), '..')
set :views, Proc.new {File.join(root, "views")}
# メインページ
get '/' do
- haml :main
+ goPage :main
end
# サインアップページ
get '/signup' do
- haml :signup
+ goPage :signup
end
# サインアップページ(POST)
# ログインページ
get '/login' do
- haml :login
+ goPage :login
end
# ログインページ(POST)
@username = user.full_name
@is_addmin = user.isAddmin
@newest_list = [ "書籍1", "書籍2", "書籍3"]
- haml :user_home
+ goPage :user_home
end
# ユーザ情報編集ページ
end
begin
user = UserAccount.getUser(id)
+ @admin_f = false
@id = id
@username = user.full_name
@account = user.user_name
rescue UserAccount::NotFoundInstanceError
raise WebError.new(status: 400, message: "該当するユーザが存在しません。")
end
- haml :user_edit
+ goPage :user_edit
end
# ユーザ情報編集ページ(POST)
# ログアウトページ
get '/logout' do
# 最終ログイン情報登録
- haml :logout
+ goPage :logout
end
# エラーページ
return user.isAddmin()
end
- private_class_method :checkAdmin
+ # SALT と Password Hash を生成する
+ # @param [String] passwd パスワード
+ # @return [String, String] SALT, パスワードハッシュ
+ def self.makeHash(passwd)
+ passwd_salt = BCrypt::Engine.generate_salt
+ passwd_hash = BCrypt::Engine.hash_secret(passwd, passwd_salt)
+
+ return passwd_salt, passwd_hash
+ end
+
+ private_class_method :checkAdmin, :makeHash
# ユーザアカウントを作成
# @param [String] name ユーザ名
end
# パスワードのハッシュ化
- passwd_salt = BCrypt::Engine.generate_salt
- passwd_hash = BCrypt::Engine.hash_secret(passwd, passwd_salt)
+ passwd_salt, passwd_hash = makeHash(passwd)
# ユーザデータの登録
user = User.new
end
if (key == :passwd)
# パスワード更新
- user.passwd_hash = BCrypt::Engine.hash_secret(value, user.passwd_salt)
+ user.passwd_salt, user.passwd_hash = makeHash(value)
change_f = true
else
if (value != user.send(key))
エラーが発生しました。
%p= error_message
- .buttoms
- .buttoms__push
- - if refs == nil
- %a{ :href => '/'}
- メインにもどる
- - else
- %a{ :href => refs}
- もどる
+ .buttons
+ - if refs == nil
+ %input{ :type => 'button', :class=>'push_button', :onclick => "location.href='/'", :value => 'メインにもどる'}
+ - else
+ %input{ :type => 'button', :class=>'push_button', :onclick => "location.href='#{refs}'", :value => 'もどる'}
%span
パスワード:
%input{ :name => 'passwd', :type => 'password', :id => 'passwd', :pattern => '.{6,}', :required => true}
- %hr
.buttons
- %input{ :type => 'submit', :value => '送信'}
- %input{ :type => 'button', :onclick =>"location.href='/'", :value => 'もどる' }
+ %hr
+ %input{ :type => 'submit', :class=>"push_button", :value => '送信'}
+ %input{ :type => 'button', :class=>"push_button", :onclick =>"location.href='/'", :value => 'もどる' }
%h2
おつかれさまでした。
-.buttoms
- .buttoms__push
- %a{ :href => '/'}
- メインにもどる
+.buttons
+ %input{ :type => 'button', :class=>"push_button", :onclick =>"location.href='/'", :value => 'メインにもどる' }
+
- # encoding: utf-8
%h1
- 蔵書管理 Web v0.01
+ □■□■ 蔵書管理 Web v0.01 ■□■□
-.buttoms
- .buttoms__push
- %a{ :href => '/signup' }
- サインアップ
+%h3
+ 重ね買いを防ぐために…
- .buttoms__push
- %a{ :href => '/login' }
- ログイン
+.buttons
+ %input{ :type => 'button', :class=>"push_button", :onclick =>"location.href='/signup'", :value => 'サインアップ' }
+ %input{ :type => 'button', :class=>"push_button", :onclick =>"location.href='/login'", :value => 'ログイン' }
+@charset "utf-8";
+
body {
color:#444;
- margin:auto;
- max-width:45em;
+ align-items: center;
+ text-align: center;
+ margin: 10px auto;
+ max-width:50em;
+}
+
+h1 {
+ font-size: 3em;
}
ul {
text-align: left;
}
+input.push_button{
+ font-size: 1em;
+ padding: 5px,20px;
+ width: 200px;
+ height: 25px;
+ background-color: #f08300;
+ color: #3e62ad;
+ border: 1px solid #000000;
+ margin-left: 20px;
+ &:hover {
+ background-color:#f6ad49;
+ color: #3e62ad;
+ }
+}
+
#main1 {
+ position: relative;
background: #f8e58c;
align-items: center;
text-align: center;
+ height: 20em;
+ padding: 20px 5px;
}
#head {
- height: 50px;
background: #a8c97f;
text-align: center;
+ padding: 5px 5px;
}
#center {
}
#main2 {
+ position: relative;
float: right;
width: 80%;
background: #f8e58c;
+ align-items: center;
text-align: center;
- padding-bottom: 3267px;
- margin-bottom: -3267px;
+ height: 32em;
+ padding: 5px 0px;
}
#foot {
- height: 50px;
background: #a8c97f;
+ padding: 5px 5px;
}
-.buttoms {
- display: flex;
- flex-direction: row;
- justify-content: center;
- &__push {
- margin: 20px;
- height: 20px;
- width: 200px;
- background: #f08300;
- foreground: #3e62ad;
- border: 1px solid #000000;
- text-align: center;
- }
-}
.message {
margin-left: 10px;
text-align: left;
}
+.buttons {
+ margin: 20px 0px;
+ position: absolute;
+ bottom: 0;
+ left: 0;
+ right: 0;
+ margin: 0px auto;
+ padding-bottom: 20px;
+
+}
+
.formstyle {
margin: 0, auto;
.params {
}
}
}
- .buttoms {
- display: block;
- }
}
+.side_item {
+ padding: 5px 5px;
+ margin: 2px 0px;
+}
+
+
.error {
- background: #cd5e3c
+ background: #cd5e3c;
+ position: absolute;
+ top: 30px;
+ bottom: 30px;
+ left: 30px;
+ right: 30px;
+ margin: auto;
}
+
+
- # encoding: utf-8
-- salt = @salt
%h3
ユーザ登録
Eメールアドレス:
%input{ :name => 'email', :type => 'email', :id => 'email', :size => 30, :maxlength => 127, :required => true}
- %hr
.buttons
- %input{ :type => 'submit', :value => '送信'}
- %input{ :type => 'button', :onclick =>"location.href='/'", :value => 'もどる' }
+ %hr
+ %input{ :type => 'submit', :class=>'push_button', :value => '送信'}
+ %input{ :type => 'button', :class=>'push_button', :onclick =>"location.href='/'", :value => 'もどる' }
- # encoding: utf-8
+- admin_f = @admin_f
- id = @id
- account = @account
- username = @username
%form{ :action => "/user_edit", :method => "post"}
.formstyle
.params
+ - if (admin_f)
+ .item
+ %label{ :for => 'user_id' }
+ %span
+ ユーザID:
+ %input{ :name => 'usr_id', :id => 'user_id', :value => account, :readonly => true}
+
.item
%label{ :for => 'name' }
%span
Eメールアドレス:
%input{ :name => 'email', :type => 'email', :id => 'email', :size => 30, :maxlength => 127, :value => email }
- %hr
.buttons
- %input{ :type => 'submit', :value => '送信'}
- %input{ :type => 'button', :onclick =>"location.href='/user_home'", :value => 'もどる' }
+ %hr
+ %input{ :type => 'submit', :class=>'push_button', :value => '送信'}
+ %input{ :type => 'button', :class=>'push_button', :onclick =>"location.href='/user_home'", :value => 'もどる' }
.message
あなたの最近登録した本は以下になります。
- %ul
- - newest_list.each do |i|
- %li= i
+%ul
+ - newest_list.each do |i|
+ %li= i
--- /dev/null
+require_relative './app/models/users_db'
+require 'bcrypt'
+
+require 'bcrypt'
+
+passwd_salt = BCrypt::Engine.generate_salt
+passwd_hash = BCrypt::Engine.hash_secret("admin000", passwd_salt)
+
+admin_user = User.new
+admin_user.user_name = "admin"
+admin_user.full_name = "Admin User"
+admin_user.passwd_salt = passwd_salt
+admin_user.passwd_hash = passwd_hash
+admin_user.user_role = User::ROLE_ADMIN
+admin_user.create_at = DateTime.now
+admin_user.update_at = DateTime.now
+admin_user.save
+