solidus_static_content 1.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 (105) hide show
  1. checksums.yaml +5 -5
  2. data/.gem_release.yml +5 -0
  3. data/.github/dependabot.yml +11 -0
  4. data/.github/workflows/lint.yml +29 -0
  5. data/.github/workflows/test.yml +25 -0
  6. data/.gitignore +18 -6
  7. data/.rspec +2 -3
  8. data/.standard.yml +6 -0
  9. data/CHANGELOG.md +110 -0
  10. data/Gemfile +48 -7
  11. data/Guardfile +9 -7
  12. data/README.md +94 -69
  13. data/Rakefile +4 -13
  14. data/app/assets/stylesheets/spree/frontend/solidus_static_content.css +7 -0
  15. data/app/assets/stylesheets/spree/frontend/spree_static_content.css +2 -7
  16. data/app/helpers/spree/pages_helper.rb +9 -5
  17. data/app/models/solidus_static_content/permission_sets/page_display.rb +21 -0
  18. data/app/models/solidus_static_content/permission_sets/page_management.rb +21 -0
  19. data/app/models/spree/page.rb +36 -37
  20. data/app/overrides/solidus_static_content/pages_in_footer.rb +11 -0
  21. data/app/overrides/solidus_static_content/pages_in_header.rb +11 -0
  22. data/app/overrides/solidus_static_content/pages_in_sidebar.rb +11 -0
  23. data/bin/console +17 -0
  24. data/bin/r +9 -0
  25. data/bin/rails +7 -6
  26. data/bin/rails-engine +15 -0
  27. data/bin/rails-sandbox +17 -0
  28. data/bin/rake +7 -0
  29. data/bin/sandbox +77 -0
  30. data/bin/sandbox_rails +9 -0
  31. data/bin/setup +8 -0
  32. data/config/locales/de.yml +7 -5
  33. data/config/locales/en.yml +7 -6
  34. data/config/locales/es-MX.yml +38 -0
  35. data/config/locales/es.yml +6 -5
  36. data/config/locales/et.yml +6 -5
  37. data/config/locales/fr.yml +7 -5
  38. data/config/locales/it.yml +6 -5
  39. data/config/locales/nl.yml +7 -5
  40. data/config/locales/pl.yml +6 -5
  41. data/config/locales/pt-BR.yml +6 -5
  42. data/config/locales/pt.yml +7 -5
  43. data/config/locales/ro.yml +11 -9
  44. data/config/locales/ru.yml +7 -5
  45. data/config/locales/sv.yml +7 -5
  46. data/config/routes.rb +13 -3
  47. data/db/migrate/20081216193152_create_pages.rb +3 -1
  48. data/db/migrate/20090625125735_extend_pages.rb +10 -9
  49. data/db/migrate/20090814113100_add_visible_to_pages.rb +6 -4
  50. data/db/migrate/20090814142845_add_default_true_to_visible_for_page.rb +5 -3
  51. data/db/migrate/20090829000527_add_index_for_page.rb +3 -2
  52. data/db/migrate/20091219021134_add_meta_fields_to_pages.rb +3 -1
  53. data/db/migrate/20100204105222_add_layout_to_pages.rb +4 -2
  54. data/db/migrate/20100323085528_add_show_in_sidebar_option_to_pages.rb +5 -3
  55. data/db/migrate/20110717103112_add_meta_title_to_page.rb +3 -1
  56. data/db/migrate/20120723144115_add_render_as_partial_for_layout_for_spree_pages.rb +9 -7
  57. data/db/migrate/20140926121757_add_pages_stores.rb +3 -3
  58. data/db/migrate/20180305193240_update_spree_page_position.rb +15 -0
  59. data/lib/controllers/backend/spree/admin/pages_controller.rb +22 -0
  60. data/lib/controllers/frontend/spree/static_content_controller.rb +32 -0
  61. data/lib/generators/solidus_static_content/install/install_generator.rb +35 -5
  62. data/lib/generators/solidus_static_content/install/templates/app/controllers/static_content_controller.rb +28 -0
  63. data/lib/generators/solidus_static_content/install/templates/app/views/static_content/show.html.erb +28 -0
  64. data/lib/solidus_static_content/engine.rb +43 -0
  65. data/lib/solidus_static_content/route_matcher.rb +15 -0
  66. data/lib/solidus_static_content/testing_support/factories.rb +18 -0
  67. data/lib/solidus_static_content/version.rb +5 -0
  68. data/lib/solidus_static_content.rb +5 -20
  69. data/lib/views/backend/spree/admin/pages/_form.html.erb +119 -0
  70. data/lib/views/backend/spree/admin/pages/edit.html.erb +32 -0
  71. data/lib/views/backend/spree/admin/pages/index.html.erb +68 -0
  72. data/lib/views/backend/spree/admin/pages/new.html.erb +31 -0
  73. data/lib/views/backend/spree/admin/shared/_pages_tabs.html.erb +9 -0
  74. data/{app/views → lib/views/frontend}/spree/static_content/_static_content_sidebar.html.erb +1 -1
  75. data/lib/views/frontend/spree/static_content/show.html.erb +18 -0
  76. data/solidus_static_content.gemspec +35 -31
  77. metadata +75 -184
  78. data/.travis.yml +0 -21
  79. data/app/assets/javascripts/spree/backend/spree_static_content.js +0 -1
  80. data/app/assets/javascripts/spree/frontend/spree_static_content.js +0 -1
  81. data/app/assets/stylesheets/spree/backend/spree_static_content.css +0 -3
  82. data/app/controllers/spree/admin/pages_controller.rb +0 -3
  83. data/app/controllers/spree/static_content_controller.rb +0 -20
  84. data/app/overrides/pages_in_footer.rb +0 -5
  85. data/app/overrides/pages_in_header.rb +0 -5
  86. data/app/overrides/pages_in_menu.rb +0 -5
  87. data/app/overrides/pages_in_sidebar.rb +0 -5
  88. data/app/views/spree/admin/pages/_form.html.erb +0 -98
  89. data/app/views/spree/admin/pages/edit.html.erb +0 -18
  90. data/app/views/spree/admin/pages/index.html.erb +0 -51
  91. data/app/views/spree/admin/pages/new.html.erb +0 -18
  92. data/app/views/spree/static_content/show.html.erb +0 -26
  93. data/lib/spree_static_content/engine.rb +0 -17
  94. data/spec/controllers/static_content_controller_spec.rb +0 -37
  95. data/spec/factories/page_factory.rb +0 -18
  96. data/spec/features/admin/pages_spec.rb +0 -67
  97. data/spec/features/static_content_spec.rb +0 -53
  98. data/spec/helpers/page_helper_spec.rb +0 -14
  99. data/spec/lib/spree_static.content_spec.rb +0 -34
  100. data/spec/models/page_spec.rb +0 -46
  101. data/spec/spec_helper.rb +0 -50
  102. /data/{LICENSE.md → LICENSE} +0 -0
  103. /data/{app/views → lib/views/frontend}/spree/static_content/_static_content_footer.html.erb +0 -0
  104. /data/{app/views → lib/views/frontend}/spree/static_content/_static_content_header.html.erb +0 -0
  105. /data/{app/views → lib/views/frontend}/spree/static_content/_static_content_list.html.erb +0 -0
