solidus_static_content 2.0.0 → 2.1.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 (64) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +11 -0
  3. data/.github/workflows/lint.yml +29 -0
  4. data/.github/workflows/test.yml +25 -0
  5. data/.gitignore +1 -0
  6. data/.standard.yml +6 -0
  7. data/CHANGELOG.md +31 -1
  8. data/Gemfile +37 -16
  9. data/Guardfile +9 -7
  10. data/README.md +20 -8
  11. data/Rakefile +2 -2
  12. data/app/helpers/spree/pages_helper.rb +9 -5
  13. data/app/models/solidus_static_content/permission_sets/page_display.rb +10 -0
  14. data/app/models/solidus_static_content/permission_sets/page_management.rb +10 -0
  15. data/app/models/spree/page.rb +38 -34
  16. data/app/overrides/solidus_static_content/pages_in_footer.rb +11 -0
  17. data/app/overrides/solidus_static_content/pages_in_header.rb +11 -0
  18. data/app/overrides/solidus_static_content/pages_in_sidebar.rb +11 -0
  19. data/bin/r +1 -0
  20. data/bin/rails +1 -0
  21. data/bin/rails-engine +2 -0
  22. data/bin/rails-sandbox +2 -1
  23. data/bin/sandbox +18 -25
  24. data/bin/sandbox_rails +1 -0
  25. data/config/locales/en.yml +1 -2
  26. data/config/routes.rb +5 -2
  27. data/db/migrate/20081216193152_create_pages.rb +2 -0
  28. data/db/migrate/20090625125735_extend_pages.rb +9 -8
  29. data/db/migrate/20090814113100_add_visible_to_pages.rb +5 -3
  30. data/db/migrate/20090814142845_add_default_true_to_visible_for_page.rb +4 -2
  31. data/db/migrate/20090829000527_add_index_for_page.rb +2 -1
  32. data/db/migrate/20091219021134_add_meta_fields_to_pages.rb +2 -0
  33. data/db/migrate/20100204105222_add_layout_to_pages.rb +3 -1
  34. data/db/migrate/20100323085528_add_show_in_sidebar_option_to_pages.rb +4 -2
  35. data/db/migrate/20110717103112_add_meta_title_to_page.rb +2 -0
  36. data/db/migrate/20120723144115_add_render_as_partial_for_layout_for_spree_pages.rb +8 -6
  37. data/db/migrate/20140926121757_add_pages_stores.rb +3 -3
  38. data/db/migrate/20180305193240_update_spree_page_position.rb +8 -6
  39. data/lib/controllers/backend/spree/admin/pages_controller.rb +17 -11
  40. data/lib/controllers/frontend/spree/static_content_controller.rb +21 -13
  41. data/lib/generators/solidus_static_content/install/install_generator.rb +33 -5
  42. data/lib/generators/solidus_static_content/install/templates/app/controllers/static_content_controller.rb +28 -0
  43. data/lib/generators/solidus_static_content/install/templates/app/views/static_content/show.html.erb +28 -0
  44. data/lib/solidus_static_content/engine.rb +25 -17
  45. data/lib/solidus_static_content/route_matcher.rb +10 -6
  46. data/lib/solidus_static_content/{factories.rb → testing_support/factories.rb} +1 -1
  47. data/lib/solidus_static_content/version.rb +1 -1
  48. data/lib/solidus_static_content.rb +4 -7
  49. data/solidus_static_content.gemspec +16 -17
  50. metadata +23 -40
  51. data/.circleci/config.yml +0 -35
  52. data/.rubocop.yml +0 -2
  53. data/app/overrides/pages_in_footer.rb +0 -5
  54. data/app/overrides/pages_in_header.rb +0 -5
  55. data/app/overrides/pages_in_sidebar.rb +0 -5
  56. data/spec/controllers/spree/admin/pages_controller_spec.rb +0 -11
  57. data/spec/controllers/spree/static_content_controller_spec.rb +0 -34
  58. data/spec/features/spree/admin/pages_spec.rb +0 -70
  59. data/spec/features/spree/static_content_spec.rb +0 -55
  60. data/spec/helpers/spree/page_helper_spec.rb +0 -14
  61. data/spec/lib/solidus_static_content/engine_spec.rb +0 -14
  62. data/spec/lib/solidus_static_content/route_matcher_spec.rb +0 -25
  63. data/spec/models/spree/page_spec.rb +0 -61
  64. data/spec/spec_helper.rb +0 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7a98d396588682a74ff937428388774a578806c8161da21195131e282244c0f9
