comfortable_mexican_sofa 1.5.11 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +2 -2
- data/Gemfile +1 -1
- data/VERSION +1 -1
- data/app/assets/images/comfortable_mexican_sofa/checkerboard.gif +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/elrte-toolbar.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/google-maps.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/iframe.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/media-director.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/media-flash.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/media-quicktime.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/media-realaudio.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/media-rutube.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/media-vimeo.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/media-winmedia.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/media-youtube.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/outline-div.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/outline-p.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/pagebreak.gif +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/pixel.gif +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/smileys/evilgrin.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/smileys/grin.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/smileys/happy.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/smileys/smile.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/smileys/surprised.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/smileys/tongue.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/smileys/unhappy.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/smileys/waii.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/elrte/smileys/wink.png +0 -0
- data/app/assets/images/comfortable_mexican_sofa/x.png +0 -0
- data/app/assets/javascripts/comfortable_mexican_sofa/application.js +28 -3
- data/app/assets/javascripts/comfortable_mexican_sofa/codemirror/codemirror.js +1 -1
- data/app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.codemirror.js +35 -0
- data/app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.js +267 -0
- data/app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_image.js +61 -0
- data/app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_link.js +58 -0
- data/app/assets/javascripts/comfortable_mexican_sofa/jquery.js +4 -18
- data/app/assets/stylesheets/comfortable_mexican_sofa/application.css +3 -0
- data/app/assets/stylesheets/comfortable_mexican_sofa/codemirror.css +6 -0
- data/app/assets/stylesheets/comfortable_mexican_sofa/content.css +0 -65
- data/app/assets/stylesheets/comfortable_mexican_sofa/dialogs.css +45 -0
- data/app/assets/stylesheets/comfortable_mexican_sofa/elrte.css +173 -0
- data/app/assets/stylesheets/comfortable_mexican_sofa/files.css +82 -0
- data/app/assets/stylesheets/comfortable_mexican_sofa/form.css +2 -2
- data/app/assets/stylesheets/comfortable_mexican_sofa/structure.css +1 -1
- data/app/assets/stylesheets/comfortable_mexican_sofa/widgets.css +14 -56
- data/app/controllers/cms_admin/categories_controller.rb +2 -2
- data/app/controllers/cms_admin/dialogs_controller.rb +13 -0
- data/app/controllers/cms_admin/files_controller.rb +4 -1
- data/app/controllers/cms_admin/revisions_controller.rb +2 -2
- data/app/controllers/cms_content_controller.rb +1 -1
- data/app/models/cms/block.rb +2 -2
- data/app/models/cms/category.rb +3 -0
- data/app/models/cms/file.rb +9 -1
- data/app/models/cms/layout.rb +2 -2
- data/app/models/cms/page.rb +7 -5
- data/app/models/cms/site.rb +10 -5
- data/app/models/cms/snippet.rb +5 -3
- data/app/views/cms_admin/categories/_form.html.erb +1 -1
- data/app/views/cms_admin/categories/_index.html.erb +2 -2
- data/app/views/cms_admin/dialogs/image.html.erb +7 -0
- data/app/views/cms_admin/dialogs/link.html.erb +5 -0
- data/app/views/cms_admin/files/_file.html.erb +17 -9
- data/app/views/cms_admin/files/_index.html.erb +8 -18
- data/app/views/cms_admin/files/create.js.erb +1 -1
- data/app/views/cms_admin/layouts/_form.html.erb +1 -1
- data/app/views/cms_admin/layouts/_index_branch.html.erb +1 -1
- data/app/views/cms_admin/pages/_form_blocks.html.erb +1 -1
- data/app/views/cms_admin/revisions/show.html.erb +1 -1
- data/app/views/cms_admin/sites/_form.html.erb +2 -1
- data/app/views/cms_admin/snippets/_form.html.erb +1 -1
- data/app/views/cms_admin/snippets/index.html.erb +1 -1
- data/app/views/layouts/cms_admin/_head.html.erb +7 -6
- data/comfortable_mexican_sofa.gemspec +46 -47
- data/config/initializers/paperclip.rb +0 -25
- data/config/locales/en.yml +6 -0
- data/config/locales/es.yml +6 -0
- data/config/routes.rb +3 -2
- data/db/migrate/01_create_cms.rb +37 -35
- data/db/migrate/upgrades/07_upgrade_to_1_6_0.rb +25 -0
- data/lib/comfortable_mexican_sofa/error.rb +4 -4
- data/lib/comfortable_mexican_sofa/extensions/is_categorized.rb +3 -1
- data/lib/comfortable_mexican_sofa/extensions/is_mirrored.rb +8 -8
- data/lib/comfortable_mexican_sofa/fixtures.rb +19 -19
- data/lib/comfortable_mexican_sofa/form_builder.rb +4 -4
- data/lib/comfortable_mexican_sofa/render_methods.rb +8 -8
- data/lib/comfortable_mexican_sofa/tag.rb +14 -13
- data/lib/comfortable_mexican_sofa/tags/asset.rb +6 -6
- data/lib/comfortable_mexican_sofa/tags/collection.rb +3 -3
- data/lib/comfortable_mexican_sofa/tags/field_datetime.rb +3 -3
- data/lib/comfortable_mexican_sofa/tags/field_integer.rb +3 -3
- data/lib/comfortable_mexican_sofa/tags/field_string.rb +3 -3
- data/lib/comfortable_mexican_sofa/tags/field_text.rb +3 -3
- data/lib/comfortable_mexican_sofa/tags/file.rb +5 -5
- data/lib/comfortable_mexican_sofa/tags/helper.rb +4 -4
- data/lib/comfortable_mexican_sofa/tags/page_datetime.rb +3 -3
- data/lib/comfortable_mexican_sofa/tags/page_file.rb +8 -6
- data/lib/comfortable_mexican_sofa/tags/page_files.rb +6 -4
- data/lib/comfortable_mexican_sofa/tags/page_integer.rb +3 -3
- data/lib/comfortable_mexican_sofa/tags/page_rich_text.rb +3 -3
- data/lib/comfortable_mexican_sofa/tags/page_string.rb +3 -3
- data/lib/comfortable_mexican_sofa/tags/page_text.rb +3 -3
- data/lib/comfortable_mexican_sofa/tags/partial.rb +4 -4
- data/lib/comfortable_mexican_sofa/tags/snippet.rb +5 -4
- data/lib/comfortable_mexican_sofa/view_methods.rb +6 -6
- data/test/fixtures/cms/blocks.yml +2 -2
- data/test/fixtures/cms/categories.yml +1 -0
- data/test/fixtures/cms/layouts.yml +3 -3
- data/test/fixtures/cms/revisions.yml +4 -4
- data/test/fixtures/cms/sites.yml +1 -0
- data/test/fixtures/cms/snippets.yml +1 -1
- data/test/fixtures/files/data.zip +0 -0
- data/test/functional/cms_admin/dialogs_controller_test.rb +24 -0
- data/test/functional/cms_admin/files_controller_test.rb +1 -1
- data/test/functional/cms_admin/layouts_controller_test.rb +7 -7
- data/test/functional/cms_admin/pages_controller_test.rb +34 -35
- data/test/functional/cms_admin/revisions_controller_test.rb +2 -2
- data/test/functional/cms_admin/sites_controller_test.rb +3 -2
- data/test/functional/cms_admin/snippets_controller_test.rb +8 -8
- data/test/functional/cms_content_controller_test.rb +10 -11
- data/test/gemfiles/{Gemfile.rails-3.0.10 → Gemfile.rails-3.0} +1 -1
- data/test/gemfiles/{Gemfile.rails-3.1.1 → Gemfile.rails-3.1} +1 -1
- data/test/integration/fixtures_test.rb +4 -4
- data/test/integration/mirrors_test.rb +1 -1
- data/test/integration/render_cms_test.rb +10 -10
- data/test/integration/sites_test.rb +3 -3
- data/test/test_helper.rb +3 -0
- data/test/unit/fixtures_test.rb +11 -11
- data/test/unit/mirrors_test.rb +25 -25
- data/test/unit/models/block_test.rb +29 -29
- data/test/unit/models/categorization_test.rb +1 -1
- data/test/unit/models/category_test.rb +2 -2
- data/test/unit/models/file_test.rb +18 -0
- data/test/unit/models/layout_test.rb +21 -18
- data/test/unit/models/page_test.rb +3 -3
- data/test/unit/models/site_test.rb +26 -17
- data/test/unit/models/snippet_test.rb +6 -6
- data/test/unit/revisions_test.rb +13 -13
- data/test/unit/tag_test.rb +39 -45
- data/test/unit/tags/asset_test.rb +1 -1
- data/test/unit/tags/collection_test.rb +12 -10
- data/test/unit/tags/field_datetime_test.rb +3 -3
- data/test/unit/tags/field_integer_test.rb +3 -3
- data/test/unit/tags/field_string_test.rb +4 -4
- data/test/unit/tags/field_text_test.rb +3 -3
- data/test/unit/tags/file_test.rb +1 -1
- data/test/unit/tags/helper_test.rb +3 -3
- data/test/unit/tags/page_datetime_test.rb +3 -3
- data/test/unit/tags/page_file_test.rb +7 -4
- data/test/unit/tags/page_files_test.rb +7 -4
- data/test/unit/tags/page_integer_test.rb +3 -3
- data/test/unit/tags/page_rich_text_test.rb +3 -3
- data/test/unit/tags/page_string_test.rb +3 -3
- data/test/unit/tags/page_text_test.rb +4 -4
- data/test/unit/tags/partial_test.rb +4 -4
- data/test/unit/tags/snippet_test.rb +3 -3
- metadata +51 -52
- data/app/assets/images/comfortable_mexican_sofa/wym_icons.png +0 -0
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/lbl-blockquote.png +0 -0
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/lbl-h1.png +0 -0
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/lbl-h2.png +0 -0
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/lbl-h3.png +0 -0
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/lbl-h4.png +0 -0
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/lbl-h5.png +0 -0
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/lbl-h6.png +0 -0
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/lbl-p.png +0 -0
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/lbl-pre.png +0 -0
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/wymiframe.css +0 -52
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/iframe/default/wymiframe.html +0 -26
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/jquery.wymeditor.cms.js +0 -342
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/jquery.wymeditor.embed.js +0 -19
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/jquery.wymeditor.pack.js +0 -1
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/bg.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/ca.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/cs.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/cy.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/de.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/en.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/es.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/fa.js +0 -46
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/fi.js +0 -44
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/fr.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/gl.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/he.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/hr.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/hu.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/it.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/nb.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/nl.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/nn.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/pl.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/pt-br.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/pt.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/ru.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/sv.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/tr.js +0 -45
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/lang/zh_cn.js +0 -47
@@ -0,0 +1,25 @@
|
|
1
|
+
class UpgradeTo150 < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
add_column :cms_sites, :identifier, :string, :null => false
|
4
|
+
add_index :cms_sites, :identifier
|
5
|
+
|
6
|
+
rename_column :cms_layouts, :slug, :identifier
|
7
|
+
rename_column :cms_blocks, :label, :identifier
|
8
|
+
rename_column :cms_snippets, :slug, :identifier
|
9
|
+
|
10
|
+
add_column :cms_categories, :site_id, :integer, :null => :false
|
11
|
+
add_index :cms_categories, [:site_id, :categorized_type, :label], :unique => true
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.down
|
15
|
+
remove_index :cms_categories, [:site_id, :categorized_type, :label], :unique => true
|
16
|
+
remove_column :cms_categories, :site_id
|
17
|
+
|
18
|
+
rename_column :cms_snippets, :identifier, :slug
|
19
|
+
rename_column :cms_blocks, :identifier, :label
|
20
|
+
rename_column :cms_layouts, :identifier, :slug
|
21
|
+
|
22
|
+
remove_index :cms_sites, :identifier
|
23
|
+
remove_column :cms_sites, :identifier
|
24
|
+
end
|
25
|
+
end
|
@@ -4,14 +4,14 @@ module ComfortableMexicanSofa
|
|
4
4
|
end
|
5
5
|
|
6
6
|
class MissingSite < ComfortableMexicanSofa::Error
|
7
|
-
def initialize(
|
8
|
-
super "Cannot find CMS Site with
|
7
|
+
def initialize(identifier)
|
8
|
+
super "Cannot find CMS Site with identifier: #{identifier}"
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
class MissingLayout < ComfortableMexicanSofa::Error
|
13
|
-
def initialize(
|
14
|
-
super "Cannot find CMS Layout with
|
13
|
+
def initialize(identifier)
|
14
|
+
super "Cannot find CMS Layout with identifier: #{identifier}"
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -22,7 +22,9 @@ module ComfortableMexicanSofa::IsCategorized
|
|
22
22
|
|
23
23
|
scope :for_category, lambda { |*categories|
|
24
24
|
if (categories = [categories].flatten.compact).present?
|
25
|
-
select("DISTINCT #{table_name}.*").
|
25
|
+
select("DISTINCT #{table_name}.*").
|
26
|
+
joins(:categorizations => :category).
|
27
|
+
where('cms_categories.label' => categories)
|
26
28
|
end
|
27
29
|
}
|
28
30
|
end
|
@@ -22,9 +22,9 @@ module ComfortableMexicanSofa::IsMirrored
|
|
22
22
|
return [] unless self.site.is_mirrored?
|
23
23
|
(Cms::Site.mirrored - [self.site]).collect do |site|
|
24
24
|
case self
|
25
|
-
when Cms::Layout then site.layouts.
|
25
|
+
when Cms::Layout then site.layouts.find_by_identifier(self.identifier)
|
26
26
|
when Cms::Page then site.pages.find_by_full_path(self.full_path)
|
27
|
-
when Cms::Snippet then site.snippets.
|
27
|
+
when Cms::Snippet then site.snippets.find_by_identifier(self.identifier)
|
28
28
|
end
|
29
29
|
end.compact
|
30
30
|
end
|
@@ -38,10 +38,10 @@ module ComfortableMexicanSofa::IsMirrored
|
|
38
38
|
(Cms::Site.mirrored - [self.site]).each do |site|
|
39
39
|
mirror = case self
|
40
40
|
when Cms::Layout
|
41
|
-
m = site.layouts.
|
41
|
+
m = site.layouts.find_by_identifier(self.identifier_was || self.identifier) || site.layouts.new
|
42
42
|
m.attributes = {
|
43
|
-
:
|
44
|
-
:parent_id => site.layouts.
|
43
|
+
:identifier => self.identifier,
|
44
|
+
:parent_id => site.layouts.find_by_identifier(self.parent.try(:identifier)).try(:id)
|
45
45
|
}
|
46
46
|
m
|
47
47
|
when Cms::Page
|
@@ -50,13 +50,13 @@ module ComfortableMexicanSofa::IsMirrored
|
|
50
50
|
:slug => self.slug,
|
51
51
|
:label => self.slug.blank?? self.label : m.label,
|
52
52
|
:parent_id => site.pages.find_by_full_path(self.parent.try(:full_path)).try(:id),
|
53
|
-
:layout => site.layouts.
|
53
|
+
:layout => site.layouts.find_by_identifier(self.layout.identifier)
|
54
54
|
}
|
55
55
|
m
|
56
56
|
when Cms::Snippet
|
57
|
-
m = site.snippets.
|
57
|
+
m = site.snippets.find_by_identifier(self.identifier_was || self.identifier) || site.snippets.new
|
58
58
|
m.attributes = {
|
59
|
-
:
|
59
|
+
:identifier => self.identifier
|
60
60
|
}
|
61
61
|
m
|
62
62
|
end
|
@@ -20,11 +20,11 @@ module ComfortableMexicanSofa::Fixtures
|
|
20
20
|
end
|
21
21
|
|
22
22
|
Dir.glob("#{path}/*").select{|f| File.directory?(f)}.each do |path|
|
23
|
-
|
24
|
-
layout = site.layouts.
|
23
|
+
identifier = path.split('/').last
|
24
|
+
layout = site.layouts.find_by_identifier(identifier) || site.layouts.new(:identifier => identifier)
|
25
25
|
|
26
26
|
# updating attributes
|
27
|
-
if File.exists?(file_path = File.join(path, "_#{
|
27
|
+
if File.exists?(file_path = File.join(path, "_#{identifier}.yml"))
|
28
28
|
if layout.new_record? || File.mtime(file_path) > layout.updated_at
|
29
29
|
attributes = YAML.load_file(file_path).symbolize_keys!
|
30
30
|
layout.label = attributes[:label] || slug.titleize
|
@@ -56,7 +56,7 @@ module ComfortableMexicanSofa::Fixtures
|
|
56
56
|
layout.parent = parent
|
57
57
|
if layout.changed?
|
58
58
|
layout.save!
|
59
|
-
Rails.logger.debug "[Fixtures] Saved Layout {#{layout.
|
59
|
+
Rails.logger.debug "[Fixtures] Saved Layout {#{layout.identifier}}"
|
60
60
|
end
|
61
61
|
layout_ids << layout.id
|
62
62
|
|
@@ -94,7 +94,7 @@ module ComfortableMexicanSofa::Fixtures
|
|
94
94
|
if page.new_record? || File.mtime(file_path) > page.updated_at
|
95
95
|
attributes = YAML.load_file(file_path).symbolize_keys!
|
96
96
|
page.label = attributes[:label] || slug.titleize
|
97
|
-
page.layout = site.layouts.
|
97
|
+
page.layout = site.layouts.find_by_identifier(attributes[:layout]) || parent.try(:layout)
|
98
98
|
page.target_page = site.pages.find_by_full_path(attributes[:target_page])
|
99
99
|
page.is_published = attributes[:is_published].present?? attributes[:is_published] : true
|
100
100
|
end
|
@@ -107,10 +107,10 @@ module ComfortableMexicanSofa::Fixtures
|
|
107
107
|
blocks_attributes = [ ]
|
108
108
|
Dir.glob("#{path}/*.html").each do |file_path|
|
109
109
|
if page.new_record? || File.mtime(file_path) > page.updated_at
|
110
|
-
|
110
|
+
identifier = file_path.split('/').last.split('.').first
|
111
111
|
blocks_attributes << {
|
112
|
-
:
|
113
|
-
:content
|
112
|
+
:identifier => identifier,
|
113
|
+
:content => File.open(file_path, 'rb').read
|
114
114
|
}
|
115
115
|
end
|
116
116
|
end
|
@@ -146,11 +146,11 @@ module ComfortableMexicanSofa::Fixtures
|
|
146
146
|
|
147
147
|
snippet_ids = []
|
148
148
|
Dir.glob("#{path}/*").select{|f| File.directory?(f)}.each do |path|
|
149
|
-
|
150
|
-
snippet = site.snippets.
|
149
|
+
identifier = path.split('/').last
|
150
|
+
snippet = site.snippets.find_by_identifier(identifier) || site.snippets.new(:identifier => identifier)
|
151
151
|
|
152
152
|
# updating attributes
|
153
|
-
if File.exists?(file_path = File.join(path, "_#{
|
153
|
+
if File.exists?(file_path = File.join(path, "_#{identifier}.yml"))
|
154
154
|
if snippet.new_record? || File.mtime(file_path) > snippet.updated_at
|
155
155
|
attributes = YAML.load_file(file_path).symbolize_keys!
|
156
156
|
snippet.label = attributes[:label] || slug.titleize
|
@@ -169,7 +169,7 @@ module ComfortableMexicanSofa::Fixtures
|
|
169
169
|
# saving
|
170
170
|
if snippet.changed?
|
171
171
|
snippet.save!
|
172
|
-
Rails.logger.debug "[Fixtures] Saved Snippet {#{snippet.
|
172
|
+
Rails.logger.debug "[Fixtures] Saved Snippet {#{snippet.identifier}}"
|
173
173
|
end
|
174
174
|
snippet_ids << snippet.id
|
175
175
|
end
|
@@ -186,14 +186,14 @@ module ComfortableMexicanSofa::Fixtures
|
|
186
186
|
FileUtils.mkdir_p(path)
|
187
187
|
|
188
188
|
site.layouts.each do |layout|
|
189
|
-
layout_path = File.join(path, layout.ancestors.reverse.collect{|l| l.
|
189
|
+
layout_path = File.join(path, layout.ancestors.reverse.collect{|l| l.identifier}, layout.identifier)
|
190
190
|
FileUtils.mkdir_p(layout_path)
|
191
191
|
|
192
|
-
open(File.join(layout_path, "_#{layout.
|
192
|
+
open(File.join(layout_path, "_#{layout.identifier}.yml"), 'w') do |f|
|
193
193
|
f.write({
|
194
194
|
'label' => layout.label,
|
195
195
|
'app_layout' => layout.app_layout,
|
196
|
-
'parent' => layout.parent.try(:
|
196
|
+
'parent' => layout.parent.try(:identifier)
|
197
197
|
}.to_yaml)
|
198
198
|
end
|
199
199
|
open(File.join(layout_path, 'content.html'), 'w') do |f|
|
@@ -222,14 +222,14 @@ module ComfortableMexicanSofa::Fixtures
|
|
222
222
|
open(File.join(page_path, "_#{page.slug}.yml"), 'w') do |f|
|
223
223
|
f.write({
|
224
224
|
'label' => page.label,
|
225
|
-
'layout' => page.layout.try(:
|
225
|
+
'layout' => page.layout.try(:identifier),
|
226
226
|
'parent' => page.parent && (page.parent.slug.present?? page.parent.slug : 'index'),
|
227
227
|
'target_page' => page.target_page.try(:slug),
|
228
228
|
'is_published' => page.is_published
|
229
229
|
}.to_yaml)
|
230
230
|
end
|
231
231
|
page.blocks_attributes.each do |block|
|
232
|
-
open(File.join(page_path, "#{block[:
|
232
|
+
open(File.join(page_path, "#{block[:identifier]}.html"), 'w') do |f|
|
233
233
|
f.write(block[:content])
|
234
234
|
end
|
235
235
|
end
|
@@ -243,8 +243,8 @@ module ComfortableMexicanSofa::Fixtures
|
|
243
243
|
FileUtils.mkdir_p(path)
|
244
244
|
|
245
245
|
site.snippets.each do |snippet|
|
246
|
-
FileUtils.mkdir_p(snippet_path = File.join(path, snippet.
|
247
|
-
open(File.join(snippet_path, "_#{snippet.
|
246
|
+
FileUtils.mkdir_p(snippet_path = File.join(path, snippet.identifier))
|
247
|
+
open(File.join(snippet_path, "_#{snippet.identifier}.yml"), 'w') do |f|
|
248
248
|
f.write({'label' => snippet.label}.to_yaml)
|
249
249
|
end
|
250
250
|
open(File.join(snippet_path, 'content.html'), 'w') do |f|
|
@@ -57,7 +57,7 @@ class ComfortableMexicanSofa::FormBuilder < ActionView::Helpers::FormBuilder
|
|
57
57
|
# -- Tag Field Fields -----------------------------------------------------
|
58
58
|
def default_tag_field(tag, index, options = {})
|
59
59
|
method = options.delete(:method) || :text_field_tag
|
60
|
-
label = tag.
|
60
|
+
label = tag.identifier.to_s.titleize
|
61
61
|
css_class = tag.class.to_s.demodulize.underscore
|
62
62
|
content = ''
|
63
63
|
|
@@ -81,7 +81,7 @@ class ComfortableMexicanSofa::FormBuilder < ActionView::Helpers::FormBuilder
|
|
81
81
|
else
|
82
82
|
content << @template.send(method, "page[blocks_attributes][#{index}][content]", tag.content, :id => nil, :class => input_class)
|
83
83
|
end
|
84
|
-
content << @template.hidden_field_tag("page[blocks_attributes][#{index}][
|
84
|
+
content << @template.hidden_field_tag("page[blocks_attributes][#{index}][identifier]", tag.identifier, :id => nil)
|
85
85
|
|
86
86
|
simple_field(label, content, :class => css_class)
|
87
87
|
end
|
@@ -141,8 +141,8 @@ class ComfortableMexicanSofa::FormBuilder < ActionView::Helpers::FormBuilder
|
|
141
141
|
@template.options_for_select(options, :selected => tag.content),
|
142
142
|
:id => nil
|
143
143
|
)
|
144
|
-
content << @template.hidden_field_tag("page[blocks_attributes][#{index}][
|
145
|
-
simple_field(tag.
|
144
|
+
content << @template.hidden_field_tag("page[blocks_attributes][#{index}][identifier]", tag.identifier, :id => nil)
|
145
|
+
simple_field(tag.identifier.titleize, content, :class => tag.class.to_s.demodulize.underscore )
|
146
146
|
end
|
147
147
|
|
148
148
|
end
|
@@ -37,9 +37,9 @@ module ComfortableMexicanSofa::RenderMethods
|
|
37
37
|
def render(options = {}, locals = {}, &block)
|
38
38
|
|
39
39
|
# TODO: add slug to Cms::Site as well
|
40
|
-
if options.is_a?(Hash) &&
|
41
|
-
unless @cms_site = Cms::Site.
|
42
|
-
raise ComfortableMexicanSofa::MissingSite.new(
|
40
|
+
if options.is_a?(Hash) && identifier = options.delete(:cms_site)
|
41
|
+
unless @cms_site = Cms::Site.find_by_identifier(identifier)
|
42
|
+
raise ComfortableMexicanSofa::MissingSite.new(identifier)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -55,25 +55,25 @@ module ComfortableMexicanSofa::RenderMethods
|
|
55
55
|
raise ComfortableMexicanSofa::MissingPage.new(path)
|
56
56
|
end
|
57
57
|
|
58
|
-
elsif options.is_a?(Hash) &&
|
58
|
+
elsif options.is_a?(Hash) && identifier = options.delete(:cms_layout)
|
59
59
|
@cms_site ||= Cms::Site.find_site(request.host.downcase, request.fullpath)
|
60
|
-
if @cms_layout = @cms_site && @cms_site.layouts.
|
60
|
+
if @cms_layout = @cms_site && @cms_site.layouts.find_by_identifier(identifier)
|
61
61
|
cms_app_layout = @cms_layout.try(:app_layout)
|
62
62
|
cms_page = @cms_site.pages.build(:layout => @cms_layout)
|
63
63
|
cms_blocks = options.delete(:cms_blocks) || { :content => render_to_string(:layout => false)}
|
64
|
-
cms_blocks.each do |
|
64
|
+
cms_blocks.each do |identifier, value|
|
65
65
|
content = if value.is_a?(Hash)
|
66
66
|
render_to_string(value.keys.first.to_sym => value[value.keys.first], :layout => false)
|
67
67
|
else
|
68
68
|
value.to_s
|
69
69
|
end
|
70
|
-
cms_page.blocks.build(:
|
70
|
+
cms_page.blocks.build(:identifier => identifier.to_s, :content => content)
|
71
71
|
end
|
72
72
|
options[:layout] ||= cms_app_layout.blank?? nil : cms_app_layout
|
73
73
|
options[:inline] = cms_page.content(true)
|
74
74
|
super(options, locals, &block)
|
75
75
|
else
|
76
|
-
raise ComfortableMexicanSofa::MissingLayout.new(
|
76
|
+
raise ComfortableMexicanSofa::MissingLayout.new(identifier)
|
77
77
|
end
|
78
78
|
|
79
79
|
else
|
@@ -11,7 +11,7 @@ module ComfortableMexicanSofa::Tag
|
|
11
11
|
TOKENIZER_REGEX = /(\{\{\s*cms:[^{}]*\}\})|((?:\{?[^{])+|\{+)/
|
12
12
|
|
13
13
|
attr_accessor :page,
|
14
|
-
:
|
14
|
+
:identifier,
|
15
15
|
:params,
|
16
16
|
:parent
|
17
17
|
|
@@ -20,19 +20,19 @@ module ComfortableMexicanSofa::Tag
|
|
20
20
|
# Example:
|
21
21
|
# /\{\{\s*?cms:page:(\w+)\}\}/
|
22
22
|
# will match tags like these:
|
23
|
-
# {{cms:page:
|
24
|
-
def regex_tag_signature(
|
23
|
+
# {{cms:page:my_identifier}}
|
24
|
+
def regex_tag_signature(identifier = nil)
|
25
25
|
nil
|
26
26
|
end
|
27
27
|
|
28
28
|
# Initializing tag object for a particular Tag type
|
29
|
-
# First capture group in the regex is the tag
|
29
|
+
# First capture group in the regex is the tag identifier
|
30
30
|
def initialize_tag(page, tag_signature)
|
31
31
|
if match = tag_signature.match(regex_tag_signature)
|
32
32
|
tag = self.new
|
33
|
-
tag.page
|
34
|
-
tag.
|
35
|
-
tag.params
|
33
|
+
tag.page = page
|
34
|
+
tag.identifier = match[1]
|
35
|
+
tag.params = match[2].to_s.split(':')
|
36
36
|
tag
|
37
37
|
end
|
38
38
|
end
|
@@ -41,8 +41,8 @@ module ComfortableMexicanSofa::Tag
|
|
41
41
|
module InstanceMethods
|
42
42
|
|
43
43
|
# String indentifier of the tag
|
44
|
-
def
|
45
|
-
"#{self.class.to_s.demodulize.underscore}_#{self.
|
44
|
+
def id
|
45
|
+
"#{self.class.to_s.demodulize.underscore}_#{self.identifier}"
|
46
46
|
end
|
47
47
|
|
48
48
|
# Ancestors of this tag constructed during rendering process.
|
@@ -54,9 +54,9 @@ module ComfortableMexicanSofa::Tag
|
|
54
54
|
|
55
55
|
# Regex that is used to identify instance of the tag
|
56
56
|
# Example:
|
57
|
-
# /<\{\s*?cms:page:
|
57
|
+
# /<\{\s*?cms:page:tag_identifier\}/
|
58
58
|
def regex_tag_signature
|
59
|
-
self.class.regex_tag_signature(
|
59
|
+
self.class.regex_tag_signature(identifier)
|
60
60
|
end
|
61
61
|
|
62
62
|
# Content that is accociated with Tag instance.
|
@@ -73,7 +73,8 @@ module ComfortableMexicanSofa::Tag
|
|
73
73
|
|
74
74
|
# Find or initialize Cms::Block object
|
75
75
|
def block
|
76
|
-
page.blocks.detect{|b| b.
|
76
|
+
page.blocks.detect{|b| b.identifier == self.identifier.to_s} ||
|
77
|
+
page.blocks.build(:identifier => self.identifier.to_s)
|
77
78
|
end
|
78
79
|
|
79
80
|
# Checks if this tag is using Cms::Block
|
@@ -105,7 +106,7 @@ private
|
|
105
106
|
if tag_signature
|
106
107
|
if tag = self.initialize_tag(page, tag_signature)
|
107
108
|
tag.parent = parent_tag if parent_tag
|
108
|
-
if tag.ancestors.select{|a| a.
|
109
|
+
if tag.ancestors.select{|a| a.id == tag.id}.blank?
|
109
110
|
page.tags << tag
|
110
111
|
self.process_content(page, tag.render, tag)
|
111
112
|
end
|
@@ -1,23 +1,23 @@
|
|
1
1
|
class ComfortableMexicanSofa::Tag::Asset
|
2
2
|
include ComfortableMexicanSofa::Tag
|
3
3
|
|
4
|
-
def self.regex_tag_signature(
|
5
|
-
|
6
|
-
/\{\{\s*cms:asset:(#{
|
4
|
+
def self.regex_tag_signature(identifier = nil)
|
5
|
+
identifier ||= /[\w\-]+/
|
6
|
+
/\{\{\s*cms:asset:(#{identifier}):?(.*?)\s*\}\}/
|
7
7
|
end
|
8
8
|
|
9
9
|
def content
|
10
|
-
return unless (layout = Cms::Layout.
|
10
|
+
return unless (layout = Cms::Layout.find_by_identifier(identifier))
|
11
11
|
type = params[0]
|
12
12
|
format = params[1]
|
13
13
|
|
14
14
|
case type
|
15
15
|
when 'css'
|
16
|
-
out = "/cms-css/#{page.site.id}/#{
|
16
|
+
out = "/cms-css/#{page.site.id}/#{identifier}.css"
|
17
17
|
out = "<link href='#{out}' media='screen' rel='stylesheet' type='text/css' />" if format == 'html_tag'
|
18
18
|
out
|
19
19
|
when 'js'
|
20
|
-
out = "/cms-js/#{page.site.id}/#{
|
20
|
+
out = "/cms-js/#{page.site.id}/#{identifier}.js"
|
21
21
|
out = "<script src='#{out}' type='text/javascript'></script>" if format == 'html_tag'
|
22
22
|
out
|
23
23
|
end
|
@@ -7,9 +7,9 @@ class ComfortableMexicanSofa::Tag::Collection
|
|
7
7
|
# {{ cms:collection:album:foo/my_album }}
|
8
8
|
# A more complete example of the above:
|
9
9
|
# {{ cms:collection:album:foo/my_album:albums/show:title:slug:param_a:param_b }}
|
10
|
-
def self.regex_tag_signature(
|
11
|
-
|
12
|
-
/\{\{\s*cms:collection:(#{
|
10
|
+
def self.regex_tag_signature(identifier = nil)
|
11
|
+
identifier ||= /[\w\/\-]+/
|
12
|
+
/\{\{\s*cms:collection:(#{identifier}):(.*?)\s*\}\}/
|
13
13
|
end
|
14
14
|
|
15
15
|
# Class definitition. It's basically `Herp::DerpityDerp.undescore` so an example
|
@@ -1,9 +1,9 @@
|
|
1
1
|
class ComfortableMexicanSofa::Tag::FieldDateTime
|
2
2
|
include ComfortableMexicanSofa::Tag
|
3
3
|
|
4
|
-
def self.regex_tag_signature(
|
5
|
-
|
6
|
-
/\{\{\s*cms:field:(#{
|
4
|
+
def self.regex_tag_signature(identifier = nil)
|
5
|
+
identifier ||= /[\w\-]+/
|
6
|
+
/\{\{\s*cms:field:(#{identifier}):datetime\s*\}\}/
|
7
7
|
end
|
8
8
|
|
9
9
|
def content
|
@@ -1,9 +1,9 @@
|
|
1
1
|
class ComfortableMexicanSofa::Tag::FieldInteger
|
2
2
|
include ComfortableMexicanSofa::Tag
|
3
3
|
|
4
|
-
def self.regex_tag_signature(
|
5
|
-
|
6
|
-
/\{\{\s*cms:field:(#{
|
4
|
+
def self.regex_tag_signature(identifier = nil)
|
5
|
+
identifier ||= /[\w\-]+/
|
6
|
+
/\{\{\s*cms:field:(#{identifier}):integer\s*\}\}/
|
7
7
|
end
|
8
8
|
|
9
9
|
def content
|
@@ -1,9 +1,9 @@
|
|
1
1
|
class ComfortableMexicanSofa::Tag::FieldString
|
2
2
|
include ComfortableMexicanSofa::Tag
|
3
3
|
|
4
|
-
def self.regex_tag_signature(
|
5
|
-
|
6
|
-
/\{\{\s*cms:field:(#{
|
4
|
+
def self.regex_tag_signature(identifier = nil)
|
5
|
+
identifier ||= /[\w\-]+/
|
6
|
+
/\{\{\s*cms:field:(#{identifier}):?(?:string)?\s*\}\}/
|
7
7
|
end
|
8
8
|
|
9
9
|
def content
|
@@ -1,9 +1,9 @@
|
|
1
1
|
class ComfortableMexicanSofa::Tag::FieldText
|
2
2
|
include ComfortableMexicanSofa::Tag
|
3
3
|
|
4
|
-
def self.regex_tag_signature(
|
5
|
-
|
6
|
-
/\{\{\s*cms:field:(#{
|
4
|
+
def self.regex_tag_signature(identifier = nil)
|
5
|
+
identifier ||= /[\w\-]+/
|
6
|
+
/\{\{\s*cms:field:(#{identifier}):?(?:text)?\s*?\}\}/
|
7
7
|
end
|
8
8
|
|
9
9
|
def content
|