spree_frontend 4.2.0.rc5 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/spree/frontend.js +10 -0
  3. data/app/assets/javascripts/spree/frontend/account.js +1 -1
  4. data/app/assets/javascripts/spree/frontend/cart.js +1 -1
  5. data/app/assets/javascripts/spree/frontend/checkout/address.js +1 -1
  6. data/app/assets/javascripts/spree/frontend/coupon_manager.js +2 -2
  7. data/app/assets/javascripts/spree/frontend/currency.js +11 -0
  8. data/app/assets/javascripts/spree/frontend/locale.js +11 -0
  9. data/app/assets/stylesheets/spree/frontend/application.scss +0 -3
  10. data/app/assets/stylesheets/spree/frontend/variables/bootstrap-overrides.scss +1 -0
  11. data/app/assets/stylesheets/spree/frontend/variables/helper-variables.scss +1 -0
  12. data/app/assets/stylesheets/spree/frontend/variables/variables.scss +54 -0
  13. data/app/controllers/concerns/spree/locale_urls.rb +23 -0
  14. data/app/controllers/spree/checkout_controller.rb +8 -8
  15. data/app/controllers/spree/currency_controller.rb +6 -10
  16. data/app/controllers/spree/locale_controller.rb +23 -6
  17. data/app/controllers/spree/orders_controller.rb +2 -2
  18. data/app/controllers/spree/store_controller.rb +8 -2
  19. data/app/helpers/spree/addresses_helper.rb +9 -2
  20. data/app/helpers/spree/frontend_helper.rb +6 -20
  21. data/app/helpers/spree/navigation_helper.rb +6 -1
  22. data/app/helpers/spree/store_helper.rb +39 -0
  23. data/app/helpers/spree/taxons_helper.rb +1 -1
  24. data/app/views/spree/checkout/_address.html.erb +2 -4
  25. data/app/views/spree/locale/index.html.erb +1 -0
  26. data/app/views/spree/orders/_line_item.html.erb +1 -1
  27. data/app/views/spree/products/_color_option_type.html.erb +1 -1
  28. data/app/views/spree/shared/_currency_dropdown.html.erb +13 -0
  29. data/app/views/spree/shared/_footer.html.erb +1 -1
  30. data/app/views/spree/shared/_head.html.erb +4 -0
  31. data/app/views/spree/shared/_internationalization_options.html.erb +31 -0
  32. data/app/views/spree/shared/_line_item.html.erb +2 -2
  33. data/app/views/spree/shared/_link_to_account.html.erb +5 -5
  34. data/app/views/spree/shared/_locale_dropdown.html.erb +13 -0
  35. data/app/views/spree/shared/_login.html.erb +1 -1
  36. data/app/views/spree/shared/_mobile_internationalization_options.html.erb +37 -0
  37. data/app/views/spree/shared/_mobile_navigation.html.erb +2 -5
  38. data/app/views/spree/shared/_nav_bar.html.erb +1 -1
  39. data/app/views/spree/shared/_order_details.html.erb +2 -2
  40. data/app/views/spree/users/show.html.erb +1 -1
  41. data/config/routes.rb +26 -29
  42. data/lib/generators/spree/frontend/copy_storefront/copy_storefront_generator.rb +1 -7
  43. data/lib/generators/spree/frontend/install/install_generator.rb +34 -0
  44. data/lib/generators/spree/frontend/install/templates/config/initializers/spree_storefront.rb +1 -0
  45. data/lib/generators/spree/frontend/install/templates/config/spree_storefront.yml +99 -0
  46. metadata +22 -12
  47. data/app/views/spree/shared/_change_store.html.erb +0 -25
  48. data/app/views/spree/shared/_mobile_change_store.html.erb +0 -30
@@ -3,7 +3,7 @@ require 'digest'
3
3
  module Spree
4
4
  module NavigationHelper
5
5
  def spree_navigation_data
6
- @spree_navigation_data ||= SpreeStorefrontConfig.dig(current_store.code, :navigation) || SpreeStorefrontConfig.dig(:default, :navigation) || []
6
+ @spree_navigation_data ||= SpreeStorefrontConfig.dig(I18n.locale, :navigation) || SpreeStorefrontConfig.dig(current_store.code, :navigation) || SpreeStorefrontConfig.dig(:default, :navigation) || []
7
7
  # safeguard for older Spree installs that don't have spree_navigation initializer
