Last active
November 15, 2018 21:33
-
-
Save bigfive/6017435 to your computer and use it in GitHub Desktop.
Active admin reskin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActiveAdminHelper | |
def admin_arbre_context | |
@admin_arbre_context ||= Arbre::Context.new(assigns, self) | |
end | |
def default_renderer | |
case controller.send(:resource_class).name | |
when "ActiveAdmin::Page" | |
"page" | |
else | |
"#{params[:action]}_page" | |
end | |
end | |
def admin_renderer method_name, renderer_name=nil | |
renderer_name ||= default_renderer | |
@renderers ||= {} | |
@renderers[renderer_name] ||= view_factory[renderer_name.to_s].new(admin_arbre_context) | |
@renderers[renderer_name].send(method_name) | |
end | |
def admin_arbre_tag renderer_name, *args | |
admin_arbre_context.insert_tag *([view_factory[renderer_name.to_s]] | args) | |
end | |
def admin_classes | |
classes = [] | |
classes << params[:action] | |
classes << params[:controller].gsub('/', '_') | |
classes << "active_admin" | |
classes << "logged_in" | |
classes << active_admin_namespace.name.to_s + "_namespace" | |
classes.join(" ") | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/active_admin_patch.rb | |
module ActiveAdmin | |
class BaseController | |
helper ActiveAdminHelper | |
def determine_active_admin_layout | |
'active_admin_reskin' | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html><html> | |
<head> | |
<meta content="text/html; charset=utf-8" http-equiv="Content-type"/> | |
<title><%= active_admin_application.site_title %></title> | |
<%= stylesheet_link_tag "active_admin", :media => "all" %> | |
<%= javascript_include_tag "active_admin" %> | |
<%= csrf_meta_tags %> | |
</head> | |
<body class="<%= admin_classes %>"> | |
<div id="wrapper"> | |
<div id="header" class="header"> | |
<%= admin_arbre_tag :site_title, active_admin_namespace %> | |
<%= admin_arbre_tag :global_navigation, current_menu, :class => 'header-item tabs' %> | |
<%= admin_arbre_tag :global_navigation, active_admin_namespace.fetch_menu(:utility_navigation), :id => "utility_nav", :class => 'header-item tabs' %> | |
</div> | |
<div class="title_bar" id="title_bar"> | |
<div id="titlebar_left"> | |
<%= admin_renderer(:build_breadcrumb, :title_bar) %> | |
<h2 id="page_title"><%= admin_renderer(:title) %><h2> | |
</div> | |
<div id="titlebar_right"> | |
<%= admin_arbre_tag(:action_items, admin_renderer(:action_items_for_action)) if admin_renderer(:action_items_for_action).any? %> | |
</div> | |
</div> | |
<%= admin_renderer(:build_flash_messages) %> | |
<div id="active_admin_content" class="<%= admin_renderer(:skip_sidebar?) ? 'without_sidebar' : 'with_sidebar' %>"> | |
<%= admin_renderer(:build_main_content_wrapper) %> | |
<%= admin_renderer(:build_sidebar) unless admin_renderer(:skip_sidebar?) %> | |
</div> | |
<div id="footer"> | |
<p><%= "Powered by #{ link_to 'Digital Dialogue', 'http://digitaldialogue.com.au' }".html_safe %></p> | |
</div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Where do you generally put these in a Rails app?