comfortable_mexican_sofa 1.0.22 → 1.0.23
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +77 -4
- data/VERSION +1 -1
- data/app/views/cms_admin/pages/_form.html.erb +1 -1
- data/comfortable_mexican_sofa.gemspec +2 -2
- data/lib/tasks/comfortable_mexican_sofa.rake +6 -6
- data/public/javascripts/comfortable_mexican_sofa/cms.js +1 -1
- data/public/stylesheets/comfortable_mexican_sofa/structure.css +11 -0
- data/test/functional/cms_admin/pages_controller_test.rb +1 -0
- metadata +4 -4
data/README.md
CHANGED
@@ -30,6 +30,8 @@ At this point you should have database structure created, some assets copied to
|
|
30
30
|
ComfortableMexicanSofa::HttpAuth.username = 'username'
|
31
31
|
ComfortableMexicanSofa::HttpAuth.password = 'password'
|
32
32
|
|
33
|
+
For a full list of available configuration options and their defaults take a peek in here: [configuration.rb](http://https://github.com/theworkinggroup/comfortable-mexican-sofa/blob/master/lib/comfortable_mexican_sofa/configuration.rb)
|
34
|
+
|
33
35
|
Usage
|
34
36
|
-----
|
35
37
|
Now you should be able to navigate to http://yoursite/cms-admin
|
@@ -49,6 +51,8 @@ Before creating pages and populating them with content we need to create a layou
|
|
49
51
|
|
50
52
|
So there's your layout and the `{{cms:page:content}}` defines a place where renderable `content` will go. There's just a handful of tags that you can use.
|
51
53
|
|
54
|
+
Layout may also be linked to the `application layout`. As a result cms page content will end up inside `<%= yeild %>` of your application layout.
|
55
|
+
|
52
56
|
#### Page Blocks
|
53
57
|
pieces of content that will be output on the page:
|
54
58
|
|
@@ -84,10 +88,79 @@ are exactly that. You don't want to do IRB inside CMS so there's a handy tag:
|
|
84
88
|
{{ cms:partial:path/to/partial:x:y }} # gets translated to <%= render :partial => 'path/to/partial',
|
85
89
|
# :locals => { :param_1 => 'x', :param_2 => 'y'} %>
|
86
90
|
|
87
|
-
|
91
|
+
### Step 3: Create Page
|
92
|
+
Now you're ready to create a page. Based on how you defined your layout, you should have form inputs ready to be populated.
|
93
|
+
Save a page, and it will be accessible from the public side.
|
94
|
+
|
95
|
+
Integrating CMS with your app
|
96
|
+
-----------------------------
|
97
|
+
Unlike most CMS solutions, Sofa is here only to help. Your application is more important. There are few useful ways you can use CMS functionality from your application.
|
88
98
|
|
89
|
-
|
99
|
+
* When CMS renders a page, you automatically have access to `@cms_page` variable.
|
100
|
+
* CMS can take over the rendering of views for your application. For example, http://your-app.local/books hits books\_controller#index and if you don't have a view setup CMS will try to serve a page with '/books' path. You can even force your controller to render a particular page like this: `render :cms_page => '/books'`
|
90
101
|
|
91
|
-
|
102
|
+
Working with fixtures
|
103
|
+
---------------------
|
104
|
+
During development it's often more convenient to work with files that can be source controlled, versus putting content in the database and then manage database dump. Thankfully Sofa makes working with fixtures easy.
|
105
|
+
|
106
|
+
### Setting up Fixtures
|
107
|
+
First of all you need to set a path where fixture files will be found:
|
108
|
+
|
109
|
+
# in config/initializers/comfortable_mexican_sofa.rb
|
110
|
+
if Rails.env.development? || Rails.env.test?
|
111
|
+
ComfortableMexicanSofa.config.seed_data_path = File.expand_path('db/cms_seeds', Rails.root)
|
112
|
+
end
|
113
|
+
|
114
|
+
This is an example of the file/folder structure for fixtures:
|
115
|
+
|
116
|
+
your-site.local/
|
117
|
+
- layouts/
|
118
|
+
- default_layout.yml
|
119
|
+
- pages
|
120
|
+
- index.yml
|
121
|
+
- help.yml
|
122
|
+
- help/
|
123
|
+
- more_help.yml
|
124
|
+
- snippets
|
125
|
+
- random_snippet.yml
|
126
|
+
|
127
|
+
Then it's a matter of populating the content. Few rules to remember:
|
128
|
+
|
129
|
+
- root page is always index.yml
|
130
|
+
- sections of the page are defined by cms\_block\_attributes
|
131
|
+
- parent pages are identified by full_path (slug for layouts)
|
132
|
+
- folder structure reflects tree structure of the site
|
133
|
+
|
134
|
+
Example fixture files for a [layout](https://github.com/theworkinggroup/comfortable-mexican-sofa/blob/master/test/cms_seeds/test.host/layouts/nested.yml), [page](https://github.com/theworkinggroup/comfortable-mexican-sofa/blob/master/test/cms_seeds/test.host/pages/child/subchild.yml) and [snippet](https://github.com/theworkinggroup/comfortable-mexican-sofa/blob/master/test/cms_seeds/test.host/snippets/default.yml)
|
92
135
|
|
93
|
-
|
136
|
+
**Note:** If ComfortableMexicanSofa.config.seed\_data\_path is set no content is loaded from database. Only fixture files are used.
|
137
|
+
|
138
|
+
### Importing fixtures into database
|
139
|
+
Now that you have all those fixture files, how do we get them into database? Easy:
|
140
|
+
|
141
|
+
rake comfortable_mexican_sofa:import:all FROM=your-site.local TO=your-site.com PATH=/path/to/fixtures
|
142
|
+
|
143
|
+
PATH is optional if seed\_data\_path configuration option is set.
|
144
|
+
|
145
|
+
### Exporting database data into fixtures
|
146
|
+
If you need to pull down database content into fixtures it's done as follows:
|
147
|
+
|
148
|
+
rake comfortable_mexican_sofa:export:all FROM=your-site.com TO=your-site.local PATH=/path/to/fixtures
|
149
|
+
|
150
|
+
During import/export it will prompt you if there are any files/database entries that are going to be overwritten
|
151
|
+
|
152
|
+
Admin Area Integration
|
153
|
+
----------------------
|
154
|
+
Sofa has a wonderful admin area. Why would you want to make your own layout, styling and so on if you can reuse what CMS has.
|
155
|
+
|
156
|
+
You can easily make your controllers use layouts and CMS authentication like this:
|
157
|
+
|
158
|
+
class Admin::UsersController < CmsAdmin::BaseController
|
159
|
+
# ...
|
160
|
+
end
|
161
|
+
|
162
|
+
To add your own tabs to the admin area you can use hooks:
|
163
|
+
|
164
|
+
# in config/initializers/comfortable_mexican_sofa.rb
|
165
|
+
ComfortableMexicanSofa::ViewHooks.add(:navigation, '/path/to/view/partial')
|
166
|
+
ComfortableMexicanSofa::ViewHooks.add(:html_head, '/path/to/view/partial')
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.23
|
@@ -5,7 +5,7 @@
|
|
5
5
|
<%= form.text_field :slug, :id => 'slug' %>
|
6
6
|
<% end %>
|
7
7
|
<% if (options = CmsLayout.options_for_select(@cms_site)).present? %>
|
8
|
-
<%= form.select :cms_layout_id, options, {}, 'data-page-id' => @cms_page.id.to_i, :label => 'Layout' %>
|
8
|
+
<%= form.select :cms_layout_id, options, {}, 'data-page-id' => @cms_page.id.to_i, 'data-path-prefix' => ComfortableMexicanSofa.config.admin_route_prefix, :label => 'Layout' %>
|
9
9
|
<% end %>
|
10
10
|
<% if (options = CmsPage.options_for_select(@cms_site, @cms_page)).present? %>
|
11
11
|
<%= form.select :parent_id, options %>
|
@@ -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.23"
|
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{2010-11-
|
12
|
+
s.date = %q{2010-11-16}
|
13
13
|
s.description = %q{}
|
14
14
|
s.email = %q{oleg@theworkinggroup.ca}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -46,7 +46,7 @@ namespace :comfortable_mexican_sofa do
|
|
46
46
|
existing_layout = nil
|
47
47
|
|
48
48
|
if existing_layout = @site.cms_layouts.find_by_slug(layout.slug)
|
49
|
-
print "Found layout in database with slug: #{layout.slug}. Overwrite? (
|
49
|
+
print "Found layout in database with slug: #{layout.slug}. Overwrite? (y/N): "
|
50
50
|
should_write = ($stdin.gets.to_s.strip.downcase == 'y')
|
51
51
|
end
|
52
52
|
if should_write
|
@@ -86,7 +86,7 @@ namespace :comfortable_mexican_sofa do
|
|
86
86
|
existing_page = nil
|
87
87
|
|
88
88
|
if existing_page = @site.cms_pages.find_by_full_path(page.full_path)
|
89
|
-
print "Found page in database with full_path: #{page.full_path}. Overwrite? (
|
89
|
+
print "Found page in database with full_path: #{page.full_path}. Overwrite? (y/N): "
|
90
90
|
should_write = ($stdin.gets.to_s.strip.downcase == 'y')
|
91
91
|
end
|
92
92
|
|
@@ -128,7 +128,7 @@ namespace :comfortable_mexican_sofa do
|
|
128
128
|
should_write = true
|
129
129
|
existing_snippet = nil
|
130
130
|
if existing_snippet = @site.cms_snippets.find_by_slug(snippet.slug)
|
131
|
-
print "Found snippet in database with slug: #{snippet.slug}. Overwrite? (
|
131
|
+
print "Found snippet in database with slug: #{snippet.slug}. Overwrite? (y/N): "
|
132
132
|
should_write = ($stdin.gets.to_s.strip.downcase == 'y')
|
133
133
|
end
|
134
134
|
if should_write
|
@@ -187,7 +187,7 @@ namespace :comfortable_mexican_sofa do
|
|
187
187
|
should_write = true
|
188
188
|
file_path = File.join(@seed_path, 'layouts', "#{layout.slug}.yml")
|
189
189
|
if File.exists?(file_path)
|
190
|
-
print "Found layout fixture: #{file_path} Overwrite? (
|
190
|
+
print "Found layout fixture: #{file_path} Overwrite? (y/N): "
|
191
191
|
should_write = ($stdin.gets.to_s.strip.downcase == 'y')
|
192
192
|
end
|
193
193
|
if should_write
|
@@ -216,7 +216,7 @@ namespace :comfortable_mexican_sofa do
|
|
216
216
|
file_path = File.join(@seed_path, 'pages', "#{page_path}/#{page_name}.yml")
|
217
217
|
|
218
218
|
if File.exists?(file_path)
|
219
|
-
print "Found page fixture: #{file_path} Overwrite? (
|
219
|
+
print "Found page fixture: #{file_path} Overwrite? (y/N): "
|
220
220
|
should_write = ($stdin.gets.to_s.strip.downcase == 'y')
|
221
221
|
end
|
222
222
|
if should_write
|
@@ -244,7 +244,7 @@ namespace :comfortable_mexican_sofa do
|
|
244
244
|
should_write = true
|
245
245
|
file_path = File.join(@seed_path, 'snippets', "#{snippet.slug}.yml")
|
246
246
|
if File.exists?(file_path)
|
247
|
-
print "Found snippet fixture: #{file_path} Overwrite? (
|
247
|
+
print "Found snippet fixture: #{file_path} Overwrite? (y/N): "
|
248
248
|
should_write = ($stdin.gets.to_s.strip.downcase == 'y')
|
249
249
|
end
|
250
250
|
if should_write
|
@@ -31,7 +31,7 @@ $.CMS = function(){
|
|
31
31
|
|
32
32
|
// Load Page Blocks on layout change
|
33
33
|
$('select#cms_page_cms_layout_id').bind('change.cms', function() {
|
34
|
-
$.ajax({url: ['
|
34
|
+
$.ajax({url: [$(this).attr('data-path-prefix'), 'pages', $(this).attr('data-page-id'), 'form_blocks'].join('/'), data: ({ layout_id: $(this).val()})})
|
35
35
|
})
|
36
36
|
|
37
37
|
}); // End $(document).ready()
|
@@ -105,6 +105,7 @@ html, body {
|
|
105
105
|
width: 98%;
|
106
106
|
}
|
107
107
|
.form_element .value input,
|
108
|
+
.form_element .value select,
|
108
109
|
.form_element .value textarea {
|
109
110
|
border: 1px solid #ccc;
|
110
111
|
padding: 2px;
|
@@ -116,6 +117,9 @@ html, body {
|
|
116
117
|
.form_element.submit_element {
|
117
118
|
margin-left: 160px;
|
118
119
|
}
|
120
|
+
.form_element.check_box_element input {
|
121
|
+
width: auto;
|
122
|
+
}
|
119
123
|
.page_form_extras {
|
120
124
|
margin-bottom: 25px;
|
121
125
|
}
|
@@ -199,6 +203,9 @@ ul.list li .item:hover .action_links,
|
|
199
203
|
table.formatted tr:hover td.action_links a {
|
200
204
|
opacity: 1;
|
201
205
|
}
|
206
|
+
table.formatted {
|
207
|
+
clear: both;
|
208
|
+
}
|
202
209
|
table.formatted th {
|
203
210
|
background: url(/images/comfortable_mexican_sofa/body_bg.jpg);
|
204
211
|
color: #ececec;
|
@@ -237,3 +244,7 @@ table.formatted td.main {
|
|
237
244
|
background-color: #1C1F22;
|
238
245
|
color: #fff;
|
239
246
|
}
|
247
|
+
form.search {
|
248
|
+
float: right;
|
249
|
+
margin: 5px 0px;
|
250
|
+
}
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: comfortable_mexican_sofa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 57
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 23
|
10
|
+
version: 1.0.23
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Oleg Khabarov
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-11-
|
19
|
+
date: 2010-11-16 00:00:00 -05:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|