ログイン、ログアウト用画面、起動確認後修正
authorOHASHI, Norikazu <katz@neko-mori.sakura.ne.jp>
Sat, 16 Mar 2019 16:05:19 +0000 (01:05 +0900)
committerOHASHI, Norikazu <katz@neko-mori.sakura.ne.jp>
Sat, 16 Mar 2019 16:05:19 +0000 (01:05 +0900)
sinatra/app/controllers/web_gui.rb
sinatra/app/views/login.haml [new file with mode: 0644]
sinatra/app/views/logout.haml [new file with mode: 0644]
sinatra/app/views/scss/style.scss
sinatra/app/views/user_home.haml [new file with mode: 0644]
sinatra/database.yml [moved from sinatra/app/models/database.yml with 100% similarity]
sinatra/start.rb

index 9383dad..ff70bac 100644 (file)
@@ -1,13 +1,11 @@
 # coding: utf-8
 require 'sinatra/base'
 require 'sinatra'
-require 'sinatra/cookies'
 require 'haml'
 require 'sass'
-require 'digest/sha1'
 
 # ユーザアクセス用モデル
-require '../models/users_db'
+require_relative '../models/users_db'
 
 class WebGui < Sinatra::Base
   set :root, File.join(File.dirname(__FILE__), '..')
@@ -61,7 +59,8 @@ class WebGui < Sinatra::Base
     id = params[:id]
     user = UserAccount.getUser(id)
     @id = id
-    @username = user.user_name
+    @username = user.full_name
+    @newest_list = [ "書籍1", "書籍2", "書籍3"]
     haml :user_home
   end
 
diff --git a/sinatra/app/views/login.haml b/sinatra/app/views/login.haml
new file mode 100644 (file)
index 0000000..e360310
--- /dev/null
@@ -0,0 +1,21 @@
+- # encoding: utf-8
+
+%h3
+  ユーザーログイン
+
+%hr
+
+%form{ :action => "/signup", :method => "post"}
+  アカウント:
+  %input{ :name => 'name', :size => 10, :maxlength => 10}
+  %br
+
+  パスワード:
+  %input{ :name => 'passwd', :type => 'password', :pattern => '.{6,}' }
+  %br
+
+  %hr
+
+  %input{ :type => 'submit', :value => '送信'}
+  %input{ :type => 'reset', :value => 'リセット'}
+  
diff --git a/sinatra/app/views/logout.haml b/sinatra/app/views/logout.haml
new file mode 100644 (file)
index 0000000..086faa3
--- /dev/null
@@ -0,0 +1,5 @@
+- # encoding: utf-8
+
+%h2
+  おつかれさまでした。
+
index 58daf89..bba7189 100644 (file)
@@ -4,21 +4,24 @@ div {
     }
     &:head {
         height: 50px;
-        background: #a8c97f
+        background: #a8c97f;
+        text-align: center
     }
     &:sidebar {
         float: left;
         width: 30%;
-        background: #fddea5
+        background: #fddea5;
+        text-align: left;
     }
     &:main {
         float: right;
         width: 70%;
         background: #f8e58c;
+        text-align: center
     }
     &:foot {
         height: 50px;
-        background: #a8c97f
+        background: #a8c97f;
     }
     &.pushbuttom {
         height: 50px;
diff --git a/sinatra/app/views/user_home.haml b/sinatra/app/views/user_home.haml
new file mode 100644 (file)
index 0000000..88d37aa
--- /dev/null
@@ -0,0 +1,14 @@
+- # encoding: utf-8
+- user_name = @username
+- newest_list = @newest_list
+
+%h2
+  ここは #{user_name} さんのホームページです
+
+%p
+  あなたの最近登録した本は以下になります。
+
+  %ul
+    - newest_list.each do |i|
+      %li=  #{i}
+    
index f21761f..d2e48f2 100644 (file)
@@ -1,10 +1,10 @@
 require 'sinatra/base'
-require 'app/controllers/web_gui'
-require 'app/controllers/restful_api'
+require './app/controllers/web_gui'
+require 'app/controllers/restful_api'
 
 class Main < Sinatra::Base
   ROUTES = {
-    '/' => WebGui,
-    '/webapi' => RESTfulAPI,
+    '/' => WebGui
+#    '/webapi' => RESTfulAPI,
   }
 end