comfortable_mexican_sofa 1.3.4 → 1.3.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -6,12 +6,12 @@ Features
6
6
  --------
7
7
  * Simple integration with Rails 3.0 and 3.1 apps
8
8
  * Build your application in Rails, not in CMS
9
- * Powerful page templating capability
10
- * Multiple Sites from a single installation
9
+ * Powerful page templating capability using [Tags](https://github.com/twg/comfortable-mexican-sofa/wiki/Tags)
10
+ * [Multiple Sites](https://github.com/twg/comfortable-mexican-sofa/wiki/Sites) from a single installation
11
11
  * Multilingual
12
- * Fixtures for initial content population
13
- * Revision History
14
- * Great reusable admin interface
12
+ * [Fixtures](https://github.com/twg/comfortable-mexican-sofa/wiki/Working-with-CMS-fixtures) for initial content population
13
+ * [Revision History](https://github.com/twg/comfortable-mexican-sofa/wiki/Revisions)
14
+ * [Great reusable admin interface](https://github.com/twg/comfortable-mexican-sofa/wiki/Reusing-sofa%27s-admin-area)
15
15
  * Almost no 3rd party library dependencies
16
16
 
17
17
  Installation
@@ -51,110 +51,6 @@ For more information please [see Wiki pages](https://github.com/twg/comfortable-
51
51
 
52
52
  ![Sofa's Page Edit View](https://github.com/twg/comfortable-mexican-sofa/raw/master/doc/page_editing.png)
53
53
 
54
- CMS Tags Overview
55
- -----------------
56
- There are a [number of cms tags]() that define where the content goes and how it's populated. **Page** and **Field** tags are used during layout creation. **Snippet**, **Helper** and **Partial** tags can be peppered pretty much anywhere. Tag is structured like so:
57
-
58
- {{ cms:page:content:text }}
59
- \ \ \ \
60
- \ \ \ ‾ tag format or extra attributes
61
- \ \ ‾‾‾‾‾‾‾ label/slug/path for the tag,
62
- \ ‾‾‾‾‾‾‾‾‾‾‾‾ tag type (page, field, snippet, helper, partial)
63
- ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ cms tag identifier
64
-
65
- Here's a number of tag variations:
66
-
67
- # Page tags are pieces of text content that will get rendered on the page. Format defines how form field
68
- # gets rendered in the page editing/creation section of the admin area.
69
-
70
- {{ cms:page:some_label:text }}
71
- {{ cms:page:some_label }} # shorthand for above. 'text' is default format for pages
72
- {{ cms:page:some_label:string }} # in admin area text field is displayed instead of textarea
73
- {{ cms:page:some_label:datetime }} # similarly, datetime widget in the admin area
74
- {{ cms:page:some_label:integer }} # a number field
75
- {{ cms:page:some_label:rich_text }} # wymiwyg editor will be used to edit this content
76
-
77
- # Field tags are pieces of text content that are NOT rendered on the page. They can be accessed via
78
- # your application's layout / helpers / partials etc. Useful for populating this like <meta> tags.
79
- # Field formats are exactly the same as for Page tags.
80
-
81
- {{ cms:field:some_label:string }}
82
- {{ cms:field:some_label }} # same as above. 'string' is default format for fields
83
-
84
- # Snippet tags are bits or reusable content that can be used anywhere. Imagine creating content like
85
- # a sharing widget, or business address that you want to randomly use across your site.
86
-
87
- {{ cms:snippet:some_label }}
88
-
89
- # Helper is a wrapper for your regular helpers. Normally you cannot have IRB in CMS content, so there are
90
- # tags that allow calling helpers and partials.
91
-
92
- {{ cms:helper:method_name }} # same as <%= method_name() %>
93
- {{ cms:helper:method_name:x:y:z }} # same as <%= method_name('x', 'y', 'z') %>
94
-
95
- # Partial tags are wrappers just like above helper ones.
96
-
97
- {{ cms:partial:path/to/partial }} # same as <%= render :partial => 'path/to/partial' %>
98
- {{ cms:partial:path/to/partial:a:b }} # same as <%= render :partial => 'path/to/partial',
99
- # :locals => { :param_1 => 'a', :param_1 => 'b' } %>
100
-
101
- Integrating CMS with your app
102
- -----------------------------
103
- ComfortableMexicanSofa is a plugin, so it allows you to easily access content it manages. Here's some things you can do.
104
-
105
- You can use your existing application layout. When creating CMS layouts there's an option to use an application layout. Suddenly all CMS pages using that layout will be rendered through <%= yield %> of your application layout.
106
-
107
- You can use CMS pages as regular views:
108
-
109
- def show
110
- @dinosaur = Dinosaur.find(params[:id])
111
- # CMS page probably should have either helper or partial tag to display @dinosaur details
112
- render :cms_page => '/dinosaur
113
- end
114
-
115
- Actually, you don't need to explicitly render a CMS page like that. Sofa will try to rescue a TemplateNotFound by providing a matching CMS page.
116
-
117
- You can access **Page** or **Field** tag content directly from your application (layouts/helpers/partials) via `cms_page_content` method. This is how you can pull things like meta tags into your application layout.
118
-
119
- # if @cms_page is available (meaning Sofa is doing the rendering)
120
- cms_page_content(:page_or_field_label)
121
-
122
- # anywhere else
123
- cms_page_content(:page_or_field_label, CmsPage.find_by_slug(...))
124
-
125
- Similarly you can access **Snippet** content:
126
-
127
- cms_snippet_content(:snippet_slug)
128
-
129
- You can also directly access `@cms_site`, `@cms_layout` and `@cms_page` objects from helpers, partials and application layouts used in rendering of a CMS page.
130
-
131
- Extending Admin Area
132
- --------------------
133
-
134
- If you wish, you can re-use Sofa's admin area for things you need to administer in your application. To do this, first you will need to make your admin controllers to inherit from CmsAdmin::BaseController. This way, your admin views will be using Sofa's admin layout and it's basic HttpAuth.
135
-
136
- class Admin::CategoriesController < CmsAdmin::BaseController
137
- # your code goes here
138
- end
139
-
140
- From your views you can use `cms_form_for` method to re-use Sofa's FormBuilder. There are also some existing styles for tables, will\_paginate helpers, etc. Take a look in [/public/stylesheets/comfortable\_mexican\_sofa/content.css](https://github.com/twg/comfortable-mexican-sofa/blob/master/public/stylesheets/comfortable_mexican_sofa/content.css)
141
-
142
- You will probably want to add a navigation link on the left side, and for that you will want to use ViewHook functionality. Create a partial that has a link to your admin area and declare in Sofa's initializer: `ComfortableMexicanSofa::ViewHooks.add(:navigation, '/admin/navigation')`. Similarly you can add extra stylesheets, etc into admin area in the same way.
143
-
144
- Do you have other authentication system in place (like Devise, AuthLogic, etc) and wish to use that? For that, you will need to create a module that does the authentication check and make ComfortableMexicanSofa use it. For example:
145
-
146
- module CmsDeviseAuth
147
- def authenticate
148
- unless current_user && current_user.admin?
149
- redirect_to new_user_session_path
150
- end
151
- end
152
- end
153
-
154
- You can put this module in /config/initializers/comfortable\_mexican\_sofa.rb and change authentication method: `config.authentication = 'CmsDeviseAuth'`. Now to access Sofa's admin area users will be authenticated against your existing authentication system.
155
-
156
- ![Looks pretty comfortable to me. No idea what makes it Mexican.](https://github.com/twg/comfortable-mexican-sofa/raw/master/doc/sofa.png)
157
-
158
54
  ComfortableMexicanSofa is released under the [MIT license](https://github.com/twg/comfortable-mexican-sofa/raw/master/LICENSE)
159
55
 
160
56
  Copyright 2009-2011 Oleg Khabarov, [The Working Group Inc](http://www.twg.ca)
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ begin
11
11
  require 'jeweler'
12
12
  Jeweler::Tasks.new do |gem|
13
13
  gem.name = 'comfortable_mexican_sofa'
14
- gem.summary = 'ComfortableMexicanSofa is a powerful micro CMS for Ruby on Rails 3 applications'
14
+ gem.summary = 'ComfortableMexicanSofa is a powerful CMS Engine for Ruby on Rails 3 applications'
15
15
  gem.description = ''
16
16
  gem.email = 'oleg@theworkinggroup.ca'
17
17
  gem.homepage = 'http://github.com/twg/comfortable-mexican-sofa'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.4
1
+ 1.3.5
@@ -30,15 +30,19 @@ protected
30
30
  end
31
31
 
32
32
  def load_cms_site
33
- @cms_site ||= Cms::Site.first if Cms::Site.count == 1
34
- Cms::Site.find_all_by_hostname(request.host.downcase).each do |site|
35
- if site.path.blank?
36
- @cms_site = site
37
- elsif "#{request.fullpath}/".match /^\/#{Regexp.escape(site.path.to_s)}\//
38
- @cms_site = site
39
- break
40
- end
41
- end unless @cms_site
33
+ if params[:site_id]
34
+ @cms_site ||= Cms::Site.find_by_id(params[:site_id])
35
+ else
36
+ @cms_site ||= Cms::Site.first if Cms::Site.count == 1
37
+ Cms::Site.find_all_by_hostname(request.host.downcase).each do |site|
38
+ if site.path.blank?
39
+ @cms_site = site
40
+ elsif "#{request.fullpath}/".match /^\/#{Regexp.escape(site.path.to_s)}\//
41
+ @cms_site = site
42
+ break
43
+ end
44
+ end unless @cms_site
45
+ end
42
46
 
43
47
  if @cms_site
44
48
  params[:cms_path].to_s.gsub!(/^#{@cms_site.path}/, '').gsub!(/^\//, '')
@@ -67,7 +71,7 @@ protected
67
71
  end
68
72
 
69
73
  def load_cms_layout
70
- @cms_layout = @cms_site.layouts.find_by_slug!(params[:id])
74
+ @cms_layout = @cms_site.layouts.find_by_slug!(params[:layout_slug])
71
75
  rescue ActiveRecord::RecordNotFound
72
76
  render :nothing => true, :status => 404
73
77
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{comfortable_mexican_sofa}
8
- s.version = "1.3.4"
8
+ s.version = "1.3.5"
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"]
@@ -273,7 +273,7 @@ Gem::Specification.new do |s|
273
273
  s.homepage = %q{http://github.com/twg/comfortable-mexican-sofa}
274
274
  s.require_paths = ["lib"]
275
275
  s.rubygems_version = %q{1.6.2}
276
- s.summary = %q{ComfortableMexicanSofa is a powerful micro CMS for Ruby on Rails 3 applications}
276
+ s.summary = %q{ComfortableMexicanSofa is a powerful CMS Engine for Ruby on Rails 3 applications}
277
277
 
278
278
  if s.respond_to? :specification_version then
279
279
  s.specification_version = 3
data/config/routes.rb CHANGED
@@ -30,9 +30,9 @@ Rails.application.routes.draw do
30
30
  end unless ComfortableMexicanSofa.config.admin_route_prefix.blank?
31
31
 
32
32
  scope :controller => :cms_content do
33
- get 'cms-css/:id' => :render_css, :as => 'cms_css'
34
- get 'cms-js/:id' => :render_js, :as => 'cms_js'
35
- get '/' => :render_html, :as => 'cms_html', :path => "(*cms_path)"
33
+ get 'cms-css/:site_id/:layout_slug' => :render_css, :as => 'cms_css'
34
+ get 'cms-js/:site_id/:layout_slug' => :render_js, :as => 'cms_js'
35
+ get '/' => :render_html, :as => 'cms_html', :path => "(*cms_path)"
36
36
  end
37
37
 
38
38
  end
@@ -13,11 +13,11 @@ class ComfortableMexicanSofa::Tag::Asset
13
13
 
14
14
  case type
15
15
  when 'css'
16
- out = "#{page.site.path}/cms-css/#{label}.css"
16
+ out = "/cms-css/#{page.site.id}/#{label}.css"
17
17
  out = "<link href='#{out}' media='screen' rel='stylesheet' type='text/css' />" if format == 'html_tag'
18
18
  out
19
19
  when 'js'
20
- out = "#{page.site.path}/cms-js/#{label}.js"
20
+ out = "/cms-js/#{page.site.id}/#{label}.js"
21
21
  out = "<script src='#{out}' type='text/javascript'></script>" if format == 'html_tag'
22
22
  out
23
23
  end
@@ -122,26 +122,26 @@ class CmsContentControllerTest < ActionController::TestCase
122
122
  end
123
123
 
124
124
  def test_render_css
125
- get :render_css, :id => cms_layouts(:default).slug
125
+ get :render_css, :site_id => cms_sites(:default).id, :layout_slug => cms_layouts(:default).slug
126
126
  assert_response :success
127
127
  assert_match %r{text\/css}, response.headers["Content-Type"]
128
128
  assert_equal cms_layouts(:default).css, response.body
129
129
  end
130
130
 
131
131
  def test_render_css_not_found
132
- get :render_css, :id => 'bogus'
132
+ get :render_css, :site_id => cms_sites(:default).id, :layout_slug => 'bogus'
133
133
  assert_response 404
134
134
  end
135
135
 
136
136
  def test_render_js
137
- get :render_js, :id => cms_layouts(:default).slug
137
+ get :render_js, :site_id => cms_sites(:default).id, :layout_slug => cms_layouts(:default).slug
138
138
  assert_response :success
139
139
  assert_match %r{text\/javascript}, response.headers["Content-Type"]
140
140
  assert_equal cms_layouts(:default).js, response.body
141
141
  end
142
142
 
143
143
  def test_render_js_not_found
144
- get :render_js, :id => 'bogus'
144
+ get :render_js, :site_id => cms_sites(:default).id, :layout_slug => 'bogus'
145
145
  assert_response 404
146
146
  end
147
147
 
@@ -33,24 +33,24 @@ class AssetTest < ActiveSupport::TestCase
33
33
  tag = ComfortableMexicanSofa::Tag::Asset.initialize_tag(
34
34
  cms_pages(:default), '{{ cms:asset:default:css }}'
35
35
  )
36
- assert_equal '/cms-css/default.css', tag.render
36
+ assert_equal "/cms-css/#{cms_sites(:default).id}/default.css", tag.render
37
37
 
38
38
  tag = ComfortableMexicanSofa::Tag::Asset.initialize_tag(
39
39
  cms_pages(:default), '{{ cms:asset:default:css:html_tag }}'
40
40
  )
41
- assert_equal "<link href='/cms-css/default.css' media='screen' rel='stylesheet' type='text/css' />", tag.render
41
+ assert_equal "<link href='/cms-css/#{cms_sites(:default).id}/default.css' media='screen' rel='stylesheet' type='text/css' />", tag.render
42
42
  end
43
43
 
44
44
  def test_render_for_js
45
45
  tag = ComfortableMexicanSofa::Tag::Asset.initialize_tag(
46
46
  cms_pages(:default), '{{ cms:asset:default:js }}'
47
47
  )
48
- assert_equal '/cms-js/default.js', tag.render
48
+ assert_equal "/cms-js/#{cms_sites(:default).id}/default.js", tag.render
49
49
 
50
50
  tag = ComfortableMexicanSofa::Tag::Asset.initialize_tag(
51
51
  cms_pages(:default), '{{ cms:asset:default:js:html_tag }}'
52
52
  )
53
- assert_equal "<script src='/cms-js/default.js' type='text/javascript'></script>", tag.render
53
+ assert_equal "<script src='/cms-js/#{cms_sites(:default).id}/default.js' type='text/javascript'></script>", tag.render
54
54
  end
55
55
 
56
56
  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.3.4
4
+ version: 1.3.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -15,7 +15,7 @@ default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails
18
- requirement: &70307918702120 !ruby/object:Gem::Requirement
18
+ requirement: &70187511396100 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ! '>='
@@ -23,10 +23,10 @@ dependencies:
23
23
  version: 3.0.0
24
24
  type: :runtime
25
25
  prerelease: false
26
- version_requirements: *70307918702120
26
+ version_requirements: *70187511396100
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: active_link_to
29
- requirement: &70307918701380 !ruby/object:Gem::Requirement
29
+ requirement: &70187511394840 !ruby/object:Gem::Requirement
30
30
  none: false
31
31
  requirements:
32
32
  - - ! '>='
@@ -34,10 +34,10 @@ dependencies:
34
34
  version: 0.0.10
35
35
  type: :runtime
36
36
  prerelease: false
37
- version_requirements: *70307918701380
37
+ version_requirements: *70187511394840
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: paperclip
40
- requirement: &70307918700620 !ruby/object:Gem::Requirement
40
+ requirement: &70187511394080 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ! '>='
@@ -45,7 +45,7 @@ dependencies:
45
45
  version: 2.3.14
46
46
  type: :runtime
47
47
  prerelease: false
48
- version_requirements: *70307918700620
48
+ version_requirements: *70187511394080
49
49
  description: ''
50
50
  email: oleg@theworkinggroup.ca
51
51
  executables: []
@@ -321,7 +321,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
321
321
  version: '0'
322
322
  segments:
323
323
  - 0
324
- hash: 2942682638602800909
324
+ hash: 1451043806041481492
325
325
  required_rubygems_version: !ruby/object:Gem::Requirement
326
326
  none: false
327
327
  requirements:
@@ -333,5 +333,5 @@ rubyforge_project:
333
333
  rubygems_version: 1.6.2
334
334
  signing_key:
335
335
  specification_version: 3
336
- summary: ComfortableMexicanSofa is a powerful micro CMS for Ruby on Rails 3 applications
336
+ summary: ComfortableMexicanSofa is a powerful CMS Engine for Ruby on Rails 3 applications
337
337
  test_files: []