Module: CamaleonCms::Admin::MenusHelper
- Includes:
- BreadcrumbHelper
- Included in:
- ApplicationHelper
- Defined in:
- app/helpers/camaleon_cms/admin/menus_helper.rb
Overview
Camaleon CMS is a content management system
Copyright (C) 2015 by Owen Peredo Diaz
Email: [email protected]
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License (GPLv3) for more details.
Instance Method Summary collapse
-
#admin_menu_add_menu(key, menu) ⇒ Object
add menu item to admin menu at the the end key: key for menu menu: is hash like this: “dashboard”, title: “My title”, url: my_path, items: [sub menus] - icon: font-awesome icon (it is already included “fa fa-”) - title: title for the menu - url: url for the menu - items: is an recursive array of the menus without a key - datas: html data text for this menu item.
-
#admin_menu_append_menu_item(key, menu) ⇒ Object
append sub menu to menu with key = key menu: is hash like this: “dashboard”, title: “My title”, url: my_path, items: [sub menus].
-
#admin_menu_draw ⇒ Object
draw admin menu as html.
-
#admin_menu_insert_menu_after(key_target, key_menu, menu) ⇒ Object
add menu after menu with key = key_target key_menu: key for menu menu: is hash like this: “dashboard”, title: “My title”, url: my_path, items: [sub menus].
-
#admin_menu_insert_menu_before(key_target, key_menu, menu) ⇒ Object
add menu before menu with key = key_target key_menu: key for menu menu: is hash like this: “dashboard”, title: “My title”, url: my_path, items: [sub menus].
-
#admin_menu_prepend_menu_item(key, menu) ⇒ Object
prepend sub menu to menu with key = key menu: is hash like this: “dashboard”, title: “My title”, url: my_path, items: [sub menus].
- #admin_menus_add_commons ⇒ Object
Instance Method Details
#admin_menu_add_menu(key, menu) ⇒ Object
add menu item to admin menu at the the end key: key for menu menu: is hash like this: “dashboard”, title: “My title”, url: my_path, items: [sub menus]
-
icon: font-awesome icon (it is already included “fa fa-”)
-
title: title for the menu
-
url: url for the menu
-
items: is an recursive array of the menus without a key
-
datas: html data text for this menu item
75 76 77 |
# File 'app/helpers/camaleon_cms/admin/menus_helper.rb', line 75 def (key, ) @_admin_menus[key] = end |
#admin_menu_append_menu_item(key, menu) ⇒ Object
append sub menu to menu with key = key menu: is hash like this: “dashboard”, title: “My title”, url: my_path, items: [sub menus]
81 82 83 84 85 |
# File 'app/helpers/camaleon_cms/admin/menus_helper.rb', line 81 def (key, ) return unless @_admin_menus[key].present? @_admin_menus[key][:items] = [] unless @_admin_menus[key].has_key?(:items) @_admin_menus[key][:items] << end |
#admin_menu_draw ⇒ Object
draw admin menu as html
120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'app/helpers/camaleon_cms/admin/menus_helper.rb', line 120 def res= [] @_tmp_menu_parents = [] = _get_url_current .each do || res << "<li data-key='#{[:key]}' class='#{"treeview" if .has_key?(:items)} #{'active' if ([:key])}' #{[:datas]}> <a href='#{[:url]}'><i class='fa fa-#{[:icon]}'></i> <span class=''>#{[:title]}</span> #{'<i class="fa fa-angle-left pull-right"></i>' if .has_key?(:items) }</a> #{([:items]) if .has_key?(:items)} </li>" end res.join end |
#admin_menu_insert_menu_after(key_target, key_menu, menu) ⇒ Object
add menu after menu with key = key_target key_menu: key for menu menu: is hash like this: “dashboard”, title: “My title”, url: my_path, items: [sub menus]
110 111 112 113 114 115 116 117 |
# File 'app/helpers/camaleon_cms/admin/menus_helper.rb', line 110 def (key_target, , ) res = {} @_admin_menus.each do |key, val| res[key] = val res[] = if key == key_target end @_admin_menus = res end |
#admin_menu_insert_menu_before(key_target, key_menu, menu) ⇒ Object
add menu before menu with key = key_target key_menu: key for menu menu: is hash like this: “dashboard”, title: “My title”, url: my_path, items: [sub menus]
98 99 100 101 102 103 104 105 |
# File 'app/helpers/camaleon_cms/admin/menus_helper.rb', line 98 def (key_target, , ) res = {} @_admin_menus.each do |key, val| res[] = if key == key_target res[key] = val end @_admin_menus = res end |
#admin_menu_prepend_menu_item(key, menu) ⇒ Object
prepend sub menu to menu with key = key menu: is hash like this: “dashboard”, title: “My title”, url: my_path, items: [sub menus]
89 90 91 92 93 |
# File 'app/helpers/camaleon_cms/admin/menus_helper.rb', line 89 def (key, ) return unless @_admin_menus[key].present? @_admin_menus[key][:items] = [] unless @_admin_menus[key].has_key?(:items) @_admin_menus[key][:items] = [] + @_admin_menus[key][:items] end |
#admin_menus_add_commons ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/helpers/camaleon_cms/admin/menus_helper.rb', line 12 def ("dashboard", {icon: "dashboard", title: t('camaleon_cms.admin.sidebar.dashboard'), url: cama_admin_dashboard_path}) items = [] current_site.post_types.eager_load(:metas)..all.each do |pt| pt = pt.decorate items_i = [] items_i << {icon: "list", title: "#{t('camaleon_cms.admin.post_type.all')}", url: cama_admin_post_type_posts_path(pt.id)} if can? :posts, pt items_i << {icon: "plus", title: "#{t('camaleon_cms.admin.post_type.add_new')} ", url: new_cama_admin_post_type_post_path(pt.id)} if can? :create_post, pt if pt.manage_categories? items_i << {icon: "folder-open", title: t('camaleon_cms.admin.post_type.categories'), url: cama_admin_post_type_categories_path(pt.id)} if can? :categories, pt end if pt. items_i << {icon: "tags", title: t('camaleon_cms.admin.post_type.tags'), url: (pt.id)} if can? :post_tags, pt end items << {icon: pt.get_option('icon', "copy"), title: pt.the_title, url: "", items: items_i } if items_i.present? #if can? :posts, pt end ("content", {icon: "database", title: t('camaleon_cms.admin.sidebar.contents'), url: "", items: items, datas: "data-intro='#{t("camaleon_cms.admin.intro.content")}' data-position='right' data-wait='600'"}) if items.present? #end ("media", {icon: "picture-o", title: t('camaleon_cms.admin.sidebar.media'), url: cama_admin_media_path, datas: "data-intro='#{t("camaleon_cms.admin.intro.media")}' data-position='right'"}) if can? :manage, :media ("comments", {icon: "comments", title: t('camaleon_cms.admin.sidebar.comments'), url: cama_admin_comments_path, datas: "data-intro='#{t("camaleon_cms.admin.intro.comments")}' data-position='right'"}) if can? :manage, :comments items = [] items << {icon: "desktop", title: t('camaleon_cms.admin.sidebar.themes'), url: cama_admin_appearances_themes_path, datas: "data-intro='#{t("camaleon_cms.admin.intro.themes")}' data-position='right'"} if can? :manage, :themes items << {icon: "archive", title: t('camaleon_cms.admin.sidebar.widgets'), url: , datas: "data-intro='#{t("camaleon_cms.admin.intro.widgets")}' data-position='right'"} if can? :manage, :widgets items << {icon: "list", title: t('camaleon_cms.admin.sidebar.menus'), url: , datas: "data-intro='#{t("camaleon_cms.admin.intro.menus", image: view_context.asset_path("camaleon_cms/admin/intro/menus.png"))}' data-position='right'"} if can? :manage, :nav_menu items << {icon: "code", title: t('camaleon_cms.admin.sidebar.shortcodes', default: "Shortcodes"), url: cama_admin_settings_shortcodes_path, datas: "data-intro='#{t("camaleon_cms.admin.intro.shortcodes")}' data-position='right'"} if can? :manage, :shortcodes ("appearance", {icon: "paint-brush", title: t('camaleon_cms.admin.sidebar.appearance'), url: "", items: items, datas: "data-intro='#{t("camaleon_cms.admin.intro.appearance")}' data-position='right' data-wait='500'"}) if items.present? ("plugins", {icon: "plug", title: "#{t('camaleon_cms.admin.sidebar.plugins')} <small class='label label-primary'>#{PluginRoutes.all_plugins.clone.delete_if{|plugin| plugin[:domain].present? && !plugin[:domain].split(",").include?(current_site.the_slug) }.size}</small>", url: cama_admin_plugins_path, datas: "data-intro='#{t("camaleon_cms.admin.intro.plugins")}' data-position='right'"}) if can? :manage, :plugins if can? :manage, :users items = [] items << {icon: "list", title: t('camaleon_cms.admin.users.all_users'), url: cama_admin_users_path} items << {icon: "plus", title: t('camaleon_cms.admin.users.add_user'), url: new_cama_admin_user_path} items << {icon: "group", title: t('camaleon_cms.admin.users.user_roles'), url: cama_admin_user_roles_path} ("users", {icon: "users", title: t('camaleon_cms.admin.sidebar.users'), url: "", items: items, datas: "data-intro='#{t("camaleon_cms.admin.intro.users")}' data-position='right' data-wait='500'"}) end items = [] if can? :manage, :settings items << {icon: "desktop", title: t('camaleon_cms.admin.sidebar.general_site'), url: cama_admin_settings_site_path, datas: "data-intro='#{t("camaleon_cms.admin.intro.gral_site")}' data-position='right'"} items << {icon: "cog", title: t('camaleon_cms.admin.sidebar.sites'), url: cama_admin_settings_sites_path, datas: "data-intro='#{t("camaleon_cms.admin.intro.sites")}' data-position='right'"} if current_site.manage_sites? items << {icon: "files-o", title: t('camaleon_cms.admin.sidebar.content_groups'), url: cama_admin_settings_post_types_path, datas: "data-intro='#{t("camaleon_cms.admin.intro.post_type")}' data-position='right'"} items << {icon: "cog", title: t('camaleon_cms.admin.sidebar.custom_fields'), url: cama_admin_settings_custom_fields_path, datas: "data-intro='#{t("camaleon_cms.admin.intro.custom_fields")}' data-position='right'"} items << {icon: "language", title: t('camaleon_cms.admin.sidebar.languages'), url: cama_admin_settings_languages_path, datas: "data-intro='#{t("camaleon_cms.admin.intro.languages")}' data-position='right'"} end items << {icon: "windows", title: t('camaleon_cms.admin.settings.theme_setting', default: 'Theme Settings'), url: cama_admin_settings_theme_path} if can? :manage, :theme_settings ("settings", {icon: "cogs", title: t('camaleon_cms.admin.sidebar.settings'), url: "", items: items, datas: "data-intro='#{t("camaleon_cms.admin.intro.settings")}' data-position='right' data-wait='500'"}) if items.present? end |