Module: Gluttonberg::Admin
- Includes:
- Assets, Form, Messages, Versioning
- Included in:
- ApplicationHelper
- Defined in:
- app/helpers/gluttonberg/admin.rb,
app/helpers/gluttonberg/admin/form.rb,
app/helpers/gluttonberg/admin/assets.rb,
app/helpers/gluttonberg/admin/messages.rb,
app/helpers/gluttonberg/admin/versioning.rb,
app/controllers/gluttonberg/admin/base_controller.rb,
app/controllers/gluttonberg/admin/main_controller.rb,
app/controllers/gluttonberg/admin/content/flag_controller.rb,
app/controllers/gluttonberg/admin/content/pages_controller.rb,
app/controllers/gluttonberg/admin/user_sessions_controller.rb,
app/controllers/gluttonberg/admin/settings/users_controller.rb,
app/controllers/gluttonberg/admin/membership/main_controller.rb,
app/controllers/gluttonberg/admin/password_resets_controller.rb,
app/controllers/gluttonberg/admin/settings/embeds_controller.rb,
app/controllers/gluttonberg/admin/settings/locales_controller.rb,
app/controllers/gluttonberg/admin/content/auto_save_controller.rb,
app/controllers/gluttonberg/admin/content/galleries_controller.rb,
app/controllers/gluttonberg/admin/membership/groups_controller.rb,
app/controllers/gluttonberg/admin/asset_library/base_controller.rb,
app/controllers/gluttonberg/admin/membership/members_controller.rb,
app/controllers/gluttonberg/admin/asset_library/assets_controller.rb,
app/controllers/gluttonberg/admin/settings/stylesheets_controller.rb,
app/controllers/gluttonberg/admin/settings/configurations_controller.rb,
app/controllers/gluttonberg/admin/settings/global_history_controller.rb,
app/controllers/gluttonberg/admin/asset_library/assets_ajax_controller.rb,
app/controllers/gluttonberg/admin/asset_library/assets_bulk_controller.rb,
app/controllers/gluttonberg/admin/asset_library/collections_controller.rb,
app/controllers/gluttonberg/admin/content/page_localizations_controller.rb
Overview
Helpers specific to the administration interface. The majority are related to forms, but there are other short cuts for things like navigation.
Defined Under Namespace
Modules: AssetLibrary, Assets, Content, Form, Membership, Messages, Settings, Versioning Classes: BaseController, MainController, PasswordResetsController, UserSessionsController
Instance Method Summary collapse
-
#custom_javascript_include_tag ⇒ Object
if custom_js_for_cms settings is true in advance gluttonberg settings initalizer it renders javascript include tag but you need make sure that gb_custom.js file exists in your host app now it supports multiple custom js files using config.custom_js_files_for_backend as an array of file names.
-
#custom_stylesheet_link_tag ⇒ Object
if custom_css_for_cms settings is true in advance gluttonberg settings initalizer it renders stylesheet link tag but you need make sure that gb_custom.css/sass file exists in your host app now it supports multiple custom css files using config.custom_css_files_for_backend as an array of file names.
-
#date_format(date_time) ⇒ Object
gluttonberg’s default date format.
-
#nav_link(*args) ⇒ Object
Writes out a link styled like a button.
- #page_and_its_children_options(page, array, level) ⇒ Object
- #page_description_option(name, desc, descriptions) ⇒ Object
-
#page_description_options ⇒ Object
formatted dropdown list for pages.
-
#page_table_rows(pages, parent_id = nil, output = "", inset = 0, row = 0) ⇒ Object
Writes out a row for each page and then for each page’s children, iterating down through the heirarchy.
-
#pages_lists_options(pages = nil, array = [], level = 0) ⇒ Object
returns pages list for dropdowns.
- #slug_donotmodify_val ⇒ Object
-
#sortable_column(column, title = nil) ⇒ Object
returns link for column sorting.
-
#sorter_link(name, param, url) ⇒ Object
Returns a link for sorting assets in the library.
-
#sub_nav(&blk) ⇒ Object
Writes out a nicely styled subnav with an entry for each of the specified links.
-
#tags_string(tag_type) ⇒ Object
returns comma seperated list of all tags for given tag type.
Methods included from Versioning
#auto_save, #auto_save_js_tag, #auto_save_version, #previous_version_warning, #version_alerts, #version_dashboard_notifications, #version_dashboard_notifications_data
Methods included from Assets
#_asset_browser_tag, #asset_browser_tag, #asset_panel, #backend_logo, #clear_asset_tag
Methods included from Form
#admin_form_controls_for_approving_or_decling_objects, #admin_form_controls_for_draft_objects, #admin_form_controls_for_published_objects, #contributor_form_controls, #form_controls, #gb_editable_field, #honeypot_field_tag, #publish_message, #submit_and_publish_controls, #version_listing
Methods included from Messages
#gb_error_messages_for, #render_flash_messages
Instance Method Details
#custom_javascript_include_tag ⇒ Object
if custom_js_for_cms settings is true in advance gluttonberg settings initalizer it renders javascript include tag but you need make sure that gb_custom.js file exists in your host app now it supports multiple custom js files using config.custom_js_files_for_backend as an array of file names
73 74 75 76 77 78 79 80 81 82 |
# File 'app/helpers/gluttonberg/admin.rb', line 73 def custom_javascript_include_tag files = "" if Rails.configuration.custom_js_for_cms == true files += javascript_include_tag("gb_custom") + "\n" end Rails.configuration.custom_js_files_for_backend.each do |file| files += javascript_include_tag(file) + "\n" end files.blank? ? nil : files.html_safe end |
#custom_stylesheet_link_tag ⇒ Object
if custom_css_for_cms settings is true in advance gluttonberg settings initalizer it renders stylesheet link tag but you need make sure that gb_custom.css/sass file exists in your host app now it supports multiple custom css files using config.custom_css_files_for_backend as an array of file names
58 59 60 61 62 63 64 65 66 67 |
# File 'app/helpers/gluttonberg/admin.rb', line 58 def custom_stylesheet_link_tag files = "" if Rails.configuration.custom_css_for_cms == true files += stylesheet_link_tag("gb_custom") + "\n" end Rails.configuration.custom_css_files_for_backend.each do |file| files += stylesheet_link_tag(file) + "\n" end files.blank? ? nil : files.html_safe end |
#date_format(date_time) ⇒ Object
gluttonberg’s default date format.
95 96 97 98 99 100 101 |
# File 'app/helpers/gluttonberg/admin.rb', line 95 def date_format(date_time) if date_time < 1.week.ago date_time.strftime("%d/%m/%Y") else time_ago_in_words(date_time) end end |
#nav_link(*args) ⇒ Object
Writes out a link styled like a button. To be used in the sub nav only
30 31 32 33 34 |
# File 'app/helpers/gluttonberg/admin.rb', line 30 def nav_link(*args) class_names = "button" class_names = "#{class_names} #{args[2][:class]}" if args.length >= 3 content_tag(:li, active_link_to(args[0] , args[1] , :title => args[0]), :class => class_names) end |
#page_and_its_children_options(page, array, level) ⇒ Object
128 129 130 131 132 133 |
# File 'app/helpers/gluttonberg/admin.rb', line 128 def (page, array, level) array << [page.name, page.id, {class: "level-#{level}"}.merge(current_user.ability.can?(:manage_object, page) ? {} : {:disabled => :disabled})] unless page.children.blank? (page.children, array, level+1) end end |
#page_description_option(name, desc, descriptions) ⇒ Object
144 145 146 147 148 149 150 |
# File 'app/helpers/gluttonberg/admin.rb', line 144 def page_description_option(name, desc, descriptions) if !current_user.contributor? || desc.contributor_access? || (@page && name.to_s == @page.description_name) group = desc[:group].blank? ? "" : desc[:group] descriptions[group] = [] if descriptions[group].blank? descriptions[group] << [desc[:description], name] end end |
#page_description_options ⇒ Object
formatted dropdown list for pages
136 137 138 139 140 141 142 |
# File 'app/helpers/gluttonberg/admin.rb', line 136 def @descriptions = {} Gluttonberg::PageDescription.all.each do |name, desc| page_description_option(name, desc, @descriptions) end @descriptions end |
#page_table_rows(pages, parent_id = nil, output = "", inset = 0, row = 0) ⇒ Object
Writes out a row for each page and then for each page’s children, iterating down through the heirarchy.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/helpers/gluttonberg/admin.rb', line 38 def page_table_rows(pages, parent_id=nil, output = "", inset = 0 , row = 0) filtered_pages_for_table_rows(pages, parent_id).each do |page| row += 1 output << "<li class='dd-item #{page.collapsed?(current_user) ? 'page-collapsed' : ''}' data-id='#{page.id}' >" output << render( :partial => "gluttonberg/admin/content/pages/row", :locals => { :page => page, :inset => inset , :row => row }) if page.number_of_children > 0 output << "<ol class='dd-list'>" children = page.children.find_all{|page| current_user.can_view_page(page) } page_table_rows(children, page.id, output, inset + 1 , row) output << "</ol>" end output << "</li>" end output.html_safe end |
#pages_lists_options(pages = nil, array = [], level = 0) ⇒ Object
returns pages list for dropdowns. it also add level-xx classes to children pages.
117 118 119 120 121 122 123 124 125 126 |
# File 'app/helpers/gluttonberg/admin.rb', line 117 def (pages=nil, array=[], level=0) if pages.blank? && level==0 pages = Gluttonberg::Page.where(:parent_id => nil).order("position ASC").all end pages = pages.find_all{|page| current_user.can_view_page(page) } pages.each do |page| (page, array, level) end array end |
#slug_donotmodify_val ⇒ Object
112 113 114 |
# File 'app/helpers/gluttonberg/admin.rb', line 112 def slug_donotmodify_val action_name == "edit" || action_name == "update" end |
#sortable_column(column, title = nil) ⇒ Object
returns link for column sorting
104 105 106 107 108 109 110 |
# File 'app/helpers/gluttonberg/admin.rb', line 104 def sortable_column(column, title = nil) title ||= column.titleize css_class = column == sort_column ? "current #{sort_direction}" : nil direction = column == sort_column && sort_direction == "asc" ? "desc" : "asc" new_params = params.merge(:sort => column, :direction => direction) link_to title, new_params, {:class => css_class} end |
#sorter_link(name, param, url) ⇒ Object
Returns a link for sorting assets in the library
11 12 13 14 15 16 17 18 19 20 |
# File 'app/helpers/gluttonberg/admin.rb', line 11 def sorter_link(name, param, url) opts = {} route_opts = { :order => param , :order_type => "asc" } if param == params[:order] || (!params[:order] && param == 'date-added') opts[:class] = "current #{route_opts[:order_type]}" #reverse route_opts[:order_type] = (params[:order_type] == "asc" ? "desc" : "asc" ) end link_to(name, url + "?" + route_opts.to_param , opts) end |
#sub_nav(&blk) ⇒ Object
Writes out a nicely styled subnav with an entry for each of the specified links.
25 26 27 |
# File 'app/helpers/gluttonberg/admin.rb', line 25 def sub_nav(&blk) content_tag(:ul, :id => "subnav", :class => "nav nav-pills", &blk) end |
#tags_string(tag_type) ⇒ Object
returns comma seperated list of all tags for given tag type
85 86 87 88 89 90 91 92 |
# File 'app/helpers/gluttonberg/admin.rb', line 85 def (tag_type) @themes = ActsAsTaggableOn::Tag.find_by_sql(%{select DISTINCT tags.id , tags.name from tags inner join taggings on tags.id = taggings.tag_id where context = '#{tag_type}' }) @themes = @themes.collect{|theme| theme.name} @themes.blank? ? "" : @themes.join(", ") end |