solidus_frontend 4.8.0 → 4.9.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a3f3ea9e774d727a0c12a9755ed0f3c1405e3b3d761f215caa1c08cdff868394
4
- data.tar.gz: 559c880062f70704a1d3729b51580c83898ee931cb26f6ac6996bb6592aabac9
3
+ metadata.gz: 7c7fb5e9af01bc82325aeaa292b5745446b7c94d544b36a9e026d4df1afdf40f
4
+ data.tar.gz: f690ae2c57089fed44797f8a8f3e3dee1e60bccc054dd497ff9ad5420545762e
5
5
  SHA512:
6
- metadata.gz: f2abf12cdad00968f8967e9d634c715a01469990e6cedf9b7bb2f1e21325250e12b1caf750cdca5593a566b1236d14209b118201533954ed6fdedb438fddd332
7
- data.tar.gz: 9ad28935908e0e5780056bfaa8168a7c670249d609fe0cc1197154414832943d9812868d3a5c88af8d8a0b2926080894ee3aef06cd0a185d94a6c507b5ca11b7
6
+ metadata.gz: 2cb78da9bc2a773e5ea3c82e9903b3241338fa73c3fc5273656be87fcc44a1c263863056b4829ed5a630591d1caf530d0d5df6271f4576bcd833079b89c41497
7
+ data.tar.gz: 17f7e6d6840a00b4fcf11fb7475c30c173c422a463d104060b2ac710b2ce7a5a802984948ba620473fccc0f7b48b8a1ffdd86c18130f9b5d606b3f5cc9b21fe2
@@ -18,7 +18,16 @@ permissions:
18
18
 
19
19
  jobs:
20
20
  test:
21
+ strategy:
22
+ fail-fast: false
23
+ matrix:
24
+ rails_version: ["8.0.0", "8.1.4"]
25
+ solidus_branch: ["v4.8", "v4.7", "v4.6"]
26
+ exclude:
27
+ - solidus_branch: "v4.6"
28
+ rails_version: "8.1.4"
21
29
  uses: solidusio/test-solidus-extension/.github/workflows/test.yml@main
22
30
  with:
23
- solidus_branches: '["v4.7", "v4.6"]'
24
- ruby_versions: '["3.2", "3.4"]'
31
+ rails_versions: '["${{ matrix.rails_version }}"]'
32
+ solidus_branches: '["${{ matrix.solidus_branch }}"]'
33
+ ruby_versions: '["3.2", "3.4", "4.0"]'
@@ -12,8 +12,9 @@ module Spree
12
12
  end
13
13
 
14
14
  def cart_link
15
- render partial: 'spree/shared/link_to_cart'
16
- fresh_when(current_order, template: 'spree/shared/_link_to_cart')
15
+ if stale?(current_order, template: 'spree/shared/_link_to_cart')
16
+ render partial: 'spree/shared/link_to_cart'
17
+ end
17
18
  end
18
19
 
19
20
  private
