comfortable_mexican_sofa 1.0.7 → 1.0.9
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.
|
1
|
+
1.0.9
|
@@ -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.9"
|
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-10-
|
12
|
+
s.date = %q{2010-10-28}
|
13
13
|
s.description = %q{}
|
14
14
|
s.email = %q{oleg@theworkinggroup.ca}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -6,6 +6,8 @@
|
|
6
6
|
# end
|
7
7
|
module CmsTag
|
8
8
|
|
9
|
+
TOKENIZER_REGEX = /(<\s*cms:.*?\/?>)|((?:[^<]|\<(?!\s*cms:.*?\/?>))+)/
|
10
|
+
|
9
11
|
attr_accessor :params,
|
10
12
|
:parent
|
11
13
|
|
@@ -81,7 +83,7 @@ private
|
|
81
83
|
# Tags are processed further and their content is expanded in the same way.
|
82
84
|
# Tags are defined in the parent tags are ignored and not rendered.
|
83
85
|
def self.process_content(cms_page, content = '', parent_tag = nil)
|
84
|
-
tokens = content.to_s.scan(
|
86
|
+
tokens = content.to_s.scan(TOKENIZER_REGEX)
|
85
87
|
tokens.collect do |tag_signature, text|
|
86
88
|
if tag_signature
|
87
89
|
if tag = self.initialize_tag(cms_page, tag_signature)
|
@@ -23,11 +23,13 @@ module ComfortableMexicanSofa::ControllerMethods
|
|
23
23
|
def render_with_cms(options = {}, locals = {}, &block)
|
24
24
|
if path = options.delete(:cms_page)
|
25
25
|
site = CmsSite.find_by_hostname(request.host.downcase)
|
26
|
-
page = site &&
|
26
|
+
page = CmsPage.load_from_file(site, path) if site && ComfortableMexicanSofa.configuration.seed_data_path
|
27
|
+
page ||= site && site.cms_pages.find_by_full_path(path)
|
27
28
|
if page
|
28
29
|
cms_app_layout = page.cms_layout.try(:app_layout)
|
29
30
|
options[:layout] ||= cms_app_layout.blank?? nil : cms_app_layout
|
30
31
|
options[:inline] = page.content
|
32
|
+
@cms_page = page
|
31
33
|
render_without_cms(options, locals, &block)
|
32
34
|
else
|
33
35
|
raise ActionView::MissingTemplate.new([path], path, "CMS page not found", nil)
|
@@ -4,8 +4,9 @@ class RenderCmsTest < ActionDispatch::IntegrationTest
|
|
4
4
|
|
5
5
|
def setup
|
6
6
|
Rails.application.routes.draw do
|
7
|
-
get '/render-implicit'
|
8
|
-
get '/render-explicit'
|
7
|
+
get '/render-implicit' => 'render_test#implicit'
|
8
|
+
get '/render-explicit' => 'render_test#explicit'
|
9
|
+
get '/seed_data_page' => 'render_test#seed_data_page'
|
9
10
|
end
|
10
11
|
super
|
11
12
|
end
|
@@ -21,6 +22,9 @@ class RenderCmsTest < ActionDispatch::IntegrationTest
|
|
21
22
|
def explicit
|
22
23
|
render :cms_page => '/render-explicit-page'
|
23
24
|
end
|
25
|
+
def seed_data_page
|
26
|
+
render :cms_page => '/'
|
27
|
+
end
|
24
28
|
end
|
25
29
|
|
26
30
|
def test_get_with_no_template
|
@@ -54,4 +58,13 @@ class RenderCmsTest < ActionDispatch::IntegrationTest
|
|
54
58
|
end
|
55
59
|
end
|
56
60
|
|
61
|
+
def test_get_seed_data_page
|
62
|
+
ComfortableMexicanSofa.configuration.seed_data_path = File.expand_path('../cms_seeds', File.dirname(__FILE__))
|
63
|
+
|
64
|
+
get '/seed_data_page'
|
65
|
+
assert_response :success
|
66
|
+
assert assigns(:cms_page)
|
67
|
+
assert assigns(:cms_page).new_record?
|
68
|
+
end
|
69
|
+
|
57
70
|
end
|
data/test/unit/cms_tag_test.rb
CHANGED
@@ -2,6 +2,50 @@ require File.dirname(__FILE__) + '/../test_helper'
|
|
2
2
|
|
3
3
|
class CmsTagTest < ActiveSupport::TestCase
|
4
4
|
|
5
|
+
def test_tokenizer_regex
|
6
|
+
regex = CmsTag::TOKENIZER_REGEX
|
7
|
+
|
8
|
+
tokens = 'content<<cms:some_tag content'.scan(regex)
|
9
|
+
assert_equal nil, tokens[0][0]
|
10
|
+
assert_equal 'content<<cms:some_tag content', tokens[0][1]
|
11
|
+
|
12
|
+
tokens = 'content<<cms some_tag>>content'.scan(regex)
|
13
|
+
assert_equal nil, tokens[0][0]
|
14
|
+
assert_equal 'content<<cms some_tag>>content', tokens[0][1]
|
15
|
+
|
16
|
+
tokens = 'content<<cms:some_tag>>content'.scan(regex)
|
17
|
+
assert_equal nil, tokens[0][0]
|
18
|
+
assert_equal 'content<', tokens[0][1]
|
19
|
+
assert_equal '<cms:some_tag>', tokens[1][0]
|
20
|
+
assert_equal nil, tokens[1][1]
|
21
|
+
assert_equal nil, tokens[2][0]
|
22
|
+
assert_equal '>content', tokens[2][1]
|
23
|
+
|
24
|
+
tokens = 'content<<cms:type:label>>content'.scan(regex)
|
25
|
+
assert_equal nil, tokens[0][0]
|
26
|
+
assert_equal 'content<', tokens[0][1]
|
27
|
+
assert_equal '<cms:type:label>', tokens[1][0]
|
28
|
+
assert_equal nil, tokens[1][1]
|
29
|
+
assert_equal nil, tokens[2][0]
|
30
|
+
assert_equal '>content', tokens[2][1]
|
31
|
+
|
32
|
+
tokens = 'content<<cms:type:label />>content'.scan(regex)
|
33
|
+
assert_equal nil, tokens[0][0]
|
34
|
+
assert_equal 'content<', tokens[0][1]
|
35
|
+
assert_equal '<cms:type:label />', tokens[1][0]
|
36
|
+
assert_equal nil, tokens[1][1]
|
37
|
+
assert_equal nil, tokens[2][0]
|
38
|
+
assert_equal '>content', tokens[2][1]
|
39
|
+
|
40
|
+
tokens = 'content<< cms:type:la/b el />>content'.scan(regex)
|
41
|
+
assert_equal nil, tokens[0][0]
|
42
|
+
assert_equal 'content<', tokens[0][1]
|
43
|
+
assert_equal '< cms:type:la/b el />', tokens[1][0]
|
44
|
+
assert_equal nil, tokens[1][1]
|
45
|
+
assert_equal nil, tokens[2][0]
|
46
|
+
assert_equal '>content', tokens[2][1]
|
47
|
+
end
|
48
|
+
|
5
49
|
def test_content_for_existing_page
|
6
50
|
page = cms_pages(:default)
|
7
51
|
assert page.cms_tags.blank?
|
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: 5
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 9
|
10
|
+
version: 1.0.9
|
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-10-
|
19
|
+
date: 2010-10-28 00:00:00 -04:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|