--- /dev/null
+CREATE TABLE users (
+ user_id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ user_name VARCHAR(10) NOT NULL UNIQUE,
+ full_name VARCHAR(127),
+ passwd_hash VARCHAR(60) NOT NULL,
+ passwd_salt VARCHAR(60) NOT NULL,
+ email VARCHAR(127) NOT NULL,
+ role INTEGER NOT NULL,
+ create_at DATETIME NOT NULL,
+ update_at DATETIME NOT NULL);
class WebGui < Sinatra::Base
set :root, File.join(File.dirname(__FILE__), '..')
set :views, Proc.new {File.join(root, "views")}
-
- before do
- set :haml, :format => :html5
- end
+ set :haml, :format => :html5
#stylesheet
- get '/sytle.css' do
- scss :'sccs/style'
+ get '/style.css' do
+ scss :'scss/style'
end
# main page
require 'bcrypt'
# DB設定ファイルの読み込み
-ActiveRecord::Base.cofigurations = YAML.load_file('database.yml')
+ActiveRecord::Base.configurations = YAML.load_file('database.yml')
ActiveRecord::Base.establish_connection(:development)
class Users < ActiveRecord::Base
end
# ユーザロールを設定
- role[:admin] = 1
- role[:normal] = 8
# ユーザアカウントを作成
def self.createAccount(name, full_name, email, passwd)
# ユーザの有無をチェック
- if (User.find_by(:user_name, name) != nil)
+ if (Users.find_by(user_name: name) != nil)
raise AlreadyInstanceError
end
user.email = email
user.passwd_salt = passwd_salt
user.passwd_hash = passwd_hash
- user.role = role[:normal]
+ user.role = 8
user.create_at = DateTime.now
user.update_at = DateTime.now
user.save
# パスワードをチェックする
def self.checkPasswd(name, passwd)
- user = Users.find_by(:user_name, id)
+ user = Users.find_by(user_name: name)
# ユーザの有無をチェック
if (user == nil)
raise AuthenticationError
end
- return id
+ return user.user_id
end
# ユーザ情報取得
def self.getUser(id)
- user = Users.find_by(:user_id, id)
+ user = Users.find_by(user_id: id)
if (user == nil)
raise NotfondInstanceError
end
%html
%head{ :lang => 'ja' }
%meta{ :charset => 'utf-8'}
- %title= #{title_name}
+ %title
+ #{title_name}
%link{ :rel => 'stylesheet', :href => '/style.css'}
%body
- - if @username != nil
+ - if user_name == nil
#title= yield
- else
#head
- @username 書籍一覧
+ #{user_name} 書籍一覧
#center
#sidebar
%a{ :href => "/user_home/#{id}" }
ホーム
+ %br
%a{ :href => "/book_list/#{id}"}
書籍一覧
+ %br
%a{ :href => "/user_info/#{id}"}
ユーザ情報
+ %br
#main= yield
#foot
%p
%hr
-%form{ :action => "/signup", :method => "post"}
+%form{ :action => "/login", :method => "post"}
アカウント:
%input{ :name => 'name', :size => 10, :maxlength => 10}
%br
%h1
書籍管理サーバ
-.push_buttom
- %a{ :href => '/signup' }
- サインアップ
+.buttoms
+ .buttoms__push
+ %a{ :href => '/signup' }
+ サインアップ
-.push_buttom
- %a{ :href => '/login' }
- ログイン
+ .buttoms__push
+ %a{ :href => '/login' }
+ ログイン
-div {
- &:title {
- background: #f8e58c;
- }
- &:head {
- height: 50px;
- background: #a8c97f;
- text-align: center
- }
- &:sidebar {
- float: left;
- width: 30%;
- background: #fddea5;
- text-align: left;
- }
- &:main {
- float: right;
- width: 70%;
- background: #f8e58c;
- text-align: center
- }
- &:foot {
- height: 50px;
- background: #a8c97f;
- }
- &.pushbuttom {
- height: 50px;
- width: 300px;
+ul {
+ text-align: left;
+}
+
+#title {
+ background: #f8e58c;
+ align-items: center;
+ text-align: center;
+}
+
+#head {
+ height: 50px;
+ background: #a8c97f;
+ text-align: center;
+}
+
+#center {
+ block: float;
+ overflow: hidden;
+}
+
+#sidebar {
+ float: left;
+ width: 30%;
+ background: #fddea5;
+ text-align: left;
+ padding-bottom: 3267px;
+ margin-bottom: -3267px;
+}
+
+#main {
+ float: right;
+ width: 70%;
+ background: #f8e58c;
+ text-align: center;
+ padding-bottom: 3267px;
+ margin-bottom: -3267px;
+}
+
+#foot {
+ height: 50px;
+ background: #a8c97f;
+}
+
+.buttoms {
+ display: flex;
+ flex-direction: row;
+ justify-content: center;
+ &__push {
+ margin: 20px;
+ height: 20px;
+ width: 100px;
background: #f08300;
foreground: #3e62ad;
border: 1px solid #000000;
+ text-align: center;
}
}
+
+.forms {
+ text-align: left;
+}
+
%hr
%form{ :action => "/signup", :method => "post"}
- アカウント:
- %input{ :name => 'name', :size => 10, :maxlength => 10}
- %br
-
- フルネーム:
- %input{ :name => 'full_name', :size => 30, :maxlength => 127}
- %br
-
- パスワード:
- %input{ :name => 'passwd', :type => 'password', :pattern => '.{6,}' }
- %br
-
- Eメールアドレス
- %input{ :name => 'email', :type => 'email', :size => 30, :maxlength => 127}
- %br
-
+ .forms
+ %p
+ アカウント:
+ %input{ :name => 'name', :size => 10, :maxlength => 10}
+
+ %p
+ フルネーム:
+ %input{ :name => 'full_name', :size => 30, :maxlength => 127}
+
+ %p
+ パスワード:
+ %input{ :name => 'passwd', :type => 'password', :pattern => '.{6,}' }
+
+
+ %p
+ Eメールアドレス:
+ %input{ :name => 'email', :type => 'email', :size => 30, :maxlength => 127}
+
%hr
%input{ :type => 'submit', :value => '送信'}
%ul
- newest_list.each do |i|
- %li= #{i}
+ %li= i
require 'sinatra'
require './start'
-run URLMap.new(Main::ROUTES)
+run Rack::URLMap.new(Main::ROUTES)