solidus_static_content 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.circleci/config.yml +35 -0
- data/.gem_release.yml +5 -0
- data/.gitignore +17 -6
- data/.rspec +2 -3
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +80 -0
- data/Gemfile +26 -6
- data/{LICENSE.md → LICENSE} +0 -0
- data/README.md +81 -68
- data/Rakefile +4 -13
- data/app/assets/stylesheets/spree/frontend/solidus_static_content.css +7 -0
- data/app/assets/stylesheets/spree/frontend/spree_static_content.css +2 -7
- data/app/models/solidus_static_content/permission_sets/page_display.rb +11 -0
- data/app/models/solidus_static_content/permission_sets/page_management.rb +11 -0
- data/app/models/spree/page.rb +16 -21
- data/bin/console +17 -0
- data/bin/r +8 -0
- data/bin/rails +6 -6
- data/bin/rails-engine +13 -0
- data/bin/rails-sandbox +16 -0
- data/bin/rake +7 -0
- data/bin/sandbox +84 -0
- data/bin/sandbox_rails +8 -0
- data/bin/setup +8 -0
- data/config/locales/de.yml +7 -5
- data/config/locales/en.yml +9 -7
- data/config/locales/es-MX.yml +38 -0
- data/config/locales/es.yml +6 -5
- data/config/locales/et.yml +6 -5
- data/config/locales/fr.yml +7 -5
- data/config/locales/it.yml +6 -5
- data/config/locales/nl.yml +7 -5
- data/config/locales/pl.yml +6 -5
- data/config/locales/pt-BR.yml +6 -5
- data/config/locales/pt.yml +7 -5
- data/config/locales/ro.yml +11 -9
- data/config/locales/ru.yml +7 -5
- data/config/locales/sv.yml +7 -5
- data/config/routes.rb +9 -2
- data/db/migrate/20081216193152_create_pages.rb +1 -1
- data/db/migrate/20090625125735_extend_pages.rb +1 -1
- data/db/migrate/20090814113100_add_visible_to_pages.rb +1 -1
- data/db/migrate/20090814142845_add_default_true_to_visible_for_page.rb +1 -1
- data/db/migrate/20090829000527_add_index_for_page.rb +1 -1
- data/db/migrate/20091219021134_add_meta_fields_to_pages.rb +1 -1
- data/db/migrate/20100204105222_add_layout_to_pages.rb +1 -1
- data/db/migrate/20100323085528_add_show_in_sidebar_option_to_pages.rb +1 -1
- data/db/migrate/20110717103112_add_meta_title_to_page.rb +1 -1
- data/db/migrate/20120723144115_add_render_as_partial_for_layout_for_spree_pages.rb +1 -1
- data/db/migrate/20140926121757_add_pages_stores.rb +1 -1
- data/db/migrate/20180305193240_update_spree_page_position.rb +13 -0
- data/lib/controllers/backend/spree/admin/pages_controller.rb +16 -0
- data/{app/controllers → lib/controllers/frontend}/spree/static_content_controller.rb +7 -3
- data/lib/generators/solidus_static_content/install/install_generator.rb +7 -5
- data/lib/solidus_static_content.rb +6 -18
- data/lib/solidus_static_content/engine.rb +35 -0
- data/lib/solidus_static_content/factories.rb +18 -0
- data/lib/solidus_static_content/route_matcher.rb +11 -0
- data/lib/solidus_static_content/version.rb +5 -0
- data/lib/views/backend/spree/admin/pages/_form.html.erb +119 -0
- data/lib/views/backend/spree/admin/pages/edit.html.erb +32 -0
- data/lib/views/backend/spree/admin/pages/index.html.erb +68 -0
- data/lib/views/backend/spree/admin/pages/new.html.erb +31 -0
- data/lib/views/backend/spree/admin/shared/_pages_tabs.html.erb +9 -0
- data/{app/views → lib/views/frontend}/spree/static_content/_static_content_footer.html.erb +0 -0
- data/{app/views → lib/views/frontend}/spree/static_content/_static_content_header.html.erb +0 -0
- data/{app/views → lib/views/frontend}/spree/static_content/_static_content_list.html.erb +0 -0
- data/{app/views → lib/views/frontend}/spree/static_content/_static_content_sidebar.html.erb +1 -1
- data/lib/views/frontend/spree/static_content/show.html.erb +18 -0
- data/solidus_static_content.gemspec +36 -31
- data/spec/controllers/spree/admin/pages_controller_spec.rb +11 -0
- data/spec/controllers/{static_content_controller_spec.rb → spree/static_content_controller_spec.rb} +9 -12
- data/spec/features/{admin → spree/admin}/pages_spec.rb +8 -5
- data/spec/features/{static_content_spec.rb → spree/static_content_spec.rb} +6 -4
- data/spec/helpers/{page_helper_spec.rb → spree/page_helper_spec.rb} +0 -0
- data/spec/lib/solidus_static_content/engine_spec.rb +14 -0
- data/spec/lib/{spree_static.content_spec.rb → solidus_static_content/route_matcher_spec.rb} +4 -13
- data/spec/models/{page_spec.rb → spree/page_spec.rb} +22 -7
- data/spec/spec_helper.rb +17 -40
- metadata +85 -177
- data/.travis.yml +0 -21
- data/app/assets/javascripts/spree/backend/spree_static_content.js +0 -1
- data/app/assets/javascripts/spree/frontend/spree_static_content.js +0 -1
- data/app/assets/stylesheets/spree/backend/spree_static_content.css +0 -3
- data/app/controllers/spree/admin/pages_controller.rb +0 -3
- data/app/overrides/pages_in_menu.rb +0 -5
- data/app/views/spree/admin/pages/_form.html.erb +0 -98
- data/app/views/spree/admin/pages/edit.html.erb +0 -18
- data/app/views/spree/admin/pages/index.html.erb +0 -51
- data/app/views/spree/admin/pages/new.html.erb +0 -18
- data/app/views/spree/static_content/show.html.erb +0 -26
- data/lib/spree_static_content/engine.rb +0 -17
- data/spec/factories/page_factory.rb +0 -18
data/config/locales/pt-BR.yml
CHANGED
@@ -30,8 +30,9 @@ pt-BR:
|
|
30
30
|
back_to_static_pages_list: "Voltar à lista de páginas estáticas"
|
31
31
|
page: Página
|
32
32
|
pages: Páginas
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
33
|
+
stores: Lojas
|
34
|
+
editing_page: "Editando página"
|
35
|
+
link: Link
|
36
|
+
new_page: "Nova página"
|
37
|
+
static_pages: "Páginas estáticas"
|
38
|
+
add_one: Crie um
|
data/config/locales/pt.yml
CHANGED
@@ -30,8 +30,10 @@ pt:
|
|
30
30
|
back_to_static_pages_list: "Voltar à lista de páginas estáticas"
|
31
31
|
page: Página
|
32
32
|
pages: Páginas
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
33
|
+
stores: Lojas
|
34
|
+
new_page: "Nova página"
|
35
|
+
editing_page: "Editar página"
|
36
|
+
link: Link
|
37
|
+
new_page: "Nova página"
|
38
|
+
static_pages: "Páginas estáticas"
|
39
|
+
add_one: Crie um
|
data/config/locales/ro.yml
CHANGED
@@ -24,15 +24,17 @@ ro:
|
|
24
24
|
spree:
|
25
25
|
page: Pagină
|
26
26
|
pages: Pagine
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
27
|
+
stores: Magazine
|
28
|
+
new_page: Pagină nouă
|
29
|
+
static_pages: Pagini statice
|
30
|
+
static_pages_desc: Descrierea paginilor statice
|
31
|
+
new_page: Pagină nouă
|
32
|
+
editing_page: Editarea paginii
|
33
|
+
confirm_delete: Sunteți siguri că doriți să ștergeți această pagină?
|
34
|
+
link: Link
|
35
|
+
meta_title: Titlu meta
|
36
|
+
page_navigation_title: Pagini
|
37
|
+
add_one: Creeaza una
|
36
38
|
back_to_static_pages_list: Înapoi la lista de pagini
|
37
39
|
admin:
|
38
40
|
tab:
|
data/config/locales/ru.yml
CHANGED
@@ -27,11 +27,13 @@ ru:
|
|
27
27
|
spree:
|
28
28
|
page: "Страница"
|
29
29
|
pages: "Страницы"
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
30
|
+
stores: "магазины"
|
31
|
+
new_page: "Новая страница"
|
32
|
+
static_pages: "Статические страницы"
|
33
|
+
new_page: "Новая страница"
|
34
|
+
editing_page: "Редактирование страницы"
|
35
|
+
link: "Ссылка"
|
36
|
+
add_one: "Создай"
|
35
37
|
back_to_static_pages_list: "Назад к списку страниц"
|
36
38
|
admin:
|
37
39
|
tab:
|
data/config/locales/sv.yml
CHANGED
@@ -30,8 +30,10 @@ sv:
|
|
30
30
|
back_to_static_pages_list: "Tillbaka till listan med sidor"
|
31
31
|
page: Sida
|
32
32
|
pages: Sidor
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
33
|
+
stores: Butiker
|
34
|
+
new_page: "Ny sida"
|
35
|
+
editing_page: "Editera sidan"
|
36
|
+
link: Länk
|
37
|
+
new_page: "Ny sida"
|
38
|
+
static_pages: "Statiska sidor"
|
39
|
+
add_one: "Skapa en"
|
data/config/routes.rb
CHANGED
@@ -1,8 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
Spree::Core::Engine.routes.draw do
|
2
4
|
namespace :admin do
|
3
|
-
resources :pages
|
5
|
+
resources :pages do
|
6
|
+
collection do
|
7
|
+
post :update_positions
|
8
|
+
end
|
9
|
+
end
|
4
10
|
end
|
5
|
-
|
11
|
+
|
12
|
+
constraints(SolidusStaticContent::RouteMatcher) do
|
6
13
|
get '/(*path)', :to => 'static_content#show', :as => 'static'
|
7
14
|
end
|
8
15
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class AddRenderAsPartialForLayoutForSpreePages <
|
1
|
+
class AddRenderAsPartialForLayoutForSpreePages < SolidusSupport::Migration[4.2]
|
2
2
|
def up
|
3
3
|
unless column_exists? :spree_pages, :render_layout_as_partial
|
4
4
|
add_column :spree_pages, :render_layout_as_partial, :boolean, :default => false
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class UpdateSpreePagePosition < SolidusSupport::Migration[4.2]
|
2
|
+
def up
|
3
|
+
if column_exists?(:spree_pages, :position)
|
4
|
+
change_column :spree_pages, :position, :integer, default: 0
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
def down
|
9
|
+
if column_exists?(:spree_pages, :position)
|
10
|
+
change_column :spree_pages, :position, :boolean, default: false
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Spree::Admin::PagesController < Spree::Admin::ResourceController
|
2
|
+
private
|
3
|
+
|
4
|
+
# Set some default attributes
|
5
|
+
def build_resource
|
6
|
+
super.tap do |resource|
|
7
|
+
if resource.stores.blank?
|
8
|
+
resource.stores << Spree::Store.default
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def collection
|
14
|
+
super.ordered_by_position
|
15
|
+
end
|
16
|
+
end
|
@@ -1,11 +1,15 @@
|
|
1
1
|
class Spree::StaticContentController < Spree::StoreController
|
2
|
-
rescue_from ActiveRecord::RecordNotFound, :with => :render_404
|
3
|
-
|
4
2
|
helper 'spree/products'
|
5
3
|
layout :determine_layout
|
6
4
|
|
7
5
|
def show
|
8
|
-
@page = Spree::Page.by_store(current_store).visible.find_by_slug!(request.
|
6
|
+
@page = Spree::Page.by_store(current_store).visible.find_by_slug!(request.path_info)
|
7
|
+
|
8
|
+
# Assign static_content to let solidus recognize it as the current
|
9
|
+
# controller resource, this is used by meta tags and in other places.
|
10
|
+
@static_content = @page
|
11
|
+
|
12
|
+
@taxonomies = Spree::Taxonomy.includes(root: :children)
|
9
13
|
end
|
10
14
|
|
11
15
|
private
|
@@ -1,22 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module SolidusStaticContent
|
2
4
|
module Generators
|
3
5
|
class InstallGenerator < Rails::Generators::Base
|
4
6
|
class_option :auto_run_migrations, type: :boolean, default: false
|
5
7
|
|
6
8
|
def add_stylesheets
|
7
|
-
inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', " *= require spree/frontend/
|
9
|
+
inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', " *= require spree/frontend/solidus_static_content\n", before: %r{\*/}, verbose: true # rubocop:disable Metrics/LineLength
|
8
10
|
end
|
9
11
|
|
10
12
|
def add_migrations
|
11
|
-
run '
|
13
|
+
run 'bin/rails railties:install:migrations FROM=solidus_static_content'
|
12
14
|
end
|
13
15
|
|
14
16
|
def run_migrations
|
15
|
-
run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask
|
17
|
+
run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]')) # rubocop:disable Metrics/LineLength
|
16
18
|
if run_migrations
|
17
|
-
run '
|
19
|
+
run 'bin/rails db:migrate'
|
18
20
|
else
|
19
|
-
puts 'Skipping
|
21
|
+
puts 'Skipping bin/rails db:migrate, don\'t forget to run it!' # rubocop:disable Rails/Output
|
20
22
|
end
|
21
23
|
end
|
22
24
|
end
|
@@ -1,21 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'solidus_core'
|
2
|
-
require '
|
3
|
-
require 'solidus_backend'
|
4
|
+
require 'solidus_support'
|
4
5
|
require 'deface'
|
5
|
-
require 'spree_static_content/engine'
|
6
|
-
require 'coffee_script'
|
7
|
-
require 'sass/rails'
|
8
|
-
|
9
|
-
module StaticPage
|
10
|
-
def self.remove_spree_mount_point(path)
|
11
|
-
regex = Regexp.new '\A' + Rails.application.routes.url_helpers.spree_path
|
12
|
-
path.sub( regex, '').split('?')[0]
|
13
|
-
end
|
14
|
-
end
|
15
6
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
!Spree::Page.visible.find_by_slug(request.path).nil?
|
20
|
-
end
|
21
|
-
end
|
7
|
+
require 'solidus_static_content/version'
|
8
|
+
require 'solidus_static_content/route_matcher'
|
9
|
+
require 'solidus_static_content/engine'
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spree/core'
|
4
|
+
require 'solidus_static_content'
|
5
|
+
|
6
|
+
module SolidusStaticContent
|
7
|
+
class Engine < Rails::Engine
|
8
|
+
include SolidusSupport::EngineExtensions
|
9
|
+
|
10
|
+
isolate_namespace ::Spree
|
11
|
+
|
12
|
+
engine_name 'solidus_static_content'
|
13
|
+
|
14
|
+
# use rspec for tests
|
15
|
+
config.generators do |g|
|
16
|
+
g.test_framework :rspec
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.menu_item
|
20
|
+
@menu_item ||= Spree::Backend::Config.class::MenuItem.new(
|
21
|
+
[:pages],
|
22
|
+
'file-text',
|
23
|
+
condition: -> { can?(:admin, Spree::Page) },
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.activate_menu_items
|
28
|
+
return if Spree::Backend::Config.menu_items.include?(menu_item)
|
29
|
+
|
30
|
+
Spree::Backend::Config.menu_items << menu_item
|
31
|
+
end
|
32
|
+
|
33
|
+
config.to_prepare(&method(:activate_menu_items))
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
FactoryBot.define do
|
4
|
+
factory :page, class: Spree::Page do
|
5
|
+
sequence(:title) { |n| "Page #{n}" }
|
6
|
+
body { 'This is the body of the page' }
|
7
|
+
|
8
|
+
sequence(:slug) { |n| "/page#{n}" }
|
9
|
+
|
10
|
+
trait :with_foreign_link do
|
11
|
+
foreign_link do
|
12
|
+
"http://example.com"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
stores { [build(:store)] }
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module SolidusStaticContent::RouteMatcher
|
2
|
+
EXCLUDED_PATHS = /^\/+(admin|account|cart|checkout|content|login|pg\/|orders|products|s\/|session|signup|shipments|states|t\/|tax_categories|user)+/
|
3
|
+
|
4
|
+
def self.matches?(request)
|
5
|
+
path = request.path_info
|
6
|
+
|
7
|
+
return false if EXCLUDED_PATHS.match? path
|
8
|
+
|
9
|
+
Spree::Page.visible.where(slug: path).exists?
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
<div data-hook='admin_page_form_fields'>
|
2
|
+
<div class='row'>
|
3
|
+
<div class='col-12'>
|
4
|
+
<%= f.field_container :title do %>
|
5
|
+
<%= f.label :title, class: 'required' %>
|
6
|
+
<%= f.text_field :title, required: true, class: 'fullwidth title' %>
|
7
|
+
<%= f.error_message_on :title %>
|
8
|
+
<% end %>
|
9
|
+
</div>
|
10
|
+
|
11
|
+
<div class='col-12'>
|
12
|
+
<%= f.field_container :slug do %>
|
13
|
+
<%= f.label :slug, class: 'required' %>
|
14
|
+
<%= f.text_field :slug, required: true, class: 'fullwidth title' %>
|
15
|
+
<%= f.error_message_on :slug %>
|
16
|
+
<% end %>
|
17
|
+
</div>
|
18
|
+
|
19
|
+
<div class='col-12'>
|
20
|
+
<%= f.field_container :body do %>
|
21
|
+
<%= f.label :body, class: 'required' %>
|
22
|
+
<%= f.text_area :body, class: 'fullwidth', rows: 12 %>
|
23
|
+
<%= f.error_message_on :body %>
|
24
|
+
<% end %>
|
25
|
+
</div>
|
26
|
+
</div>
|
27
|
+
|
28
|
+
<div class='row'>
|
29
|
+
<div class='col-6'>
|
30
|
+
<%= f.field_container :layout do %>
|
31
|
+
<%= f.label :layout %>
|
32
|
+
<%= f.text_field :layout, class: 'fullwidth title' %>
|
33
|
+
<% end %>
|
34
|
+
</div>
|
35
|
+
|
36
|
+
<div class='col-6'>
|
37
|
+
<%= f.field_container :foreign_link do %>
|
38
|
+
<%= f.label :foreign_link %>
|
39
|
+
<%= f.text_field :foreign_link, class: 'fullwidth title' %>
|
40
|
+
<% end %>
|
41
|
+
</div>
|
42
|
+
</div>
|
43
|
+
|
44
|
+
<div class='row'>
|
45
|
+
<div class='col-2'>
|
46
|
+
<%= f.field_container :show_in_sidebar do %>
|
47
|
+
<%= f.check_box :show_in_sidebar %>
|
48
|
+
<%= f.label :show_in_sidebar %>
|
49
|
+
<% end %>
|
50
|
+
</div>
|
51
|
+
|
52
|
+
<div class='col-2'>
|
53
|
+
<%= f.field_container :show_in_header do %>
|
54
|
+
<%= f.check_box :show_in_header %>
|
55
|
+
<%= f.label :show_in_header %>
|
56
|
+
<% end %>
|
57
|
+
</div>
|
58
|
+
|
59
|
+
<div class='col-2'>
|
60
|
+
<%= f.field_container :show_in_footer do %>
|
61
|
+
<%= f.check_box :show_in_footer %>
|
62
|
+
<%= f.label :show_in_footer %>
|
63
|
+
<% end %>
|
64
|
+
</div>
|
65
|
+
|
66
|
+
<div class='col-2'>
|
67
|
+
<%= f.field_container :visible do %>
|
68
|
+
<%= f.check_box :visible %>
|
69
|
+
<%= f.label :visible %>
|
70
|
+
<% end %>
|
71
|
+
</div>
|
72
|
+
|
73
|
+
<div class='col-2'>
|
74
|
+
<%= f.field_container :render_layout_as_partial do %>
|
75
|
+
<%= f.check_box :render_layout_as_partial %>
|
76
|
+
<%= f.label :render_layout_as_partial %>
|
77
|
+
<% end %>
|
78
|
+
</div>
|
79
|
+
</div>
|
80
|
+
|
81
|
+
<div class='row'>
|
82
|
+
<div class='col-2'>
|
83
|
+
<%= f.field_container :stores do %>
|
84
|
+
<%= f.label :stores, t("spree.stores") %>
|
85
|
+
<br>
|
86
|
+
<% Spree::Store.all.each do |store| %>
|
87
|
+
<%= check_box_tag 'page[store_ids][]', store.id, @page.stores.include?(store) %>
|
88
|
+
<%= label_tag store.name %>
|
89
|
+
<% end %>
|
90
|
+
<% end %>
|
91
|
+
</div>
|
92
|
+
</div>
|
93
|
+
|
94
|
+
<div class='row'>
|
95
|
+
<div class='col-12'>
|
96
|
+
<%= f.field_container :meta_title do %>
|
97
|
+
<%= f.label :meta_title %>
|
98
|
+
<%= f.text_field :meta_title, class: 'fullwidth title' %>
|
99
|
+
<%= f.error_message_on :meta_title %>
|
100
|
+
<% end %>
|
101
|
+
</div>
|
102
|
+
|
103
|
+
<div class='col-12'>
|
104
|
+
<%= f.field_container :meta_keywords do %>
|
105
|
+
<%= f.label :meta_keywords %>
|
106
|
+
<%= f.text_field :meta_keywords, class: 'fullwidth title' %>
|
107
|
+
<%= f.error_message_on :meta_keywords %>
|
108
|
+
<% end %>
|
109
|
+
</div>
|
110
|
+
|
111
|
+
<div class='col-12'>
|
112
|
+
<%= f.field_container :meta_description do %>
|
113
|
+
<%= f.label :meta_description %>
|
114
|
+
<%= f.text_field :meta_description, class: 'fullwidth title' %>
|
115
|
+
<%= f.error_message_on :meta_description %>
|
116
|
+
<% end %>
|
117
|
+
</div>
|
118
|
+
</div>
|
119
|
+
</div>
|