deliver API
This commit is contained in:
parent
6af375efa4
commit
f6b600df59
|
@ -24,7 +24,7 @@ class Admin::PagePartsController < OrbitBackendController
|
|||
|
||||
def edit
|
||||
@part = PagePart.find(params[:id])
|
||||
@module_apps = ModuleApp.excludes(widgets: nil).where(enable_frontend: true).order_by(:title, :asc)
|
||||
@module_apps = ModuleApp.where(:key.in=>OrbitApp::Module::WidgetUtility.all.keys).order_by(:title, :asc)
|
||||
@module_app = @part.module_app ? @part.module_app : nil
|
||||
@user_choose = @part.widget_path
|
||||
@r_tag = @part.public_r_tag.blank? ? LIST[:public_r_tags][0] : @part.public_r_tag
|
||||
|
|
|
@ -13,7 +13,7 @@ helper Admin::PagePartsHelper
|
|||
def new
|
||||
@item = Page.new
|
||||
@item.parent = Item.find(params[:parent_id]) rescue nil
|
||||
@apps = ModuleApp.excludes(app_pages: nil).entries
|
||||
@apps = ModuleApp.where(:key.in => OrbitApp::Module::FrontendUtility.all.keys)
|
||||
@designs = Design.all.entries
|
||||
@design = Design.first
|
||||
end
|
||||
|
@ -21,7 +21,7 @@ helper Admin::PagePartsHelper
|
|||
def edit
|
||||
@item = Page.find(params[:id])
|
||||
@user_choose = @item.app_frontend_url
|
||||
@apps = ModuleApp.excludes(app_pages: nil).entries
|
||||
@apps = ModuleApp.where(:key.in => OrbitApp::Module::FrontendUtility.all.keys)
|
||||
@module_apps = ModuleApp.excludes(widgets: nil).where(enable_frontend: true).order_by(:title, :asc)
|
||||
|
||||
@designs = Design.all.entries
|
||||
|
@ -62,7 +62,7 @@ helper Admin::PagePartsHelper
|
|||
end
|
||||
else
|
||||
flash.now[:error] = t('create.error.page')
|
||||
@apps = ModuleApp.all
|
||||
@apps = ModuleApp.where(:key.in => OrbitApp::Module::FrontendUtility.all.keys)
|
||||
@designs = Design.all.entries
|
||||
@design = Design.first
|
||||
render :action => "new"
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
<div class="control-group" id="module_app_list">
|
||||
<%= f.label '',t("default_widget.select_module_app"), :class => 'control-label' %>
|
||||
<div class="controls">
|
||||
<%= render :partial => "app_selector", :locals => { :f => f } %>
|
||||
<%= render :partial => "app_selector", :locals => { :f => f } %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -1,20 +1,27 @@
|
|||
module OrbitApp
|
||||
module Module
|
||||
module FrontendUtility
|
||||
Version = "0.1"
|
||||
Version = "0.2"
|
||||
|
||||
module ClassMethods
|
||||
@@frontend_pages = []
|
||||
@@frontend_pages = {}
|
||||
#Record all frontend pages of orbit
|
||||
|
||||
def add(var) #build @@frontend_pages
|
||||
@@frontend_pages << var
|
||||
def add(key,var) #build @@frontend_pages
|
||||
if @@frontend_pages[key].nil?
|
||||
@@frontend_pages[key]= {"frontend"=>var}
|
||||
else
|
||||
@@frontend_pages[key]["frontend"]= var
|
||||
end
|
||||
end
|
||||
|
||||
def add_default_widget(key,var)
|
||||
@@frontend_pages[key]["default_widget"]= var
|
||||
end
|
||||
|
||||
def all #return all frontend_pages of orbit
|
||||
return @@frontend_pages
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
extend ClassMethods
|
||||
|
@ -23,9 +30,10 @@ module OrbitApp
|
|||
end
|
||||
|
||||
class AppPageSet # From Registration
|
||||
def initialize(&block)
|
||||
def initialize(name,key,&block)
|
||||
@frontend_pages = []
|
||||
block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given?
|
||||
OrbitApp::Module::FrontendUtility.add(key,@frontend_pages)
|
||||
end
|
||||
|
||||
def app_page(name,&block)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
module OrbitApp
|
||||
module Module
|
||||
module Registration
|
||||
Version = "0.1"
|
||||
Version = "0.2"
|
||||
|
||||
module ClassMethods
|
||||
@@registrations = []
|
||||
|
@ -120,7 +120,7 @@ module OrbitApp
|
|||
end
|
||||
|
||||
def front_end(&block) #setter for front_end from init
|
||||
@front_end_app_pages = FrontendUtility::AppPageSet.new(&block)
|
||||
@front_end_app_pages = FrontendUtility::AppPageSet.new(@name,@key,&block)
|
||||
end
|
||||
|
||||
def side_bar(&block) #setter for side_bar from init
|
||||
|
@ -129,12 +129,12 @@ module OrbitApp
|
|||
|
||||
def personal_plugin(params) #setter for personal_plugin from init
|
||||
# TODO 這裡要看是一些檔案是不是都有
|
||||
Plugin::Registration.new_from_module_app(@name,@base_path,params)
|
||||
Plugin::Registration.new_from_module_app(@name,@key,@base_path,params)
|
||||
end
|
||||
|
||||
def widgets(&block) #setter for widget from init
|
||||
# @widgets = WidgetRegisition::WidgetSet.new(&block)
|
||||
@widget_set = WidgetUtility::WidgetSet.new(&block)
|
||||
@widget_set = WidgetUtility::WidgetSet.new(@name,@key,&block)
|
||||
|
||||
# @widgets = widget_set.widgets
|
||||
# @default_widget = widget_set.default_widget
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
module OrbitApp
|
||||
module Module
|
||||
module SideBarRegisition
|
||||
Version = "0.1"
|
||||
Version = "0.2"
|
||||
|
||||
module ClassMethods
|
||||
@@side_bars = []
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
module OrbitApp
|
||||
module Module
|
||||
module WidgetUtility
|
||||
Version = "0.1"
|
||||
Version = "0.2"
|
||||
|
||||
module ClassMethods
|
||||
@@widgets = []
|
||||
@@widgets = {}
|
||||
|
||||
def add(var)
|
||||
@@widgets << var
|
||||
def add(name,default_widget,customize_widget)
|
||||
@@widgets[name] = {:default_widget=>default_widget,:customize_widget=>customize_widget}
|
||||
Hash[@@widgets.sort]
|
||||
end
|
||||
|
||||
def all
|
||||
|
@ -22,12 +23,13 @@ module OrbitApp
|
|||
|
||||
class WidgetSet
|
||||
attr_reader :widgets,:categories_query,:tags_query
|
||||
def initialize(&block)
|
||||
def initialize(name,key,&block)
|
||||
@widgets = []
|
||||
@default_widget = nil
|
||||
@categories_query = ''
|
||||
@tags_query = ''
|
||||
block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given?
|
||||
OrbitApp::Module::WidgetUtility.add(key,@default_widget,@widgets)
|
||||
end
|
||||
|
||||
%w{categories_query tags_query}.each do |field|
|
||||
|
@ -58,6 +60,7 @@ module OrbitApp
|
|||
|
||||
def default_widget(&block)
|
||||
@default_widget = DefaultWidget.new(&block)
|
||||
# OrbitApp::Module::FrontendUtility.add()
|
||||
end
|
||||
|
||||
def customize_widget(name,&block)
|
||||
|
@ -115,7 +118,6 @@ module OrbitApp
|
|||
end
|
||||
|
||||
def self.get_interface_args
|
||||
#will need to work with design
|
||||
{:name=>"default_widget",:field=>@fields,:style=>@enabled_styles,:i18n=>'default_widget.default_widget'}
|
||||
end
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
module OrbitApp
|
||||
module Plugin
|
||||
module Registration
|
||||
Version = "0.1"
|
||||
Version = "0.2"
|
||||
|
||||
module ClassMethods
|
||||
@@registrations = []
|
||||
|
@ -10,7 +10,7 @@ module OrbitApp
|
|||
@@registrations << DataSheet.new(name,&block)
|
||||
end
|
||||
|
||||
def new_from_module_app(name,base_path,*args)
|
||||
def new_from_module_app(name,key,base_path,*args)
|
||||
@@registrations << DataSheet.new(name,args,:base_path=>base_path)
|
||||
end
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module OrbitApp
|
||||
module Summary
|
||||
Version = "0.1"
|
||||
Version = "0.2"
|
||||
|
||||
module ClassMethods
|
||||
@@summaries = []
|
||||
|
|
Reference in New Issue