8
8
  # or spree.yml file present
9
9
  rescue
@@ -28,6 +28,11 @@ module Spree
28
28
  )
29
29
  end
30
30
 
31
+ def should_render_internationalization_dropdown?
32
+ (defined?(should_render_locale_dropdown?) && should_render_locale_dropdown?) ||
33
+ (defined?(should_render_currency_dropdown?) && should_render_currency_dropdown?)
34
+ end
35
+
31
36
  private
32
37
 
33
38
  def spree_navigation_data_cache_key
@@ -0,0 +1,39 @@
1
+ module Spree
2
+ module StoreHelper
3
+ def store_country_iso(store = nil)
4
+ store ||= current_store if defined?(current_store)
5
+
6
+ store&.default_country&.iso&.downcase
7
+ end
8
+
9
+ def stores
10
+ @stores ||= Spree::Store.includes(:default_country).order(:id)
11
+ end
12
+
13
+ def store_currency_symbol(store = nil)
14
+ store ||= current_store if defined?(current_store)
15
+ return unless store&.default_currency
16
+
17
+ ::Money::Currency.find(store.default_currency).symbol
18
+ end
19
+
20
+ def store_locale_name(store = nil)
21
+ store ||= current_store if defined?(current_store)
22
+ return unless store
23
+ return store.name if store.default_locale.blank?
24
+
25
+ Spree.t('i18n.this_file_language', locale: store.default_locale)
26
+ end
27
+
28
+ def should_render_store_chooser?
29
+ Spree::Config.show_store_selector && stores.size > 1
30
+ end
31
+
32
+ def store_link(store = nil, html_opts = {})
33
+ store ||= current_store if defined?(current_store)
34
+ return unless store
35
+
36
+ link_to "#{store_locale_name(store)} (#{store_currency_symbol(store)})", store.formatted_url, **html_opts
37
+ end
38
+ end
39
+ end
@@ -5,7 +5,7 @@ module Spree
5
5
  # to show the most popular products for a particular taxon (that is an exercise left to the developer.)
6
6
  def taxon_preview(taxon, max = 4)
7
7
  ActiveSupport::Deprecation.warn(<<-DEPRECATION, caller)
8
- TaxonsHelper is deprecated and will be removed in Spree 4.2.
8
+ TaxonsHelper is deprecated and will be removed in Spree 5.0.
9
9
  Please remove any `helper 'spree/taxons'` from your controllers.
10
10
  DEPRECATION
11
11
  products = taxon.active_products.distinct.select('spree_products.*, spree_products_taxons.position').limit(max)
@@ -1,5 +1,3 @@
1
- <% @addresses = try_spree_current_user ? user_available_addresses : [] %>
2
-
3
1
  <% if !try_spree_current_user || try_spree_current_user.email.blank? %>
4
2
  <div class="row">
5
3
  <div class="col-12 mb-4">
@@ -28,10 +26,10 @@
28
26
  <%= label_tag :order_use_billing, Spree.t(:use_billing_address), class: 'spree-checkbox-label' %>
29
27
  </div>
30
28
  <% end %>
31
- <% if @addresses.present? %>
29
+ <% if user_available_addresses.present? %>
32
30
  <div class="select_address mb-5">
33
31
  <div class="form-group col">
34
- <% @addresses.each_with_index do |address, idx| %>
32
+ <% user_available_addresses.each_with_index do |address, idx| %>
35
33
  <div class="row mb-3" id="<%= [address_type, dom_id(address)].join('_') %>">
36
34
  <label class="form-check-label spree-radio-label col-8">
37
35
  <%= form.radio_button "#{address_name}_id", address.id, checked: (address.id == try_spree_current_user["#{address_name}_id"] || idx == 0) %>
@@ -0,0 +1 @@
1
+ <%= render 'spree/shared/locale_dropdown' %>
@@ -3,7 +3,7 @@
3
3
  <%= order_form.fields_for :line_items, line_item do |item_form| %>
