spree_static_content 0.70.3 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. data/README.md +6 -2
  2. data/app/controllers/spree/admin/pages_controller.rb +16 -0
  3. data/app/controllers/{static_content_controller.rb → spree/static_content_controller.rb} +10 -4
  4. data/app/models/{page.rb → spree/page.rb} +10 -10
  5. data/app/overrides/pages_in_footer.rb +4 -0
  6. data/app/overrides/pages_in_header.rb +4 -0
  7. data/app/overrides/pages_in_sidebar.rb +4 -0
  8. data/app/overrides/static_content_admin_tab.rb +1 -1
  9. data/app/views/spree/admin/pages/_form.html.erb +76 -0
  10. data/app/views/spree/admin/pages/edit.html.erb +7 -0
  11. data/app/views/{admin → spree/admin}/pages/index.html.erb +2 -2
  12. data/app/views/spree/admin/pages/new.html.erb +7 -0
  13. data/app/views/spree/static_content/_static_content_footer.html.erb +3 -0
  14. data/app/views/spree/static_content/_static_content_header.html.erb +1 -0
  15. data/app/views/spree/static_content/_static_content_list.html.erb +1 -0
  16. data/app/views/spree/static_content/_static_content_sidebar.html.erb +3 -0
  17. data/app/views/spree/static_content/show.html.erb +22 -0
  18. data/lib/generators/spree_static_content/install_generator.rb +38 -17
  19. data/lib/spree_static_content.rb +2 -21
  20. data/lib/spree_static_content/engine.rb +16 -0
  21. metadata +80 -28
  22. data/app/controllers/admin/pages_controller.rb +0 -16
  23. data/app/controllers/spree/base_controller_decorator.rb +0 -33
  24. data/app/views/admin/pages/_form.html.erb +0 -15
  25. data/app/views/admin/pages/edit.html.erb +0 -10
  26. data/app/views/admin/pages/new.html.erb +0 -10
  27. data/app/views/static_content/show.html.erb +0 -14
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Spree Static Content
2
2
 
