Permalink
Browse files

tweak code so that locomotive.works (hosting) could handle smoothly t…

…he white label feature
  • Loading branch information...
did committed Mar 8, 2017
1 parent d5c959e commit fde99c41bb99721d007b3fbd05319407c69896b3
@@ -13,7 +13,7 @@ module RedirectToMainHostController
private
def redirect_to_main_host
return if Locomotive.config.host.blank?
return if Locomotive.config.host.blank? || request.env['locomotive.default_host'].present?
if request.host != Locomotive.config.host
options = { host: Locomotive.config.host }
@@ -3,6 +3,8 @@ class ErrorsController < ApplicationController
layout '/locomotive/layouts/error'
helper Locomotive::BaseHelper
def error_404
render '404', status: :not_found
end
@@ -28,7 +28,11 @@ def after_sending_reset_password_instructions_path_for(resource_name)
end
def set_locale
I18n.locale = current_site? ? current_site.accounts.first.locale : Locomotive.config.default_locale
I18n.locale = current_site? ? current_site.accounts.first.locale : default_locale
end
def default_locale
Locomotive.config.default_locale
end
end
@@ -10,6 +10,8 @@ class RegistrationsController < ::Devise::RegistrationsController
helper Locomotive::BaseHelper
before_filter :set_locale
private
def after_sign_up_path_for(resource)
@@ -20,5 +22,9 @@ def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up) << :name
end
def set_locale
I18n.locale = Locomotive.config.default_locale
end
end
end
@@ -24,7 +24,11 @@ def after_sign_out_path_for(resource)
end
def set_locale
I18n.locale = current_site? ? current_site.accounts.first.locale : Locomotive.config.default_locale
I18n.locale = current_site? ? current_site.accounts.first.locale : default_locale
end
def default_locale
Locomotive.config.default_locale
end
end
@@ -11,6 +11,10 @@ def body_class
[self.controller.controller_name, action].map(&:dasherize).join(' ')
end
def application_name
Locomotive.config.name
end
def title(title = nil)
if title.nil?
@content_for_title
@@ -33,6 +37,12 @@ def help(text)
end
end
#= Sessions
def enable_registration?
current_site.nil? && Locomotive.config.enable_registration
end
#= Sidebar
def sidebar_current_section_class
@@ -72,6 +82,14 @@ def form_tab_pane(name, first = false, &block)
## Tag helpers ##
def account_logo_tag
image_tag 'locomotive/logo-white.png'
end
def sidebar_logo_tag
image_tag 'locomotive/logo.png'
end
def icon_tag(name)
content_tag :i, '', class: ['fa', name].join(' ')
end
@@ -4,7 +4,7 @@ html xmlns='http://www.w3.org/1999/xhtml' lang=I18n.locale
meta charset="utf-8"
meta http-equiv="x-ua-compatible" content="ie=edge"
title= escape_once(strip_tags(title) + " | #{Locomotive.config.name}")
title= escape_once(strip_tags(title) + " | #{application_name}")
meta name="viewport" content="width=device-width, initial-scale=1"
@@ -4,7 +4,7 @@ html xmlns='http://www.w3.org/1999/xhtml' lang=I18n.locale
meta charset="utf-8"
meta http-equiv="x-ua-compatible" content="ie=edge"
title= escape_once(strip_tags(error_title) + " | Locomotive")
title= escape_once(strip_tags(error_title) + " | #{application_name}")
meta name="viewport" content="width=device-width, initial-scale=1"
@@ -19,6 +19,6 @@ html xmlns='http://www.w3.org/1999/xhtml' lang=I18n.locale
.public-container
.public-wrapper
= link_to root_path, class: 'brand-logo' do
= image_tag 'locomotive/logo-white.png'
= account_logo_tag
= yield
@@ -1,7 +1,7 @@
- title t('locomotive.passwords.edit.title')
= link_to root_path, class: 'brand-logo' do
= image_tag 'locomotive/logo-white.png'
= account_logo_tag
.public-box
.public-intro
@@ -1,7 +1,7 @@
- title t('locomotive.passwords.new.title')
= link_to root_path, class: 'brand-logo' do
= image_tag 'locomotive/logo-white.png'
= account_logo_tag
.public-box
.public-intro
@@ -1,7 +1,7 @@
- title t('locomotive.registrations.new.title')
= link_to root_path, class: 'brand-logo' do
= image_tag 'locomotive/logo-white.png'
= account_logo_tag
.public-box
.public-intro
@@ -1,7 +1,7 @@
- title t('locomotive.sessions.new.title')
= link_to root_path, class: 'brand-logo' do
= image_tag 'locomotive/logo-white.png'
= account_logo_tag
.public-box
.public-intro
@@ -20,5 +20,5 @@
= f.actions do
= f.button :submit, t('.submit'), class: 'btn btn-primary'
- if current_site.nil? && Locomotive.config.enable_registration
- if enable_registration?
= link_to t('.sign_up').html_safe, sign_up_path, class: 'public-link'
@@ -1,5 +1,5 @@
nav.navigation class="#{class_name rescue ''}"
= link_to root_path, class: 'brand-logo' do
= image_tag 'locomotive/logo-white.png'
= account_logo_tag
= render 'locomotive/shared/account/navigation'
@@ -1,6 +1,6 @@
.sidebar role="tablist" aria-multiselectable="false" data-current-section=sidebar_current_section_class
= link_to root_path, class: 'sidebar-logo' do
= image_tag 'locomotive/logo.png'
= sidebar_logo_tag
- cache(cache_key_for_sidebar) do
= link_to dashboard_path(current_site), class: sidebar_link_class(:dashboard) do
@@ -40,11 +40,12 @@ en:
send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.'
unlocked: 'Your account was successfully unlocked. You are now signed in.'
mailer:
locomotive_account:
confirmation_instructions: 'Confirmation instructions'
reset_password_instructions: 'Reset password instructions'
unlock_instructions: 'Unlock Instructions'
confirmation_instructions:
locomotive_account_subject: 'Confirmation instructions'
reset_password_instructions:
locomotive_account_subject: 'Reset password instructions'
unlock_instructions:
locomotive_account_subject: 'Unlock Instructions'
locomotive:
devise_mailer:
@@ -39,10 +39,12 @@ fr:
send_instructions: 'Vous allez recevoir un email avec les instructions nécessaires pour dé-vérouiller votre compte dans quelques minutes'
unlocked: 'Votre compte à été dé-verouillé. Vous êtes connecté!'
mailer:
locomotive_account:
confirmation_instructions: 'Instructions de validation'
reset_password_instructions: 'Instructions de rétablissement du mot de passe'
unlock_instructions: 'Instructions de déverrouillage.'
confirmation_instructions:
locomotive_account_subject: 'Instructions de validation'
reset_password_instructions:
locomotive_account_subject: 'Instructions de rétablissement du mot de passe'
unlock_instructions:
locomotive_account_subject: 'Instructions de déverrouillage.'
locomotive:
devise_mailer:
common:
@@ -117,7 +117,9 @@ def request_for_the_back_office_and_default_host?(request)
end
def default_host?(request)
(default_host && request.host == default_host) || localhost?(request)
request.env['locomotive.default_host'].present? ||
(default_host && request.host == default_host) ||
localhost?(request)
end
def localhost?(request)
@@ -388,12 +388,12 @@
end
# it_should_behave_like 'model scoped by a site' do
it_should_behave_like 'model scoped by a site' do
# let(:model) { build_content_entry }
# let(:attribute) { :content_version }
let(:model) { build_content_entry }
let(:attribute) { :content_version }
# end
end
def localize_content_type(content_type)
content_type.entries_custom_fields.first.localized = true

0 comments on commit fde99c4

Please sign in to comment.