From 25f1d0ce576bdbd4d39c6bdd854d06d2e95d9b17 Mon Sep 17 00:00:00 2001 From: telva0527 Date: Sat, 3 Jul 2021 00:08:55 +0900 Subject: [PATCH 1/7] =?UTF-8?q?=E5=88=9D=E6=9C=9F=E8=A8=AD=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .ruby-version | 2 +- Gemfile | 15 +- Gemfile.lock | 139 +++++++++++++++- app/assets/stylesheets/application.css | 15 -- app/assets/stylesheets/application.scss | 1 + app/views/layouts/application.html.erb | 15 -- app/views/layouts/application.html.slim | 11 ++ app/views/layouts/mailer.html.erb | 13 -- app/views/layouts/mailer.html.slim | 8 + app/views/layouts/mailer.text.erb | 1 - app/views/layouts/mailer.text.slim | 1 + config/application.rb | 8 + config/initializers/locale.rb | 1 + config/locales/ja.yml | 207 ++++++++++++++++++++++++ 14 files changed, 389 insertions(+), 48 deletions(-) delete mode 100644 app/assets/stylesheets/application.css create mode 100644 app/assets/stylesheets/application.scss delete mode 100644 app/views/layouts/application.html.erb create mode 100644 app/views/layouts/application.html.slim delete mode 100644 app/views/layouts/mailer.html.erb create mode 100644 app/views/layouts/mailer.html.slim delete mode 100644 app/views/layouts/mailer.text.erb create mode 100644 app/views/layouts/mailer.text.slim create mode 100644 config/initializers/locale.rb create mode 100644 config/locales/ja.yml diff --git a/.ruby-version b/.ruby-version index 4fd0fe3..2714f53 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.5.1 \ No newline at end of file +2.6.4 diff --git a/Gemfile b/Gemfile index 0f0e7a7..11dd34c 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } -ruby '2.5.1' +ruby '2.6.4' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.2.6' @@ -56,3 +56,16 @@ end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] + +gem 'bootstrap' +gem 'slim-rails' +gem 'html2slim' +gem 'kaminari' +gem 'sorcery' +gem 'rubocop' +gem 'redis-rails' +gem 'annotate' +gem 'better_errors' +gem 'binding_of_caller' +gem 'pry-byebug', group: :development +gem 'pry-rails' diff --git a/Gemfile.lock b/Gemfile.lock index b46341d..06fffd1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -44,12 +44,29 @@ GEM tzinfo (~> 1.1) addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) + annotate (3.1.1) + activerecord (>= 3.2, < 7.0) + rake (>= 10.4, < 14.0) archive-zip (0.12.0) io-like (~> 0.3.0) arel (9.0.0) + ast (2.4.2) + autoprefixer-rails (10.2.5.1) + execjs (> 0) + bcrypt (3.1.16) + better_errors (2.9.1) + coderay (>= 1.0.0) + erubi (>= 1.0.0) + rack (>= 0.9.0) bindex (0.8.1) + binding_of_caller (1.0.0) + debug_inspector (>= 0.0.1) bootsnap (1.7.5) msgpack (~> 1.0) + bootstrap (5.0.1) + autoprefixer-rails (>= 9.1.0) + popper_js (>= 2.9.2, < 3) + sassc-rails (>= 2.0.0) builder (3.2.4) byebug (11.1.3) capybara (3.35.3) @@ -64,18 +81,49 @@ GEM chromedriver-helper (2.1.1) archive-zip (~> 0.10) nokogiri (~> 1.8) + coderay (1.1.3) concurrent-ruby (1.1.9) crass (1.0.6) + debug_inspector (1.1.0) erubi (1.10.0) execjs (2.8.1) + faraday (1.4.3) + faraday-em_http (~> 1.0) + faraday-em_synchrony (~> 1.0) + faraday-excon (~> 1.1) + faraday-net_http (~> 1.0) + faraday-net_http_persistent (~> 1.1) + multipart-post (>= 1.2, < 3) + ruby2_keywords (>= 0.0.4) + faraday-em_http (1.0.0) + faraday-em_synchrony (1.0.0) + faraday-excon (1.1.0) + faraday-net_http (1.0.1) + faraday-net_http_persistent (1.1.0) ffi (1.15.3) globalid (0.4.2) activesupport (>= 4.2.0) + hpricot (0.8.6) + html2slim (0.2.0) + hpricot i18n (1.8.10) concurrent-ruby (~> 1.0) io-like (0.3.1) jbuilder (2.11.2) activesupport (>= 5.0.0) + jwt (2.2.3) + kaminari (1.2.1) + activesupport (>= 4.1.0) + kaminari-actionview (= 1.2.1) + kaminari-activerecord (= 1.2.1) + kaminari-core (= 1.2.1) + kaminari-actionview (1.2.1) + actionview + kaminari-core (= 1.2.1) + kaminari-activerecord (1.2.1) + activerecord + kaminari-core (= 1.2.1) + kaminari-core (1.2.1) listen (3.1.5) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) @@ -90,10 +138,32 @@ GEM mini_mime (1.1.0) minitest (5.14.4) msgpack (1.4.2) + multi_json (1.15.0) + multi_xml (0.6.0) + multipart-post (2.1.1) mysql2 (0.5.3) nio4r (2.5.7) nokogiri (1.11.7-x86_64-darwin) racc (~> 1.4) + oauth (0.5.6) + oauth2 (1.4.7) + faraday (>= 0.8, < 2.0) + jwt (>= 1.0, < 3.0) + multi_json (~> 1.3) + multi_xml (~> 0.5) + rack (>= 1.2, < 3) + parallel (1.20.1) + parser (3.0.1.1) + ast (~> 2.4.1) + popper_js (2.9.2) + pry (0.13.1) + coderay (~> 1.1) + method_source (~> 1.0) + pry-byebug (3.9.0) + byebug (~> 11.0) + pry (~> 0.13.0) + pry-rails (0.3.9) + pry (>= 0.10.4) public_suffix (4.0.6) puma (3.12.6) racc (1.5.2) @@ -124,11 +194,43 @@ GEM method_source rake (>= 0.8.7) thor (>= 0.19.0, < 2.0) + rainbow (3.0.0) rake (13.0.3) rb-fsevent (0.11.0) rb-inotify (0.10.1) ffi (~> 1.0) + redis (4.3.1) + redis-actionpack (5.2.0) + actionpack (>= 5, < 7) + redis-rack (>= 2.1.0, < 3) + redis-store (>= 1.1.0, < 2) + redis-activesupport (5.2.1) + activesupport (>= 3, < 7) + redis-store (>= 1.3, < 2) + redis-rack (2.1.3) + rack (>= 2.0.8, < 3) + redis-store (>= 1.2, < 2) + redis-rails (5.0.2) + redis-actionpack (>= 5.0, < 6) + redis-activesupport (>= 5.0, < 6) + redis-store (>= 1.2, < 2) + redis-store (1.9.0) + redis (>= 4, < 5) regexp_parser (2.1.1) + rexml (3.2.5) + rubocop (1.18.2) + parallel (~> 1.10) + parser (>= 3.0.0.0) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml + rubocop-ast (>= 1.7.0, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 1.4.0, < 3.0) + rubocop-ast (1.7.0) + parser (>= 3.0.1.1) + ruby-progressbar (1.11.0) + ruby2_keywords (0.0.4) ruby_dep (1.5.0) rubyzip (2.3.0) sass (3.7.4) @@ -142,9 +244,28 @@ GEM sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) + sassc (2.4.0) + ffi (~> 1.9) + sassc-rails (2.1.2) + railties (>= 4.0.0) + sassc (>= 2.0) + sprockets (> 3.0) + sprockets-rails + tilt selenium-webdriver (3.142.7) childprocess (>= 0.5, < 4.0) rubyzip (>= 1.2.2) + slim (4.1.0) + temple (>= 0.7.6, < 0.9) + tilt (>= 2.0.6, < 2.1) + slim-rails (3.2.0) + actionpack (>= 3.1) + railties (>= 3.1) + slim (>= 3.0, < 5.0) + sorcery (0.16.1) + bcrypt (~> 3.1) + oauth (~> 0.5, >= 0.5.5) + oauth2 (~> 1.0, >= 0.8.0) spring (2.1.1) spring-watcher-listen (2.0.1) listen (>= 2.7, < 4.0) @@ -156,6 +277,7 @@ GEM actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) + temple (0.8.2) thor (1.1.0) thread_safe (0.3.6) tilt (2.0.10) @@ -163,6 +285,7 @@ GEM thread_safe (~> 0.1) uglifier (4.2.0) execjs (>= 0.3.0, < 3) + unicode-display_width (2.0.0) web-console (3.7.0) actionview (>= 5.0) activemodel (>= 5.0) @@ -178,17 +301,29 @@ PLATFORMS x86_64-darwin-20 DEPENDENCIES + annotate + better_errors + binding_of_caller bootsnap (>= 1.1.0) + bootstrap byebug capybara (>= 2.15) chromedriver-helper + html2slim jbuilder (~> 2.5) + kaminari listen (>= 3.0.5, < 3.2) mysql2 (>= 0.4.4, < 0.6.0) + pry-byebug + pry-rails puma (~> 3.11) rails (~> 5.2.6) + redis-rails + rubocop sass-rails (~> 5.0) selenium-webdriver + slim-rails + sorcery spring spring-watcher-listen (~> 2.0.0) tzinfo-data @@ -196,7 +331,7 @@ DEPENDENCIES web-console (>= 3.3.0) RUBY VERSION - ruby 2.5.1p57 + ruby 2.6.4p104 BUNDLED WITH - 2.2.17 + 2.2.21 diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css deleted file mode 100644 index d05ea0f..0000000 --- a/app/assets/stylesheets/application.css +++ /dev/null @@ -1,15 +0,0 @@ -/* - * This is a manifest file that'll be compiled into application.css, which will include all the files - * listed below. - * - * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's - * vendor/assets/stylesheets directory can be referenced here using a relative path. - * - * You're free to add application-wide styles to this file and they'll appear at the bottom of the - * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS - * files in this directory. Styles in this file should be added after the last require_* statement. - * It is generally better to create a new file per style scope. - * - *= require_tree . - *= require_self - */ diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss new file mode 100644 index 0000000..cbd46a7 --- /dev/null +++ b/app/assets/stylesheets/application.scss @@ -0,0 +1 @@ +@import "bootstrap"; diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb deleted file mode 100644 index 5d683c9..0000000 --- a/app/views/layouts/application.html.erb +++ /dev/null @@ -1,15 +0,0 @@ - - - - InstagramClone - <%= csrf_meta_tags %> - <%= csp_meta_tag %> - - <%= stylesheet_link_tag 'application', media: 'all' %> - <%= javascript_include_tag 'application' %> - - - - <%= yield %> - - diff --git a/app/views/layouts/application.html.slim b/app/views/layouts/application.html.slim new file mode 100644 index 0000000..5663ccd --- /dev/null +++ b/app/views/layouts/application.html.slim @@ -0,0 +1,11 @@ +doctype html +html + head + title + | InstagramClone + = csrf_meta_tags + = csp_meta_tag + = stylesheet_link_tag 'application', media: 'all' + = javascript_include_tag 'application' + body + = yield diff --git a/app/views/layouts/mailer.html.erb b/app/views/layouts/mailer.html.erb deleted file mode 100644 index cbd34d2..0000000 --- a/app/views/layouts/mailer.html.erb +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - <%= yield %> - - diff --git a/app/views/layouts/mailer.html.slim b/app/views/layouts/mailer.html.slim new file mode 100644 index 0000000..aa4c616 --- /dev/null +++ b/app/views/layouts/mailer.html.slim @@ -0,0 +1,8 @@ +doctype html +html + head + meta[http-equiv="Content-Type" content="text/html; charset=utf-8"] + style + | /* Email styles need to be inline */ + body + = yield diff --git a/app/views/layouts/mailer.text.erb b/app/views/layouts/mailer.text.erb deleted file mode 100644 index 37f0bdd..0000000 --- a/app/views/layouts/mailer.text.erb +++ /dev/null @@ -1 +0,0 @@ -<%= yield %> diff --git a/app/views/layouts/mailer.text.slim b/app/views/layouts/mailer.text.slim new file mode 100644 index 0000000..0a90f09 --- /dev/null +++ b/app/views/layouts/mailer.text.slim @@ -0,0 +1 @@ += yield diff --git a/config/application.rb b/config/application.rb index 3d7c7dc..b8139ce 100644 --- a/config/application.rb +++ b/config/application.rb @@ -10,6 +10,14 @@ module InstagramClone class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. config.load_defaults 5.2 + config.time_zone = 'Tokyo' + config.active_record.default_timezone = :local + + config.generators do |g| + g.assets false + g.skip_routes true + g.test_framework false + end # Settings in config/environments/* take precedence over those specified here. # Application configuration can go into files in config/initializers diff --git a/config/initializers/locale.rb b/config/initializers/locale.rb new file mode 100644 index 0000000..63cee70 --- /dev/null +++ b/config/initializers/locale.rb @@ -0,0 +1 @@ +Rails.application.config.i18n.default_locale = :ja diff --git a/config/locales/ja.yml b/config/locales/ja.yml new file mode 100644 index 0000000..1e47b0c --- /dev/null +++ b/config/locales/ja.yml @@ -0,0 +1,207 @@ +--- +ja: + activerecord: + errors: + messages: + record_invalid: 'バリデーションに失敗しました: %{errors}' + restrict_dependent_destroy: + has_one: "%{record}が存在しているので削除できません" + has_many: "%{record}が存在しているので削除できません" + date: + abbr_day_names: + - 日 + - 月 + - 火 + - 水 + - 木 + - 金 + - 土 + abbr_month_names: + - + - 1月 + - 2月 + - 3月 + - 4月 + - 5月 + - 6月 + - 7月 + - 8月 + - 9月 + - 10月 + - 11月 + - 12月 + day_names: + - 日曜日 + - 月曜日 + - 火曜日 + - 水曜日 + - 木曜日 + - 金曜日 + - 土曜日 + formats: + default: "%Y/%m/%d" + long: "%Y年%m月%d日(%a)" + short: "%m/%d" + month_names: + - + - 1月 + - 2月 + - 3月 + - 4月 + - 5月 + - 6月 + - 7月 + - 8月 + - 9月 + - 10月 + - 11月 + - 12月 + order: + - :year + - :month + - :day + datetime: + distance_in_words: + about_x_hours: + one: 約1時間 + other: 約%{count}時間 + about_x_months: + one: 約1ヶ月 + other: 約%{count}ヶ月 + about_x_years: + one: 約1年 + other: 約%{count}年 + almost_x_years: + one: 1年弱 + other: "%{count}年弱" + half_a_minute: 30秒前後 + less_than_x_seconds: + one: 1秒以内 + other: "%{count}秒未満" + less_than_x_minutes: + one: 1分以内 + other: "%{count}分未満" + over_x_years: + one: 1年以上 + other: "%{count}年以上" + x_seconds: + one: 1秒 + other: "%{count}秒" + x_minutes: + one: 1分 + other: "%{count}分" + x_days: + one: 1日 + other: "%{count}日" + x_months: + one: 1ヶ月 + other: "%{count}ヶ月" + x_years: + one: 1年 + other: "%{count}年" + prompts: + second: 秒 + minute: 分 + hour: 時 + day: 日 + month: 月 + year: 年 + errors: + format: "%{attribute}%{message}" + messages: + accepted: を受諾してください + blank: を入力してください + confirmation: と%{attribute}の入力が一致しません + empty: を入力してください + equal_to: は%{count}にしてください + even: は偶数にしてください + exclusion: は予約されています + greater_than: は%{count}より大きい値にしてください + greater_than_or_equal_to: は%{count}以上の値にしてください + inclusion: は一覧にありません + invalid: は不正な値です + less_than: は%{count}より小さい値にしてください + less_than_or_equal_to: は%{count}以下の値にしてください + model_invalid: 'バリデーションに失敗しました: %{errors}' + not_a_number: は数値で入力してください + not_an_integer: は整数で入力してください + odd: は奇数にしてください + other_than: は%{count}以外の値にしてください + present: は入力しないでください + required: を入力してください + taken: はすでに存在します + too_long: は%{count}文字以内で入力してください + too_short: は%{count}文字以上で入力してください + wrong_length: は%{count}文字で入力してください + template: + body: 次の項目を確認してください + header: + one: "%{model}にエラーが発生しました" + other: "%{model}に%{count}個のエラーが発生しました" + helpers: + select: + prompt: 選択してください + submit: + create: 登録する + submit: 保存する + update: 更新する + number: + currency: + format: + delimiter: "," + format: "%n%u" + precision: 0 + separator: "." + significant: false + strip_insignificant_zeros: false + unit: 円 + format: + delimiter: "," + precision: 3 + separator: "." + significant: false + strip_insignificant_zeros: false + human: + decimal_units: + format: "%n %u" + units: + billion: 十億 + million: 百万 + quadrillion: 千兆 + thousand: 千 + trillion: 兆 + unit: '' + format: + delimiter: '' + precision: 3 + significant: true + strip_insignificant_zeros: true + storage_units: + format: "%n%u" + units: + byte: バイト + eb: EB + gb: GB + kb: KB + mb: MB + pb: PB + tb: TB + percentage: + format: + delimiter: '' + format: "%n%" + precision: + format: + delimiter: '' + support: + array: + last_word_connector: "、" + two_words_connector: "、" + words_connector: "、" + time: + am: 午前 + formats: + default: "%Y年%m月%d日(%a) %H時%M分%S秒 %z" + long: "%Y/%m/%d %H:%M" + short: "%m/%d %H:%M" + pm: 午後 From 2b72eb58005d3e4831bb62b19a94a663eab61716 Mon Sep 17 00:00:00 2001 From: telva0527 Date: Sat, 3 Jul 2021 10:47:08 +0900 Subject: [PATCH 2/7] =?UTF-8?q?=E3=83=86=E3=83=BC=E3=83=96=E3=83=AB?= =?UTF-8?q?=E3=83=BB=E3=82=B3=E3=83=B3=E3=83=88=E3=83=AD=E3=83=BC=E3=83=A9?= =?UTF-8?q?=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/user_sessions_controller.rb | 4 + app/controllers/users_controller.rb | 19 + app/helpers/user_sessions_helper.rb | 2 + app/helpers/users_helper.rb | 2 + app/models/user.rb | 3 + app/views/user_sessions/new.html.slim | 2 + app/views/users/edit.html.slim | 2 + app/views/users/index.html.slim | 2 + app/views/users/new.html.slim | 2 + app/views/users/show.html.slim | 2 + config/initializers/sorcery.rb | 557 ++++++++++++++++++++ db/migrate/20210702224153_sorcery_core.rb | 14 + db/schema.rb | 25 + 13 files changed, 636 insertions(+) create mode 100644 app/controllers/user_sessions_controller.rb create mode 100644 app/controllers/users_controller.rb create mode 100644 app/helpers/user_sessions_helper.rb create mode 100644 app/helpers/users_helper.rb create mode 100644 app/models/user.rb create mode 100644 app/views/user_sessions/new.html.slim create mode 100644 app/views/users/edit.html.slim create mode 100644 app/views/users/index.html.slim create mode 100644 app/views/users/new.html.slim create mode 100644 app/views/users/show.html.slim create mode 100644 config/initializers/sorcery.rb create mode 100644 db/migrate/20210702224153_sorcery_core.rb create mode 100644 db/schema.rb diff --git a/app/controllers/user_sessions_controller.rb b/app/controllers/user_sessions_controller.rb new file mode 100644 index 0000000..2981a29 --- /dev/null +++ b/app/controllers/user_sessions_controller.rb @@ -0,0 +1,4 @@ +class UserSessionsController < ApplicationController + def new + end +end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb new file mode 100644 index 0000000..6accb51 --- /dev/null +++ b/app/controllers/users_controller.rb @@ -0,0 +1,19 @@ +class UsersController < ApplicationController + def index + end + + def new + end + + def create + end + + def show + end + + def edit + end + + def destroy + end +end diff --git a/app/helpers/user_sessions_helper.rb b/app/helpers/user_sessions_helper.rb new file mode 100644 index 0000000..2018402 --- /dev/null +++ b/app/helpers/user_sessions_helper.rb @@ -0,0 +1,2 @@ +module UserSessionsHelper +end diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb new file mode 100644 index 0000000..2310a24 --- /dev/null +++ b/app/helpers/users_helper.rb @@ -0,0 +1,2 @@ +module UsersHelper +end diff --git a/app/models/user.rb b/app/models/user.rb new file mode 100644 index 0000000..0e3f1de --- /dev/null +++ b/app/models/user.rb @@ -0,0 +1,3 @@ +class User < ApplicationRecord + authenticates_with_sorcery! +end diff --git a/app/views/user_sessions/new.html.slim b/app/views/user_sessions/new.html.slim new file mode 100644 index 0000000..4ba63aa --- /dev/null +++ b/app/views/user_sessions/new.html.slim @@ -0,0 +1,2 @@ +h1 UserSessions#new +p Find me in app/views/user_sessions/new.html.slim diff --git a/app/views/users/edit.html.slim b/app/views/users/edit.html.slim new file mode 100644 index 0000000..d62632d --- /dev/null +++ b/app/views/users/edit.html.slim @@ -0,0 +1,2 @@ +h1 Users#edit +p Find me in app/views/users/edit.html.slim diff --git a/app/views/users/index.html.slim b/app/views/users/index.html.slim new file mode 100644 index 0000000..0e8ecec --- /dev/null +++ b/app/views/users/index.html.slim @@ -0,0 +1,2 @@ +h1 Users#index +p Find me in app/views/users/index.html.slim diff --git a/app/views/users/new.html.slim b/app/views/users/new.html.slim new file mode 100644 index 0000000..40795b1 --- /dev/null +++ b/app/views/users/new.html.slim @@ -0,0 +1,2 @@ +h1 Users#new +p Find me in app/views/users/new.html.slim diff --git a/app/views/users/show.html.slim b/app/views/users/show.html.slim new file mode 100644 index 0000000..a71f8ee --- /dev/null +++ b/app/views/users/show.html.slim @@ -0,0 +1,2 @@ +h1 Users#show +p Find me in app/views/users/show.html.slim diff --git a/config/initializers/sorcery.rb b/config/initializers/sorcery.rb new file mode 100644 index 0000000..69f8050 --- /dev/null +++ b/config/initializers/sorcery.rb @@ -0,0 +1,557 @@ +# The first thing you need to configure is which modules you need in your app. +# The default is nothing which will include only core features (password encryption, login/logout). +# +# Available submodules are: :user_activation, :http_basic_auth, :remember_me, +# :reset_password, :session_timeout, :brute_force_protection, :activity_logging, +# :magic_login, :external +Rails.application.config.sorcery.submodules = [] + +# Here you can configure each submodule's features. +Rails.application.config.sorcery.configure do |config| + # -- core -- + # What controller action to call for non-authenticated users. You can also + # override the 'not_authenticated' method of course. + # Default: `:not_authenticated` + # + # config.not_authenticated_action = + + # When a non logged-in user tries to enter a page that requires login, save + # the URL he wants to reach, and send him there after login, using 'redirect_back_or_to'. + # Default: `true` + # + # config.save_return_to_url = + + # Set domain option for cookies; Useful for remember_me submodule. + # Default: `nil` + # + # config.cookie_domain = + + # Allow the remember_me cookie to be set through AJAX + # Default: `true` + # + # config.remember_me_httponly = + + # Set token randomness. (e.g. user activation tokens) + # The length of the result string is about 4/3 of `token_randomness`. + # Default: `15` + # + # config.token_randomness = + + # -- session timeout -- + # How long in seconds to keep the session alive. + # Default: `3600` + # + # config.session_timeout = + + # Use the last action as the beginning of session timeout. + # Default: `false` + # + # config.session_timeout_from_last_action = + + # Invalidate active sessions. Requires an `invalidate_sessions_before` timestamp column + # Default: `false` + # + # config.session_timeout_invalidate_active_sessions_enabled = + + # -- http_basic_auth -- + # What realm to display for which controller name. For example {"My App" => "Application"} + # Default: `{"application" => "Application"}` + # + # config.controller_to_realm_map = + + # -- activity logging -- + # Will register the time of last user login, every login. + # Default: `true` + # + # config.register_login_time = + + # Will register the time of last user logout, every logout. + # Default: `true` + # + # config.register_logout_time = + + # Will register the time of last user action, every action. + # Default: `true` + # + # config.register_last_activity_time = + + # -- external -- + # What providers are supported by this app + # i.e. [:twitter, :facebook, :github, :linkedin, :xing, :google, :liveid, :salesforce, :slack, :line]. + # Default: `[]` + # + # config.external_providers = + + # You can change it by your local ca_file. i.e. '/etc/pki/tls/certs/ca-bundle.crt' + # Path to ca_file. By default use a internal ca-bundle.crt. + # Default: `'path/to/ca_file'` + # + # config.ca_file = + + # Linkedin requires r_emailaddress scope to fetch user's email address. + # You can skip including the email field if you use an intermediary signup form. (using build_from method). + # The r_emailaddress scope is only necessary if you are using the create_from method directly. + # + # config.linkedin.key = "" + # config.linkedin.secret = "" + # config.linkedin.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=linkedin" + # config.linkedin.user_info_mapping = { + # first_name: 'localizedFirstName', + # last_name: 'localizedLastName', + # email: 'emailAddress' + # } + # config.linkedin.scope = "r_liteprofile r_emailaddress" + # + # + # For information about XING API: + # - user info fields go to https://dev.xing.com/docs/get/users/me + # + # config.xing.key = "" + # config.xing.secret = "" + # config.xing.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=xing" + # config.xing.user_info_mapping = {first_name: "first_name", last_name: "last_name"} + # + # + # Twitter will not accept any requests nor redirect uri containing localhost, + # Make sure you use 0.0.0.0:3000 to access your app in development + # + # config.twitter.key = "" + # config.twitter.secret = "" + # config.twitter.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=twitter" + # config.twitter.user_info_mapping = {:email => "screen_name"} + # + # config.facebook.key = "" + # config.facebook.secret = "" + # config.facebook.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=facebook" + # config.facebook.user_info_path = "me?fields=email" + # config.facebook.user_info_mapping = {:email => "email"} + # config.facebook.access_permissions = ["email"] + # config.facebook.display = "page" + # config.facebook.api_version = "v2.3" + # config.facebook.parse = :json + # + # config.instagram.key = "" + # config.instagram.secret = "" + # config.instagram.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=instagram" + # config.instagram.user_info_mapping = {:email => "username"} + # config.instagram.access_permissions = ["basic", "public_content", "follower_list", "comments", "relationships", "likes"] + # + # config.github.key = "" + # config.github.secret = "" + # config.github.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=github" + # config.github.user_info_mapping = {:email => "name"} + # config.github.scope = "" + # + # config.paypal.key = "" + # config.paypal.secret = "" + # config.paypal.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=paypal" + # config.paypal.user_info_mapping = {:email => "email"} + # + # config.wechat.key = "" + # config.wechat.secret = "" + # config.wechat.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=wechat" + # + # For Auth0, site is required and should match the domain provided by Auth0. + # + # config.auth0.key = "" + # config.auth0.secret = "" + # config.auth0.callback_url = "https://0.0.0.0:3000/oauth/callback?provider=auth0" + # config.auth0.site = "https://example.auth0.com" + # + # config.google.key = "" + # config.google.secret = "" + # config.google.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=google" + # config.google.user_info_mapping = {:email => "email", :username => "name"} + # config.google.scope = "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile" + # + # For Microsoft Graph, the key will be your App ID, and the secret will be your app password/public key. + # The callback URL "can't contain a query string or invalid special characters" + # See: https://docs.microsoft.com/en-us/azure/active-directory/active-directory-v2-limitations#restrictions-on-redirect-uris + # More information at https://graph.microsoft.io/en-us/docs + # + # config.microsoft.key = "" + # config.microsoft.secret = "" + # config.microsoft.callback_url = "http://0.0.0.0:3000/oauth/callback/microsoft" + # config.microsoft.user_info_mapping = {:email => "userPrincipalName", :username => "displayName"} + # config.microsoft.scope = "openid email https://graph.microsoft.com/User.Read" + # + # config.vk.key = "" + # config.vk.secret = "" + # config.vk.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=vk" + # config.vk.user_info_mapping = {:login => "domain", :name => "full_name"} + # config.vk.api_version = "5.71" + # + # config.slack.callback_url = "http://0.0.0.0:3000/oauth/callback?provider=slack" + # config.slack.key = '' + # config.slack.secret = '' + # config.slack.user_info_mapping = {email: 'email'} + # + # To use liveid in development mode you have to replace mydomain.com with + # a valid domain even in development. To use a valid domain in development + # simply add your domain in your /etc/hosts file in front of 127.0.0.1 + # + # config.liveid.key = "" + # config.liveid.secret = "" + # config.liveid.callback_url = "http://mydomain.com:3000/oauth/callback?provider=liveid" + # config.liveid.user_info_mapping = {:username => "name"} + + # For information about JIRA API: + # https://developer.atlassian.com/display/JIRADEV/JIRA+REST+API+Example+-+OAuth+authentication + # To obtain the consumer key and the public key you can use the jira-ruby gem https://github.com/sumoheavy/jira-ruby + # or run openssl req -x509 -nodes -newkey rsa:1024 -sha1 -keyout rsakey.pem -out rsacert.pem to obtain the public key + # Make sure you have configured the application link properly + + # config.jira.key = "1234567" + # config.jira.secret = "jiraTest" + # config.jira.site = "http://localhost:2990/jira/plugins/servlet/oauth" + # config.jira.signature_method = "RSA-SHA1" + # config.jira.private_key_file = "rsakey.pem" + + # For information about Salesforce API: + # https://developer.salesforce.com/signup & + # https://www.salesforce.com/us/developer/docs/api_rest/ + # Salesforce callback_url must be https. You can run the following to generate self-signed ssl cert: + # openssl req -new -newkey rsa:2048 -sha1 -days 365 -nodes -x509 -keyout server.key -out server.crt + # Make sure you have configured the application link properly + # config.salesforce.key = '123123' + # config.salesforce.secret = 'acb123' + # config.salesforce.callback_url = "https://127.0.0.1:9292/oauth/callback?provider=salesforce" + # config.salesforce.scope = "full" + # config.salesforce.user_info_mapping = {:email => "email"} + + # config.line.key = "" + # config.line.secret = "" + # config.line.callback_url = "http://mydomain.com:3000/oauth/callback?provider=line" + # config.line.scope = "profile" + # config.line.bot_prompt = "normal" + # config.line.user_info_mapping = {name: 'displayName'} + + + # For information about Discord API + # https://discordapp.com/developers/docs/topics/oauth2 + # config.discord.key = "xxxxxx" + # config.discord.secret = "xxxxxx" + # config.discord.callback_url = "http://localhost:3000/oauth/callback?provider=discord" + # config.discord.scope = "email guilds" + + # For information about Battlenet API + # https://develop.battle.net/documentation/guides/using-oauth + # config.battlenet.site = "https://eu.battle.net/" #See Website for other Regional Domains + # config.battlenet.key = "xxxxxx" + # config.battlenet.secret = "xxxxxx" + # config.battlenet.callback_url = "http://localhost:3000/oauth/callback?provider=battlenet" + # config.battlenet.scope = "openid" + # --- user config --- + config.user_config do |user| + # -- core -- + # Specify username attributes, for example: [:username, :email]. + # Default: `[:email]` + # + # user.username_attribute_names = + + # Change *virtual* password attribute, the one which is used until an encrypted one is generated. + # Default: `:password` + # + # user.password_attribute_name = + + # Downcase the username before trying to authenticate, default is false + # Default: `false` + # + # user.downcase_username_before_authenticating = + + # Change default email attribute. + # Default: `:email` + # + # user.email_attribute_name = + + # Change default crypted_password attribute. + # Default: `:crypted_password` + # + # user.crypted_password_attribute_name = + + # What pattern to use to join the password with the salt + # Default: `""` + # + # user.salt_join_token = + + # Change default salt attribute. + # Default: `:salt` + # + # user.salt_attribute_name = + + # How many times to apply encryption to the password. + # Default: 1 in test env, `nil` otherwise + # + user.stretches = 1 if Rails.env.test? + + # Encryption key used to encrypt reversible encryptions such as AES256. + # WARNING: If used for users' passwords, changing this key will leave passwords undecryptable! + # Default: `nil` + # + # user.encryption_key = + + # Use an external encryption class. + # Default: `nil` + # + # user.custom_encryption_provider = + + # Encryption algorithm name. See 'encryption_algorithm=' for available options. + # Default: `:bcrypt` + # + # user.encryption_algorithm = + + # Make this configuration inheritable for subclasses. Useful for ActiveRecord's STI. + # Default: `false` + # + # user.subclasses_inherit_config = + + # -- remember_me -- + # How long in seconds the session length will be + # Default: `60 * 60 * 24 * 7` + # + # user.remember_me_for = + + # When true, sorcery will persist a single remember me token for all + # logins/logouts (to support remembering on multiple browsers simultaneously). + # Default: false + # + # user.remember_me_token_persist_globally = + + # -- user_activation -- + # The attribute name to hold activation state (active/pending). + # Default: `:activation_state` + # + # user.activation_state_attribute_name = + + # The attribute name to hold activation code (sent by email). + # Default: `:activation_token` + # + # user.activation_token_attribute_name = + + # The attribute name to hold activation code expiration date. + # Default: `:activation_token_expires_at` + # + # user.activation_token_expires_at_attribute_name = + + # How many seconds before the activation code expires. nil for never expires. + # Default: `nil` + # + # user.activation_token_expiration_period = + + # REQUIRED: + # User activation mailer class. + # Default: `nil` + # + # user.user_activation_mailer = + + # When true, sorcery will not automatically + # send the activation details email, and allow you to + # manually handle how and when the email is sent. + # Default: `false` + # + # user.activation_mailer_disabled = + + # Method to send email related + # options: `:deliver_later`, `:deliver_now`, `:deliver` + # Default: :deliver (Rails version < 4.2) or :deliver_now (Rails version 4.2+) + # + # user.email_delivery_method = + + # Activation needed email method on your mailer class. + # Default: `:activation_needed_email` + # + # user.activation_needed_email_method_name = + + # Activation success email method on your mailer class. + # Default: `:activation_success_email` + # + # user.activation_success_email_method_name = + + # Do you want to prevent users who did not activate by email from logging in? + # Default: `true` + # + # user.prevent_non_active_users_to_login = + + # -- reset_password -- + # Password reset token attribute name. + # Default: `:reset_password_token` + # + # user.reset_password_token_attribute_name = + + # Password token expiry attribute name. + # Default: `:reset_password_token_expires_at` + # + # user.reset_password_token_expires_at_attribute_name = + + # When was password reset email sent. Used for hammering protection. + # Default: `:reset_password_email_sent_at` + # + # user.reset_password_email_sent_at_attribute_name = + + # REQUIRED: + # Password reset mailer class. + # Default: `nil` + # + # user.reset_password_mailer = + + # Reset password email method on your mailer class. + # Default: `:reset_password_email` + # + # user.reset_password_email_method_name = + + # When true, sorcery will not automatically + # send the password reset details email, and allow you to + # manually handle how and when the email is sent + # Default: `false` + # + # user.reset_password_mailer_disabled = + + # How many seconds before the reset request expires. nil for never expires. + # Default: `nil` + # + # user.reset_password_expiration_period = + + # Hammering protection: how long in seconds to wait before allowing another email to be sent. + # Default: `5 * 60` + # + # user.reset_password_time_between_emails = + + # Access counter to a reset password page attribute name + # Default: `:access_count_to_reset_password_page` + # + # user.reset_password_page_access_count_attribute_name = + + # -- magic_login -- + # Magic login code attribute name. + # Default: `:magic_login_token` + # + # user.magic_login_token_attribute_name = + + # Magic login expiry attribute name. + # Default: `:magic_login_token_expires_at` + # + # user.magic_login_token_expires_at_attribute_name = + + # When was magic login email sent — used for hammering protection. + # Default: `:magic_login_email_sent_at` + # + # user.magic_login_email_sent_at_attribute_name = + + # REQUIRED: + # Magic login mailer class. + # Default: `nil` + # + # user.magic_login_mailer_class = + + # Magic login email method on your mailer class. + # Default: `:magic_login_email` + # + # user.magic_login_email_method_name = + + # When true, sorcery will not automatically + # send magic login details email, and allow you to + # manually handle how and when the email is sent + # Default: `true` + # + # user.magic_login_mailer_disabled = + + # How many seconds before the request expires. nil for never expires. + # Default: `nil` + # + # user.magic_login_expiration_period = + + # Hammering protection: how long in seconds to wait before allowing another email to be sent. + # Default: `5 * 60` + # + # user.magic_login_time_between_emails = + + # -- brute_force_protection -- + # Failed logins attribute name. + # Default: `:failed_logins_count` + # + # user.failed_logins_count_attribute_name = + + # This field indicates whether user is banned and when it will be active again. + # Default: `:lock_expires_at` + # + # user.lock_expires_at_attribute_name = + + # How many failed logins are allowed. + # Default: `50` + # + # user.consecutive_login_retries_amount_limit = + + # How long the user should be banned, in seconds. 0 for permanent. + # Default: `60 * 60` + # + # user.login_lock_time_period = + + # Unlock token attribute name + # Default: `:unlock_token` + # + # user.unlock_token_attribute_name = + + # Unlock token mailer method + # Default: `:send_unlock_token_email` + # + # user.unlock_token_email_method_name = + + # When true, sorcery will not automatically + # send email with the unlock token + # Default: `false` + # + # user.unlock_token_mailer_disabled = true + + # REQUIRED: + # Unlock token mailer class. + # Default: `nil` + # + # user.unlock_token_mailer = + + # -- activity logging -- + # Last login attribute name. + # Default: `:last_login_at` + # + # user.last_login_at_attribute_name = + + # Last logout attribute name. + # Default: `:last_logout_at` + # + # user.last_logout_at_attribute_name = + + # Last activity attribute name. + # Default: `:last_activity_at` + # + # user.last_activity_at_attribute_name = + + # How long since user's last activity will they be considered logged out? + # Default: `10 * 60` + # + # user.activity_timeout = + + # -- external -- + # Class which holds the various external provider data for this user. + # Default: `nil` + # + # user.authentications_class = + + # User's identifier in the `authentications` class. + # Default: `:user_id` + # + # user.authentications_user_id_attribute_name = + + # Provider's identifier in the `authentications` class. + # Default: `:provider` + # + # user.provider_attribute_name = + + # User's external unique identifier in the `authentications` class. + # Default: `:uid` + # + # user.provider_uid_attribute_name = + end + + # This line must come after the 'user config' block. + # Define which model authenticates with sorcery. + config.user_class = "User" +end diff --git a/db/migrate/20210702224153_sorcery_core.rb b/db/migrate/20210702224153_sorcery_core.rb new file mode 100644 index 0000000..e7082b1 --- /dev/null +++ b/db/migrate/20210702224153_sorcery_core.rb @@ -0,0 +1,14 @@ +class SorceryCore < ActiveRecord::Migration[5.2] + def change + create_table :users do |t| + t.string :email, null: false + t.string :crypted_password + t.string :salt + t.string :username, null: false + + t.timestamps null: false + end + + add_index :users, :email, unique: true + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 0000000..d541eb5 --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,25 @@ +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 2021_07_02_224153) do + + create_table "users", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb3", force: :cascade do |t| + t.string "email", null: false + t.string "crypted_password" + t.string "salt" + t.string "username", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["email"], name: "index_users_on_email", unique: true + end + +end From 98b558a3147245e2a1594a4a3574ac3d0c3922bc Mon Sep 17 00:00:00 2001 From: telva0527 Date: Sat, 3 Jul 2021 17:57:48 +0900 Subject: [PATCH 3/7] =?UTF-8?q?=E3=83=AD=E3=82=B0=E3=82=A4=E3=83=B3?= =?UTF-8?q?=E6=A9=9F=E8=83=BD=E3=81=AE=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 4 +++ Gemfile.lock | 13 +++++++++ app/controllers/user_sessions_controller.rb | 16 +++++++++++ app/controllers/users_controller.rb | 16 +++++++++++ app/models/user.rb | 6 +++++ app/views/layouts/application.html.slim | 5 ++++ .../shared/_before_login_header.html.slim | 13 +++++++++ app/views/shared/_error_messages.html.slim | 5 ++++ app/views/shared/_flash_messages.html.slim | 2 ++ app/views/shared/_header.html.slim | 20 ++++++++++++++ app/views/user_sessions/new.html.slim | 20 ++++++++++++-- app/views/users/new.html.slim | 27 +++++++++++++++++-- config/routes.rb | 7 +++++ 13 files changed, 150 insertions(+), 4 deletions(-) create mode 100644 app/views/shared/_before_login_header.html.slim create mode 100644 app/views/shared/_error_messages.html.slim create mode 100644 app/views/shared/_flash_messages.html.slim create mode 100644 app/views/shared/_header.html.slim diff --git a/Gemfile b/Gemfile index 11dd34c..24e76df 100644 --- a/Gemfile +++ b/Gemfile @@ -69,3 +69,7 @@ gem 'better_errors' gem 'binding_of_caller' gem 'pry-byebug', group: :development gem 'pry-rails' +gem 'font-awesome-sass' +gem 'jquery-rails' +gem 'popper_js' +gem 'rails-i18n' diff --git a/Gemfile.lock b/Gemfile.lock index 06fffd1..3de0ed1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -101,6 +101,8 @@ GEM faraday-net_http (1.0.1) faraday-net_http_persistent (1.1.0) ffi (1.15.3) + font-awesome-sass (5.15.1) + sassc (>= 1.11) globalid (0.4.2) activesupport (>= 4.2.0) hpricot (0.8.6) @@ -111,6 +113,10 @@ GEM io-like (0.3.1) jbuilder (2.11.2) activesupport (>= 5.0.0) + jquery-rails (4.4.0) + rails-dom-testing (>= 1, < 3) + railties (>= 4.2.0) + thor (>= 0.14, < 2.0) jwt (2.2.3) kaminari (1.2.1) activesupport (>= 4.1.0) @@ -188,6 +194,9 @@ GEM nokogiri (>= 1.6) rails-html-sanitizer (1.3.0) loofah (~> 2.3) + rails-i18n (5.1.3) + i18n (>= 0.7, < 2) + railties (>= 5.0, < 6) railties (5.2.6) actionpack (= 5.2.6) activesupport (= 5.2.6) @@ -309,15 +318,19 @@ DEPENDENCIES byebug capybara (>= 2.15) chromedriver-helper + font-awesome-sass html2slim jbuilder (~> 2.5) + jquery-rails kaminari listen (>= 3.0.5, < 3.2) mysql2 (>= 0.4.4, < 0.6.0) + popper_js pry-byebug pry-rails puma (~> 3.11) rails (~> 5.2.6) + rails-i18n redis-rails rubocop sass-rails (~> 5.0) diff --git a/app/controllers/user_sessions_controller.rb b/app/controllers/user_sessions_controller.rb index 2981a29..1318916 100644 --- a/app/controllers/user_sessions_controller.rb +++ b/app/controllers/user_sessions_controller.rb @@ -1,4 +1,20 @@ class UserSessionsController < ApplicationController def new end + + def create + @user = login(params[:email], params[:password]) + + if @user + redirect_back_or_to root_path, success: "ログインに成功しました" + else + flash.now[:danger] = "ログインに失敗しました" + render :new + end + end + + def destroy + logout + redirect_to root_path, success: "ログアウトしました" + end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 6accb51..cea8ba6 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,11 +1,21 @@ class UsersController < ApplicationController def index + @users = User.all end def new + @user = User.new end def create + @user = User.new(user_params) + if @user.save + auto_login(@user) + redirect_to root_path, success: "ユーザーを作成しました" + else + flash.now[:danger] = "ユーザーの作成に失敗しました" + render :new + end end def show @@ -16,4 +26,10 @@ def edit def destroy end + + private + + def user_params + params.require(:user).permit(:username, :email, :password, :password_confirmation) + end end diff --git a/app/models/user.rb b/app/models/user.rb index 0e3f1de..56597e7 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,3 +1,9 @@ class User < ApplicationRecord authenticates_with_sorcery! + + validates :username, uniqueness: true, presence: true + validates :email, uniqueness: true + validates :password, length: { minimum: 3 }, if: -> { new_record? || changes[:crypted_password] } + validates :password, confirmation: true, if: -> { new_record? || changes[:crypted_password] } + validates :password_confirmation, presence: true, if: -> { new_record? || changes[:crypted_password] } end diff --git a/app/views/layouts/application.html.slim b/app/views/layouts/application.html.slim index 5663ccd..f5441ad 100644 --- a/app/views/layouts/application.html.slim +++ b/app/views/layouts/application.html.slim @@ -8,4 +8,9 @@ html = stylesheet_link_tag 'application', media: 'all' = javascript_include_tag 'application' body + - if logged_in? + = render 'shared/header' + - else + = render 'shared/before_login_header' + = render 'shared/flash_messages' = yield diff --git a/app/views/shared/_before_login_header.html.slim b/app/views/shared/_before_login_header.html.slim new file mode 100644 index 0000000..485995f --- /dev/null +++ b/app/views/shared/_before_login_header.html.slim @@ -0,0 +1,13 @@ +nav.navbar.navbar-expand-lg.navbar-light.bg-light + = link_to 'InstaClone', root_path, class: 'navbar-brand' + button.navbar-toggler aria-controls="navbarTogglerDemo02" aria-expanded="false" aria-label=("Toggle navigation") data-target="#navbarTogglerDemo02" data-toggle="collapse" type="button" + span.navbar-toggler-icon + #navbarTogglerDemo02.collapse.navbar-collapse + form.form-inline.my-2.my-lg-0.mr-auto + input.form-control.mr-sm-2 placeholder="Search" type="search" / + button.btn.btn-outline-success.my-2.my-sm-0 type="submit" Search + ul.navbar-nav.mt-2.mt-lg-0 + li.nav-item + = link_to 'ポスト一覧', '#', class: 'nav-link' + li.nav-item + = link_to 'ログイン', login_path, class: 'nav-link' diff --git a/app/views/shared/_error_messages.html.slim b/app/views/shared/_error_messages.html.slim new file mode 100644 index 0000000..8d8f9a5 --- /dev/null +++ b/app/views/shared/_error_messages.html.slim @@ -0,0 +1,5 @@ +- if object.errors.any? + #error_messages.alert.alert-danger + ul.mb-0 + - object.errors.full_messages.each do |msg| + li = msg diff --git a/app/views/shared/_flash_messages.html.slim b/app/views/shared/_flash_messages.html.slim new file mode 100644 index 0000000..db73a0f --- /dev/null +++ b/app/views/shared/_flash_messages.html.slim @@ -0,0 +1,2 @@ +- flash.each do |message_type, message| + div class=("alert alert-#{message_type}") = message diff --git a/app/views/shared/_header.html.slim b/app/views/shared/_header.html.slim new file mode 100644 index 0000000..fdf45d4 --- /dev/null +++ b/app/views/shared/_header.html.slim @@ -0,0 +1,20 @@ +nav.navbar.navbar-expand-lg.navbar-light.bg-info + = link_to 'InstaClone', root_path, class: 'navbar-brand' + button.navbar-toggler aria-controls="navbarTogglerDemo02" aria-expanded="false" aria-label=("Toggle navigation") data-target="#navbarTogglerDemo02" data-toggle="collapse" type="button" + span.navbar-toggler-icon + #navbarTogglerDemo02.collapse.navbar-collapse + form.form-inline.my-2.my-lg-0.mr-auto + input.form-control.mr-sm-2 placeholder="Search" type="search" / + button.btn.btn-outline-dark.my-2.my-sm-0 type="submit" Search + ul.navbar-nav.mt-2.mt-lg-0 + li.nav-item + a.nav-link href="#" + = icon 'far', 'image', class: 'fa-lg' + li.nav-item + a.nav-link href="#" + = icon 'far', 'heart', class: 'fa-lg' + li.nav-item + a.nav-link href="#" + = icon 'far', 'user', class: 'fa-lg' + li.nav-item + = link_to 'ログアウト', logout_path, class: 'nav-link', method: :delete diff --git a/app/views/user_sessions/new.html.slim b/app/views/user_sessions/new.html.slim index 4ba63aa..a22924f 100644 --- a/app/views/user_sessions/new.html.slim +++ b/app/views/user_sessions/new.html.slim @@ -1,2 +1,18 @@ -h1 UserSessions#new -p Find me in app/views/user_sessions/new.html.slim +h1 ログイン + +.login-register-form + .login-register-form-inner + .card.mb-3 + = form_with url: login_path, class: 'card-body', local: true do |f| + .form-group + = f.label :email, 'メールアドレス', class: 'bmd-label-floating' + = f.email_field :email, class: 'form-control' + .form-group + = f.label :password, 'パスワード', class: 'bmd-label-floating' + = f.password_field :password, class: 'form-control' + + = f.submit 'ログイン', class: 'btn btn-raised btn-primary' + .card + .card-body + | アカウントをお持ちでないですか? + = link_to '登録する', new_user_path diff --git a/app/views/users/new.html.slim b/app/views/users/new.html.slim index 40795b1..1cd0c4d 100644 --- a/app/views/users/new.html.slim +++ b/app/views/users/new.html.slim @@ -1,2 +1,25 @@ -h1 Users#new -p Find me in app/views/users/new.html.slim +h1 新規登録 + +.login-register-form + .login-register-form-inner + .card.mb-3 + = form_with model: @user, class: 'card-body', local: true do |f| + = render 'shared/error_messages', object: @user + .form-group + = f.label :username, class: 'bmd-label-floating' + = f.text_field :username, class: 'form-control' + .form-group + = f.label :email, class: 'bmd-label-floating' + = f.email_field :email, class: 'form-control' + .form-group + = f.label :password, class: 'bmd-label-floating' + = f.password_field :password, class: 'form-control' + .form-group + = f.label :password_confirmation, class: 'bmd-label-floating' + = f.password_field :password_confirmation, class: 'form-control' + + = f.submit '登録', class: 'btn btn-raised btn-primary' + .card + .card-body + | アカウントをお持ちですか + = link_to 'ログインする', login_path diff --git a/config/routes.rb b/config/routes.rb index 787824f..5247b75 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,10 @@ Rails.application.routes.draw do + root to: 'users#new' + resources :users + get '/login', to: 'user_sessions#new' + post '/login', to: 'user_sessions#create' + delete 'logout', to: 'user_sessions#destroy' + + # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html end From a6925f0824a8271cbb9d5d88debc0f65cb311ba7 Mon Sep 17 00:00:00 2001 From: telva0527 Date: Sat, 3 Jul 2021 18:10:41 +0900 Subject: [PATCH 4/7] =?UTF-8?q?annotate=E3=81=AE=E5=B0=8E=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/user.rb | 16 ++++++++ lib/tasks/auto_annotate_models.rake | 59 +++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 lib/tasks/auto_annotate_models.rake diff --git a/app/models/user.rb b/app/models/user.rb index 56597e7..3bd9c9f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,3 +1,19 @@ +# == Schema Information +# +# Table name: users +# +# id :bigint not null, primary key +# crypted_password :string(255) +# email :string(255) not null +# salt :string(255) +# username :string(255) not null +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_users_on_email (email) UNIQUE +# class User < ApplicationRecord authenticates_with_sorcery! diff --git a/lib/tasks/auto_annotate_models.rake b/lib/tasks/auto_annotate_models.rake new file mode 100644 index 0000000..e96283e --- /dev/null +++ b/lib/tasks/auto_annotate_models.rake @@ -0,0 +1,59 @@ +# NOTE: only doing this in development as some production environments (Heroku) +# NOTE: are sensitive to local FS writes, and besides -- it's just not proper +# NOTE: to have a dev-mode tool do its thing in production. +if Rails.env.development? + require 'annotate' + task :set_annotation_options do + # You can override any of these by setting an environment variable of the + # same name. + Annotate.set_defaults( + 'active_admin' => 'false', + 'additional_file_patterns' => [], + 'routes' => 'false', + 'models' => 'true', + 'position_in_routes' => 'before', + 'position_in_class' => 'before', + 'position_in_test' => 'before', + 'position_in_fixture' => 'before', + 'position_in_factory' => 'before', + 'position_in_serializer' => 'before', + 'show_foreign_keys' => 'true', + 'show_complete_foreign_keys' => 'false', + 'show_indexes' => 'true', + 'simple_indexes' => 'false', + 'model_dir' => 'app/models', + 'root_dir' => '', + 'include_version' => 'false', + 'require' => '', + 'exclude_tests' => 'false', + 'exclude_fixtures' => 'false', + 'exclude_factories' => 'false', + 'exclude_serializers' => 'false', + 'exclude_scaffolds' => 'true', + 'exclude_controllers' => 'true', + 'exclude_helpers' => 'true', + 'exclude_sti_subclasses' => 'false', + 'ignore_model_sub_dir' => 'false', + 'ignore_columns' => nil, + 'ignore_routes' => nil, + 'ignore_unknown_models' => 'false', + 'hide_limit_column_types' => 'integer,bigint,boolean', + 'hide_default_column_types' => 'json,jsonb,hstore', + 'skip_on_db_migrate' => 'false', + 'format_bare' => 'true', + 'format_rdoc' => 'false', + 'format_yard' => 'false', + 'format_markdown' => 'false', + 'sort' => 'false', + 'force' => 'false', + 'frozen' => 'false', + 'classified_sort' => 'true', + 'trace' => 'false', + 'wrapper_open' => nil, + 'wrapper_close' => nil, + 'with_comment' => 'true' + ) + end + + Annotate.load_tasks +end From 9c634fb26c6929667a39103298bdb9b6c96c9e64 Mon Sep 17 00:00:00 2001 From: telva0527 Date: Sun, 4 Jul 2021 09:09:44 +0900 Subject: [PATCH 5/7] =?UTF-8?q?ActiveStorage=E3=81=AE=E5=B0=8E=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .rubocop.yml | 1 + .rubocop_todo.yml | 0 Gemfile | 25 +++--- Gemfile.lock | 5 ++ app/controllers/user_sessions_controller.rb | 9 +- app/controllers/users_controller.rb | 15 ++-- app/models/user.rb | 1 + app/views/users/new.html.slim | 2 +- bin/yarn | 12 ++- config/environments/production.rb | 4 +- config/initializers/sorcery.rb | 3 +- config/puma.rb | 8 +- config/routes.rb | 1 - db/migrate/20210702224153_sorcery_core.rb | 2 +- ...te_active_storage_tables.active_storage.rb | 27 ++++++ db/schema.rb | 24 ++++- lib/tasks/auto_annotate_models.rake | 90 +++++++++---------- test/application_system_test_case.rb | 2 +- 18 files changed, 140 insertions(+), 91 deletions(-) create mode 100644 .rubocop.yml create mode 100644 .rubocop_todo.yml create mode 100644 db/migrate/20210703235517_create_active_storage_tables.active_storage.rb diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..cc32da4 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1 @@ +inherit_from: .rubocop_todo.yml diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 0000000..e69de29 diff --git a/Gemfile b/Gemfile index 24e76df..f10487e 100644 --- a/Gemfile +++ b/Gemfile @@ -34,13 +34,13 @@ gem 'bootsnap', '>= 1.1.0', require: false group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console - gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] + gem 'byebug', platforms: %i[mri mingw x64_mingw] end group :development do # Access an interactive console on exception pages or by calling 'console' anywhere in the code. - gem 'web-console', '>= 3.3.0' gem 'listen', '>= 3.0.5', '< 3.2' + gem 'web-console', '>= 3.3.0' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' gem 'spring-watcher-listen', '~> 2.0.0' @@ -55,21 +55,22 @@ group :test do end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem -gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] +gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby] -gem 'bootstrap' -gem 'slim-rails' -gem 'html2slim' -gem 'kaminari' -gem 'sorcery' -gem 'rubocop' -gem 'redis-rails' gem 'annotate' gem 'better_errors' gem 'binding_of_caller' -gem 'pry-byebug', group: :development -gem 'pry-rails' +gem 'bootstrap' gem 'font-awesome-sass' +gem 'html2slim' gem 'jquery-rails' +gem 'kaminari' gem 'popper_js' +gem 'pry-byebug', group: :development +gem 'pry-rails' gem 'rails-i18n' +gem 'redis-rails' +gem 'rubocop' +gem 'rubocop-rails' +gem 'slim-rails' +gem 'sorcery' diff --git a/Gemfile.lock b/Gemfile.lock index 3de0ed1..83f3020 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -238,6 +238,10 @@ GEM unicode-display_width (>= 1.4.0, < 3.0) rubocop-ast (1.7.0) parser (>= 3.0.1.1) + rubocop-rails (2.11.2) + activesupport (>= 4.2.0) + rack (>= 1.1) + rubocop (>= 1.7.0, < 2.0) ruby-progressbar (1.11.0) ruby2_keywords (0.0.4) ruby_dep (1.5.0) @@ -333,6 +337,7 @@ DEPENDENCIES rails-i18n redis-rails rubocop + rubocop-rails sass-rails (~> 5.0) selenium-webdriver slim-rails diff --git a/app/controllers/user_sessions_controller.rb b/app/controllers/user_sessions_controller.rb index 1318916..d437137 100644 --- a/app/controllers/user_sessions_controller.rb +++ b/app/controllers/user_sessions_controller.rb @@ -1,20 +1,19 @@ class UserSessionsController < ApplicationController - def new - end + def new; end def create @user = login(params[:email], params[:password]) if @user - redirect_back_or_to root_path, success: "ログインに成功しました" + redirect_back_or_to root_path, success: 'ログインに成功しました' else - flash.now[:danger] = "ログインに失敗しました" + flash.now[:danger] = 'ログインに失敗しました' render :new end end def destroy logout - redirect_to root_path, success: "ログアウトしました" + redirect_to root_path, success: 'ログアウトしました' end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index cea8ba6..335bf4c 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,6 +1,6 @@ class UsersController < ApplicationController def index - @users = User.all + @users = User.all end def new @@ -11,21 +11,18 @@ def create @user = User.new(user_params) if @user.save auto_login(@user) - redirect_to root_path, success: "ユーザーを作成しました" + redirect_to root_path, success: 'ユーザーを作成しました' else - flash.now[:danger] = "ユーザーの作成に失敗しました" + flash.now[:danger] = 'ユーザーの作成に失敗しました' render :new end end - def show - end + def show; end - def edit - end + def edit; end - def destroy - end + def destroy; end private diff --git a/app/models/user.rb b/app/models/user.rb index 3bd9c9f..ab8ae99 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -15,6 +15,7 @@ # index_users_on_email (email) UNIQUE # class User < ApplicationRecord + has_one_attached :image authenticates_with_sorcery! validates :username, uniqueness: true, presence: true diff --git a/app/views/users/new.html.slim b/app/views/users/new.html.slim index 1cd0c4d..fb6246f 100644 --- a/app/views/users/new.html.slim +++ b/app/views/users/new.html.slim @@ -21,5 +21,5 @@ h1 新規登録 = f.submit '登録', class: 'btn btn-raised btn-primary' .card .card-body - | アカウントをお持ちですか + | アカウントをお持ちですか? = link_to 'ログインする', login_path diff --git a/bin/yarn b/bin/yarn index 460dd56..d3627c3 100755 --- a/bin/yarn +++ b/bin/yarn @@ -1,11 +1,9 @@ #!/usr/bin/env ruby APP_ROOT = File.expand_path('..', __dir__) Dir.chdir(APP_ROOT) do - begin - exec "yarnpkg", *ARGV - rescue Errno::ENOENT - $stderr.puts "Yarn executable was not detected in the system." - $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" - exit 1 - end + exec 'yarnpkg', *ARGV +rescue Errno::ENOENT + warn 'Yarn executable was not detected in the system.' + warn 'Download Yarn at https://yarnpkg.com/en/docs/install' + exit 1 end diff --git a/config/environments/production.rb b/config/environments/production.rb index 574bb02..c233525 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -54,7 +54,7 @@ config.log_level = :debug # Prepend all log lines with the following tags. - config.log_tags = [ :request_id ] + config.log_tags = [:request_id] # Use a different cache store in production. # config.cache_store = :mem_cache_store @@ -83,7 +83,7 @@ # require 'syslog/logger' # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') - if ENV["RAILS_LOG_TO_STDOUT"].present? + if ENV['RAILS_LOG_TO_STDOUT'].present? logger = ActiveSupport::Logger.new(STDOUT) logger.formatter = config.log_formatter config.logger = ActiveSupport::TaggedLogging.new(logger) diff --git a/config/initializers/sorcery.rb b/config/initializers/sorcery.rb index 69f8050..21af875 100644 --- a/config/initializers/sorcery.rb +++ b/config/initializers/sorcery.rb @@ -226,7 +226,6 @@ # config.line.bot_prompt = "normal" # config.line.user_info_mapping = {name: 'displayName'} - # For information about Discord API # https://discordapp.com/developers/docs/topics/oauth2 # config.discord.key = "xxxxxx" @@ -553,5 +552,5 @@ # This line must come after the 'user config' block. # Define which model authenticates with sorcery. - config.user_class = "User" + config.user_class = 'User' end diff --git a/config/puma.rb b/config/puma.rb index b210207..0a5ce17 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -4,19 +4,19 @@ # the maximum value specified for Puma. Default is set to 5 threads for minimum # and maximum; this matches the default thread size of Active Record. # -threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 } threads threads_count, threads_count # Specifies the `port` that Puma will listen on to receive requests; default is 3000. # -port ENV.fetch("PORT") { 3000 } +port ENV.fetch('PORT') { 3000 } # Specifies the `environment` that Puma will run in. # -environment ENV.fetch("RAILS_ENV") { "development" } +environment ENV.fetch('RAILS_ENV') { 'development' } # Specifies the `pidfile` that Puma will use. -pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } +pidfile ENV.fetch('PIDFILE') { 'tmp/pids/server.pid' } # Specifies the number of `workers` to boot in clustered mode. # Workers are forked webserver processes. If using threads and workers together diff --git a/config/routes.rb b/config/routes.rb index 5247b75..5121a60 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -5,6 +5,5 @@ post '/login', to: 'user_sessions#create' delete 'logout', to: 'user_sessions#destroy' - # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html end diff --git a/db/migrate/20210702224153_sorcery_core.rb b/db/migrate/20210702224153_sorcery_core.rb index e7082b1..148daa3 100644 --- a/db/migrate/20210702224153_sorcery_core.rb +++ b/db/migrate/20210702224153_sorcery_core.rb @@ -1,7 +1,7 @@ class SorceryCore < ActiveRecord::Migration[5.2] def change create_table :users do |t| - t.string :email, null: false + t.string :email, null: false t.string :crypted_password t.string :salt t.string :username, null: false diff --git a/db/migrate/20210703235517_create_active_storage_tables.active_storage.rb b/db/migrate/20210703235517_create_active_storage_tables.active_storage.rb new file mode 100644 index 0000000..0b2ce25 --- /dev/null +++ b/db/migrate/20210703235517_create_active_storage_tables.active_storage.rb @@ -0,0 +1,27 @@ +# This migration comes from active_storage (originally 20170806125915) +class CreateActiveStorageTables < ActiveRecord::Migration[5.2] + def change + create_table :active_storage_blobs do |t| + t.string :key, null: false + t.string :filename, null: false + t.string :content_type + t.text :metadata + t.bigint :byte_size, null: false + t.string :checksum, null: false + t.datetime :created_at, null: false + + t.index [ :key ], unique: true + end + + create_table :active_storage_attachments do |t| + t.string :name, null: false + t.references :record, null: false, polymorphic: true, index: false + t.references :blob, null: false + + t.datetime :created_at, null: false + + t.index [ :record_type, :record_id, :name, :blob_id ], name: "index_active_storage_attachments_uniqueness", unique: true + t.foreign_key :active_storage_blobs, column: :blob_id + end + end +end diff --git a/db/schema.rb b/db/schema.rb index d541eb5..c33ec84 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,28 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_07_02_224153) do +ActiveRecord::Schema.define(version: 2021_07_03_235517) do + + create_table "active_storage_attachments", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb3", force: :cascade do |t| + t.string "name", null: false + t.string "record_type", null: false + t.bigint "record_id", null: false + t.bigint "blob_id", null: false + t.datetime "created_at", null: false + t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id" + t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true + end + + create_table "active_storage_blobs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb3", force: :cascade do |t| + t.string "key", null: false + t.string "filename", null: false + t.string "content_type" + t.text "metadata" + t.bigint "byte_size", null: false + t.string "checksum", null: false + t.datetime "created_at", null: false + t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true + end create_table "users", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb3", force: :cascade do |t| t.string "email", null: false @@ -22,4 +43,5 @@ t.index ["email"], name: "index_users_on_email", unique: true end + add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id" end diff --git a/lib/tasks/auto_annotate_models.rake b/lib/tasks/auto_annotate_models.rake index e96283e..e802626 100644 --- a/lib/tasks/auto_annotate_models.rake +++ b/lib/tasks/auto_annotate_models.rake @@ -7,51 +7,51 @@ if Rails.env.development? # You can override any of these by setting an environment variable of the # same name. Annotate.set_defaults( - 'active_admin' => 'false', - 'additional_file_patterns' => [], - 'routes' => 'false', - 'models' => 'true', - 'position_in_routes' => 'before', - 'position_in_class' => 'before', - 'position_in_test' => 'before', - 'position_in_fixture' => 'before', - 'position_in_factory' => 'before', - 'position_in_serializer' => 'before', - 'show_foreign_keys' => 'true', - 'show_complete_foreign_keys' => 'false', - 'show_indexes' => 'true', - 'simple_indexes' => 'false', - 'model_dir' => 'app/models', - 'root_dir' => '', - 'include_version' => 'false', - 'require' => '', - 'exclude_tests' => 'false', - 'exclude_fixtures' => 'false', - 'exclude_factories' => 'false', - 'exclude_serializers' => 'false', - 'exclude_scaffolds' => 'true', - 'exclude_controllers' => 'true', - 'exclude_helpers' => 'true', - 'exclude_sti_subclasses' => 'false', - 'ignore_model_sub_dir' => 'false', - 'ignore_columns' => nil, - 'ignore_routes' => nil, - 'ignore_unknown_models' => 'false', - 'hide_limit_column_types' => 'integer,bigint,boolean', - 'hide_default_column_types' => 'json,jsonb,hstore', - 'skip_on_db_migrate' => 'false', - 'format_bare' => 'true', - 'format_rdoc' => 'false', - 'format_yard' => 'false', - 'format_markdown' => 'false', - 'sort' => 'false', - 'force' => 'false', - 'frozen' => 'false', - 'classified_sort' => 'true', - 'trace' => 'false', - 'wrapper_open' => nil, - 'wrapper_close' => nil, - 'with_comment' => 'true' + 'active_admin' => 'false', + 'additional_file_patterns' => [], + 'routes' => 'false', + 'models' => 'true', + 'position_in_routes' => 'before', + 'position_in_class' => 'before', + 'position_in_test' => 'before', + 'position_in_fixture' => 'before', + 'position_in_factory' => 'before', + 'position_in_serializer' => 'before', + 'show_foreign_keys' => 'true', + 'show_complete_foreign_keys' => 'false', + 'show_indexes' => 'true', + 'simple_indexes' => 'false', + 'model_dir' => 'app/models', + 'root_dir' => '', + 'include_version' => 'false', + 'require' => '', + 'exclude_tests' => 'false', + 'exclude_fixtures' => 'false', + 'exclude_factories' => 'false', + 'exclude_serializers' => 'false', + 'exclude_scaffolds' => 'true', + 'exclude_controllers' => 'true', + 'exclude_helpers' => 'true', + 'exclude_sti_subclasses' => 'false', + 'ignore_model_sub_dir' => 'false', + 'ignore_columns' => nil, + 'ignore_routes' => nil, + 'ignore_unknown_models' => 'false', + 'hide_limit_column_types' => 'integer,bigint,boolean', + 'hide_default_column_types' => 'json,jsonb,hstore', + 'skip_on_db_migrate' => 'false', + 'format_bare' => 'true', + 'format_rdoc' => 'false', + 'format_yard' => 'false', + 'format_markdown' => 'false', + 'sort' => 'false', + 'force' => 'false', + 'frozen' => 'false', + 'classified_sort' => 'true', + 'trace' => 'false', + 'wrapper_open' => nil, + 'wrapper_close' => nil, + 'with_comment' => 'true' ) end diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb index d19212a..23701b4 100644 --- a/test/application_system_test_case.rb +++ b/test/application_system_test_case.rb @@ -1,4 +1,4 @@ -require "test_helper" +require 'test_helper' class ApplicationSystemTestCase < ActionDispatch::SystemTestCase driven_by :selenium, using: :chrome, screen_size: [1400, 1400] From 499452eeac1f911ac658e733f6d1bc0727f9aad6 Mon Sep 17 00:00:00 2001 From: telva0527 Date: Sun, 4 Jul 2021 23:58:49 +0900 Subject: [PATCH 6/7] =?UTF-8?q?bootstrap-material=E3=81=A8swiper=E3=81=AE?= =?UTF-8?q?=E5=B0=8E=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/edit.html.slim | 2 +- package.json | 10 +++++++++- yarn.lock | 28 ++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 yarn.lock diff --git a/app/views/users/edit.html.slim b/app/views/users/edit.html.slim index d62632d..c9559a5 100644 --- a/app/views/users/edit.html.slim +++ b/app/views/users/edit.html.slim @@ -1,2 +1,2 @@ h1 Users#edit -p Find me in app/views/users/edit.html.slim +p Find me in app/views/users/edit.html.slim \ No newline at end of file diff --git a/package.json b/package.json index baeae1e..344998b 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,13 @@ { "name": "instagram_clone", "private": true, - "dependencies": {} + "dependencies": { + "bootstrap-material-design": "^4.1.3", + "swiper": "^6.7.5" + }, + "version": "1.0.0", + "main": "index.js", + "repository": "https://github.com/telva0527/instagram_clone.git", + "author": "telva0527 ", + "license": "MIT" } diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000..b5592cb --- /dev/null +++ b/yarn.lock @@ -0,0 +1,28 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +bootstrap-material-design@^4.1.3: + version "4.1.3" + resolved "https://registry.yarnpkg.com/bootstrap-material-design/-/bootstrap-material-design-4.1.3.tgz#f48c9c94784adf0273261ba0741ed2b927f16bce" + integrity sha512-jOB9io76BKLxwF+IAgObFH9f88ityqOiYsQe9Aa8m88h7sSP3eFL1K8ygb0FsYyIiVm194iodg9i4GMOSlLeRA== + +dom7@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/dom7/-/dom7-3.0.0.tgz#b861ce5d67a6becd7aaa3ad02942ff14b1240331" + integrity sha512-oNlcUdHsC4zb7Msx7JN3K0Nro1dzJ48knvBOnDPKJ2GV9wl1i5vydJZUSyOfrkKFDZEud/jBsTk92S/VGSAe/g== + dependencies: + ssr-window "^3.0.0-alpha.1" + +ssr-window@^3.0.0, ssr-window@^3.0.0-alpha.1: + version "3.0.0" + resolved "https://registry.yarnpkg.com/ssr-window/-/ssr-window-3.0.0.tgz#fd5b82801638943e0cc704c4691801435af7ac37" + integrity sha512-q+8UfWDg9Itrg0yWK7oe5p/XRCJpJF9OBtXfOPgSJl+u3Xd5KI328RUEvUqSMVM9CiQUEf1QdBzJMkYGErj9QA== + +swiper@^6.7.5: + version "6.7.5" + resolved "https://registry.yarnpkg.com/swiper/-/swiper-6.7.5.tgz#8f150c7281919b7d6bea00889e9dc16448e92986" + integrity sha512-KaTjO93tZyMpxWHaey+T+H/JeePMZV/joZWhZaor76Xk+rPGmjOz1S8mXSyrRkaW0p0LOJYeWGB8d0gYxSSV/Q== + dependencies: + dom7 "^3.0.0" + ssr-window "^3.0.0" From 29c775fe51da9877fb28530f9a4ea07573ee13f6 Mon Sep 17 00:00:00 2001 From: telva0527 Date: Mon, 5 Jul 2021 22:39:21 +0900 Subject: [PATCH 7/7] =?UTF-8?q?=E5=BE=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .rubocop_todo.yml | 130 ++++++++++++++++++++++++++++++++++++++++++ config/application.rb | 2 + dump.rdb | Bin 0 -> 92 bytes 3 files changed, 132 insertions(+) create mode 100644 dump.rdb diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e69de29..d7de472 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -0,0 +1,130 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2021-07-05 03:04:45 UTC using RuboCop version 1.18.2. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, no_empty_lines +Layout/EmptyLinesAroundBlockBody: + Exclude: + - 'db/schema.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets. +# SupportedStyles: space, no_space, compact +# SupportedStylesForEmptyBrackets: space, no_space +Layout/SpaceInsideArrayLiteralBrackets: + Exclude: + - 'db/migrate/20210703235517_create_active_storage_tables.active_storage.rb' + +# Offense count: 2 +# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. +# IgnoredMethods: refine +Metrics/BlockLength: + Max: 47 + +# Offense count: 1 +# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. +Metrics/MethodLength: + Max: 18 + +# Offense count: 1 +# Configuration parameters: AllowedChars. +# AllowedChars: © +Style/AsciiComments: + Exclude: + - 'config/initializers/sorcery.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: nested, compact +Style/ClassAndModuleChildren: + Exclude: + - 'test/test_helper.rb' + +# Offense count: 8 +# Configuration parameters: AllowedConstants. +Style/Documentation: + Exclude: + - 'spec/**/*' + - 'test/**/*' + - 'app/controllers/user_sessions_controller.rb' + - 'app/controllers/users_controller.rb' + - 'app/helpers/application_helper.rb' + - 'app/helpers/user_sessions_helper.rb' + - 'app/helpers/users_helper.rb' + - 'app/models/application_record.rb' + - 'config/application.rb' + - 'db/migrate/20210702224153_sorcery_core.rb' + +# Offense count: 48 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, always_true, never +Style/FrozenStringLiteralComment: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +Style/GlobalStdStream: + Exclude: + - 'config/environments/production.rb' + +# Offense count: 2 +Style/MixinUsage: + Exclude: + - 'bin/setup' + - 'bin/update' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: MinDigits, Strict. +Style/NumericLiterals: + Exclude: + - 'db/schema.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: SafeForConstants. +Style/RedundantFetchBlock: + Exclude: + - 'config/puma.rb' + +# Offense count: 39 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. +# SupportedStyles: single_quotes, double_quotes +Style/StringLiterals: + Exclude: + - 'db/migrate/20210703235517_create_active_storage_tables.active_storage.rb' + - 'db/schema.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: . +# SupportedStyles: percent, brackets +Style/SymbolArray: + EnforcedStyle: percent + MinSize: 5 + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: WordRegex. +# SupportedStyles: percent, brackets +Style/WordArray: + EnforcedStyle: percent + MinSize: 5 + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. +# URISchemes: http, https +Layout/LineLength: + Max: 126 diff --git a/config/application.rb b/config/application.rb index b8139ce..4e79b86 100644 --- a/config/application.rb +++ b/config/application.rb @@ -12,6 +12,8 @@ class Application < Rails::Application config.load_defaults 5.2 config.time_zone = 'Tokyo' config.active_record.default_timezone = :local + config.i18n.default_locale = :ja + confg.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}').to_s] config.generators do |g| g.assets false diff --git a/dump.rdb b/dump.rdb new file mode 100644 index 0000000000000000000000000000000000000000..9f94bf617c599778761bac71e6a30cec40533087 GIT binary patch literal 92 zcmWG?b@2=~Ffg$E#aWb^l3A=1kd#?ce8AxsYjR0uZt9^wy^j)p tag-LPrs(FT<{nZ=<7fEAlbD~TTTqmmn46T7dVt~o)%uGw4%_+20{~SOC3ye< literal 0 HcmV?d00001