Module: ExpressAdmin::AdminHelper
- Defined in:
- app/helpers/express_admin/admin_helper.rb
Instance Method Summary collapse
- #admin_javascript_and_css_includes ⇒ Object
- #admin_menus ⇒ Object
- #current_engine ⇒ Object
- #current_menu ⇒ Object
- #current_menu_name ⇒ Object
- #current_module ⇒ Object
- #current_module_path_name ⇒ Object
- #current_user_gravatar ⇒ Object
- #description_meta_content ⇒ Object
- #flash_class(key) ⇒ Object
- #is_active?(path) ⇒ Boolean
- #menu_item(name, path) ⇒ Object
- #sign_in_or_sign_out ⇒ Object
- #title_content ⇒ Object
-
#title_partial ⇒ Object
TODO move this out include ExpressMedia::Admin::MediaHelper if Kernel.const_defined?("ExpressMedia::Engine").
- #title_partial_or_express_admin ⇒ Object
Instance Method Details
#admin_javascript_and_css_includes ⇒ Object
59 60 61 62 63 64 65 66 67 68 |
# File 'app/helpers/express_admin/admin_helper.rb', line 59 def admin_javascript_and_css_includes current_module_path = current_module.to_s.underscore admin_path = current_module_path.eql?('admin') ? "admin" : "#{current_module_path}/admin" a = [] a << stylesheet_link_tag("#{admin_path}/application") a << stylesheet_link_tag("app_express/admin/application") if defined?(AppExpress) a << javascript_include_tag("express_admin", 'data-turbolinks-track' => true) a << javascript_include_tag("#{admin_path}/application", 'data-turbolinks-track' => true) a.join().html_safe end |
#admin_menus ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'app/helpers/express_admin/admin_helper.rb', line 70 def = ExpressAdmin::Engine.all_addons.map do |engine| ExpressAdmin::Menu[engine.addon_name.to_s] rescue nil end.compact .sort do |, | if .position == .position .title <=> .title else .position <=> .position end end = ExpressAdmin::Menu['admin'] rescue nil .unshift if end |
#current_engine ⇒ Object
33 34 35 |
# File 'app/helpers/express_admin/admin_helper.rb', line 33 def current_engine "#{current_module}::Engine".constantize end |
#current_menu ⇒ Object
37 38 39 |
# File 'app/helpers/express_admin/admin_helper.rb', line 37 def ExpressAdmin::Menu[current_module_path_name] end |
#current_menu_name ⇒ Object
41 42 43 |
# File 'app/helpers/express_admin/admin_helper.rb', line 41 def .title end |
#current_module ⇒ Object
25 26 27 |
# File 'app/helpers/express_admin/admin_helper.rb', line 25 def current_module controller.class.to_s.split('::').first.constantize end |
#current_module_path_name ⇒ Object
29 30 31 |
# File 'app/helpers/express_admin/admin_helper.rb', line 29 def current_module_path_name current_module.to_s.underscore end |
#current_user_gravatar ⇒ Object
45 46 47 48 49 |
# File 'app/helpers/express_admin/admin_helper.rb', line 45 def current_user_gravatar if defined?(current_user) && !current_user.nil? && !current_user.email.match(/example.com/) gravatar_image_tag current_user.email end end |
#description_meta_content ⇒ Object
55 56 57 |
# File 'app/helpers/express_admin/admin_helper.rb', line 55 def content_for?(:description) ? yield(:description) : 'Testapp' end |
#flash_class(key) ⇒ Object
100 101 102 103 104 105 106 107 |
# File 'app/helpers/express_admin/admin_helper.rb', line 100 def flash_class(key) case key when 'notice' then 'info' when 'success' then 'success' when 'alert' then 'warning' when 'error' then 'alert' end end |
#is_active?(path) ⇒ Boolean
92 93 94 95 96 97 98 |
# File 'app/helpers/express_admin/admin_helper.rb', line 92 def is_active?(path) if request.path.eql?(path) "active" else nil end end |
#menu_item(name, path) ⇒ Object
88 89 90 |
# File 'app/helpers/express_admin/admin_helper.rb', line 88 def (name, path) content_tag(:li, link_to(name, path), class: is_active?(path)) end |
#sign_in_or_sign_out ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'app/helpers/express_admin/admin_helper.rb', line 15 def sign_in_or_sign_out if self.respond_to?(:user_signed_in?) if user_signed_in? link_to 'Logout', main_app.destroy_user_session_path, method: :delete else link_to 'Sign in', main_app.user_session_path end end end |
#title_content ⇒ Object
51 52 53 |
# File 'app/helpers/express_admin/admin_helper.rb', line 51 def title_content content_for?(:title) ? yield(:title) : Rails.application.class.parent_name.underscore.titleize end |
#title_partial ⇒ Object
TODO move this out include ExpressMedia::Admin::MediaHelper if Kernel.const_defined?("ExpressMedia::Engine")
7 8 9 |
# File 'app/helpers/express_admin/admin_helper.rb', line 7 def title_partial (ExpressAdmin::Engine.config.title_partial rescue nil) || 'shared/express_admin/title' end |
#title_partial_or_express_admin ⇒ Object
11 12 13 |
# File 'app/helpers/express_admin/admin_helper.rb', line 11 def title_partial_or_express_admin render(title_partial) rescue 'ExpressAdmin' end |