@@ -1,13 +1,15 @@
1
- class AddVisibleToPages < ActiveRecord::Migration
2
- class Page < ActiveRecord::Base
1
+ # frozen_string_literal: true
2
+
3
+ class AddVisibleToPages < SolidusSupport::Migration[4.2]
4
+ class Page < ApplicationRecord
3
5
  end
4
6
 
5
7
  def self.up
6
8
  add_column :spree_pages, :visible, :boolean
7
9
  if Page.table_exists?
8
- Page.update_all :visible => true
10
+ Page.update_all visible: true
9
11
  else
10
- Spree::Page.update_all :visible => true
12
+ Spree::Page.update_all visible: true
11
13
  end
12
14
  end
13
15
 
@@ -1,8 +1,10 @@
1
- class AddDefaultTrueToVisibleForPage < ActiveRecord::Migration
1
+ # frozen_string_literal: true
2
+
3
+ class AddDefaultTrueToVisibleForPage < SolidusSupport::Migration[4.2]
2
4
  def self.up
3
- change_column :spree_pages, :visible, :boolean, :default=> true
5
+ change_column :spree_pages, :visible, :boolean, default: true
4
6
  end
5
7
 
6
8
  def self.down
7
9
  end
8
- end
10
+ end
@@ -1,4 +1,6 @@
1
- class AddIndexForPage < ActiveRecord::Migration
1
+ # frozen_string_literal: true
2
+
3
+ class AddIndexForPage < SolidusSupport::Migration[4.2]
2
4
  def self.up
