comfortable_mexican_sofa 1.0.44 → 1.0.45
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +17 -16
- data/VERSION +1 -1
- data/app/models/cms_page.rb +5 -0
- data/comfortable_mexican_sofa.gemspec +2 -2
- data/lib/comfortable_mexican_sofa/controller_methods.rb +21 -22
- data/test/unit/cms_page_test.rb +3 -0
- metadata +4 -4
data/README.md
CHANGED
@@ -7,7 +7,7 @@ Installation
|
|
7
7
|
------------
|
8
8
|
Add gem definition to your Gemfile:
|
9
9
|
|
10
|
-
|
10
|
+
gem 'comfortable_mexican_sofa'
|
11
11
|
|
12
12
|
Then from the Rails project's root run:
|
13
13
|
|
@@ -15,6 +15,8 @@ Then from the Rails project's root run:
|
|
15
15
|
rails g cms
|
16
16
|
rake db:migrate
|
17
17
|
|
18
|
+
When upgrading to a newer version just run `rails g cms` and replace files when prompted. You may also need to run `rake db:migrate` again.
|
19
|
+
|
18
20
|
Usage
|
19
21
|
-----
|
20
22
|
After finishing installation you should be able to navigate to http://yoursite/cms-admin
|
@@ -122,7 +124,7 @@ If you wish, you can re-use Sofa's admin area for things you need to administer
|
|
122
124
|
# your code goes here
|
123
125
|
end
|
124
126
|
|
125
|
-
From your views you can
|
127
|
+
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)
|
126
128
|
|
127
129
|
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 in Sofa's initializer: `ComfortableMexicanSofa::ViewHooks.add(:navigation, '/admin/navigation')`. Similarly you can add extra stylesheets, etc into admin area in the same way.
|
128
130
|
|
@@ -138,9 +140,9 @@ Do you have other authentication system in place (like Devise, AuthLogic, etc) a
|
|
138
140
|
|
139
141
|
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.
|
140
142
|
|
141
|
-
Working with
|
142
|
-
|
143
|
-
Comfortable Mexican Sofa has
|
143
|
+
Working with seeds
|
144
|
+
------------------
|
145
|
+
Comfortable Mexican Sofa has seeds, functionality that helps manage content during development phase. It's very different from Rails seeds as Sofa's seeds are loaded with each page load. The database is completely bypassed when seeds are active. This way, you can source-control content before going live, disabling seeds and dumping everything into the database.
|
144
146
|
|
145
147
|
First, you will need to set a path where fixture files will be found (inside Sofa's initializer):
|
146
148
|
|
@@ -148,20 +150,19 @@ First, you will need to set a path where fixture files will be found (inside Sof
|
|
148
150
|
ComfortableMexicanSofa.config.seed_data_path = File.expand_path('db/cms_seeds', Rails.root)
|
149
151
|
end
|
150
152
|
|
151
|
-
If you ran `rails g cms`, you should find an example set of
|
153
|
+
If you ran `rails g cms`, you should find an example set of seeds in /db/cms\_seeds directory. Please note that seeds are nested in the folder that is the hostname of your site. Each file is an YAML representation of a database entry for that layout/page/snippet.
|
152
154
|
|
153
|
-
There's a rake task that makes moving
|
155
|
+
There's a rake task that makes moving seeds into database (and vice-versa) easy:
|
154
156
|
|
155
|
-
# from
|
156
|
-
rake comfortable_mexican_sofa:import:all FROM=your-site.local TO=your-site.com SEED_PATH=/path/to/
|
157
|
+
# from seeds into database
|
158
|
+
rake comfortable_mexican_sofa:import:all FROM=your-site.local TO=your-site.com SEED_PATH=/path/to/seeds
|
157
159
|
|
158
|
-
# from database to
|
159
|
-
rake comfortable_mexican_sofa:export:all FROM=your-site.com TO=your-site.local SEED_PATH=/path/to/
|
160
|
+
# from database to seeds
|
161
|
+
rake comfortable_mexican_sofa:export:all FROM=your-site.com TO=your-site.local SEED_PATH=/path/to/seeds
|
160
162
|
|
161
|
-
|
162
|
-
----------
|
163
|
-
Versioning control will be eventually implemented. Also I'd love to hear ideas how this CMS can be improved. But feel free to just fork and hack away.
|
164
|
-
|
163
|
+
---
|
165
164
|
![Looks pretty comfortable to me. No idea what makes it Mexican.](https://github.com/twg/comfortable-mexican-sofa/raw/master/doc/sofa.png)
|
166
165
|
|
167
|
-
ComfortableMexicanSofa is released under the [MIT license](https://github.com/twg/comfortable-mexican-sofa/raw/master/LICENSE)
|
166
|
+
ComfortableMexicanSofa is released under the [MIT license](https://github.com/twg/comfortable-mexican-sofa/raw/master/LICENSE)
|
167
|
+
|
168
|
+
Copyright 2009-2011 Oleg Khabarov, [The Working Group Inc](http://www.twg.ca)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.45
|
data/app/models/cms_page.rb
CHANGED
@@ -86,6 +86,11 @@ class CmsPage < ActiveRecord::Base
|
|
86
86
|
end
|
87
87
|
|
88
88
|
# -- Instance Methods -----------------------------------------------------
|
89
|
+
# For previewing purposes sometimes we need to have full_path set
|
90
|
+
def full_path
|
91
|
+
self.read_attribute(:full_path) || self.assign_full_path
|
92
|
+
end
|
93
|
+
|
89
94
|
# Transforms existing cms_block information into a hash that can be used
|
90
95
|
# during form processing. That's the only way to modify cms_blocks.
|
91
96
|
def cms_blocks_attributes
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{comfortable_mexican_sofa}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.45"
|
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 = %q{2011-02-
|
12
|
+
s.date = %q{2011-02-17}
|
13
13
|
s.description = %q{}
|
14
14
|
s.email = %q{oleg@theworkinggroup.ca}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module ComfortableMexicanSofa::ControllerMethods
|
2
2
|
|
3
3
|
def self.included(base)
|
4
|
-
base.alias_method_chain :render, :cms
|
5
4
|
|
6
5
|
# If application controller doesn't have template associated with it
|
7
6
|
# CMS will attempt to find one. This is so you don't have to explicitly
|
@@ -13,29 +12,29 @@ module ComfortableMexicanSofa::ControllerMethods
|
|
13
12
|
raise e
|
14
13
|
end
|
15
14
|
end
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
15
|
+
|
16
|
+
# Now you can render cms_page simply by calling:
|
17
|
+
# render :cms_page => '/path/to/page'
|
18
|
+
# This way application controllers can use CMS content while populating
|
19
|
+
# instance variables that can be used in partials (that are included by
|
20
|
+
# by the cms page and/or layout)
|
21
|
+
def render(options = {}, locals = {}, &block)
|
22
|
+
if options.is_a?(Hash) && path = options.delete(:cms_page)
|
23
|
+
site = CmsSite.find_by_hostname(request.host.downcase)
|
24
|
+
page = CmsPage.load_from_file(site, path) if site && ComfortableMexicanSofa.configuration.seed_data_path
|
25
|
+
page ||= site && site.cms_pages.find_by_full_path(path)
|
26
|
+
if page
|
27
|
+
cms_app_layout = page.cms_layout.try(:app_layout)
|
28
|
+
options[:layout] ||= cms_app_layout.blank?? nil : cms_app_layout
|
29
|
+
options[:inline] = page.content
|
30
|
+
@cms_page = page
|
31
|
+
super(options, locals, &block)
|
32
|
+
else
|
33
|
+
raise ActionView::MissingTemplate.new([path], path, "CMS page not found", nil)
|
34
|
+
end
|
34
35
|
else
|
35
|
-
|
36
|
+
super(options, locals, &block)
|
36
37
|
end
|
37
|
-
else
|
38
|
-
render_without_cms(options, locals, &block)
|
39
38
|
end
|
40
39
|
end
|
41
40
|
end
|
data/test/unit/cms_page_test.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 1.0.
|
8
|
+
- 45
|
9
|
+
version: 1.0.45
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Oleg Khabarov
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-02-
|
18
|
+
date: 2011-02-17 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -384,7 +384,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
384
384
|
requirements:
|
385
385
|
- - ">="
|
386
386
|
- !ruby/object:Gem::Version
|
387
|
-
hash: -
|
387
|
+
hash: -53123372768433435
|
388
388
|
segments:
|
389
389
|
- 0
|
390
390
|
version: "0"
|