diff --git a/Gemfile b/Gemfile
index 38a94697..d6f88b3e 100644
--- a/Gemfile
+++ b/Gemfile
@@ -19,6 +19,8 @@ gem 'sprockets'
gem 'radius'
+gem 'exception_notification'
+
# For linux
# gem 'therubyracer'
diff --git a/Gemfile.lock b/Gemfile.lock
index 6cad44d4..d7c74ccf 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -70,6 +70,8 @@ GEM
warden (~> 1.1)
diff-lcs (1.1.3)
erubis (2.7.0)
+ exception_notification (2.5.2)
+ actionmailer (>= 3.0.4)
execjs (1.2.9)
multi_json (~> 1.0)
factory_girl (2.3.2)
@@ -97,7 +99,7 @@ GEM
multi_json (1.0.4)
orm_adapter (0.0.5)
polyglot (0.3.3)
- rack (1.3.5)
+ rack (1.3.6)
rack-cache (1.1)
rack (>= 0.4)
rack-mount (0.8.3)
@@ -196,6 +198,7 @@ DEPENDENCIES
database_cleaner
delorean
devise
+ exception_notification
execjs
factory_girl_rails
jquery-rails
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
-
- <% @roles.each do |role| %>
- - <%= link_to content_tag(:span, "Role") %>
- <% end -%>
-
-
-
-<% end -%>
-
-<%= t('admin.list_app_auths') %>
-
-
-
- <%= t('admin.app.name') %> |
- <%= t('admin.description') %> |
-
-
-<% @app_auth_data.each do |app| %>
-
- <%= app[0][:app_obj].title %> |
- <% app[0][:auth_field].each do |unit| %>
-
- <%= render :partial => "auth_unit",:locals => {:unit => unit } %>
- |
- <%end%>
-
+ <% #render 'side_bar' %>
<% end %>
-
+
+
+ <%= flash_messages %>
+
+ <% #link_to t('admin.new_user'), new_admin_user_path, :class => 'new' %>
+
+
+
+
+ <%= 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_apps.each do |module_app| %>
+ ">
+ <%= 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.author %> |
+ <%= module_app.organization %> |
+ <%= 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 %>
+ |
+
+
+ |
+
+ <% end %>
+
+
+
+ <%# 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 @@
-
+
<% content_for :page_specific_javascript do %>