spree_essential_cms 0.2.1 → 0.3.0.rc1
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.
- data/README.md +94 -68
- data/app/controllers/{admin → spree/admin}/contents_controller.rb +11 -11
- data/app/controllers/{admin → spree/admin}/page_images_controller.rb +3 -3
- data/app/controllers/{admin → spree/admin}/pages_controller.rb +10 -10
- data/app/controllers/{page_controller.rb → spree/page_controller.rb} +8 -7
- data/app/controllers/spree/pages_controller.rb +28 -0
- data/app/controllers/{spree_base_controller_decorator.rb → spree/spree_base_controller_decorator.rb} +4 -4
- data/app/models/{content.rb → spree/content.rb} +1 -1
- data/app/models/{page.rb → spree/page.rb} +3 -3
- data/app/models/spree/page_image.rb +31 -0
- data/app/views/{admin → spree/admin}/contents/_form.html.erb +0 -0
- data/app/views/{admin → spree/admin}/contents/edit.html.erb +3 -3
- data/app/views/{admin → spree/admin}/contents/index.html.erb +3 -3
- data/app/views/{admin → spree/admin}/contents/new.html.erb +3 -3
- data/app/views/spree/admin/contents/show.html.erb +11 -0
- data/app/views/{admin → spree/admin}/page_images/_form.html.erb +0 -0
- data/app/views/{admin → spree/admin}/page_images/edit.html.erb +3 -3
- data/app/views/{admin → spree/admin}/page_images/index.html.erb +2 -2
- data/app/views/{admin → spree/admin}/page_images/new.html.erb +1 -1
- data/app/views/{admin → spree/admin}/pages/_form.html.erb +1 -1
- data/app/views/{admin → spree/admin}/pages/edit.html.erb +3 -3
- data/app/views/{admin → spree/admin}/pages/index.html.erb +2 -2
- data/app/views/{admin → spree/admin}/pages/new.html.erb +2 -2
- data/app/views/{admin → spree/admin}/pages/show.html.erb +2 -2
- data/app/views/{admin → spree/admin}/shared/_page_tabs.html.erb +0 -0
- data/app/views/spree/pages/home.html.erb +28 -0
- data/app/views/spree/pages/show.html.erb +3 -0
- data/app/views/{shared → spree/shared}/_content.html.erb +0 -0
- data/app/views/{shared → spree/shared}/_main_menu.html.erb +0 -0
- data/app/views/{shared → spree/shared}/_slideshow.html.erb +0 -0
- data/config/locales/en.yml +30 -28
- data/config/routes.rb +9 -9
- data/lib/generators/spree_essentials/cms_generator.rb +1 -0
- data/lib/generators/templates/db/migrate/add_spree_namespace.rb +11 -0
- data/lib/spree_essential_cms.rb +1 -1
- data/lib/spree_essential_cms/version.rb +1 -1
- data/lib/tasks/sample.rake +1 -1
- metadata +49 -51
- data/app/controllers/pages_controller.rb +0 -28
- data/app/models/page_image.rb +0 -40
- data/app/views/admin/contents/show.html.erb +0 -11
- data/app/views/pages/home.html.erb +0 -28
- data/app/views/pages/show.html.erb +0 -3
data/README.md
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
# Spree Essential CMS [](http://travis-ci.org/citrus/spree_essential_cms)
|
2
2
|
|
3
|
+
A robust CMS for Spree Commerce.
|
3
4
|
|
5
|
+
|
6
|
+
------------------------------------------------------------------------------
|
4
7
|
Installation
|
5
|
-
|
8
|
+
------------------------------------------------------------------------------
|
6
9
|
|
7
10
|
If you don't already have an existing Spree site, [click here](https://gist.github.com/946719) then come back later... You can also read the Spree docs [here](http://spreecommerce.com/documentation/getting_started.html)...
|
8
11
|
|
@@ -10,37 +13,46 @@ Otherwise, follow these steps to get up and running with SpreeEssentialCms:
|
|
10
13
|
|
11
14
|
Add spree_essential_cms to your Gemfile:
|
12
15
|
|
13
|
-
|
16
|
+
```ruby
|
17
|
+
gem 'spree_essential_cms', '>= 0.2.1'
|
18
|
+
```
|
14
19
|
|
15
20
|
Now, bundle up with:
|
16
21
|
|
17
|
-
|
22
|
+
```bash
|
23
|
+
bundle install
|
24
|
+
```
|
18
25
|
|
19
26
|
Then run the generators to create the migration files:
|
20
27
|
|
21
|
-
|
22
|
-
|
28
|
+
```bash
|
29
|
+
bundle exec rails g spree_essentials:install
|
30
|
+
bundle exec rails g spree_essentials:cms
|
31
|
+
```
|
23
32
|
|
24
33
|
Now migrate your database:
|
25
34
|
|
26
|
-
|
27
|
-
|
28
|
-
|
35
|
+
```bash
|
36
|
+
bundle exec rake db:migrate
|
37
|
+
```
|
29
38
|
|
30
|
-
|
31
|
-
|
39
|
+
Boot your server and checkout the admin at `localhost:3000/admin`!
|
32
40
|
|
41
|
+
```bash
|
42
|
+
bundle exec rails s
|
43
|
+
```
|
33
44
|
|
34
|
-
Usage
|
35
|
-
-----
|
36
45
|
|
37
|
-
|
46
|
+
------------------------------------------------------------------------------
|
47
|
+
Usage
|
48
|
+
------------------------------------------------------------------------------
|
38
49
|
|
50
|
+
Basic usage of this CMS is trivial. Create pages and add content...
|
39
51
|
|
40
|
-
|
52
|
+
Pages also have images so you can create galleries or slideshows.
|
41
53
|
|
42
54
|
|
43
|
-
|
55
|
+
### Content Contexts
|
44
56
|
|
45
57
|
Contexts allow you to place different forms of content in various places of a page. A slideshow or a sidebar might be good examples...
|
46
58
|
|
@@ -48,70 +60,79 @@ You can set a content's context (say that ten times fast!) under the 'Optional F
|
|
48
60
|
|
49
61
|
In your view you'll be able to grab those bits of content like so:
|
50
62
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
- if @sidebar = @page.for_context('sidebar').first
|
57
|
-
- content_for :sidebar do
|
58
|
-
= render 'shared/your_custom_sidebar', :content => @sidebar
|
59
|
-
|
63
|
+
```haml
|
64
|
+
.slideshow
|
65
|
+
- if @slides = @page.for_context('slideshow')
|
66
|
+
= render 'shared/content', :content => @slides
|
60
67
|
|
68
|
+
- if @sidebar = @page.for_context('sidebar').first
|
69
|
+
- content_for :sidebar do
|
70
|
+
= render 'shared/your_custom_sidebar', :content => @sidebar
|
71
|
+
```
|
61
72
|
|
62
73
|
|
63
|
-
|
74
|
+
### Custom image sizes
|
64
75
|
|
65
76
|
Use a content decorator when you want different contexts to have their own image sizes:
|
66
77
|
|
67
78
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
end
|
74
|
-
|
75
|
-
# or set a custom size for each context
|
76
|
-
def attachment_sizes
|
77
|
-
case context
|
78
|
-
when 'slideshow'
|
79
|
-
sizes = default_attachment_sizes.merge(:slide => '955x476#')
|
80
|
-
when 'main'
|
81
|
-
sizes = default_attachment_sizes.merge(:custom => '580x289#')
|
82
|
-
when 'small-top'
|
83
|
-
sizes = default_attachment_sizes.merge(:custom => '364x177#')
|
84
|
-
when 'small-bottom'
|
85
|
-
sizes = default_attachment_sizes.merge(:custom => '364x109#')
|
86
|
-
else
|
87
|
-
sizes = default_attachment_sizes
|
88
|
-
end
|
89
|
-
sizes
|
90
|
-
end
|
91
|
-
|
92
|
-
end
|
79
|
+
```ruby
|
80
|
+
|
81
|
+
# app/models/content_decorator.rb
|
82
|
+
|
83
|
+
Content.class_eval do
|
93
84
|
|
85
|
+
# override default image sizes
|
86
|
+
def default_attachment_sizes
|
87
|
+
{ :mini => '48x48>', :medium => '427x287>' }
|
88
|
+
end
|
94
89
|
|
90
|
+
# or set a custom size for each context
|
91
|
+
def attachment_sizes
|
92
|
+
case context
|
93
|
+
when 'slideshow'
|
94
|
+
sizes = default_attachment_sizes.merge(:slide => '955x476#')
|
95
|
+
when 'main'
|
96
|
+
sizes = default_attachment_sizes.merge(:custom => '580x289#')
|
97
|
+
when 'small-top'
|
98
|
+
sizes = default_attachment_sizes.merge(:custom => '364x177#')
|
99
|
+
when 'small-bottom'
|
100
|
+
sizes = default_attachment_sizes.merge(:custom => '364x109#')
|
101
|
+
else
|
102
|
+
sizes = default_attachment_sizes
|
103
|
+
end
|
104
|
+
sizes
|
105
|
+
end
|
95
106
|
|
107
|
+
end
|
108
|
+
```
|
96
109
|
|
97
110
|
|
98
|
-
|
111
|
+
------------------------------------------------------------------------------
|
99
112
|
Demo
|
100
|
-
|
113
|
+
------------------------------------------------------------------------------
|
101
114
|
|
102
115
|
You can easily use the test/dummy app as a demo of spree_essential_cms. Just `cd` to where you develop and run:
|
103
|
-
|
104
|
-
git clone git://github.com/citrus/spree_essential_cms.git
|
105
|
-
cd spree_essential_cms
|
106
|
-
mv lib/dummy_hooks/after_migrate.rb.sample lib/dummy_hooks/after_migrate.rb
|
107
|
-
bundle install
|
108
|
-
bundle exec dummier
|
109
|
-
cd test/dummy
|
110
|
-
rails s
|
111
|
-
|
112
116
|
|
117
|
+
```bash
|
118
|
+
git clone git://github.com/citrus/spree_essential_cms.git
|
119
|
+
cd spree_essential_cms
|
120
|
+
cp test/dummy_hooks/after_migrate.rb.sample test/dummy_hooks/after_migrate.rb
|
121
|
+
bundle install
|
122
|
+
bundle exec dummier
|
123
|
+
cd test/dummy
|
124
|
+
bundle exec rails s
|
125
|
+
```
|
126
|
+
|
127
|
+
|
128
|
+
------------------------------------------------------------------------------
|
113
129
|
Change Log
|
114
|
-
|
130
|
+
------------------------------------------------------------------------------
|
131
|
+
|
132
|
+
**2012/1/16**
|
133
|
+
|
134
|
+
* Add support for Spree 1.0.x
|
135
|
+
|
115
136
|
|
116
137
|
**0.2.1 - 2011/12/15**
|
117
138
|
|
@@ -141,8 +162,9 @@ Change Log
|
|
141
162
|
* Extracted from the Spree Essentials core.
|
142
163
|
|
143
164
|
|
165
|
+
------------------------------------------------------------------------------
|
144
166
|
To Do
|
145
|
-
|
167
|
+
------------------------------------------------------------------------------
|
146
168
|
|
147
169
|
* more tests... many many more.
|
148
170
|
* optimizations
|
@@ -150,19 +172,23 @@ To Do
|
|
150
172
|
* add widgets that you can drop into any page
|
151
173
|
* page and menu caching/sweeping
|
152
174
|
* nested set for pages
|
153
|
-
* 0.30 and 0.40 compatibility
|
154
175
|
* create wiki pages
|
155
176
|
|
156
177
|
|
178
|
+
------------------------------------------------------------------------------
|
157
179
|
Contributors
|
158
|
-
|
180
|
+
------------------------------------------------------------------------------
|
181
|
+
|
182
|
+
* Spencer Steffen ([@citrus](https://github.com/citrus))
|
183
|
+
* Kyle West ([@kylewest](https://github.com/kylewest))
|
184
|
+
* [@kpitn](https://github.com/kpitn)
|
159
185
|
|
160
|
-
So far it's just me; Spencer Steffen.
|
161
186
|
|
162
187
|
If you'd like to help out feel free to fork and send me pull requests!
|
163
188
|
|
164
189
|
|
190
|
+
------------------------------------------------------------------------------
|
165
191
|
License
|
166
|
-
|
192
|
+
------------------------------------------------------------------------------
|
167
193
|
|
168
|
-
Copyright (c) 2011 Spencer Steffen & Citrus, released under the New BSD License All rights reserved.
|
194
|
+
Copyright (c) 2011 - 2012 Spencer Steffen & Citrus, released under the New BSD License All rights reserved.
|
@@ -1,33 +1,33 @@
|
|
1
|
-
class ::Admin::ContentsController < ::Admin::ResourceController
|
1
|
+
class Spree::Admin::ContentsController < Spree::Admin::ResourceController
|
2
2
|
|
3
3
|
before_filter :load_resource
|
4
4
|
before_filter :parent, :only => :index
|
5
|
-
|
5
|
+
|
6
6
|
before_filter :get_pages, :only => [ :new, :edit, :create, :update ]
|
7
7
|
|
8
|
-
belongs_to
|
9
|
-
|
8
|
+
belongs_to 'spree/page'
|
9
|
+
|
10
10
|
def update_positions
|
11
11
|
@page = parent
|
12
12
|
params[:positions].each do |id, index|
|
13
13
|
@page.contents.update_all(['position=?', index], ['id=?', id])
|
14
14
|
end
|
15
15
|
respond_to do |format|
|
16
|
-
format.html { redirect_to admin_page_contents_url(@
|
16
|
+
format.html { redirect_to admin_page_contents_url(@page) }
|
17
17
|
format.js { render :text => 'Ok' }
|
18
18
|
end
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
private
|
22
|
-
|
22
|
+
|
23
23
|
def get_pages
|
24
|
-
@pages = Page.order(:position).all
|
24
|
+
@pages = Spree::Page.order(:position).all
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
def parent
|
28
|
-
|
28
|
+
@page ||= Spree::Page.find_by_path(params[:page_id])
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
def collection
|
32
32
|
params[:search] ||= {}
|
33
33
|
params[:search][:meta_sort] ||= "page.asc"
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class Admin::PageImagesController < Admin::ResourceController
|
1
|
+
class Spree::Admin::PageImagesController < Spree::Admin::ResourceController
|
2
2
|
|
3
3
|
before_filter :load_data
|
4
4
|
|
@@ -8,7 +8,7 @@ class Admin::PageImagesController < Admin::ResourceController
|
|
8
8
|
|
9
9
|
def update_positions
|
10
10
|
params[:positions].each do |id, index|
|
11
|
-
PageImage.update_all(['position=?', index], ['id=?', id])
|
11
|
+
Spree::PageImage.update_all(['position=?', index], ['id=?', id])
|
12
12
|
end
|
13
13
|
respond_to do |format|
|
14
14
|
format.js { render :text => 'Ok' }
|
@@ -22,7 +22,7 @@ class Admin::PageImagesController < Admin::ResourceController
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def load_data
|
25
|
-
@page = Page.find_by_path(params[:page_id])
|
25
|
+
@page = Spree::Page.find_by_path(params[:page_id])
|
26
26
|
end
|
27
27
|
|
28
28
|
def set_viewable
|
@@ -1,23 +1,23 @@
|
|
1
|
-
class ::Admin::PagesController < ::Admin::ResourceController
|
1
|
+
class Spree::Admin::PagesController < Spree::Admin::ResourceController
|
2
2
|
|
3
3
|
before_filter :load_resource
|
4
|
-
|
4
|
+
|
5
5
|
def index
|
6
6
|
@pages = collection
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
def location_after_save
|
10
10
|
case params[:action]
|
11
11
|
when "create"
|
12
12
|
edit_admin_page_content_path(@page, @page.contents.first)
|
13
13
|
else
|
14
14
|
admin_page_path(@page)
|
15
|
-
end
|
15
|
+
end
|
16
16
|
end
|
17
17
|
|
18
18
|
def update_positions
|
19
19
|
params[:positions].each do |id, index|
|
20
|
-
Page.update_all(['position=?', index], ['id=?', id])
|
20
|
+
Spree::Page.update_all(['position=?', index], ['id=?', id])
|
21
21
|
end
|
22
22
|
respond_to do |format|
|
23
23
|
format.html { redirect_to admin_pages_path }
|
@@ -26,16 +26,16 @@ class ::Admin::PagesController < ::Admin::ResourceController
|
|
26
26
|
end
|
27
27
|
|
28
28
|
private
|
29
|
-
|
29
|
+
|
30
30
|
def find_resource
|
31
|
-
@page ||= Page.find_by_path(params[:id])
|
31
|
+
@page ||= ::Spree::Page.find_by_path(params[:id])
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
def collection
|
35
35
|
params[:search] ||= {}
|
36
36
|
params[:search][:meta_sort] ||= "page.asc"
|
37
|
-
@search = Page.metasearch(params[:search])
|
37
|
+
@search = Spree::Page.metasearch(params[:search])
|
38
38
|
@collection = @search.page(params[:page]).per(Spree::Config[:orders_per_page])
|
39
39
|
end
|
40
40
|
|
41
|
-
end
|
41
|
+
end
|
@@ -1,19 +1,20 @@
|
|
1
|
-
class PageController < Spree::BaseController
|
1
|
+
class Spree::PageController < Spree::BaseController
|
2
2
|
|
3
3
|
before_filter :get_page, :only => :index
|
4
|
-
|
4
|
+
|
5
|
+
|
5
6
|
def show
|
6
7
|
end
|
7
|
-
|
8
|
+
|
8
9
|
private
|
9
|
-
|
10
|
+
|
10
11
|
def get_page
|
11
|
-
@page = Page.active.find_by_path(page_path)
|
12
|
+
@page = Spree::Page.active.find_by_path(page_path)
|
12
13
|
return raise ActionController::RoutingError.new(page_path) unless @page
|
13
14
|
end
|
14
|
-
|
15
|
+
|
15
16
|
def page_path
|
16
17
|
params[:path] || "/"
|
17
18
|
end
|
18
|
-
|
19
|
+
|
19
20
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class Spree::PagesController < Spree::BaseController
|
2
|
+
|
3
|
+
before_filter :get_page, :only => :show
|
4
|
+
|
5
|
+
def show
|
6
|
+
if @page.root?
|
7
|
+
@posts = Spree::Post.live.limit(5) if SpreeEssentials.has?(:blog)
|
8
|
+
@articles = Spree::Article.live.limit(5) if SpreeEssentials.has?(:news)
|
9
|
+
render :template => 'spree/pages/home'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def get_page
|
16
|
+
@page = Spree::Page.includes(:images, :contents).active.find_by_path(page_path) rescue nil
|
17
|
+
raise ActionController::RoutingError.new(page_path) if @page.nil?
|
18
|
+
end
|
19
|
+
|
20
|
+
def page_path
|
21
|
+
params[:page_path].blank? ? "/" : params[:page_path]
|
22
|
+
end
|
23
|
+
|
24
|
+
def accurate_title
|
25
|
+
@page.meta_title
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
data/app/controllers/{spree_base_controller_decorator.rb → spree/spree_base_controller_decorator.rb}
RENAMED
@@ -1,11 +1,11 @@
|
|
1
1
|
Spree::BaseController.class_eval do
|
2
|
-
|
2
|
+
|
3
3
|
before_filter :get_pages
|
4
|
-
|
4
|
+
|
5
5
|
def get_pages
|
6
6
|
admin = request.path =~ /^\/admin/
|
7
|
-
@page = Page.find_by_path(request.path) rescue nil unless admin
|
8
|
-
scope = admin ? Page.scoped : Page.visible
|
7
|
+
@page = Spree::Page.find_by_path(request.path) rescue nil unless admin
|
8
|
+
scope = admin ? Spree::Page.scoped : Spree::Page.visible
|
9
9
|
@pages = scope.order(:position).all
|
10
10
|
end
|
11
11
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class Page < ActiveRecord::Base
|
1
|
+
class Spree::Page < ActiveRecord::Base
|
2
2
|
|
3
3
|
alias_attribute :name, :title
|
4
4
|
|
@@ -11,13 +11,13 @@ class Page < ActiveRecord::Base
|
|
11
11
|
scope :visible, active.where(:visible => true)
|
12
12
|
|
13
13
|
has_many :contents, :order => :position, :dependent => :destroy
|
14
|
-
has_many :images, :as => :viewable, :class_name => 'PageImage', :order => :position, :dependent => :destroy
|
14
|
+
has_many :images, :as => :viewable, :class_name => 'Spree::PageImage', :order => :position, :dependent => :destroy
|
15
15
|
|
16
16
|
before_validation :set_defaults
|
17
17
|
after_create :create_default_content
|
18
18
|
|
19
19
|
def self.find_by_path(_path)
|
20
|
-
return super('/') if _path == '_home_' &&
|
20
|
+
return super('/') if _path == '_home_' && self.exists?(:path => '/')
|
21
21
|
super _path.to_s.sub(/^\/*/, '/').gsub('--', '/')
|
22
22
|
end
|
23
23
|
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class Spree::PageImage < Spree::Asset
|
2
|
+
|
3
|
+
validate :no_attachement_errors
|
4
|
+
|
5
|
+
has_attached_file :attachment,
|
6
|
+
:styles => Proc.new{ |clip| clip.instance.attachment_sizes },
|
7
|
+
:default_style => :medium
|
8
|
+
|
9
|
+
def image_content?
|
10
|
+
attachment_content_type.match(/\/(jpeg|png|gif|tiff|x-photoshop)/)
|
11
|
+
end
|
12
|
+
|
13
|
+
def attachment_sizes
|
14
|
+
sizes = {}
|
15
|
+
if image_content?
|
16
|
+
sizes.merge!(:mini => '48x48>', :small => '150x150>', :medium => '420x300>', :large => '900x650>')
|
17
|
+
sizes.merge!(:slide => '950x250#') if viewable.respond_to?(:root?) && viewable.root?
|
18
|
+
end
|
19
|
+
sizes
|
20
|
+
end
|
21
|
+
|
22
|
+
def no_attachement_errors
|
23
|
+
unless attachment.errors.empty?
|
24
|
+
# uncomment this to get rid of the less-than-useful interrim messages
|
25
|
+
errors.clear
|
26
|
+
errors.add :attachment, "Paperclip returned errors for file '#{attachment_file_name}' - check ImageMagick installation or image source file."
|
27
|
+
false
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
File without changes
|
@@ -1,9 +1,9 @@
|
|
1
|
-
<%= render :partial => 'admin/shared/contents_sub_menu' %>
|
1
|
+
<%= render :partial => 'spree/admin/shared/contents_sub_menu' %>
|
2
2
|
|
3
|
-
<%= render :partial => 'admin/shared/page_tabs', :locals => {:current => 'Contents'} %>
|
3
|
+
<%= render :partial => 'spree/admin/shared/page_tabs', :locals => {:current => 'Contents'} %>
|
4
4
|
|
5
5
|
<% if @content.try(:errors).present? %>
|
6
|
-
<%= render 'shared/error_messages', :target => @content %>
|
6
|
+
<%= render 'spree/shared/error_messages', :target => @content %>
|
7
7
|
<% end %>
|
8
8
|
|
9
9
|
<h2><%= t('.edit_content') %></h2>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= render :partial => 'admin/shared/contents_sub_menu' %>
|
1
|
+
<%= render :partial => 'spree/admin/shared/contents_sub_menu' %>
|
2
2
|
|
3
3
|
<div class='toolbar'>
|
4
4
|
<ul class='actions'>
|
@@ -9,7 +9,7 @@
|
|
9
9
|
<br class='clear' />
|
10
10
|
</div>
|
11
11
|
|
12
|
-
<%= render :partial => 'admin/shared/page_tabs', :locals => {:current => 'Contents'} %>
|
12
|
+
<%= render :partial => 'spree/admin/shared/page_tabs', :locals => {:current => 'Contents'} %>
|
13
13
|
|
14
14
|
<h2><%= t('.listing_contents') %></h2>
|
15
15
|
|
@@ -42,7 +42,7 @@
|
|
42
42
|
<div class="box">
|
43
43
|
<h3><%= t(:search) %></h3>
|
44
44
|
|
45
|
-
<% @content = Content.metasearch %>
|
45
|
+
<% @content = Spree::Content.metasearch %>
|
46
46
|
<%= form_for [:admin, @page, @content] do |f| %>
|
47
47
|
<p>
|
48
48
|
<label><%= t('content.title') %></label><br />
|
@@ -1,9 +1,9 @@
|
|
1
|
-
<%= render :partial => 'admin/shared/contents_sub_menu' %>
|
1
|
+
<%= render :partial => 'spree/admin/shared/contents_sub_menu' %>
|
2
2
|
|
3
|
-
<%= render :partial => 'admin/shared/page_tabs', :locals => {:current => 'Contents'} %>
|
3
|
+
<%= render :partial => 'spree/admin/shared/page_tabs', :locals => {:current => 'Contents'} %>
|
4
4
|
|
5
5
|
<% if @content.try(:errors).present? %>
|
6
|
-
<%= render 'shared/error_messages', :target => @content %>
|
6
|
+
<%= render 'spree/shared/error_messages', :target => @content %>
|
7
7
|
<% end %>
|
8
8
|
|
9
9
|
<h2><%= t('.new_content') %></h2>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<%= render :partial => 'spree/admin/shared/contents_sub_menu' %>
|
2
|
+
<%= render :partial => 'spree/admin/shared/page_tabs', :locals => {:current => 'Contents'} %>
|
3
|
+
|
4
|
+
<h2>Content: <%= h @content.title %></h2>
|
5
|
+
|
6
|
+
<%= RDiscount.new(@content.body).to_html.html_safe %>
|
7
|
+
|
8
|
+
<p>
|
9
|
+
<%= link_to_edit @content %>
|
10
|
+
<%= link_to t('back'), collection_url %>
|
11
|
+
</p>
|
File without changes
|
@@ -1,9 +1,9 @@
|
|
1
|
-
<%= render :partial => 'admin/shared/contents_sub_menu' %>
|
1
|
+
<%= render :partial => 'spree/admin/shared/contents_sub_menu' %>
|
2
2
|
|
3
|
-
<%= render :partial => 'admin/shared/page_tabs', :locals => {:current => "Images"} %>
|
3
|
+
<%= render :partial => 'spree/admin/shared/page_tabs', :locals => {:current => "Images"} %>
|
4
4
|
|
5
5
|
<% if @page_image.try(:errors).present? %>
|
6
|
-
<%= render 'shared/error_messages', :target => @page_image %>
|
6
|
+
<%= render 'spree/shared/error_messages', :target => @page_image %>
|
7
7
|
<% end %>
|
8
8
|
|
9
9
|
<%= form_for([:admin, @page.id, @page_image], :url => admin_page_image_url(@page, @page_image), :html => { :multipart => true }) do |f| %>
|
@@ -1,6 +1,6 @@
|
|
1
|
-
<%= render :partial => 'admin/shared/contents_sub_menu' %>
|
1
|
+
<%= render :partial => 'spree/admin/shared/contents_sub_menu' %>
|
2
2
|
|
3
|
-
<%= render :partial => 'admin/shared/page_tabs', :locals => {:current => "Images"} %>
|
3
|
+
<%= render :partial => 'spree/admin/shared/page_tabs', :locals => {:current => "Images"} %>
|
4
4
|
|
5
5
|
<table class="index sortable">
|
6
6
|
<tr>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<h3><%= t("new_image") %></h3>
|
2
2
|
|
3
|
-
<%= render 'shared/error_messages', :target => @page_image %>
|
3
|
+
<%= render 'spree/shared/error_messages', :target => @page_image %>
|
4
4
|
|
5
5
|
<%= form_for(@page_image, :url => admin_page_images_path(@page), :html => { :multipart => true }) do |form| %>
|
6
6
|
<table class="basic-table">
|
@@ -25,7 +25,7 @@
|
|
25
25
|
<%= form.field_container :accessible do %>
|
26
26
|
<%= form.check_box :accessible, :class => "text" %>
|
27
27
|
<%= form.label :accessible, t('page.accessible') %>
|
28
|
-
|
28
|
+
<em><%= t('page.explain_accessible') %></em>
|
29
29
|
<%= error_message_on :page, :accessible %>
|
30
30
|
<% end %>
|
31
31
|
|
@@ -1,9 +1,9 @@
|
|
1
|
-
<%= render :partial => 'admin/shared/contents_sub_menu' %>
|
1
|
+
<%= render :partial => 'spree/admin/shared/contents_sub_menu' %>
|
2
2
|
|
3
|
-
<%= render :partial => 'admin/shared/page_tabs', :locals => {:current => 'Page Details'} %>
|
3
|
+
<%= render :partial => 'spree/admin/shared/page_tabs', :locals => {:current => 'Page Details'} %>
|
4
4
|
|
5
5
|
<% if @page.try(:errors).present? %>
|
6
|
-
<%= render 'shared/error_messages', :target => @page %>
|
6
|
+
<%= render 'spree/shared/error_messages', :target => @page %>
|
7
7
|
<% end %>
|
8
8
|
|
9
9
|
<%= form_for([:admin, @page]) do |f| %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= render :partial => 'admin/shared/contents_sub_menu' %>
|
1
|
+
<%= render :partial => 'spree/admin/shared/contents_sub_menu' %>
|
2
2
|
|
3
3
|
<div class='toolbar'>
|
4
4
|
<ul class='actions'>
|
@@ -45,7 +45,7 @@
|
|
45
45
|
<div class="box">
|
46
46
|
<h3><%= t(:search) %></h3>
|
47
47
|
|
48
|
-
<% @page = Page.metasearch %>
|
48
|
+
<% @page = Spree::Page.metasearch %>
|
49
49
|
<%= form_for [:admin, @page] do |f| %>
|
50
50
|
<p>
|
51
51
|
<label><%= t '.title_contains' %></label><br />
|
@@ -1,7 +1,7 @@
|
|
1
|
-
<%= render :partial => 'admin/shared/contents_sub_menu' %>
|
1
|
+
<%= render :partial => 'spree/admin/shared/contents_sub_menu' %>
|
2
2
|
|
3
3
|
<% if @page.try(:errors).present? %>
|
4
|
-
<%= render 'shared/error_messages', :target => @page %>
|
4
|
+
<%= render 'spree/shared/error_messages', :target => @page %>
|
5
5
|
<% end %>
|
6
6
|
|
7
7
|
<h1><%= t('.new_page') %></h1>
|
@@ -1,6 +1,6 @@
|
|
1
|
-
<%= render :partial => 'admin/shared/contents_sub_menu' %>
|
1
|
+
<%= render :partial => 'spree/admin/shared/contents_sub_menu' %>
|
2
2
|
|
3
|
-
<%= render :partial => 'admin/shared/page_tabs', :locals => {:current => "Page Details"} %>
|
3
|
+
<%= render :partial => 'spree/admin/shared/page_tabs', :locals => {:current => "Page Details"} %>
|
4
4
|
|
5
5
|
<h3>Meta Data:</h3>
|
6
6
|
<p>
|
File without changes
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<% unless @page.images.empty? %>
|
2
|
+
<%= render 'spree/shared/slideshow', :images => @page.images, :size => :slide %>
|
3
|
+
<% end %>
|
4
|
+
|
5
|
+
<% if @page.has_context?('intro') %>
|
6
|
+
<div class="intro">
|
7
|
+
<%= render 'spree/shared/content', :content => @page.for_context('intro').first %>
|
8
|
+
</div>
|
9
|
+
<% end %>
|
10
|
+
|
11
|
+
<div class="left">
|
12
|
+
<%= render :partial => 'spree/shared/content', :collection => @page.for_context('main') %>
|
13
|
+
</div>
|
14
|
+
|
15
|
+
<div class="right">
|
16
|
+
<% if defined?(Spree::SpreeEssentialBlog) && !@posts.blank? %>
|
17
|
+
<div class="home-posts">
|
18
|
+
<h1><%= t('blog.home.title') %></h1>
|
19
|
+
<%= render :partial => 'spree/blog/shared/preview', :collection => @posts, :as => :post %>
|
20
|
+
</div>
|
21
|
+
<% end %>
|
22
|
+
<% if defined?(Spree::SpreeEssentialNews) && !@articles.blank? %>
|
23
|
+
<div class="home-articles">
|
24
|
+
<h1><%= t('news.home.title') %></h1>
|
25
|
+
<%= render :partial => 'spree/news/articles/preview', :collection => @articles, :as => :article %>
|
26
|
+
</div>
|
27
|
+
<% end %>
|
28
|
+
</div>
|
File without changes
|
File without changes
|
File without changes
|
data/config/locales/en.yml
CHANGED
@@ -27,31 +27,33 @@ en:
|
|
27
27
|
|
28
28
|
pages: Pages
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
30
|
+
|
31
|
+
spree:
|
32
|
+
admin:
|
33
|
+
subnav:
|
34
|
+
pages: Pages
|
35
|
+
shared:
|
36
|
+
contents_tab:
|
37
|
+
content: Content
|
38
|
+
page_tabs:
|
39
|
+
editing_page: Editing Page
|
40
|
+
page_details: Page Details
|
41
|
+
contents: Contents
|
42
|
+
images: Images
|
43
|
+
pages:
|
44
|
+
index:
|
45
|
+
title: Title
|
46
|
+
listing_pages: Listing Pages
|
47
|
+
new_page: New Page
|
48
|
+
title_contains: Title
|
49
|
+
new:
|
50
|
+
new_page: New Page
|
51
|
+
|
52
|
+
contents:
|
53
|
+
index:
|
54
|
+
new_content: New Content
|
55
|
+
listing_contents: Listing Contents
|
56
|
+
new:
|
57
|
+
new_content: New Content
|
58
|
+
edit:
|
59
|
+
edit_content: Edit Content
|
data/config/routes.rb
CHANGED
@@ -1,37 +1,37 @@
|
|
1
|
-
class PossiblePage
|
1
|
+
class Spree::PossiblePage
|
2
2
|
def self.matches?(request)
|
3
3
|
path = request.fullpath
|
4
4
|
return if path =~ /(^\/(admin|account|cart|checkout|content|login|pg\/|orders|products|s\/|session|signup|shipments|states|t\/|tax_categories|user)+)/
|
5
|
-
count = Page.active.where(:path => path).count
|
5
|
+
count = Spree::Page.active.where(:path => path.gsub("//","/")).count
|
6
6
|
0 < count
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
Spree::Core::Engine.routes.draw do
|
11
|
+
|
12
12
|
namespace :admin do
|
13
|
-
|
13
|
+
|
14
14
|
resources :pages do
|
15
15
|
collection do
|
16
16
|
post :update_positions
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
resources :contents do
|
20
20
|
collection do
|
21
21
|
post :update_positions
|
22
22
|
end
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
resources :images, :controller => "page_images" do
|
26
26
|
collection do
|
27
27
|
post :update_positions
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
end
|
33
33
|
|
34
|
-
constraints(PossiblePage) do
|
34
|
+
constraints(Spree::PossiblePage) do
|
35
35
|
get '(:page_path)', :to => 'pages#show', :page_path => /.*/, :as => :page
|
36
36
|
end
|
37
37
|
|
@@ -10,6 +10,7 @@ module SpreeEssentials
|
|
10
10
|
def copy_migrations
|
11
11
|
migration_template "create_pages.rb", "db/migrate/create_pages.rb"
|
12
12
|
migration_template "create_contents.rb", "db/migrate/create_contents.rb"
|
13
|
+
migration_template "add_spree_namespace.rb", "db/migrate/add_spree_namespace.rb"
|
13
14
|
end
|
14
15
|
|
15
16
|
end
|
data/lib/spree_essential_cms.rb
CHANGED
@@ -16,7 +16,7 @@ module SpreeEssentialCms
|
|
16
16
|
|
17
17
|
config.to_prepare do
|
18
18
|
#loads application's model / class decorators
|
19
|
-
Dir.glob File.expand_path("../../app/**/*_decorator
|
19
|
+
Dir.glob File.expand_path("../../app/**/*_decorator.rb", __FILE__) do |c|
|
20
20
|
Rails.configuration.cache_classes ? require(c) : load(c)
|
21
21
|
end
|
22
22
|
|
data/lib/tasks/sample.rake
CHANGED
@@ -19,7 +19,7 @@ namespace :db do
|
|
19
19
|
images = Dir[File.expand_path("../sample", __FILE__) + "/*.jpg"]
|
20
20
|
|
21
21
|
home = Page.create(:title => "Home", :path => "/")
|
22
|
-
home.contents.first.update_attributes(:body =>
|
22
|
+
home.contents.first.update_attributes(:body => FFaker::Lorem.paragraphs().join("\n\n"), :context => "main")
|
23
23
|
home.contents.create(:title => Faker::Lorem.words(3 + rand(3)).join(" "), :body => Faker::Lorem.sentence, :context => "intro")
|
24
24
|
|
25
25
|
images.each {|image|
|
metadata
CHANGED
@@ -1,30 +1,30 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_essential_cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.3.0.rc1
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Spencer Steffen
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-01-17 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: spree_essentials
|
16
|
-
requirement: &
|
16
|
+
requirement: &70176245146400 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.
|
21
|
+
version: 0.4.0.rc1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70176245146400
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: dummier
|
27
|
-
requirement: &
|
27
|
+
requirement: &70176245145720 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.2.4
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70176245145720
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: shoulda
|
38
|
-
requirement: &
|
38
|
+
requirement: &70176245145160 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 3.0.0.beta2
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70176245145160
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: factory_girl
|
49
|
-
requirement: &
|
49
|
+
requirement: &70176245144400 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 2.3.2
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70176245144400
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: capybara
|
60
|
-
requirement: &
|
60
|
+
requirement: &70176245143220 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 1.1.2
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70176245143220
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: sqlite3
|
71
|
-
requirement: &
|
71
|
+
requirement: &70176245142740 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: 1.3.5
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70176245142740
|
80
80
|
description: SpreeEssentialCms is a full featured content management system for Spree
|
81
81
|
Commerce. It's designed to be used with the spree_essentials base.
|
82
82
|
email:
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- config/locales/en.yml
|
91
91
|
- config/routes.rb
|
92
92
|
- lib/generators/spree_essentials/cms_generator.rb
|
93
|
+
- lib/generators/templates/db/migrate/add_spree_namespace.rb
|
93
94
|
- lib/generators/templates/db/migrate/create_contents.rb
|
94
95
|
- lib/generators/templates/db/migrate/create_pages.rb
|
95
96
|
- lib/spree_essential_cms/version.rb
|
@@ -99,35 +100,35 @@ files:
|
|
99
100
|
- lib/tasks/sample/sailing3.jpg
|
100
101
|
- lib/tasks/sample.rake
|
101
102
|
- app/assets/stylesheets/essentials/cms.css
|
102
|
-
- app/controllers/admin/contents_controller.rb
|
103
|
-
- app/controllers/admin/page_images_controller.rb
|
104
|
-
- app/controllers/admin/pages_controller.rb
|
105
|
-
- app/controllers/page_controller.rb
|
106
|
-
- app/controllers/pages_controller.rb
|
107
|
-
- app/controllers/spree_base_controller_decorator.rb
|
108
|
-
- app/models/content.rb
|
109
|
-
- app/models/page.rb
|
110
|
-
- app/models/page_image.rb
|
111
|
-
- app/views/admin/contents/_form.html.erb
|
112
|
-
- app/views/admin/contents/edit.html.erb
|
113
|
-
- app/views/admin/contents/index.html.erb
|
114
|
-
- app/views/admin/contents/new.html.erb
|
115
|
-
- app/views/admin/contents/show.html.erb
|
116
|
-
- app/views/admin/page_images/_form.html.erb
|
117
|
-
- app/views/admin/page_images/edit.html.erb
|
118
|
-
- app/views/admin/page_images/index.html.erb
|
119
|
-
- app/views/admin/page_images/new.html.erb
|
120
|
-
- app/views/admin/pages/_form.html.erb
|
121
|
-
- app/views/admin/pages/edit.html.erb
|
122
|
-
- app/views/admin/pages/index.html.erb
|
123
|
-
- app/views/admin/pages/new.html.erb
|
124
|
-
- app/views/admin/pages/show.html.erb
|
125
|
-
- app/views/admin/shared/_page_tabs.html.erb
|
126
|
-
- app/views/pages/home.html.erb
|
127
|
-
- app/views/pages/show.html.erb
|
128
|
-
- app/views/shared/_content.html.erb
|
129
|
-
- app/views/shared/_main_menu.html.erb
|
130
|
-
- app/views/shared/_slideshow.html.erb
|
103
|
+
- app/controllers/spree/admin/contents_controller.rb
|
104
|
+
- app/controllers/spree/admin/page_images_controller.rb
|
105
|
+
- app/controllers/spree/admin/pages_controller.rb
|
106
|
+
- app/controllers/spree/page_controller.rb
|
107
|
+
- app/controllers/spree/pages_controller.rb
|
108
|
+
- app/controllers/spree/spree_base_controller_decorator.rb
|
109
|
+
- app/models/spree/content.rb
|
110
|
+
- app/models/spree/page.rb
|
111
|
+
- app/models/spree/page_image.rb
|
112
|
+
- app/views/spree/admin/contents/_form.html.erb
|
113
|
+
- app/views/spree/admin/contents/edit.html.erb
|
114
|
+
- app/views/spree/admin/contents/index.html.erb
|
115
|
+
- app/views/spree/admin/contents/new.html.erb
|
116
|
+
- app/views/spree/admin/contents/show.html.erb
|
117
|
+
- app/views/spree/admin/page_images/_form.html.erb
|
118
|
+
- app/views/spree/admin/page_images/edit.html.erb
|
119
|
+
- app/views/spree/admin/page_images/index.html.erb
|
120
|
+
- app/views/spree/admin/page_images/new.html.erb
|
121
|
+
- app/views/spree/admin/pages/_form.html.erb
|
122
|
+
- app/views/spree/admin/pages/edit.html.erb
|
123
|
+
- app/views/spree/admin/pages/index.html.erb
|
124
|
+
- app/views/spree/admin/pages/new.html.erb
|
125
|
+
- app/views/spree/admin/pages/show.html.erb
|
126
|
+
- app/views/spree/admin/shared/_page_tabs.html.erb
|
127
|
+
- app/views/spree/pages/home.html.erb
|
128
|
+
- app/views/spree/pages/show.html.erb
|
129
|
+
- app/views/spree/shared/_content.html.erb
|
130
|
+
- app/views/spree/shared/_main_menu.html.erb
|
131
|
+
- app/views/spree/shared/_slideshow.html.erb
|
131
132
|
- Rakefile
|
132
133
|
homepage: http://github.com/citrus/spree_essential_cms
|
133
134
|
licenses: []
|
@@ -143,16 +144,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
143
144
|
version: '0'
|
144
145
|
segments:
|
145
146
|
- 0
|
146
|
-
hash:
|
147
|
+
hash: 1544382525842900464
|
147
148
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
149
|
none: false
|
149
150
|
requirements:
|
150
|
-
- - ! '
|
151
|
+
- - ! '>'
|
151
152
|
- !ruby/object:Gem::Version
|
152
|
-
version:
|
153
|
-
segments:
|
154
|
-
- 0
|
155
|
-
hash: -927433600182519188
|
153
|
+
version: 1.3.1
|
156
154
|
requirements: []
|
157
155
|
rubyforge_project:
|
158
156
|
rubygems_version: 1.8.10
|
@@ -1,28 +0,0 @@
|
|
1
|
-
class PagesController < Spree::BaseController
|
2
|
-
|
3
|
-
before_filter :get_page, :only => :show
|
4
|
-
|
5
|
-
def show
|
6
|
-
if @page.root?
|
7
|
-
@posts = Post.live.limit(5) if SpreeEssentials.has?(:blog)
|
8
|
-
@articles = Article.live.limit(5) if SpreeEssentials.has?(:news)
|
9
|
-
render :template => 'pages/home'
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
private
|
14
|
-
|
15
|
-
def get_page
|
16
|
-
@page = Page.includes(:images, :contents).active.find_by_path(page_path) rescue nil
|
17
|
-
raise ActionController::RoutingError.new(page_path) if @page.nil?
|
18
|
-
end
|
19
|
-
|
20
|
-
def page_path
|
21
|
-
params[:page_path] || "/"
|
22
|
-
end
|
23
|
-
|
24
|
-
def accurate_title
|
25
|
-
@page.meta_title
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
data/app/models/page_image.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
class PageImage < Image
|
2
|
-
|
3
|
-
validate :no_attachement_errors
|
4
|
-
|
5
|
-
if defined?(SpreeHeroku)
|
6
|
-
has_attached_file :attachment,
|
7
|
-
:styles => Proc.new{ |clip| clip.instance.attachment_sizes },
|
8
|
-
:default_style => :medium,
|
9
|
-
:path => "assets/pages/:id/:style/:basename.:extension",
|
10
|
-
:storage => "s3",
|
11
|
-
:s3_credentials => "#{Rails.root}/config/s3.yml"
|
12
|
-
else
|
13
|
-
has_attached_file :attachment,
|
14
|
-
:styles => Proc.new{ |clip| clip.instance.attachment_sizes },
|
15
|
-
:default_style => :medium,
|
16
|
-
:url => "/assets/pages/:id/:style/:basename.:extension",
|
17
|
-
:path => ":rails_root/public/assets/pages/:id/:style/:basename.:extension"
|
18
|
-
end
|
19
|
-
|
20
|
-
def image_content?
|
21
|
-
attachment_content_type.match(/\/(jpeg|png|gif|tiff|x-photoshop)/)
|
22
|
-
end
|
23
|
-
|
24
|
-
def attachment_sizes
|
25
|
-
sizes = {}
|
26
|
-
sizes.merge!(:mini => '48x48>', :small => '150x150>', :medium => '420x300>', :large => '900x650>') if image_content?
|
27
|
-
sizes.merge!(:slide => '950x250#') if viewable.respond_to?(:root?) && viewable.root?
|
28
|
-
sizes
|
29
|
-
end
|
30
|
-
|
31
|
-
def no_attachement_errors
|
32
|
-
unless attachment.errors.empty?
|
33
|
-
# uncomment this to get rid of the less-than-useful interrim messages
|
34
|
-
errors.clear
|
35
|
-
errors.add :attachment, "Paperclip returned errors for file '#{attachment_file_name}' - check ImageMagick installation or image source file."
|
36
|
-
false
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
<%= render :partial => 'admin/shared/contents_sub_menu' %>
|
2
|
-
<%= render :partial => 'admin/shared/page_tabs', :locals => {:current => 'Contents'} %>
|
3
|
-
|
4
|
-
<h2><%= h @content.title %></h2>
|
5
|
-
|
6
|
-
<%= RDiscount.new(@content.body).to_html.html_safe %>
|
7
|
-
|
8
|
-
<p>
|
9
|
-
<%= link_to_edit @user %>
|
10
|
-
<%= link_to t('back'), collection_url %>
|
11
|
-
</p>
|
@@ -1,28 +0,0 @@
|
|
1
|
-
<% unless @page.images.empty? %>
|
2
|
-
<%= render 'shared/slideshow', :images => @page.images, :size => :slide %>
|
3
|
-
<% end %>
|
4
|
-
|
5
|
-
<% if @page.has_context?('intro') %>
|
6
|
-
<div class="intro">
|
7
|
-
<%= render 'shared/content', :content => @page.for_context('intro').first %>
|
8
|
-
</div>
|
9
|
-
<% end %>
|
10
|
-
|
11
|
-
<div class="left">
|
12
|
-
<%= render :partial => 'shared/content', :collection => @page.for_context('main') %>
|
13
|
-
</div>
|
14
|
-
|
15
|
-
<div class="right">
|
16
|
-
<% if defined?(SpreeEssentialBlog) && !@posts.blank? %>
|
17
|
-
<div class="home-posts">
|
18
|
-
<h1><%= t('blog.home.title') %></h1>
|
19
|
-
<%= render :partial => 'blog/shared/preview', :collection => @posts, :as => :post %>
|
20
|
-
</div>
|
21
|
-
<% end %>
|
22
|
-
<% if defined?(SpreeEssentialNews) && !@articles.blank? %>
|
23
|
-
<div class="home-articles">
|
24
|
-
<h1><%= t('news.home.title') %></h1>
|
25
|
-
<%= render :partial => 'news/articles/preview', :collection => @articles, :as => :article %>
|
26
|
-
</div>
|
27
|
-
<% end %>
|
28
|
-
</div>
|