diff --git a/app/controllers/admin/users_new_interface_controller.rb b/app/controllers/admin/users_new_interface_controller.rb index f0aaef73..4c258087 100644 --- a/app/controllers/admin/users_new_interface_controller.rb +++ b/app/controllers/admin/users_new_interface_controller.rb @@ -26,6 +26,8 @@ class Admin::UsersNewInterfaceController < ApplicationController def show @user = User.find(params[:id]) + @plugins = OrbitApp::Module::Registration.all + @profile_data = [] @teacher_data = [] @student_data = [] @@ -47,6 +49,12 @@ class Admin::UsersNewInterfaceController < ApplicationController @staff_data.push({:name => att_val.attribute_field.title,:value =>eval("att_val.#{att_val.key}")}) if att_val.attribute_field.role.key=="staff_data"rescue false } + if(!params[:show_plugin_profile].nil?) + @right_partial = OrbitApp::Plugin::Registration.find_by_key(params[:show_plugin_profile]).profile_partial_path rescue 'plugin_summary' + else + @right_partial = "plugin_summary" + end + # binding.pry # @user.attribute_values.each{|att_val| # @teacher_data.push({:name => att_val.attribute_field.title,:value =>att_val[I18n.locale]}) diff --git a/app/views/admin/users_new_interface/plugin_dashbroad.html.erb b/app/views/admin/users_new_interface/plugin_dashbroad.html.erb new file mode 100644 index 00000000..7cd090b5 --- /dev/null +++ b/app/views/admin/users_new_interface/plugin_dashbroad.html.erb @@ -0,0 +1,6 @@ +
+ <% #binding.pry%> + <%= render :partial=> 'plugin_summary'%> + <%= render :partial=> 'plugin_summary'%> + <%= render :partial=> 'plugin_summary'%> +
\ No newline at end of file diff --git a/app/views/admin/users_new_interface/show.html.erb b/app/views/admin/users_new_interface/show.html.erb index c70a1d98..262b2db9 100644 --- a/app/views/admin/users_new_interface/show.html.erb +++ b/app/views/admin/users_new_interface/show.html.erb @@ -6,23 +6,20 @@
-
- <% #binding.pry%> - <%= render :partial=> 'plugin_summary'%> - <%= render :partial=> 'plugin_summary'%> - <%= render :partial=> 'plugin_summary'%> -
+ <%=render :partial=> @right_partial%>
diff --git a/lib/orbit_app.rb b/lib/orbit_app.rb index d171a5a6..b0e5a735 100644 --- a/lib/orbit_app.rb +++ b/lib/orbit_app.rb @@ -1,8 +1,10 @@ require "orbit_app/summary" require "orbit_app/dsl" -require "orbit_app/backend_side_bar" -require "orbit_app/plugin/plugin_summary" -require "orbit_app/module/module_summary" +require "orbit_app/module/backend_side_bar" +require "orbit_app/plugin/summary" +require "orbit_app/plugin/registration" +require "orbit_app/module/summary" +require "orbit_app/module/registration" module OrbitApp extend DSL diff --git a/lib/orbit_app/backend_side_bar.rb b/lib/orbit_app/backend_side_bar.rb deleted file mode 100644 index a4f3728e..00000000 --- a/lib/orbit_app/backend_side_bar.rb +++ /dev/null @@ -1,15 +0,0 @@ -module OrbitApp - class BackendSideBar - attr_reader :name - - def initialize(name, &block) - @name = name - block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given? - end - - def item(*args) - - end - - end -end \ No newline at end of file diff --git a/lib/orbit_app/dsl.rb b/lib/orbit_app/dsl.rb index c414d663..95bc7cce 100644 --- a/lib/orbit_app/dsl.rb +++ b/lib/orbit_app/dsl.rb @@ -1,16 +1,26 @@ module OrbitApp module DSL - def backend_side_bar(name,&block) - BackendSideBar.new(name,&block) + def registration(name,type ={:type=> "ModuleApp"} ,&block) + if type[:type] == "ModuleApp" + Module::Registration.new(name,&block) + elsif type[:type] == "PersonalPlugin" + Plugin::Registration.new(name,&block) + end + end - def plugin_summary(name,&block) - # Plugin::PluginSummary.new(name,&block) - end - def module_summary(name,&block) - Module::ModuleSummary.new(name,&block) - end + # def backend_side_bar(name,&block) + # Module::BackendSideBar.new(name,&block) + # end + + # def plugin_summary(name,&block) + # # Plugin::PluginSummary.new(name,&block) + # end + + # def module_summary(name,&block) + # Module::Summary.new(name,&block) + # end end end \ No newline at end of file diff --git a/lib/orbit_app/module/backend_side_bar.rb b/lib/orbit_app/module/backend_side_bar.rb new file mode 100644 index 00000000..de0ef750 --- /dev/null +++ b/lib/orbit_app/module/backend_side_bar.rb @@ -0,0 +1,17 @@ +module OrbitApp + module Module + class BackendSideBar + attr_reader :name + + def initialize(name, &block) + @name = name + block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given? + end + + # def personal_plugin(*args) + # binding.pry + # end + + end + end +end \ No newline at end of file diff --git a/lib/orbit_app/module/registration.rb b/lib/orbit_app/module/registration.rb new file mode 100644 index 00000000..2f98592d --- /dev/null +++ b/lib/orbit_app/module/registration.rb @@ -0,0 +1,54 @@ +module OrbitApp + module Module + module Registration + Version = "0.1" + + module ClassMethods + @@registrations = [] + + def new( name ,&block) + @@registrations << DataSheet.new(name,&block) + end + + def find_by_key(key) + @@registrations.each{|t| + return t if t.name == key + } + return nil + end + + def all + return @@registrations + end + end + + extend ClassMethods + def self.included( other ) + other.extend( ClassMethods ) + end + + class DataSheet + attr_reader :name + attr_reader :base_path + + def initialize(name, &block) + @name = name + block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given? + end + + def plugin + + end + + def personal_plugin(params) + # TODO 這裡要看是一些檔案是不是都有 + Plugin::Registration.new_from_module_app(@name,@base_path,params) + end + + def base_url(var) + @base_path = var + end + end + end + end +end \ No newline at end of file diff --git a/lib/orbit_app/module/module_summary.rb b/lib/orbit_app/module/summary.rb similarity index 83% rename from lib/orbit_app/module/module_summary.rb rename to lib/orbit_app/module/summary.rb index 746e1205..c3098cb1 100644 --- a/lib/orbit_app/module/module_summary.rb +++ b/lib/orbit_app/module/summary.rb @@ -3,8 +3,8 @@ require "orbit_app/summary" module OrbitApp module Module - module ModuleSummary - include Summary + module Summary + include OrbitApp::Summary class Item def initialize() diff --git a/lib/orbit_app/plugin/registration.rb b/lib/orbit_app/plugin/registration.rb new file mode 100644 index 00000000..f996fc6d --- /dev/null +++ b/lib/orbit_app/plugin/registration.rb @@ -0,0 +1,58 @@ +module OrbitApp + module Plugin + module Registration + Version = "0.1" + + module ClassMethods + @@registrations = [] + + def new( name ,&block) + @@registrations << DataSheet.new(name,&block) + end + + def new_from_module_app(name,base_path,arg) + @@registrations << DataSheet.new(name,arg,:base_path=>base_path) + end + + def find_by_key(key) + @@registrations.each{|t| + return t if t.name == key + } + return nil + end + + def all + return @@registrations + end + end + + extend ClassMethods + def self.included( other ) + other.extend( ClassMethods ) + end + + class DataSheet + attr_reader :name + attr_reader :base_path + + + def initialize(name,partial=nil,*args ,&block) + @base_path = args[0][:base_path] + @name = name + @partial_path = '' + + unless partial.nil? + @partial_path = partial[:path] + end + + block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given? + end + + def profile_partial_path + return @partial_path + end + + end + end + end +end \ No newline at end of file diff --git a/lib/orbit_app/plugin/plugin_summary.rb b/lib/orbit_app/plugin/summary.rb similarity index 65% rename from lib/orbit_app/plugin/plugin_summary.rb rename to lib/orbit_app/plugin/summary.rb index 55e05120..ee0c6982 100644 --- a/lib/orbit_app/plugin/plugin_summary.rb +++ b/lib/orbit_app/plugin/summary.rb @@ -2,7 +2,8 @@ require "orbit_app/summary" module OrbitApp module Plugin - module PluginSummary + module Summary + # include OrbitApp::Summary include OrbitApp::Summary end diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/plugin/_profile.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/plugin/_profile.html.erb new file mode 100644 index 00000000..54b2428e --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/plugin/_profile.html.erb @@ -0,0 +1 @@ +Hello~ I am your plugin profile \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/init.rb b/vendor/built_in_modules/announcement/init.rb index a9a24c5f..9a2c0d43 100644 --- a/vendor/built_in_modules/announcement/init.rb +++ b/vendor/built_in_modules/announcement/init.rb @@ -1,7 +1,15 @@ -OrbitApp.module_summary "Announcement" do - +module Announcement + OrbitApp.registration "Announcement",:type=> 'ModuleApp' do + + base_url File.expand_path File.dirname(__FILE__) + personal_plugin :enable => true,:path=>"panel/announcement/plugin/profile" + + + end + end + # OrbitApp.backend_side_bar 'News' do # block :available_for => [:admin,:guest,:manager,:sub_manager], diff --git a/vendor/built_in_modules/announcement/lib/announcement.rb b/vendor/built_in_modules/announcement/lib/announcement.rb deleted file mode 100644 index 1feec47d..00000000 --- a/vendor/built_in_modules/announcement/lib/announcement.rb +++ /dev/null @@ -1,4 +0,0 @@ -require "announcement/engine" - -module Announcement -end diff --git a/vendor/built_in_modules/announcement/lib/announcement/engine.rb b/vendor/built_in_modules/announcement/lib/announcement/engine.rb deleted file mode 100644 index 6b87cf08..00000000 --- a/vendor/built_in_modules/announcement/lib/announcement/engine.rb +++ /dev/null @@ -1,4 +0,0 @@ -module Announcement - class Engine < Rails::Engine - end -end diff --git a/vendor/built_in_modules/announcement/lib/announcement/version.rb b/vendor/built_in_modules/announcement/lib/announcement/version.rb deleted file mode 100644 index 1b522752..00000000 --- a/vendor/built_in_modules/announcement/lib/announcement/version.rb +++ /dev/null @@ -1,3 +0,0 @@ -module Announcement - VERSION = "0.0.1" -end