comfortable_mexican_sofa 1.0.48 → 1.0.49

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
- Comfortable Mexican Sofa (MicroCMS)
2
- ===================================
1
+ ComfortableMexicanSofa (MicroCMS)
2
+ =================================
3
3
 
4
4
  ComfortableMexicanSofa is a tiny and powerful micro CMS for your Rails 3 application. This CMS is a plugin for your application, not the other way around. Implemented as an Engine so installation is no different than for any other plugin out there.
5
5
 
@@ -89,7 +89,7 @@ Sofa is able to manage multiple sites from the same application. For instance: '
89
89
 
90
90
  Integrating CMS with your app
91
91
  -----------------------------
92
- Comfortable Mexican Sofa is a plugin, so it allows you to easily access content it manages. Here's some things you can do.
92
+ ComfortableMexicanSofa is a plugin, so it allows you to easily access content it manages. Here's some things you can do.
93
93
 
94
94
  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.
95
95
 
@@ -130,7 +130,7 @@ From your views you can use `cms_form_for` method to re-use Sofa's FormBuilder.
130
130
 
131
131
  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.
132
132
 
133
- 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 Comfortable Mexican Sofa use it. For example:
133
+ 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:
134
134
 
135
135
  module CmsDeviseAuth
136
136
  def authenticate
@@ -144,7 +144,7 @@ You can put this module in /config/initializers/comfortable\_mexican\_sofa.rb an
144
144
 
145
145
  Working with seeds
146
146
  ------------------
147
- 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.
147
+ ComfortableMexicanSofa 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.
148
148
 