4
4
  <div class="d-table-row shopping-cart-item">
5
5
  <div class="d-table-cell shopping-cart-item-image" data-hook="cart_item_image">
6
- <%= link_to product_image(variant), variant.product %>
6
+ <%= link_to product_image(variant), spree.product_path(variant.product) %>
7
7
  </div>
8
8
  <div class="d-table-cell shopping-cart-item-description" data-hook="cart_item_description">
9
9
  <h2 class="item-title"><%= link_to line_item.name, spree.product_path(variant.product) %></h2>
@@ -9,7 +9,7 @@
9
9
  <li>
10
10
  <%= label_tag "variant_option_value_id_#{option_type[:id]}_#{option_value[:id]}",
11
11
  class: "m-1 m-sm-2 m-md-1 color-select-label",
12
- title: option_value[:name],
12
+ title: option_value[:name]&.humanize,
13
13
  data: { toggle: "tooltip", placement: "bottom" } do %>
14
14
 
15
15
  <%= radio_button_tag "variant_option_value_id_#{option_type[:id]}",
@@ -0,0 +1,13 @@
1
+ <% if defined?(should_render_currency_dropdown?) && should_render_currency_dropdown? %>
2
+ <%= form_tag spree.set_currency_path, method: :get, class: 'px-4 py-3 w-100', id: 'currency-select' do %>
3
+ <div class="form-group">
4
+ <label for="switch_to_currency" class="dropdown-header text-center">
5
+ <%= Spree.t(:choose_currency) %>
6
+ </label>
7
+ <%= select_tag(:switch_to_currency,
8
+ options_for_select(supported_currency_options, current_currency),
9
+ class: 'custom-select w-100') %>
10
+ <noscript><%= submit_tag %></noscript>
11
+ </div>
12
+ <% end %>
13
+ <% end %>
@@ -68,7 +68,7 @@
68
68
  <%= Spree.t('nav_bar.my_account') %>
69
69
  </div>
70
70
  <div class="pt-2">
71
- <%= link_to Spree.t('nav_bar.my_orders'), spree.account_path(anchor: "account-my-orders") %>
71
+ <%= link_to Spree.t(:my_orders).upcase, spree.account_path(anchor: "account-my-orders") %>
72
72
  </div>
73
73
  </div>
74
74
  <% end %>
@@ -8,5 +8,9 @@
8
8
  <%= stylesheet_link_tag 'spree/frontend/all', media: 'screen', 'data-turbolinks-track': 'reload' %>
9
9
  <%= csrf_meta_tags %>
10
10
  <%= render 'spree/shared/paths' %>
11
+ <script>
12
+ var SPREE_LOCALE = '<%= I18n.locale %>'
13
+ var SPREE_CURRENCY = '<%= current_currency %>'
14
+ </script>
11
15
  <%= javascript_include_tag 'spree/frontend/all', defer: true, 'data-turbolinks-track': 'reload' %>
12
16
  <%= yield :head %>
@@ -0,0 +1,31 @@
1
+ <% if (defined?(should_render_store_chooser?) && should_render_store_chooser?) || (defined?(should_render_internationalization_dropdown?) && should_render_internationalization_dropdown?) %>
2
+ <li class="d-none d-xl-block internationalization-options">
3
+ <div class="dropdown navbar-right-dropdown">
4
+ <button id="internationalization-button-desktop" type="button" data-toggle="dropdown" class="navbar-right-dropdown-toggle" aria-label="<%= Spree.t(:internationalization) %>">
5
+ <%= icon(name: 'global',
6
+ classes: 'd-none d-xl-inline-block',
7
+ width: 41,
8
+ height: 36) %>
9
+ <%= icon(name: 'arrow-down',
10
+ classes: 'd-inline-block d-xl-none',
11
+ width: 15,
12
+ height: 15) %>
13
+ </button>
14
+
15
+ <div id="internationalization-options-desktop" class="dropdown-menu dropdown-menu-right text-left">
16
+ <% if (defined?(should_render_store_chooser?) && should_render_store_chooser?) %>
17
+ <% stores.each do |store| %>
18
+ <div class="pl-3 d-flex justify-content-between align-items-center stores-list">
19
+ <%= country_flag_icon(store_country_iso(store)) %>
20
+ <%= store_link(store, class: "dropdown-item text-uppercase #{'font-weight-bold' if current_store == store}") %>
21
+ </div>
22
+ <% end %>
23
+ <% else %>
24
+ <%= render 'spree/shared/locale_dropdown' %>
25
+ <div class="dropdown-divider"></div>
26
+ <%= render 'spree/shared/currency_dropdown' %>
27
+ <% end %>
28
+ </div>
29
+ </div>
30
+ </li>
31
+ <% end %>
@@ -1,9 +1,9 @@
1
1
  <div class="checkout-confirm-order-details-line-items-line-item w-100 d-table-row">
