This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
orbit-4-1/lib/orbit_app/module/front_end.rb

89 lines
2.2 KiB
Ruby
Raw Normal View History

module OrbitApp
module Module
module FrontendUtility
2013-03-22 06:19:10 +00:00
Version = "0.2"
module ClassMethods
2013-03-22 06:19:10 +00:00
@@frontend_pages = {}
#Record all frontend pages of orbit
2013-03-22 06:19:10 +00:00
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
def self.included( other )
other.extend( ClassMethods )
end
class AppPageSet # From Registration
2013-03-22 06:19:10 +00:00
def initialize(name,key,&block)
@frontend_pages = []
block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given?
2013-03-22 06:19:10 +00:00
OrbitApp::Module::FrontendUtility.add(key,@frontend_pages)
end
def app_page(name,&block)
@frontend_pages << AppPage.new(name,&block)
end
def to_module_app_format #For ModuleApp to fetch data
2013-03-11 10:21:17 +00:00
result = {}
@frontend_pages.collect do |t|
result[t.name] = {:i18n=>t.get_i18n,:style=>t.get_style}
end
result
end
end
class AppPage
attr_reader :name
2013-03-11 10:21:17 +00:00
attr_reader :style
def initialize(name,&block)
2013-03-11 10:21:17 +00:00
@style
@name = name
@frontend_i18n = 'rulingcom.errors.init.app_page_noname'
block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given?
end
def frontend_i18n(i18n)
@frontend_i18n = i18n
end
def get_i18n
@frontend_i18n
end
def finalize!
end
2013-03-11 10:21:17 +00:00
def get_style
@style
end
def style(ary)# []
@style = ary
end
protected
end# of AppPage
end # of FrontendUtility
end # of Module
end # of OrbitApp