149
149
  First, you will need to set a path where fixture files will be found (inside Sofa's initializer):
150
150
 
@@ -164,13 +164,19 @@ There's a rake task that makes moving seeds into database (and vice-versa) easy:
164
164
 
165
165
  Active Components
166
166
  -----------------
167
- Comfortable Mexican Sofa utilizes the following:
167
+ ComfortableMexicanSofa utilizes the following:
168
168
 
169
169
  * **[https://github.com/rails/rails](https://github.com/rails/rails)** - Ruby on Rails 3.*, of course
170
170
  * **[https://github.com/thoughtbot/paperclip](https://github.com/thoughtbot/paperclip)** - Paperclip to handle file uploads
171
171
  * **[https://github.com/twg/active_link_to](https://github.com/twg/active_link_to)** - Easy method to handle logic behind 'active' links
172
172
 
173
- * * *
173
+ Contributing to ComfortableMexicanSofa
174
+ --------------------------------------
175
+
176
+ * Fork the project
177
+ * Start a feature/bugfix branch (don't just work on the master branch)
178
+ * Commit and push until you are happy with your contribution
179
+ * Create a Pull Request
174
180
 
175
181
  ![Looks pretty comfortable to me. No idea what makes it Mexican.](https://github.com/twg/comfortable-mexican-sofa/raw/master/doc/sofa.png)
176
182
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.48
1
+ 1.0.49
@@ -109,9 +109,10 @@ protected
109
109
  FileUtils.rm File.expand_path("cms-js/#{self.slug}.js", Rails.public_path), :force => true
110
110
  end
111
111
 
112
- # Forcing page content reload. This will happen in cascade due to #clear_cache mathod above.
112
+ # Forcing page content reload
113
113
  def clear_cached_page_content
114
114
  self.cms_pages.each{ |page| page.save! }
115
+ self.children.each{ |child_layout| child_layout.save! }
115
116
  end
116
117
 
117
118
  end
@@ -3,5 +3,5 @@
3
3
  <% end %>
4
4
 
5
5
  <%= form.text_field :label, :id => (@cms_snippet.new_record?? 'slugify' : nil) %>
6
- <%= form.text_field :slug, :id => 'slug' %>
6
+ <%= form.text_field :slug, :id => 'slug', :class => 'delimiter-underscore' %>
7
7
  <%= form.text_area :content, :class => 'code' %>
@@ -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.0.48"
8
+ s.version = "1.0.49"
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"]
@@ -31,17 +31,23 @@ $.CMS = function(){
31
31
 
32
32
  slugify: function(){
33
33
  $('input#slugify').bind('keyup.cms', function() {
34
- $('input#slug').val( slugify( $(this).val() ) );
34
+ var slug_input = $('input#slug');
35
+ var delimiter = slug_input.hasClass('delimiter-underscore') ? '_' : '-';
36
+ slug_input.val( slugify( $(this).val(), delimiter ) );
35
37
  });
36
-
37
- function slugify(str){
38
+
39
+ function slugify(str, delimiter){
40
+ var opposite_delimiter = (delimiter == '-') ? '_' : '-';
38
41
  str = str.replace(/^\s+|\s+$/g, '');
39
- var from = "ÀÁÄÂÈÉËÊÌÍÏÎÒÓÖÔÙÚÜÛàáäâèéëêìíïîòóöôùúüûÑñÇç·/_,:;";
40
- var to = "aaaaeeeeiiiioooouuuuaaaaeeeeiiiioooouuuunncc------";
42
+ var from = "ÀÁÄÂÈÉËÊÌÍÏÎÒÓÖÔÙÚÜÛàáäâèéëêìíïîòóöôùúüûÑñÇç";
43
+ var to = "aaaaeeeeiiiioooouuuuaaaaeeeeiiiioooouuuunncc";
41
44
  for (var i=0, l=from.length ; i<l ; i++) {
42
45
  str = str.replace(new RegExp(from[i], "g"), to[i]);
43
46
  }
44
- str = str.replace(/[^a-zA-Z0-9 -]/g, '').replace(/\s+/g, '-').toLowerCase();
47
+ var chars_to_replace_with_delimiter = new RegExp('[·/,:;'+ opposite_delimiter +']', 'g');
48
+ str = str.replace(chars_to_replace_with_delimiter, delimiter);
49
+ var chars_to_remove = new RegExp('[^a-zA-Z0-9 '+ delimiter +']', 'g');
50
+ str = str.replace(chars_to_remove, '').replace(/\s+/g, delimiter).toLowerCase();
45
51
  return str;
46
52
  }
47
53
  },
@@ -78,7 +78,6 @@ class CmsContentControllerTest < ActionController::TestCase
78
78
  :is_published => '1',
79
79
  :cms_blocks_attributes => [
80
80
  { :label => 'default_page_text',
81
- :type => 'CmsTag::PageText',
82
81
  :content => 'text <%= 2 + 2 %> text' }
83
82
  ]
84
83
  )
@@ -98,7 +97,6 @@ class CmsContentControllerTest < ActionController::TestCase
98
97
  :is_published => '1',
99
98
  :cms_blocks_attributes => [
100
99
  { :label => 'default_page_text',
101
- :type => 'CmsTag::PageText',
102
100
  :content => 'text <%= 2 + 2 %> text' }
103
101
  ]
104
102
  )
@@ -135,12 +135,45 @@ class CmsLayoutTest < ActiveSupport::TestCase
135
135
  end
136
136
 
137
137
  def test_update_forces_page_content_reload
138
- layout = cms_layouts(:default)
139
- page = cms_pages(:default)
140
- assert_equal layout, page.cms_layout
141
- layout.update_attribute(:content, 'updated {{cms:page:default_page_text:text}} updated')
142
- page.reload
143
- assert_equal "updated default_page_text_content_a\ndefault_snippet_content\ndefault_page_text_content_b updated", page.content
138
+ layout_1 = cms_layouts(:nested)
139
+ layout_2 = cms_layouts(:child)
140
+ page_1 = cms_sites(:default).cms_pages.create!(
141
+ :label => 'page_1',
142
+ :slug => 'page-1',
143
+ :parent_id => cms_pages(:default).id,
144
+ :cms_layout_id => layout_1.id,
145
+ :is_published => '1',
146
+ :cms_blocks_attributes => [
147
+ { :label => 'header',
148
+ :content => 'header_content' },
149
+ { :label => 'content',
150
+ :content => 'content_content' }
151
+ ]
152
+ )
153
+ page_2 = cms_sites(:default).cms_pages.create!(
154
+ :label => 'page_2',
155
+ :slug => 'page-2',
156
+ :parent_id => cms_pages(:default).id,
157
+ :cms_layout_id => layout_2.id,
158
+ :is_published => '1',
159
+ :cms_blocks_attributes => [
160
+ { :label => 'header',
161
+ :content => 'header_content' },
162
+ { :label => 'left_column',
163
+ :content => 'left_column_content' },
164
+ { :label => 'right_column',
165
+ :content => 'left_column_content' }
166
+ ]
167
+ )
168
+ assert_equal "header_content\ncontent_content", page_1.content
169
+ assert_equal "header_content\nleft_column_content\nleft_column_content", page_2.content
170
+
171
+ layout_1.update_attribute(:content, "Updated {{cms:page:content}}")
172
+ page_1.reload
173
+ page_2.reload
174
+
175
+ assert_equal "Updated content_content", page_1.content
176
+ assert_equal "Updated left_column_content\nleft_column_content", page_2.content
144
177
  end
145
178
 
146
179
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 48
9
- version: 1.0.48
8
+ - 49
9
+ version: 1.0.49
10
10
  platform: ruby
11
11
  authors:
12
12
  - Oleg Khabarov
@@ -384,7 +384,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
384
384
  requirements:
385
385
  - - ">="
386
386
  - !ruby/object:Gem::Version
387
- hash: -3244962332587742397
387
+ hash: -3061887318835465352
388
388
  segments:
389
389
  - 0
390
390
  version: "0"