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 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
- content_tag :div, role: 'html-editor' do
28
- out = content_tag(:div, class: 'cms-page-area', role: 'display') do
29
- if page_area.content.present? && !page_area.default
30
- content = page_area.content
31
- elsif block_given?
32
- content = capture(&block)
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
- display = ''.html_safe
38
- display << cms_page_area_edit_link if admin?
39
- display << content_tag(:div, class: 'content') do
40
- cms_content_parse(content) if content.present?
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
- out << content_tag(:div, role: 'editor') do
45
- form_for([:cms, page_area], format: 'json', remote: true) do |f|
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')
@@ -1,3 +1,6 @@
1
+ #= require codemirror
2
+ #= require codemirror/xml
3
+
1
4
  class window.HtmlEditor extends Backbone.View
2
5
  events:
3
6
  'click a[href=#edit]': 'showEditor'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: honey-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: