diff --git a/app/views/layouts/_side_bar_content.html.erb b/app/views/layouts/_side_bar_content.html.erb
index 7b3a2974..76fced3a 100644
--- a/app/views/layouts/_side_bar_content.html.erb
+++ b/app/views/layouts/_side_bar_content.html.erb
@@ -2,7 +2,10 @@
<%= javascript_include_tag "/static/kernel.js" %>
<% end %>
-<%=OrbitApp::Module::SideBarRegisition.all.first.render(request,params,current_user,@module_app) %>
+
+<%OrbitApp::Module::SideBarRegisition.all.each do |t| %>
+ <%= t.render(request,params,current_user,@module_app) %>
+<% end %>
<% flash.each do |key, msg| %>
diff --git a/lib/orbit_app/helper/context_link_renderer.rb b/lib/orbit_app/helper/context_link_renderer.rb
index a34f6cb4..d4014fae 100644
--- a/lib/orbit_app/helper/context_link_renderer.rb
+++ b/lib/orbit_app/helper/context_link_renderer.rb
@@ -1,11 +1,12 @@
module ContextLinkRenderer
include Renderer
- def render(request,params,module_app,user)
- @module_app = module_app
+ def render(request,params,current_module_app,current_user,belong_module_app)
+ @current_module_app = current_module_app
+ @belong_module_app = belong_module_app
@request = request
@params = params
- @current_user = user
+ @current_user = current_user
if display?
content_tag :li, link_to((I18n.t(@label_i18n) + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, eval(@path)), :class => (active? ? 'active' : nil)
end
@@ -18,9 +19,9 @@ protected
when :all
true
when :manager
- @module_app.is_manager? @current_user
+ @belong_module_app.is_manager? @current_user
when :sub_manager
- @module_app.is_sub_manager? @current_user
+ @belong_module_app.is_sub_manager? @current_user
else
(eval(available_for_in_sym).include? @current_user rescue false)
end # of case
diff --git a/lib/orbit_app/helper/side_bar_renderer.rb b/lib/orbit_app/helper/side_bar_renderer.rb
index 3fd680ef..ba6f7c7d 100644
--- a/lib/orbit_app/helper/side_bar_renderer.rb
+++ b/lib/orbit_app/helper/side_bar_renderer.rb
@@ -2,8 +2,9 @@ module SideBarRenderer
include Renderer
include AdminHelper
- def render(request,params,user,module_app)
- @module_app = module_app
+ def render(request,params,user,current_module_app)
+ @belong_module_app = get_module_app
+ @current_module_app = current_module_app
@request = request
@params = params
@current_user = user
@@ -12,7 +13,7 @@ module SideBarRenderer
buf = link_to( content_tag(:i, nil, :class => @icon_class ) + content_tag(:span, I18n.t( @head_label )), eval(@head_link))
buf << content_tag( :ul, :class => ("nav nav-list active") )do # visible_for_controllers('bulletins', '/panel/announcement/back_end/tags', 'bulletin_categorys', 'approvals')||active_for_ob_auths_object("BulletinCategory"))
@context_links.sort_by! {| obj | obj.priority}.collect do |link|
- link.render(request,params,@module_app,@current_user)
+ link.render(request,params,@current_module_app,@current_user,@belong_module_app)
end.join.html_safe
end
end
@@ -24,7 +25,7 @@ module SideBarRenderer
def display? #控制sidebar 要不要算圖
if is_manager? || is_admin? #如果是系統管理員 或 是模組管理員
true
- elsif (@module_app.open rescue false) # 如果app 被設定成 開放
+ elsif (@current_module_app.open rescue false) # 如果app 被設定成 開放
true
elsif is_member? #如果app 是封閉 那至少需要是 member
true
diff --git a/lib/orbit_app/module/registration.rb b/lib/orbit_app/module/registration.rb
index d94de028..4c64f629 100644
--- a/lib/orbit_app/module/registration.rb
+++ b/lib/orbit_app/module/registration.rb
@@ -39,8 +39,12 @@ module OrbitApp
setup_module_app
end
+ def get_module_app
+ ModuleApp.first(conditions: {:key=>@key,:title=>name})
+ end
+
def setup_module_app
- module_app = ModuleApp.first(conditions: {:key=>@key,:title=>name})
+ module_app = get_module_app
module_app = ModuleApp.new(:key=>@key,:title=>name) if module_app.nil?
begin
@@ -90,7 +94,7 @@ module OrbitApp
end
def side_bar(&block)
- @side_bar = SideBarRegisition::SideBar.new(@name,@key,&block)
+ @side_bar = SideBarRegisition::SideBar.new(@name,@key,method(:get_module_app),&block)
end
def personal_plugin(params)
diff --git a/lib/orbit_app/module/side_bar.rb b/lib/orbit_app/module/side_bar.rb
index 7d733bfa..050df87a 100644
--- a/lib/orbit_app/module/side_bar.rb
+++ b/lib/orbit_app/module/side_bar.rb
@@ -17,6 +17,10 @@ module OrbitApp
return nil
end
+ def render_all(request,params,user,current_module_app)
+ @@side_bars.collect{|t| t.render(request,params,user,current_module_app)}.join.html_safe
+ end
+
def all
return @@side_bars
end
@@ -37,7 +41,7 @@ module OrbitApp
# def is_manager?
# binding.pry
# end
- def initialize(name = '',key,&block)
+ def initialize(name = '',key,get_module_app,&block)
@head_label = name
@context_links = []
@available_for = []
@@ -47,12 +51,16 @@ module OrbitApp
@head_link = ""
@app_base_path = ''
@module_app_key = key
+ @get_module_app = get_module_app
block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given?
# setup_module_app(module_app_key)
finalize!
SideBarRegisition.add(self)
end
+ def get_module_app
+ @get_module_app.call
+ end
def head_label_i18n(var,options ={})
@head_label = var
@@ -76,7 +84,7 @@ module OrbitApp
end
def context_link(*var)
- var[1].merge!(:module_app_key=>@module_app_key) unless @module_app_key.nil?
+ var[1].merge!({:module_app_key=>@module_app_key,:get_module_app=>@get_module_app}) unless @module_app_key.nil?
new_context_link = ContextLink.new(*var)
@context_links << new_context_link
end
@@ -126,6 +134,11 @@ module OrbitApp
@active_for_object_auth = options[:active_for_object_auth] || []
@active_for_app_auth = options[:active_for_app_auth] || []
@module_app_key = options[:module_app_key]
+ @get_module_app = options[:get_module_app]
+ end
+
+ def get_module_app
+ @get_module_app.call
end
def active?
diff --git a/vendor/built_in_modules/ad_banner/init.rb b/vendor/built_in_modules/ad_banner/init.rb
new file mode 100644
index 00000000..6776ee0a
--- /dev/null
+++ b/vendor/built_in_modules/ad_banner/init.rb
@@ -0,0 +1,49 @@
+module AdBanner
+ OrbitApp.registration "AdBanner",:type=> 'ModuleApp' do
+ module_label 'ad_banner.ad_banner'
+ base_url File.expand_path File.dirname(__FILE__)
+ # personal_plugin :enable => true,:path=>"panel/ad_banner/plugin/profile",:i18n=>'admin.ad_banner'
+
+ version "0.1"
+ organization "Rulingcom"
+ author "RD dep"
+ intro "I am intro"
+ update_info 'some update_info'
+
+ # front_end do
+ # app_page 'bulletins'
+ # end
+
+ # category ["BulletinCategory"]
+
+ # widgets do
+ # # default_widget do
+ # # query 'Bulletin.all'
+ # # image :image
+ # # end
+
+ # # categories_query 'BulletinCategory.all'
+ # # tags_query 'AdBannerTag.all'
+
+ # # customize_widget "index","ad_banner.widget.index",:fields=>["title","category","postdate"],:style=>["cu_style_1","cu_style_2","cu_style_3","cu_style_4","cu_style_5"]
+ # # customize_widget "bulletins_and_web_links","ad_banner.widget.bulletins_and_web_links"
+
+ # # item "index","ad_banner.widget.index",:default_template=>true,:fields=>["title","category","postdate"]
+ # # item "bulletins_and_web_links","ad_banner.widget.bulletins_and_web_links"
+ # end
+
+ side_bar do
+ head_label_i18n 'admin.ad_banner',:icon_class=>"icons-landscape"
+ available_for [:admin,:guest,:manager,:sub_manager]
+ active_for_controllers ({:private=>['ad_banners', 'ad_images']})
+
+ head_link_path "admin_ad_banners_path"
+
+ context_link 'module_authorization',
+ :link_path=>"admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {key: 'ad_banner'}))",
+ :priority=>6,
+ :active_for_app_auth => 'ad_banners',
+ :available_for => [:admin]
+ end
+ end
+end
diff --git a/vendor/built_in_modules/announcement/init.rb b/vendor/built_in_modules/announcement/init.rb
index a92ab14f..e2d81f81 100644
--- a/vendor/built_in_modules/announcement/init.rb
+++ b/vendor/built_in_modules/announcement/init.rb
@@ -32,7 +32,7 @@ module Announcement
end
side_bar do
- head_label_i18n 'admin.announcement',:icon_class=>"icons-announcement"
+ head_label_i18n 'admin.announcement',:icon_class=>"icons-megaphone"
available_for [:admin,:guest,:manager,:sub_manager]
active_for_controllers ({:private=>['bulletins', 'bulletin_categorys', 'approvals','tags']})
active_for_object_auth ['BulletinCategory']
@@ -75,7 +75,7 @@ module Announcement
:link_path=>"admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {title: 'Announcement'}))",
:priority=>6,
:active_for_app_auth => 'Announcement',
- :available_for => [:manager]
+ :available_for => [:admin]
end
end
end
diff --git a/vendor/built_in_modules/archive/init.rb b/vendor/built_in_modules/archive/init.rb
new file mode 100644
index 00000000..565b2cdf
--- /dev/null
+++ b/vendor/built_in_modules/archive/init.rb
@@ -0,0 +1,62 @@
+module Archive
+ OrbitApp.registration "Archive",:type=> 'ModuleApp' do
+ module_label 'miss_module_i18n.archive'
+ base_url File.expand_path File.dirname(__FILE__)
+ personal_plugin :enable => true,:path=>"panel/archive/plugin/profile",:i18n=>'admin.archive'
+
+ version "0.1"
+ organization "Rulingcom"
+ author "RD dep"
+ intro "I am intro"
+ update_info 'some update_info'
+
+ front_end do
+ app_page 'archive_files'
+ end
+
+ widgets do
+ # default_widget do
+ # query 'Bulletin.all'
+ # image :image
+ # end
+
+ # categories_query 'BulletinCategory.all'
+ # tags_query 'ArchiveTag.all'
+ customize_widget "archive_files","archive.widget.archive_files",:style=>[]
+ end
+
+ side_bar do
+ head_label_i18n 'miss_module_i18n.archive',:icon_class=>"icons-archive"
+ available_for [:admin,:guest,:manager,:sub_manager]
+ active_for_controllers ({:private=>['archive_file_categorys'],:public=>['panel/archive/back_end/tags']})
+ active_for_object_auth ['BulletinCategory']
+
+ head_link_path "panel_archive_back_end_archive_files_path"
+
+ context_link 'miss_module_i18n._archive.all',
+ :link_path=>"panel_archive_back_end_archive_files_path" ,
+ :priority=>1,
+ :active_for_action=>{:archive_file=>:index},
+ :available_for => [:all]
+
+ context_link 'add',
+ :link_path=>"new_panel_archive_back_end_archive_file_path" ,
+ :priority=>2,
+ :active_for_action=>{:archive_file=>:new},
+ :available_for => [:admin]
+
+ context_link 'categories',
+ :link_path=>"panel_archive_back_end_archive_file_categorys_path" ,
+ :priority=>3,
+ :active_for_action=>{:archive_file_categorys=>:index},
+ :available_for => [:manager]
+
+ context_link 'tags',
+ :link_path=>"panel_archive_back_end_tags_path" ,
+ :priority=>4,
+ # :active_for_action=>{:bulletin_categorys=>:index},
+ :available_for => [:admin]
+
+ end
+ end
+end
diff --git a/vendor/built_in_modules/calendar/init.rb b/vendor/built_in_modules/calendar/init.rb
new file mode 100644
index 00000000..fc318e6c
--- /dev/null
+++ b/vendor/built_in_modules/calendar/init.rb
@@ -0,0 +1,34 @@
+module Calendar
+ OrbitApp.registration "Calendar",:type=> 'ModuleApp' do
+ module_label 'miss_module_i18n.calendar'
+ base_url File.expand_path File.dirname(__FILE__)
+ # personal_plugin :enable => true,:path=>"panel/calendar/plugin/profile",:i18n=>'admin.calendar'
+
+ version "0.1"
+ organization "Rulingcom"
+ author "RD dep"
+ intro "I am intro"
+ update_info 'some update_info'
+
+ side_bar do
+ head_label_i18n 'miss_module_i18n.calendar',:icon_class=>"icons-calendar"
+ available_for [:admin,:guest,:manager,:sub_manager]
+ active_for_controllers ({:private=>['cals','calendar_categories'],:public=>['panel/calendar/back_end/tags']})
+
+
+ head_link_path "panel_calendar_back_end_cals_path"
+
+ context_link 'calendar.calendars',
+ :link_path=>"new_panel_calendar_back_end_cal_path" ,
+ :priority=>1,
+ :active_for_action=>{:cals=>:new},
+ :available_for => [:manager]
+
+ context_link 'tags',
+ :link_path=>"panel_calendar_back_end_tags_path" ,
+ :priority=>4,
+ # :active_for_action=>{:bulletin_categorys=>:index},
+ :available_for => [:manager]
+ end
+ end
+end
diff --git a/vendor/built_in_modules/gallery/init.rb b/vendor/built_in_modules/gallery/init.rb
new file mode 100644
index 00000000..e7db1e81
--- /dev/null
+++ b/vendor/built_in_modules/gallery/init.rb
@@ -0,0 +1,59 @@
+module Gallery
+ OrbitApp.registration "Gallery",:type=> 'ModuleApp' do
+ module_label 'miss_module_i18n.gallery'
+ base_url File.expand_path File.dirname(__FILE__)
+ # personal_plugin :enable => true,:path=>"panel/gallery/plugin/profile",:i18n=>'admin.gallery'
+
+ version "0.1"
+ organization "Rulingcom"
+ author "Visual dep"
+ intro "A simple and amazing gallery"
+ update_info 'some update_info'
+
+ front_end do
+ app_page 'albums'
+ end
+
+ category ["gallery_categories"]
+
+ widgets do
+ # default_widget do
+ # query 'Bulletin.all'
+ # image :image
+ # end
+
+ categories_query 'GalleryCategory.all'
+ # tags_query 'GalleryTag.all'
+
+ customize_widget "albums","gallery.widget.albums",:fields=>[],:style=>[]
+
+ end
+
+ side_bar do
+ head_label_i18n 'miss_module_i18n.gallery',:icon_class=>"icons-pictures"
+ available_for [:admin,:guest,:manager,:sub_manager]
+ active_for_controllers ({:private=>['albums','album_images','gallery_categories','/panel/gallery/back_end/tags']})
+ active_for_object_auth ['BulletinCategory']
+
+ head_link_path "panel_gallery_back_end_albums_path"
+
+ context_link 'gallery.categories',
+ :link_path=>"panel_gallery_back_end_gallery_categories_path" ,
+ :priority=>3,
+ :active_for_action=>{:gallery_categories=>:index},
+ :available_for => [:manager]
+
+ context_link 'tags',
+ :link_path=>"panel_gallery_back_end_tags_path" ,
+ :priority=>4,
+ # :active_for_action=>{:bulletin_categorys=>:index},
+ :available_for => [:manager]
+
+ context_link 'module_authorization',
+ :link_path=>"admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {key: 'gallery'}))",
+ :priority=>6,
+ :active_for_app_auth => 'gallery',
+ :available_for => [:admin]
+ end
+ end
+end
diff --git a/vendor/built_in_modules/gprs/init.rb b/vendor/built_in_modules/gprs/init.rb
new file mode 100644
index 00000000..99de7772
--- /dev/null
+++ b/vendor/built_in_modules/gprs/init.rb
@@ -0,0 +1,43 @@
+module Location
+ OrbitApp.registration "Location",:type=> 'ModuleApp' do
+ module_label 'miss_module_i18n.location'
+ base_url File.expand_path File.dirname(__FILE__)
+ # personal_plugin :enable => true,:path=>"panel/location/plugin/profile",:i18n=>'admin.location'
+
+ # version "0.1"
+ # organization "Rulingcom"
+ # author "RD dep"
+ # intro "I am intro"
+ # update_info 'some update_info'
+
+ # front_end do
+ # app_page 'bulletins'
+ # end
+
+ # category ["BulletinCategory"]
+
+ # widgets do
+ # default_widget do
+ # query 'Bulletin.all'
+ # image :image
+ # end
+
+ # categories_query 'BulletinCategory.all'
+ # tags_query 'LocationTag.all'
+
+ # customize_widget "index","location.widget.index",:fields=>["title","category","postdate"],:style=>["cu_style_1","cu_style_2","cu_style_3","cu_style_4","cu_style_5"]
+ # customize_widget "bulletins_and_web_links","location.widget.bulletins_and_web_links"
+ # # item "index","location.widget.index",:default_template=>true,:fields=>["title","category","postdate"]
+ # # item "bulletins_and_web_links","location.widget.bulletins_and_web_links"
+ # end
+
+ side_bar do
+ head_label_i18n 'miss_module_i18n.location',:icon_class=>"icons-location"
+ available_for [:admin,:guest,:manager,:sub_manager]
+ active_for_controllers ({:private=>['locations']})
+
+ head_link_path "panel_gprs_back_end_locations_path"
+
+ end
+ end
+end
diff --git a/vendor/built_in_modules/miss_module/config/locales/zh_tw.yml b/vendor/built_in_modules/miss_module/config/locales/zh_tw.yml
new file mode 100644
index 00000000..b91058c4
--- /dev/null
+++ b/vendor/built_in_modules/miss_module/config/locales/zh_tw.yml
@@ -0,0 +1,10 @@
+zh_tw:
+
+ miss_module_i18n:
+ archive: 檔案室
+ _archive:
+ all: 全部檔案
+ calendar: 日曆模組
+ calendars: 日曆
+ gallery: 相簿
+ location: Location
diff --git a/vendor/built_in_modules/page_content/init.rb b/vendor/built_in_modules/page_content/init.rb
new file mode 100644
index 00000000..2bf8a2f7
--- /dev/null
+++ b/vendor/built_in_modules/page_content/init.rb
@@ -0,0 +1,33 @@
+module PageContent
+
+ OrbitApp.registration "PageContent",:type=> 'ModuleApp' do
+ module_label 'page'
+ base_url File.expand_path File.dirname(__FILE__)
+ # personal_plugin :enable => true,:path=>"panel/announcement/plugin/profile",:i18n=>'admin.announcement'
+
+ version "0.1"
+ organization "Rulingcom"
+ author "RD dep"
+ intro "I am intro"
+ update_info 'some update_info'
+
+ front_end do
+ app_page 'page_contexts'
+ end
+
+ side_bar do
+ head_label_i18n 'page',:icon_class=>"icons-page"
+ available_for [:admin,:guest,:manager,:sub_manager]
+ active_for_controllers ({:private=>['page_contexts']})
+ active_for_object_auth ['PageContext']
+
+ head_link_path "panel_page_content_back_end_page_contexts_path"
+
+ context_link 'module_authorization',
+ :link_path=>"admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {key: 'page_content'}))",
+ :priority=>1,
+ :active_for_app_auth => 'PageContext',
+ :available_for => [:admin]
+ end
+ end
+end
diff --git a/vendor/built_in_modules/web_resource/init.rb b/vendor/built_in_modules/web_resource/init.rb
new file mode 100644
index 00000000..c581506b
--- /dev/null
+++ b/vendor/built_in_modules/web_resource/init.rb
@@ -0,0 +1,67 @@
+module WebResource
+ OrbitApp.registration "WebResource",:type=> 'ModuleApp' do
+ module_label 'link'
+ base_url File.expand_path File.dirname(__FILE__)
+ # personal_plugin :enable => true,:path=>"panel/web_resource/plugin/profile",:i18n=>'admin.web_resource'
+
+ version "0.1"
+ organization "Rulingcom"
+ author "RD dep"
+ intro "I am intro"
+ update_info 'some update_info'
+
+ category ["WebLinkCategory"]
+
+ widgets do
+ # default_widget do
+ # query 'Bulletin.all'
+ # image :image
+ # end
+
+ categories_query 'BulletinCategory.all'
+ tags_query 'WebResourceTag.all'
+
+ customize_widget "home_list","web_resource.widget.home_list"
+
+ end
+
+ side_bar do
+ head_label_i18n 'link',:icon_class=>"icons-link"
+ available_for [:admin,:guest,:manager,:sub_manager]
+ active_for_controllers ({:private=>['web_links', 'web_link_categorys']})
+ active_for_object_auth ['WebLinkCategory']
+
+ head_link_path "panel_web_resource_back_end_web_links_path"
+
+ context_link 'list_',
+ :link_path=>"panel_web_resource_back_end_web_links_path" ,
+ :priority=>1,
+ :active_for_action=>{:bulletins=>:index},
+ :available_for => [:all]
+
+ context_link 'link',
+ :link_path=>"new_panel_web_resource_back_end_web_link_path" ,
+ :priority=>2,
+ :active_for_action=>{:bulletins=>:new},
+ :available_for => [:sub_manager]
+
+ context_link 'categories',
+ :link_path=>"panel_web_resource_back_end_web_link_categorys_path" ,
+ :priority=>3,
+ :active_for_action=>{:bulletin_categorys=>:index},
+ :available_for => [:manager]
+
+ context_link 'tags',
+ :link_path=>"panel_web_resource_back_end_tags_path" ,
+ :priority=>4,
+ # :active_for_action=>{:bulletin_categorys=>:index},
+ :available_for => [:manager]
+
+ context_link 'module_authorization',
+ :link_path=>"admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {key: 'web_resource'}))",
+ :priority=>6,
+ :active_for_app_auth => 'web_resource',
+ :available_for => [:admin]
+ end
+ end
+end