From ee4f5718912f415123041b3dd61c5c3c639878a8 Mon Sep 17 00:00:00 2001 From: yasushiito Date: Wed, 5 Feb 2014 17:18:22 +0900 Subject: [PATCH] fix manifest/system_resource --- .../javascripts/manifest/work/models.js.coffee.erb | 6 +- .../manifest/work/system_resources.js.coffee.erb | 100 ++++++++--------- app/assets/javascripts/panels.js.coffee | 1 - app/helpers/application_helper.rb | 2 +- app/models/license_group.rb | 8 +- app/models/speech_balloon_template.rb | 8 +- app/models/writing_format.rb | 8 +- app/views/comics/_form.html.erb | 2 +- app/views/ground_colors/_form.html.erb | 2 +- app/views/ground_pictures/_form.html.erb | 2 +- app/views/panels/_form.html.erb | 2 +- app/views/scroll_panels/_scroll_header.html.erb | 2 +- app/views/scrolls/_form.html.erb | 2 +- app/views/sheets/_form.html.erb | 2 +- app/views/stories/_form.html.erb | 2 +- config/routes.rb | 12 +- lib/manifest/list/system_resource.rb | 2 + lib/manifest/manifest.rb | 22 +--- .../model/attribute/source/magic_number.rb | 5 +- lib/manifest/model/attribute/source/model.rb | 14 ++- lib/manifest/model/list/system_resource.rb | 3 + lib/manifest/system_resource/engine_resource.rb | 39 +++++++ lib/manifest/system_resources.rb | 44 ++++++-- public/manifest.json | 121 +++++++++------------ 24 files changed, 220 insertions(+), 191 deletions(-) create mode 100644 lib/manifest/system_resource/engine_resource.rb diff --git a/app/assets/javascripts/manifest/work/models.js.coffee.erb b/app/assets/javascripts/manifest/work/models.js.coffee.erb index 45ed19c0..5e9b60e7 100644 --- a/app/assets/javascripts/manifest/work/models.js.coffee.erb +++ b/app/assets/javascripts/manifest/work/models.js.coffee.erb @@ -1077,9 +1077,6 @@ type: 'number', source: { type: 'model', - args: { - select_item_name: 'writing_format_items', - }, }, rules : { required: true, @@ -1825,6 +1822,9 @@ }, select_items: { type: 'system_resource', + args: { + select_item_name: 'panel_visible_items', + }, }, }, }, diff --git a/app/assets/javascripts/manifest/work/system_resources.js.coffee.erb b/app/assets/javascripts/manifest/work/system_resources.js.coffee.erb index 4b0c93c7..a470975c 100644 --- a/app/assets/javascripts/manifest/work/system_resources.js.coffee.erb +++ b/app/assets/javascripts/manifest/work/system_resources.js.coffee.erb @@ -2,21 +2,28 @@ @system_resources = { engine_resources: { license_groups: { - PettanrCreativeCommonsV30Licenses: 'pettanr_creative_commons_v30_licenses', - PettanrPettanCommonsV01Licenses: 'pettanr_pettan_commons_v01_licenses', - PettanrPettanProtectedV01Licenses: 'pettanr_pettan_protected_v01_licenses', - PettanrPettanPublicV01Licenses: 'pettanr_pettan_public_v01_licenses', - PettanrPublicDomainV01Licenses: 'pettanr_public_domain_v01_licenses', - PettanrUnknownV01Licenses: 'pettanr_unknown_v01_licenses', + resource_items: { + PettanrCreativeCommonsV30Licenses: 'pettanr_creative_commons_v30_licenses', + PettanrPettanCommonsV01Licenses: 'pettanr_pettan_commons_v01_licenses', + PettanrPettanProtectedV01Licenses: 'pettanr_pettan_protected_v01_licenses', + PettanrPettanPublicV01Licenses: 'pettanr_pettan_public_v01_licenses', + PettanrPublicDomainV01Licenses: 'pettanr_public_domain_v01_licenses', + PettanrUnknownV01Licenses: 'pettanr_unknown_v01_licenses', + }, }, speech_balloon_templates: { - CircleSpeechBalloon: 'circle_speech_balloon', - PlainSpeechBalloon: 'plain_speech_balloon', - SquareSpeechBalloon: 'square_speech_balloon', - # TestSpeechBalloon: 'test_speech_balloon', + resource_items: { + CircleSpeechBalloon: 'circle_speech_balloon', + PlainSpeechBalloon: 'plain_speech_balloon', + SquareSpeechBalloon: 'square_speech_balloon', + # TestSpeechBalloon: 'test_speech_balloon', + }, }, writing_formats: { - SimpleFormat: 'pettanr_simple_format', + has_route: 0, + resource_items: { + SimpleFormat: 'pettanr_simple_format', + }, }, }, elements: { @@ -25,51 +32,7 @@ GroundPicture: 'ground_pictures', GroundColor: 'ground_colors', }, -} -@magic_numbers = { - run_mode: 1, - thumbnail_width: 64, - thumbnail_height: 64, - profile: { - users: { - caption: "ペンギン王国", - url: "http://localhost:3001/", - description: "ペンギン王国はペンギン素材を豊富に用意したペンギンマニアのサイトです。", - }, - admins: { - caption: "site name for admin", - url: "http://your.site.url/admins/", - description: "admin register", - }, - demand_users: { - caption: "provider name", - url: "http://your.site.url/demanders/", - description: "provider description", - }, - }, - provider_sources: [ - 'http://sourceforge.jp/projects/pettanr/wiki/ProviderSource/attach/provider_source.json' - ], -} -@select_items = { - model_loader: { - writing_format_items: { - model_name: 'writing_format', - list_name: 'select_items', - caption_name: 'caption' - }, - license_group_items: { - model_name: 'license_group', - list_name: 'select_items', - caption_name: 'caption' - }, - speech_balloon_template_items: { - model_name: 'speech_balloon_template', - list_name: 'select_items', - caption_name: 'caption' - }, - }, - magic_number: { + select_items: { provider_status_status_items: [ ['select_items.provider_status.status.waiting', 0], ['select_items.provider_status.status.receiving', 1], @@ -127,5 +90,30 @@ ['select_items.speeches.text_align.right', 2], ['select_items.speeches.text_align.center', 3], ], + } +} +@magic_numbers = { + run_mode: 1, + thumbnail_width: 64, + thumbnail_height: 64, + profile: { + users: { + caption: "ペンギン王国", + url: "http://localhost:3001/", + description: "ペンギン王国はペンギン素材を豊富に用意したペンギンマニアのサイトです。", + }, + admins: { + caption: "site name for admin", + url: "http://your.site.url/admins/", + description: "admin register", + }, + demand_users: { + caption: "provider name", + url: "http://your.site.url/demanders/", + description: "provider description", + }, }, + provider_sources: [ + 'http://sourceforge.jp/projects/pettanr/wiki/ProviderSource/attach/provider_source.json' + ], } diff --git a/app/assets/javascripts/panels.js.coffee b/app/assets/javascripts/panels.js.coffee index d0834fa4..72239041 100644 --- a/app/assets/javascripts/panels.js.coffee +++ b/app/assets/javascripts/panels.js.coffee @@ -13,7 +13,6 @@ $ -> models: window.models, system_resources: window.system_resources, magic_numbers: window.magic_numbers, - select_items: window.select_items, locals: { profilers: window.profilers, filers: window.filers, diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9fe49677..b02b9187 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -25,7 +25,7 @@ module ApplicationHelper end def t_selected_item(name, index) - t(manifest.select_items['magic_number'][name][index][0]) + t(manifest.system_resources.select_items[name][index][0]) end def item_tag diff --git a/app/models/license_group.rb b/app/models/license_group.rb index 23873475..42402ed9 100644 --- a/app/models/license_group.rb +++ b/app/models/license_group.rb @@ -47,12 +47,16 @@ class LicenseGroup < Pettanr::Item {:include => {:licenses => {}}} end + def my_engine_resource + Manifest.manifest.system_resources.engine_resources['system_resources'] + end + def engine_name - Pettanr::Application.manifest.system_resources.license_groups[self.classname] + self.my_engine_resource.resource_items[self.classname] end def enable? - Pettanr::Application.manifest.system_resources.license_groups.include? self.classname + self.my_engine_resource.resource_items.include? self.classname end def engine_module_name diff --git a/app/models/speech_balloon_template.rb b/app/models/speech_balloon_template.rb index c2ebbd39..e04ef29f 100644 --- a/app/models/speech_balloon_template.rb +++ b/app/models/speech_balloon_template.rb @@ -61,12 +61,16 @@ class SpeechBalloonTemplate < Pettanr::Item @template_settings ||= JSON.parse(self.settings) end + def my_engine_resource + Manifest.manifest.system_resources.engine_resources['speech_balloon_templates'] + end + def engine_name - Manifest.manifest.system_resources.speech_balloon_templates[self.classname] + self.my_engine_resource.resource_items[self.classname] end def enable? - Manifest.manifest.system_resources.speech_balloon_templates.include? self.classname + self.my_engine_resource.resource_items.include? self.classname end def engine_module_name diff --git a/app/models/writing_format.rb b/app/models/writing_format.rb index 390c5c6e..5dc12c16 100644 --- a/app/models/writing_format.rb +++ b/app/models/writing_format.rb @@ -67,12 +67,16 @@ end @parsed_settings ||= JSON.parse(self.settings) end + def my_engine_resource + Manifest.manifest.system_resources.engine_resources['writing_formats'] + end + def engine_name - Manifest.manifest.system_resources.writing_formats[self.classname] + self.my_engine_resource.resource_items[self.classname] end def enable? - Manifest.manifest.system_resources.writing_formats.include? self.classname + self.my_engine_resource.resource_items.include? self.classname end def engine_module_name diff --git a/app/views/comics/_form.html.erb b/app/views/comics/_form.html.erb index b8bcfd2b..9953ba02 100644 --- a/app/views/comics/_form.html.erb +++ b/app/views/comics/_form.html.erb @@ -15,7 +15,7 @@
<%= f.label :visible %>
- <%= f.collection_select :visible, t_select_items(manifest.select_items['magic_number']['comic_visible_items']), :last, :first, :html => {:selected => @comic.visible} %> + <%= f.collection_select :visible, t_select_items(manifest.system_resources.select_items['comic_visible_items']), :last, :first, :html => {:selected => @comic.visible} %>
diff --git a/app/views/ground_colors/_form.html.erb b/app/views/ground_colors/_form.html.erb index b8aadcfe..7bec82e5 100644 --- a/app/views/ground_colors/_form.html.erb +++ b/app/views/ground_colors/_form.html.erb @@ -20,7 +20,7 @@
<%= f.label :orientation %> - <%= f.collection_select :orientation, t_select_items(MagicNumber['ground_color_orientation_items']), :last, :first, :html => {:selected => elm.orientation} %> + <%= f.collection_select :orientation, t_select_items(manifest.system_resources.select_items['ground_color_orientation_items']), :last, :first, :html => {:selected => elm.orientation} %> <%= f.label :xy %> <%= f.number_field :xy, elm.field_tag_attributes(:xy, no_attr, :size => 5) %> diff --git a/app/views/ground_pictures/_form.html.erb b/app/views/ground_pictures/_form.html.erb index 026a53fb..6480cadd 100644 --- a/app/views/ground_pictures/_form.html.erb +++ b/app/views/ground_pictures/_form.html.erb @@ -9,7 +9,7 @@
<%= f.label :repeat %> - <%= f.collection_select :repeat, t_select_items(manifest.select_items['magic_number']['ground_picture_repeat_items']), *elm.select_tag_attributes(elm.repeat, :repeat, no_attr) %> + <%= f.collection_select :repeat, t_select_items(manifest.system_resources.select_items['ground_picture_repeat_items']), *elm.select_tag_attributes(elm.repeat, :repeat, no_attr) %>
diff --git a/app/views/panels/_form.html.erb b/app/views/panels/_form.html.erb index 4276a977..c27d1ac0 100644 --- a/app/views/panels/_form.html.erb +++ b/app/views/panels/_form.html.erb @@ -48,7 +48,7 @@
<%= f.label :publish %> - <%= f.select :publish, t_select_items(manifest.select_items['magic_number']['panel_visible_items']), *@panel.select_tag_attributes(@panel.publish, :publish, 'data-model' => 'panel') %> + <%= f.select :publish, t_select_items(manifest.system_resources.select_items['panel_visible_items']), *@panel.select_tag_attributes(@panel.publish, :publish, 'data-model' => 'panel') %>
diff --git a/app/views/scroll_panels/_scroll_header.html.erb b/app/views/scroll_panels/_scroll_header.html.erb index c6f316de..df0997b1 100644 --- a/app/views/scroll_panels/_scroll_header.html.erb +++ b/app/views/scroll_panels/_scroll_header.html.erb @@ -10,7 +10,7 @@
<%= f.label :visible %>
- <%= f.collection_select :visible, t_select_items(MagicNumber['scroll_visible_items']), :last, :first, :html => {:selected => @scroll.visible} %> + <%= f.collection_select :visible, t_select_items(manifest.system_resources.select_items['scroll_visible_items']), :last, :first, :html => {:selected => @scroll.visible} %>
<%= f.submit %> diff --git a/app/views/scrolls/_form.html.erb b/app/views/scrolls/_form.html.erb index 496b16f1..e23c6c9b 100644 --- a/app/views/scrolls/_form.html.erb +++ b/app/views/scrolls/_form.html.erb @@ -15,7 +15,7 @@
<%= f.label :visible %>
- <%= f.select :visible, t_select_items(manifest.select_items['magic_number']['scroll_visible_items']), :html => {:selected => @scroll.visible} %> + <%= f.select :visible, t_select_items(manifest.system_resources.select_items['scroll_visible_items']), :html => {:selected => @scroll.visible} %>
diff --git a/app/views/sheets/_form.html.erb b/app/views/sheets/_form.html.erb index fd3c9efb..c4069b1b 100644 --- a/app/views/sheets/_form.html.erb +++ b/app/views/sheets/_form.html.erb @@ -28,7 +28,7 @@
<%= f.label :visible %> - <%= f.collection_select :visible, t_select_items(MagicNumber['sheet_visible_items']), :last, :first, {:html => {:selected => @sheet.visible}}, {:id => @sheet.field_tag_id(:visible), :sheet_id => @sheet.tag_sheet_id, :column => :visible} %> + <%= f.collection_select :visible, t_select_items(manifest.system_resources.select_items['sheet_visible_items']), :last, :first, {:html => {:selected => @sheet.visible}}, {:id => @sheet.field_tag_id(:visible), :sheet_id => @sheet.tag_sheet_id, :column => :visible} %>
diff --git a/app/views/stories/_form.html.erb b/app/views/stories/_form.html.erb index 15d1ca53..02b141b2 100644 --- a/app/views/stories/_form.html.erb +++ b/app/views/stories/_form.html.erb @@ -21,7 +21,7 @@
<%= f.label :visible %>
- <%= f.collection_select :visible, t_select_items(manifest.select_items['magic_number']['story_visible_items']), :last, :first, :html => {:selected => @story.visible} %> + <%= f.collection_select :visible, t_select_items(manifest.system_resources.select_items['story_visible_items']), :last, :first, :html => {:selected => @story.visible} %>
diff --git a/config/routes.rb b/config/routes.rb index d1b42eb1..bcc06b5b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,12 +4,12 @@ Pettanr::Application.routes.draw do devise_for :admins devise_for :demand_users - Manifest.manifest.system_resources.license_groups.each do |klass, name| - p klass - mount Module.const_get(klass)::Engine => "/#{name}" - end - Manifest.manifest.system_resources.speech_balloon_templates.each do |klass , name| - mount Module.const_get(klass)::Engine => "/#{name}" + Manifest.manifest.system_resources.engine_resources.each do |engine_resource_name, engine_resource| + if engine_resource.add_route? + engine_resource.resource_items.each do |klass, name| + mount Module.const_get(klass)::Engine => "/#{name}" + end + end end resources :scrolls do diff --git a/lib/manifest/list/system_resource.rb b/lib/manifest/list/system_resource.rb index 218d7e76..c83b1502 100644 --- a/lib/manifest/list/system_resource.rb +++ b/lib/manifest/list/system_resource.rb @@ -1,6 +1,7 @@ module Manifest module ListModule class SystemResourceList < Base + attr :select_item_name def set_default super @@ -8,6 +9,7 @@ module Manifest def init super + @select_item_name = @list_manifest['select_item_name'] end def items options, offset, page_size diff --git a/lib/manifest/manifest.rb b/lib/manifest/manifest.rb index 13ad27f4..5ae1f138 100644 --- a/lib/manifest/manifest.rb +++ b/lib/manifest/manifest.rb @@ -1,7 +1,7 @@ module Manifest class Manifest cattr_accessor :manifest - attr :system_resources, :magic_numbers, :select_items, + attr :system_resources, :magic_numbers, :controllers, :models, :lists, :profilers, :filers, :forms, :lists, :views # call me before load routes.rb # routes.rb needs engine_resources manifest in system_resources @@ -10,7 +10,6 @@ module Manifest @manifest = manifest || {} @system_resources = SystemResources.new(self, SystemResources.set_default(@manifest['system_resources'])) @magic_numbers = @manifest['magic_numbers'] - @select_items = @manifest['select_items'] end def init @@ -24,27 +23,10 @@ module Manifest @forms = Form.base_manager(self, @locals['forms']) @forms.merge(Form.extend_manager(self, @locals['forms'])) @lists = List.manager(self, @locals['lists']) - select_items_loader + @system_resources.init add_action end - # call after load app - def select_items_loader - @system_resources.select_items['model_loader'].each {|name, conf| - raise "undefined model_name for select_items > model_loader > #{name}\n" unless conf['model_name'] - model_name = conf['model_name'] - list_name = conf['list_name'] || 'select_items' - caption = conf['caption_name'] || 'caption' - list_group = @lists[model_name] - raise "undefined list for select_items > model_loader > #{name} > model_name > #{model_name} \n" unless list_group - list = list_group[list_name] - raise "undefined list for select_items > model_loader > #{name} > list_name > #{list_name} \n" unless list - @select_items['model'] ||= {} - r = list.open operators, options - @select_items['model'][name] = r.items.map {|item| [item.attributes[caption], item.id]} - } - end - def add_action return @controllers.each do |controller_name, controller| diff --git a/lib/manifest/model/attribute/source/magic_number.rb b/lib/manifest/model/attribute/source/magic_number.rb index 564c8ace..26659746 100644 --- a/lib/manifest/model/attribute/source/magic_number.rb +++ b/lib/manifest/model/attribute/source/magic_number.rb @@ -3,7 +3,7 @@ module Manifest module AttributeModule module SourceModule class MagicNumberSource - attr :attribute, :source_manifest + attr :attribute, :source_manifest, :type, :select_item_name def initialize attribute, source_manifest @attribute = attribute @@ -14,13 +14,12 @@ module Manifest def set_default @source_manifest['args'] ||= {} - @source_manifest['args']['type'] ||= 'magic_number' raise "undefined select_item_name for models > #{@attribute.model_name} > attributes > #{@attribute.attribute_name} > source\n" unless @source_manifest['args']['select_item_name'] end def init @args = @source_manifest['args'] - @type = @args['type'] + @type = @source_manifest['type'] @select_item_name = @args['select_item_name'] end diff --git a/lib/manifest/model/attribute/source/model.rb b/lib/manifest/model/attribute/source/model.rb index 3bca1041..d59cf1d0 100644 --- a/lib/manifest/model/attribute/source/model.rb +++ b/lib/manifest/model/attribute/source/model.rb @@ -3,7 +3,8 @@ module Manifest module AttributeModule module SourceModule class ModelSource - attr :attribute, :source_manifest + attr :attribute, :source_manifest, :type, + :resource_model_name, :resource_list_name, :select_item_name, :caption_name def initialize attribute, source_manifest @attribute = attribute @@ -14,14 +15,19 @@ module Manifest def set_default @source_manifest['args'] ||= {} - @source_manifest['args']['type'] ||= 'model' - raise "undefined select_item_name for models > #{@attribute.model_name} > attributes > #{@attribute.attribute_name} > source\n" unless @source_manifest['args']['select_item_name'] + @source_manifest['args']['resource_model_name'] ||= (@attribute.attribute_name.gsub('_id', '')) + @source_manifest['args']['resource_list_name'] ||= 'select_items' + @source_manifest['args']['select_item_name'] ||= self.model_name + '_' + self.attribute_name.gsub('_id', '') + '_items' + @source_manifest['args']['caption_name'] ||= 'caption' end def init @args = @source_manifest['args'] - @type = @args['type'] + @type = @source_manifest['type'] + @resource_model_name = @args['resource_model_name'] + @resource_list_name = @args['resource_list_name'] @select_item_name = @args['select_item_name'] + @caption_name = @args['caption_name'] end def model_name diff --git a/lib/manifest/model/list/system_resource.rb b/lib/manifest/model/list/system_resource.rb index 84f26240..8d3bb5e0 100644 --- a/lib/manifest/model/list/system_resource.rb +++ b/lib/manifest/model/list/system_resource.rb @@ -2,13 +2,16 @@ module Manifest module ModelModule module ListModule class SystemResourceList < Base + attr :list_name def set_default super + @list_manifest['args']['list_name'] ||= 'select_items' end def init super + @list_name = @args['list_name'] end def items diff --git a/lib/manifest/system_resource/engine_resource.rb b/lib/manifest/system_resource/engine_resource.rb new file mode 100644 index 00000000..cb565d1d --- /dev/null +++ b/lib/manifest/system_resource/engine_resource.rb @@ -0,0 +1,39 @@ +module Manifest + module SystemResourceModule + class EngineResource + def self.manager manifest, my_manifests + engine_resources = {} + my_manifests.each {|engine_resource_name, engine_resource_manifest| + engine_resources[engine_resource_name] = self.new(manifest, engine_resource_name, engine_resource_manifest) + } + engine_resources + end + + attr :engine_resource_name, :engine_resource_manifest, + :resource_items, :has_route + def initialize manifest, engine_resource_name, engine_resource_manifest + @manifest = manifest + @engine_resource_name = engine_resource_name + @engine_resource_manifest = engine_resource_manifest + self.set_default + self.init + end + + def set_default + @engine_resource_manifest['resource_items'] ||= {} + @engine_resource_manifest['has_route'] ||= 1 + end + + def init + @resource_items = @engine_resource_manifest['resource_items'] + @has_route = @engine_resource_manifest['has_route'] + end + + def add_route? + @has_route > 0 + end + + end + end +end + diff --git a/lib/manifest/system_resources.rb b/lib/manifest/system_resources.rb index 42b2daea..d0554a6e 100644 --- a/lib/manifest/system_resources.rb +++ b/lib/manifest/system_resources.rb @@ -1,36 +1,56 @@ +require_dependency "manifest/system_resource/engine_resource" module Manifest class SystemResources + include SystemResourceModule def self.set_default system_resources_manifest system_resources_manifest['engine_resources'] ||= {} - system_resources_manifest['license_groups'] ||= {} - system_resources_manifest['speech_balloon_templates'] ||= {} - system_resources_manifest['writing_formats'] ||= {} system_resources_manifest['elements'] ||= {} system_resources_manifest['select_items'] ||= {} - system_resources_manifest['select_items']['model_loader'] ||= {} - system_resources_manifest['select_items']['magic_number'] ||= {} #oh my ... #JSON.stringify couldn't print 1.0 # 1 == 1.0 ? #change class - system_resources_manifest['select_items']['magic_number']['speech_font_size_items'] ||= {} - system_resources_manifest['select_items']['magic_number']['speech_font_size_items'].each {|conf| + system_resources_manifest['select_items']['speech_font_size_items'] ||= {} + system_resources_manifest['select_items']['speech_font_size_items'].each {|conf| conf[1] = conf[1].to_f } system_resources_manifest end - attr :engine_resources, :license_groups, :speech_balloon_templates, :writing_formats, :elements, :select_items + attr :engine_resources, :elements, :select_items def initialize manifest, system_resources_manifest @manifest = manifest - @engine_resources = system_resources_manifest['engine_resources'] - @license_groups = system_resources_manifest['license_groups'] - @speech_balloon_templates = system_resources_manifest['speech_balloon_templates'] - @writing_formats = system_resources_manifest['writing_formats'] + @system_resources_manifest = system_resources_manifest + @engine_resources = EngineResource.manager(self, @system_resources_manifest['engine_resources']) @elements = system_resources_manifest['elements'] @select_items = system_resources_manifest['select_items'] end + # call after load app + def init + self.select_items_loader + end + + def select_items_loader + @manifest.models.each {|model_name, model_manifest| + model_manifest.attributes.each {|attribute_name, attribute_manifest| + source_manifest = attribute_manifest.source + next unless source_manifest + next unless source_manifest.type == 'model' + resource_model_name = source_manifest.resource_model_name + resource_list_name = source_manifest.resource_list_name + caption = source_manifest.caption_name + list_group = @manifest.lists[resource_model_name] + raise "undefined resource model list for lists > #{resource_model_name}\n" unless list_group + list = list_group[resource_list_name] + raise "undefined resource list for lists > #{resource_model_name} > #{resource_list_name}\n" unless list + r = list.open nil, {} + @select_items[source_manifest.select_item_name] = + r.items.map {|item| [item.attributes[caption], item.id]} + } + } + end + end end diff --git a/public/manifest.json b/public/manifest.json index 1ea57440..2041744d 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -1819,10 +1819,7 @@ "writing_format_id": { "type": "number", "source": { - "type": "model", - "args": { - "select_item_name": "writing_format_items" - } + "type": "model" }, "rules": { "required": true, @@ -2565,7 +2562,10 @@ "type": "public" }, "select_items": { - "type": "system_resource" + "type": "system_resource", + "args": { + "select_item_name": "panel_visible_items" + } } } }, @@ -2980,20 +2980,27 @@ "system_resources": { "engine_resources": { "license_groups": { - "PettanrCreativeCommonsV30Licenses": "pettanr_creative_commons_v30_licenses", - "PettanrPettanCommonsV01Licenses": "pettanr_pettan_commons_v01_licenses", - "PettanrPettanProtectedV01Licenses": "pettanr_pettan_protected_v01_licenses", - "PettanrPettanPublicV01Licenses": "pettanr_pettan_public_v01_licenses", - "PettanrPublicDomainV01Licenses": "pettanr_public_domain_v01_licenses", - "PettanrUnknownV01Licenses": "pettanr_unknown_v01_licenses" + "resource_items": { + "PettanrCreativeCommonsV30Licenses": "pettanr_creative_commons_v30_licenses", + "PettanrPettanCommonsV01Licenses": "pettanr_pettan_commons_v01_licenses", + "PettanrPettanProtectedV01Licenses": "pettanr_pettan_protected_v01_licenses", + "PettanrPettanPublicV01Licenses": "pettanr_pettan_public_v01_licenses", + "PettanrPublicDomainV01Licenses": "pettanr_public_domain_v01_licenses", + "PettanrUnknownV01Licenses": "pettanr_unknown_v01_licenses" + } }, "speech_balloon_templates": { - "CircleSpeechBalloon": "circle_speech_balloon", - "PlainSpeechBalloon": "plain_speech_balloon", - "SquareSpeechBalloon": "square_speech_balloon" + "resource_items": { + "CircleSpeechBalloon": "circle_speech_balloon", + "PlainSpeechBalloon": "plain_speech_balloon", + "SquareSpeechBalloon": "square_speech_balloon" + } }, "writing_formats": { - "SimpleFormat": "pettanr_simple_format" + "has_route": 0, + "resource_items": { + "SimpleFormat": "pettanr_simple_format" + } } }, "elements": { @@ -3001,52 +3008,8 @@ "SpeechBalloon": "speech_balloons", "GroundPicture": "ground_pictures", "GroundColor": "ground_colors" - } - }, - "magic_numbers": { - "run_mode": 1, - "thumbnail_width": 64, - "thumbnail_height": 64, - "profile": { - "users": { - "caption": "ペンギン王国", - "url": "http://localhost:3001/", - "description": "ペンギン王国はペンギン素材を豊富に用意したペンギンマニアのサイトです。" - }, - "admins": { - "caption": "site name for admin", - "url": "http://your.site.url/admins/", - "description": "admin register" - }, - "demand_users": { - "caption": "provider name", - "url": "http://your.site.url/demanders/", - "description": "provider description" - } - }, - "provider_sources": [ - "http://sourceforge.jp/projects/pettanr/wiki/ProviderSource/attach/provider_source.json" - ] - }, - "select_items": { - "model_loader": { - "writing_format_items": { - "model_name": "writing_format", - "list_name": "select_items", - "caption_name": "caption" - }, - "license_group_items": { - "model_name": "license_group", - "list_name": "select_items", - "caption_name": "caption" - }, - "speech_balloon_template_items": { - "model_name": "speech_balloon_template", - "list_name": "select_items", - "caption_name": "caption" - } }, - "magic_number": { + "select_items": { "provider_status_status_items": [ [ "select_items.provider_status.status.waiting", @@ -3211,6 +3174,31 @@ ] } }, + "magic_numbers": { + "run_mode": 1, + "thumbnail_width": 64, + "thumbnail_height": 64, + "profile": { + "users": { + "caption": "ペンギン王国", + "url": "http://localhost:3001/", + "description": "ペンギン王国はペンギン素材を豊富に用意したペンギンマニアのサイトです。" + }, + "admins": { + "caption": "site name for admin", + "url": "http://your.site.url/admins/", + "description": "admin register" + }, + "demand_users": { + "caption": "provider name", + "url": "http://your.site.url/demanders/", + "description": "provider description" + } + }, + "provider_sources": [ + "http://sourceforge.jp/projects/pettanr/wiki/ProviderSource/attach/provider_source.json" + ] + }, "locals": { "profilers": { "scroll": { @@ -4610,17 +4598,8 @@ } }, "caption": { - "type": "default", - "args": { - "face": { - "type": "none", - "args": {} - }, - "link": { - "type": "none", - "args": {} - } - } + "type": "none", + "args": {} }, "summary": { "type": "template", -- 2.11.0