3
5
  add_index(:spree_pages, :slug)
4
6
  end
@@ -7,4 +9,3 @@ class AddIndexForPage < ActiveRecord::Migration
7
9
  remove_index(:spree_pages, :slug)
8
10
  end
9
11
  end
10
-
@@ -1,4 +1,6 @@
1
- class AddMetaFieldsToPages < ActiveRecord::Migration
1
+ # frozen_string_literal: true
2
+
3
+ class AddMetaFieldsToPages < SolidusSupport::Migration[4.2]
2
4
  def self.up
3
5
  add_column :spree_pages, :meta_keywords, :string
4
6
  add_column :spree_pages, :meta_description, :string
@@ -1,4 +1,6 @@
1
- class AddLayoutToPages < ActiveRecord::Migration
1
+ # frozen_string_literal: true
2
+
3
+ class AddLayoutToPages < SolidusSupport::Migration[4.2]
2
4
  def self.up
3
5
  add_column :spree_pages, :layout, :string
4
6
  end
@@ -6,4 +8,4 @@ class AddLayoutToPages < ActiveRecord::Migration
6
8
  def self.down
7
9
  remove_column :spree_pages, :layout
8
10
  end
9
- end
11
+ end
@@ -1,9 +1,11 @@
1
- class AddShowInSidebarOptionToPages < ActiveRecord::Migration
1
+ # frozen_string_literal: true
2
+
3
+ class AddShowInSidebarOptionToPages < SolidusSupport::Migration[4.2]
2
4
  def self.up
3
- add_column :spree_pages, :show_in_sidebar, :boolean, :default=> false, :null=>false
5
+ add_column :spree_pages, :show_in_sidebar, :boolean, default: false, null: false
4
6
  end
5
7
 
6
8
  def self.down
7
9
  remove_column :spree_pages, :show_in_sidebar
8
10
  end
9
- end
11
+ end
@@ -1,4 +1,6 @@
1
- class AddMetaTitleToPage < ActiveRecord::Migration
1
+ # frozen_string_literal: true
2
+
3
+ class AddMetaTitleToPage < SolidusSupport::Migration[4.2]
2
4
  def self.up
3
5
  add_column :spree_pages, :meta_title, :string
4
6
  end
@@ -1,13 +1,15 @@
1
- class AddRenderAsPartialForLayoutForSpreePages < ActiveRecord::Migration
1
+ # frozen_string_literal: true
2
+
3
+ class AddRenderAsPartialForLayoutForSpreePages < SolidusSupport::Migration[4.2]
2
4
  def up
3
- unless column_exists? :spree_pages, :render_layout_as_partial
4
- add_column :spree_pages, :render_layout_as_partial, :boolean, :default => false
5
- end
5
+ return if column_exists? :spree_pages, :render_layout_as_partial
6
+
7
+ add_column :spree_pages, :render_layout_as_partial, :boolean, default: false
6
8
  end
7
9
 
8
10
  def down
9
- if column_exists? :spree_pages, :render_layout_as_partial
10
- remove_column :spree_pages, :render_layout_as_partial
11
- end
11
+ return unless column_exists? :spree_pages, :render_layout_as_partial
12
+
13
+ remove_column :spree_pages, :render_layout_as_partial
12
14
  end
13
15
  end
@@ -1,7 +1,8 @@
1
- class AddPagesStores < ActiveRecord::Migration
1
+ # frozen_string_literal: true
2
2
 
3
+ class AddPagesStores < SolidusSupport::Migration[4.2]
3
4
  def change
4
- create_table :spree_pages_stores, :id => false do |t|
5
+ create_table :spree_pages_stores, id: false do |t|
5
6
  t.integer :store_id
6
7
  t.integer :page_id
7
8
  t.timestamps
@@ -9,6 +10,5 @@ class AddPagesStores < ActiveRecord::Migration
9
10
 
10
11
  add_index :spree_pages_stores, :store_id
11
12
  add_index :spree_pages_stores, :page_id
12
-
13
13
  end
