comfortable_mexican_sofa 1.9.2 → 1.9.3
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +2 -2
- data/app/assets/javascripts/comfortable_mexican_sofa/application.js.coffee +5 -0
- data/app/assets/stylesheets/comfortable_mexican_sofa/base.css.sass +11 -0
- data/app/controllers/cms_admin/pages_controller.rb +1 -1
- data/app/models/cms/block.rb +1 -4
- data/app/models/cms/categorization.rb +1 -4
- data/app/models/cms/category.rb +1 -4
- data/app/models/cms/file.rb +2 -5
- data/app/models/cms/layout.rb +2 -5
- data/app/models/cms/page.rb +34 -25
- data/app/models/cms/revision.rb +1 -4
- data/app/models/cms/site.rb +1 -4
- data/app/models/cms/snippet.rb +2 -8
- data/app/models/concerns/cms/base.rb +17 -0
- data/app/views/cms_admin/files/_file.html.haml +1 -1
- data/app/views/cms_admin/files/_form.html.haml +4 -0
- data/app/views/cms_admin/files/index.html.haml +5 -0
- data/app/views/cms_admin/layouts/_form.html.haml +4 -0
- data/app/views/cms_admin/layouts/index.html.haml +4 -0
- data/app/views/cms_admin/pages/_form.html.haml +5 -1
- data/app/views/cms_admin/pages/index.html.haml +4 -0
- data/app/views/cms_admin/partials/_body_before.html.haml +3 -0
- data/app/views/cms_admin/partials/_file_form_after.html.haml +3 -0
- data/app/views/cms_admin/partials/_file_form_before.html.haml +3 -0
- data/app/views/cms_admin/partials/_files_after.html.haml +3 -0
- data/app/views/cms_admin/partials/_files_before.html.haml +3 -0
- data/app/views/cms_admin/partials/_html_footer.html.haml +2 -0
- data/app/views/cms_admin/partials/_html_head.html.haml +2 -0
- data/app/views/cms_admin/partials/_layout_form_after.html.haml +3 -0
- data/app/views/cms_admin/partials/_layout_form_before.html.haml +3 -0
- data/app/views/cms_admin/partials/_layouts_after.html.haml +3 -0
- data/app/views/cms_admin/partials/_layouts_before.html.haml +3 -0
- data/app/views/cms_admin/partials/_navigation_after.html.haml +3 -0
- data/app/views/cms_admin/partials/_navigation_before.html.haml +3 -0
- data/app/views/cms_admin/partials/_navigation_inner.html.haml +3 -0
- data/app/views/cms_admin/partials/_page_form_after.html.haml +3 -0
- data/app/views/cms_admin/partials/_page_form_before.html.haml +3 -0
- data/app/views/cms_admin/partials/_page_form_inner.html.haml +3 -0
- data/app/views/cms_admin/partials/_pages_after.html.haml +3 -0
- data/app/views/cms_admin/partials/_pages_before.html.haml +3 -0
- data/app/views/cms_admin/partials/_right_column_after.html.haml +3 -0
- data/app/views/cms_admin/partials/_right_column_before.html.haml +3 -0
- data/app/views/cms_admin/partials/_site_form_after.html.haml +3 -0
- data/app/views/cms_admin/partials/_site_form_before.html.haml +3 -0
- data/app/views/cms_admin/partials/_sites_after.html.haml +3 -0
- data/app/views/cms_admin/partials/_sites_before.html.haml +3 -0
- data/app/views/cms_admin/partials/_snippet_form_after.html.haml +3 -0
- data/app/views/cms_admin/partials/_snippet_form_before.html.haml +3 -0
- data/app/views/cms_admin/partials/_snippets_after.html.haml +3 -0
- data/app/views/cms_admin/partials/_snippets_before.html.haml +3 -0
- data/app/views/cms_admin/sites/_form.html.haml +4 -0
- data/app/views/cms_admin/sites/index.html.haml +5 -1
- data/app/views/cms_admin/snippets/_form.html.haml +5 -1
- data/app/views/cms_admin/snippets/index.html.haml +4 -0
- data/app/views/layouts/cms_admin/_body.html.haml +2 -1
- data/app/views/layouts/cms_admin/_footer_js.html.haml +2 -0
- data/app/views/layouts/cms_admin/_head.html.haml +2 -1
- data/app/views/layouts/cms_admin/_left.html.haml +6 -0
- data/app/views/layouts/cms_admin/_right.html.haml +5 -1
- data/comfortable_mexican_sofa.gemspec +1 -0
- data/config/initializers/comfortable_mexican_sofa.rb +4 -7
- data/lib/comfortable_mexican_sofa.rb +0 -7
- data/lib/comfortable_mexican_sofa/configuration.rb +5 -0
- data/lib/comfortable_mexican_sofa/fixture/page.rb +2 -6
- data/lib/comfortable_mexican_sofa/render_methods.rb +3 -1
- data/lib/comfortable_mexican_sofa/version.rb +1 -1
- data/test/controllers/cms_content_controller_test.rb +1 -1
- data/test/integration/fixtures_test.rb +1 -1
- data/test/integration/render_cms_test.rb +12 -3
- data/test/models/cms/page_test.rb +11 -11
- data/test/models/fixtures/pages_test.rb +1 -2
- data/test/models/tag_test.rb +8 -7
- data/test/test_helper.rb +8 -0
- metadata +34 -3
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2010-
|
1
|
+
Copyright (c) 2010-2013 Oleg Khabarov, The Working Group Inc
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
a copy of this software and associated documentation files (the
|
@@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
17
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
18
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
19
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -26,6 +26,7 @@ window.CMS =
|
|
26
26
|
CMS.page_update_publish()
|
27
27
|
CMS.categories()
|
28
28
|
CMS.uploader()
|
29
|
+
CMS.uploaded_files()
|
29
30
|
|
30
31
|
|
31
32
|
window.CMS.slugify = ->
|
@@ -154,3 +155,7 @@ window.CMS.uploader = ->
|
|
154
155
|
$('.uploaded-files').prepend(files)
|
155
156
|
files.map ->
|
156
157
|
$(this).fadeIn()
|
158
|
+
|
159
|
+
window.CMS.uploaded_files = ->
|
160
|
+
$('.uploaded-files').on 'click', 'input', ->
|
161
|
+
$(this).select()
|
@@ -128,6 +128,9 @@ body#comfy
|
|
128
128
|
margin: 0
|
129
129
|
font-size: 11px
|
130
130
|
width: 100%
|
131
|
+
line-height: 12px
|
132
|
+
&:hover
|
133
|
+
cursor: default
|
131
134
|
iframe#file-upload-frame
|
132
135
|
display: none
|
133
136
|
|
@@ -164,6 +167,14 @@ body#comfy
|
|
164
167
|
.item-meta
|
165
168
|
font-size: 11px
|
166
169
|
line-height: 14px
|
170
|
+
|
171
|
+
.cms-partial
|
172
|
+
background-color: #252525
|
173
|
+
color: #ccc
|
174
|
+
outline: 1px dotted #666
|
175
|
+
font-size: 9px
|
176
|
+
padding: 0 5px
|
177
|
+
margin: 2px
|
167
178
|
|
168
179
|
// -- Sofa Version --------------------------------------------------------
|
169
180
|
.center-column .body-footer
|
@@ -106,7 +106,7 @@ protected
|
|
106
106
|
@cms_site = @page.site
|
107
107
|
@cms_layout = @page.layout
|
108
108
|
@cms_page = @page
|
109
|
-
render :inline => @page.
|
109
|
+
render :inline => @page.render, :layout => layout, :content_type => 'text/html'
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
data/app/models/cms/block.rb
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
class Cms::Categorization < ActiveRecord::Base
|
2
|
-
|
3
|
-
ComfortableMexicanSofa.establish_connection(self)
|
4
|
-
|
5
|
-
self.table_name = 'cms_categorizations'
|
2
|
+
include Cms::Base
|
6
3
|
|
7
4
|
# -- Relationships --------------------------------------------------------
|
8
5
|
belongs_to :category
|
data/app/models/cms/category.rb
CHANGED
data/app/models/cms/file.rb
CHANGED
@@ -1,11 +1,8 @@
|
|
1
1
|
class Cms::File < ActiveRecord::Base
|
2
|
+
include Cms::Base
|
2
3
|
|
3
4
|
IMAGE_MIMETYPES = %w(gif jpeg pjpeg png svg+xml tiff).collect{|subtype| "image/#{subtype}"}
|
4
5
|
|
5
|
-
ComfortableMexicanSofa.establish_connection(self)
|
6
|
-
|
7
|
-
self.table_name = 'cms_files'
|
8
|
-
|
9
6
|
cms_is_categorized
|
10
7
|
|
11
8
|
attr_accessor :dimensions
|
@@ -64,7 +61,7 @@ protected
|
|
64
61
|
def reload_page_cache
|
65
62
|
return unless self.block
|
66
63
|
p = self.block.page
|
67
|
-
Cms::Page.where(:id => p.id).update_all(:content =>
|
64
|
+
Cms::Page.where(:id => p.id).update_all(:content => nil)
|
68
65
|
end
|
69
66
|
|
70
67
|
end
|
data/app/models/cms/layout.rb
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
class Cms::Layout < ActiveRecord::Base
|
2
|
-
|
3
|
-
ComfortableMexicanSofa.establish_connection(self)
|
4
|
-
|
5
|
-
self.table_name = 'cms_layouts'
|
2
|
+
include Cms::Base
|
6
3
|
|
7
4
|
cms_acts_as_tree
|
8
5
|
cms_is_mirrored
|
@@ -84,7 +81,7 @@ protected
|
|
84
81
|
|
85
82
|
# Forcing page content reload
|
86
83
|
def clear_cached_page_content
|
87
|
-
self.pages.each{ |page| page.
|
84
|
+
self.pages.each{ |page| page.clear_cached_content! }
|
88
85
|
self.children.each{ |child_layout| child_layout.clear_cached_page_content }
|
89
86
|
end
|
90
87
|
|
data/app/models/cms/page.rb
CHANGED
@@ -1,10 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
class Cms::Page < ActiveRecord::Base
|
4
|
-
|
5
|
-
ComfortableMexicanSofa.establish_connection(self)
|
6
|
-
|
7
|
-
self.table_name = 'cms_pages'
|
4
|
+
include Cms::Base
|
8
5
|
|
9
6
|
cms_acts_as_tree :counter_cache => :children_count
|
10
7
|
cms_is_categorized
|
@@ -12,6 +9,7 @@ class Cms::Page < ActiveRecord::Base
|
|
12
9
|
cms_has_revisions_for :blocks_attributes
|
13
10
|
|
14
11
|
attr_accessor :tags,
|
12
|
+
:cached_content,
|
15
13
|
:blocks_attributes_changed
|
16
14
|
|
17
15
|
# -- Relationships --------------------------------------------------------
|
@@ -30,7 +28,7 @@ class Cms::Page < ActiveRecord::Base
|
|
30
28
|
:assign_full_path
|
31
29
|
before_create :assign_position
|
32
30
|
before_save :set_cached_content
|
33
|
-
after_save :
|
31
|
+
after_save :sync_child_full_paths!
|
34
32
|
after_find :unescape_slug_and_path
|
35
33
|
|
36
34
|
# -- Validations ----------------------------------------------------------
|
@@ -59,8 +57,8 @@ class Cms::Page < ActiveRecord::Base
|
|
59
57
|
out << [ "#{spacer*depth}#{current_page.label}", current_page.id ] unless current_page == page
|
60
58
|
current_page.children.each do |child|
|
61
59
|
out += options_for_select(site, page, child, depth + 1, exclude_self, spacer)
|
62
|
-
end
|
63
|
-
return out.compact
|
60
|
+
end if current_page.children_count.nonzero?
|
61
|
+
return out.compact
|
64
62
|
end
|
65
63
|
|
66
64
|
# -- Instance Methods -----------------------------------------------------
|
@@ -100,31 +98,38 @@ class Cms::Page < ActiveRecord::Base
|
|
100
98
|
|
101
99
|
# Processing content will return rendered content and will populate
|
102
100
|
# self.cms_tags with instances of CmsTag
|
103
|
-
def
|
104
|
-
@
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
101
|
+
def render
|
102
|
+
@tags = [] # resetting
|
103
|
+
return '' unless layout
|
104
|
+
|
105
|
+
ComfortableMexicanSofa::Tag.process_content(
|
106
|
+
self, ComfortableMexicanSofa::Tag.sanitize_irb(layout.merged_content)
|
107
|
+
)
|
108
|
+
end
|
109
|
+
|
110
|
+
# Cached content accessor
|
111
|
+
def content
|
112
|
+
if (@cached_content = read_attribute(:content)).nil?
|
113
|
+
@cached_content = self.render
|
114
|
+
update_column(:content, @cached_content) unless self.new_record?
|
115
115
|
end
|
116
|
+
@cached_content
|
117
|
+
end
|
118
|
+
|
119
|
+
def clear_cached_content!
|
120
|
+
self.update_column(:content, nil)
|
116
121
|
end
|
117
122
|
|
118
123
|
# Array of cms_tags for a page. Content generation is called if forced.
|
119
124
|
# These also include initialized cms_blocks if present
|
120
125
|
def tags(force_reload = false)
|
121
|
-
self.
|
126
|
+
self.render if force_reload
|
122
127
|
@tags ||= []
|
123
128
|
end
|
124
129
|
|
125
130
|
# Full url for a page
|
126
131
|
def url
|
127
|
-
"
|
132
|
+
"//" + "#{self.site.hostname}/#{self.site.path}/#{self.full_path}".squeeze("/")
|
128
133
|
end
|
129
134
|
|
130
135
|
# Method to collect prevous state of blocks for revisions
|
@@ -168,14 +173,18 @@ protected
|
|
168
173
|
errors.add(:slug, :invalid) unless unescaped_slug =~ /^\p{Alnum}[\.\p{Alnum}\p{Mark}_-]*$/i
|
169
174
|
end
|
170
175
|
|
171
|
-
# NOTE: This can create 'phantom' page blocks as they are defined in the layout. This is normal.
|
172
176
|
def set_cached_content
|
173
|
-
|
177
|
+
@cached_content = self.render
|
178
|
+
write_attribute(:content, self.cached_content)
|
174
179
|
end
|
175
180
|
|
176
181
|
# Forcing re-saves for child pages so they can update full_paths
|
177
|
-
def
|
178
|
-
|
182
|
+
def sync_child_full_paths!
|
183
|
+
return unless full_path_changed?
|
184
|
+
children.each do |p|
|
185
|
+
p.update_column(:full_path, p.send(:assign_full_path))
|
186
|
+
p.send(:sync_child_full_paths!)
|
187
|
+
end
|
179
188
|
end
|
180
189
|
|
181
190
|
# Escape slug unless it's nonexistent (root)
|
data/app/models/cms/revision.rb
CHANGED
data/app/models/cms/site.rb
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
class Cms::Site < ActiveRecord::Base
|
2
|
-
|
3
|
-
ComfortableMexicanSofa.establish_connection(self)
|
4
|
-
|
5
|
-
self.table_name = 'cms_sites'
|
2
|
+
include Cms::Base
|
6
3
|
|
7
4
|
# -- Relationships --------------------------------------------------------
|
8
5
|
with_options :dependent => :destroy do |site|
|
data/app/models/cms/snippet.rb
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
class Cms::Snippet < ActiveRecord::Base
|
2
|
-
|
3
|
-
ComfortableMexicanSofa.establish_connection(self)
|
4
|
-
|
5
|
-
self.table_name = 'cms_snippets'
|
2
|
+
include Cms::Base
|
6
3
|
|
7
4
|
cms_is_categorized
|
8
5
|
cms_is_mirrored
|
@@ -36,12 +33,9 @@ protected
|
|
36
33
|
self.label = self.label.blank?? self.identifier.try(:titleize) : self.label
|
37
34
|
end
|
38
35
|
|
39
|
-
# Note: This might be slow. We have no idea where the snippet is used, so
|
40
|
-
# gotta reload every single page. Kinda sucks, but might be ok unless there
|
41
|
-
# are hundreds of pages.
|
42
36
|
def clear_cached_page_content
|
43
37
|
site.pages.each do |p|
|
44
|
-
Cms::Page.where(:id => p.id).update_all(:content =>
|
38
|
+
Cms::Page.where(:id => p.id).update_all(:content => nil)
|
45
39
|
end
|
46
40
|
end
|
47
41
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Cms::Base
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
# Establishing database connection if custom one is defined
|
6
|
+
if ComfortableMexicanSofa.config.database_config && !Rails.env.test?
|
7
|
+
establish_connection "#{ComfortableMexicanSofa.config.database_config}_#{Rails.env}"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module ClassMethods
|
12
|
+
def table_name_prefix
|
13
|
+
'cms_'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -8,6 +8,6 @@
|
|
8
8
|
.thumb
|
9
9
|
= image_tag file.file.url(:cms_thumb) if file.is_image?
|
10
10
|
.details
|
11
|
-
%input{:type => 'text', :value => file.file.url}
|
11
|
+
%input{:type => 'text', :value => file.file.url, :readonly => 'readonly'}
|
12
12
|
.file-type= file.file_content_type
|
13
13
|
.file-size= number_to_human_size(file.file_file_size, :locale => :en)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
= render 'cms_admin/partials/file_form_before', :object => form
|
2
|
+
|
1
3
|
= form.text_field :label
|
2
4
|
= form.file_field :file, :multiple => @file.new_record?
|
3
5
|
|
@@ -10,5 +12,7 @@
|
|
10
12
|
|
11
13
|
= render :partial => 'cms_admin/categories/form', :object => form
|
12
14
|
|
15
|
+
= render 'cms_admin/partials/file_form_after', :object => form
|
16
|
+
|
13
17
|
.form-actions
|
14
18
|
= form.submit t(@file.new_record?? '.create' : '.update'), :class => 'btn btn-primary'
|
@@ -1,6 +1,8 @@
|
|
1
1
|
.page-header
|
2
2
|
= link_to t('.new_link'), new_cms_admin_site_file_path(@site), :class => 'btn pull-right'
|
3
3
|
%h2= t('.title')
|
4
|
+
|
5
|
+
= render 'cms_admin/partials/files_before'
|
4
6
|
|
5
7
|
= render :partial => 'cms_admin/categories/index', :object => 'Cms::File'
|
6
8
|
|
@@ -26,3 +28,6 @@
|
|
26
28
|
.btn-group
|
27
29
|
= link_to t('.edit'), edit_cms_admin_site_file_path(@site, file), :class => 'btn btn-small'
|
28
30
|
= link_to t('.delete'), cms_admin_site_file_path(@site, file), :method => :delete, :data => {:confirm => t('.are_you_sure')}, :class => 'btn btn-small btn-danger'
|
31
|
+
|
32
|
+
|
33
|
+
= render 'cms_admin/partials/files_after'
|
@@ -1,5 +1,7 @@
|
|
1
1
|
- content_for :right_column do
|
2
2
|
= render :partial => 'cms_admin/files/index'
|
3
|
+
|
4
|
+
= render 'cms_admin/partials/layout_form_before', :object => form
|
3
5
|
|
4
6
|
= form.text_field :label, :data => {:slugify => @layout.new_record?}
|
5
7
|
= form.text_field :identifier, :data => {:slug => true}
|
@@ -13,5 +15,7 @@
|
|
13
15
|
= form.text_area :css, :data => {:cm_mode => 'css'}
|
14
16
|
= form.text_area :js, :data => {:cm_mode => 'javascript'}
|
15
17
|
|
18
|
+
= render 'cms_admin/partials/layout_form_after', :object => form
|
19
|
+
|
16
20
|
.form-actions
|
17
21
|
= form.submit t(@layout.new_record?? '.create' : '.update'), :class => 'btn btn-primary'
|
@@ -5,5 +5,9 @@
|
|
5
5
|
- content_for :right_column do
|
6
6
|
= render :partial => 'cms_admin/sites/mirrors'
|
7
7
|
|
8
|
+
= render 'cms_admin/partials/layouts_before'
|
9
|
+
|
8
10
|
%ul.list.sortable
|
9
11
|
= render :partial => 'index_branch', :collection => @layouts
|
12
|
+
|
13
|
+
= render 'cms_admin/partials/layouts_after'
|
@@ -6,6 +6,8 @@
|
|
6
6
|
%button.btn.btn-small.btn-primary.pull-right
|
7
7
|
= render :partial => 'cms_admin/files/index'
|
8
8
|
|
9
|
+
= render 'cms_admin/partials/page_form_before', :object => form
|
10
|
+
|
9
11
|
= form.text_field :label, :data => {:slugify => @page.new_record?}
|
10
12
|
|
11
13
|
- unless @site.pages.count == 0 || @site.pages.root == @page
|
@@ -22,7 +24,7 @@
|
|
22
24
|
- if (options = Cms::Page.options_for_select(@site, @page, nil, 0, false)).present?
|
23
25
|
= form.select :target_page_id, [["---- #{t('.select_target_page')} ----", nil]] + options
|
24
26
|
|
25
|
-
=
|
27
|
+
= render 'cms_admin/partials/page_form_inner', :object => form
|
26
28
|
|
27
29
|
= render :partial => 'cms_admin/categories/form', :object => form
|
28
30
|
|
@@ -30,6 +32,8 @@
|
|
30
32
|
|
31
33
|
= form.check_box :is_published, :label => t('.is_published')
|
32
34
|
|
35
|
+
= render 'cms_admin/partials/page_form_after', :object => form
|
36
|
+
|
33
37
|
.form-actions
|
34
38
|
= form.submit t('.preview'), :name => 'preview', :id => nil, :class => 'btn'
|
35
39
|
= form.submit t(@page.new_record?? '.create' : '.update'), :class => 'btn btn-primary'
|
@@ -5,7 +5,11 @@
|
|
5
5
|
- content_for :right_column do
|
6
6
|
= render :partial => 'cms_admin/sites/mirrors'
|
7
7
|
|
8
|
+
= render 'cms_admin/partials/pages_before'
|
9
|
+
|
8
10
|
= render :partial => 'cms_admin/categories/index', :object => 'Cms::Page'
|
9
11
|
|
10
12
|
%ul.list.sortable
|
11
13
|
= render :partial => 'index_branch', :collection => @pages
|
14
|
+
|
15
|
+
= render 'cms_admin/partials/pages_after'
|
@@ -1,3 +1,5 @@
|
|
1
|
+
= render 'cms_admin/partials/site_form_before', :object => form
|
2
|
+
|
1
3
|
= form.text_field :label, :data => {:slugify => @site.new_record?}
|
2
4
|
= form.text_field :identifier, :data => {:slug => true}
|
3
5
|
= form.text_field :hostname
|
@@ -5,6 +7,8 @@
|
|
5
7
|
= form.select :locale, ComfortableMexicanSofa.config.locales.to_a.collect{|l| [l[1], l[0]]}
|
6
8
|
= form.check_box :is_mirrored, :label => t('.is_mirrored')
|
7
9
|
|
10
|
+
= render 'cms_admin/partials/site_form_after', :object => form
|
11
|
+
|
8
12
|
.form-actions
|
9
13
|
= form.submit t(@site.new_record?? '.create' : '.update'), :class => 'btn btn-primary'
|
10
14
|
|
@@ -2,6 +2,8 @@
|
|
2
2
|
= link_to t('.new_link'), new_cms_admin_site_path, :class => 'btn pull-right'
|
3
3
|
%h2= t('.title')
|
4
4
|
|
5
|
+
= render 'cms_admin/partials/sites_before'
|
6
|
+
|
5
7
|
%table.table.table-hover.table-bordered
|
6
8
|
- @sites.each do |site|
|
7
9
|
%tr
|
@@ -21,4 +23,6 @@
|
|
21
23
|
.btn-group
|
22
24
|
= link_to t('.select'), cms_admin_site_pages_path(site), :class => 'btn btn-small'
|
23
25
|
= link_to t('.edit'), edit_cms_admin_site_path(site), :class => 'btn btn-small'
|
24
|
-
= link_to t('.delete'), cms_admin_site_path(site), :method => :delete, :data => {:confirm => t('.are_you_sure')}, :class => 'btn btn-small btn-danger'
|
26
|
+
= link_to t('.delete'), cms_admin_site_path(site), :method => :delete, :data => {:confirm => t('.are_you_sure')}, :class => 'btn btn-small btn-danger'
|
27
|
+
|
28
|
+
= render 'cms_admin/partials/sites_after'
|
@@ -1,11 +1,15 @@
|
|
1
1
|
- content_for :right_column do
|
2
2
|
= render :partial => 'cms_admin/files/index'
|
3
3
|
|
4
|
+
= render 'cms_admin/partials/snippet_form_before', :object => form
|
5
|
+
|
4
6
|
= form.text_field :label, :data => {:slugify => @snippet.new_record?}
|
5
7
|
= form.text_field :identifier, :data => {:slug => true}
|
6
8
|
= form.text_area :content, :data => {:cm_mode => 'text/html'}
|
7
9
|
|
8
10
|
= render :partial => 'cms_admin/categories/form', :object => form
|
9
11
|
|
12
|
+
= render 'cms_admin/partials/snippet_form_after', :object => form
|
13
|
+
|
10
14
|
.form-actions
|
11
|
-
= form.submit t(@snippet.new_record?? '.create' : '.update'), :class => 'btn btn-primary'
|
15
|
+
= form.submit t(@snippet.new_record?? '.create' : '.update'), :class => 'btn btn-primary'
|
@@ -5,6 +5,8 @@
|
|
5
5
|
- content_for :right_column do
|
6
6
|
= render :partial => 'cms_admin/sites/mirrors'
|
7
7
|
|
8
|
+
= render 'cms_admin/partials/snippets_before'
|
9
|
+
|
8
10
|
= render :partial => 'cms_admin/categories/index', :object => 'Cms::Snippet'
|
9
11
|
|
10
12
|
%table.table.table-hover.table-bordered
|
@@ -26,3 +28,5 @@
|
|
26
28
|
.btn-group
|
27
29
|
= link_to t('.edit'), edit_cms_admin_site_snippet_path(@site, snippet), :class => 'btn btn-small'
|
28
30
|
= link_to t('.delete'), cms_admin_site_snippet_path(@site, snippet), :method => :delete, :data => {:confirm => t('.are_you_sure')}, :class => 'btn btn-small btn-danger'
|
31
|
+
|
32
|
+
= render 'cms_admin/partials/snippets_after'
|
@@ -1,3 +1,5 @@
|
|
1
|
+
= render '/cms_admin/partials/navigation_before'
|
2
|
+
|
1
3
|
%ul.navigation
|
2
4
|
%li= active_link_to t('cms_admin.base.sites'), cms_admin_sites_path, :active => ['cms_admin/sites']
|
3
5
|
|
@@ -8,3 +10,7 @@
|
|
8
10
|
%li= active_link_to t('cms_admin.base.files'), cms_admin_site_files_path(@site)
|
9
11
|
|
10
12
|
= cms_hook :navigation
|
13
|
+
|
14
|
+
= render '/cms_admin/partials/navigation_inner'
|
15
|
+
|
16
|
+
= render '/cms_admin/partials/navigation_after'
|
@@ -11,6 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.homepage = "http://github.com/comfy/comfortable-mexican-sofa"
|
12
12
|
s.summary = "CMS Engine for Rails 4 apps"
|
13
13
|
s.description = "ComfortableMexicanSofa is a powerful CMS Engine for Ruby on Rails applications"
|
14
|
+
s.license = 'MIT'
|
14
15
|
|
15
16
|
s.files = `git ls-files`.split("\n")
|
16
17
|
s.platform = Gem::Platform::RUBY
|
@@ -87,6 +87,10 @@ ComfortableMexicanSofa.configure do |config|
|
|
87
87
|
# e.g. config.hostname_aliases = {'host.com' => 'host.inv', 'host_a.com' => ['host.lvh.me', 'host.dev']}
|
88
88
|
# Default is nil (not used)
|
89
89
|
# config.hostname_aliases = nil
|
90
|
+
|
91
|
+
# Reveal partials that can be overwritten in the admin area.
|
92
|
+
# Default is false.
|
93
|
+
# config.reveal_cms_partials = false
|
90
94
|
|
91
95
|
end
|
92
96
|
|
@@ -94,10 +98,3 @@ end
|
|
94
98
|
# YOU REALLY WANT TO CHANGE THIS BEFORE PUTTING YOUR SITE LIVE
|
95
99
|
ComfortableMexicanSofa::HttpAuth.username = 'username'
|
96
100
|
ComfortableMexicanSofa::HttpAuth.password = 'password'
|
97
|
-
|
98
|
-
# If you need to inject some html in cms admin views you can define what partial
|
99
|
-
# should be rendered into the following areas:
|
100
|
-
# ComfortableMexicanSofa::ViewHooks.add(:header, '/layouts/admin/header')
|
101
|
-
# ComfortableMexicanSofa::ViewHooks.add(:navigation, '/layouts/admin/navigation')
|
102
|
-
# ComfortableMexicanSofa::ViewHooks.add(:html_head, '/layouts/admin/html_head')
|
103
|
-
# ComfortableMexicanSofa::ViewHooks.add(:page_form, '/layouts/admin/page_form')
|
@@ -47,13 +47,6 @@ module ComfortableMexicanSofa
|
|
47
47
|
@configuration ||= Configuration.new
|
48
48
|
end
|
49
49
|
alias :config :configuration
|
50
|
-
|
51
|
-
# Establishing database connection if custom one is defined
|
52
|
-
def establish_connection(klass)
|
53
|
-
if ComfortableMexicanSofa.config.database_config && !Rails.env.test?
|
54
|
-
klass.establish_connection "#{ComfortableMexicanSofa.config.database_config}_#{Rails.env}"
|
55
|
-
end
|
56
|
-
end
|
57
50
|
|
58
51
|
def logger=(new_logger)
|
59
52
|
@logger = new_logger
|
@@ -71,6 +71,10 @@ class ComfortableMexicanSofa::Configuration
|
|
71
71
|
# Default is nil (not used)
|
72
72
|
attr_accessor :hostname_aliases
|
73
73
|
|
74
|
+
# Reveal partials that can be overwritten in the admin area.
|
75
|
+
# Default is false.
|
76
|
+
attr_accessor :reveal_cms_partials
|
77
|
+
|
74
78
|
# Configuration defaults
|
75
79
|
def initialize
|
76
80
|
@cms_title = 'ComfortableMexicanSofa CMS Engine'
|
@@ -103,6 +107,7 @@ class ComfortableMexicanSofa::Configuration
|
|
103
107
|
@allowed_helpers = nil
|
104
108
|
@allowed_partials = nil
|
105
109
|
@hostname_aliases = nil
|
110
|
+
@reveal_cms_partials = false
|
106
111
|
end
|
107
112
|
|
108
113
|
end
|
@@ -47,12 +47,8 @@ module ComfortableMexicanSofa::Fixture::Page
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
:identifier => identifier,
|
53
|
-
:content => nil
|
54
|
-
}
|
55
|
-
end
|
50
|
+
# deleting removed blocks
|
51
|
+
page.blocks.where(:identifier => blocks_to_clear).destroy_all
|
56
52
|
|
57
53
|
page.blocks_attributes = blocks_attributes if blocks_attributes.present?
|
58
54
|
|
@@ -44,6 +44,8 @@ module ComfortableMexicanSofa::RenderMethods
|
|
44
44
|
|
45
45
|
if options.is_a?(Hash) && path = options.delete(:cms_page)
|
46
46
|
@cms_site ||= Cms::Site.find_site(request.host.downcase, request.fullpath)
|
47
|
+
path.gsub!(/^\/#{@cms_site.path}/, '') if @cms_site && @cms_site.path.present?
|
48
|
+
|
47
49
|
if @cms_page = @cms_site && @cms_site.pages.find_by_full_path(path)
|
48
50
|
@cms_layout = @cms_page.layout
|
49
51
|
cms_app_layout = @cms_layout.try(:app_layout)
|
@@ -69,7 +71,7 @@ module ComfortableMexicanSofa::RenderMethods
|
|
69
71
|
cms_page.blocks.build(:identifier => identifier.to_s, :content => content)
|
70
72
|
end
|
71
73
|
options[:layout] ||= cms_app_layout.blank?? nil : cms_app_layout
|
72
|
-
options[:inline] = cms_page.content
|
74
|
+
options[:inline] = cms_page.content
|
73
75
|
super(options, locals, &block)
|
74
76
|
else
|
75
77
|
raise ComfortableMexicanSofa::MissingLayout.new(identifier)
|
@@ -85,7 +85,7 @@ class CmsContentControllerTest < ActionController::TestCase
|
|
85
85
|
assert_equal cms_pages(:default), cms_pages(:child).target_page
|
86
86
|
get :render_html, :cms_path => 'child-page'
|
87
87
|
assert_response :redirect
|
88
|
-
assert_redirected_to
|
88
|
+
assert_redirected_to cms_pages(:default).url
|
89
89
|
end
|
90
90
|
|
91
91
|
def test_render_page_unpublished
|
@@ -30,7 +30,7 @@ class FixturesIntergrationTest < ActionDispatch::IntegrationTest
|
|
30
30
|
assert_difference 'Cms::Snippet.count', 1 do
|
31
31
|
get '/'
|
32
32
|
assert_response :redirect
|
33
|
-
assert_redirected_to '
|
33
|
+
assert_redirected_to '//test.host/child'
|
34
34
|
follow_redirect!
|
35
35
|
|
36
36
|
assert_equal 'Home Fixture Page', Cms::Page.root.label
|
@@ -5,9 +5,10 @@ class RenderCmsIntergrationTest < ActionDispatch::IntegrationTest
|
|
5
5
|
def setup
|
6
6
|
super
|
7
7
|
Rails.application.routes.draw do
|
8
|
-
get '/render-basic'
|
9
|
-
get '/render-page'
|
10
|
-
get '/render-
|
8
|
+
get '/render-basic' => 'render_test#render_basic'
|
9
|
+
get '/render-page' => 'render_test#render_page'
|
10
|
+
get '/site-path/render-page' => 'render_test#render_page'
|
11
|
+
get '/render-layout' => 'render_test#render_layout'
|
11
12
|
end
|
12
13
|
cms_layouts(:default).update_columns(:content => '{{cms:page:content}}')
|
13
14
|
cms_pages(:child).update_attributes(:blocks_attributes => [
|
@@ -117,6 +118,14 @@ class RenderCmsIntergrationTest < ActionDispatch::IntegrationTest
|
|
117
118
|
assert_equal 'TestBlockContent', response.body
|
118
119
|
end
|
119
120
|
|
121
|
+
def test_implicit_cms_page_with_site_path
|
122
|
+
cms_sites(:default).update_column(:path, 'site-path')
|
123
|
+
cms_pages(:child).update_attributes(:slug => 'render-page')
|
124
|
+
get '/site-path/render-page?type=page_implicit'
|
125
|
+
assert_response :success
|
126
|
+
assert_equal 'TestBlockContent', response.body
|
127
|
+
end
|
128
|
+
|
120
129
|
def test_explicit_cms_page
|
121
130
|
page = cms_pages(:child)
|
122
131
|
page.update_attributes(slug: 'test-page')
|
@@ -7,7 +7,7 @@ class CmsPageTest < ActiveSupport::TestCase
|
|
7
7
|
def test_fixtures_validity
|
8
8
|
Cms::Page.all.each do |page|
|
9
9
|
assert page.valid?, page.errors.full_messages.to_s
|
10
|
-
assert_equal page.
|
10
|
+
assert_equal page.content, page.render
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -195,13 +195,13 @@ class CmsPageTest < ActiveSupport::TestCase
|
|
195
195
|
|
196
196
|
def test_content_caching
|
197
197
|
page = cms_pages(:default)
|
198
|
-
assert_equal page.
|
199
|
-
assert_equal page.read_attribute(:content), page.content(true)
|
198
|
+
assert_equal page.content, page.render
|
200
199
|
|
201
|
-
page.
|
202
|
-
|
203
|
-
|
204
|
-
|
200
|
+
page.update_columns(:content => 'Old Content')
|
201
|
+
refute_equal page.content, page.render
|
202
|
+
|
203
|
+
page.clear_cached_content!
|
204
|
+
assert_equal page.content, page.render
|
205
205
|
end
|
206
206
|
|
207
207
|
def test_scope_published
|
@@ -218,15 +218,15 @@ class CmsPageTest < ActiveSupport::TestCase
|
|
218
218
|
def test_url
|
219
219
|
site = cms_sites(:default)
|
220
220
|
|
221
|
-
assert_equal '
|
222
|
-
assert_equal '
|
221
|
+
assert_equal '//test.host/', cms_pages(:default).url
|
222
|
+
assert_equal '//test.host/child-page', cms_pages(:child).url
|
223
223
|
|
224
224
|
site.update_columns(:path => '/en/site')
|
225
225
|
cms_pages(:default).reload
|
226
226
|
cms_pages(:child).reload
|
227
227
|
|
228
|
-
assert_equal '
|
229
|
-
assert_equal '
|
228
|
+
assert_equal '//test.host/en/site/', cms_pages(:default).url
|
229
|
+
assert_equal '//test.host/en/site/child-page', cms_pages(:child).url
|
230
230
|
end
|
231
231
|
|
232
232
|
def test_unicode_slug_escaping
|
@@ -106,8 +106,7 @@ class FixturePagesTest < ActiveSupport::TestCase
|
|
106
106
|
block = page.blocks.where(:identifier => 'content').first
|
107
107
|
assert_equal "Home Page Fixture Contént\n{{ cms:snippet:default }}", block.content
|
108
108
|
|
109
|
-
|
110
|
-
assert_equal nil, block.content
|
109
|
+
assert !page.blocks.where(:identifier => 'to_delete').first
|
111
110
|
end
|
112
111
|
|
113
112
|
def test_export
|
data/test/models/tag_test.rb
CHANGED
@@ -78,7 +78,7 @@ class TagTest < ActiveSupport::TestCase
|
|
78
78
|
layout_content_b
|
79
79
|
default_snippet_content
|
80
80
|
layout_content_c'
|
81
|
-
), page.
|
81
|
+
), page.render
|
82
82
|
|
83
83
|
assert_equal 4, page.tags.size
|
84
84
|
assert_equal 'field_text_default_field_text', page.tags[0].id
|
@@ -107,7 +107,7 @@ class TagTest < ActiveSupport::TestCase
|
|
107
107
|
layout_content_b
|
108
108
|
default_snippet_content
|
109
109
|
layout_content_c'
|
110
|
-
), page.
|
110
|
+
), page.render
|
111
111
|
|
112
112
|
assert_equal 3, page.tags.size
|
113
113
|
assert_equal 'field_text_default_field_text', page.tags[0].id
|
@@ -140,7 +140,7 @@ class TagTest < ActiveSupport::TestCase
|
|
140
140
|
layout_content_b
|
141
141
|
default_snippet_content
|
142
142
|
layout_content_c'
|
143
|
-
), page.
|
143
|
+
), page.render
|
144
144
|
|
145
145
|
assert_equal 4, page.tags.size
|
146
146
|
assert_equal 'field_text_default_field_text', page.tags[0].id
|
@@ -167,7 +167,7 @@ class TagTest < ActiveSupport::TestCase
|
|
167
167
|
default_page_text_content_a
|
168
168
|
default_snippet_content
|
169
169
|
default_page_text_content_b'
|
170
|
-
), page.
|
170
|
+
), page.render
|
171
171
|
|
172
172
|
assert_equal 6, page.tags.size
|
173
173
|
assert_equal 'field_text_default_field_text', page.tags[0].id
|
@@ -193,7 +193,7 @@ class TagTest < ActiveSupport::TestCase
|
|
193
193
|
layout_content_b
|
194
194
|
infinite loop
|
195
195
|
layout_content_c'
|
196
|
-
), page.
|
196
|
+
), page.render
|
197
197
|
assert_equal 6, page.tags.size
|
198
198
|
end
|
199
199
|
|
@@ -265,10 +265,11 @@ class TagTest < ActiveSupport::TestCase
|
|
265
265
|
{ :identifier => 'content',
|
266
266
|
:content => 'text {{ cms:snippet:irb-snippet }} {{ cms:partial:path/to }} {{ cms:helper:method }} text' },
|
267
267
|
{ :identifier => 'snippet',
|
268
|
-
:content => snippet.id }
|
268
|
+
:content => snippet.id.to_s }
|
269
269
|
]
|
270
270
|
)
|
271
|
-
|
271
|
+
|
272
|
+
assert_equal "<% 1 + 1 %> text <% 2 + 2 %> snippet <%= 2 + 2 %> <%= render :partial => 'path/to' %> <%= method() %> text <%= render :partial => 'partials/cms/snippets', :locals => {:model => 'Cms::Snippet', :identifier => '#{snippet.id}'} %> <%= 1 + 1 %>", page.render
|
272
273
|
end
|
273
274
|
|
274
275
|
def test_escaping_of_parameters
|
data/test/test_helper.rb
CHANGED
@@ -17,6 +17,7 @@ class ActiveSupport::TestCase
|
|
17
17
|
|
18
18
|
def setup
|
19
19
|
reset_config
|
20
|
+
stub_paperclip
|
20
21
|
end
|
21
22
|
|
22
23
|
# resetting default configuration
|
@@ -87,6 +88,12 @@ class ActiveSupport::TestCase
|
|
87
88
|
string.gsub(/^[ ]+/, '')
|
88
89
|
end
|
89
90
|
|
91
|
+
def stub_paperclip
|
92
|
+
Cms::Block.any_instance.stubs(:save_attached_files).returns(true)
|
93
|
+
Cms::Block.any_instance.stubs(:delete_attached_files).returns(true)
|
94
|
+
Paperclip::Attachment.any_instance.stubs(:post_process).returns(true)
|
95
|
+
end
|
96
|
+
|
90
97
|
end
|
91
98
|
|
92
99
|
class ActionController::TestCase
|
@@ -100,6 +107,7 @@ class ActionDispatch::IntegrationTest
|
|
100
107
|
def setup
|
101
108
|
host! 'test.host'
|
102
109
|
reset_config
|
110
|
+
stub_paperclip
|
103
111
|
end
|
104
112
|
|
105
113
|
# Attaching http_auth stuff with request. Example use:
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: comfortable_mexican_sofa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.9.
|
4
|
+
version: 1.9.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-10-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -234,6 +234,7 @@ files:
|
|
234
234
|
- app/models/cms/revision.rb
|
235
235
|
- app/models/cms/site.rb
|
236
236
|
- app/models/cms/snippet.rb
|
237
|
+
- app/models/concerns/cms/base.rb
|
237
238
|
- app/views/cms_admin/categories/_categories.html.haml
|
238
239
|
- app/views/cms_admin/categories/_edit.html.haml
|
239
240
|
- app/views/cms_admin/categories/_form.html.haml
|
@@ -264,6 +265,35 @@ files:
|
|
264
265
|
- app/views/cms_admin/pages/index.html.haml
|
265
266
|
- app/views/cms_admin/pages/new.html.haml
|
266
267
|
- app/views/cms_admin/pages/toggle_branch.js.erb
|
268
|
+
- app/views/cms_admin/partials/_body_before.html.haml
|
269
|
+
- app/views/cms_admin/partials/_file_form_after.html.haml
|
270
|
+
- app/views/cms_admin/partials/_file_form_before.html.haml
|
271
|
+
- app/views/cms_admin/partials/_files_after.html.haml
|
272
|
+
- app/views/cms_admin/partials/_files_before.html.haml
|
273
|
+
- app/views/cms_admin/partials/_html_footer.html.haml
|
274
|
+
- app/views/cms_admin/partials/_html_head.html.haml
|
275
|
+
- app/views/cms_admin/partials/_layout_form_after.html.haml
|
276
|
+
- app/views/cms_admin/partials/_layout_form_before.html.haml
|
277
|
+
- app/views/cms_admin/partials/_layouts_after.html.haml
|
278
|
+
- app/views/cms_admin/partials/_layouts_before.html.haml
|
279
|
+
- app/views/cms_admin/partials/_navigation_after.html.haml
|
280
|
+
- app/views/cms_admin/partials/_navigation_before.html.haml
|
281
|
+
- app/views/cms_admin/partials/_navigation_inner.html.haml
|
282
|
+
- app/views/cms_admin/partials/_page_form_after.html.haml
|
283
|
+
- app/views/cms_admin/partials/_page_form_before.html.haml
|
284
|
+
- app/views/cms_admin/partials/_page_form_inner.html.haml
|
285
|
+
- app/views/cms_admin/partials/_pages_after.html.haml
|
286
|
+
- app/views/cms_admin/partials/_pages_before.html.haml
|
287
|
+
- app/views/cms_admin/partials/_right_column_after.html.haml
|
288
|
+
- app/views/cms_admin/partials/_right_column_before.html.haml
|
289
|
+
- app/views/cms_admin/partials/_site_form_after.html.haml
|
290
|
+
- app/views/cms_admin/partials/_site_form_before.html.haml
|
291
|
+
- app/views/cms_admin/partials/_sites_after.html.haml
|
292
|
+
- app/views/cms_admin/partials/_sites_before.html.haml
|
293
|
+
- app/views/cms_admin/partials/_snippet_form_after.html.haml
|
294
|
+
- app/views/cms_admin/partials/_snippet_form_before.html.haml
|
295
|
+
- app/views/cms_admin/partials/_snippets_after.html.haml
|
296
|
+
- app/views/cms_admin/partials/_snippets_before.html.haml
|
267
297
|
- app/views/cms_admin/revisions/show.html.haml
|
268
298
|
- app/views/cms_admin/sites/_form.html.haml
|
269
299
|
- app/views/cms_admin/sites/_mirrors.html.haml
|
@@ -458,7 +488,8 @@ files:
|
|
458
488
|
- test/models/view_methods_test.rb
|
459
489
|
- test/test_helper.rb
|
460
490
|
homepage: http://github.com/comfy/comfortable-mexican-sofa
|
461
|
-
licenses:
|
491
|
+
licenses:
|
492
|
+
- MIT
|
462
493
|
post_install_message:
|
463
494
|
rdoc_options: []
|
464
495
|
require_paths:
|