Module: Geri::PagesHelper
- Included in:
- Admin::EditorController
- Defined in:
- app/helpers/geri/pages_helper.rb
Instance Method Summary collapse
- #current_site ⇒ Object
- #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
#current_site ⇒ Object
12 13 14 |
# File 'app/helpers/geri/pages_helper.rb', line 12 def current_site Geri::Config.sites[request.host] || Geri::Config.sites[:default] end |
#editable(name, &block) ⇒ Object
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 63 64 65 66 |
# File 'app/helpers/geri/pages_helper.rb', line 35 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
21 22 23 24 25 26 |
# File 'app/helpers/geri/pages_helper.rb', line 21 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
16 17 18 19 |
# File 'app/helpers/geri/pages_helper.rb', line 16 def link_to_with_active(name, = {}, = {}, &block) [:class] = [:class] ? [:class] + ' active' : 'active' if current_page?() link_to name, , , &block end |
#meta_tags ⇒ Object
28 29 30 31 32 33 |
# File 'app/helpers/geri/pages_helper.rb', line 28 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
8 9 10 |
# File 'app/helpers/geri/pages_helper.rb', line 8 def site_name current_site.name end |
#title ⇒ Object
4 5 6 |
# File 'app/helpers/geri/pages_helper.rb', line 4 def title @metadata[:title] end |