Class: ActiveAdmin::Views::HeaderRenderer

Inherits:
Renderer
  • Object
show all
Defined in:
lib/active_admin/views/header_renderer.rb

Overview

Renderer for the header of the application. Includes the page title, global navigation and utility navigation.

Instance Attribute Summary

Attributes inherited from Renderer

#assigns, #view

Instance Method Summary collapse

Methods inherited from Renderer

#call_method_or_proc_on, #haml, #initialize, #method_missing, #set_ivar_on_view, #to_s

Methods included from Arbre::Builder

#current_dom_context, #helpers, #method_missing

Methods included from ActiveAdmin::ViewHelpers::RendererHelper

#render

Constructor Details

This class inherits a constructor from ActiveAdmin::Renderer

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ActiveAdmin::Renderer

Instance Method Details

#active_admin_logout_pathObject (protected)

Returns the logout path from the application settings



68
69
70
71
72
73
74
# File 'lib/active_admin/views/header_renderer.rb', line 68

def active_admin_logout_path
  if active_admin_namespace.logout_link_path.is_a?(Symbol)
    send(active_admin_namespace.logout_link_path)
  else
    active_admin_namespace.logout_link_path
  end
end

Renders the global navigation returned by ActiveAdmin::ResourceController#current_menu

It uses the ActiveAdmin.tabs_renderer option



51
52
53
# File 'lib/active_admin/views/header_renderer.rb', line 51

def global_navigation
  render view_factory.global_navigation, current_menu, :class => 'header-item' 
end


19
20
21
22
23
24
25
# File 'lib/active_admin/views/header_renderer.rb', line 19

def link_to_site_title(title_tag)
  if active_admin_namespace.site_title_link.present?
    link_to(title_tag, active_admin_namespace.site_title_link)
  else
    title_tag
  end
end

#logout_methodObject (protected)



76
77
78
# File 'lib/active_admin/views/header_renderer.rb', line 76

def logout_method
  active_admin_namespace.logout_link_method || :get
end

#titleObject (protected)

Renders the title/branding area for the site



15
16
17
# File 'lib/active_admin/views/header_renderer.rb', line 15

def title
  ('h1', link_to_site_title(title_image_tag || title_text), :id => 'site_title')
end

#title_imageString (protected)

Returns The title image url.

Returns:

  • The title image url



38
39
40
# File 'lib/active_admin/views/header_renderer.rb', line 38

def title_image
  render_or_call_method_or_proc_on(self, active_admin_namespace.site_title_image)
end

#title_image_tagString (protected)

site_title_image is blank.

Returns:

  • An HTML img tag with site_title_image. Return nil when



29
30
31
32
33
34
35
# File 'lib/active_admin/views/header_renderer.rb', line 29

def title_image_tag
  if active_admin_namespace.site_title_image.present?
    image_tag(title_image, 
              :id => "site_title_image", 
              :alt => active_admin_namespace.site_title)
  end
end

#title_textString (protected)

Returns The site title.

Returns:

  • The site title



43
44
45
# File 'lib/active_admin/views/header_renderer.rb', line 43

def title_text
  render_or_call_method_or_proc_on(self, active_admin_namespace.site_title)
end

#to_htmlObject



8
9
10
# File 'lib/active_admin/views/header_renderer.rb', line 8

def to_html
  title + global_navigation + utility_navigation
end

#utility_navigationObject (protected)



55
56
57
58
59
60
61
62
63
64
65
# File 'lib/active_admin/views/header_renderer.rb', line 55

def utility_navigation
   'p', :id => "utility_nav", :class => 'header-item' do
    if current_active_admin_user?
      html = (:span, display_name(current_active_admin_user), :class => "current_user")

      if active_admin_namespace.logout_link_path
        html << link_to(I18n.t('active_admin.logout'), active_admin_logout_path, :method => logout_method)
      end
    end
  end
end