Module: Geri::PagesHelper
- Included in:
- Admin::EditorController
- Defined in:
- app/helpers/geri/pages_helper.rb
Instance Method Summary collapse
- #editable(name, &block) ⇒ Object
- #geri_sanitize(content) ⇒ Object
- #link_to_with_active(name, options = {}, html_options = {}, &block) ⇒ Object
- #meta_tags ⇒ Object
- #site_name ⇒ Object
- #title ⇒ Object
Instance Method Details
#editable(name, &block) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/helpers/geri/pages_helper.rb', line 31 def editable(name, &block) name = "#{current_page}_#{name}" content = Content.find_by(name: name) && geri_sanitize(Content.find_by(name: name).body) content ||= capture(&block) if current_user content = capture do content_tag(:div, contenteditable: true, id: name, class: 'editable') { content } end unless @ckeditor_loaded content << javascript_tag('window.CKEDITOR_BASEPATH = "assets/ckeditor/"') content << javascript_include_tag('ckeditor/ckeditor') content << javascript_tag('CKEDITOR.disableAutoInline = true') @ckeditor_loaded = true end unless @editor_loaded content << stylesheet_link_tag('geri/admin/editor') content << javascript_include_tag('geri/admin/editor') end content << javascript_tag do %Q{ CKEDITOR.inline('#{name}', { on: { change: function(event) { GERI_EDITOR.update(event.editor.name) } } }) }.html_safe end end content end |
#geri_sanitize(content) ⇒ Object
13 14 15 16 17 18 |
# File 'app/helpers/geri/pages_helper.rb', line 13 def geri_sanitize(content) ActionController::Base.helpers.sanitize(content, { tags: %w{ p div strong ol ul li em}, attributes: %w{ href target } }) end |
#link_to_with_active(name, options = {}, html_options = {}, &block) ⇒ Object
8 9 10 11 |
# File 'app/helpers/geri/pages_helper.rb', line 8 def link_to_with_active(name, = {}, = {}, &block) [:class] = [:class] ? [:class] + ' active' : 'active' if current_page?() link_to name, , , &block end |
#meta_tags ⇒ Object
20 21 22 23 24 25 |
# File 'app/helpers/geri/pages_helper.rb', line 20 def concat(content_tag(:meta, '', name: :copyright, content: @metadata[:copyright])) if @metadata[:copyright] concat(content_tag(:meta, '', name: :description, content: @metadata[:description])) if @metadata[:description] concat(content_tag(:meta, '', name: :keywords, content: @metadata[:keywords].join(','))) if @metadata[:keywords] concat(content_tag(:meta, '', name: :robots, content: @metadata[:robots])) if @metadata[:robots] end |
#site_name ⇒ Object
27 28 29 |
# File 'app/helpers/geri/pages_helper.rb', line 27 def site_name Geri::Config.site_name end |
#title ⇒ Object
4 5 6 |
# File 'app/helpers/geri/pages_helper.rb', line 4 def title @metadata[:title] end |