diff --git a/app/assets/javascripts/page_edit.js b/app/assets/javascripts/page_edit.js index 50e974b4..25348105 100644 --- a/app/assets/javascripts/page_edit.js +++ b/app/assets/javascripts/page_edit.js @@ -6,7 +6,7 @@ $("#page_design_id").live('change', function() { $.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_themes'); }); -$("#page_module_app").live('change', function() { +$("#page_module_app_id").live('change', function() { var app_id = $(this).val(); if(app_id!=''){ $.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_frontend_pages',function(data, textStatus){ @@ -16,6 +16,6 @@ $("#page_module_app").live('change', function() { }); } else{ - $("#app_page_url").remove(); + $("#app_page_url").children().remove(); } }); diff --git a/app/assets/javascripts/rss.js b/app/assets/javascripts/rss.js index e993df79..93b52140 100644 --- a/app/assets/javascripts/rss.js +++ b/app/assets/javascripts/rss.js @@ -392,7 +392,6 @@ modalWindow : function(settings,callbackFn){ tempwidth=maxwidth; }else{tempwidth="auto";} - $rss("body").append('
'); $rss("#rgsheath").css({background: "#000", width: "100%", position: "fixed", top: 0, left: 0,opacity:0.9,'z-index':199}); $rss("body").append('
'); diff --git a/app/controllers/admin/app_auths_controller.rb b/app/controllers/admin/app_auths_controller.rb index 6f3f1c3d..e925b857 100644 --- a/app/controllers/admin/app_auths_controller.rb +++ b/app/controllers/admin/app_auths_controller.rb @@ -4,14 +4,15 @@ class Admin::AppAuthsController < ApplicationController before_filter :is_admin? def index - @user_roles = UserRole.all.entries - apps = Purchase.where(:type =>"App") - @app_auth_data = apps.entries.map do |app| - app_c = eval(app.app_controller) - obj = app_c.new - obj_auth = obj.send "auth" - [:app_obj => app,:auth_field => obj_auth] - end + # @roles = Role.all.entries + # apps = Purchase.where(:type =>"App") + # @app_auth_data = apps.entries.map do |app| + # app_c = eval(app.app_controller) + # obj = app_c.new + # obj_auth = obj.send "auth" + # [:app_obj => app,:auth_field => obj_auth] + # end + @module_apps = ModuleApp.all end end \ No newline at end of file diff --git a/app/controllers/admin/module_apps_controller.rb b/app/controllers/admin/module_apps_controller.rb index 55be4135..142830f1 100644 --- a/app/controllers/admin/module_apps_controller.rb +++ b/app/controllers/admin/module_apps_controller.rb @@ -1,9 +1,33 @@ class Admin::ModuleAppsController < ApplicationController + layout "admin" -def reload_frontend_pages - @module_app = ModuleApp.find(params[:id]) - respond_to do |format| - format.js {} + def index + @module_apps = ModuleApp.all.entries + end + + + def reload_frontend_pages + @module_app = ModuleApp.find(params[:id]) + respond_to do |format| + format.js {} + end + end + + def edit + @module_app = ModuleApp.find(params[:id]) + + end + + def update + @module_app = ModuleApp.find(params[:id]) + unless params['module_app']['enable_frontend'].nil? + @module_app.update_attribute('enable_frontend',params['module_app']['enable_frontend']) + @module_app.save! + end + @attribute = @module_app + respond_to do |format| + format.html { redirect_to :action => :index } + format.js { render 'admin/attributes/toggle_enable' } + end end -end end \ No newline at end of file diff --git a/app/controllers/admin/page_parts_controller.rb b/app/controllers/admin/page_parts_controller.rb index f77a7782..71e39ae1 100644 --- a/app/controllers/admin/page_parts_controller.rb +++ b/app/controllers/admin/page_parts_controller.rb @@ -28,7 +28,7 @@ class Admin::PagePartsController < ApplicationController @partial = 'edit_text' @part_locale = params[:part_locale] || I18n.locale.to_s when 'module' - @plugins=[{:module=>"Blog",:widgets=>[{:name=>"Blog",:path=>"panel/blog/widget_latest_post"},{:name=>"Blog",:path=>"panel/blog/widget_index"}]}] + @plugins=[{:module=>"Blog",:widgets=>[{:name=>"Blog",:path=>"panel/new_blog/widget_latest_post"},{:name=>"Blog",:path=>"panel/new_blog/widget_index"}]}] when 'snippet' end end diff --git a/app/controllers/admin/pages_controller.rb b/app/controllers/admin/pages_controller.rb index 23f58444..c547d5f2 100644 --- a/app/controllers/admin/pages_controller.rb +++ b/app/controllers/admin/pages_controller.rb @@ -32,6 +32,7 @@ class Admin::PagesController < ApplicationController @i18n_variable = @item.i18n_variable @designs = Design.all.entries @design = @item.design + @app_frontend_urls = @item.module_app.app_pages end def create diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index cc64e130..6bdac5ee 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -5,9 +5,16 @@ class ApplicationController < ActionController::Base helper :all before_filter :set_locale, :set_site + + def front_end_available(module_app_title='') + app_controller = ModuleApp.first(conditions: {:title => module_app_title} ) + unless app_controller.enable_frontend? + render :nothing + end + end def get_all_app_engines - ary = ["vender/plugins/NewBlog"] + ary = ["vender/plugins/new_blog"] app_engines = ary.collect{|t| Rails::Engine.find t } diff --git a/app/controllers/obit_frontend_component_controller.rb b/app/controllers/obit_frontend_component_controller.rb new file mode 100644 index 00000000..d5bfaac6 --- /dev/null +++ b/app/controllers/obit_frontend_component_controller.rb @@ -0,0 +1,4 @@ +class ObitFrontendComponentController< ApplicationController + before_filter {|c| c.front_end_available(@app_title)} + layout 'production' +end \ No newline at end of file diff --git a/app/controllers/obit_frontend_controller.rb b/app/controllers/obit_frontend_controller.rb new file mode 100644 index 00000000..fb42ac78 --- /dev/null +++ b/app/controllers/obit_frontend_controller.rb @@ -0,0 +1,3 @@ +class ObitFrontendController< ObitFrontendComponentController + +end \ No newline at end of file diff --git a/app/controllers/obit_widget_controller.rb b/app/controllers/obit_widget_controller.rb new file mode 100644 index 00000000..e0a9746d --- /dev/null +++ b/app/controllers/obit_widget_controller.rb @@ -0,0 +1,3 @@ +class ObitWidgetController< ObitFrontendComponentController + +end \ No newline at end of file diff --git a/app/helpers/admin/app_auth_helper.rb b/app/helpers/admin/app_auth_helper.rb new file mode 100644 index 00000000..fe63a2a6 --- /dev/null +++ b/app/helpers/admin/app_auth_helper.rb @@ -0,0 +1,6 @@ +module Admin::AppAuthHelper + 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' + end +end \ No newline at end of file diff --git a/app/models/app_auth.rb b/app/models/app_auth.rb index 9602fda0..b31add3c 100644 --- a/app/models/app_auth.rb +++ b/app/models/app_auth.rb @@ -15,55 +15,72 @@ class AppAuth has_and_belongs_to_many :roles + has_and_belongs_to_many :sub_roles + + attr_protected :roles,:sub_roles,:privilege_users,:blocked_users,:users + + def add_role role + add_operation(:roles,role) + end + + def add_sub_role role + add_operation(:sub_roles,role) + end + + def remove_role role + remove_operation(:roles,role) + end + + def remove_sub_role role + remove_operation(:sub_roles,role) + end def add_user_to_black_list user - unless self.blocked_users.include?(user) - self.blocked_users << user - self.save! - else - false #should put error message for user existed in list already - end + add_operation(:blocked_users,user) end - def remove_user_from_black_list user - if self.blocked_users.include? user - self.blocked_users.delete user + remove_operation(:blocked_users,user) + end + + def add_user_to_privilege_list user + add_operation(:privilege_users,user) + end + + def remove_user_from_privilege_list user + remove_operation(:privilege_users,user) + end + + def remove_operation(item,obj) + if (self.send item).include? obj + (self.send item).delete obj self.save! else false #should put error message for user not existed in list - end + end end - - def add_user_to_privilege_list user - unless self.privilege_users.include? user - self.privilege_users << user + def add_operation(item,obj) + unless (self.send item).include?(obj) + (self.send item) << obj self.save! else false #should put error message for user existed in list already end end - - def remove_user_from_privilege_list user - if self.privilege_users.include? user - self.privilege_users.delete user - self.save! - else - false #should put error message for user not existed in list - end - end - def auth_users if self.all? User.all.entries else - ary= self.roles.collect do |role| - role.users + ary=[] + [:roles,:sub_roles].each do |t_role| + ary += (self.send t_role).collect do |role| + role.users + end end ary << self.privilege_users - ary.flatten! + ary.flatten!.uniq end end diff --git a/app/models/module_app.rb b/app/models/module_app.rb index 31a02025..d398f7ef 100644 --- a/app/models/module_app.rb +++ b/app/models/module_app.rb @@ -9,6 +9,14 @@ class ModuleApp field :intro field :update_info field :create_date + field :enable_frontend,type: Boolean + + field :app_pages ,type: Array + field :widgets ,type: Array + + has_one :app_auth,dependent: :delete + + field :app_pages ,type: Array diff --git a/app/models/user/user.rb b/app/models/user/user.rb index 1e956b80..60199ce7 100644 --- a/app/models/user/user.rb +++ b/app/models/user/user.rb @@ -19,7 +19,10 @@ class User accepts_nested_attributes_for :attribute_values, :allow_destroy => true def avb_apps - query = AppAuth.any_of({all: true},{privilege_user_ids: self.id},{roles: self.role.id}).excludes(blocked_user_ids: self.id) + sub_role_ids_ary=self.sub_roles.collect{|t| t.id} + query1 = AppAuth.any_in({sub_role_ids: sub_role_ids_ary}).excludes(blocked_user_ids: self.id) + query2 = AppAuth.any_of({all: true},{privilege_user_ids: self.id},{role_ids: self.role.id}).excludes(blocked_user_ids: self.id) + (query1 + query2).uniq end def name diff --git a/app/views/admin/app_auths/index.html.erb b/app/views/admin/app_auths/index.html.erb index 0d804b2b..392f8d2b 100644 --- a/app/views/admin/app_auths/index.html.erb +++ b/app/views/admin/app_auths/index.html.erb @@ -1,32 +1,52 @@ <% content_for :secondary do %> -
-
-

User Role

- -
-
-<% end -%> - -

<%= t('admin.list_app_auths') %>

- - - - - - - -<% @app_auth_data.each do |app| %> - - - <% app[0][:auth_field].each do |unit| %> - - <%end%> - + <% #render 'side_bar' %> <% end %> -
<%= t('admin.app.name') %><%= t('admin.description') %>
<%= app[0][:app_obj].title %> - <%= render :partial => "auth_unit",:locals => {:unit => unit } %> -
+ +
+ <%= flash_messages %> +
+ <% #link_to t('admin.new_user'), new_admin_user_path, :class => 'new' %> +
+ + + + + + + + + + + + + + <% @module_apps.each do |module_app| %> + "> + + + + + + + + + + + + <% end %> + +
<%= t('admin.app.title') %><%= t('admin.app.description') %><%= t('admin.app.use_status') %><%= t('admin.app.autdor') %><%= t('admin.app.organization') %><%= t('admin.app.version') %><%= t('admin.action') %>
<%= module_app.title %><%= module_app.intro %> + <% attribute_type = "module_app" %> + <% attribute = module_app %> + <%= link_to t(:enable), admin_module_app_path(attribute, :authenticity_token => form_authenticity_token, :module_app => {:enable_frontend => true}), :remote => true, :method => :put, :id => "disable_#{attribute.id}", :style => "display:#{attribute.enable_frontend ? 'none' : ''}", :class => 'switch' %> + <%= link_to t(:disable), admin_module_app_path(attribute, :authenticity_token => form_authenticity_token, :module_app => {:enable_frontend => false}), :remote => true, :method => :put, :id => "enable_#{attribute.id}", :style => "display:#{attribute.enable_frontend ? '' : 'none'}", :class => 'switch' %> + + <%= module_app.version %> + <%= link_to t(:show), admin_module_app_path(module_app), :class => 'show' %> + <%= link_to t(:edit), edit_admin_module_app_path(module_app), :class => 'edit' %> + <%= link_to t(:delete), admin_module_app_path(module_app), :class => 'delete', :confirm => t('sure?'), :method => :delete %> +
+
+ <%# link_to t('admin.new_user'), new_admin_user_path, :class => 'new' %> +
+
diff --git a/app/views/admin/designs/_form.html.erb b/app/views/admin/designs/_form.html.erb index b6ba7cb2..fd579e5e 100644 --- a/app/views/admin/designs/_form.html.erb +++ b/app/views/admin/designs/_form.html.erb @@ -38,7 +38,7 @@ <%= f.hidden_field :to_save, :value => true %> <% end %> <% else %> - <%= File.basename (@design.default_css.file.url) %> + <%= File.basename (@design.default_css.file.url) rescue "" %> <% end %>

diff --git a/app/views/admin/designs/_new.html.erb b/app/views/admin/designs/_new.html.erb index ded2237a..a4aba6c9 100644 --- a/app/views/admin/designs/_new.html.erb +++ b/app/views/admin/designs/_new.html.erb @@ -1,6 +1,6 @@

<%= t('admin.new_design') %>

-<%= form_for :design, :url => admin_designs_path do |f| %> +<%= form_for @design, :url => admin_design_path(@design),:html => {:multipart => true} do |f| %> <%= f.error_messages %> <%= render :partial => "form", :locals => { :f => f } %> diff --git a/app/views/admin/module_apps/_app_selector.html.erb b/app/views/admin/module_apps/_app_selector.html.erb index 90c2aee1..c20a3885 100644 --- a/app/views/admin/module_apps/_app_selector.html.erb +++ b/app/views/admin/module_apps/_app_selector.html.erb @@ -1 +1 @@ -<%= f.select :module_app, @apps.collect { |t| [t.title.capitalize, t.id] }, {:include_blank => true} ,{:rel => admin_module_apps_path } %> \ No newline at end of file +<%= f.select :module_app_id, @apps.collect { |t| [t.title.capitalize, t.id] }, {:include_blank => true} ,{:rel => admin_module_apps_path } %> diff --git a/vendor/built_in_modules/NewBlog/app/assets/images/NewBlog/.gitkeep b/app/views/admin/module_apps/index.html.erb similarity index 100% rename from vendor/built_in_modules/NewBlog/app/assets/images/NewBlog/.gitkeep rename to app/views/admin/module_apps/index.html.erb diff --git a/app/views/admin/pages/_form.html.erb b/app/views/admin/pages/_form.html.erb index d0c00d16..8223f0bb 100644 --- a/app/views/admin/pages/_form.html.erb +++ b/app/views/admin/pages/_form.html.erb @@ -33,7 +33,7 @@

<%= t('admin.module_app') %> <%= render :partial => "admin/module_apps/app_selector", :locals => { :f => f } %> - + <%= select('page','app_frontend_url', @app_frontend_urls ) rescue ''%>

<%= f.label :is_published, "#{t('admin.is_published')} ?" %> diff --git a/app/views/admin/roles/_sub_role.html.erb b/app/views/admin/roles/_sub_role.html.erb index 4c39229c..ca20890f 100644 --- a/app/views/admin/roles/_sub_role.html.erb +++ b/app/views/admin/roles/_sub_role.html.erb @@ -1,59 +1,59 @@ -

- - - - - <% @site_valid_locales.each do |locale| %> - - <% end %> - - - - - - <%= f.fields_for :i18n_variable, (sub_role.new_record? ? sub_role.build_i18n_variable : sub_role.i18n_variable) do |f| %> - <% @site_valid_locales.each do |locale| %> - - <% end %> +
+
<%= t('admin.key') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %>
<%= sub_role.new_record? ? (f.text_field :key, {:style => "width:150px"}) : sub_role.key %><%= f.text_field locale, :style => "width:150px" %>
+ + + + <% @site_valid_locales.each do |locale| %> + + <% end %> + + + + + + <%= f.fields_for :i18n_variable, (sub_role.new_record? ? sub_role.build_i18n_variable : sub_role.i18n_variable) do |f| %> + <% @site_valid_locales.each do |locale| %> + + <% end %> + <% end %> + + +
<%= t('admin.key') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %>
<%= sub_role.new_record? ? (f.text_field :key, {:style => "width:150px"}) : sub_role.key %><%= f.text_field locale, :style => "width:150px" %>
+
+

Attributes

+
+ + + + + + <% @site_valid_locales.each do |locale| %> + + <% end %> + + + + + + + + + + + <% sub_role.attribute_fields.each do |attribute_field| %> + <%= render :partial => 'attribute_field', :object => attribute_field, :locals => {:f => f} %> <% end %> - - -
<%= t('admin.key') %><%= t('admin.multilingual') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %><%= t('admin.type')%> 
+
+ <%= hidden_field_tag 'attribute_field_count', sub_role.attribute_fields.count %> + <%= t(:add) %> + <%= hidden_field_tag 'sub_role_temp_id', (i rescue 'new_sub_roles') %> +
+
-
-

Attributes

-
- - - - - - <% @site_valid_locales.each do |locale| %> - - <% end %> - - - - - - - - - - - <% sub_role.attribute_fields.each do |attribute_field| %> - <%= render :partial => 'attribute_field', :object => attribute_field, :locals => {:f => f} %> - <% end %> - -
<%= t('admin.key') %><%= t('admin.multilingual') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %><%= t('admin.type')%> 
-
- <%= hidden_field_tag 'attribute_field_count', sub_role.attribute_fields.count %> - <%= t(:add) %> - <%= hidden_field_tag 'sub_role_temp_id', (i rescue 'new_sub_roles') %> -
-
-
+ +
+
<% content_for :page_specific_javascript do %>