From: OHASHI, Norikazu Date: Sat, 16 Mar 2019 16:05:19 +0000 (+0900) Subject: ログイン、ログアウト用画面、起動確認後修正 X-Git-Url: http://www.wald-der-katze.sakura.ne.jp/git/gitweb.cgi?a=commitdiff_plain;h=8a4c7185624fa7f571e32be96bfb33ecce6030c3;p=book_server.git ログイン、ログアウト用画面、起動確認後修正 --- diff --git a/sinatra/app/controllers/web_gui.rb b/sinatra/app/controllers/web_gui.rb index 9383dad..ff70bac 100644 --- a/sinatra/app/controllers/web_gui.rb +++ b/sinatra/app/controllers/web_gui.rb @@ -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 index 0000000..e360310 --- /dev/null +++ b/sinatra/app/views/login.haml @@ -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 index 0000000..086faa3 --- /dev/null +++ b/sinatra/app/views/logout.haml @@ -0,0 +1,5 @@ +- # encoding: utf-8 + +%h2 + おつかれさまでした。 + diff --git a/sinatra/app/views/scss/style.scss b/sinatra/app/views/scss/style.scss index 58daf89..bba7189 100644 --- a/sinatra/app/views/scss/style.scss +++ b/sinatra/app/views/scss/style.scss @@ -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 index 0000000..88d37aa --- /dev/null +++ b/sinatra/app/views/user_home.haml @@ -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} + diff --git a/sinatra/app/models/database.yml b/sinatra/database.yml similarity index 100% rename from sinatra/app/models/database.yml rename to sinatra/database.yml diff --git a/sinatra/start.rb b/sinatra/start.rb index f21761f..d2e48f2 100644 --- a/sinatra/start.rb +++ b/sinatra/start.rb @@ -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