導通確認などによる修正の適用
authorOHASHI, Norikazu <katz@neko-mori.sakura.ne.jp>
Sun, 17 Mar 2019 12:51:26 +0000 (21:51 +0900)
committerOHASHI, Norikazu <katz@neko-mori.sakura.ne.jp>
Sun, 17 Mar 2019 12:51:26 +0000 (21:51 +0900)
create_table.sql [new file with mode: 0644]
sinatra/app/controllers/web_gui.rb
sinatra/app/models/users_db.rb
sinatra/app/views/layout.haml
sinatra/app/views/login.haml
sinatra/app/views/main.haml
sinatra/app/views/scss/style.scss
sinatra/app/views/signup.haml
sinatra/app/views/user_home.haml
sinatra/config.ru

diff --git a/create_table.sql b/create_table.sql
new file mode 100644 (file)
index 0000000..d6688f6
--- /dev/null
@@ -0,0 +1,10 @@
+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);
index ff70bac..8dc1b21 100644 (file)
@@ -10,14 +10,11 @@ require_relative '../models/users_db'
 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 
index bef6e99..151e1e5 100644 (file)
@@ -5,7 +5,7 @@ require 'mysql2'
 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
@@ -31,14 +31,12 @@ class UserAccount
   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
 
@@ -53,7 +51,7 @@ class UserAccount
     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
@@ -64,7 +62,7 @@ class UserAccount
 
   # パスワードをチェックする
   def self.checkPasswd(name, passwd)
-    user = Users.find_by(:user_name, id)
+    user = Users.find_by(user_name: name)
 
     # ユーザの有無をチェック
     if (user == nil)
@@ -79,12 +77,12 @@ class UserAccount
       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
index a6c179f..f0e15f9 100644 (file)
@@ -9,23 +9,27 @@
 %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
index e360310..7a0612e 100644 (file)
@@ -5,7 +5,7 @@
 
 %hr
 
-%form{ :action => "/signup", :method => "post"}
+%form{ :action => "/login", :method => "post"}
   アカウント:
   %input{ :name => 'name', :size => 10, :maxlength => 10}
   %br
index 845f68d..1719528 100644 (file)
@@ -3,10 +3,11 @@
 %h1
   書籍管理サーバ
 
-.push_buttom
-  %a{ :href => '/signup' }
-    サインアップ
+.buttoms
+  .buttoms__push
+    %a{ :href => '/signup' }
+      サインアップ
   
-.push_buttom
-  %a{ :href => '/login' }
-    ログイン
+  .buttoms__push
+    %a{ :href => '/login' }
+      ログイン
index bba7189..c42922b 100644 (file)
@@ -1,33 +1,63 @@
-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;
+}
+
index 439c30e..528d1a4 100644 (file)
@@ -9,22 +9,24 @@
 %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 => '送信'}
index 88d37aa..9bb1415 100644 (file)
@@ -10,5 +10,5 @@
 
   %ul
     - newest_list.each do |i|
-      %li=  #{i}
+      %li=  i
     
index 4e55c78..4e4bd52 100644 (file)
@@ -1,4 +1,4 @@
 require 'sinatra'
 require './start'
 
-run URLMap.new(Main::ROUTES)
+run Rack::URLMap.new(Main::ROUTES)