14
14
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ class UpdateSpreePagePosition < SolidusSupport::Migration[4.2]
4
+ def up
5
+ return unless column_exists?(:spree_pages, :position)
6
+
7
+ change_column :spree_pages, :position, :integer, default: 0
8
+ end
9
+
10
+ def down
11
+ return unless column_exists?(:spree_pages, :position)
12
+
13
+ change_column :spree_pages, :position, :boolean, default: false
14
+ end
15
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spree
4
+ module Admin
5
+ class PagesController < Spree::Admin::ResourceController
6
+ private
7
+
8
+ # Set some default attributes
9
+ def build_resource
10
+ super.tap do |resource|
11
+ if resource.stores.blank?
12
+ resource.stores << Spree::Store.default
13
+ end
14
+ end
15
+ end
16
+
17
+ def collection
18
+ super.ordered_by_position
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spree
4
+ class StaticContentController < Spree::StoreController
5
+ helper "spree/products"
6
+ layout :determine_layout
7
+
8
+ def show
9
+ @page = Spree::Page.by_store(current_store).visible.find_by!(slug: request.path_info)
10
+
11
+ # Assign static_content to let solidus recognize it as the current
12
+ # controller resource, this is used by meta tags and in other places.
13
+ @static_content = @page
14
+
15
+ @taxonomies = Spree::Taxonomy.includes(root: :children)
16
+ end
17
+
18
+ private
19
+
20
+ def determine_layout
21
+ return @page.layout if @page && @page.layout.present? && !@page.render_layout_as_partial?
22
+
23
+ Spree::Config.layout
24
+ end
25
+
26
+ def accurate_title
27
+ return unless @page
28
+
29
+ @page.meta_title.presence || @page.title
30
+ end
31
+ end
32
+ end
@@ -1,22 +1,52 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SolidusStaticContent
2
4
  module Generators
3
5
  class InstallGenerator < Rails::Generators::Base
6
+ source_root File.expand_path("templates", __dir__)
4
7
  class_option :auto_run_migrations, type: :boolean, default: false
8
+ # Either 'starter' or 'classic'
9
+ class_option :frontend, type: :string, default: "classic"
5
10
 
6
11
  def add_stylesheets
7
- inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', " *= require spree/frontend/spree_static_content\n", before: /\*\//, verbose: true
12
+ inject_into_file "vendor/assets/stylesheets/spree/frontend/all.css", " *= require spree/frontend/solidus_static_content\n", before: %r{\*/}, verbose: true
8
13
  end
9
14
 
10
15
  def add_migrations
11
- run 'bundle exec rake railties:install:migrations FROM=solidus_static_content'
16
+ run "bin/rails railties:install:migrations FROM=solidus_static_content"
17
+ end
18
+
19
+ def add_javascripts
20
+ empty_directory "app/assets/javascripts"
21
+ end
22
+
23
+ def copy_starter_frontend_files
24
+ return if options[:frontend] != "starter"
25
+
26
+ copy_file "app/controllers/static_content_controller.rb"
27
+ copy_file "app/views/static_content/show.html.erb"
28
+
29
+ insert_into_file "config/initializers/spree.rb", after: "Spree.config do |config|\n" do
30
+ <<~RUBY.indent(2)
31
+ config.layout = 'layouts/storefront'
32
+
33
+ RUBY
34
+ end
35
+ route <<~ROUTES
36
+ if Spree::Config.layout == 'layouts/storefront'
37
+ constraints(SolidusStaticContent::RouteMatcher) do
38
+ get '/(*path)', to: 'static_content#show', as: 'static'
39
+ end
40
+ end
41
+ ROUTES
12
42
  end
13
43
 
14
44
  def run_migrations
15
- run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask 'Would you like to run the migrations now? [Y/n]')
45
+ run_migrations = options[:auto_run_migrations] || ["", "y", "Y"].include?(ask("Would you like to run the migrations now? [Y/n]"))
16
46
  if run_migrations
17
- run 'bundle exec rake db:migrate'
47
+ run "bin/rails db:migrate"
18
48
  else
19
- puts 'Skipping rake db:migrate, don\'t forget to run it!'
49
+ puts "Skipping bin/rails db:migrate, don't forget to run it!"
20
50
  end
21
51
  end
22
52
  end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ class StaticContentController < StoreController
