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.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +11 -0
- data/.github/workflows/lint.yml +29 -0
- data/.github/workflows/test.yml +25 -0
- data/.gitignore +1 -0
- data/.standard.yml +6 -0
- data/CHANGELOG.md +31 -1
- data/Gemfile +37 -16
- data/Guardfile +9 -7
- data/README.md +20 -8
- data/Rakefile +2 -2
- data/app/helpers/spree/pages_helper.rb +9 -5
- data/app/models/solidus_static_content/permission_sets/page_display.rb +10 -0
- data/app/models/solidus_static_content/permission_sets/page_management.rb +10 -0
- data/app/models/spree/page.rb +38 -34
- data/app/overrides/solidus_static_content/pages_in_footer.rb +11 -0
- data/app/overrides/solidus_static_content/pages_in_header.rb +11 -0
- data/app/overrides/solidus_static_content/pages_in_sidebar.rb +11 -0
- data/bin/r +1 -0
- data/bin/rails +1 -0
- data/bin/rails-engine +2 -0
- data/bin/rails-sandbox +2 -1
- data/bin/sandbox +18 -25
- data/bin/sandbox_rails +1 -0
- data/config/locales/en.yml +1 -2
- data/config/routes.rb +5 -2
- data/db/migrate/20081216193152_create_pages.rb +2 -0
- data/db/migrate/20090625125735_extend_pages.rb +9 -8
- data/db/migrate/20090814113100_add_visible_to_pages.rb +5 -3
- data/db/migrate/20090814142845_add_default_true_to_visible_for_page.rb +4 -2
- data/db/migrate/20090829000527_add_index_for_page.rb +2 -1
- data/db/migrate/20091219021134_add_meta_fields_to_pages.rb +2 -0
- data/db/migrate/20100204105222_add_layout_to_pages.rb +3 -1
- data/db/migrate/20100323085528_add_show_in_sidebar_option_to_pages.rb +4 -2
- data/db/migrate/20110717103112_add_meta_title_to_page.rb +2 -0
- data/db/migrate/20120723144115_add_render_as_partial_for_layout_for_spree_pages.rb +8 -6
- data/db/migrate/20140926121757_add_pages_stores.rb +3 -3
- data/db/migrate/20180305193240_update_spree_page_position.rb +8 -6
- data/lib/controllers/backend/spree/admin/pages_controller.rb +17 -11
- data/lib/controllers/frontend/spree/static_content_controller.rb +21 -13
- data/lib/generators/solidus_static_content/install/install_generator.rb +33 -5
- data/lib/generators/solidus_static_content/install/templates/app/controllers/static_content_controller.rb +28 -0
- data/lib/generators/solidus_static_content/install/templates/app/views/static_content/show.html.erb +28 -0
- data/lib/solidus_static_content/engine.rb +25 -17
- data/lib/solidus_static_content/route_matcher.rb +10 -6
- data/lib/solidus_static_content/{factories.rb → testing_support/factories.rb} +1 -1
- data/lib/solidus_static_content/version.rb +1 -1
- data/lib/solidus_static_content.rb +4 -7
- data/solidus_static_content.gemspec +16 -17
- metadata +23 -40
- data/.circleci/config.yml +0 -35
- data/.rubocop.yml +0 -2
- data/app/overrides/pages_in_footer.rb +0 -5
- data/app/overrides/pages_in_header.rb +0 -5
- data/app/overrides/pages_in_sidebar.rb +0 -5
- data/spec/controllers/spree/admin/pages_controller_spec.rb +0 -11
- data/spec/controllers/spree/static_content_controller_spec.rb +0 -34
- data/spec/features/spree/admin/pages_spec.rb +0 -70
- data/spec/features/spree/static_content_spec.rb +0 -55
- data/spec/helpers/spree/page_helper_spec.rb +0 -14
- data/spec/lib/solidus_static_content/engine_spec.rb +0 -14
- data/spec/lib/solidus_static_content/route_matcher_spec.rb +0 -25
- data/spec/models/spree/page_spec.rb +0 -61
- data/spec/spec_helper.rb +0 -27
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 36a00320fd2554bbb2414bc64b45691610c1fdd6446e026e57d162553a39d47b
|
|
4
|
+
data.tar.gz: d2480b136fc1ecc8f64cf8eebd20e3e5b597966df697e102bda3c4aecbab6e0a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 33d3223b1fe7f2aebd01751af23414834c0dc02edf4d22a29a80fffc7b0043a9138abd3dca03149160abec35e3aaeebfd2e35732d1ea77dd0d348cbcfb8e6f15
|
|
7
|
+
data.tar.gz: f4fdf74889347f53dd93ac6d441bd813c36b97eb145f312c18afa460a1ab013a232766b895ed655e59fe1dfe8e7a015f0a512e09f8b97ee1f40e60d0389d7d28
|
|
@@ -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
data/.standard.yml
ADDED
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 `
|
|
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
|
|
3
|
+
source "https://rubygems.org"
|
|
4
4
|
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
|
5
5
|
|
|
6
|
-
branch = ENV.fetch(
|
|
7
|
-
gem
|
|
6
|
+
branch = ENV.fetch("SOLIDUS_BRANCH", "main")
|
|
7
|
+
gem "solidus", github: "solidusio/solidus", branch: branch
|
|
8
8
|
|
|
9
|
-
#
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
#
|
|
15
|
-
|
|
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
|
|
18
|
-
when
|
|
19
|
-
gem
|
|
20
|
-
when
|
|
21
|
-
gem
|
|
38
|
+
case ENV.fetch("DB", nil)
|
|
39
|
+
when "mysql"
|
|
40
|
+
gem "mysql2"
|
|
41
|
+
when "postgresql"
|
|
42
|
+
gem "pg"
|
|
22
43
|
else
|
|
23
|
-
gem
|
|
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,
|
|
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")
|
|
3
|
-
watch("config/routes.rb")
|
|
4
|
-
watch("app/controllers/application_controller.rb")
|
|
5
|
-
watch(%r{^spec/(.+)_spec\.rb$})
|
|
6
|
-
watch(%r{^app/(.+)_decorator\.rb$})
|
|
7
|
-
watch(%r{^(app|lib)/(.+)(\.rb|\.erb)$})
|
|
8
|
-
watch(%r{^app/controllers/(.+)_(controller)\.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
|
-
[](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
|
-
|
|
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
|
-
|
|
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 [
|
|
89
|
+
To run [Standard](https://github.com/standardrb/standard) static code analysis run
|
|
78
90
|
|
|
79
91
|
```shell
|
|
80
|
-
bundle exec
|
|
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,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
data/app/models/spree/page.rb
CHANGED
|
@@ -1,49 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
acts_as_list
|
|
3
|
-
default_scope -> { order("position ASC") }
|
|
1
|
+
# frozen_string_literal: true
|
|
4
2
|
|
|
5
|
-
|
|
3
|
+
module Spree
|
|
4
|
+
class Page < ApplicationRecord
|
|
5
|
+
acts_as_list
|
|
6
|
+
default_scope -> { order("position ASC") }
|
|
6
7
|
|
|
7
|
-
|
|
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
|
-
|
|
13
|
-
|
|
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
|
-
|
|
15
|
+
validates :slug, uniqueness: true, if: :not_using_foreign_link?
|
|
16
|
+
validates :foreign_link, uniqueness: true, allow_blank: true
|
|
16
17
|
|
|
17
|
-
|
|
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
|
-
|
|
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
|
-
|
|
26
|
+
scope :by_store, lambda { |store| joins(:stores).where("spree_pages_stores.store_id = ?", store) }
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
foreign_link.blank? ? slug : foreign_link
|
|
29
|
-
end
|
|
28
|
+
before_save :normalize_slug
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
def link
|
|
31
|
+
foreign_link.presence || slug
|
|
32
|
+
end
|
|
34
33
|
|
|
35
|
-
|
|
34
|
+
def meta_title
|
|
35
|
+
super.presence || title
|
|
36
|
+
end
|
|
36
37
|
|
|
37
|
-
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
47
|
-
|
|
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
data/bin/rails
CHANGED
data/bin/rails-engine
CHANGED
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
|
|
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="
|
|
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
|
-
|
|
37
|
-
--
|
|
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
|
|
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
|
|
71
|
-
|
|
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
data/config/locales/en.yml
CHANGED
data/config/routes.rb
CHANGED
|
@@ -9,7 +9,10 @@ Spree::Core::Engine.routes.draw do
|
|
|
9
9
|
end
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
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
|