2
2
  <div class="checkout-confirm-order-details-line-items-line-item-name d-table-cell align-middle py-3 py-sm-4">
3
3
  <div class="d-flex align-items-lg-center">
4
- <%= link_to product_image(line_item.variant), line_item.product %>
4
+ <%= link_to product_image(line_item.variant), spree.product_path(line_item.product) %>
5
5
  <div class="d-flex flex-column mt-2 mt-lg-0">
6
- <div><%= link_to line_item.name, line_item.product %></div>
6
+ <div><%= link_to line_item.name, spree.product_path(line_item.product) %></div>
7
7
  <ul class="checkout-confirm-order-details-line-items-line-item-name-options text-uppercase list-unstyled mb-0">
8
8
  <% line_item.variant.option_values.sort { |ov| ov.option_type.position }.each do |ov| %>
9
9
  <li>
@@ -1,8 +1,8 @@
1
1
  <% if try_spree_current_user %>
2
- <%= link_to Spree.t('nav_bar.my_account'), spree.account_path, class: 'dropdown-item' if spree.respond_to?(:account_path) %>
3
- <%= link_to Spree.t('nav_bar.admin_panel'), spree.admin_orders_path, class: 'dropdown-item text-uppercase' if try_spree_current_user.has_spree_role?(:admin) %>
4
- <%= link_to Spree.t('nav_bar.log_out'), spree_logout_path, class: 'dropdown-item', method: :get if defined?(spree_logout_path) %>
2
+ <%= link_to Spree.t(:my_account).upcase, spree.account_path, class: 'dropdown-item' if spree.respond_to?(:account_path) %>
3
+ <%= link_to Spree.t('nav_bar.admin_panel'), spree.admin_orders_path(locale: nil), class: 'dropdown-item text-uppercase' if try_spree_current_user.has_spree_role?(:admin) %>
4
+ <%= link_to Spree.t(:logout).upcase, spree_logout_path, class: 'dropdown-item', method: :get if defined?(spree_logout_path) %>
5
5
  <% else %>
6
- <%= link_to Spree.t('nav_bar.log_in'), spree_login_path, class: 'dropdown-item' if defined?(spree_login_path) %>
7
- <%= link_to Spree.t('nav_bar.sign_up'), spree_signup_path, class: 'dropdown-item' if defined?(spree_signup_path) %>
6
+ <%= link_to Spree.t(:login).upcase, spree_login_path, class: 'dropdown-item' if defined?(spree_login_path) %>
7
+ <%= link_to Spree.t(:sign_up).upcase, spree_signup_path, class: 'dropdown-item' if defined?(spree_signup_path) %>
8
8
  <% end %>
@@ -0,0 +1,13 @@
1
+ <% if should_render_locale_dropdown? %>
2
+ <%= form_tag spree.set_locale_path, method: :get, class: 'px-4 py-3 w-100', id: 'locale-select' do %>
3
+ <div class="form-group">
4
+ <label for="switch_to_locale" class="dropdown-header text-center">
5
+ <%= Spree.t('i18n.language') %>
6
+ </label>
7
+ <%= select_tag(:switch_to_locale,
8
+ options_for_select(supported_locales_options, I18n.locale),
9
+ class: 'custom-select w-100') %>
10
+ <noscript><%= submit_tag %></noscript>
11
+ </div>
12
+ <% end %>
13
+ <% end %>
@@ -25,7 +25,7 @@
25
25
  </div>
