before_filter :authenticate_admin!, :only => [:list, :browse]
@@model = Comic
- @@filer_manager = Pettanr::FilerManager.new @@model.item_name, Pettanr.manifest
- @@profiler_manager = Pettanr::ProfilerManager.new @@model.item_name, Pettanr.manifest
- @@list_manager = Pettanr::ListManager.new @@model.item_name, Pettanr.manifest
+ @@controller = Pettanr::ControllerManager.new @@model.item_name, Pettanr.manifest
- @@filer_manager = Pettanr::Application::manifest.list_managers[@@model.item_name]
- @@profiler_manager = Pettanr::Application::manifest.list_managers[@@model.item_name]
+ @@list_manager = Pettanr::Application::manifest.list_managers[@@model.item_name]
++ @@filer_manager = Pettanr::Application::manifest.filer_managers[@@model.item_name]
++ @@profiler_manager = Pettanr::Application::manifest.profiler_managers[@@model.item_name]
+
def index
- set_filer
- @list = @@list_manager.open('public', @page, @page_size, @operators)
- @items = @list.items
+ @c = @@controller.open(params[:action])
- @list = @c.list.open(@page, @page_size, @operators)
- @items = @list.items
++ @list = @@list_manager.open(@page, @page_size, @operators)
++ @items = @c.items
respond_to do |format|
format.html {
@filer = @@filer_manager.open(@items, @operators, @list.paginate)
module Pettanr
class Manifest
+ class Controller
+ attr :conf, :attributes, :associations
+ def initialize item_name, conf, manifest
+ @item_name = item_name
+ @conf = conf || {}
+ @manifest = manifest
+ @model_name = @conf['model_name']
+ end
+
+ def actions
+ @model_manifest['actions'] || {}
+ end
+
+ end
+
class Model
- attr :conf, :attributes, :associations
+ attr :item_name, :conf, :manifest, :attributes, :associations
def initialize item_name, conf, manifest
@item_name = item_name
@conf = conf || {}
end
+ attr :licenses, :elements, :speech_balloon_templates, :writing_formats, :profile,
+ :model_managers, :list_managers, :profiler_managers, :filer_managers, :form_managers
def initialize manifest
@manifest = manifest || {}
+ @controllers = {}
@models = {}
@lists = {}
+ @licenses = License.new(manifest)
+ @elements = Element.new(manifest)
+ @speech_balloon_templates = SpeechBalloonTemplate.new(manifest)
+ @writing_formats = WritingFormat.new(manifest)
+ @profile = Profile.new(manifest)
@profilers = {}
@filers = {}
@forms = {}
- manifest['controller'].each {|item_name, controller_conf|
+ @model_managers = {}
+ @list_managers = {}
+ @profiler_managers = {}
+ @filer_managers = {}
+ @form_managers = {}
++ (@manifest['controllers'] || {}).each {|item_name, controller_conf|
+ @controllers[item_name] = Controller.new(item_name, controller_conf, manifest)
+ }
- manifest['models'].each {|item_name, model_conf|
+ (@manifest['models'] || {}).each {|item_name, model_conf|
@models[item_name] = Model.new(item_name, model_conf, manifest)
+ @model_managers[item_name] = Pettanr::ModelManager.new @models[item_name]
}
- manifest['lists'].each {|item_name, list_manifest|
- @lists[item_name] = List.new(item_name, list_manifest)
+ (@manifest['lists'] || {}).each {|item_name, list_conf|
+ @lists[item_name] = List.new(item_name, list_conf, manifest)
+ @list_managers[item_name] = Pettanr::ListManager.new @lists[item_name]
}
- manifest['locals']['profilers'].each {|item_name, profiler_manifest|
- @profilers[item_name] = Profiler.new item_name, profiler_manifest
+ @locals = @manifest['locals'] || {}
+ (@locals['profilers'] || {}).each {|item_name, profiler_conf|
+ @profilers[item_name] = Profiler.new item_name, profiler_conf, manifest
+ @profiler_managers[item_name] = Pettanr::ProfilerManager.new @profilers[item_name]
}
- manifest['locals']['filers'].each {|item_name, filer_manifest|
- @filers[item_name] = Filer.new item_name, filer_manifest
+ (@locals['filers'] || {}).each {|item_name, filer_conf|
+ @filers[item_name] = Filer.new item_name, filer_conf, manifest
+ @filer_managers[item_name] = Pettanr::FilerManager.new @filers[item_name]
}
- manifest['locals']['forms'].each {|item_name, form_manifest|
- @forms[item_name] = Form.new item_name, form_manifest
+ (@locals['forms'] || {}).each {|item_name, form_conf|
+ @forms[item_name] = Form.new item_name, form_conf, manifest
+ @form_managers[item_name] = Pettanr::FormManager.new @forms[item_name]
}
end