mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Content-manage footer fields
This commit is contained in:
1
Gemfile
1
Gemfile
@@ -30,6 +30,7 @@ gem 'newrelic_rpm'
|
||||
gem 'haml'
|
||||
gem 'sass', "~> 3.3"
|
||||
gem 'sass-rails', '~> 3.2.3', groups: [:default, :assets]
|
||||
gem 'redcarpet'
|
||||
gem 'aws-sdk'
|
||||
gem 'db2fog'
|
||||
gem 'andand'
|
||||
|
||||
@@ -424,6 +424,7 @@ GEM
|
||||
ffi (>= 0.5.0)
|
||||
rdoc (3.12.2)
|
||||
json (~> 1.4)
|
||||
redcarpet (3.2.3)
|
||||
ref (1.0.5)
|
||||
representative (1.0.5)
|
||||
activesupport (>= 2.2.2)
|
||||
@@ -583,6 +584,7 @@ DEPENDENCIES
|
||||
rack-ssl
|
||||
rails (= 3.2.21)
|
||||
rails-i18n (~> 3.0.0)
|
||||
redcarpet
|
||||
representative_view
|
||||
roadie-rails (~> 1.0.3)
|
||||
rspec-rails
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
module Admin
|
||||
class ContentsController < Spree::Admin::BaseController
|
||||
def edit
|
||||
@preferences = [:home_tagline_cta, :home_whats_happening, :footer_about_url]
|
||||
@preferences_home = [:home_tagline_cta, :home_whats_happening]
|
||||
@preferences_footer = [:footer_facebook_url, :footer_twitter_url, :footer_instagram_url, :footer_linkedin_url, :footer_googleplus_url, :footer_pinterest_url, :footer_email, :footer_links_md, :footer_about_url]
|
||||
end
|
||||
|
||||
def update
|
||||
|
||||
6
app/helpers/markdown_helper.rb
Normal file
6
app/helpers/markdown_helper.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
module MarkdownHelper
|
||||
def render_markdown(markdown)
|
||||
md ||= Redcarpet::Markdown.new(Redcarpet::Render::HTML, no_intra_emphasis: true, tables: true, autolink: true, superscript: true)
|
||||
md.render markdown
|
||||
end
|
||||
end
|
||||
@@ -2,5 +2,20 @@ class ContentConfiguration < Spree::Preferences::Configuration
|
||||
preference :home_tagline_cta, :string, default: "Browse Open Food Network Australia"
|
||||
preference :home_whats_happening, :string, default: "Thanks for making the Open Food Network possible. Our vision is a better food system, and we're proud of what we're achieving together."
|
||||
|
||||
preference :footer_facebook_url, :string, default: "https://www.facebook.com/OpenFoodNet"
|
||||
preference :footer_twitter_url, :string, default: "https://twitter.com/OpenFoodNet"
|
||||
preference :footer_instagram_url, :string, default: ""
|
||||
preference :footer_linkedin_url, :string, default: "http://www.linkedin.com/groups/Open-Food-Foundation-4743336"
|
||||
preference :footer_googleplus_url, :string, default: ""
|
||||
preference :footer_pinterest_url, :string, default: ""
|
||||
preference :footer_email, :string, default: "hello@openfoodnetwork.org"
|
||||
preference :footer_links_md, :text, default: <<-EOS
|
||||
[Newsletter sign-up](/)
|
||||
|
||||
[Blog](/)
|
||||
|
||||
[Calendar](/)
|
||||
EOS
|
||||
|
||||
preference :footer_about_url, :string, default: "http://global.openfoodnetwork.org/ofn-local/open-food-network-australia/"
|
||||
end
|
||||
|
||||
8
app/views/admin/contents/_fieldset.html.haml
Normal file
8
app/views/admin/contents/_fieldset.html.haml
Normal file
@@ -0,0 +1,8 @@
|
||||
%fieldset.no-border-bottom
|
||||
%legend{align: "center"}= name
|
||||
- preferences.each do |key|
|
||||
- type = ContentConfig.preference_type(key)
|
||||
.field
|
||||
= label_tag(key, t(key) + ': ') + tag(:br) if type != :boolean
|
||||
= preference_field_tag(key, ContentConfig[key], :type => type)
|
||||
= label_tag(key, t(key)) + tag(:br) if type == :boolean
|
||||
@@ -6,14 +6,8 @@
|
||||
|
||||
= form_tag main_app.admin_content_path, method: :put do
|
||||
#preferences
|
||||
%fieldset.no-border-bottom
|
||||
%legend{align: "center"} Home page
|
||||
- @preferences.each do |key|
|
||||
- type = ContentConfig.preference_type(key)
|
||||
.field
|
||||
= label_tag(key, t(key) + ': ') + tag(:br) if type != :boolean
|
||||
= preference_field_tag(key, ContentConfig[key], :type => type)
|
||||
= label_tag(key, t(key)) + tag(:br) if type == :boolean
|
||||
= render 'fieldset', name: 'Home page', preferences: @preferences_home
|
||||
= render 'fieldset', name: 'Footer', preferences: @preferences_footer
|
||||
|
||||
.form-buttons.filter-actions.actions{"data-hook" => "buttons"}
|
||||
= button t(:update), 'icon-refresh'
|
||||
|
||||
@@ -52,26 +52,28 @@
|
||||
// This is the instance-managed set of links:
|
||||
%h4 Keep in touch
|
||||
%p.social-icons
|
||||
%a{href: "/"}
|
||||
%i.ofn-i_044-facebook
|
||||
%a{href: "/"}
|
||||
%i.ofn-i_041-twitter
|
||||
%a{href: "/"}
|
||||
%i.ofn-i_043-instagram
|
||||
%a{href: "/"}
|
||||
%i.ofn-i_042-linkedin
|
||||
%a{href: "/"}
|
||||
%i.ofn-i_046-g
|
||||
%a{href: "/"}
|
||||
%i.ofn-i_045-pintrest
|
||||
%p
|
||||
%a{href: "hello@openfoodnetwork.org".reverse, target: '_blank', mailto: true} Email us
|
||||
%p
|
||||
%a{href: "/"} Newsletter sign-up
|
||||
%p
|
||||
%a{href: "/"} Blog
|
||||
%p
|
||||
%a{href: "/"} Calendar
|
||||
- if ContentConfig.footer_facebook_url.present?
|
||||
%a{href: ContentConfig.footer_facebook_url}
|
||||
%i.ofn-i_044-facebook
|
||||
- if ContentConfig.footer_twitter_url.present?
|
||||
%a{href: ContentConfig.footer_twitter_url}
|
||||
%i.ofn-i_041-twitter
|
||||
- if ContentConfig.footer_instagram_url.present?
|
||||
%a{href: ContentConfig.footer_instagram_url}
|
||||
%i.ofn-i_043-instagram
|
||||
- if ContentConfig.footer_linkedin_url.present?
|
||||
%a{href: ContentConfig.footer_linkedin_url}
|
||||
%i.ofn-i_042-linkedin
|
||||
- if ContentConfig.footer_googleplus_url.present?
|
||||
%a{href: ContentConfig.footer_googleplus_url}
|
||||
%i.ofn-i_046-g
|
||||
- if ContentConfig.footer_pinterest_url.present?
|
||||
%a{href: ContentConfig.footer_pinterest_url}
|
||||
%i.ofn-i_045-pintrest
|
||||
- if ContentConfig.footer_email.present?
|
||||
%p
|
||||
%a{href: ContentConfig.footer_email.reverse, mailto: true, target: '_blank'} Email us
|
||||
= render_markdown(ContentConfig.footer_links_md).html_safe
|
||||
|
||||
|
||||
.small-6.medium-3.columns.text-left
|
||||
|
||||
@@ -20,4 +20,14 @@ en:
|
||||
producers_join: Australian producers are now welcome to join the Open Food Network.
|
||||
charges_sales_tax: Charges GST?
|
||||
|
||||
home_tagline_cta: "Home tagline call to action"
|
||||
home_tagline_cta: "Tagline call to action"
|
||||
home_whats_happening: "What's happening"
|
||||
footer_facebook_url: "Facebook URL"
|
||||
footer_twitter_url: "Twitter URL"
|
||||
footer_instagram_url: "Instagram URL"
|
||||
footer_linkedin_url: "LinkedIn URL"
|
||||
footer_googleplus_url: "Google Plus URL"
|
||||
footer_pinterest_url: "Pinterest URL"
|
||||
footer_email: "Email"
|
||||
footer_links_md: "Links"
|
||||
footer_about_url: "About URL"
|
||||
@@ -13,10 +13,22 @@ feature %q{
|
||||
click_link 'Content'
|
||||
|
||||
fill_in 'home_tagline_cta', with: 'Editable text'
|
||||
fill_in 'footer_facebook_url', with: ''
|
||||
fill_in 'footer_twitter_url', with: 'http://twitter.com/me'
|
||||
fill_in 'footer_links_md', with: '[markdown link](/)'
|
||||
click_button 'Update'
|
||||
page.should have_content 'Your content has been successfully updated!'
|
||||
|
||||
visit root_path
|
||||
|
||||
# The content should be shown
|
||||
page.should have_content 'Editable text'
|
||||
|
||||
# And social media icons are only shown if they have a value
|
||||
page.should_not have_selector 'i.ofn-i_044-facebook'
|
||||
page.should have_selector 'i.ofn-i_041-twitter'
|
||||
|
||||
# And markdown is rendered
|
||||
page.should have_link 'markdown link'
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user