26
26
  <% end %>
27
27
 
28
- <%= f.submit Spree.t(:log_in), class: 'btn btn-primary btn-block spree-btn mt-2' %>
28
+ <%= f.submit Spree.t(:login), class: 'btn btn-primary btn-block spree-btn mt-2' %>
29
29
  <% end %>
30
30
 
31
31
  <% if spree.respond_to?(:recover_password_path) %>
@@ -0,0 +1,37 @@
1
+ <% if (defined?(should_render_store_chooser?) && should_render_store_chooser?) || (defined?(should_render_internationalization_dropdown?) && should_render_internationalization_dropdown?) %>
2
+ <% link_title = "#{Spree.t(:choose_currency)} / #{Spree.t('i18n.language')}" %>
3
+
4
+ <li class="d-flex justify-content-between align-items-center mobile-navigation-list-item">
5
+ <span class="w-75"><%= link_title %></span>
6
+ <a class="w-25 text-right mobile-navigation-category-link" data-category="internationalization" href="#" aria-label="<%= link_title %>">
7
+ <%= icon(name: 'arrow-right',
8
+ classes: 'd-sm-none spree-icon-arrow spree-icon-arrow-right',
9
+ width: 16,
10
+ height: 16) %>
11
+ <%= icon(name: 'arrow-right',
12
+ classes: 'd-none d-sm-inline spree-icon-arrow spree-icon-arrow-right',
13
+ width: 14,
14
+ height: 27) %>
15
+ </a>
16
+
17
+ <ul class="list-unstyled position-absolute mobile-navigation-sublist" data-category="internationalization">
18
+ <li class="text-center font-weight-bold mobile-navigation-sublist-header">
19
+ <%= Spree.t(:internationalization) %>
20
+ </li>
21
+ <% if (defined?(should_render_store_chooser?) && should_render_store_chooser?) %>
22
+ <% stores.each do |store| %>
23
+ <li class="d-flex justify-content-between align-items-center mobile-navigation-list-item">
24
+ <%= country_flag_icon(store_country_iso(store)) %>
25
+ <%= store_link(store, class: "dropdown-item text-uppercase d-flex #{'font-weight-bold' if current_store == store}") %>
26
+ </li>
27
+ <% end %>
28
+ <% else %>
29
+ <div class="mt-4 pt-4">
30
+ <%= render 'spree/shared/locale_dropdown' %>
31
+ <div class="dropdown-divider mt-4 pb-4"></div>
32
+ <%= render 'spree/shared/currency_dropdown' %>
33
+ </div>
34
+ <% end %>
35
+ </ul>
36
+ </li>
37
+ <% end %>
@@ -7,11 +7,8 @@
7
7
  width: 26,
8
8
  height: 26) %>
9
9
  </button>
10
- <figure class="logo header-spree-fluid-logo" data-hook>
11
- <%= logo %>
12
- </figure>
13
10
  <div id="top-nav-bar-mobile" class="m-0 p-0 header-spree-fluid-secondary-navigation" data-hook>
