Module: Cms::RenderingHelper

Defined in:
app/helpers/cms/rendering_helper.rb

Instance Method Summary collapse

Instance Method Details

#attachment_viewer(content) ⇒ Object

Renders a table of attachments for a given content block. This is intended as a basic view of the content, and probably won’t be suitable for blocks that need to be added directly to pages.



11
12
13
# File 'app/helpers/cms/rendering_helper.rb', line 11

def attachment_viewer(content)
  render :partial => 'cms/attachments/attachment_table', :locals => { :block => content, :can_delete => false }
end

#is_editing_page?(page) ⇒ Boolean

Determines if a user is currently editing this page

Returns:

  • (Boolean)


16
17
18
# File 'app/helpers/cms/rendering_helper.rb', line 16

def is_editing_page?(page)
  logged_in? && @mode == "edit" && current_user.able_to_edit?(page)
end

#render_cms_toolbar(tab = :dashboard) ⇒ Object

Renders the toolbar for the CMS. All page templates need to include this or they won’t be editable. Typically rendered as an iframe to avoid CSS/JS conflicts.

Parameters:

  • tab (Symbol) (defaults to: :dashboard)

    Which tab of the dashboard to highlight. Defaults to :dashboard.



51
52
53
# File 'app/helpers/cms/rendering_helper.rb', line 51

def render_cms_toolbar(tab=:dashboard)
  render :partial => 'layouts/cms_toolbar', :locals => {:tab => tab}
end

#render_connectable(content_block) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/helpers/cms/rendering_helper.rb', line 29

def render_connectable(content_block)
  if content_block
    if content_block.class.renderable?
      logger.debug "Rendering connectable #{content_block.class} ##{content_block.id} #{"v#{content_block.version}" if content_block.respond_to?(:version)}"
      content_block.perform_render(controller)
    else
      logger.warn "Connectable #{content_block.class} ##{content_block.id} is not renderable"
    end
  else
    logger.warn "Connectable is null"
  end
rescue Exception => e
  logger.error "Error occurred while rendering #{content_block.class}##{content_block.id}: #{e.message}\n#{e.backtrace.join("\n")}"
  "ERROR: #{e.message}"
end

#render_connector_and_connectable(connector, connectable) ⇒ Object



20
21
22
23
24
25
26
27
# File 'app/helpers/cms/rendering_helper.rb', line 20

def render_connector_and_connectable(connector, connectable)
  logger.debug "Rendering #{connectable} "
  if is_editing_page?(connector.page)
    render(:partial => 'cms/pages/edit_connector', :locals => { :connector => connector, :connectable => connectable})
  else
    render_connectable(connectable)
  end
end