4
- data.tar.gz: 6247ace2e49037b397ae2adaca3456cf121a5d0fd242d7d8f5fc15c742afadc3
3
+ metadata.gz: 36a00320fd2554bbb2414bc64b45691610c1fdd6446e026e57d162553a39d47b
4
+ data.tar.gz: d2480b136fc1ecc8f64cf8eebd20e3e5b597966df697e102bda3c4aecbab6e0a
5
5
  SHA512:
6
- metadata.gz: 4a7ec81a975abfc2d02b987787db16c99d33536525981fa0f30693d274bd519bc5e6721629f6cdae1dff8a1c30d33d323be79d23abb897a04b320130b38687d6
7
- data.tar.gz: 4fe5ad4a7eae624705fd593d604c5bef9ac44ec91f3de12f5bd9293dc71086ad8b975fef2ef35f31b7d6b44cce8949091f2b543d6a07006ee0cf2dd7e0531664
6
+ metadata.gz: 33d3223b1fe7f2aebd01751af23414834c0dc02edf4d22a29a80fffc7b0043a9138abd3dca03149160abec35e3aaeebfd2e35732d1ea77dd0d348cbcfb8e6f15
7
+ data.tar.gz: f4fdf74889347f53dd93ac6d441bd813c36b97eb145f312c18afa460a1ab013a232766b895ed655e59fe1dfe8e7a015f0a512e09f8b97ee1f40e60d0389d7d28
@@ -0,0 +1,11 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ open-pull-requests-limit: 10
8
+ ignore:
9
+ - dependency-name: solidus_core
10
+ versions:
11
+ - 3.0.0.rc2
@@ -0,0 +1,29 @@
1
+ name: Lint
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+
9
+ concurrency:
10
+ group: lint-${{ github.ref_name }}
11
+ cancel-in-progress: ${{ github.ref_name != 'main' }}
12
+
13
+ permissions:
14
+ contents: read
15
+
16
+ jobs:
17
+ standardrb:
18
+ name: StandardRB
19
+ runs-on: ubuntu-24.04
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+ - name: Set up Ruby
23
+ uses: ruby/setup-ruby@v1
24
+ with:
25
+ ruby-version: "3.4"
26
+ bundler-cache: true
27
+ rubygems: latest
28
+ - name: Run StandardRB
29
+ run: bundle exec standardrb
@@ -0,0 +1,25 @@
1
+ name: Test
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+ schedule:
9
+ - cron: "0 0 * * 4" # every Thursday
10
+
11
+ concurrency:
12
+ group: test-${{ github.ref_name }}
13
+ cancel-in-progress: ${{ github.ref_name != 'main' }}
14
+
15
+ permissions:
16
+ contents: read
17
+
18
+ jobs:
19
+ rspec:
20
+ uses: solidusio/test-solidus-extension/.github/workflows/test.yml@main
21
+ with:
22
+ ruby_versions: '["3.4"]'
23
+ rails_versions: '["8.0", "7.2"]'
24
+ solidus_branches: '["v4.7"]'
25
+ databases: '["postgresql", "sqlite"]'
data/.gitignore CHANGED
@@ -18,3 +18,4 @@ spec/examples.txt
18
18
  .rvmrc
19
19
  .ruby-version
20
20
  .ruby-gemset
21
+ vendor
data/.standard.yml ADDED
@@ -0,0 +1,6 @@
1
+ parallel: true
2
+ format: progress
3
+ ruby_version: 3.1
4
+ ignore:
5
+ - 'spec/dummy/**/*'
6
+ - 'sandbox/**/*'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # Changelog
2
2
 
