comfortable_mexican_sofa 1.5.10 → 1.5.11
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +3 -4
- data/VERSION +1 -1
- data/app/controllers/cms_content_controller.rb +0 -5
- data/comfortable_mexican_sofa.gemspec +5 -5
- data/config/initializers/comfortable_mexican_sofa.rb +13 -1
- data/lib/comfortable_mexican_sofa/error.rb +11 -4
- data/lib/comfortable_mexican_sofa/render_methods.rb +17 -3
- data/rvmrc.example +1 -0
- data/test/gemfiles/{Gemfile.rails-3.0.x → Gemfile.rails-3.0.10} +0 -0
- data/test/gemfiles/{Gemfile.rails-3.1.x → Gemfile.rails-3.1.1} +1 -1
- data/test/integration/render_cms_test.rb +47 -0
- metadata +12 -12
- data/test/gemfiles/Gemfile.rails-3.1.stable +0 -10
data/.travis.yml
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
rvm:
|
2
2
|
- 1.8.7
|
3
3
|
- 1.9.2
|
4
|
-
|
4
|
+
- 1.9.3
|
5
5
|
# - rbx-2.0
|
6
6
|
- ree
|
7
7
|
# - jruby
|
8
8
|
gemfile:
|
9
|
-
- test/gemfiles/Gemfile.rails-3.0.
|
10
|
-
- test/gemfiles/Gemfile.rails-3.1.
|
11
|
-
- test/gemfiles/Gemfile.rails-3.1.stable
|
9
|
+
- test/gemfiles/Gemfile.rails-3.0.10
|
10
|
+
- test/gemfiles/Gemfile.rails-3.1.1
|
12
11
|
notifications:
|
13
12
|
recipients:
|
14
13
|
- oleg@twg.ca
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.5.
|
1
|
+
1.5.11
|
@@ -52,11 +52,6 @@ protected
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
def load_fixtures
|
56
|
-
return unless ComfortableMexicanSofa.config.enable_fixtures
|
57
|
-
ComfortableMexicanSofa::Fixtures.import_all(@cms_site.hostname)
|
58
|
-
end
|
59
|
-
|
60
55
|
def load_cms_page
|
61
56
|
@cms_page = @cms_site.pages.published.find_by_full_path!("/#{params[:cms_path]}")
|
62
57
|
return redirect_to(@cms_page.target_page.full_path) if @cms_page.target_page
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "comfortable_mexican_sofa"
|
8
|
-
s.version = "1.5.
|
8
|
+
s.version = "1.5.11"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Oleg Khabarov", "The Working Group Inc"]
|
12
|
-
s.date = "2011-
|
12
|
+
s.date = "2011-11-17"
|
13
13
|
s.description = ""
|
14
14
|
s.email = "oleg@theworkinggroup.ca"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -240,6 +240,7 @@ Gem::Specification.new do |s|
|
|
240
240
|
"lib/generators/README",
|
241
241
|
"lib/generators/cms_generator.rb",
|
242
242
|
"lib/tasks/comfortable_mexican_sofa.rake",
|
243
|
+
"rvmrc.example",
|
243
244
|
"script/rails",
|
244
245
|
"test/fixtures/cms/blocks.yml",
|
245
246
|
"test/fixtures/cms/categories.yml",
|
@@ -266,9 +267,8 @@ Gem::Specification.new do |s|
|
|
266
267
|
"test/functional/cms_admin/sites_controller_test.rb",
|
267
268
|
"test/functional/cms_admin/snippets_controller_test.rb",
|
268
269
|
"test/functional/cms_content_controller_test.rb",
|
269
|
-
"test/gemfiles/Gemfile.rails-3.0.
|
270
|
-
"test/gemfiles/Gemfile.rails-3.1.
|
271
|
-
"test/gemfiles/Gemfile.rails-3.1.x",
|
270
|
+
"test/gemfiles/Gemfile.rails-3.0.10",
|
271
|
+
"test/gemfiles/Gemfile.rails-3.1.1",
|
272
272
|
"test/integration/authentication_test.rb",
|
273
273
|
"test/integration/fixtures_test.rb",
|
274
274
|
"test/integration/mirrors_test.rb",
|
@@ -34,13 +34,25 @@ ComfortableMexicanSofa.configure do |config|
|
|
34
34
|
# config.upload_file_options = {:storage => :filesystem}
|
35
35
|
|
36
36
|
# Sofa allows you to setup entire site from files. Database is updated with each
|
37
|
-
# request (if
|
37
|
+
# request (if necessary). Please note that database entries are destroyed if there's
|
38
38
|
# no corresponding file. Fixtures are disabled by default.
|
39
39
|
# config.enable_fixtures = false
|
40
40
|
|
41
41
|
# Path where fixtures can be located.
|
42
42
|
# config.fixtures_path = File.expand_path('db/cms_fixtures', Rails.root)
|
43
43
|
|
44
|
+
# Importing fixtures into Database
|
45
|
+
# To load fixtures into the database just run this rake task:
|
46
|
+
# local: $ rake comfortable_mexican_sofa:fixtures:import FROM=example.local TO=localhost
|
47
|
+
# Heroku: $ heroku run rake comfortable_mexican_sofa:fixtures:import FROM=example.local TO=yourapp.herokuapp.com
|
48
|
+
# From indicates folder the fixtures are in and to is the Site hostname you have defined in the database.
|
49
|
+
|
50
|
+
# Exporting fixtures into Files
|
51
|
+
# If you need to dump database contents into fixture files run:
|
52
|
+
# local: $ rake comfortable_mexican_sofa:fixtures:export FROM=localhost TO=example.local
|
53
|
+
# Heroku: $ heroku run rake comfortable_mexican_sofa:fixtures:export FROM=yourapp.herokuapp.com TO=example.local
|
54
|
+
# This will create example.local folder and dump all content from example.com Site.
|
55
|
+
|
44
56
|
# Content for Layouts, Pages and Snippets has a revision history. You can revert
|
45
57
|
# a previous version using this system. You can control how many revisions per
|
46
58
|
# object you want to keep. Set it to 0 if you wish to turn this feature off.
|
@@ -3,15 +3,22 @@ module ComfortableMexicanSofa
|
|
3
3
|
class Error < StandardError
|
4
4
|
end
|
5
5
|
|
6
|
-
class
|
7
|
-
def initialize(
|
8
|
-
super "Cannot find CMS
|
6
|
+
class MissingSite < ComfortableMexicanSofa::Error
|
7
|
+
def initialize(slug)
|
8
|
+
super "Cannot find CMS Site with slug: #{slug}"
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
class MissingLayout < ComfortableMexicanSofa::Error
|
13
13
|
def initialize(slug)
|
14
|
-
super "Cannot find CMS
|
14
|
+
super "Cannot find CMS Layout with slug: #{slug}"
|
15
15
|
end
|
16
16
|
end
|
17
|
+
|
18
|
+
class MissingPage < ComfortableMexicanSofa::Error
|
19
|
+
def initialize(path)
|
20
|
+
super "Cannot find CMS Page at #{path}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
17
24
|
end
|
@@ -26,11 +26,25 @@ module ComfortableMexicanSofa::RenderMethods
|
|
26
26
|
# :block_label_b => { :template => 'path/to/template' },
|
27
27
|
# :block_label_c => { :partial => 'path/to/partial' }
|
28
28
|
# }
|
29
|
-
#
|
29
|
+
#
|
30
|
+
# This way you are populating page block content and rendering
|
30
31
|
# an instantialized CMS page.
|
32
|
+
#
|
33
|
+
# Site is loaded automatically based on the request. However you can force
|
34
|
+
# it by passing :cms_site parameter with site's slug. For example:
|
35
|
+
# render :cms_page => '/path/to/page', :cms_site => 'default'
|
36
|
+
#
|
31
37
|
def render(options = {}, locals = {}, &block)
|
38
|
+
|
39
|
+
# TODO: add slug to Cms::Site as well
|
40
|
+
if options.is_a?(Hash) && site_slug = options.delete(:cms_site)
|
41
|
+
unless @cms_site = Cms::Site.find_by_label(site_slug)
|
42
|
+
raise ComfortableMexicanSofa::MissingSite.new(site_slug)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
32
46
|
if options.is_a?(Hash) && path = options.delete(:cms_page)
|
33
|
-
@cms_site
|
47
|
+
@cms_site ||= Cms::Site.find_site(request.host.downcase, request.fullpath)
|
34
48
|
if @cms_page = @cms_site && @cms_site.pages.find_by_full_path(path)
|
35
49
|
@cms_layout = @cms_page.layout
|
36
50
|
cms_app_layout = @cms_layout.try(:app_layout)
|
@@ -42,7 +56,7 @@ module ComfortableMexicanSofa::RenderMethods
|
|
42
56
|
end
|
43
57
|
|
44
58
|
elsif options.is_a?(Hash) && slug = options.delete(:cms_layout)
|
45
|
-
@cms_site
|
59
|
+
@cms_site ||= Cms::Site.find_site(request.host.downcase, request.fullpath)
|
46
60
|
if @cms_layout = @cms_site && @cms_site.layouts.find_by_slug(slug)
|
47
61
|
cms_app_layout = @cms_layout.try(:app_layout)
|
48
62
|
cms_page = @cms_site.pages.build(:layout => @cms_layout)
|
data/rvmrc.example
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use 1.9.2@comfortable-mexican-sofa --create
|
File without changes
|
@@ -19,6 +19,19 @@ class RenderCmsTest < ActionDispatch::IntegrationTest
|
|
19
19
|
load(File.expand_path('config/routes.rb', Rails.root))
|
20
20
|
end
|
21
21
|
|
22
|
+
def create_site_b
|
23
|
+
site = Cms::Site.create!(
|
24
|
+
:label => 'SiteB',
|
25
|
+
:hostname => 'site-b.test')
|
26
|
+
layout = site.layouts.create!(
|
27
|
+
:slug => 'default',
|
28
|
+
:content => 'site-b {{cms:page:content}}')
|
29
|
+
page = site.pages.create!(
|
30
|
+
:label => 'default',
|
31
|
+
:layout => layout,
|
32
|
+
:blocks_attributes => [{ :label => 'content', :content => 'SiteBContent' }])
|
33
|
+
end
|
34
|
+
|
22
35
|
class ::RenderTestController < ApplicationController
|
23
36
|
append_view_path(File.expand_path('../fixtures/views', File.dirname(__FILE__)))
|
24
37
|
|
@@ -43,6 +56,8 @@ class RenderCmsTest < ActionDispatch::IntegrationTest
|
|
43
56
|
render :cms_page => '/test-page'
|
44
57
|
when 'page_explicit_with_status'
|
45
58
|
render :cms_page => '/test-page', :status => 404
|
59
|
+
when 'page_explicit_with_site'
|
60
|
+
render :cms_page => '/', :cms_site => 'SiteB'
|
46
61
|
else
|
47
62
|
raise 'Invalid or no param[:type] provided'
|
48
63
|
end
|
@@ -63,6 +78,8 @@ class RenderCmsTest < ActionDispatch::IntegrationTest
|
|
63
78
|
render :cms_layout => 'default', :status => 404
|
64
79
|
when 'layout_invalid'
|
65
80
|
render :cms_layout => 'invalid'
|
81
|
+
when 'layout_defaults_with_site'
|
82
|
+
render :cms_layout => 'default', :cms_site => 'SiteB'
|
66
83
|
else
|
67
84
|
raise 'Invalid or no param[:type] provided'
|
68
85
|
end
|
@@ -133,6 +150,21 @@ class RenderCmsTest < ActionDispatch::IntegrationTest
|
|
133
150
|
end
|
134
151
|
end
|
135
152
|
|
153
|
+
def test_explicit_with_site
|
154
|
+
create_site_b
|
155
|
+
get '/render-page?type=page_explicit_with_site'
|
156
|
+
assert_response :success
|
157
|
+
assert assigns(:cms_site)
|
158
|
+
assert_equal 'SiteB', assigns(:cms_site).label
|
159
|
+
assert_equal 'site-b SiteBContent', response.body
|
160
|
+
end
|
161
|
+
|
162
|
+
def test_explicit_with_site_failure
|
163
|
+
assert_exception_raised ComfortableMexicanSofa::MissingSite do
|
164
|
+
get '/render-page?type=page_explicit_with_site'
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
136
168
|
# -- Layout Render Tests --------------------------------------------------
|
137
169
|
def test_cms_layout_defaults
|
138
170
|
get '/render-layout?type=layout_defaults'
|
@@ -168,4 +200,19 @@ class RenderCmsTest < ActionDispatch::IntegrationTest
|
|
168
200
|
end
|
169
201
|
end
|
170
202
|
|
203
|
+
def test_cms_layout_defaults_with_site
|
204
|
+
create_site_b
|
205
|
+
get '/render-layout?type=layout_defaults_with_site'
|
206
|
+
assert_response :success
|
207
|
+
assert assigns(:cms_site)
|
208
|
+
assert_equal 'SiteB', assigns(:cms_site).label
|
209
|
+
assert_equal 'site-b TestTemplate TestValue', response.body
|
210
|
+
end
|
211
|
+
|
212
|
+
def test_cms_layout_defaults_with_site_failure
|
213
|
+
assert_exception_raised ComfortableMexicanSofa::MissingSite do
|
214
|
+
get '/render-layout?type=layout_defaults_with_site'
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
171
218
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: comfortable_mexican_sofa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.11
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-11-17 00:00:00.000000000Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
17
|
-
requirement: &
|
17
|
+
requirement: &70264886592940 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: 3.0.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70264886592940
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: active_link_to
|
28
|
-
requirement: &
|
28
|
+
requirement: &70264886591540 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: 1.0.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *70264886591540
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: paperclip
|
39
|
-
requirement: &
|
39
|
+
requirement: &70264886588600 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ~>
|
@@ -44,7 +44,7 @@ dependencies:
|
|
44
44
|
version: 2.3.0
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *70264886588600
|
48
48
|
description: ''
|
49
49
|
email: oleg@theworkinggroup.ca
|
50
50
|
executables: []
|
@@ -276,6 +276,7 @@ files:
|
|
276
276
|
- lib/generators/README
|
277
277
|
- lib/generators/cms_generator.rb
|
278
278
|
- lib/tasks/comfortable_mexican_sofa.rake
|
279
|
+
- rvmrc.example
|
279
280
|
- script/rails
|
280
281
|
- test/fixtures/cms/blocks.yml
|
281
282
|
- test/fixtures/cms/categories.yml
|
@@ -302,9 +303,8 @@ files:
|
|
302
303
|
- test/functional/cms_admin/sites_controller_test.rb
|
303
304
|
- test/functional/cms_admin/snippets_controller_test.rb
|
304
305
|
- test/functional/cms_content_controller_test.rb
|
305
|
-
- test/gemfiles/Gemfile.rails-3.0.
|
306
|
-
- test/gemfiles/Gemfile.rails-3.1.
|
307
|
-
- test/gemfiles/Gemfile.rails-3.1.x
|
306
|
+
- test/gemfiles/Gemfile.rails-3.0.10
|
307
|
+
- test/gemfiles/Gemfile.rails-3.1.1
|
308
308
|
- test/integration/authentication_test.rb
|
309
309
|
- test/integration/fixtures_test.rb
|
310
310
|
- test/integration/mirrors_test.rb
|
@@ -359,7 +359,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
359
359
|
version: '0'
|
360
360
|
segments:
|
361
361
|
- 0
|
362
|
-
hash:
|
362
|
+
hash: 3416423876498059333
|
363
363
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
364
364
|
none: false
|
365
365
|
requirements:
|