14
- <button id="mobile-navigation-close-button" aria-label="<%= Spree.t('nav_bar.close_menu') %>">
11
+ <button id="mobile-navigation-close-button" aria-label="<%= Spree.t(:close) %>">
15
12
  <%= icon(name: 'close',
16
13
  classes: 'd-inline',
17
14
  width: 26,
@@ -44,7 +41,7 @@
44
41
  <% end %>
45
42
  </li>
46
43
  <% end %>
47
- <%= render partial: 'spree/shared/mobile_change_store' %>
44
+ <%= render partial: 'spree/shared/mobile_internationalization_options' %>
48
45
  </ul>
49
46
  </div>
50
47
  <% end %>
@@ -31,5 +31,5 @@
31
31
  <li id="link-to-cart">
32
32
  <%= render 'spree/shared/cart', class: 'd-inline-block cart-icon', size: 36, item_count: 0 %>
33
33
  </li>
34
- <%= render partial: 'spree/shared/change_store' %>
34
+ <%= render partial: 'spree/shared/internationalization_options' %>
35
35
  </ul>
@@ -75,11 +75,11 @@
75
75
  <div class="checkout-confirm-order-details-line-items-line-item-name d-table-cell align-middle py-3 py-sm-4">
76
76
  <div class="d-flex align-items-lg-center">
77
77
  <div class="checkout-confirm-order-details-line-items-line-item-name-image" data-hook="order_item_image">
78
- <%= link_to product_image(item.variant), item.product %>
78
+ <%= link_to product_image(item.variant), spree.product_path(item.product) %>
79
79
  </div>
80
80
  <div class="d-flex flex-column mt-2 mt-lg-0" data-hook="order_item_description">
81
81
  <div data-hook="order_item_name">
82
- <%= link_to item.name, item.product, class: 'checkout-confirm-order-details-line-items-line-item-name-link' %>
82
+ <%= link_to item.name, spree.product_path(item.product), class: 'checkout-confirm-order-details-line-items-line-item-name-link' %>
83
83
  </div>
84
84
  <% unless item.variant.is_master? %>
85
85
  <ul class="checkout-confirm-order-details-line-items-line-item-name-options text-uppercase list-unstyled mb-0">
@@ -57,7 +57,7 @@
57
57
  <tbody>
58
58
  <% @orders.each do |order| %>
59
59
  <tr>
60
- <td class="account-page-order-number"><%= link_to order.number, order_url(order), class: "text-primary" %></td>
60
+ <td class="account-page-order-number"><%= link_to order.number, spree.order_path(order), class: "text-primary" %></td>
61
61
  <td class="account-page-order-date"><%= l order.completed_at.to_date %></td>
62
62
  <td class="account-page-order-status"><%= Spree.t("order_state.#{order.state}").titleize %></td>
63
63
  <td class="account-page-order-payment-state"><%= Spree.t("payment_states.#{order.payment_state}").titleize if order.payment_state %></td>
data/config/routes.rb CHANGED
@@ -1,39 +1,36 @@
1
1
  Spree::Core::Engine.add_routes do
2
- root to: 'home#index'
2
+ scope '(:locale)', locale: /#{Spree.available_locales.join('|')}/, defaults: { locale: nil } do
3
+ root to: 'home#index'
3
4
 
4
- resources :products, only: [:index, :show]
5
+ resources :products, only: [:index, :show]
6
+ get '/products/:id/related', to: 'products#related'
7
+ # route globbing for pretty nested taxon and product paths
8
+ get '/t/*id', to: 'taxons#show', as: :nested_taxons
9
+ get '/product_carousel/:id', to: 'taxons#product_carousel'
5
10
 
6
- get '/locale/set', to: 'locale#set'
11
+ # non-restful checkout stuff
12
+ patch '/checkout/update/:state', to: 'checkout#update', as: :update_checkout
13
+ get '/checkout/:state', to: 'checkout#edit', as: :checkout_state
14
+ get '/checkout', to: 'checkout#edit', as: :checkout
7
15
 
8
- # non-restful checkout stuff
9
- patch '/checkout/update/:state', to: 'checkout#update', as: :update_checkout
10
- get '/checkout/:state', to: 'checkout#edit', as: :checkout_state
11
- get '/checkout', to: 'checkout#edit', as: :checkout
16
+ resources :orders, except: [:index, :new, :create, :destroy]
12
17
 
13
- get '/orders/populate', to: 'orders#populate_redirect'
18
+ resources :addresses, except: [:show]
14
19
 
15
- resources :orders, except: [:index, :new, :create, :destroy] do
16
- post :populate, on: :collection
17
- end
18
-
19
- resources :addresses, except: [:show]
20
-
21
- get '/cart', to: 'orders#edit', as: :cart
22
- patch '/cart', to: 'orders#update', as: :update_cart
23
- put '/cart/empty', to: 'orders#empty', as: :empty_cart
20
+ get '/cart', to: 'orders#edit', as: :cart
21
+ patch '/cart', to: 'orders#update', as: :update_cart
22
+ put '/cart/empty', to: 'orders#empty', as: :empty_cart
24
23
 
25
- # route globbing for pretty nested taxon and product paths
26
- get '/t/*id', to: 'taxons#show', as: :nested_taxons
27
- get '/product_carousel/:id', to: 'taxons#product_carousel'
24
+ get '/content/cvv', to: 'content#cvv', as: :cvv
25
+ get '/content/test', to: 'content#test'
26
+ get '/cart_link', to: 'store#cart_link', as: :cart_link
27
+ get '/account_link', to: 'store#account_link', as: :account_link
28
28
 
29
- get '/content/cvv', to: 'content#cvv', as: :cvv
30
- get '/content/test', to: 'content#test'
31
- get '/cart_link', to: 'store#cart_link', as: :cart_link
32
- get '/account_link', to: 'store#account_link', as: :account_link
29
+ get '/locales', to: 'locale#index', as: :locales
30
+ get '/locale/set', to: 'locale#set', as: :set_locale
31
+ get '/currency/set', to: 'currency#set', as: :set_currency
33
32
 
34
- get '/api_tokens', to: 'store#api_tokens'
35
- post '/ensure_cart', to: 'store#ensure_cart'
36
- get '/products/:id/related', to: 'products#related'
37
-
38
- get '/currency/set', to: 'currency#set', defaults: { format: :json }, as: :set_currency
33
+ get '/api_tokens', to: 'store#api_tokens'
34
+ post '/ensure_cart', to: 'store#ensure_cart'
35
+ end
39
36
  end
@@ -1,24 +1,18 @@
1
1
  module Spree
2
2
  module Frontend
3
3
  class CopyStorefrontGenerator < Rails::Generators::Base
4
- desc 'Copies storefront from spree frontend to your application'
4
+ desc 'Copies all storefront views and stylesheets from spree frontend to your application'
5
5
 
6
6
  def self.source_paths
7
7
  [
8
8
  File.expand_path('../../../../../app', __dir__),
9
- File.expand_path('../../../../../app/assets/images', __dir__),
10
9
  File.expand_path('../../../../../app/assets/stylesheets/spree/frontend', __dir__),
11
- File.expand_path('../../../../../app/assets/stylesheets/spree/frontend/variables', __dir__)
12
10
  ]
13
11
  end
14
12
 
15
13
  def copy_storefront
16
14
  directory 'views', './app/views'
17
- directory 'noimage', './app/assets/images/noimage'
18
- directory 'homepage', './app/assets/images/homepage'
19
- directory 'meganav', './app/assets/images/meganav'
20
15
  template 'application.scss', './app/assets/stylesheets/spree/frontend/application.scss'
21
- template 'variables.scss', './app/assets/stylesheets/spree/frontend/variables/variables.scss'
22
16
  end
23
17
  end
24
18
  end
@@ -0,0 +1,34 @@
1
+ module Spree
2
+ module Frontend
3
+ module Generators
4
+ class InstallGenerator < Rails::Generators::Base
5
+ desc 'Copies storefront configuration files for easy customization'
6
+
7
+ def self.source_paths
8
+ [
9
+ File.expand_path('templates', __dir__),
10
+ File.expand_path('../templates', "../#{__FILE__}"),
11
+ File.expand_path('../templates', "../../#{__FILE__}"),
12
+ File.expand_path('../../../../../app/views/spree', __dir__),
13
+ File.expand_path('../../../../../app/assets/images', __dir__),
14
+ File.expand_path('../../../../../app/assets/stylesheets/spree/frontend/variables', __dir__)
15
+ ]
16
+ end
17
+
18
+ def install
19
+ # main navigation configuration
20
+ template 'config/initializers/spree_storefront.rb', 'config/initializers/spree_storefront.rb'
21
+ template 'config/spree_storefront.yml', 'config/spree_storefront.yml'
22
+ # static images
23
+ directory 'noimage', './app/assets/images/noimage'
24
+ directory 'homepage', './app/assets/images/homepage'
25
+ directory 'meganav', './app/assets/images/meganav'
26
+ # SCSS theming
27
+ template 'variables.scss', './app/assets/stylesheets/spree/frontend/variables/variables.scss'
28
+ # home page template
29
+ directory 'home', './app/views/spree/home'
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end