3
+ ## [v2.1.0](https://github.com/solidusio-contrib/solidus_static_content/tree/v2.1.0) (2026-08-25)
4
+
5
+ [Full Changelog](https://github.com/solidusio-contrib/solidus_static_content/compare/v2.0.0...v2.1.0)
6
+
7
+ **Closed issues:**
8
+
9
+ - Not compatible with Solidus 4 [\#87](https://github.com/solidusio-contrib/solidus_static_content/issues/87)
10
+ - Not compatible with Ruby 3.1.2 [\#85](https://github.com/solidusio-contrib/solidus_static_content/issues/85)
11
+ - Support for Ruby 3.0 [\#83](https://github.com/solidusio-contrib/solidus_static_content/issues/83)
12
+ - Dependabot can't resolve your Ruby dependency files [\#78](https://github.com/solidusio-contrib/solidus_static_content/issues/78)
13
+ - Prepare Solidus Static Content for Solidus 3.0 [\#75](https://github.com/solidusio-contrib/solidus_static_content/issues/75)
14
+ - Dependabot can't resolve your Ruby dependency files [\#74](https://github.com/solidusio-contrib/solidus_static_content/issues/74)
15
+ - Dependabot can't resolve your Ruby dependency files [\#73](https://github.com/solidusio-contrib/solidus_static_content/issues/73)
16
+ - wrong translation key [\#72](https://github.com/solidusio-contrib/solidus_static_content/issues/72)
17
+ - Version conflict on newest version \(deface compatibility\) [\#65](https://github.com/solidusio-contrib/solidus_static_content/issues/65)
18
+
19
+ **Merged pull requests:**
20
+
21
+ - Add privilege and category method to permission sets [\#93](https://github.com/solidusio-contrib/solidus_static_content/pull/93) ([sascha-karnatz](https://github.com/sascha-karnatz))
22
+ - Move to Standardrb [\#92](https://github.com/solidusio-contrib/solidus_static_content/pull/92) ([sascha-karnatz](https://github.com/sascha-karnatz))
23
+ - Run tests on GitHub [\#91](https://github.com/solidusio-contrib/solidus_static_content/pull/91) ([sascha-karnatz](https://github.com/sascha-karnatz))
24
+ - Add updated Menu Item for Solidus 4.2 [\#89](https://github.com/solidusio-contrib/solidus_static_content/pull/89) ([sascha-karnatz](https://github.com/sascha-karnatz))
25
+ - Restore solidus\_static\_content on Solidus 4.0 [\#88](https://github.com/solidusio-contrib/solidus_static_content/pull/88) ([JustShah](https://github.com/JustShah))
26
+ - Update to use forked solidus\_frontend when needed [\#84](https://github.com/solidusio-contrib/solidus_static_content/pull/84) ([waiting-for-dev](https://github.com/waiting-for-dev))
27
+ - English Translation Key Fix [\#82](https://github.com/solidusio-contrib/solidus_static_content/pull/82) ([QuintinAdam](https://github.com/QuintinAdam))
28
+ - Updates Gemspec to allow Ruby 3 [\#81](https://github.com/solidusio-contrib/solidus_static_content/pull/81) ([QuintinAdam](https://github.com/QuintinAdam))
29
+ - Upgrade to GitHub-native Dependabot [\#80](https://github.com/solidusio-contrib/solidus_static_content/pull/80) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
30
+ - Solidus version update to v3.0.0 [\#79](https://github.com/solidusio-contrib/solidus_static_content/pull/79) ([webhive](https://github.com/webhive))
31
+ - Scroll Update button into view before clicking [\#76](https://github.com/solidusio-contrib/solidus_static_content/pull/76) ([jarednorman](https://github.com/jarednorman))
32
+
3
33
  ## [v2.0.0](https://github.com/solidusio-contrib/solidus_static_content/tree/v2.0.0) (2020-06-05)
4
34
 
5
35
  [Full Changelog](https://github.com/solidusio-contrib/solidus_static_content/compare/v1.0.0...v2.0.0)
@@ -36,7 +66,7 @@
36
66
  **Closed issues:**
37
67
 
38
68
  - Couldn't find Spree::Page [\#33](https://github.com/solidusio-contrib/solidus_static_content/issues/33)
39
- - Spree::PagesHelper doesn't have `render\_snippet` method [\#25](https://github.com/solidusio-contrib/solidus_static_content/issues/25)
69
+ - Spree::PagesHelper doesn't have `render_snippet` method [\#25](https://github.com/solidusio-contrib/solidus_static_content/issues/25)
40
70
  - admin menu item 'Pages' still appears after logout [\#9](https://github.com/solidusio-contrib/solidus_static_content/issues/9)
41
71
  - Problem with solidus 2.1.0.beta1 and solidus\_static\_content [\#5](https://github.com/solidusio-contrib/solidus_static_content/issues/5)
42
72
  - DB Migration not working [\#4](https://github.com/solidusio-contrib/solidus_static_content/issues/4)
data/Gemfile CHANGED
@@ -1,26 +1,47 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source 'https://rubygems.org'
3
+ source "https://rubygems.org"
4
4
  git_source(:github) { |repo| "https://github.com/#{repo}.git" }
5
5
 
6
- branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
7
- gem 'solidus', github: 'solidusio/solidus', branch: branch
6
+ branch = ENV.fetch("SOLIDUS_BRANCH", "main")
7
+ gem "solidus", github: "solidusio/solidus", branch: branch
8
8
 
9
- # Needed to help Bundler figure out how to resolve dependencies,
10
- # otherwise it takes forever to resolve them.
11
- # See https://github.com/bundler/bundler/issues/6677
12
- gem 'rails', '>0.a'
9
+ # The solidus_frontend gem has been pulled out since v3.2
10
+ if branch >= "v3.2"
11
+ gem "solidus_frontend"
12
+ elsif branch == "main"
13
+ gem "solidus_frontend", github: "solidusio/solidus_frontend"
14
+ else
15
+ gem "solidus_frontend", github: "solidusio/solidus", branch: branch
16
+ end
17
+
18
+ rails_version = ENV.fetch("RAILS_VERSION", "~> 7.0")
19
+ # CI passes bare versions such as "8.0", which Bundler reads as an exact
20
+ # requirement that no released gem satisfies. Treat them as pessimistic instead.
21
+ rails_version = "~> #{rails_version}.0" if rails_version.match?(/\A\d+\.\d+\z/)
22
+ gem "rails", rails_version
23
+
24
+ # Extract the minimum Rails version from the version requirement.
25
+ # For example, both "~> 7.0" and ">= 7.0" translate to a minimum of "7.0".
26
+ rails_req = Gem::Requirement.new(rails_version)
27
+ min_rails_version = rails_req.requirements.map(&:last).min || Gem::Version.new("0")
13
28
 
14
- # Provides basic authentication functionality for testing parts of your engine
15
- gem 'solidus_auth_devise'
29
+ # Determine the sqlite3 version based on the minimum Rails version.
30
+ # If the minimum Rails version is less than 7.2, use "~> 1.4"; otherwise, use "~> 2.0".
31
+ sqlite_version =
32
+ if min_rails_version < Gem::Version.new("7.2")
33
+ "~> 1.4"
34
+ else
35
+ "~> 2.0"
36
+ end
16
37
 
17
- case ENV['DB']
18
- when 'mysql'
19
- gem 'mysql2'
20
- when 'postgresql'
21
- gem 'pg'
38
+ case ENV.fetch("DB", nil)
39
+ when "mysql"
40
+ gem "mysql2"
41
+ when "postgresql"
42
+ gem "pg"
22
43
  else
23
- gem 'sqlite3'
44
+ gem "sqlite3", sqlite_version
24
45
  end
25
46
 
26
47
  gemspec
@@ -30,4 +51,4 @@ gemspec
30
51
  #
31
52
  # We use `send` instead of calling `eval_gemfile` to work around an issue with
32
53
  # how Dependabot parses projects: https://github.com/dependabot/dependabot-core/issues/1658.
33
- send(:eval_gemfile, 'Gemfile-local') if File.exist? 'Gemfile-local'
54
+ send(:eval_gemfile, "Gemfile-local") if File.exist? "Gemfile-local"
data/Guardfile CHANGED
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  guard "rspec", cmd: "bundle exec rspec" do
2
- watch("spec/spec_helper.rb") { "spec" }
3
- watch("config/routes.rb") { "spec/controllers" }
4
- watch("app/controllers/application_controller.rb") { "spec/controllers" }
5
- watch(%r{^spec/(.+)_spec\.rb$}) { |m| "spec/#{m[1]}_spec.rb"}
6
- watch(%r{^app/(.+)_decorator\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
7
- watch(%r{^(app|lib)/(.+)(\.rb|\.erb)$}) { |m| "spec/#{m[2]}_spec.rb" }
8
- watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb" }
4
+ watch("spec/spec_helper.rb") { "spec" }
5
+ watch("config/routes.rb") { "spec/controllers" }
6
+ watch("app/controllers/application_controller.rb") { "spec/controllers" }
7
+ watch(%r{^spec/(.+)_spec\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
8
+ watch(%r{^app/(.+)_decorator\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
9
+ watch(%r{^(app|lib)/(.+)(\.rb|\.erb)$}) { |m| "spec/#{m[2]}_spec.rb" }
10
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb" }
9
11
  end
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Solidus Static Content
2
2
 
3
- [![CircleCI](https://circleci.com/gh/solidusio-contrib/solidus_static_content.svg?style=svg)](https://circleci.com/gh/solidusio-contrib/solidus_static_content)
3
+ [![Test](https://github.com/solidusio-contrib/solidus_static_content/actions/workflows/test.yml/badge.svg)](https://github.com/solidusio-contrib/solidus_static_content/actions/workflows/test.yml)
4
4
 
5
5
  A fork of the [Spree extension](https://github.com/spree-contrib/spree_static_content) for
6
6
  compatibility with [Solidus](https://solidus.io).
@@ -15,15 +15,27 @@ Good, clean content management of pages for Solidus. You can use it to:
15
15
 
16
16
  Add solidus_static_content to your Gemfile:
17
17
 
18
- ```ruby
19
- gem 'solidus_static_content'
20
- ```
18
+ ### Starter Frontend
21
19
 
22
20
  Bundle your dependencies and run the installation generator:
23
21
 
24
22
  ```shell
25
23
  bundle
26
- bundle exec rails g solidus_static_content:install
24
+ bin/rails generate solidus_static_content:install --frontend=starter
25
+ ```
26
+
27
+ Please, be aware that the installation only works with the default
28
+ implementation of the starter frontend. Any customization to the files that
29
+ will be modified by the installer might break the installation procedure.
30
+ If that happens, try to adapt the installed code on top of the customizations
31
+ of the store.
32
+
33
+ ### Legacy Frontend
34
+
35
+ If you are using the legacy `solidus_frontend` gem, please run this command instead:
36
+
37
+ ```shell
38
+ bin/rails generate solidus_static_content:install
27
39
  ```
28
40
 
29
41
  ## Usage
@@ -74,17 +86,17 @@ bundle
74
86
  bin/rake
75
87
  ```
76
88
 
77
- To run [Rubocop](https://github.com/bbatsov/rubocop) static code analysis run
89
+ To run [Standard](https://github.com/standardrb/standard) static code analysis run
78
90
 
79
91
  ```shell
80
- bundle exec rubocop
92
+ bundle exec standardrb
81
93
  ```
82
94
 
83
95
  When testing your application's integration with this extension you may use its factories.
84
96
  Simply add this require statement to your spec_helper:
85
97
 
86
98
  ```ruby
87
- require 'solidus_static_content/factories'
99
+ require 'solidus_static_content/testing_support/factories'
88
100
  ```
89
101
 
90
102
  ### Running the sandbox
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'solidus_dev_support/rake_tasks'
3
+ require "solidus_dev_support/rake_tasks"
4
4
  SolidusDevSupport::RakeTasks.install
5
5
 
6
- task default: 'extension:specs'
6
+ task default: "extension:specs"
@@ -1,6 +1,10 @@
1
- module Spree::PagesHelper
2
- def render_snippet(slug)
3
- page = Spree::Page.find_by_slug(slug)
4
- raw page.body if page
1
+ # frozen_string_literal: true
2
+
3
+ module Spree
4
+ module PagesHelper
5
+ def render_snippet(slug)
6
+ page = Spree::Page.find_by(slug: slug)
7
+ raw page.body if page
8
+ end
5
9
  end
6
- end
10
+ end
@@ -3,6 +3,16 @@
3
3
  module SolidusStaticContent
4
4
  module PermissionSets
5
5
  class PageDisplay < Spree::PermissionSets::Base
6
+ class << self
7
+ def privilege
8
+ :display
9
+ end
10
+
11
+ def category
12
+ :page
13
+ end
14
+ end
15
+
6
16
  def activate!
7
17
  can [:display, :admin], Spree::Page
8
18
  end
@@ -3,6 +3,16 @@
3
3
  module SolidusStaticContent
4
4
  module PermissionSets
5
5
  class PageManagement < Spree::PermissionSets::Base
6
+ class << self
7
+ def privilege
8
+ :management
9
+ end
10
+
11
+ def category
12
+ :page
13
+ end
14
+ end
15
+
6
16
  def activate!
7
17
  can :manage, Spree::Page
8
18
  end
@@ -1,49 +1,53 @@
1
- class Spree::Page < ActiveRecord::Base
2
- acts_as_list
3
- default_scope -> { order("position ASC") }
1
+ # frozen_string_literal: true
4
2
 
5
- has_and_belongs_to_many :stores, join_table: 'spree_pages_stores'
3
+ module Spree
4
+ class Page < ApplicationRecord
5
+ acts_as_list
6
+ default_scope -> { order("position ASC") }
6
7
 
7
- validates_presence_of :title
8
- validates_presence_of [:slug, :body], :if => :not_using_foreign_link?
9
- validates_presence_of :layout, :if => :render_layout_as_partial?
10
- validates_presence_of :stores
8
+ has_and_belongs_to_many :stores, join_table: "spree_pages_stores"
11
9
 
12
- validates :slug, :uniqueness => true, :if => :not_using_foreign_link?
13
- validates :foreign_link, :uniqueness => true, :allow_blank => true
10
+ validates :title, presence: true
11
+ validates :slug, :body, presence: true, if: :not_using_foreign_link?
12
+ validates :layout, presence: {if: :render_layout_as_partial?}
13
+ validates :stores, presence: true
14
14
 
15
- before_validation :generate_slug, if: :title?
15
+ validates :slug, uniqueness: true, if: :not_using_foreign_link?
16
+ validates :foreign_link, uniqueness: true, allow_blank: true
16
17
 
17
- scope :visible, -> { where(:visible => true) }
18
- scope :header_links, -> { where(:show_in_header => true).visible }
19
- scope :footer_links, -> { where(:show_in_footer => true).visible }
20
- scope :sidebar_links, -> { where(:show_in_sidebar => true).visible }
21
- scope :ordered_by_position, -> { order(:position) }
18
+ before_validation :generate_slug, if: :title?
22
19
 
23
- scope :by_store, lambda { |store| joins(:stores).where("spree_pages_stores.store_id = ?", store) }
20
+ scope :visible, -> { where(visible: true) }
21
+ scope :header_links, -> { where(show_in_header: true).visible }
22
+ scope :footer_links, -> { where(show_in_footer: true).visible }
23
+ scope :sidebar_links, -> { where(show_in_sidebar: true).visible }
24
+ scope :ordered_by_position, -> { order(:position) }
24
25
 
25
- before_save :normalize_slug
26
+ scope :by_store, lambda { |store| joins(:stores).where("spree_pages_stores.store_id = ?", store) }
26
27
 
27
- def link
28
- foreign_link.blank? ? slug : foreign_link
29
- end
28
+ before_save :normalize_slug
30
29
 
31
- def meta_title
32
- super.presence || title
33
- end
30
+ def link
31
+ foreign_link.presence || slug
32
+ end
34
33
 
35
- private
34
+ def meta_title
35
+ super.presence || title
36
+ end
36
37
 
37
- def normalize_slug
38
- # ensure that all slugs start with a slash
39
- slug.prepend('/') if not_using_foreign_link? and not slug.start_with? '/'
40
- end
38
+ private
41
39
 
42
- def not_using_foreign_link?
43
- foreign_link.blank?
44
- end
40
+ def normalize_slug
41
+ # ensure that all slugs start with a slash
42
+ slug.prepend("/") if not_using_foreign_link? && (!slug.start_with? "/")
43
+ end
44
+
45
+ def not_using_foreign_link?
46
+ foreign_link.blank?
47
+ end
45
48
 
46
- def generate_slug
47
- self.slug ||= title.parameterize
49
+ def generate_slug
50
+ self.slug ||= title.parameterize
51
+ end
48
52
  end
49
53
  end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SolidusStaticContent
4
+ module PagesInFooter
5
+ Deface::Override.new(virtual_path: "spree/shared/_footer",
6
+ name: "pages_in_footer",
7
+ insert_bottom: "#footer-right",
8
+ partial: "spree/static_content/static_content_footer",
9
+ disabled: false)
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SolidusStaticContent
4
+ module PagesInHeader
5
+ Deface::Override.new(virtual_path: "spree/shared/_main_nav_bar",
6
+ name: "pages_in_header",
7
+ insert_bottom: "#main-nav-bar",
8
+ partial: "spree/static_content/static_content_header",
9
+ disabled: false)
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SolidusStaticContent
4
+ module PagesInSidebar
5
+ Deface::Override.new(virtual_path: "spree/shared/_sidebar",
6
+ name: "pages_in_sidebar",
7
+ insert_bottom: "#sidebar",
8
+ partial: "spree/static_content/static_content_sidebar",
9
+ disabled: false)
10
+ end
11
+ end
data/bin/r CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  warn %{
4
5
  DEPRECATION: bin/r has been replaced by bin/rails-engine, please use that
data/bin/rails CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  if %w[g generate].include? ARGV.first
4
5
  exec "#{__dir__}/rails-engine", *ARGV
data/bin/rails-engine CHANGED
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
2
4
  # This command will automatically be run when you run "rails" with Rails gems
3
5
  # installed from the root of your application.
4
6
 
data/bin/rails-sandbox CHANGED
@@ -1,11 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  app_root = 'sandbox'
4
5
 
5
6
  unless File.exist? "#{app_root}/bin/rails"
6
7
  warn 'Creating the sandbox app...'
7
8
  Dir.chdir "#{__dir__}/.." do
8
- system "#{__dir__}/sandbox" or begin # rubocop:disable Style/AndOr
9
+ system "#{__dir__}/sandbox" or begin
9
10
  warn 'Automatic creation of the sandbox app failed'
10
11
  exit 1
11
12
  end
data/bin/sandbox CHANGED
@@ -22,19 +22,19 @@ if [ ! -z $SOLIDUS_BRANCH ]
22
22
  then
23
23
  BRANCH=$SOLIDUS_BRANCH
24
24
  else
25
- BRANCH="master"
25
+ BRANCH="main"
26
26
  fi
27
27
 
28
28
  extension_name="solidus_static_content"
29
29
 
30
30
  # Stay away from the bundler env of the containing extension.
31
31
  function unbundled {
32
- ruby -rbundler -e'b = proc {system *ARGV}; Bundler.respond_to?(:with_unbundled_env) ? Bundler.with_unbundled_env(&b) : Bundler.with_clean_env(&b)' -- $@
32
+ ruby -rbundler -e'b = proc {system *ARGV}; Bundler.respond_to?(:with_unbundled_env) ? Bundler.with_unbundled_env(&b) : Bundler.with_clean_env(&b)' -- "$@"
33
33
  }
34
34
 
35
35
  rm -rf ./sandbox
36
- unbundled bundle exec rails new sandbox --database="$RAILSDB" \
37
- --skip-bundle \
36
+ rails new sandbox \
37
+ --database="$RAILSDB" \
38
38
  --skip-git \
39
39
  --skip-keeps \
40
40
  --skip-rc \
@@ -47,37 +47,30 @@ if [ ! -d "sandbox" ]; then
47
47
  exit 1
48
48
  fi
49
49
 
50
+ # 🔥 Fix for Sprockets error: Ensure the manifest.js file exists
51
+ mkdir -p sandbox/app/assets/config
52
+ cat <<EOF > sandbox/app/assets/config/manifest.js
53
+ //= link_tree ../images
54
+ //= link_directory ../javascripts .js
55
+ //= link_directory ../stylesheets .css
56
+ EOF
57
+
50
58
  cd ./sandbox
51
59
  cat <<RUBY >> Gemfile
52
- gem 'solidus', github: 'solidusio/solidus', branch: '$BRANCH'
53
- gem 'solidus_auth_devise', '>= 2.1.0'
54
- gem 'rails-i18n'
55
- gem 'solidus_i18n'
56
-
57
- gem '$extension_name', path: '..'
58
-
59
60
  group :test, :development do
60
61
  platforms :mri do
61
- gem 'pry-byebug'
62
+ gem 'pry'
62
63
  end
63
64
  end
64
65
  RUBY
65
-
66
- unbundled bundle install --gemfile Gemfile
67
-
66
+ unbundled bundle add solidus --github solidusio/solidus --branch "${BRANCH:-main}" --version '> 0.a'
68
67
  unbundled bundle exec rake db:drop db:create
69
-
70
- unbundled bundle exec rails generate spree:install \
71
- --auto-accept \
72
- --user_class=Spree::User \
73
- --enforce_available_locales=true \
74
- --with-authentication=false \
75
- $@
76
-
77
- unbundled bundle exec rails generate solidus:auth:install
68
+ unbundled bundle exec rails generate solidus:install --payment-method=none --auto-accept "$@"
69
+ unbundled bundle add ${extension_name} --path '../'
70
+ unbundled bundle exec rails generate $extension_name:install --frontend=starter --auto-run-migrations
78
71
 
79
72
  echo
80
- echo "🚀 Sandbox app successfully created for $extension_name!"
73
+ echo "🚀 Sandbox app successfully created for ${extension_name}!"
81
74
  echo "🚀 Using $RAILSDB and Solidus $BRANCH"
82
75
  echo "🚀 Use 'export DB=[postgres|mysql|sqlite]' to control the DB adapter"
83
76
  echo "🚀 Use 'export SOLIDUS_BRANCH=<BRANCH-NAME>' to control the Solidus version"
data/bin/sandbox_rails CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  warn %{
4
5
  DEPRECATION: bin/sandbox_rails has been replaced by bin/rails-sandbox, please
@@ -24,11 +24,10 @@ en:
24
24
  one: Page
25
25
  other: Pages
26
26
  spree:
27
- stores: Stores
28
27
  admin:
29
28
  tab:
30
29
  pages: Pages
31
- back_to_pages: "Back to static pages list"
30
+ back_to_static_pages_list: "Back to static pages list"
32
31
  page: Page
33
32
  pages: Pages
34
33
  stores: Stores
data/config/routes.rb CHANGED
@@ -9,7 +9,10 @@ Spree::Core::Engine.routes.draw do
9
9
  end
10
10
  end
11
11
 
12
- constraints(SolidusStaticContent::RouteMatcher) do
13
- get '/(*path)', :to => 'static_content#show', :as => 'static'
12
+ # Check if the layout is not the default layout to avoid conflicts with the starter_frontend routes
13
+ if Spree::Config.layout != "layouts/storefront"
14
+ constraints(SolidusStaticContent::RouteMatcher) do
15
+ get "/(*path)", to: "static_content#show", as: "static"
16
+ end
14
17
  end
15
18
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class CreatePages < SolidusSupport::Migration[4.2]
2
4
  def self.up
3
5
  create_table :spree_pages do |t|