@@ -0,0 +1,20 @@
1
+ Copyright 2012 Denis Ivanov
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/deprecation'
4
+
5
+ module CanonicalRails
6
+ Deprecation = ActiveSupport::Deprecation.new('1.0', 'CanonicalRails')
7
+ end
@@ -0,0 +1,86 @@
1
+ module CanonicalRails
2
+ module TagHelper
3
+ def trailing_slash_needed?
4
+ request.params.key?('action') && CanonicalRails.sym_collection_actions.include?(request.params['action'].to_sym)
5
+ end
6
+
7
+ # Leave force_trailing_slash as nil to get the original behavior of trailing_slash_if_needed
8
+ def trailing_slash_config(force_trailing_slash = nil)
9
+ if force_trailing_slash
10
+ "/"
11
+ elsif force_trailing_slash.nil?
12
+ trailing_slash_if_needed
13
+ end
14
+ end
15
+
16
+ def trailing_slash_if_needed
17
+ "/" if trailing_slash_needed?
18
+ end
19
+
20
+ def path_without_extension
21
+ return '' if request.path == '/'
22
+
23
+ request.path.sub(/\.\w{3,4}$/, '')
24
+ end
25
+
26
+ def canonical_protocol
27
+ CanonicalRails.protocol || request.protocol
28
+ end
29
+
30
+ def canonical_host
31
+ CanonicalRails.host || request.host
32
+ end
33
+
34
+ def canonical_port
35
+ (CanonicalRails.port || request.port).to_i
36
+ end
37
+
38
+ def canonical_href(host = canonical_host, port = canonical_port, force_trailing_slash = nil)
39
+ default_ports = { 'https://' => 443, 'http://' => 80 }
40
+ port = port.present? && port.to_i != default_ports[canonical_protocol] ? ":#{port}" : ''
41
+ raw "#{canonical_protocol}#{host}#{port}#{path_without_extension}#{trailing_slash_config(force_trailing_slash)}#{allowed_query_string}"
42
+ end
43
+
44
+ def canonical_path(force_trailing_slash = nil)
45
+ raw "#{path_without_extension}#{trailing_slash_config(force_trailing_slash)}#{allowed_query_string}"
46
+ end
47
+
48
+ def canonical_tag(host = canonical_host, port = canonical_port, force_trailing_slash = nil)
49
+ canonical_url = canonical_href(host, port, force_trailing_slash)
50
+ capture do
51
+ if CanonicalRails.opengraph_url
52
+ concat tag(:meta, property: 'og:url', content: canonical_url)
53
+ end
54
+ concat tag(:link, href: canonical_url, rel: :canonical)
55
+ end
56
+ end
57
+
58
+ def allowed_params
59
+ selected_params = params.select do |key, value|
60
+ value.present? && CanonicalRails.sym_allowed_parameters.include?(key.to_sym)
61
+ end
62
+
63
+ selected_params.respond_to?(:to_unsafe_h) ? selected_params.to_unsafe_h : selected_params.to_h
64
+ end
65
+
66
+ def allowed_query_string
67
+ # Rack 1.4.5 fails to handle params that are not strings
68
+ # So if
69
+ # my_hash = { "a" => 1, "b" => 2}
70
+ # Rack::Utils.build_nested_query(my_hash) would return
71
+ # "a&b"
72
+ # Rack 1.4.5 did not have a test case for this scenario
73
+ # https://github.com/rack/rack/blob/9939d40a5e23dcb058751d1029b794aa2f551900/test/spec_utils.rb#L222
74
+ # Rack 1.6.0 has it
75
+ # https://github.com/rack/rack/blob/65a7104b6b3e9ecd8f33c63a478ab9a33a103507/test/spec_utils.rb#L251
76
+ parameters = allowed_params
77
+ "?" + Rack::Utils.build_nested_query(convert_numeric_params(parameters)) if parameters.present?
78
+ end
79
+
80
+ private
81
+
82
+ def convert_numeric_params(params_hash)
83
+ Hash[params_hash.map { |k, v| v.is_a?(Numeric) ? [k, v.to_s] : [k, v] }]
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,49 @@
1
+ require "canonical-rails/deprecation"
2
+ require "canonical-rails/tag_helper"
3
+
4
+ module CanonicalRails
5
+
6
+ # Default way to setup CanonicalRails. Run `rails g canonical_rails:install` to create
7
+ # a fresh initializer with all configuration values.
8
+ #
9
+ # the config\setup concept politely observed at and borrowed from Devise: https://github.com/plataformatec/devise/blob/master/lib/devise.rb
10
+
11
+ def self.setup
12
+ yield self
13
+ end
14
+
15
+ mattr_accessor :host
16
+ @@host = nil
17
+
18
+ mattr_accessor :port
19
+ @@port = nil
20
+
21
+ mattr_accessor :protocol
22
+ @@protocol = nil
23
+
24
+ mattr_accessor :collection_actions
25
+ @@collection_actions = [:index]
26
+
27
+ # @deprecated: use config.allowed_parameters instead
28
+ mattr_accessor :whitelisted_parameters
29
+ @@whitelisted_parameters = []
30
+
31
+ mattr_accessor :allowed_parameters
32
+ @@allowed_parameters = []
33
+
34
+ mattr_accessor :opengraph_url
35
+ @@opengraph_url = false
36
+
37
+ def self.sym_collection_actions
38
+ @@sym_collection_actions ||= self.collection_actions.map(&:to_sym)
39
+ end
40
+
41
+ def self.sym_allowed_parameters
42
+ @@sym_allowed_parameters ||= if self.whitelisted_parameters.empty?
43
+ self.allowed_parameters.map(&:to_sym)
44
+ else
45
+ CanonicalRails::Deprecation.warn('config.whitelisted_parameters is deprecated, please use config.allowed_parameters instead.')
46
+ self.whitelisted_parameters.map(&:to_sym)
47
+ end
48
+ end
49
+ end
@@ -14,6 +14,12 @@ module Spree
14
14
  config.after_initialize do
