From 552d22bec9602a64616538f7df0bdac13140c7f8 Mon Sep 17 00:00:00 2001 From: takayamaki Date: Wed, 11 Oct 2017 07:52:25 +0900 Subject: [PATCH] sign_in and sign_up views present og meta infos (#5308) --- app/controllers/auth/registrations_controller.rb | 5 +++++ app/controllers/auth/sessions_controller.rb | 5 +++++ app/views/about/more.html.haml | 2 +- app/views/about/show.html.haml | 2 +- app/views/auth/registrations/new.html.haml | 3 +++ app/views/auth/sessions/new.html.haml | 3 +++ app/views/{about => shared}/_og.html.haml | 0 7 files changed, 18 insertions(+), 2 deletions(-) rename app/views/{about => shared}/_og.html.haml (100%) diff --git a/app/controllers/auth/registrations_controller.rb b/app/controllers/auth/registrations_controller.rb index 60ace04d7..aac3c31ff 100644 --- a/app/controllers/auth/registrations_controller.rb +++ b/app/controllers/auth/registrations_controller.rb @@ -6,6 +6,7 @@ class Auth::RegistrationsController < Devise::RegistrationsController before_action :check_enabled_registrations, only: [:new, :create] before_action :configure_sign_up_params, only: [:create] before_action :set_sessions, only: [:edit, :update] + before_action :set_instance_presenter, only: [:new, :update] def destroy not_found @@ -39,6 +40,10 @@ class Auth::RegistrationsController < Devise::RegistrationsController private + def set_instance_presenter + @instance_presenter = InstancePresenter.new + end + def determine_layout %w(edit update).include?(action_name) ? 'admin' : 'auth' end diff --git a/app/controllers/auth/sessions_controller.rb b/app/controllers/auth/sessions_controller.rb index bc3bd2f4b..463a183e4 100644 --- a/app/controllers/auth/sessions_controller.rb +++ b/app/controllers/auth/sessions_controller.rb @@ -8,6 +8,7 @@ class Auth::SessionsController < Devise::SessionsController skip_before_action :require_no_authentication, only: [:create] skip_before_action :check_suspension, only: [:destroy] prepend_before_action :authenticate_with_two_factor, if: :two_factor_enabled?, only: [:create] + before_action :set_instance_presenter, only: [:new] def create super do |resource| @@ -84,6 +85,10 @@ class Auth::SessionsController < Devise::SessionsController private + def set_instance_presenter + @instance_presenter = InstancePresenter.new + end + def home_paths(resource) paths = [about_path] if single_user_mode? && resource.is_a?(User) diff --git a/app/views/about/more.html.haml b/app/views/about/more.html.haml index 1a4e74643..b012606ce 100644 --- a/app/views/about/more.html.haml +++ b/app/views/about/more.html.haml @@ -3,7 +3,7 @@ - content_for :header_tags do = javascript_pack_tag 'public', integrity: true, crossorigin: 'anonymous' - = render partial: 'og' + = render partial: 'shared/og' .landing-page .header-wrapper.compact diff --git a/app/views/about/show.html.haml b/app/views/about/show.html.haml index ef27d07a1..f8f90ce24 100644 --- a/app/views/about/show.html.haml +++ b/app/views/about/show.html.haml @@ -4,7 +4,7 @@ - content_for :header_tags do %script#initial-state{ type: 'application/json' }!= json_escape(@initial_state_json) = javascript_pack_tag 'about', integrity: true, crossorigin: 'anonymous' - = render partial: 'og' + = render partial: 'shared/og' .landing-page .header-wrapper diff --git a/app/views/auth/registrations/new.html.haml b/app/views/auth/registrations/new.html.haml index 807020310..f71675df0 100644 --- a/app/views/auth/registrations/new.html.haml +++ b/app/views/auth/registrations/new.html.haml @@ -1,6 +1,9 @@ - content_for :page_title do = t('auth.register') +- content_for :header_tags do + = render partial: 'shared/og' + = simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| = render 'shared/error_messages', object: resource diff --git a/app/views/auth/sessions/new.html.haml b/app/views/auth/sessions/new.html.haml index e589377bf..a52b0053b 100644 --- a/app/views/auth/sessions/new.html.haml +++ b/app/views/auth/sessions/new.html.haml @@ -1,6 +1,9 @@ - content_for :page_title do = t('auth.login') +- content_for :header_tags do + = render partial: 'shared/og' + = simple_form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| = f.input :email, autofocus: true, placeholder: t('simple_form.labels.defaults.email'), required: true, input_html: { 'aria-label' => t('simple_form.labels.defaults.email') } = f.input :password, placeholder: t('simple_form.labels.defaults.password'), required: true, input_html: { 'aria-label' => t('simple_form.labels.defaults.password'), :autocomplete => 'off' } diff --git a/app/views/about/_og.html.haml b/app/views/shared/_og.html.haml similarity index 100% rename from app/views/about/_og.html.haml rename to app/views/shared/_og.html.haml