4
+ helper "spree/products"
5
+ layout :determine_layout
6
+
7
+ def show
8
+ @page = Spree::Page.by_store(current_store).visible.find_by!(slug: request.path_info)
9
+
10
+ # Assign static_content to let solidus recognize it as the current
11
+ # controller resource, this is used by meta tags and in other places.
12
+ @static_content = @page
13
+ end
14
+
15
+ private
16
+
17
+ def determine_layout
18
+ return @page.layout if @page && @page.layout.present? && !@page.render_layout_as_partial?
19
+
20
+ Spree::Config.layout
21
+ end
22
+
23
+ def accurate_title
24
+ return unless @page
25
+
26
+ @page.meta_title.presence || @page.title
27
+ end
28
+ end
@@ -0,0 +1,28 @@
1
+ <% if @page.layout.present? and @page.render_layout_as_partial? %>
2
+ <%= render partial: @page.layout %>
3
+ <% else %>
4
+ <% content_for :head do -%>
5
+ <%- if @page.meta_title.present? -%>
6
+ <meta name="title" content="<%= @page.meta_title %>">
7
+ <%- else -%>
8
+ <meta name="title" content="<%= @page.title %>">
9
+ <%- end -%>
10
+ <meta name="keywords" content="<%= @page.meta_keywords %>">
11
+ <meta name="description" content="<%= @page.meta_description %>">
12
+ <% end -%>
13
+
14
+ <% content_for :sidebar do %>
15
+ <% if (defined?(@products) && @products) && (defined?(@taxon) && @taxon) %>
16
+ <%= render partial: 'spree/shared/filters' %>
17
+ <% elsif defined?(@taxonomies) && @taxonomies %>
18
+ <%= render partial: 'spree/shared/taxonomies' %>
19
+ <% end %>
20
+ <% end %>
21
+
22
+ <div class="container" id="page_content">
23
+ <h1 class="wrapper mt-4 font-serif text-h3 lg:text-h2"><%= @page.title %></h1>
24
+ <div class="pt-4 pb-4">
25
+ <%= raw @page.body %>
26
+ </div>
27
+ </div>
28
+ <% end %>
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "solidus_core"
4
+ require "solidus_support"
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
+ initializer "solidus_subscriptions.configure_backend" do
20
+ next unless ::Spree::Backend::Config.respond_to?(:menu_items)
21
+
22
+ ::Spree::Backend::Config.configure do |config|
23
+ config.menu_items << if Spree.solidus_gem_version >= Gem::Version.new("4.2.0")
24
+ config.class::MenuItem.new(
25
+ label: :pages,
26
+ icon: "ri-file-text-line",
27
+ url: :admin_pages_path,
28
+ condition: -> { can?(:admin, Spree::Page) },
29
+ match_path: "/pages"
30
+ )
31
+ else
32
+ config.class::MenuItem.new(
33
+ [:pages],
34
+ "file-text",
35
+ url: :admin_pages_path,
36
+ condition: -> { can?(:admin, Spree::Page) },
37
+ match_path: "/pages"
38
+ )
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SolidusStaticContent
4
+ module RouteMatcher
5
+ EXCLUDED_PATHS = %r{^/+(admin|account|cart|checkout|content|login|pg/|orders|products|s/|session|signup|shipments|states|t/|tax_categories|user)+}
6
+
7
+ def self.matches?(request)
8
+ path = request.path_info
9
+
10
+ return false if EXCLUDED_PATHS.match? path
11
+
12
+ Spree::Page.visible.where(slug: path).exists?
13
+ end
14
+ end
15
+ 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,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SolidusStaticContent
4
+ VERSION = "2.1.0"
5
+ end
@@ -1,21 +1,6 @@
1
- require 'solidus_core'
2
- require 'solidus_frontend'
3
- require 'solidus_backend'
4
- require 'deface'
5
- require 'spree_static_content/engine'
6
- require 'coffee_script'
7
- require 'sass/rails'
1
+ # frozen_string_literal: true
8
2
 
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
-
16
- class Spree::StaticPage
17
- def self.matches?(request)
18
- return false if request.path =~ /(^\/+(admin|account|cart|checkout|content|login|pg\/|orders|products|s\/|session|signup|shipments|states|t\/|tax_categories|user)+)/
19
- !Spree::Page.visible.find_by_slug(request.path).nil?
20
- end
21
- end
3
+ require "solidus_static_content/version"
4
+ require "solidus_static_content/route_matcher"
5
+ require "solidus_static_content/engine"
6
+ require "deface"
@@ -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>
@@ -0,0 +1,32 @@
1
+ <%= render 'spree/admin/shared/pages_tabs' %>
2
+
3
+ <% admin_breadcrumb(link_to plural_resource_name(Spree::Page), spree.admin_pages_path) %>
4
+ <% admin_breadcrumb(@page.title) %>
5
+
6
+ <% content_for :page_title do %>
7
+ <%= t("spree.editing_page") %>
8
+ <% end %>
9
+
10
+ <% content_for :page_actions do %>
11
+ <li>
12
+ <%= button_to t("spree.back_to_static_pages_list"), spree.admin_pages_path %>
13
+ </li>
14
+ <% end %>
15
+
16
+ <div data-hook='admin_page_edit_form_header'>
17
+ <%= render "spree/shared/error_messages", :target => @page %>
18
+ </div>
19
+
20
+ <%= form_for [:admin, @page], as: :page, url: admin_page_path(@page) do |f| %>
21
+ <fieldset class="no-border-top">
22
+ <%= render :partial => 'form', :locals => { :f => f } %>
23
+
24
+ <div class='clear'></div>
25
+
26
+ <div data-hook='admin_page_edit_form_buttons'>
27
+ <% if can?(:update, @page) %>
28
+ <%= render partial: 'spree/admin/shared/edit_resource_links' %>
29
+ <% end %>
30
+ </div>
31
+ </fieldset>
32
+ <% end %>
@@ -0,0 +1,68 @@
1
+ <%= render 'spree/admin/shared/pages_tabs' %>
2
+
3
+ <% content_for :page_actions do %>
4
+ <% if can?(:create, Spree::Page) %>
5
+ <li>
6
+ <%= link_to t("spree.new_page"), new_object_url, icon: 'plus' %>
7
+ </li>
8
+ <% end %>
9
+ <% end %>
10
+
11
+ <% content_for :page_title do %>
12
+ <%= t("spree.static_pages") %>
13
+ <% end %>
14
+
15
+ <% if @pages.any? %>
16
+ <table class="index responsive sortable" id="listing_pages" data-hook data-sortable-link="<%= update_positions_admin_pages_url %>">
17
+ <colgroup>
18
+ <col style="width: 10%">
19
+ <col style="width: 40%">
20
+ <col style="width: 35%">
21
+ <col style="width: 10%">
22
+ <col style="width: 15%">
23
+ </colgroup>
24
+
25
+ <thead>
26
+ <tr data-hook="admin_pages_index_headers">
27
+ <th></th>
28
+ <th><%= Spree::Page.human_attribute_name(:title) %></th>
29
+ <th><%= t("spree.link") %></th>
30
+ <th><%= Spree::Page.human_attribute_name(:visible) %></th>
31
+ <th data-hook="admin_pages_index_header_actions" class="actions"></th>
32
+ </tr>
33
+ </thead>
34
+
35
+ <tbody class="ui-sortable">
36
+ <% @pages.each do |page| %>
37
+ <tr data-hook="admin_pages_index_rows" class="<%= cycle('odd', 'even') %>" id="<%= dom_id page %>">
38
+ <td>
39
+ <% if can?(:update_positions, Spree::StockLocation) %>
40
+ <span class='handle ui-sortable-handle'></span>
41
+ <% end %>
42
+ </td>
43
+ <td><%= page.title %></td>
44
+ <td><%= link_to page.link, page.link, :target => '_blank' %></td>
45
+ <td>
46
+ <span class='pill pill-<%= page.visible ? 'active' : 'inactive' %>'>
47
+ <%= t("spree.#{page.visible? ? :active : :inactive}") %>
48
+ </span>
49
+ </td>
50
+ <td data-hook="admin_pages_index_row_actions" class="actions" >
51
+ <% if can?(:update, page) %>
52
+ <%= link_to_edit page, no_text: true %>
53
+ <% end %>
54
+ <% if can?(:destroy, page) %>
55
+ <%= link_to_delete page, no_text: true %>
56
+ <% end %>
57
+ </td>
58
+ </tr>
59
+ <% end %>
60
+ </tbody>
61
+ </table>
62
+ <% else %>
63
+ <div class="no-objects-found">
64
+ <%= render 'spree/admin/shared/no_objects_found',
65
+ resource: Spree::Page,
66
+ new_resource_url: new_object_url %>
67
+ </div>
68
+ <% end %>