honey-cms 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/cms/helper.rb +30 -19
- data/vendor/assets/javascripts/cms.js.coffee +3 -0
- metadata +1 -1
data/lib/cms/helper.rb
CHANGED
@@ -21,38 +21,49 @@ module CMS::Helper
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
+
|
24
25
|
def cms_page_area name, &block
|
25
26
|
page_area = if area = CMS::PageArea.find_by_name(name) then area else CMS::PageArea.new({name: name}, without_protection: true) end
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
page_area.content = ''.concat(content)
|
34
|
-
page_area.save!
|
28
|
+
if admin?
|
29
|
+
content_tag :div, role: 'html-editor' do
|
30
|
+
out = content_tag(:div, class: 'cms-page-area', role: 'display') do
|
31
|
+
display = ''.html_safe
|
32
|
+
display << cms_page_area_edit_link if admin?
|
33
|
+
display << render_cms_page_area_content(page_area, &block)
|
35
34
|
end
|
36
35
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
36
|
+
out << content_tag(:div, role: 'editor') do
|
37
|
+
form_for([:cms, page_area], format: 'json', remote: true) do |f|
|
38
|
+
form = f.hidden_field(:name)
|
39
|
+
form << f.hidden_field(:content, class: 'content')
|
40
|
+
form << f.actions(save: 'done')
|
41
|
+
end
|
41
42
|
end
|
42
43
|
end
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
form = f.hidden_field(:name)
|
47
|
-
form << f.hidden_field(:content, class: 'content')
|
48
|
-
form << f.actions(save: 'done')
|
49
|
-
end
|
44
|
+
else
|
45
|
+
content_tag :div, class: 'cms-page-area' do
|
46
|
+
render_cms_page_area_content(page_area, &block)
|
50
47
|
end
|
51
48
|
end
|
52
49
|
rescue Exception => e
|
53
50
|
if Rails.env.production? then '' else raise e end
|
54
51
|
end
|
55
52
|
|
53
|
+
def render_cms_page_area_content page_area, &block
|
54
|
+
if page_area.content.present? && !page_area.default
|
55
|
+
content = page_area.content
|
56
|
+
elsif block_given?
|
57
|
+
content = capture(&block)
|
58
|
+
page_area.content = ''.concat(content)
|
59
|
+
page_area.save!
|
60
|
+
end
|
61
|
+
|
62
|
+
content_tag(:div, class: 'content') do
|
63
|
+
cms_content_parse(content) if content.present?
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
56
67
|
def cms_page_area_edit_link
|
57
68
|
content_tag :div, class: 'cms-edit-link' do
|
58
69
|
link_to('Edit', '#edit')
|