3
+ [![Build Status](https://secure.travis-ci.org/spree/spree_static_content.png?branch=1-0-stable)](http://travis-ci.org/spree/spree_static_content)
4
+
3
5
  Good, clean content management of pages for Spree. You can use this to:
4
6
 
5
7
  - Add and manage static pages such as an 'About' page.
@@ -16,9 +18,11 @@ See the wiki for some more documentation on how you can use this extension.
16
18
 
17
19
  ## Basic Installation
18
20
 
21
+ **For Spree 0.70.x**
22
+
19
23
  1. Add the following to your Gemfile
20
24
  <pre>
21
- gem 'spree_static_content', :git => 'github.com/spree/spree_static_content'
25
+ gem 'spree_static_content', :git => 'http://github.com/spree/spree_static_content', :ref => '1861f4cd08c0ffa9940f0c81e69ea29b4541dbbd'
22
26
  </pre>
23
27
  2. Run `bundle install`
24
28
  3. To copy and apply migrations run: `rails g spree_static_content:install`
@@ -42,4 +46,4 @@ You can also run `bundle exec rake test_app` and then to run the specs run `bund
42
46
  <pre>
43
47
  git push -u origin my-feature-branch
44
48
  </pre>
45
- 4. Send a pull request from your feature branch in the forked repository on github.
49
+ 4. Send a pull request from your feature branch in the forked repository on github.
@@ -0,0 +1,16 @@
1
+ class Spree::Admin::PagesController < Spree::Admin::ResourceController
2
+ update.after :expire_cache
3
+
4
+ def new
5
+ @page = @object
6
+ end
7
+
8
+ def edit
9
+ @page = @object
10
+ end
11
+
12
+ private
13
+ def expire_cache
14
+ expire_page :controller => '/spree/static_content', :action => 'show', :path => @object.slug
15
+ end
16
+ end
@@ -1,23 +1,29 @@
1
- class StaticContentController < Spree::BaseController
1
+ class Spree::StaticContentController < Spree::BaseController
2
2
  caches_action :show
3
+ layout :determine_layout
3
4
 
4
5
  def show
5
6
  path = case params[:path]
6
7
  when Array
7
8
  '/' + params[:path].join("/")
8
9
  when String
9
- params[:path]
10
+ '/' + params[:path]
10
11
  when nil
11
12
  request.path
12
13
  end
13
14
 
14
- unless @page = Page.visible.find_by_slug(path)
15
+ unless @page = Spree::Page.visible.find_by_slug(path.gsub('//','/'))
15
16
  render_404
16
17
  end
17
18
  end
18
-
19
+
19
20
  private
20
21
 
22
+ def determine_layout
23
+ return @page.layout if @page and @page.layout.present?
24
+ 'spree/layouts/spree_application'
25
+ end
26
+
21
27
  def accurate_title
22
28
  @page ? (@page.meta_title ? @page.meta_title : @page.title) : nil
23
29
  end
@@ -1,20 +1,20 @@
1
- class Page < ActiveRecord::Base
1
+ class Spree::Page < ActiveRecord::Base
2
2
  default_scope :order => "position ASC"
3
3
 
4
4
  validates_presence_of :title
5
5
  validates_presence_of [:slug, :body], :if => :not_using_foreign_link?
6
-
6
+
7
7
  scope :visible, where(:visible => true)
8
8
  scope :header_links, where(:show_in_header => true).visible
9
9
  scope :footer_links, where(:show_in_footer => true).visible
10
10
  scope :sidebar_links, where(:show_in_sidebar => true).visible
11
-
12
-
11
+
12
+
13
13
  before_save :update_positions_and_slug
14
14
 
15
15
  def initialize(*args)
16
16
  super(*args)
17
- last_page = Page.last
17
+ last_page = Spree::Page.last
18
18
  self.position = last_page ? last_page.position + 1 : 0
19
19
  end
20
20
 
@@ -26,11 +26,11 @@ private
26
26
 
27
27
  def update_positions_and_slug
28
28
  unless new_record?
29
- return unless prev_position = Page.find(self.id).position
29
+ return unless prev_position = Spree::Page.find(self.id).position
30
30
  if prev_position > self.position
31
- Page.update_all("position = position + 1", ["? <= position AND position < ?", self.position, prev_position])
31
+ Spree::Page.update_all("position = position + 1", ["? <= position AND position < ?", self.position, prev_position])
32
32
  elsif prev_position < self.position
33
- Page.update_all("position = position - 1", ["? < position AND position <= ?", prev_position, self.position])
33
+ Spree::Page.update_all("position = position - 1", ["? < position AND position <= ?", prev_position, self.position])
34
34
  end
35
35
  end
36
36
 
@@ -40,7 +40,7 @@ private
40
40
  end
41
41
  return true
42
42
  end
43
-
43
+
44
44
  def not_using_foreign_link?
45
45
  foreign_link.blank?
46
46
  end
@@ -48,7 +48,7 @@ private
48
48
  def slug_link
49
49
  ensure_slash_prefix slug
50
50
  end
51
-
51
+
52
52
  def ensure_slash_prefix(str)
53
53
  str.index('/') == 0 ? str : '/' + str
54
54
  end
@@ -0,0 +1,4 @@
1
+ Deface::Override.new(:virtual_path => "spree/layouts/spree_application",
2
+ :name => "pages_in_footer",
3
+ :insert_bottom => "#footer-right",
4
+ :partial => "spree/static_content/static_content_footer")
@@ -0,0 +1,4 @@
1
+ Deface::Override.new(:virtual_path => "spree/layouts/spree_application",
2
+ :name => "pages_in_header",
3
+ :insert_bottom => "#main-nav-bar",
4
+ :partial => "spree/static_content/static_content_header")
@@ -0,0 +1,4 @@
1
+ Deface::Override.new(:virtual_path => "spree/layouts/spree_application",
2
+ :name => "pages_in_sidebar",
3
+ :insert_bottom => "#sidebar",
4
+ :partial => "spree/static_content/static_content_sidebar")
@@ -1,4 +1,4 @@
1
- Deface::Override.new(:virtual_path => "layouts/admin",
1
+ Deface::Override.new(:virtual_path => "spree/layouts/admin",
2
2
  :name => "static_content_admin_tab",
3
3
  :insert_bottom => "[data-hook='admin_tabs']",
4
4
  :text => "<%= tab(:pages) %>")
@@ -0,0 +1,76 @@
1
+ <div class="clearfix">
2
+ <div class="left">
3
+ <%= f.field_container :title do %>
4
+ <%= f.label :title, t(:title) %> <span class="required">*</span><br />
5
+ <%= f.text_field :title, :class => 'fullwidth title' %>
6
+ <%= f.error_message_on :title %>
7
+ <% end %>
8
+
9
+ <%= f.field_container :slug do %>
10
+ <%= f.label :slug, t(:slug) %> <span class="required">*</span><br />
11
+ <%= f.text_field :slug, :class => 'fullwidth title' %>
12
+ <%= f.error_message_on :slug %>
13
+ <% end %>
14
+
15
+ <%= f.field_container :body do %>
16
+ <%= f.label :body, t(:body) %><br />
17
+ <%= f.text_area :body, {:class => 'fullwidth'} %>
18
+ <%= f.error_message_on :body %>
19
+ <% end %>
20
+
21
+ <%= f.field_container :meta_title do %>
22
+ <%= f.label :meta_title, t(:meta_title) %><br />
23
+ <%= f.text_field :meta_title, :class => 'fullwidth title' %>
24
+ <%= f.error_message_on :meta_title %>
25
+ <% end %>
26
+
27
+ <%= f.field_container :meta_keywords do %>
28
+ <%= f.label :meta_keywords, t(:meta_keywords) %><br />
29
+ <%= f.text_field :meta_keywords, :class => 'fullwidth title' %>
30
+ <%= f.error_message_on :meta_keywords %>
31
+ <% end %>
32
+
33
+ <%= f.field_container :meta_description do %>
34
+ <%= f.label :meta_description, t(:meta_description) %><br />
35
+ <%= f.text_field :meta_description, :class => 'fullwidth title' %>
36
+ <%= f.error_message_on :meta_description %>
37
+ <% end %>
38
+
39
+ </div>
40
+ <div class="right">
41
+ <%= f.field_container :layout do %>
42
+ <%= f.label :layout, t(:layout) %><br />
43
+ <%= f.text_field :layout, :class => 'fullwidth title' %>
44
+ <% end %>
45
+
46
+ <%= f.field_container :foreign_link do %>
47
+ <%= f.label :foreign_link, t(:foreign_link) %><br />
48
+ <%= f.text_field :foreign_link, :class => 'fullwidth title' %>
49
+ <% end %>
50
+
51
+ <%= f.field_container :position do %>
52
+ <%= f.label :position, t(:position) %><br />
53
+ <%= f.number_field :position, :min => 0 %>
54
+ <% end %>
55
+
56
+ <ul id="static_page_options">
57
+ <li>
58
+ <%= f.check_box :show_in_sidebar %>
59
+ <%= f.label :show_in_sidebar %>
60
+ </li>
61
+ <li>
62
+ <%= f.check_box :show_in_header %>
63
+ <%= f.label :show_in_header %>
64
+ </li>
65
+ <li>
66
+ <%= f.check_box :show_in_footer %>
67
+ <%= f.label :show_in_footer %>
68
+ </li>
69
+ <li>
70
+ <%= f.check_box :visible %>
71
+ <%= f.label :visible %>
72
+ </li>
73
+ </ul>
74
+
75
+ </div>
76
+ </div>
@@ -0,0 +1,7 @@
1
+ <h1><%= t("static_content.editing_page") %></h1>
2
+ <%= render "spree/shared/error_messages", :target => @page %>
3
+
4
+ <%= form_for [:admin, @page] do |f| %>
5
+ <%= render :partial => 'form', :locals => { :f => f } %>
6
+ <%= render :partial => 'spree/admin/shared/edit_resource_links' %>
7
+ <% end %>
@@ -11,9 +11,9 @@
11
11
 
12
12
  <table class="index">
13
13
  <tr>
14
- <th><%= Page.human_attribute_name(:title) %></th>
14
+ <th><%= Spree::Page.human_attribute_name(:title) %></th>
15
15
  <th><%= t("static_content.link") %></th>
16
- <th><%= Page.human_attribute_name(:visible) %></th>
16
+ <th><%= Spree::Page.human_attribute_name(:visible) %></th>
17
17
  <th><%= t("action") %></th>
18
18
  </tr>
19
19
  <tbody>
@@ -0,0 +1,7 @@
1
+ <h1><%= t("static_content.editing_page") %></h1>
2
+ <%= render "spree/shared/error_messages", :target => @page %>
3
+
4
+ <%= form_for [:admin, @page] do |f| %>
5
+ <%= render :partial => 'form', :locals => { :f => f } %>
6
+ <%= render :partial => 'spree/admin/shared/edit_resource_links' %>
7
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <nav id="footer-pages">
2
+ <ul><%= render :partial => "spree/static_content/static_content_list", :collection => Spree::Page.visible.footer_links, :as => :page %></ul>
3
+ </nav>
@@ -0,0 +1 @@
1
+ <%= render :partial => "spree/static_content/static_content_list", :collection => Spree::Page.visible.header_links, :as => :page %>
@@ -0,0 +1 @@
1
+ <li class=<%=(request.fullpath[1..-1] == page.slug) ? 'current' : 'not'%>><%= link_to page.title, page.slug %></li>
@@ -0,0 +1,3 @@
1
+ <nav id="sidebar-pages-menu">
2
+ <ul><%= render :partial => "spree/static_content/static_content_list", :collection => Spree::Page.visible.sidebar_links, :as => :page %></ul>
3
+ </nav>
@@ -0,0 +1,22 @@
1
+ <% content_for :head do -%>
2
+ <%- if @page.meta_title.present? -%>
3
+ <meta name="title" content="<%=@page.meta_title%>">
4
+ <%- else -%>
5
+ <meta name="title" content="<%=@page.title%>">
6
+ <%- end -%>
7
+ <meta name="keywords" content="<%=@page.meta_keywords%>">
8
+ <meta name="keywords" content="<%=@page.meta_description%>">
9
+ <% end -%>
10
+
11
+ <% content_for :sidebar do %>
12
+ <% if "products" == @current_controller && @taxon %>
13
+ <%= render :partial => "spree/shared/filters" %>
14
+ <% else %>
15
+ <%= render :partial => "spree/shared/taxonomies" %>
16
+ <% end %>
17
+ <% end %>
18
+
19
+ <h1><%= @page.title %></h1>
20
+ <div id="page_content">
21
+ <%= raw @page.body %>
22
+ </div>
@@ -1,24 +1,45 @@
1
- module SpreeStaticContent
2
- module Generators
3
- class InstallGenerator < Rails::Generators::Base
1
+ if ::Rails.version < "3.1" || !::Rails.application.config.assets.enabled
2
+ module SpreeStaticContent
3
+ module Generators
4
+ class InstallGenerator < Rails::Generators::Base
4
5
 
5
- def add_stylesheets
6
- inject_into_file "app/assets/stylesheets/admin/all.css", " *= require formtastic\n", :before => /\*\//, :verbose => true
7
- end
6
+ def add_stylesheets
7
+ inject_into_file "app/assets/stylesheets/admin/all.css", " *= require formtastic\n", :before => /\*\//, :verbose => true
8
+ end
8
9
 
9
- def add_migrations
10
- run 'rake railties:install:migrations FROM=spree_static_content'
11
- end
10
+ def add_migrations
11
+ run 'rake railties:install:migrations FROM=spree_static_content'
12
+ end
12
13
 
13
- def run_migrations
14
- res = ask "Would you like to run the migrations now? [Y/n]"
15
- if res == "" || res.downcase == "y"
16
- run 'rake db:migrate'
17
- else
18
- puts "Skiping rake db:migrate, don't forget to run it!"
19
- end
14
+ def run_migrations
15
+ res = ask "Would you like to run the migrations now? [Y/n]"
16
+ if res == "" || res.downcase == "y"
17
+ run 'rake db:migrate'
18
+ else
19
+ puts "Skiping rake db:migrate, don't forget to run it!"
20
+ end
21
+ end
20
22
  end
21
23
  end
22
24
  end
23
- end
25
+ else
26
+ module SpreeStaticContent
27
+ module Generators
28
+ class InstallGenerator < Rails::Generators::Base
29
+ def add_migrations
30
+ run 'rake railties:install:migrations FROM=spree_static_content'
31
+ end
32
+
33
+ def run_migrations
34
+ res = ask "Would you like to run the migrations now? [Y/n]"
35
+ if res == "" || res.downcase == "y"
36
+ run 'rake db:migrate'
37
+ else
38
+ puts "Skiping rake db:migrate, don't forget to run it!"
39
+ end
40
+ end
24
41
 
42
+ end
43
+ end
44
+ end
45
+ end
@@ -1,21 +1,2 @@
1
- require 'spree_core'
2
- require 'formtastic'
3
-
4
- module SpreeStaticContent
5
- class Engine < Rails::Engine
6
- engine_name 'spree_static_content'
7
-
8
- def self.activate
9
- Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c|
10
- Rails.application.config.cache_classes ? require(c) : load(c)
11
- end
12
-
13
- Dir.glob(File.join(File.dirname(__FILE__), "../app/overrides/**/*.rb")) do |c|
14
- Rails.application.config.cache_classes ? require(c) : load(c)
15
- end
16
- end
17
- config.to_prepare &method(:activate).to_proc
18
- config.autoload_paths += %W(#{config.root}/lib)
19
- end
20
- end
21
-
1
+ require 'spree/core'
2
+ require 'spree_static_content/engine'
@@ -0,0 +1,16 @@
1
+ module SpreeStaticContent
2
+ class Engine < Rails::Engine
3
+ engine_name 'spree_static_content'
4
+
5
+ def self.activate
6
+ Dir.glob(File.join(File.dirname(__FILE__), "../../app/**/*_decorator*.rb")) do |c|
7
+ Rails.application.config.cache_classes ? require(c) : load(c)
8
+ end
9
+ Dir.glob(File.join(File.dirname(__FILE__), "../../app/overrides/**/*.rb")) do |c|
10
+ Rails.application.config.cache_classes ? require(c) : load(c)
11
+ end
12
+ end
13
+ config.to_prepare &method(:activate).to_proc
14
+ config.autoload_paths += %W(#{config.root}/lib)
15
+ end
16
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_static_content
3
3
  version: !ruby/object:Gem::Version
4
- hash: 257
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
+ - 1
7
8
  - 0
8
- - 70
9
- - 3
10
- version: 0.70.3
9
+ - 1
10
+ version: 1.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Peter Berkenbosch
@@ -24,14 +24,14 @@ dependencies:
24
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ">="
27
+ - - ~>
28
28
  - !ruby/object:Gem::Version
29
- hash: 261
29
+ hash: 23
30
30
  segments:
31
- - 0
32
- - 70
33
31
  - 1
34
- version: 0.70.1
32
+ - 0
33
+ - 0
34
+ version: 1.0.0
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
@@ -40,20 +40,36 @@ dependencies:
40
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ">="
43
+ - - ~>
44
44
  - !ruby/object:Gem::Version
45
- hash: 261
45
+ hash: 23
46
46
  segments:
47
- - 0
48
- - 70
49
47
  - 1
50
- version: 0.70.1
48
+ - 0
49
+ - 0
50
+ version: 1.0.0
51
51
  type: :runtime
52
52
  version_requirements: *id002
53
53
  - !ruby/object:Gem::Dependency
54
- name: formtastic
54
+ name: capybara
55
55
  prerelease: false
56
56
  requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - "="
60
+ - !ruby/object:Gem::Version
61
+ hash: 21
62
+ segments:
63
+ - 1
64
+ - 0
65
+ - 1
66
+ version: 1.0.1
67
+ type: :development
68
+ version_requirements: *id003
69
+ - !ruby/object:Gem::Dependency
70
+ name: factory_girl
71
+ prerelease: false
72
+ requirement: &id004 !ruby/object:Gem::Requirement
57
73
  none: false
58
74
  requirements:
59
75
  - - ">="
@@ -62,12 +78,41 @@ dependencies:
62
78
  segments:
63
79
  - 0
64
80
  version: "0"
65
- type: :runtime
66
- version_requirements: *id003
81
+ type: :development
82
+ version_requirements: *id004
83
+ - !ruby/object:Gem::Dependency
84
+ name: ffaker
85
+ prerelease: false
86
+ requirement: &id005 !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ hash: 3
92
+ segments:
93
+ - 0
94
+ version: "0"
95
+ type: :development
96
+ version_requirements: *id005
67
97
  - !ruby/object:Gem::Dependency
68
98
  name: rspec-rails
69
99
  prerelease: false
70
- requirement: &id004 !ruby/object:Gem::Requirement
100
+ requirement: &id006 !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - ~>
104
+ - !ruby/object:Gem::Version
105
+ hash: 13
106
+ segments:
107
+ - 2
108
+ - 7
109
+ version: "2.7"
110
+ type: :development
111
+ version_requirements: *id006
112
+ - !ruby/object:Gem::Dependency
113
+ name: sqlite3
114
+ prerelease: false
115
+ requirement: &id007 !ruby/object:Gem::Requirement
71
116
  none: false
72
117
  requirements:
73
118
  - - ">="
@@ -77,7 +122,7 @@ dependencies:
77
122
  - 0
78
123
  version: "0"
79
124
  type: :development
80
- version_requirements: *id004
125
+ version_requirements: *id007
81
126
  description:
82
127
  email: peter@pero-ict.nl
83
128
  executables: []
@@ -88,18 +133,25 @@ extra_rdoc_files: []
88
133
 
89
134
  files:
90
135
  - README.md
136
+ - lib/spree_static_content/engine.rb
91
137
  - lib/spree_static_content.rb
92
138
  - lib/generators/spree_static_content/install_generator.rb
93
- - app/models/page.rb
94
- - app/views/admin/pages/_form.html.erb
95
- - app/views/admin/pages/edit.html.erb
96
- - app/views/admin/pages/new.html.erb
97
- - app/views/admin/pages/index.html.erb
98
- - app/views/static_content/show.html.erb
139
+ - app/models/spree/page.rb
140
+ - app/views/spree/admin/pages/_form.html.erb
141
+ - app/views/spree/admin/pages/edit.html.erb
142
+ - app/views/spree/admin/pages/new.html.erb
143
+ - app/views/spree/admin/pages/index.html.erb
144
+ - app/views/spree/static_content/_static_content_sidebar.html.erb
145
+ - app/views/spree/static_content/_static_content_footer.html.erb
146
+ - app/views/spree/static_content/show.html.erb
147
+ - app/views/spree/static_content/_static_content_list.html.erb
148
+ - app/views/spree/static_content/_static_content_header.html.erb
149
+ - app/overrides/pages_in_footer.rb
99
150
  - app/overrides/static_content_admin_tab.rb
100
- - app/controllers/spree/base_controller_decorator.rb
101
- - app/controllers/static_content_controller.rb
102
- - app/controllers/admin/pages_controller.rb
151
+ - app/overrides/pages_in_sidebar.rb
152
+ - app/overrides/pages_in_header.rb
153
+ - app/controllers/spree/static_content_controller.rb
154
+ - app/controllers/spree/admin/pages_controller.rb
103
155
  homepage: http://spreecommerce.com/extensions/139-static-content
104
156
  licenses: []
105
157
 
@@ -1,16 +0,0 @@
1
- class Admin::PagesController < Admin::ResourceController
2
- update.after :expire_cache
3
-
4
- def new
5
- @page = @object
6
- end
7
-
8
- def edit
9
- @page = @object
10
- end
11
-
12
- private
13
- def expire_cache
14
- expire_page :controller => '/static_content', :action => 'show', :path => @object.slug
15
- end
16
- end
@@ -1,33 +0,0 @@
1
- Spree::BaseController.class_eval do
2
- # ProductsHelper needed for seo_url method used when generating
3
- # taxonomies partial in content/show.html.erb.
4
- helper :products
5
- # Use before_filter instead of prepend_before_filter to ensure that
6
- # ApplicationController filters that the view may require are run.
7
- before_filter :render_page_if_exists
8
-
9
- # Checks if page is not beeing overriden by static one that starts with /
10
- #
11
- # Using request.path allows us to override dynamic pages including
12
- # the home page, product and taxon pages.
13
- def render_page_if_exists
14
- # If we don't know if page exists we assume it's and we query DB.
15
- # But we realy don't want to query DB on each page we're sure doesn't exist!
16
- return if Rails.cache.fetch('page_not_exist/'+request.path)
17
-
18
- if @page = Page.visible.find_by_slug(request.path)
19
-
20
- #load @content object to load correct meta_keywords & meta_description
21
- @content = @page
22
-
23
- if @page.layout && !@page.layout.empty?
24
- render :template => 'static_content/show', :layout => @page.layout
25
- else
26
- render :template => 'static_content/show'
27
- end
28
- else
29
- Rails.cache.write('page_not_exist/'+request.path, true)
30
- return(nil)
31
- end
32
- end
33
- end
@@ -1,15 +0,0 @@
1
- <%= f.inputs do %>
2
- <%= f.input :title %>
3
- <%= f.input :slug %>
4
- <%= f.input :body %>
5
- <%= f.input :foreign_link %>
6
- <%= f.input :meta_title %>
7
- <%= f.input :meta_keywords %>
8
- <%= f.input :meta_description %>
9
- <%= f.input :show_in_sidebar %>
10
- <%= f.input :show_in_header %>
11
- <%= f.input :show_in_footer %>
12
- <%= f.input :position %>
13
- <%= f.input :layout %>
14
- <%= f.input :visible %>
15
- <% end %>
@@ -1,10 +0,0 @@
1
- <h1><%= t("static_content.editing_page") %></h1>
2
- <%= render "shared/error_messages", :target => @page %>
3
-
4
- <%= semantic_form_for([:admin, @page]) do |f| -%>
5
- <%= render :partial => "form", :locals => { :f => f } %>
6
- <p class="form-buttons">
7
- <%= button t("actions.update"), nil, 'submit' %>
8
- <%= t("or") %> <%= link_to t("actions.cancel"), admin_pages_path %>
9
- </p>
10
- <% end %>
@@ -1,10 +0,0 @@
1
- <h1><%= t("static_content.new_page") %></h1>
2
- <%= render "shared/error_messages", :target => @page %>
3
-
4
- <%= semantic_form_for([:admin, @page]) do |f| %>
5
- <%= render :partial => "form", :locals => { :f => f } %>
6
- <p class="form-buttons">
7
- <%= button t("actions.create"), nil, 'submit' %>
8
- <%= t("or") %> <%= link_to t("actions.cancel"), admin_pages_path %>
9
- </p>
10
- <% end %>
@@ -1,14 +0,0 @@
1
- <% content_for :head do -%>
2
- <meta name="title" content="<%=@page.title%>">
3
- <% end -%>
4
- <% content_for :sidebar do %>
5
- <% if "products" == @current_controller && @taxon %>
6
- <%= render :partial => "shared/filters" %>
7
- <% else %>
8
- <%= render :partial => "shared/taxonomies" %>
9
- <% end %>
10
- <% end %>
11
- <h1><%= @page.title %></h1>
12
- <div id="page_content">
13
- <%= raw @page.body %>
14
- </div>