spree_frontend 4.3.0.rc3 → 4.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +191 -0
- data/.codeclimate.yml +36 -0
- data/.deepsource.toml +19 -0
- data/.editorconfig +22 -0
- data/.eslintignore +7 -0
- data/.eslintrc +36 -0
- data/.gem_release.yml +7 -0
- data/.github/CONTRIBUTING.md +1 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +47 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- data/.github/ISSUE_TEMPLATE.md +39 -0
- data/.github/dependabot.yml +32 -0
- data/.gitignore +58 -0
- data/.rubocop.yml +197 -0
- data/.solargraph.yml +20 -0
- data/.stylelintignore +4 -0
- data/.stylelintrc +6 -0
- data/CODE_OF_CONDUCT.md +22 -0
- data/Gemfile +62 -3
- data/LICENSE +1 -1
- data/README.md +35 -0
- data/SECURITY.md +1 -0
- data/app/controllers/spree/addresses_controller.rb +2 -6
- data/app/controllers/spree/locale_controller.rb +1 -1
- data/app/controllers/spree/store_controller.rb +42 -1
- data/app/helpers/spree/frontend_helper.rb +19 -1
- data/app/helpers/spree/navigation_helper.rb +1 -1
- data/app/helpers/spree/store_helper.rb +1 -1
- data/app/models/spree/frontend_configuration.rb +7 -1
- data/app/services/spree/build_localized_redirect_url.rb +101 -0
- data/app/views/spree/checkout/_delivery.html.erb +1 -1
- data/app/views/spree/products/_description.html.erb +1 -1
- data/app/views/spree/shared/_link_to_account.html.erb +3 -1
- data/app/views/spree/shared/_paths.html.erb +1 -1
- data/config/routes.rb +5 -5
- data/lib/spree/frontend/engine.rb +2 -1
- data/lib/spree/frontend/version.rb +9 -0
- data/license.md +13 -0
- data/spree_frontend.gemspec +2 -2
- metadata +34 -12
- data/app/views/spree/shared/_taxonomies.html.erb +0 -16
data/.rubocop.yml
ADDED
@@ -0,0 +1,197 @@
|
|
1
|
+
require: rubocop-rspec
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
TargetRubyVersion: 2.5
|
5
|
+
Exclude:
|
6
|
+
- '**/sandbox/**/*'
|
7
|
+
- '**/db/migrate/*'
|
8
|
+
- '**/Gemfile'
|
9
|
+
- '**/Gemfile.lock'
|
10
|
+
- '**/Rakefile'
|
11
|
+
- '**/rails'
|
12
|
+
- '**/*.gemspec'
|
13
|
+
- '**/dummy/**/*'
|
14
|
+
- '**/vendor/**/*'
|
15
|
+
- '**/spec_helper.rb'
|
16
|
+
- '**/templates/**/*'
|
17
|
+
|
18
|
+
Layout/MultilineOperationIndentation:
|
19
|
+
EnforcedStyle: indented
|
20
|
+
|
21
|
+
Layout/ParameterAlignment:
|
22
|
+
Enabled: false
|
23
|
+
|
24
|
+
Metrics/ClassLength:
|
25
|
+
CountComments: false
|
26
|
+
Max: 150
|
27
|
+
|
28
|
+
Metrics/ModuleLength:
|
29
|
+
CountComments: false
|
30
|
+
Max: 250
|
31
|
+
Exclude:
|
32
|
+
- '**/spec/**/*'
|
33
|
+
|
34
|
+
Style/Documentation:
|
35
|
+
Enabled: false
|
36
|
+
|
37
|
+
Layout/LineLength:
|
38
|
+
Max: 150
|
39
|
+
Exclude:
|
40
|
+
- '**/spec/**/*'
|
41
|
+
|
42
|
+
Metrics/MethodLength:
|
43
|
+
CountComments: false
|
44
|
+
Max: 50
|
45
|
+
|
46
|
+
Metrics/BlockLength:
|
47
|
+
CountComments: false
|
48
|
+
Max: 50
|
49
|
+
Exclude:
|
50
|
+
- '**/spec/**/*'
|
51
|
+
- '**/*.rake'
|
52
|
+
- '**/factories/**/*'
|
53
|
+
- '**/config/routes.rb'
|
54
|
+
|
55
|
+
Metrics/AbcSize:
|
56
|
+
Max: 45
|
57
|
+
|
58
|
+
Style/StringLiterals:
|
59
|
+
EnforcedStyle: single_quotes
|
60
|
+
|
61
|
+
Layout/DotPosition:
|
62
|
+
EnforcedStyle: trailing
|
63
|
+
Enabled: true
|
64
|
+
|
65
|
+
Layout/SpaceInsideArrayLiteralBrackets:
|
66
|
+
Exclude:
|
67
|
+
- 'api/spec/integration/**/*.rb'
|
68
|
+
- 'api/lib/spree/api/testing_support/v2/platform_contexts.rb'
|
69
|
+
|
70
|
+
Style/FrozenStringLiteralComment:
|
71
|
+
Enabled: false
|
72
|
+
|
73
|
+
Style/RegexpLiteral:
|
74
|
+
Enabled: false
|
75
|
+
|
76
|
+
Style/WordArray:
|
77
|
+
Enabled: false
|
78
|
+
|
79
|
+
Style/SymbolArray:
|
80
|
+
Enabled: false
|
81
|
+
|
82
|
+
Style/SymbolProc:
|
83
|
+
Exclude:
|
84
|
+
- '**/app/serializers/**/*'
|
85
|
+
|
86
|
+
Style/GuardClause:
|
87
|
+
Enabled: false
|
88
|
+
|
89
|
+
Style/TrailingCommaInArrayLiteral:
|
90
|
+
Enabled: false
|
91
|
+
|
92
|
+
Style/TrailingCommaInHashLiteral:
|
93
|
+
Enabled: false
|
94
|
+
|
95
|
+
Style/BarePercentLiterals:
|
96
|
+
Enabled: false
|
97
|
+
|
98
|
+
Style/MutableConstant:
|
99
|
+
Enabled: false
|
100
|
+
|
101
|
+
Style/PercentLiteralDelimiters:
|
102
|
+
Enabled: false
|
103
|
+
|
104
|
+
Style/IfUnlessModifier:
|
105
|
+
Enabled: false
|
106
|
+
|
107
|
+
Naming/VariableNumber:
|
108
|
+
Enabled: false
|
109
|
+
|
110
|
+
Style/RedundantPercentQ:
|
111
|
+
Enabled: false
|
112
|
+
|
113
|
+
Lint/ParenthesesAsGroupedExpression:
|
114
|
+
Enabled: false
|
115
|
+
|
116
|
+
Style/NumericPredicate:
|
117
|
+
Enabled: false
|
118
|
+
|
119
|
+
Metrics/PerceivedComplexity:
|
120
|
+
Max: 10
|
121
|
+
|
122
|
+
Metrics/CyclomaticComplexity:
|
123
|
+
Max: 10
|
124
|
+
|
125
|
+
Style/ClassAndModuleChildren:
|
126
|
+
Enabled: false
|
127
|
+
|
128
|
+
Style/AndOr:
|
129
|
+
Exclude:
|
130
|
+
- '**/*controller.rb'
|
131
|
+
|
132
|
+
Style/HashEachMethods:
|
133
|
+
Enabled: false
|
134
|
+
|
135
|
+
Style/HashTransformKeys:
|
136
|
+
Enabled: false
|
137
|
+
|
138
|
+
Style/HashTransformValues:
|
139
|
+
Enabled: false
|
140
|
+
|
141
|
+
RSpec/NestedGroups:
|
142
|
+
Max: 7
|
143
|
+
|
144
|
+
Lint/AmbiguousBlockAssociation:
|
145
|
+
Exclude:
|
146
|
+
- '**/spec/**/*'
|
147
|
+
|
148
|
+
Style/NumericLiterals:
|
149
|
+
Enabled: false
|
150
|
+
|
151
|
+
RSpec/DescribeClass:
|
152
|
+
Enabled: false
|
153
|
+
|
154
|
+
RSpec/VerifiedDoubles:
|
155
|
+
Enabled: false
|
156
|
+
|
157
|
+
RSpec/MessageChain:
|
158
|
+
Enabled: false
|
159
|
+
|
160
|
+
RSpec/AnyInstance:
|
161
|
+
Enabled: false
|
162
|
+
|
163
|
+
RSpec/InstanceVariable:
|
164
|
+
Enabled: false
|
165
|
+
|
166
|
+
RSpec/ContextWording:
|
167
|
+
Enabled: false
|
168
|
+
|
169
|
+
RSpec/ExpectInHook:
|
170
|
+
Enabled: false
|
171
|
+
|
172
|
+
RSpec/ExampleLength:
|
173
|
+
Enabled: false
|
174
|
+
|
175
|
+
RSpec/MessageSpies:
|
176
|
+
Enabled: false
|
177
|
+
|
178
|
+
RSpec/NamedSubject:
|
179
|
+
Enabled: false
|
180
|
+
|
181
|
+
RSpec/MultipleExpectations:
|
182
|
+
Enabled: false
|
183
|
+
|
184
|
+
RSpec/FilePath:
|
185
|
+
Enabled: false
|
186
|
+
|
187
|
+
RSpec/LetSetup:
|
188
|
+
Enabled: false
|
189
|
+
|
190
|
+
RSpec/SubjectStub:
|
191
|
+
Enabled: false
|
192
|
+
|
193
|
+
RSpec/VoidExpect:
|
194
|
+
Enabled: false
|
195
|
+
|
196
|
+
RSpec/BeforeAfterAll:
|
197
|
+
Enabled: false
|
data/.solargraph.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
---
|
2
|
+
include:
|
3
|
+
- "**/*.rb"
|
4
|
+
exclude:
|
5
|
+
- "*/spec/**/*"
|
6
|
+
- "*test/**/*"
|
7
|
+
- "*/vendor/**/*"
|
8
|
+
- vendor/**/*
|
9
|
+
- ".bundle/**/*"
|
10
|
+
- sample/**/*
|
11
|
+
- sandbox/**/*
|
12
|
+
- pkg/**/*
|
13
|
+
- cli/**/*.gemspec
|
14
|
+
require: []
|
15
|
+
domains: []
|
16
|
+
reporters:
|
17
|
+
- rubocop
|
18
|
+
- require_not_found
|
19
|
+
require_paths: []
|
20
|
+
max_files: 50_000
|
data/.stylelintignore
ADDED
data/.stylelintrc
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include:
|
8
|
+
|
9
|
+
* The use of sexualized language or imagery
|
10
|
+
* Personal attacks
|
11
|
+
* Trolling or insulting/derogatory comments
|
12
|
+
* Public or private harassment
|
13
|
+
* Publishing other's private information, such as physical or electronic addresses, without explicit permission
|
14
|
+
* Other unethical or unprofessional conduct.
|
15
|
+
|
16
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team.
|
17
|
+
|
18
|
+
This code of conduct applies both within project spaces and in public spaces when an individual is representing the project or its community.
|
19
|
+
|
20
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
21
|
+
|
22
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/)
|
data/Gemfile
CHANGED
@@ -1,6 +1,65 @@
|
|
1
|
-
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
gem '
|
4
|
-
|
3
|
+
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]
|
4
|
+
|
5
|
+
%w[
|
6
|
+
actionmailer actionpack actionview activejob activemodel activerecord
|
7
|
+
activestorage activesupport railties
|
8
|
+
].each do |rails_gem|
|
9
|
+
gem rails_gem, ENV.fetch('RAILS_VERSION', '~> 6.1.0'), require: false
|
10
|
+
end
|
11
|
+
|
12
|
+
platforms :jruby do
|
13
|
+
gem 'jruby-openssl'
|
14
|
+
end
|
15
|
+
|
16
|
+
platforms :ruby do
|
17
|
+
if ENV['DB'] == 'mysql'
|
18
|
+
gem 'mysql2'
|
19
|
+
else
|
20
|
+
gem 'pg', '~> 1.1'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
group :test do
|
25
|
+
gem 'capybara', '~> 3.24'
|
26
|
+
gem 'capybara-screenshot', '~> 1.0'
|
27
|
+
gem 'capybara-select-2'
|
28
|
+
gem 'database_cleaner', '~> 2.0'
|
29
|
+
gem 'email_spec'
|
30
|
+
gem 'factory_bot_rails', '~> 6.0'
|
31
|
+
gem 'multi_json'
|
32
|
+
gem 'rspec-activemodel-mocks', '~> 1.0'
|
33
|
+
gem 'rspec-rails', '~> 5.0'
|
34
|
+
gem 'rspec-retry'
|
35
|
+
gem 'rspec_junit_formatter'
|
36
|
+
gem 'rswag-specs'
|
37
|
+
gem 'jsonapi-rspec'
|
38
|
+
gem 'simplecov', '0.17.1'
|
39
|
+
gem 'webmock', '~> 3.7'
|
40
|
+
gem 'timecop'
|
41
|
+
gem 'rails-controller-testing'
|
42
|
+
end
|
43
|
+
|
44
|
+
group :test, :development do
|
45
|
+
gem 'awesome_print'
|
46
|
+
gem 'gem-release'
|
47
|
+
gem 'redis'
|
48
|
+
gem 'rubocop', '~> 1.22.3', require: false # bumped
|
49
|
+
gem 'rubocop-rspec', require: false
|
50
|
+
gem 'pry-byebug'
|
51
|
+
gem 'webdrivers', '~> 4.1'
|
52
|
+
gem 'puma'
|
53
|
+
gem 'ffaker'
|
54
|
+
end
|
55
|
+
|
56
|
+
group :development do
|
57
|
+
gem 'github_fast_changelog'
|
58
|
+
gem 'solargraph'
|
59
|
+
end
|
60
|
+
|
61
|
+
spree_opts = { github: 'spree/spree', branch: ENV.fetch('SPREE_BRANCH', '4-4-stable') }
|
62
|
+
gem 'spree_core', spree_opts
|
63
|
+
gem 'spree_api', spree_opts
|
5
64
|
|
6
65
|
gemspec
|
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2007-
|
1
|
+
Copyright (c) 2007-2021, Spree Commerce, Inc., Spark Solutions Sp. z o.o. and other contributors
|
2
2
|
All rights reserved.
|
3
3
|
|
4
4
|
Redistribution and use in source and binary forms, with or without modification,
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Spree (Legacy) Frontend
|
2
|
+
|
3
|
+
This is the old Spree Storefront extracted from Spree < 4.3.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'spree_frontend'
|
11
|
+
```
|
12
|
+
|
13
|
+
to your `Gemfile`.
|
14
|
+
|
15
|
+
Run:
|
16
|
+
|
17
|
+
```bash
|
18
|
+
bundle install
|
19
|
+
bin/rails g spree:frontend:install
|
20
|
+
```
|
21
|
+
|
22
|
+
## Maintanence policy
|
23
|
+
|
24
|
+
This gem is in maintainence mode.
|
25
|
+
|
26
|
+
We only accept bug fixes, Spree/Rails compatibility improvements & security patches.
|
27
|
+
|
28
|
+
For new project we recommend using [Storefront API](https://api.spreecommerce.org/) to create your own unique storefront or use one of the pre-built starters:
|
29
|
+
|
30
|
+
* [Next.js](https://dev-docs.spreecommerce.org/storefronts/next.js-commerce)
|
31
|
+
* [Vue Storefront](https://dev-docs.spreecommerce.org/storefronts/vue-storefront)
|
32
|
+
|
33
|
+
## Customization
|
34
|
+
|
35
|
+
[Developer documentation](https://dev-docs.spreecommerce.org/customization/storefront)
|
data/SECURITY.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Please see [Spree Guides Security section](https://dev-docs.spreecommerce.org/security/index).
|
@@ -4,10 +4,6 @@ module Spree
|
|
4
4
|
helper Spree::AddressesHelper
|
5
5
|
load_and_authorize_resource class: Spree::Address
|
6
6
|
|
7
|
-
def index
|
8
|
-
@addresses = try_spree_current_user.addresses
|
9
|
-
end
|
10
|
-
|
11
7
|
def create
|
12
8
|
@address = try_spree_current_user.addresses.build(address_params)
|
13
9
|
if create_service.call(user: try_spree_current_user, address_params: @address.attributes).success?
|
@@ -49,11 +45,11 @@ module Spree
|
|
49
45
|
end
|
50
46
|
|
51
47
|
def create_service
|
52
|
-
Spree::Dependencies.
|
48
|
+
Spree::Dependencies.address_create_service.constantize
|
53
49
|
end
|
54
50
|
|
55
51
|
def update_service
|
56
|
-
Spree::Dependencies.
|
52
|
+
Spree::Dependencies.address_update_service.constantize
|
57
53
|
end
|
58
54
|
end
|
59
55
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module Spree
|
2
2
|
class StoreController < ApplicationController
|
3
3
|
include Spree::Core::ControllerHelpers::Auth
|
4
|
-
include Spree::Core::ControllerHelpers::Common
|
5
4
|
include Spree::Core::ControllerHelpers::Search
|
6
5
|
include Spree::Core::ControllerHelpers::Store
|
7
6
|
include Spree::Core::ControllerHelpers::StrongParameters
|
@@ -12,10 +11,16 @@ module Spree
|
|
12
11
|
|
13
12
|
respond_to :html
|
14
13
|
|
14
|
+
layout :get_layout
|
15
|
+
|
15
16
|
helper 'spree/base'
|
16
17
|
helper 'spree/locale'
|
17
18
|
helper 'spree/currency'
|
18
19
|
|
20
|
+
helper_method :title
|
21
|
+
helper_method :title=
|
22
|
+
helper_method :accurate_title
|
23
|
+
|
19
24
|
skip_before_action :verify_authenticity_token, only: :ensure_cart, raise: false
|
20
25
|
|
21
26
|
before_action :redirect_to_default_locale
|
@@ -43,10 +48,46 @@ module Spree
|
|
43
48
|
|
44
49
|
protected
|
45
50
|
|
51
|
+
# can be used in views as well as controllers.
|
52
|
+
# e.g. <% self.title = 'This is a custom title for this view' %>
|
53
|
+
attr_writer :title
|
54
|
+
|
55
|
+
def title
|
56
|
+
title_string = @title.present? ? @title : accurate_title
|
57
|
+
if title_string.present?
|
58
|
+
if Spree::Frontend::Config[:always_put_site_name_in_title] && !title_string.include?(default_title)
|
59
|
+
[title_string, default_title].join(" #{Spree::Frontend::Config[:title_site_name_separator]} ")
|
60
|
+
else
|
61
|
+
title_string
|
62
|
+
end
|
63
|
+
else
|
64
|
+
default_title
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def default_title
|
69
|
+
current_store.name
|
70
|
+
end
|
71
|
+
|
72
|
+
# this is a hook for subclasses to provide title
|
73
|
+
def accurate_title
|
74
|
+
current_store.seo_title
|
75
|
+
end
|
76
|
+
|
46
77
|
def config_locale
|
47
78
|
Spree::Frontend::Config[:locale]
|
48
79
|
end
|
49
80
|
|
81
|
+
# Returns which layout to render.
|
82
|
+
#
|
83
|
+
# You can set the layout you want to render inside your Spree configuration with the +:layout+ option.
|
84
|
+
#
|
85
|
+
# Default layout is: +app/views/spree/layouts/spree_application+
|
86
|
+
#
|
87
|
+
def get_layout
|
88
|
+
layout ||= Spree::Frontend::Config[:layout]
|
89
|
+
end
|
90
|
+
|
50
91
|
def store_etag
|
51
92
|
[
|
52
93
|
current_store,
|
@@ -14,7 +14,7 @@ module Spree
|
|
14
14
|
elsif current_store.logo.attached? && current_store.logo.image?
|
15
15
|
main_app.url_for(current_store.logo)
|
16
16
|
else
|
17
|
-
|
17
|
+
'logo/spree_50.png'
|
18
18
|
end
|
19
19
|
|
20
20
|
path = spree.respond_to?(:root_path) ? spree.root_path : main_app.root_path
|
@@ -373,6 +373,24 @@ module Spree
|
|
373
373
|
content_tag :span, nil, class: "flag-icon flag-icon-#{country_iso_code.downcase}"
|
374
374
|
end
|
375
375
|
|
376
|
+
def product_wysiwyg_editor_enabled?
|
377
|
+
defined?(Spree::Backend) && Spree::Backend::Config[:product_wysiwyg_editor_enabled]
|
378
|
+
end
|
379
|
+
|
380
|
+
def taxon_wysiwyg_editor_enabled?
|
381
|
+
defined?(Spree::Backend) && Spree::Backend::Config[:taxon_wysiwyg_editor_enabled]
|
382
|
+
end
|
383
|
+
|
384
|
+
# converts line breaks in product description into <p> tags (for html display purposes)
|
385
|
+
def product_description(product)
|
386
|
+
description = if Spree::Frontend::Config[:show_raw_product_description] || product_wysiwyg_editor_enabled?
|
387
|
+
product.description
|
388
|
+
else
|
389
|
+
product.description.to_s.gsub(/(.*?)\r?\n\r?\n/m, '<p>\1</p>')
|
390
|
+
end
|
391
|
+
description.blank? ? Spree.t(:product_has_no_description) : description
|
392
|
+
end
|
393
|
+
|
376
394
|
private
|
377
395
|
|
378
396
|
def formatted_price(value)
|
@@ -26,7 +26,7 @@ module Spree
|
|
26
26
|
DEPRECATION
|
27
27
|
|
28
28
|
@spree_nav_cache_key = begin
|
29
|
-
keys = base_cache_key + [current_store, spree_navigation_data_cache_key,
|
29
|
+
keys = base_cache_key + [current_store, spree_navigation_data_cache_key, stores&.cache_key_with_version, section]
|
30
30
|
Digest::MD5.hexdigest(keys.join('-'))
|
31
31
|
end
|
32
32
|
end
|
@@ -1,10 +1,16 @@
|
|
1
1
|
module Spree
|
2
2
|
class FrontendConfiguration < Preferences::Configuration
|
3
|
+
preference :additional_filters_partials, :array, default: %w()
|
4
|
+
preference :always_put_site_name_in_title, :boolean, default: true
|
3
5
|
preference :coupon_codes_enabled, :boolean, default: true # Determines if we show coupon code form at cart and checkout
|
4
6
|
preference :http_cache_enabled, :boolean, default: true
|
7
|
+
preference :layout, :string, default: 'spree/layouts/spree_application'
|
5
8
|
preference :locale, :string, default: nil
|
6
9
|
preference :products_filters, :array, default: %w(keywords price sort_by)
|
7
|
-
preference :additional_filters_partials, :array, default: %w()
|
8
10
|
preference :remember_me_enabled, :boolean, default: true
|
11
|
+
preference :shipping_instructions, :boolean, default: false # Request instructions/info for shipping
|
12
|
+
preference :show_raw_product_description, :boolean, default: false
|
13
|
+
preference :show_store_selector, :boolean, default: false
|
14
|
+
preference :title_site_name_separator, :string, default: '-' # When always_put_site_name_in_title is true, insert a separator character before the site name in the title
|
9
15
|
end
|
10
16
|
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require 'uri'
|
2
|
+
|
3
|
+
module Spree
|
4
|
+
class BuildLocalizedRedirectUrl
|
5
|
+
prepend Spree::ServiceModule::Base
|
6
|
+
|
7
|
+
LOCALE_REGEX = /^\/[A-Za-z]{2}\/|^\/[A-Za-z]{2}-[A-Za-z]{2}\/|^\/[A-Za-z]{2}$|^\/[A-Za-z]{2}-[A-Za-z]{2}$/.freeze
|
8
|
+
|
9
|
+
SUPPORTED_PATHS_REGEX = /\/(products|t\/|cart|checkout|addresses|content|pages)/.freeze
|
10
|
+
|
11
|
+
# rubocop:disable Lint/UnusedMethodArgument
|
12
|
+
def call(url:, locale:, default_locale: nil)
|
13
|
+
run :initialize_url_object
|
14
|
+
run :generate_new_path
|
15
|
+
run :append_locale_param
|
16
|
+
run :build_url
|
17
|
+
end
|
18
|
+
# rubocop:enable Lint/UnusedMethodArgument
|
19
|
+
|
20
|
+
protected
|
21
|
+
|
22
|
+
def initialize_url_object(url:, locale:, default_locale:)
|
23
|
+
success(
|
24
|
+
url: URI(url),
|
25
|
+
locale: locale,
|
26
|
+
default_locale_supplied: default_locale_supplied?(locale, default_locale)
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
def generate_new_path(url:, locale:, default_locale_supplied:)
|
31
|
+
unless supported_path?(url.path)
|
32
|
+
return success(
|
33
|
+
url: url,
|
34
|
+
locale: locale,
|
35
|
+
path: cleanup_path(url.path),
|
36
|
+
default_locale_supplied: default_locale_supplied,
|
37
|
+
locale_added_to_path: false
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
new_path = if default_locale_supplied
|
42
|
+
maches_locale_regex?(url.path) ? url.path.gsub(LOCALE_REGEX, '/') : url.path
|
43
|
+
else
|
44
|
+
maches_locale_regex?(url.path) ? url.path.gsub(LOCALE_REGEX, "/#{locale}/") : "/#{locale}#{url.path}"
|
45
|
+
end
|
46
|
+
|
47
|
+
success(
|
48
|
+
url: url,
|
49
|
+
locale: locale,
|
50
|
+
path: cleanup_path(new_path),
|
51
|
+
default_locale_supplied: default_locale_supplied,
|
52
|
+
locale_added_to_path: true
|
53
|
+
)
|
54
|
+
end
|
55
|
+
|
56
|
+
def append_locale_param(url:, locale:, path:, default_locale_supplied:, locale_added_to_path:)
|
57
|
+
return success(url: url, path: path, query: url.query) if locale_added_to_path
|
58
|
+
|
59
|
+
query_params = Rack::Utils.parse_nested_query(url.query)
|
60
|
+
|
61
|
+
if default_locale_supplied
|
62
|
+
query_params.delete('locale')
|
63
|
+
else
|
64
|
+
query_params.merge!('locale' => locale)
|
65
|
+
end
|
66
|
+
|
67
|
+
query_string = query_params.any? ? query_params.to_query : nil
|
68
|
+
|
69
|
+
success(url: url, path: path, query: query_string)
|
70
|
+
end
|
71
|
+
|
72
|
+
def build_url(url:, path:, query:)
|
73
|
+
localized_url = builder_class(url).build(host: url.host, port: url.port, path: path, query: query).to_s
|
74
|
+
success(localized_url)
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def supported_path?(path)
|
80
|
+
return true if path.blank? || path == '/' || maches_locale_regex?(path)
|
81
|
+
|
82
|
+
path.match(SUPPORTED_PATHS_REGEX)
|
83
|
+
end
|
84
|
+
|
85
|
+
def maches_locale_regex?(path)
|
86
|
+
path.match(LOCALE_REGEX)[0].gsub('/', '') if path.match(LOCALE_REGEX)
|
87
|
+
end
|
88
|
+
|
89
|
+
def default_locale_supplied?(locale, default_locale)
|
90
|
+
default_locale.present? && default_locale.to_s == locale.to_s
|
91
|
+
end
|
92
|
+
|
93
|
+
def cleanup_path(path)
|
94
|
+
path.chomp('/').gsub('//', '/')
|
95
|
+
end
|
96
|
+
|
97
|
+
def builder_class(url)
|
98
|
+
url.scheme == 'http' ? URI::HTTP : URI::HTTPS
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<h3 class="pt-4 font-weight-bold text-uppercase product-details-subtitle"><%= Spree.t(:description) %></h3>
|
2
2
|
|
3
|
-
<% if Spree::Config[:show_raw_product_description] || product_wysiwyg_editor_enabled? %>
|
3
|
+
<% if Spree::Frontend::Config[:show_raw_product_description] || product_wysiwyg_editor_enabled? %>
|
4
4
|
<div id="product-description-long" class="m-0 text-break product-description" data-hook="description">
|
5
5
|
<%= raw product_description(@product) %>
|
6
6
|
</div>
|
@@ -1,6 +1,8 @@
|
|
1
1
|
<% if try_spree_current_user %>
|
2
2
|
<%= link_to Spree.t(:my_account).upcase, spree.account_path, class: 'dropdown-item' if spree.respond_to?(:account_path) %>
|
3
|
-
|
3
|
+
<% if spree.respond_to(:admin_orders_path) %>
|
4
|
+
<%= 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) %>
|
5
|
+
<% end %>
|
4
6
|
<%= link_to Spree.t(:logout).upcase, spree_logout_path, class: 'dropdown-item', method: :get if defined?(spree_logout_path) %>
|
5
7
|
<% else %>
|
6
8
|
<%= link_to Spree.t(:login).upcase, spree_login_path, class: 'dropdown-item' if defined?(spree_login_path) %>
|