Module: Gluttonberg::ContentHelpers
- Included in:
- ApplicationHelper
- Defined in:
- app/helpers/gluttonberg/content_helpers.rb
Instance Method Summary collapse
-
#content_editor(content) ⇒ Object
Looks for a matching partial in the templates directory.
-
#enable_redactor(html_class) ⇒ Object
generate javascript code to enable tinymce on it.
- #enable_slug_management_on(html_class) ⇒ Object
-
#gb_content_for(section_name, opts = nil) ⇒ Object
Returns the content record for the specified section.
- #gb_image_alt_text(section_name, opts = {}) ⇒ Object
-
#gb_image_url(section_name, opts = {}) ⇒ Object
Renders an image url, allows the designer to specify who they want to handle the image.
Instance Method Details
#content_editor(content) ⇒ Object
Looks for a matching partial in the templates directory. Failing that, it falls back to Gluttonberg’s view dir — views/content/editors
26 27 28 29 30 |
# File 'app/helpers/gluttonberg/content_helpers.rb', line 26 def content_editor(content) locals = {:content => content} type = content.content_type render :partial => Gluttonberg::Templates.editor_template_path(type) , :locals => locals end |
#enable_redactor(html_class) ⇒ Object
generate javascript code to enable tinymce on it.
38 39 40 41 42 43 44 45 |
# File 'app/helpers/gluttonberg/content_helpers.rb', line 38 def enable_redactor(html_class) if Gluttonberg::Setting.get_setting("enable_WYSIWYG") == "Yes" link_count = Page.published.count link_count += Gluttonberg::Blog::Article.published.count if Gluttonberg.constants.include?(:Blog) content = "enableRedactor('.#{html_class}', #{link_count}); \n" javascript_tag(content) end end |
#enable_slug_management_on(html_class) ⇒ Object
33 34 35 |
# File 'app/helpers/gluttonberg/content_helpers.rb', line 33 def enable_slug_management_on(html_class) javascript_tag("enable_slug_management_on('#{html_class}')" ) end |
#gb_content_for(section_name, opts = nil) ⇒ Object
Returns the content record for the specified section. It will include the relevant localized version based the current locale/dialect
6 7 8 9 |
# File 'app/helpers/gluttonberg/content_helpers.rb', line 6 def gb_content_for(section_name, opts = nil) section_name = section_name.to_sym @page.localized_contents.pluck {|c| c.section[:name] == section_name} end |
#gb_image_alt_text(section_name, opts = {}) ⇒ Object
17 18 19 20 21 22 |
# File 'app/helpers/gluttonberg/content_helpers.rb', line 17 def gb_image_alt_text(section_name, opts = {}) content = gb_content_for(section_name) if content.asset content.asset.name end end |
#gb_image_url(section_name, opts = {}) ⇒ Object
Renders an image url, allows the designer to specify who they want to handle the image.
13 14 15 |
# File 'app/helpers/gluttonberg/content_helpers.rb', line 13 def gb_image_url(section_name, opts = {}) @page.easy_contents(section_name, opts) end |