app/helpers/rails/service/admin_helper.rb in rails-service-0.1.0 vs app/helpers/rails/service/admin_helper.rb in rails-service-0.2.0

- old
+ new

@@ -1,14 +1,18 @@ module Rails module Service module AdminHelper + def autoformat_action_name(action) + action.split('_').map(&:capitalize).join(' ') + end + def render_sidebar - li = [] - Rails::Service::AdminController.action_methods.sort.each do |method| - text = method.split('_').map(&:capitalize).join(' ') - li << content_tag(:li, link_to(text, admin_path(action: method)).html_safe) + li = Rails::Service::AdminController.action_methods.sort.map do |method| + text = autoformat_action_name(method) + content_tag(:li, link_to(text, admin_path(action: method)).html_safe) end + content_tag(:ul, li.join.html_safe, class: 'nav nav-stacked') end def render_rails_iframe(opts = {}) attrs = { @@ -19,9 +23,25 @@ scrolling: 'no', onload: 'javascript:resizeIframe(this);', } content_tag(:iframe, nil, attrs) + end + + def render_pretty_json(object) + content_tag(:pre, content_tag(:code, JSON.pretty_generate(object), class: 'json')) + end + + def render_title(_opts = {}) + content_for?(:title) ? yield(:title) : autoformat_action_name(controller.action_name) + end + + def render_meta_title + [Rails::Service.context.app, render_title].join(' / ') + end + + def title(text) + content_for(:title, text) end end end end