From 189fa553c54d308ae3a7f155ed8a9b43edfc16a2 Mon Sep 17 00:00:00 2001 From: chris Date: Tue, 9 Oct 2012 14:47:16 +0800 Subject: [PATCH] Changes for helpers, not including all by default --- app/controllers/application_controller.rb | 2 +- ..._banner_helper.rb => ad_banners_helper.rb} | 2 +- app/helpers/admin/ad_images_helper.rb | 3 --- ...app_auth_helper.rb => app_auths_helper.rb} | 2 +- .../{asset_helper.rb => assets_helper.rb} | 2 +- ...shboard_helper.rb => dashboards_helper.rb} | 2 +- .../admin/{item_helper.rb => items_helper.rb} | 2 +- ...le_app_helper.rb => module_apps_helper.rb} | 2 +- app/helpers/admin/page_content_helper.rb | 18 -------------- .../{plugin_helper.rb => plugins_helper.rb} | 2 +- .../admin/{user_helper.rb => users_helper.rb} | 2 +- app/helpers/admin/web_link_helper.rb | 11 --------- ...d_helper.rb => attribute_fields_helper.rb} | 2 +- app/helpers/calendar_helper.rb | 24 ------------------- app/helpers/design_helper.rb | 4 ---- app/helpers/sites_helper.rb | 2 -- config/application.rb | 3 +++ 17 files changed, 13 insertions(+), 72 deletions(-) rename app/helpers/admin/{ad_banner_helper.rb => ad_banners_helper.rb} (96%) delete mode 100644 app/helpers/admin/ad_images_helper.rb rename app/helpers/admin/{app_auth_helper.rb => app_auths_helper.rb} (95%) rename app/helpers/admin/{asset_helper.rb => assets_helper.rb} (86%) rename app/helpers/admin/{dashboard_helper.rb => dashboards_helper.rb} (95%) rename app/helpers/admin/{item_helper.rb => items_helper.rb} (98%) rename app/helpers/admin/{module_app_helper.rb => module_apps_helper.rb} (94%) delete mode 100644 app/helpers/admin/page_content_helper.rb rename app/helpers/admin/{plugin_helper.rb => plugins_helper.rb} (96%) rename app/helpers/admin/{user_helper.rb => users_helper.rb} (93%) delete mode 100644 app/helpers/admin/web_link_helper.rb rename app/helpers/{attribute_field_helper.rb => attribute_fields_helper.rb} (99%) delete mode 100644 app/helpers/calendar_helper.rb delete mode 100644 app/helpers/design_helper.rb delete mode 100644 app/helpers/sites_helper.rb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 18c180a9..0588ae5a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -5,7 +5,7 @@ class ApplicationController < ActionController::Base layout :layout_by_resource - helper :all + helper :admin before_filter :set_locale, :set_site def set_current_user diff --git a/app/helpers/admin/ad_banner_helper.rb b/app/helpers/admin/ad_banners_helper.rb similarity index 96% rename from app/helpers/admin/ad_banner_helper.rb rename to app/helpers/admin/ad_banners_helper.rb index ecba9b3b..9c068621 100644 --- a/app/helpers/admin/ad_banner_helper.rb +++ b/app/helpers/admin/ad_banners_helper.rb @@ -1,4 +1,4 @@ -module Admin::AdBannerHelper +module Admin::AdBannersHelper def preview_block_ad_images_helper(ad_banner) printable_ad_images = [] ad_banner.ad_images.each do |ad_image| diff --git a/app/helpers/admin/ad_images_helper.rb b/app/helpers/admin/ad_images_helper.rb deleted file mode 100644 index b09bd263..00000000 --- a/app/helpers/admin/ad_images_helper.rb +++ /dev/null @@ -1,3 +0,0 @@ -module Admin::AdImagesHelper - -end diff --git a/app/helpers/admin/app_auth_helper.rb b/app/helpers/admin/app_auths_helper.rb similarity index 95% rename from app/helpers/admin/app_auth_helper.rb rename to app/helpers/admin/app_auths_helper.rb index 1a022e94..c679f338 100644 --- a/app/helpers/admin/app_auth_helper.rb +++ b/app/helpers/admin/app_auths_helper.rb @@ -1,4 +1,4 @@ -module Admin::AppAuthHelper +module Admin::AppAuthsHelper def on_off_switch(attribute,attribute_type) link_to t(:enable), eval("admin_#{attribute_type}_path(attribute, :authenticity_token => form_authenticity_token, :#{attribute_type} => {:disabled => true})"), :remote => true, :method => :put, :id => "disable_#{attribute.id}", :style => "display:#{attribute.is_disabled? ? 'none' : ''}", :class => 'switch' link_to t(:disable), eval("admin_#{attribute_type}_path(attribute, :authenticity_token => form_authenticity_token, :#{attribute_type} => {:disabled => false})"), :remote => true, :method => :put, :id => "enable_#{attribute.id}", :style => "display:#{attribute.is_disabled? ? '' : 'none'}", :class => 'switch' diff --git a/app/helpers/admin/asset_helper.rb b/app/helpers/admin/assets_helper.rb similarity index 86% rename from app/helpers/admin/asset_helper.rb rename to app/helpers/admin/assets_helper.rb index 7ed6fa15..f6187d52 100644 --- a/app/helpers/admin/asset_helper.rb +++ b/app/helpers/admin/assets_helper.rb @@ -1,4 +1,4 @@ -module Admin::AssetHelper +module Admin::AssetsHelper def show_all_fields(asset, field) a = [] diff --git a/app/helpers/admin/dashboard_helper.rb b/app/helpers/admin/dashboards_helper.rb similarity index 95% rename from app/helpers/admin/dashboard_helper.rb rename to app/helpers/admin/dashboards_helper.rb index bbfde448..8ee0e36e 100644 --- a/app/helpers/admin/dashboard_helper.rb +++ b/app/helpers/admin/dashboards_helper.rb @@ -1,4 +1,4 @@ -module Admin::DashboardHelper +module Admin::DashboardsHelper def get_link(title) case title diff --git a/app/helpers/admin/item_helper.rb b/app/helpers/admin/items_helper.rb similarity index 98% rename from app/helpers/admin/item_helper.rb rename to app/helpers/admin/items_helper.rb index f5b8589a..3ac6aed6 100644 --- a/app/helpers/admin/item_helper.rb +++ b/app/helpers/admin/items_helper.rb @@ -1,4 +1,4 @@ -module Admin::ItemHelper +module Admin::ItemsHelper def render_node_and_children(node) ret = '' diff --git a/app/helpers/admin/module_app_helper.rb b/app/helpers/admin/module_apps_helper.rb similarity index 94% rename from app/helpers/admin/module_app_helper.rb rename to app/helpers/admin/module_apps_helper.rb index 3ac82364..1bf78ab5 100644 --- a/app/helpers/admin/module_app_helper.rb +++ b/app/helpers/admin/module_apps_helper.rb @@ -1,4 +1,4 @@ -module Admin::ModuleAppHelper +module Admin::ModuleAppsHelper def if_permit_to_delete(item) case item.downcase diff --git a/app/helpers/admin/page_content_helper.rb b/app/helpers/admin/page_content_helper.rb deleted file mode 100644 index 9f2b22e0..00000000 --- a/app/helpers/admin/page_content_helper.rb +++ /dev/null @@ -1,18 +0,0 @@ -module Admin::PageContentHelper -include ActionView::Helpers::UrlHelper - - - def show_page_context_edit_auth_link(page_context) - type = 'Edit' -# debugger -# a=1 - oa = page_context.get_object_auth_by_title(type) - if oa.nil? - page_context.object_auths.new(title: type ).save rescue - oa = page_context.get_object_auth_by_title(type) - end -# link_to t('announcement.bulletin.cate_auth'), edit_admin_object_auth_path(oa) - link_to t('admin.page_context.ob_auth.edit'),admin_object_auth_ob_auth_path(oa) - end - -end \ No newline at end of file diff --git a/app/helpers/admin/plugin_helper.rb b/app/helpers/admin/plugins_helper.rb similarity index 96% rename from app/helpers/admin/plugin_helper.rb rename to app/helpers/admin/plugins_helper.rb index 3afa9d1f..7d0bc5c3 100644 --- a/app/helpers/admin/plugin_helper.rb +++ b/app/helpers/admin/plugins_helper.rb @@ -1,4 +1,4 @@ -module Admin::PluginHelper +module Admin::PluginsHelper def render_plugin_list ret = '' diff --git a/app/helpers/admin/user_helper.rb b/app/helpers/admin/users_helper.rb similarity index 93% rename from app/helpers/admin/user_helper.rb rename to app/helpers/admin/users_helper.rb index 22da150e..c6b72b53 100644 --- a/app/helpers/admin/user_helper.rb +++ b/app/helpers/admin/users_helper.rb @@ -1,4 +1,4 @@ -module Admin::UserHelper +module Admin::UsersHelper def show_attribute(object, field_id, locale = '') attribute = object.attribute_values.detect {|av| av.attribute_field_id.eql?(field_id) || av[locale.to_s].eql?(locale.to_s) } rescue nil diff --git a/app/helpers/admin/web_link_helper.rb b/app/helpers/admin/web_link_helper.rb deleted file mode 100644 index 0498f31b..00000000 --- a/app/helpers/admin/web_link_helper.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Admin::WebLinkHelper - def show_web_link_permission_link(web_link) - type = 'edit' - oa = web_link.get_object_auth_by_title(type) - if oa.nil? - web_link.object_auths.new(title: type ).save - oa = web_link.get_object_auth_by_title(type) - end - link_to t('web_resource.cate_auth'),admin_object_auth_ob_auth_path(oa) - end -end \ No newline at end of file diff --git a/app/helpers/attribute_field_helper.rb b/app/helpers/attribute_fields_helper.rb similarity index 99% rename from app/helpers/attribute_field_helper.rb rename to app/helpers/attribute_fields_helper.rb index 9d0999da..dfc30ddd 100644 --- a/app/helpers/attribute_field_helper.rb +++ b/app/helpers/attribute_fields_helper.rb @@ -1,6 +1,6 @@ # require ActionView::Helpers::FormTagHelper -module AttributeFieldHelper +module AttributeFieldsHelper include ActionView::Helpers::FormTagHelper include ActionView::Helpers::FormOptionsHelper include ActionView::Helpers::DateHelper diff --git a/app/helpers/calendar_helper.rb b/app/helpers/calendar_helper.rb deleted file mode 100644 index 880acc33..00000000 --- a/app/helpers/calendar_helper.rb +++ /dev/null @@ -1,24 +0,0 @@ -module CalendarHelper - def month_link(month_date) - link_to(I18n.localize(month_date, :format => "%B"), {:month => month_date.month, :year => month_date.year}) - end - - # custom options for this calendar - def event_calendar_opts - { - :year => @year, - :month => @month, - :event_strips => @event_strips, - :month_name_text => I18n.localize(@shown_month, :format => "%B %Y"), - :previous_month_text => "<< " + month_link(@shown_month.prev_month), - :next_month_text => month_link(@shown_month.next_month) + " >>" } - end - - def event_calendar - # args is an argument hash containing :event, :day, and :options - calendar event_calendar_opts do |args| - event = args[:event] - %(#{h(event.name)}) - end - end -end diff --git a/app/helpers/design_helper.rb b/app/helpers/design_helper.rb deleted file mode 100644 index c55eb2a0..00000000 --- a/app/helpers/design_helper.rb +++ /dev/null @@ -1,4 +0,0 @@ -module DesignHelper - - -end diff --git a/app/helpers/sites_helper.rb b/app/helpers/sites_helper.rb deleted file mode 100644 index 621069db..00000000 --- a/app/helpers/sites_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module SitesHelper -end diff --git a/config/application.rb b/config/application.rb index 9faef5d4..d6d9b6b4 100644 --- a/config/application.rb +++ b/config/application.rb @@ -34,6 +34,9 @@ module Orbit config.autoload_paths += %W(#{config.root}/app/models/purchase) config.autoload_paths += %W(#{config.root}/app/models/user) + # Include all helpers + # 'helper :all' must be removed in ApplicationController + config.action_controller.include_all_helpers = false # Only load the plugins named here, in the order given (default is alphabetical). # :all can be used as a placeholder for all plugins not explicitly named.