15
15
  Spree::Frontend::Config.check_load_defaults_called('Spree::Frontend::Config')
16
16
  end
17
+
18
+ initializer "canonical_rails.add_helpers" do |app|
19
+ ActiveSupport.on_load(:action_view) do
20
+ self.include CanonicalRails::TagHelper
21
+ end
22
+ end
17
23
  end
18
24
  end
19
25
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Spree
4
4
  module Frontend
5
- VERSION = "4.8.0"
5
+ VERSION = "4.9.1"
6
6
 
7
7
  def self.version
8
8
  VERSION
@@ -36,7 +36,6 @@ Gem::Specification.new do |s|
36
36
  s.add_dependency 'solidus_api', '>= 3.2.0.alpha'
37
37
  s.add_dependency 'solidus_core', '>= 3.2.0.alpha'
38
38
 
39
- s.add_dependency 'canonical-rails', '~> 0.2.10'
40
39
  s.add_dependency 'font-awesome-rails', '~> 4.0'
41
40
  s.add_dependency 'jquery-rails'
42
41
  s.add_dependency 'kaminari', '~> 1.1'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_frontend
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.8.0
4
+ version: 4.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Solidus Team
@@ -37,20 +37,6 @@ dependencies:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
39
  version: 3.2.0.alpha
40
- - !ruby/object:Gem::Dependency
41
- name: canonical-rails
42
- requirement: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - "~>"
45
- - !ruby/object:Gem::Version
46
- version: 0.2.10
47
- type: :runtime
48
- prerelease: false
49
- version_requirements: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - "~>"
52
- - !ruby/object:Gem::Version
53
- version: 0.2.10
54
40
  - !ruby/object:Gem::Dependency
55
41
  name: font-awesome-rails
56
42
  requirement: !ruby/object:Gem::Requirement
@@ -363,6 +349,10 @@ files:
363
349
  - config/initializers/canonical_rails.rb
364
350
  - config/routes.rb
365
351
  - docker-compose.yml
352
+ - lib/canonical-rails.rb
353
+ - lib/canonical-rails/MIT-LICENSE
354
+ - lib/canonical-rails/deprecation.rb
355
+ - lib/canonical-rails/tag_helper.rb
366
356
  - lib/generators/solidus/views/override_generator.rb
367
357
  - lib/generators/solidus_frontend/install/install_generator.rb
368
358
  - lib/generators/solidus_frontend/install/templates/initializer.rb
@@ -401,7 +391,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
401
391
  - !ruby/object:Gem::Version
402
392
  version: 1.8.23
403
393
  requirements: []
404
- rubygems_version: 4.0.20
394
+ rubygems_version: 4.0.24
405
395
  specification_version: 4
406
396
  summary: 'Legacy storefront for the Solidus e-commerce platform. New Solidus installations
407
397
  use Solidus Storefront: https://github.com/solidusio/solidus/tree/main/storefront#readme'