Replace connect-learn banner with custom content

The connect and learn banner is only used in Australia at the moment. We
would like to have customisable content here. Now every instance can
choose to place a custom alert banner at the top. Unfortunately, custom
banners are not translated into other languages. That's why I kept the
standard register call. For example, the register call is in use where
it is displayed in French and Italian. Completely switching to custom
content would break the translation.

Translations in custom content are an existing feature request,
"multi-lang 2.0".
This commit is contained in:
Maikel Linke
2019-05-07 16:32:45 +10:00
parent 38c9ecd44f
commit a3adbd9fc8
4 changed files with 18 additions and 14 deletions

View File

@@ -12,6 +12,20 @@ class ContentConfiguration < Spree::Preferences::FileConfiguration
has_attached_file :logo_mobile_svg, default_url: "/assets/ofn-logo-mobile.svg"
# Home page
#
# I intended to set a default for home_page_alert_html including I18n text.
#
# default: "<a href='/register' target='_blank'>
# #{I18n.t('shared.register_call.selling_on_ofn')}&nbsp;
# <strong>#{I18n.t('shared.register_call.register')}
# <i class='ofn-i_054-point-right'></i></strong>
# </a>"
#
# Unfortunately, this configuration is initialised and cached before locales
# are loaded. So I chose to not set a default and use a translatable view instead.
# All the following defaults using I18n don't work.
# https://github.com/openfoodfoundation/openfoodnetwork/issues/3816
preference :home_page_alert_html, :text
preference :home_hero, :file
preference :home_show_stats, :boolean, default: true
has_attached_file :home_hero, default_url: "/assets/home/home.jpg"

View File

@@ -6,6 +6,7 @@ module PreferenceSections
def preferences
[
:home_page_alert_html,
:home_hero,
:home_show_stats
]

View File

@@ -1,12 +0,0 @@
:css
.page-alert .alert-box { background-color: #fdddac; }
.alert-cta
%h6
Open Food Network
%strong
= link_to t(:label_connect), "https://openfoodnetwork.org/au/connect/", target: '_blank'
and
%strong
= link_to t(:label_learn), "https://openfoodnetwork.org/au/learn/", target: '_blank'
\- Go exploring and get inspired!

View File

@@ -1,5 +1,6 @@
- if feature? :connect_learn_homepage
= render "shared/connect_learn_call"
- if ContentConfig.home_page_alert_html.present?
.alert-cta
%h6= raw ContentConfig.home_page_alert_html
- else
= render "shared/register_call"