workarea-storefront 3.4.45 → 3.5.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +52 -0
- data/app/assets/javascripts/workarea/storefront/application.js.erb +2 -12
- data/app/assets/javascripts/workarea/storefront/config.js.erb +0 -5
- data/app/assets/javascripts/workarea/storefront/modules/{analytics.js → analytics.js.erb} +17 -0
- data/app/assets/javascripts/workarea/storefront/modules/dialog_buttons.js +1 -1
- data/app/assets/javascripts/workarea/storefront/modules/workarea_analytics.js +4 -0
- data/app/assets/stylesheets/workarea/storefront/application.scss.erb +0 -2
- data/app/assets/stylesheets/workarea/storefront/email/_base.scss +9 -1
- data/app/assets/stylesheets/workarea/storefront/email/_components.scss +1 -1
- data/app/assets/stylesheets/workarea/storefront/email/_helpers.scss +16 -0
- data/app/assets/stylesheets/workarea/storefront/email/{_settings.scss → _settings.scss.erb} +1 -1
- data/app/controllers/workarea/storefront/analytics_controller.rb +36 -21
- data/app/controllers/workarea/storefront/application_controller.rb +2 -4
- data/app/controllers/workarea/storefront/cart_items_controller.rb +1 -2
- data/app/controllers/workarea/storefront/checkout/addresses_controller.rb +0 -2
- data/app/controllers/workarea/storefront/checkouts_controller.rb +6 -4
- data/app/controllers/workarea/storefront/content_areas_controller.rb +1 -0
- data/app/controllers/workarea/storefront/content_blocks_controller.rb +1 -0
- data/app/controllers/workarea/storefront/current_checkout.rb +20 -14
- data/app/controllers/workarea/storefront/downloads_controller.rb +18 -0
- data/app/controllers/workarea/storefront/email_signups_controller.rb +1 -0
- data/app/controllers/workarea/storefront/errors_controller.rb +6 -0
- data/app/controllers/workarea/storefront/recent_views_controller.rb +2 -35
- data/app/controllers/workarea/storefront/recommendations_controller.rb +2 -2
- data/app/controllers/workarea/storefront/searches_controller.rb +0 -11
- data/app/controllers/workarea/storefront/users/accounts_controller.rb +2 -7
- data/app/controllers/workarea/storefront/users/credit_cards_controller.rb +5 -2
- data/app/controllers/workarea/storefront/users/passwords_controller.rb +1 -5
- data/app/helpers/workarea/storefront/application_helper.rb +19 -3
- data/app/helpers/workarea/storefront/content_helper.rb +1 -1
- data/app/helpers/workarea/storefront/favicons_helper.rb +6 -7
- data/app/helpers/workarea/storefront/navigation_helper.rb +10 -0
- data/app/helpers/workarea/storefront/schema_org_helper.rb +156 -0
- data/app/mailers/workarea/storefront/application_mailer.rb +1 -0
- data/app/view_models/workarea/storefront/category_view_model.rb +2 -2
- data/app/view_models/workarea/storefront/content_block_view_model.rb +41 -10
- data/app/view_models/workarea/storefront/content_blocks/product_insights_view_model.rb +1 -1
- data/app/view_models/workarea/storefront/display_content.rb +3 -1
- data/app/view_models/workarea/storefront/inquiry_view_model.rb +1 -7
- data/app/view_models/workarea/storefront/inventory_status_view_model.rb +10 -6
- data/app/view_models/workarea/storefront/order_item_view_model.rb +14 -0
- data/app/view_models/workarea/storefront/product_view_model.rb +22 -4
- data/app/view_models/workarea/storefront/recommendations_view_model.rb +8 -4
- data/app/view_models/workarea/storefront/search_view_model.rb +1 -1
- data/app/view_models/workarea/storefront/user_activity_view_model.rb +6 -17
- data/app/views/layouts/workarea/storefront/application.html.haml +13 -17
- data/app/views/layouts/workarea/storefront/checkout.html.haml +1 -1
- data/app/views/layouts/workarea/storefront/content_preview.html.haml +1 -0
- data/app/views/layouts/workarea/storefront/email.html.haml +33 -26
- data/app/views/layouts/workarea/storefront/empty.html.haml +1 -0
- data/app/views/layouts/workarea/storefront/navigation.html.haml +1 -1
- data/app/views/workarea/storefront/account_mailer/creation.html.haml +2 -0
- data/app/views/workarea/storefront/account_mailer/password_reset.html.haml +2 -0
- data/app/views/workarea/storefront/cart_items/create.html.haml +1 -1
- data/app/views/workarea/storefront/carts/show.html.haml +1 -1
- data/app/views/workarea/storefront/categories/show.html.haml +3 -2
- data/app/views/workarea/storefront/checkouts/confirmation.html.haml +1 -1
- data/app/views/workarea/storefront/contacts/show.html.haml +4 -2
- data/app/views/workarea/storefront/content_areas/show.html.haml +1 -0
- data/app/views/workarea/storefront/content_blocks/_category_summary.html.haml +2 -1
- data/app/views/workarea/storefront/content_blocks/_product_insights.html.haml +2 -1
- data/app/views/workarea/storefront/content_blocks/_product_list.html.haml +2 -1
- data/app/views/workarea/storefront/errors/show.html.haml +1 -0
- data/app/views/workarea/storefront/fulfillment_mailer/shipped.html.haml +3 -1
- data/app/views/workarea/storefront/order_mailer/_summary.html.haml +6 -0
- data/app/views/workarea/storefront/order_mailer/confirmation.html.haml +3 -0
- data/app/views/workarea/storefront/order_mailer/reminder.html.haml +3 -0
- data/app/views/workarea/storefront/orders/_summary.html.haml +3 -1
- data/app/views/workarea/storefront/orders/show.html.haml +3 -3
- data/app/views/workarea/storefront/pages/home_page.html.haml +4 -0
- data/app/views/workarea/storefront/pages/robots.text.erb +0 -1
- data/app/views/workarea/storefront/pages/show.html.haml +1 -0
- data/app/views/workarea/storefront/products/_price.html.haml +1 -2
- data/app/views/workarea/storefront/products/_pricing.html.haml +12 -6
- data/app/views/workarea/storefront/products/_summary.html.haml +3 -3
- data/app/views/workarea/storefront/products/show.html.haml +6 -4
- data/app/views/workarea/storefront/products/templates/_generic.html.haml +5 -5
- data/app/views/workarea/storefront/products/templates/_option_selects.html.haml +5 -7
- data/app/views/workarea/storefront/products/templates/_option_thumbnails.html.haml +5 -7
- data/app/views/workarea/storefront/recent_views/aside.html.haml +3 -10
- data/app/views/workarea/storefront/recent_views/narrow.html.haml +3 -10
- data/app/views/workarea/storefront/recent_views/show.html.haml +3 -10
- data/app/views/workarea/storefront/recommendations/show.html.haml +1 -1
- data/app/views/workarea/storefront/searches/show.html.haml +4 -5
- data/app/views/workarea/storefront/users/accounts/edit.html.haml +3 -3
- data/app/views/workarea/storefront/users/accounts/show.html.haml +3 -3
- data/app/views/workarea/storefront/users/addresses/edit.html.haml +3 -3
- data/app/views/workarea/storefront/users/addresses/new.html.haml +3 -3
- data/app/views/workarea/storefront/users/credit_cards/edit.html.haml +3 -3
- data/app/views/workarea/storefront/users/credit_cards/new.html.haml +3 -3
- data/app/views/workarea/storefront/users/orders/index.html.haml +3 -3
- data/app/views/workarea/storefront/users/orders/show.html.haml +4 -4
- data/app/views/workarea/storefront/users/passwords/new.html.haml +3 -3
- data/config/locales/en.yml +16 -3
- data/config/routes.rb +4 -2
- data/test/dummy/config/initializers/session_store.rb +1 -1
- data/test/helpers/workarea/storefront/content_helper_test.rb +1 -0
- data/test/helpers/workarea/storefront/navigation_helper_test.rb +4 -0
- data/test/helpers/workarea/storefront/schema_org_helper_test.rb +27 -0
- data/test/integration/workarea/storefront/analytics_integration_test.rb +44 -4
- data/test/integration/workarea/storefront/cart_items_integration_test.rb +0 -12
- data/test/integration/workarea/storefront/categories_integration_test.rb +0 -10
- data/test/integration/workarea/storefront/checkout_side_effects_integration_test.rb +15 -1
- data/test/integration/workarea/storefront/checkouts_integration_test.rb +68 -11
- data/test/integration/workarea/storefront/contact_form_integration_test.rb +18 -20
- data/test/integration/workarea/storefront/content_blocks_integration_test.rb +1 -4
- data/test/integration/workarea/storefront/current_checkout_integration_test.rb +53 -2
- data/test/integration/workarea/storefront/downloads_integration_test.rb +38 -0
- data/test/integration/workarea/storefront/email_signups_integration_test.rb +2 -0
- data/test/integration/workarea/storefront/guest_browsing_integration_test.rb +2 -2
- data/test/integration/workarea/storefront/impersonations_integration_test.rb +2 -2
- data/test/integration/workarea/storefront/login_integration_test.rb +3 -9
- data/test/integration/workarea/storefront/order_data_integration_test.rb +1 -9
- data/test/integration/workarea/storefront/place_order_integration_test.rb +5 -7
- data/test/integration/workarea/storefront/placing_order_integration_test.rb +1 -1
- data/test/integration/workarea/storefront/recent_views_integration_test.rb +29 -0
- data/test/integration/workarea/storefront/releases_integration_test.rb +132 -0
- data/test/integration/workarea/storefront/search_integration_test.rb +0 -46
- data/test/integration/workarea/storefront/segment_overrides_integration_test.rb +48 -0
- data/test/integration/workarea/storefront/segments_integration_test.rb +250 -0
- data/test/integration/workarea/storefront/store_credit_integration_test.rb +1 -1
- data/test/integration/workarea/storefront/users/credit_cards_integration_test.rb +2 -2
- data/test/integration/workarea/storefront/users/passwords_integration_test.rb +0 -19
- data/test/javascripts/traffic_referrer_spec.js +1 -1
- data/test/mailers/workarea/storefront/transactional_mailer_test.rb +9 -13
- data/test/system/workarea/storefront/analytics_system_test.rb +54 -40
- data/test/system/workarea/storefront/content_system_test.rb +10 -1
- data/test/system/workarea/storefront/digital_products_system_test.rb +2 -0
- data/test/system/workarea/storefront/download_system_test.rb +145 -0
- data/test/system/workarea/storefront/guest_checkout_system_test.rb +20 -0
- data/test/system/workarea/storefront/logged_in_checkout_system_test.rb +31 -32
- data/test/system/workarea/storefront/passwords_system_test.rb +35 -37
- data/test/system/workarea/storefront/pricing_overrides_system_test.rb +13 -2
- data/test/system/workarea/storefront/segment_overrides_system_test.rb +69 -0
- data/test/view_models/workarea/storefront/category_view_model_test.rb +20 -0
- data/test/view_models/workarea/storefront/content_block_view_model_test.rb +135 -3
- data/test/view_models/workarea/storefront/display_content_test.rb +4 -0
- data/test/view_models/workarea/storefront/product_view_model/option_set_test.rb +7 -8
- data/test/view_models/workarea/storefront/product_view_model_test.rb +17 -10
- data/test/view_models/workarea/storefront/search_view_model_test.rb +0 -6
- data/test/view_models/workarea/storefront/user_activity_view_model_test.rb +18 -20
- metadata +20 -22
- data/app/assets/javascripts/workarea/storefront/modules/recent_views.js +0 -25
- data/app/assets/javascripts/workarea/storefront/modules/search_fields.js +0 -59
- data/app/assets/javascripts/workarea/storefront/templates/ui_menu_heading.jst.ejs +0 -1
- data/app/assets/javascripts/workarea/storefront/templates/ui_menu_item.jst.ejs +0 -8
- data/app/assets/stylesheets/jquery_ui/storefront/_ui_autocomplete.scss +0 -17
- data/app/assets/stylesheets/jquery_ui/storefront/_ui_menu.scss +0 -40
- data/app/controllers/workarea/storefront/http_caching.rb +0 -33
- data/app/controllers/workarea/storefront/user_activity.rb +0 -19
- data/app/view_models/workarea/storefront/search_suggestion_view_model.rb +0 -87
- data/app/views/workarea/storefront/searches/index.json.jbuilder +0 -1
- data/app/views/workarea/storefront/style_guides/components/_ui_autocomplete.html.haml +0 -11
- data/test/dummy/tmp/screenshots/.keep +0 -0
- data/test/view_models/workarea/storefront/search_suggestion_view_model_test.rb +0 -42
@@ -2,6 +2,7 @@ module Workarea
|
|
2
2
|
class Storefront::ContentBlocksController < Storefront::ApplicationController
|
3
3
|
layout 'workarea/storefront/empty'
|
4
4
|
|
5
|
+
skip_around_action :apply_segments
|
5
6
|
before_action :require_login
|
6
7
|
before_action :require_admin
|
7
8
|
before_action :disable_xss_protection
|
@@ -5,7 +5,7 @@ module Workarea
|
|
5
5
|
|
6
6
|
included do
|
7
7
|
helper_method :current_order
|
8
|
-
after_action :
|
8
|
+
after_action :set_order_id_cookie
|
9
9
|
end
|
10
10
|
|
11
11
|
# The current order for the current session.
|
@@ -14,8 +14,11 @@ module Workarea
|
|
14
14
|
#
|
15
15
|
def current_order
|
16
16
|
@current_order ||= Order.find_current(
|
17
|
-
|
18
|
-
|
17
|
+
# TODO session[:order_id] is deprecated in v3.5, remove in v3.6
|
18
|
+
# TODO cookies.signed[:user_id] is deprecated in v3.5, remove in v3.6
|
19
|
+
|
20
|
+
id: cookies.signed[:order_id].presence || session[:order_id],
|
21
|
+
user_id: session[:user_id].presence || cookies.signed[:user_id]
|
19
22
|
)
|
20
23
|
end
|
21
24
|
|
@@ -23,13 +26,16 @@ module Workarea
|
|
23
26
|
#
|
24
27
|
def current_order=(order)
|
25
28
|
@current_order = order
|
26
|
-
|
29
|
+
cookies.permanent.signed[:order_id] = order&.id
|
27
30
|
end
|
28
31
|
|
29
32
|
# Removes the current order from the session.
|
30
33
|
#
|
31
34
|
def clear_current_order
|
35
|
+
# TODO session[:order_id] is deprecated in v3.5, remove in v3.6
|
32
36
|
session.delete(:order_id)
|
37
|
+
|
38
|
+
cookies.delete(:order_id)
|
33
39
|
@current_order = nil
|
34
40
|
end
|
35
41
|
|
@@ -38,11 +44,7 @@ module Workarea
|
|
38
44
|
# page.
|
39
45
|
#
|
40
46
|
def completed_order=(order)
|
41
|
-
|
42
|
-
value: order.id,
|
43
|
-
expires: Workarea.config.completed_order_timeout.from_now
|
44
|
-
}
|
45
|
-
|
47
|
+
session[:completed_order_id] = order&.id
|
46
48
|
@completed_order = order
|
47
49
|
end
|
48
50
|
|
@@ -52,9 +54,8 @@ module Workarea
|
|
52
54
|
# @return [Order]
|
53
55
|
#
|
54
56
|
def completed_order
|
55
|
-
if
|
56
|
-
|
57
|
-
end
|
57
|
+
return @completed_order if defined?(@completed_order)
|
58
|
+
@completed_order = Order.find(session[:completed_order_id]) rescue nil
|
58
59
|
end
|
59
60
|
|
60
61
|
# Get the current checkout for the session.
|
@@ -81,11 +82,16 @@ module Workarea
|
|
81
82
|
current_checkout.shippings
|
82
83
|
end
|
83
84
|
|
85
|
+
def logout
|
86
|
+
super
|
87
|
+
clear_current_order
|
88
|
+
end
|
89
|
+
|
84
90
|
private
|
85
91
|
|
86
|
-
def
|
92
|
+
def set_order_id_cookie
|
87
93
|
if @current_order.present? && @current_order.persisted?
|
88
|
-
|
94
|
+
cookies.permanent.signed[:order_id] = @current_order.id
|
89
95
|
end
|
90
96
|
end
|
91
97
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Workarea
|
2
|
+
module Storefront
|
3
|
+
class DownloadsController < Storefront::ApplicationController
|
4
|
+
def show
|
5
|
+
token = Fulfillment::Token.find(params[:id])
|
6
|
+
sku = Fulfillment::Sku.find(token.sku) rescue nil
|
7
|
+
|
8
|
+
if token&.enabled? && sku&.downloadable?
|
9
|
+
token.inc(downloads: 1)
|
10
|
+
send_file sku.file.file, filename: sku.file_name
|
11
|
+
else
|
12
|
+
flash[:info] = t('workarea.storefront.flash_messages.download_unavailable')
|
13
|
+
redirect_to root_path
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -8,6 +8,7 @@ module Workarea
|
|
8
8
|
signup = Email.signup(params[:email])
|
9
9
|
|
10
10
|
if signup.try(:valid?)
|
11
|
+
update_tracking!(email: signup.email)
|
11
12
|
flash[:success] = t('workarea.storefront.flash_messages.email_signed_up')
|
12
13
|
else
|
13
14
|
flash[:error] = t('workarea.storefront.flash_messages.email_signup_error')
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Workarea
|
2
2
|
module Storefront
|
3
3
|
class ErrorsController < Storefront::ApplicationController
|
4
|
+
after_action :skip_session
|
5
|
+
|
4
6
|
def not_found
|
5
7
|
redirect_url = Navigation::Redirect.find_destination(
|
6
8
|
request.env['action_dispatch.original_path']
|
@@ -53,6 +55,10 @@ module Workarea
|
|
53
55
|
end
|
54
56
|
end
|
55
57
|
end
|
58
|
+
|
59
|
+
def skip_session
|
60
|
+
request.session_options[:skip] = true
|
61
|
+
end
|
56
62
|
end
|
57
63
|
end
|
58
64
|
end
|
@@ -1,51 +1,18 @@
|
|
1
1
|
module Workarea
|
2
2
|
class Storefront::RecentViewsController < Storefront::ApplicationController
|
3
3
|
skip_before_action :verify_authenticity_token
|
4
|
-
before_action :block_robots
|
5
4
|
|
6
5
|
def show
|
7
|
-
if stale?(etag:
|
8
|
-
@recent_views = Storefront::UserActivityViewModel.new(
|
6
|
+
if stale?(etag: current_metrics, last_modified: current_metrics.updated_at)
|
7
|
+
@recent_views = Storefront::UserActivityViewModel.new(current_metrics, view_model_options)
|
9
8
|
render params[:view].in?(allowed_alt_views) ? params[:view] : :show
|
10
9
|
end
|
11
10
|
end
|
12
11
|
|
13
|
-
def update
|
14
|
-
if params[:product_id].present?
|
15
|
-
Recommendation::UserActivity.save_product(
|
16
|
-
current_user_activity_id,
|
17
|
-
params[:product_id]
|
18
|
-
)
|
19
|
-
end
|
20
|
-
|
21
|
-
if params[:category_id].present?
|
22
|
-
Recommendation::UserActivity.save_category(
|
23
|
-
current_user_activity_id,
|
24
|
-
params[:category_id]
|
25
|
-
)
|
26
|
-
end
|
27
|
-
|
28
|
-
if params[:search].present?
|
29
|
-
Recommendation::UserActivity.save_search(
|
30
|
-
current_user_activity_id,
|
31
|
-
params[:search]
|
32
|
-
)
|
33
|
-
end
|
34
|
-
|
35
|
-
head :ok
|
36
|
-
end
|
37
|
-
|
38
12
|
private
|
39
13
|
|
40
14
|
def allowed_alt_views
|
41
15
|
['aside', 'narrow']
|
42
16
|
end
|
43
|
-
|
44
|
-
def block_robots
|
45
|
-
if Robots.is_robot?(request.user_agent)
|
46
|
-
head :forbidden
|
47
|
-
return false
|
48
|
-
end
|
49
|
-
end
|
50
17
|
end
|
51
18
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Workarea
|
2
2
|
class Storefront::RecommendationsController < Storefront::ApplicationController
|
3
3
|
def show
|
4
|
-
fresh_when(etag:
|
4
|
+
fresh_when(etag: current_metrics, last_modified: current_metrics.updated_at)
|
5
5
|
@recommendations = Storefront::PersonalizedRecommendationsViewModel.new(
|
6
|
-
|
6
|
+
current_metrics,
|
7
7
|
view_model_options
|
8
8
|
)
|
9
9
|
end
|
@@ -3,17 +3,6 @@ module Workarea
|
|
3
3
|
class SearchesController < Storefront::ApplicationController
|
4
4
|
before_action :cache_page
|
5
5
|
|
6
|
-
def index
|
7
|
-
render nothing: true and return if search_query.blank?
|
8
|
-
autocomplete_params = params.permit(:q)
|
9
|
-
|
10
|
-
search = Search::SearchSuggestions.new(autocomplete_params)
|
11
|
-
|
12
|
-
@results = search.results.map do |result|
|
13
|
-
SearchSuggestionViewModel.new(result).to_h
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
6
|
def show
|
18
7
|
if search_query.blank?
|
19
8
|
flash[:error] = t('workarea.storefront.flash_messages.no_search_query')
|
@@ -60,7 +60,7 @@ module Workarea
|
|
60
60
|
|
61
61
|
def find_recommendations
|
62
62
|
@recommendations = Storefront::PersonalizedRecommendationsViewModel.new(
|
63
|
-
|
63
|
+
current_metrics,
|
64
64
|
view_model_options
|
65
65
|
)
|
66
66
|
end
|
@@ -74,18 +74,13 @@ module Workarea
|
|
74
74
|
)
|
75
75
|
end
|
76
76
|
|
77
|
-
def completed_order
|
78
|
-
return unless cookies.signed[:completed_order].present?
|
79
|
-
Order.find(cookies.signed[:completed_order])
|
80
|
-
end
|
81
|
-
|
82
77
|
def save_completed_order_details(user)
|
83
78
|
if user.email == completed_order.email
|
84
79
|
completed_order.update_attributes!(user_id: user.id)
|
85
80
|
SaveUserOrderDetails.new.perform(completed_order.id)
|
86
81
|
end
|
87
82
|
|
88
|
-
|
83
|
+
self.completed_order = nil
|
89
84
|
end
|
90
85
|
end
|
91
86
|
end
|
@@ -8,11 +8,7 @@ module Workarea
|
|
8
8
|
|
9
9
|
def edit
|
10
10
|
reset = User::PasswordReset.find_by(token: params[:token]) rescue nil
|
11
|
-
|
12
|
-
unless reset
|
13
|
-
flash[:error] = t('workarea.storefront.flash_messages.password_reset_expired')
|
14
|
-
redirect_to forgot_password_path
|
15
|
-
end
|
11
|
+
redirect_to forgot_password_path unless reset
|
16
12
|
end
|
17
13
|
|
18
14
|
def create
|
@@ -2,9 +2,17 @@ module Workarea
|
|
2
2
|
module Storefront
|
3
3
|
module ApplicationHelper
|
4
4
|
def page_title(title_content = @title)
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
if title_content.present?
|
6
|
+
title = t(
|
7
|
+
'workarea.storefront.layouts.page_title_with_content',
|
8
|
+
title_content: title_content,
|
9
|
+
site_name: Workarea.config.site_name
|
10
|
+
)
|
11
|
+
else
|
12
|
+
title = t('workarea.storefront.layouts.page_title',
|
13
|
+
site_name: Workarea.config.site_name
|
14
|
+
)
|
15
|
+
end
|
8
16
|
|
9
17
|
unless Rails.env.in?(%w(test development production))
|
10
18
|
title = "[#{Rails.env.upcase}] #{title}"
|
@@ -29,6 +37,14 @@ module Workarea
|
|
29
37
|
end
|
30
38
|
end
|
31
39
|
|
40
|
+
def add_head_content(content)
|
41
|
+
return unless content.present?
|
42
|
+
|
43
|
+
content_for(:head_content) do
|
44
|
+
content.html_safe
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
32
48
|
def flash_messages
|
33
49
|
flash.keys.inject('') do |memo, name|
|
34
50
|
msg = flash[name]
|
@@ -21,7 +21,7 @@ module Workarea
|
|
21
21
|
render_content_blocks_without_cache(blocks)
|
22
22
|
else
|
23
23
|
Rails.cache.fetch(
|
24
|
-
blocks.map(&:cache_key).join('/'),
|
24
|
+
blocks.map(&:cache_key).push(cache_varies).join('/'),
|
25
25
|
expires_in: Workarea.config.cache_expirations.render_content_blocks
|
26
26
|
) { render_content_blocks_without_cache(blocks) }
|
27
27
|
end
|
@@ -1,13 +1,12 @@
|
|
1
1
|
module Workarea
|
2
2
|
module Storefront
|
3
3
|
module FaviconsHelper
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
end
|
4
|
+
# TODO remove in v3.6
|
5
|
+
def favicon_tags; end
|
6
|
+
Workarea.deprecation.deprecate_methods(
|
7
|
+
FaviconsHelper,
|
8
|
+
favicon_tags: "Use `render 'workarea/storefront/favicons/tags'`"
|
9
|
+
)
|
11
10
|
|
12
11
|
def favicons_present?
|
13
12
|
Content::Asset.favicons.count.positive?
|
@@ -77,6 +77,16 @@ module Workarea
|
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
+
def storefront_url_for(taxon)
|
81
|
+
path = storefront_path_for(taxon)
|
82
|
+
|
83
|
+
return if path.blank?
|
84
|
+
|
85
|
+
protocol = Rails.application.config.force_ssl ? 'https' : 'http'
|
86
|
+
"#{protocol}://#{Workarea.config.host}/#{path.sub(/^\//, '')}"
|
87
|
+
end
|
88
|
+
|
89
|
+
|
80
90
|
# Generate a cache key for a taxon's left navigation. Uses the
|
81
91
|
# `:selected` taxon in the cache key if a given node is selected,
|
82
92
|
# otherwise just appends the `section` argument onto the `taxon`'s
|
@@ -0,0 +1,156 @@
|
|
1
|
+
module Workarea
|
2
|
+
module Storefront
|
3
|
+
module SchemaOrgHelper
|
4
|
+
def web_site_schema
|
5
|
+
{
|
6
|
+
'@context': 'http://schema.org',
|
7
|
+
'@type': 'WebSite',
|
8
|
+
'url': root_url,
|
9
|
+
'potentialAction': {
|
10
|
+
'@type': 'SearchAction',
|
11
|
+
"target": "#{search_url}?q={search_term_string}",
|
12
|
+
'query-input': 'required name=search_term_string'
|
13
|
+
}
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
def web_page_schema(type = 'WebPage')
|
18
|
+
{
|
19
|
+
'@context': 'http://schema.org',
|
20
|
+
'@type': type
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
def breadcrumb_list_schema(breadcrumbs)
|
25
|
+
{
|
26
|
+
"@context": "http://schema.org",
|
27
|
+
"@type": "BreadcrumbList",
|
28
|
+
"itemListElement": breadcrumbs.each_with_index.map do |(name, url), index|
|
29
|
+
{
|
30
|
+
"@type": "ListItem",
|
31
|
+
"position": index + 1,
|
32
|
+
"item": {
|
33
|
+
"@id": url,
|
34
|
+
"name": name
|
35
|
+
}
|
36
|
+
}
|
37
|
+
end
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
def product_schema(product, related_products: nil)
|
42
|
+
schema = {
|
43
|
+
"@context": "http://schema.org",
|
44
|
+
"@type": "Product",
|
45
|
+
"description": product.description,
|
46
|
+
"name": product.name,
|
47
|
+
"image": product_image_url(product.primary_image, :large_thumb),
|
48
|
+
"url": product_url(product),
|
49
|
+
"productID": product.id
|
50
|
+
}
|
51
|
+
|
52
|
+
if product.pricing.sell_min_price.present?
|
53
|
+
schema['offers'] = {
|
54
|
+
"@type": "Offer",
|
55
|
+
"availability": "http://schema.org/InStock",
|
56
|
+
"price": product.pricing.sell_min_price.to_s,
|
57
|
+
"priceCurrency": product.pricing.sell_min_price.currency.to_s,
|
58
|
+
"url": product_url(product)
|
59
|
+
}
|
60
|
+
end
|
61
|
+
|
62
|
+
if related_products.present?
|
63
|
+
schema['isRelatedTo'] = related_products.map do |related_product|
|
64
|
+
product_schema(related_product)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
schema
|
69
|
+
end
|
70
|
+
|
71
|
+
def order_email_schema(order)
|
72
|
+
{
|
73
|
+
'@context': 'http://schema.org',
|
74
|
+
'@type': 'Order',
|
75
|
+
'merchant': {
|
76
|
+
'@type': 'Organization',
|
77
|
+
'name': Workarea.config.site_name
|
78
|
+
},
|
79
|
+
'orderNumber': order.id,
|
80
|
+
'orderStatus': 'http://schema.org/OrderProcessing',
|
81
|
+
'acceptedOffer': order.items.map do |item|
|
82
|
+
{
|
83
|
+
'@type': 'Offer',
|
84
|
+
'itemOffered': {
|
85
|
+
'@type': 'Product',
|
86
|
+
'name': item.product.name,
|
87
|
+
'sku': item.sku,
|
88
|
+
'url': product_url(item.product, sku: item.sku),
|
89
|
+
'image': path_to_url(product_image_url(item.product.primary_image, :small_thumb)),
|
90
|
+
},
|
91
|
+
'price': item.total_price.to_s,
|
92
|
+
'priceCurrency': item.total_price.currency.to_s,
|
93
|
+
'eligibleQuantity': {
|
94
|
+
'@type': 'QuantitativeValue',
|
95
|
+
'value': item.quantity
|
96
|
+
}
|
97
|
+
}
|
98
|
+
end,
|
99
|
+
'url': order_url(order),
|
100
|
+
'potentialAction': {
|
101
|
+
'@type': 'ViewAction',
|
102
|
+
'url': order_url(order)
|
103
|
+
}
|
104
|
+
}
|
105
|
+
end
|
106
|
+
|
107
|
+
def fulfillment_email_schema(order, package)
|
108
|
+
{
|
109
|
+
'@context': 'http://schema.org',
|
110
|
+
'@type': 'ParcelDelivery',
|
111
|
+
'deliveryAddress': {
|
112
|
+
'@type': 'PostalAddress',
|
113
|
+
'name': 'Ship To',
|
114
|
+
'streetAddress': [
|
115
|
+
order.shipping_address.street,
|
116
|
+
order.shipping_address.street_2
|
117
|
+
].join(' / '),
|
118
|
+
'addressLocality': order.shipping_address.city,
|
119
|
+
'addressRegion': order.shipping_address.region,
|
120
|
+
'addressCountry': order.shipping_address.country,
|
121
|
+
'postalCode': order.shipping_address.postal_code
|
122
|
+
},
|
123
|
+
'carrier': {
|
124
|
+
'@type': 'Organization',
|
125
|
+
'name': package.carrier
|
126
|
+
},
|
127
|
+
'itemShipped': order.items.map do |item|
|
128
|
+
{
|
129
|
+
'@type': 'Product',
|
130
|
+
'name': item.product.name,
|
131
|
+
'sku': item.sku,
|
132
|
+
'url': product_url(item.product, sku: item.sku),
|
133
|
+
'image': path_to_url(product_image_url(item.product.primary_image, :small_thumb)),
|
134
|
+
}
|
135
|
+
end,
|
136
|
+
'partOfOrder': {
|
137
|
+
'@type': 'Order',
|
138
|
+
'orderNumber': order.id,
|
139
|
+
'merchant': {
|
140
|
+
'@type': 'Organization',
|
141
|
+
'name': Workarea.config.site_name
|
142
|
+
},
|
143
|
+
'orderStatus': 'http://schema.org/OrderInTransit'
|
144
|
+
},
|
145
|
+
'expectedArrivalUntil': Workarea.config.order_expected_arrival.call(order, package),
|
146
|
+
'trackingNumber': package.tracking_number,
|
147
|
+
'trackingUrl': package.tracking_link,
|
148
|
+
'potentialAction': {
|
149
|
+
'@type': 'TrackAction',
|
150
|
+
'target': package.tracking_link
|
151
|
+
}
|
152
|
+
}
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|