comfortable_mexican_sofa 1.0.23 → 1.0.24

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.23
1
+ 1.0.24
@@ -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.23"
8
+ s.version = "1.0.24"
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"]
@@ -169,7 +169,8 @@ Gem::Specification.new do |s|
169
169
  "test/unit/cms_tags/page_text_test.rb",
170
170
  "test/unit/cms_tags/partial_test.rb",
171
171
  "test/unit/cms_tags/snippet_test.rb",
172
- "test/unit/cms_upload_test.rb"
172
+ "test/unit/cms_upload_test.rb",
173
+ "test/unit/view_methods_test.rb"
173
174
  ]
174
175
  s.homepage = %q{http://github.com/theworkinggroup/comfortable-mexican-sofa}
175
176
  s.rdoc_options = ["--charset=UTF-8"]
@@ -208,7 +209,8 @@ Gem::Specification.new do |s|
208
209
  "test/unit/cms_tags/page_text_test.rb",
209
210
  "test/unit/cms_tags/partial_test.rb",
210
211
  "test/unit/cms_tags/snippet_test.rb",
211
- "test/unit/cms_upload_test.rb"
212
+ "test/unit/cms_upload_test.rb",
213
+ "test/unit/view_methods_test.rb"
212
214
  ]
213
215
 
214
216
  if s.respond_to? :specification_version then
@@ -19,6 +19,24 @@ module ComfortableMexicanSofa::ViewMethods
19
19
  def cms_hook(name)
20
20
  ComfortableMexicanSofa::ViewHooks.render(name, self)
21
21
  end
22
+
23
+ # Content of a snippet. Example:
24
+ # cms_snippet_content(:my_snippet)
25
+ def cms_snippet_content(snippet_slug)
26
+ return '' unless snippet = CmsSnippet.find_by_slug(snippet_slug)
27
+ snippet.content.to_s.html_safe
28
+ end
29
+
30
+ # Content of a page block. This is how you get content from page:field
31
+ # Example:
32
+ # cms_page_content(:left_column, CmsPage.first)
33
+ # cms_page_content(:left_column) # if @cms_page is present
34
+ def cms_page_content(block_label, page = nil)
35
+ return '' unless page ||= @cms_page
36
+ return '' unless block = page.cms_blocks.find_by_label(block_label)
37
+ block.content.to_s.html_safe
38
+ end
39
+
22
40
  end
23
41
 
24
42
  ActionView::Base.send :include, ComfortableMexicanSofa::ViewMethods
@@ -6,7 +6,7 @@ $.CMS = function(){
6
6
  $('input#slugify').bind('keyup.cms', function() {
7
7
  $('input#slug').val( $.CMS.slugify( $(this).val() ) );
8
8
  });
9
-
9
+
10
10
  // Expand/Collapse tree function
11
11
  $('a.tree_toggle').bind('click.cms', function() {
12
12
  $(this).siblings('ul').toggle();
@@ -14,12 +14,12 @@ $.CMS = function(){
14
14
  // object_id are set in the helper (check cms_helper.rb)
15
15
  $.ajax({url: [current_path, object_id, 'toggle'].join('/')});
16
16
  });
17
-
17
+
18
18
  // Show/hide details
19
19
  $('a.details_toggle').bind('click.cms', function() {
20
20
  $(this).parent().siblings('table.details').toggle();
21
21
  });
22
-
22
+
23
23
  // Sortable trees
24
24
  $('ul.sortable').each(function(){
25
25
  $(this).sortable({ handle: 'div.dragger',
@@ -31,13 +31,11 @@ $.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: [$(this).attr('data-path-prefix'), 'pages', $(this).attr('data-page-id'), 'form_blocks'].join('/'), data: ({ layout_id: $(this).val()})})
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()
38
-
39
-
40
-
38
+
41
39
  return {
42
40
  slugify: function(str){
43
41
  str = str.replace(/^\s+|\s+$/g, '');
@@ -50,4 +48,4 @@ $.CMS = function(){
50
48
  return str;
51
49
  }
52
50
  }
53
- }();
51
+ }();
@@ -0,0 +1,21 @@
1
+ require File.expand_path('../test_helper', File.dirname(__FILE__))
2
+
3
+ class ViewMethodsTest < ActiveSupport::TestCase
4
+
5
+ include ComfortableMexicanSofa::ViewMethods
6
+
7
+ def test_cms_snippet_content
8
+ assert_equal 'default_snippet_content', cms_snippet_content('default')
9
+ assert_equal '', cms_snippet_content('not_found')
10
+ end
11
+
12
+ def test_cms_page_content
13
+ assert_equal 'default_field_text_content', cms_page_content('default_field_text', cms_pages(:default))
14
+ assert_equal '', cms_page_content('default_field_text')
15
+ @cms_page = cms_pages(:default)
16
+ assert_equal 'default_field_text_content', cms_page_content('default_field_text')
17
+ assert_equal '', cms_page_content('not_found')
18
+ @cms_page = nil
19
+ end
20
+
21
+ end
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: 57
4
+ hash: 39
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 23
10
- version: 1.0.23
9
+ - 24
10
+ version: 1.0.24
11
11
  platform: ruby
12
12
  authors:
13
13
  - Oleg Khabarov
@@ -230,6 +230,7 @@ files:
230
230
  - test/unit/cms_tags/partial_test.rb
231
231
  - test/unit/cms_tags/snippet_test.rb
232
232
  - test/unit/cms_upload_test.rb
233
+ - test/unit/view_methods_test.rb
233
234
  has_rdoc: true
234
235
  homepage: http://github.com/theworkinggroup/comfortable-mexican-sofa
235
236
  licenses: []
@@ -297,3 +298,4 @@ test_files:
297
298
  - test/unit/cms_tags/partial_test.rb
298
299
  - test/unit/cms_tags/snippet_test.rb
299
300
  - test/unit/cms_upload_test.rb
301
+ - test/unit/view_methods_test.rb