diff --git a/app/assets/stylesheets/darkswarm/home_panes.css.sass b/app/assets/stylesheets/darkswarm/home_panes.css.sass index dd3c6a0fca..ed74450317 100644 --- a/app/assets/stylesheets/darkswarm/home_panes.css.sass +++ b/app/assets/stylesheets/darkswarm/home_panes.css.sass @@ -76,7 +76,7 @@ width: 64px height: 64px margin: 0 auto - background-color: $australia-orange + background-color: $brand-colour background-position: center center background-repeat: no-repeat background-size: auto 100% @@ -90,13 +90,13 @@ h2 font-size: 70px font-weight: 300 - color: $australia-orange + color: $brand-colour @media all and (max-width: 640px) font-size: 45px a - color: $australia-orange + color: $brand-colour .home-icon-box-bottom margin-top: 1rem @@ -110,8 +110,8 @@ padding-left: 1rem padding-right: 1rem h4 - color: $australia-orange - border-bottom: 2px solid lighten($australia-orange, 20%) + color: $brand-colour + border-bottom: 2px solid lighten($brand-colour, 20%) text-align: center padding: 1rem 0 margin: 1.5rem 0 @@ -146,4 +146,4 @@ font-weight: 300 #shops-signup.pane - background-color: $australia-orange + background-color: $brand-colour diff --git a/app/assets/stylesheets/darkswarm/menu.css.sass b/app/assets/stylesheets/darkswarm/menu.css.sass index d92fac2d06..41b86f72ff 100644 --- a/app/assets/stylesheets/darkswarm/menu.css.sass +++ b/app/assets/stylesheets/darkswarm/menu.css.sass @@ -51,7 +51,7 @@ nav opacity: 1 .nav-branded - color: $australia-orange + color: $brand-colour span font-size: 13px .nav-primary @@ -102,7 +102,7 @@ nav color: rgba(0, 0, 0, 0.9) &:hover background-color: transparent - color: $australia-orange + color: $brand-colour @include transition(all 0.3s ease-in-out) .off-canvas-wrap.move-right ul.off-canvas-list i diff --git a/app/assets/stylesheets/darkswarm/mixins.sass b/app/assets/stylesheets/darkswarm/mixins.sass index 668ef2b59c..4e779bd2a5 100644 --- a/app/assets/stylesheets/darkswarm/mixins.sass +++ b/app/assets/stylesheets/darkswarm/mixins.sass @@ -7,7 +7,7 @@ @mixin tiledPane background-image: url("/assets/tile-wide.png") - background-color: $australia-orange + background-color: $brand-colour background-position: center center @include paneWhiteText diff --git a/app/assets/stylesheets/darkswarm/signup.css.sass b/app/assets/stylesheets/darkswarm/signup.css.sass index c4d055b3a6..cd6ebf458a 100644 --- a/app/assets/stylesheets/darkswarm/signup.css.sass +++ b/app/assets/stylesheets/darkswarm/signup.css.sass @@ -20,13 +20,13 @@ #producer-case-studies, #shops-case-studies padding-top: 100px padding-bottom: 100px - background-color: $australia-orange + background-color: $brand-colour background-image: url("/assets/hubs-bg.jpg") background-position: center center -webkit-filter: brightness(1.1) filter: brightness(1.1) h2 - color: $australia-orange + color: $brand-colour font-size: 3rem .case-study background-color: rgba(255, 255, 255, 0.5) @@ -42,7 +42,7 @@ @media all and (min-width: 640px) text-align: left h4, a - color: $australia-orange + color: $brand-colour a &, & * @include csstrans @@ -68,9 +68,9 @@ table.signup-table.hubs-table, table.signup-table.producers-table background-color: lighten($ofn-grey, 41%) td:last-child &, & i - color: $australia-orange - border-bottom: 1px solid rgba($australia-orange, 0.3) - background-color: lighten($australia-orange, 48%) + color: $brand-colour + border-bottom: 1px solid rgba($brand-colour, 0.3) + background-color: lighten($brand-colour, 48%) thead background-color: transparent tr @@ -85,7 +85,7 @@ table.signup-table.hubs-table, table.signup-table.producers-table td:last-child &, & * color: white - background: $australia-orange + background: $brand-colour h5 text-transform: uppercase color: $ofn-grey @@ -107,7 +107,7 @@ table.signup-table.hubs-table, table.signup-table.producers-table td:last-child &, & * color: white - background: $australia-orange + background: $brand-colour h2 .text-small text-transform: uppercase diff --git a/app/assets/stylesheets/darkswarm/variables.css.sass b/app/assets/stylesheets/darkswarm/variables.css.sass index 81018be6ec..ea87d11fc4 100644 --- a/app/assets/stylesheets/darkswarm/variables.css.sass +++ b/app/assets/stylesheets/darkswarm/variables.css.sass @@ -1,7 +1,17 @@ @import "foundation/functions" @import "foundation/components/global" -$australia-orange: rgba(242, 112, 82, 1) +// Brand guide colours: +// International: #81c26e +// Australia: #f35746 +// Africa: #f35e32 +// South Africa: #f9a72b +// Norway: #4b83cc +// Scandanavia: #0c8bbc +// UK: #e6373f + +$brand-colour: #f27052 + // Topbar $topbar-height: rem-calc(75) @@ -11,7 +21,7 @@ $topbar-bg: $white $topbar-bg-color: $topbar-bg $topbar-link-color: $black -$topbar-link-color-hover: $australia-orange +$topbar-link-color-hover: $brand-colour $topbar-link-color-active: $black $topbar-link-color-active-hover: $white $topbar-link-bg-hover: $white diff --git a/app/controllers/admin/contents_controller.rb b/app/controllers/admin/contents_controller.rb index a048981f5e..87c86997d9 100644 --- a/app/controllers/admin/contents_controller.rb +++ b/app/controllers/admin/contents_controller.rb @@ -1,15 +1,26 @@ module Admin class ContentsController < Spree::Admin::BaseController def edit - @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] + @preference_sections = [{name: 'Header', preferences: [:logo, :logo_mobile, :logo_mobile_svg]}, + {name: 'Home page', preferences: [:home_hero, :home_show_stats]}, + {name: 'Producer signup page', preferences: [:producer_signup_pricing_table_html, :producer_signup_case_studies_html, :producer_signup_detail_html]}, + {name: 'Hub signup page', preferences: [:hub_signup_pricing_table_html, :hub_signup_case_studies_html, :hub_signup_detail_html]}, + {name: 'Group signup page', preferences: [:group_signup_pricing_table_html, :group_signup_case_studies_html, :group_signup_detail_html]}, + {name: 'Footer', preferences: [:footer_logo, + :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, :footer_tos_url]}] end def update params.each do |name, value| - next unless ContentConfig.has_preference? name - ContentConfig[name] = value + if ContentConfig.has_preference?(name) || ContentConfig.has_attachment?(name) + ContentConfig.send("#{name}=", value) + end end + + # Save any uploaded images + ContentConfig.save + flash[:success] = t(:successfully_updated, :resource => "Your content") redirect_to main_app.edit_admin_content_path diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index d1e1ae472c..07ba097f85 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -2,9 +2,11 @@ class HomeController < BaseController layout 'darkswarm' def index - @num_distributors = Enterprise.is_distributor.activated.visible.count - @num_producers = Enterprise.is_primary_producer.activated.visible.count - @num_users = Spree::User.joins(:orders).merge(Spree::Order.complete).count('DISTINCT spree_users.*') - @num_orders = Spree::Order.complete.count + if ContentConfig.home_show_stats + @num_distributors = Enterprise.is_distributor.activated.visible.count + @num_producers = Enterprise.is_primary_producer.activated.visible.count + @num_users = Spree::User.joins(:orders).merge(Spree::Order.complete).count('DISTINCT spree_users.*') + @num_orders = Spree::Order.complete.count + end end end diff --git a/app/helpers/spree/admin/base_helper_decorator.rb b/app/helpers/spree/admin/base_helper_decorator.rb index e278626c5c..82bf794073 100644 --- a/app/helpers/spree/admin/base_helper_decorator.rb +++ b/app/helpers/spree/admin/base_helper_decorator.rb @@ -15,6 +15,16 @@ module Spree link_to_with_icon('icon-trash', name, url, :class => "remove_fields #{options[:class]}", :data => {:action => 'remove'}, :title => t(:remove)) + f.hidden_field(:_destroy) end + + + def preference_field_tag_with_files(name, value, options) + if options[:type] == :file + file_field_tag name, preference_field_options(options) + else + preference_field_tag_without_files name, value, options + end + end + alias_method_chain :preference_field_tag, :files end end end diff --git a/app/models/content_configuration.rb b/app/models/content_configuration.rb index 6e36b67812..2357f8dfa3 100644 --- a/app/models/content_configuration.rb +++ b/app/models/content_configuration.rb @@ -1,7 +1,39 @@ -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." +require 'open_food_network/paperclippable' +class ContentConfiguration < Spree::Preferences::FileConfiguration + include OpenFoodNetwork::Paperclippable + + # Header + preference :logo, :file + preference :logo_mobile, :file + preference :logo_mobile_svg, :file + has_attached_file :logo + has_attached_file :logo_mobile + has_attached_file :logo_mobile_svg + + # Home page + preference :home_hero, :file + preference :home_show_stats, :boolean, default: true + has_attached_file :home_hero + + # Producer sign-up page + preference :producer_signup_pricing_table_html, :text, default: "(TODO: Pricing table)" + preference :producer_signup_case_studies_html, :text, default: "(TODO: Case studies)" + preference :producer_signup_detail_html, :text, default: "(TODO: Detail)" + + # Hubs sign-up page + preference :hub_signup_pricing_table_html, :text, default: "(TODO: Pricing table)" + preference :hub_signup_case_studies_html, :text, default: "(TODO: Case studies)" + preference :hub_signup_detail_html, :text, default: "(TODO: Detail)" + + # Groups sign-up page + preference :group_signup_pricing_table_html, :text, default: "(TODO: Pricing table)" + preference :group_signup_case_studies_html, :text, default: "(TODO: Case studies)" + preference :group_signup_detail_html, :text, default: "(TODO: Detail)" + + # Footer + preference :footer_logo, :file + has_attached_file :footer_logo 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: "" @@ -18,4 +50,5 @@ class ContentConfiguration < Spree::Preferences::Configuration EOS preference :footer_about_url, :string, default: "http://www.openfoodnetwork.org/ofn-local/open-food-network-australia/" + preference :footer_tos_url, :string, default: "/Terms-of-service.pdf" end diff --git a/app/models/spree/preferences/file_configuration.rb b/app/models/spree/preferences/file_configuration.rb new file mode 100644 index 0000000000..fa1838a778 --- /dev/null +++ b/app/models/spree/preferences/file_configuration.rb @@ -0,0 +1,50 @@ +module Spree::Preferences + class FileConfiguration < Configuration + + def self.preference(name, type, *args) + if type == :file + super "#{name}_file_name", :string, *args + super "#{name}_content_type", :string, *args + super "#{name}_file_size", :integer, *args + super "#{name}_updated_at", :string, *args + + else + super name, type, *args + end + end + + + def get_preference(key) + if !has_preference?(key) && has_attachment?(key) + send key + else + super key + end + end + alias :[] :get_preference + + + def preference_type(name) + if has_attachment? name + :file + else + super name + end + end + + + # Spree's Configuration responds to preference methods via method_missing, but doesn't + # override respond_to?, which consequently reports those methods as unavailable. Paperclip + # errors if respond_to? isn't correct, so we override it here. + def respond_to?(method, include_all=false) + name = method.to_s.gsub('=', '') + super(self.class.preference_getter_method(name), include_all) || super(method, include_all) + end + + + def has_attachment?(name) + self.class.respond_to?(:attachment_definitions) && + self.class.attachment_definitions.keys.include?(name.to_sym) + end + end +end diff --git a/app/views/admin/contents/edit.html.haml b/app/views/admin/contents/edit.html.haml index ef4467f09d..82751abebc 100644 --- a/app/views/admin/contents/edit.html.haml +++ b/app/views/admin/contents/edit.html.haml @@ -4,10 +4,10 @@ Content -= form_tag main_app.admin_content_path, method: :put do += form_tag main_app.admin_content_path, method: :put, multipart: true do #preferences - = render 'fieldset', name: 'Home page', preferences: @preferences_home - = render 'fieldset', name: 'Footer', preferences: @preferences_footer + - @preference_sections.each do |preference_section| + = render 'fieldset', name: preference_section[:name], preferences: preference_section[:preferences] .form-buttons.filter-actions.actions{"data-hook" => "buttons"} = button t(:update), 'icon-refresh' diff --git a/app/views/groups/signup.html.haml b/app/views/groups/signup.html.haml index cbd44faec1..c1c885d0f0 100644 --- a/app/views/groups/signup.html.haml +++ b/app/views/groups/signup.html.haml @@ -35,63 +35,14 @@ -# / If there is a time-sensitive offer you can write it here, e.g. -# Time-sensitive offer goes here! %br - %table.signup-table.hubs-table{cellpadding: "0", cellspacing: "0"} - %thead - %tr - %td - %h5 - %td.text-center{width: "24%"} - %h5 OFN Group - %tr - %td - %p - %strong Promote your members - %br - %span.text-small Promote your local and/or member businesses through a group page - %td.text-center - %i.ofn-i_003-check.text-big - %tr - %td - %p - %strong Unique URL - %br - %span.text-small Your own organisation page/url on the Open Food Network. - %td.text-center - %i.ofn-i_003-check.text-big - %tr - %td - %p - %strong Region map & listings - %br - %span.text-small Easy search from your own list view and your own map - links through to profile pages for your member/local producers and/or food businesses. - %td.text-center - %i.ofn-i_003-check.text-big - %tr - %td - %p - %strong Opt-in extras - %p.text-small Available additional support: - %ul.small - %li Tailored workshop(s) for your stakeholders - %li Tailored training and support package - %td.text-center - %tfoot - %tr - %td - %td.text-center{valign: "top"} - %h2 - $5,500 + = ContentConfig.group_signup_pricing_table_html.html_safe #shops-case-studies .row .small-12.medium-10.medium-offset-1.columns %h2.text-center Case studies %br - .row - .small-12.medium-6.columns - = render 'shared/case_study', img_src: "/assets/case-studies/South_East_Food_Hub.png", title: "South East Food Group", description: "The South East Food Hub lists all its participating producers and hubs (food clubs) on its group page on the Open Food Network.", link: "https://openfoodnetwork.org.au/groups/6" - .small-12.medium-6.columns - = render 'shared/case_study', img_src: "/assets/case-studies/mt-alexander.png", title: "Mt Alexander Local Produce Network", description: "This community organisation promotes local sustainable food production and consumption through its group page. It lists sources of local sustenance — direct from the grower or through a range local shops and markets.".html_safe, link: "https://openfoodnetwork.org.au/groups/10" + = ContentConfig.group_signup_case_studies_html.html_safe .pane#cta .row @@ -105,26 +56,6 @@ .row .small-12.medium-10.medium-offset-1.columns %h2.text-center Here's the detail. - .row - .small-12.medium-6.columns - %h4 A sub-heading goes here - %p Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer in odio vel ex efficitur auctor. Nam rhoncus, tortor vel varius varius, magna lorem dignissim libero, at dignissim erat leo id tortor. Donec gravida quis augue sed pellentesque. Morbi laoreet efficitur mi, id tempus diam lacinia eu. - %h5 Smaller sub-heading goes here - %p.text-small Vestibulum eu quam neque. Aenean porta velit sit amet metus mattis, ut pulvinar dui semper. Nunc ornare scelerisque varius. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Cras a magna nec augue suscipit fermentum at ac urna. - %ul.text-small - %li A bullet point - %li Another point - %li A third point goes here - %p.text-small Quisque urna lacus, tristique sed rutrum a, volutpat eu diam. Nam placerat mi nec enim tincidunt, nec dapibus risus molestie. Praesent mattis eu dolor nec sollicitudin. Cras ut magna sem. Etiam vitae commodo augue, sit amet feugiat diam. - .small-12.medium-6.columns - %h4 A sub-heading goes here - %p Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer in odio vel ex efficitur auctor. Nam rhoncus, tortor vel varius varius, magna lorem dignissim libero, at dignissim erat leo id tortor. Donec gravida quis augue sed pellentesque. Morbi laoreet efficitur mi, id tempus diam lacinia eu. - %h5 Smaller sub-heading goes here - %p.text-small Vestibulum eu quam neque. Aenean porta velit sit amet metus mattis, ut pulvinar dui semper. Nunc ornare scelerisque varius. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Cras a magna nec augue suscipit fermentum at ac urna. - %ul.text-small - %li A bullet point - %li Another point - %li A third point goes here - %p.text-small Quisque urna lacus, tristique sed rutrum a, volutpat eu diam. Nam placerat mi nec enim tincidunt, nec dapibus risus molestie. Praesent mattis eu dolor nec sollicitudin. Cras ut magna sem. Etiam vitae commodo augue, sit amet feugiat diam. + = ContentConfig.group_signup_detail_html.html_safe = render partial: "shared/footer" diff --git a/app/views/home/_stats.html.haml b/app/views/home/_stats.html.haml index 374a98cdbf..6c686a22b7 100644 --- a/app/views/home/_stats.html.haml +++ b/app/views/home/_stats.html.haml @@ -4,19 +4,20 @@ %h2 We're creating a new food system. .row.content - .small-12.medium-3.columns.text-center - %h4 - %strong= number_with_delimiter @num_producers - food producers - .small-12.medium-3.columns.text-center - %h4 - %strong= number_with_delimiter @num_distributors - food shops - .small-12.medium-3.columns.text-center - %h4 - %strong= number_with_delimiter @num_users - food shoppers - .small-12.medium-3.columns.text-center - %h4 - %strong= number_with_delimiter @num_orders - food orders + - if ContentConfig.home_show_stats + .small-12.medium-3.columns.text-center + %h4 + %strong= number_with_delimiter @num_producers + food producers + .small-12.medium-3.columns.text-center + %h4 + %strong= number_with_delimiter @num_distributors + food shops + .small-12.medium-3.columns.text-center + %h4 + %strong= number_with_delimiter @num_users + food shoppers + .small-12.medium-3.columns.text-center + %h4 + %strong= number_with_delimiter @num_orders + food orders diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index 7388466973..ee4fca7b27 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -1,3 +1,7 @@ +:css + #tagline:before { background-image: url("#{ContentConfig.home_hero.url}") } + + %div{"ng-controller" => "HomeCtrl"} = render partial: "shared/menu/alert" @@ -6,8 +10,7 @@ .small-12.text-center.columns %h1 / TODO: Rohan - logo asset & width is content manageable: - -# TODO: SVGify - %img{src: "/assets/logo-white-notext.png", width: "250", title: "Open Food Network Australia"} + %img{src: "/assets/logo-white-notext.png", width: "250", title: Spree::Config.site_name} %br/ %a.button.transparent{href: "/shops"} Shop Now diff --git a/app/views/producers/signup.html.haml b/app/views/producers/signup.html.haml index 6f2cee2a5b..169d4b179f 100644 --- a/app/views/producers/signup.html.haml +++ b/app/views/producers/signup.html.haml @@ -20,79 +20,14 @@ -# If there is a time-sensitive offer you can write it here, e.g. -# Sign up before 30th June for an extra month free! %br - %table.signup-table.producers-table{cellpadding: "0", cellspacing: "0"} - %thead - %tr - %td - %h5 - %td.text-center{width: "20%"} - %h5 Basic - %td.text-center{width: "24%"} - %h5 Plus - %tr - %td - %p - %strong Profile - %p - %span.text-small Get a profile on the Open Food Network - including a listing on the Producers page and a pin on the OFN Map. These help people to find and connect with you. - %p - %span.text-small Option to add and manage your products on OFN, enabling you to act as a supplier to other OFN shopfronts. - %td.text-center - %i.ofn-i_003-check.text-big - %td.text-center - %i.ofn-i_003-check.text-big - %tr - %td - %p - %strong Shop - %p.text-small Get a shopfront on OFN to sell your produce direct! - %p.text-small Basic support included: - %ul.small - %li User manual - %li Post queries to discussion forum/via contact form - %li Report bugs/suggestions - %li Regular release notes – what's new - %td.text-center - %td.text-center - %i.ofn-i_003-check.text-big - %tfoot - %tr - %td - %td.text-center{valign: "top"} - %h2 Free - %td.text-center{valign: "top"} - %h2 - .text-small - first - %br - month - Free - %p.text-small - Then, 2% of total transactions - %br - %em - Capped at - %strong $50 - per month - %br - %em (Special offer for 2015) + = ContentConfig.producer_signup_pricing_table_html.html_safe #producer-case-studies .row .small-12.medium-10.medium-offset-1.columns %h2.text-center Stories from our producers. %br - .row - .small-12.medium-6.columns - = render 'shared/case_study', img_src: "/assets/case-studies/jonai.png", title: "Jonai Farms", description: "Jonai Farms is an ethical pork and beef “Community Supported Agriculture” farm that delivers to a range of hubs in Melbourne and central Victoria every month.", link: "http://www.jonaifarms.com.au" - .small-12.medium-6.columns - = render 'shared/case_study', img_src: "/assets/case-studies/wandiful.png", title: "Wandiful Produce", description: "Biodynamically grown in NE Victoria, Wandiful Produce supplies hazelnuts, chestnuts and associated products (bliss balls - yum!) shipped to your door.", link: "https://openfoodnetwork.org.au/wandiful-produce/shop" - .row - .small-12.medium-6.columns - = render 'shared/case_study', img_src: "/assets/case-studies/longley.png", title: "Longley Organic Farm", description: "Near Hobart, Longley Organic Farm provides berries and vegetables for local food cooperatives and small shops and through its roadside stall.", link: "https://openfoodnetwork.org.au/longley-organic-farm/shop" - .small-12.medium-6.columns - = render 'shared/case_study', img_src: "/assets/case-studies/jindivick.jpg", title: "Jindivick Hydroponics", description: "Selling through farmers markets and the South East Food Hub, Jindivick Hydroponics grow an ever increasing range of vegetables including tomatoes, cucumbers and beans.", link: "https://openfoodnetwork.org.au/producers#/#jindivick-hydroponics" - + = ContentConfig.producer_signup_case_studies_html.html_safe .pane#cta .row @@ -106,17 +41,6 @@ .row .small-12.medium-10.medium-offset-1.columns %h2.text-center Here's the detail. - = render 'shared/enterprise_type_flowchart', type: 'producers' - %h4 Join a marketplace of independent online food stores - %p Create an online shop front and join the network of online farmers markets on the Open Food Network. Set up a Producer Shop and sell your products direct to customers, or create a Food Hub and sell products from multiple producers. - - %h4 Connect with a new source of customers - %p Gain access to the growing crowd of conscientious buyers on the Open Food Network, all looking to make more ethical and sustainable choices when purchasing food. - %h4 Manage your business online - %p The Open Food Network provides online tools to help with the day-to-day running of your business. Manage your product listing and stock levels. Create, receive and manage orders from your buyers, and organise payments online. Generate invoices for orders and export them to your accounting software, and access a range of reports. - %h4 Start with a simple listing on our directory - %p Create a profile on the Open Food Network and gain exposure to a new marketplace of potential buyers. Tell your story in words and images, provide your contact details, and drive connections to your social and online presence. - %p Access new wholesale opportunities by connecting with food hubs in your region who can sell and distribute your products to buyers on the Open Food Network. - + = ContentConfig.producer_signup_detail_html.html_safe = render partial: "shared/footer" diff --git a/app/views/shared/_enterprise_type_flowchart.html.haml b/app/views/shared/_enterprise_type_flowchart.html.haml deleted file mode 100644 index 7fda2e0891..0000000000 --- a/app/views/shared/_enterprise_type_flowchart.html.haml +++ /dev/null @@ -1,16 +0,0 @@ -.enterprise-type-flowchart - = image_tag "enterprise-type.png" - %br - %br - %br - %br - %br - %p{style: "text-align: center;"} - %a{href: "http://www.openfoodnetwork.org/platform/features/"} More Features - \| - %a{href: "http://www.openfoodnetwork.org/platform/user-guide/"} User Guide - \| - - if type == 'hubs' - %a{href: "http://www.openfoodnetwork.org/platform/user-guide/faqs/hub-faqs/"} Hub FAQs - - elsif type == 'producers' - %a{href: "http://www.openfoodnetwork.org/platform/user-guide/faqs/producer-faqs/"} Producer FAQs diff --git a/app/views/shared/_footer.html.haml b/app/views/shared/_footer.html.haml index de9d9e341a..7450966e5f 100644 --- a/app/views/shared/_footer.html.haml +++ b/app/views/shared/_footer.html.haml @@ -116,11 +116,11 @@ .row .small-12.medium-3.medium-offset-2.columns.text-left %a{href: root_path} - %img{src: "/assets/logo-color.png", srcset: "/assets/logo-color.svg", width: "220px"} + %img{src: ContentConfig.footer_logo.url, width: "220"} .small-12.medium-5.columns.text-left %p.text-small Read our - %a{href: "/Terms-of-service.pdf"} Terms & conditions + %a{href: ContentConfig.footer_tos_url} Terms & conditions | Find us on %a{href:"https://github.com/openfoodfoundation/openfoodnetwork", target: "_blank"} Github diff --git a/app/views/shared/menu/_large_menu.html.haml b/app/views/shared/menu/_large_menu.html.haml index 97a815a27a..4f71e1c93e 100644 --- a/app/views/shared/menu/_large_menu.html.haml +++ b/app/views/shared/menu/_large_menu.html.haml @@ -3,8 +3,7 @@ %ul.left %li.ofn-logo %a{href: root_path} - -# TODO: SVGify (though this image is double-size for retina) - %img{src: "/assets/logo-australia.png", width: "250", height: "51"} + %img{src: ContentConfig.logo.url, width: "250", height: "51"} %ul.center %li %a{href: main_app.shops_path} diff --git a/app/views/shared/menu/_mobile_menu.html.haml b/app/views/shared/menu/_mobile_menu.html.haml index 869785fce5..d43c95ca46 100644 --- a/app/views/shared/menu/_mobile_menu.html.haml +++ b/app/views/shared/menu/_mobile_menu.html.haml @@ -6,7 +6,7 @@ %section.left .ofn-logo %a{href: root_path} - %img{src: "/assets/logo-black.png", srcset: "/assets/logo-black.svg", width: "75", height: "26"} + %img{src: ContentConfig.logo_mobile.url, srcset: ContentConfig.logo_mobile_svg.url, width: "75", height: "26"} %section.right{"ng-cloak" => true} .cart @@ -18,7 +18,7 @@ %ul.off-canvas-list %li.ofn-logo %a{href: root_path} - %img{src: "/assets/logo-black.png", srcset: "/assets/logo-black.svg", width: "75", height: "26"} + %img{src: ContentConfig.logo_mobile.url, srcset: ContentConfig.logo_mobile_svg.url, width: "75", height: "26"} %li.li-menu - if current_page? main_app.shops_path %a{"ofn-scroll-to" => "hubs"} diff --git a/app/views/shops/signup.html.haml b/app/views/shops/signup.html.haml index 72c319413f..a04f7d82e2 100644 --- a/app/views/shops/signup.html.haml +++ b/app/views/shops/signup.html.haml @@ -20,78 +20,14 @@ -# If there is a time-sensitive offer you can write it here, e.g. -# Sign up before 30th June for an extra month free! %br - %table.signup-table.hubs-table{cellpadding: "0", cellspacing: "0"} - %thead - %tr - %td - %h5 - %td.text-center{width: "20%"} - %h5 Basic - %td.text-center{width: "24%"} - %h5 Plus - %tr - %td - %p - %strong Profile - %p - %span.text-small Get a profile on the Open Food Network - including a listing on the Shops page and a pin on the OFN Map. These help people to find and connect with you. - %td.text-center - %i.ofn-i_003-check.text-big - %td.text-center - %i.ofn-i_003-check.text-big - %tr - %td - %p - %strong Shop - %p.text-small Get a shopfront on OFN to sell food from multiple suppliers & producers. - %p.text-small Basic support included: - %ul.small - %li User manual - %li Post queries to discussion forum/via contact form - %li Report bugs/suggestions - %li Regular release notes – what's new - %td.text-center - %td.text-center - %i.ofn-i_003-check.text-big - %tfoot - %tr - %td - %td.text-center{valign: "top"} - %h2 - Free - %td.text-center{valign: "top"} - %h2 - .text-small - First - %br - month - Free - %p.text-small - Then, 2% of transactions - %br - %em - Capped at - %strong $50 - per month - %br - %em (Special offer for 2015) + = ContentConfig.hub_signup_pricing_table_html.html_safe #shops-case-studies .row .small-12.medium-10.medium-offset-1.columns %h2.text-center Stories from our hubs. %br - .row - .small-12.medium-6.columns - = render 'shared/case_study', img_src: "/assets/case-studies/bfc_logo_square.png", title: "Bondi Food Collective", description: "Bondi Food Collective is a member-based not for profit that provide weekly fruit & veg picked fresh to order, plus dry foods - all organic and all Australian-grown.", link: "http://www.bondifoodcollective.org" - .small-12.medium-6.columns - = render 'shared/case_study', img_src: "/assets/case-studies/bonnie-beef-growers.png", title: "Bonnie Beef Growers", description: "Bonnie Beef Growers work on monthly order cycles for their wide range of beef products and also act as a hub for products from neighboring farms on the Sunshine Coast.", link: "http://www.bonniebeef.com.au" - .row - .small-12.medium-6.columns - = render 'shared/case_study', img_src: "/assets/case-studies/South_East_Food_Hub.png", title: "South East Food Hub", description: "South East Food Hub is a choose-your-own food box service supported by a collective of farmers in Melbourne’s south-east. It distributes food through buying groups or “food clubs”.", link: "http://www.southeastfoodhub.org" - .small-12.medium-6.columns - = render 'shared/case_study', img_src: "/assets/case-studies/baw-baw.png", title: "Baw Baw Organics", description: "A weekly seasonal vegetable box program, Baw Baw Organics services around 100 households with local produce in West Gippsland.", link: "https://bawbawfoodhub.org.au" - + = ContentConfig.hub_signup_case_studies_html.html_safe .pane#cta .row @@ -106,15 +42,7 @@ .row .small-12.medium-10.medium-offset-1.columns %h2.text-center Here's the detail. - = render 'shared/enterprise_type_flowchart', type: 'hubs' - - %h4 Join a marketplace of independent online food stores - %p Create a hub profile on the Open Food Network and gain exposure to a new marketplace of potential buyers. Tell your story in words and images, provide your contact details, and drive connections to your social and online presence. Set up a “Hub” shop and sell products from multiple producers. - %h4 Connect with a new source of customers and suppliers - %p Gain access to the growing crowd of conscientious buyers on the Open Food Network, all looking to make more ethical and sustainable choices when purchasing food. - %p Access new supply opportunities by connecting with producers in your region, sell their products in your shop. - %h4 Manage your business online - %p The Open Food Network provides online tools to help with the day-to-day running of your business. Manage your product listing and stock levels. Create, receive and manage orders from your buyers, and organise payments online. Generate invoices for orders and export them to your accounting software, and access a range of reports. + = ContentConfig.hub_signup_detail_html.html_safe = render partial: "shared/footer" diff --git a/config/locales/en.yml b/config/locales/en.yml index 05ad5113ee..3149620eab 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -20,8 +20,12 @@ en: producers_join: Australian producers are now welcome to join the Open Food Network. charges_sales_tax: Charges GST? - home_tagline_cta: "Tagline call to action" - home_whats_happening: "What's happening" + logo: "Logo (640x130)" + logo_mobile: "Mobile logo (75x26)" + logo_mobile_svg: "Mobile logo (SVG)" + home_hero: "Hero image" + home_show_stats: "Show statistics" + footer_logo: "Logo (220x76)" footer_facebook_url: "Facebook URL" footer_twitter_url: "Twitter URL" footer_instagram_url: "Instagram URL" @@ -30,4 +34,5 @@ en: footer_pinterest_url: "Pinterest URL" footer_email: "Email" footer_links_md: "Links" - footer_about_url: "About URL" \ No newline at end of file + footer_about_url: "About URL" + footer_tos_url: "Terms of Service URL" \ No newline at end of file diff --git a/lib/open_food_network/paperclippable.rb b/lib/open_food_network/paperclippable.rb new file mode 100644 index 0000000000..78b4d1a100 --- /dev/null +++ b/lib/open_food_network/paperclippable.rb @@ -0,0 +1,45 @@ +# Allow use of Paperclip's has_attached_file on non-ActiveRecord classes +# https://gist.github.com/basgys/5712426 + +module OpenFoodNetwork + module Paperclippable + def self.included(base) + base.send :extend, ActiveModel::Naming + base.send :extend, ActiveModel::Callbacks + base.send :include, ActiveModel::Validations + base.send :include, Paperclip::Glue + + # Paperclip required callbacks + base.send :define_model_callbacks, :save, only: [:after] + base.send :define_model_callbacks, :commit, only: [:after] + base.send :define_model_callbacks, :destroy, only: [:before, :after] + + # Initialise an ID + base.send :attr_accessor, :id + base.instance_variable_set :@id, 1 + end + + # ActiveModel requirements + def to_model + self + end + + def valid?() true end + def new_record?() true end + def destroyed?() true end + + def save + run_callbacks :save do + end + true + end + + def errors + obj = Object.new + def obj.[](key) [] end + def obj.full_messages() [] end + def obj.any?() false end + obj + end + end +end diff --git a/spec/features/admin/content_spec.rb b/spec/features/admin/content_spec.rb index 00a162f0b4..073ae35e3c 100644 --- a/spec/features/admin/content_spec.rb +++ b/spec/features/admin/content_spec.rb @@ -7,11 +7,13 @@ feature %q{ include AuthenticationWorkflow include WebHelper - scenario "filling in a setting shows the result on the home page" do + before do login_to_admin_section click_link 'Configuration' click_link 'Content' + end + scenario "filling in a setting shows the result on the home page" do fill_in 'footer_facebook_url', with: '' fill_in 'footer_twitter_url', with: 'http://twitter.com/me' fill_in 'footer_links_md', with: '[markdown link](/)' @@ -27,4 +29,12 @@ feature %q{ # And markdown is rendered page.should have_link 'markdown link' end + + scenario "uploading logos" do + attach_file 'logo', "#{Rails.root}/app/assets/images/logo-white.png" + click_button 'Update' + page.should have_content 'Your content has been successfully updated!' + + ContentConfig.logo.to_s.should include "logo-white" + end end diff --git a/spec/models/spree/preferences/file_configuration_spec.rb b/spec/models/spree/preferences/file_configuration_spec.rb new file mode 100644 index 0000000000..eb18b23e12 --- /dev/null +++ b/spec/models/spree/preferences/file_configuration_spec.rb @@ -0,0 +1,57 @@ +require 'spec_helper' + +module Spree + module Preferences + class TestConfiguration < FileConfiguration + preference :name, :string + + include OpenFoodNetwork::Paperclippable + preference :logo, :file + has_attached_file :logo + end + + describe FileConfiguration do + let(:c) { TestConfiguration.new } + + describe "getting preferences" do + it "returns regular preferences" do + c.name = 'foo' + c.get_preference(:name).should == 'foo' + end + + it "returns file preferences" do + c.get_preference(:logo).should be_a Paperclip::Attachment + end + + it "returns regular preferences via []" do + c.name = 'foo' + c[:name].should == 'foo' + end + + it "returns file preferences via []" do + c[:logo].should be_a Paperclip::Attachment + end + end + + describe "getting preference types" do + it "returns regular preference types" do + c.preference_type(:name).should == :string + end + + it "returns file preference types" do + c.preference_type(:logo).should == :file + end + end + + describe "respond_to?" do + it "responds to preference getters" do + c.respond_to?(:name).should be_true + end + + it "responds to preference setters" do + c.respond_to?(:name=).should be_true + end + end + end + end +end