From eada248d033161ff9797c40bac0fd24ed7d1d962 Mon Sep 17 00:00:00 2001 From: yasushiito Date: Fri, 6 Dec 2013 16:22:13 +0900 Subject: [PATCH] temp --- .../javascripts/configurations.js.coffee.erb | 286 ++++++++++++++++----- app/helpers/application_helper.rb | 4 + app/models/panel.rb | 2 +- app/models/speech_balloon_template.rb | 4 +- app/models/writing_format.rb | 4 +- app/views/layouts/test.html.erb | 4 +- app/views/layouts/test.prof.erb | 2 +- config/application.rb | 10 +- config/routes.rb | 4 +- lib/manifest/list.rb | 2 +- lib/manifest/manifest.rb | 56 +--- public/manifest.json | 121 +++++---- 12 files changed, 315 insertions(+), 184 deletions(-) diff --git a/app/assets/javascripts/configurations.js.coffee.erb b/app/assets/javascripts/configurations.js.coffee.erb index 994351de..8c4f3664 100644 --- a/app/assets/javascripts/configurations.js.coffee.erb +++ b/app/assets/javascripts/configurations.js.coffee.erb @@ -4,11 +4,16 @@ scroll: { item_name: 'scroll', index: { + type: 'list', list: { list_name: 'public', }, }, + show: { + type: 'show', + name: 'show', + }, }, }, models: { @@ -34,6 +39,18 @@ }, }, }, + filters: { + by_author: { + type: 'filter', + key: 'author_id', + }, + }, + through_filters: { + by_panel: { + through: 'scroll_panels', + key: 'panel_id', + }, + }, attributes: { id: { type: 'number', @@ -2056,39 +2073,164 @@ lists: { scroll: { default_page_size: 20, - public_list: { - type: 'public', - }, - private_list: { - type: 'private', - }, - scroll_panels: { - type: 'has_many', - association_name: 'scroll_panels', - }, - panels: { - type: 'has_many', - association_name: 'panels', - }, - by_panel: { - type: 'filter', - filter_key: 'scroll_id', - list: { - method: 'filtered_list', + lists: { + public_list: { + type: 'public', + }, + private_list: { + type: 'private', + }, + scroll_panels: { + type: 'has_many', + association_name: 'scroll_panels', + }, + panels: { + type: 'has_many', + association_name: 'panels', + }, + by_panel: { + type: 'throughfilter', + filter_key: 'panel_id', + list: { + method: 'filtered_list', + }, }, }, }, scroll_panel: { + default_page_size: 20, + lists: { + public_list: { + type: 'public', + }, + private_list: { + type: 'private', + }, + by_scroll: { + type: 'filter', + filter_key: 'scroll_id', + list: { + method: 'filtered_list', + }, + }, + by_panel: { + type: 'filter', + filter_key: 'panel_id', + list: { + method: 'filtered_list', + }, + }, + }, }, comic: { + default_page_size: 20, + lists: { + public_list: { + type: 'public', + }, + private_list: { + type: 'private', + }, + stories: { + type: 'has_many', + association_name: 'stories', + }, + }, }, story: { + default_page_size: 20, + lists: { + public_list: { + type: 'public', + }, + private_list: { + type: 'private', + }, + story_sheets: { + type: 'has_many', + association_name: 'story_sheets', + }, + sheets: { + type: 'has_many', + association_name: 'sheets', + }, + by_comic: { + type: 'filter', + filter_key: 'comic_id', + list: { + method: 'filtered_list', + }, + }, + }, }, story_sheet: { + default_page_size: 20, + lists: { + public_list: { + type: 'public', + }, + private_list: { + type: 'private', + }, + by_story: { + type: 'filter', + filter_key: 'story_id', + list: { + method: 'filtered_list', + }, + }, + by_sheet: { + type: 'filter', + filter_key: 'sheet_id', + list: { + method: 'filtered_list', + }, + }, + }, }, sheet: { + default_page_size: 20, + lists: { + public_list: { + type: 'public', + }, + private_list: { + type: 'private', + }, + story_sheets: { + type: 'has_many', + association_name: 'story_sheets', + }, + sheet_panels: { + type: 'has_many', + association_name: 'sheet_panels', + }, + }, }, sheet_panel: { + default_page_size: 20, + lists: { + public_list: { + type: 'public', + }, + private_list: { + type: 'private', + }, + by_sheet: { + type: 'filter', + filter_key: 'sheet_id', + list: { + method: 'filtered_list', + }, + }, + by_panel: { + type: 'filter', + filter_key: 'panel_id', + list: { + method: 'filtered_list', + }, + }, + }, }, panel: { }, @@ -2125,90 +2267,97 @@ system_picture: { }, }, - licenses: { - pettanr_creative_commons_v30_licenses: 'PettanrCreativeCommonsV30Licenses', - pettanr_pettan_commons_v01_licenses: 'PettanrPettanCommonsV01Licenses', - pettanr_pettan_protected_v01_licenses: 'PettanrPettanProtectedV01Licenses', - pettanr_pettan_public_v01_licenses: 'PettanrPettanPublicV01Licenses', - pettanr_public_domain_v01_licenses: 'PettanrPublicDomainV01Licenses', - pettanr_unknown_v01_licenses: 'PettanrUnknownV01Licenses', - }, - elements: { - PanelPicture: 'panel_pictures', - SpeechBalloon: 'speech_balloons', - GroundPicture: 'ground_pictures', - GroundColor: 'ground_colors', - }, - speech_balloon_templates: { - CircleSpeechBalloon: 'circle_speech_balloon', - PlainSpeechBalloon: 'plain_speech_balloon', - SquareSpeechBalloon: 'square_speech_balloon', - # TestSpeechBalloon: 'test_speech_balloon', - }, - writing_formats: { - SimpleFormat: 'pettanr_simple_format', - }, - profile: { - "users": { - "caption": "ペンギン王国", - "url": "http://localhost:3001/", - "description": "ペンギン王国はペンギン素材を豊富に用意したペンギンマニアのサイトです。", + system_resources: { + licenses: { + pettanr_creative_commons_v30_licenses: 'PettanrCreativeCommonsV30Licenses', + pettanr_pettan_commons_v01_licenses: 'PettanrPettanCommonsV01Licenses', + pettanr_pettan_protected_v01_licenses: 'PettanrPettanProtectedV01Licenses', + pettanr_pettan_public_v01_licenses: 'PettanrPettanPublicV01Licenses', + pettanr_public_domain_v01_licenses: 'PettanrPublicDomainV01Licenses', + pettanr_unknown_v01_licenses: 'PettanrUnknownV01Licenses', }, - "admins": { - "caption": "site name for admin", - "url": "http://your.site.url/admins/", - "description": "admin register", + elements: { + PanelPicture: 'panel_pictures', + SpeechBalloon: 'speech_balloons', + GroundPicture: 'ground_pictures', + GroundColor: 'ground_colors', + }, + speech_balloon_templates: { + CircleSpeechBalloon: 'circle_speech_balloon', + PlainSpeechBalloon: 'plain_speech_balloon', + SquareSpeechBalloon: 'square_speech_balloon', + # TestSpeechBalloon: 'test_speech_balloon', + }, + writing_formats: { + SimpleFormat: 'pettanr_simple_format', }, - "demand_users": { - "caption": "provider name", - "url": "http://your.site.url/demanders/", - "description": "provider description", - } }, 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: { provider_status_status_items: [ ['select_items.provider_status.status.waiting', 0], ['select_items.provider_status.status.receiving', 1], - ] + ], demander_status_status_items: [ ['select_items.demander_status.status.waiting', 0], ['select_items.demander_status.status.rejected', 1], ['select_items.demander_status.status.requesting', 2], ['select_items.demander_status.status.approved', 3], - ] + ], scroll_visible_items: [ ['select_items.scroll.visible.private', 0], ['select_items.scroll.visible.public', 1], - ] + ], comic_visible_items: [ ['select_items.comic.visible.private', 0], ['select_items.comic.visible.public', 1], - ] + ], story_visible_items: [ ['select_items.story.visible.private', 0], ['select_items.story.visible.public', 1], - ] + ], sheet_visible_items: [ ['select_items.sheet.visible.private', 0], ['select_items.sheet.visible.public', 1], - ] + ], panel_visible_items: [ ['select_items.panel.visible.private', 0], ['select_items.panel.visible.public', 1], - ] + ], ground_picture_repeat_items: [ ['select_items.ground_pictures.repeat.repeat', 0], ['select_items.ground_pictures.repeat.repeat-x', 1], ['select_items.ground_pictures.repeat.repeat-y', 2], ['select_items.ground_pictures.repeat.no-repeat', 3], - ] + ], ground_color_orientation_items: [ ['select_items.ground_color.orientation.horizontal', 0], ['select_items.ground_color.orientation.vertical', 1], - ] + ], speech_font_size_items: [ ['select_items.speeches.font_size.ultra_small', 0.2], ['select_items.speeches.font_size.very_small', 0.4], @@ -2219,16 +2368,13 @@ ['select_items.speeches.font_size.large', 2.0], ['select_items.speeches.font_size.very_large', 3.5], ['select_items.speeches.font_size.ultra_large', 5.0], - ] + ], speech_text_align_items: [ ['select_items.speeches.text_align.none', 0], ['select_items.speeches.text_align.left', 1], ['select_items.speeches.text_align.right', 2], ['select_items.speeches.text_align.center', 3], - ] - provider_sources: [ - 'http://sourceforge.jp/projects/pettanr/wiki/ProviderSource/attach/provider_source.json' - ] + ], }, locals: { profilers: { diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 5a7cc0d6..15e6292c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,4 +1,8 @@ module ApplicationHelper + def manifest + Pettanr::Application.manifest + end + def full_url filename request.protocol + request.host_with_port + filename end diff --git a/app/models/panel.rb b/app/models/panel.rb index 0f133cbd..d2bfdf75 100644 --- a/app/models/panel.rb +++ b/app/models/panel.rb @@ -28,7 +28,7 @@ class Panel < ActiveRecord::Base end def self.each_element_class_names - Pettanr::Application.elements.each do |k, n| + Pettanr::Application.manifest.system_resources.elements.each do |k, n| yield k end end diff --git a/app/models/speech_balloon_template.rb b/app/models/speech_balloon_template.rb index a6c6f75a..a639bf60 100644 --- a/app/models/speech_balloon_template.rb +++ b/app/models/speech_balloon_template.rb @@ -43,7 +43,7 @@ class SpeechBalloonTemplate < ActiveRecord::Base def self.enable_list SpeechBalloonTemplate.list.delete_if {|sbt| - Pettanr::Application.speech_balloons[sbt.classname] == nil + Pettanr::Application.manifest.system_resources.speech_balloon_templates[sbt.classname] == nil } end @@ -86,7 +86,7 @@ class SpeechBalloonTemplate < ActiveRecord::Base end def engine_name - Pettanr::Application.speech_balloons[self.classname] + Pettanr::Application.manifest.system_resources.speech_balloon_templates[self.classname] end def engine_module_name diff --git a/app/models/writing_format.rb b/app/models/writing_format.rb index 4cdfd73f..9ea43fc7 100644 --- a/app/models/writing_format.rb +++ b/app/models/writing_format.rb @@ -80,11 +80,11 @@ class WritingFormat < ActiveRecord::Base end def engine_name - Pettanr::Application.writing_formats[self.classname] + Pettanr::Application.manifest.system_resources.writing_formats[self.classname] end def enable? - Pettanr::Application.writing_formats.include? self.classname + Pettanr::Application.manifest.system_resources.writing_formats.include? self.classname end def engine_module_name diff --git a/app/views/layouts/test.html.erb b/app/views/layouts/test.html.erb index 93aeab0e..763fb69a 100644 --- a/app/views/layouts/test.html.erb +++ b/app/views/layouts/test.html.erb @@ -7,7 +7,7 @@ <% else %> <%= t("#{params[:controller]}.#{params[:action]}.title") %> <% end %> - - <%= h(MagicNumber['profile']['users']['caption']) %> + - <%= h(manifest.magic_numbers['profile']['users']['caption']) %> <%= stylesheet_link_tag "application" %> <%= javascript_include_tag "application" %> @@ -20,7 +20,7 @@
-

<%= link_to MagicNumber['profile']['users']['caption'], main_app.root_path %>

+

<%= link_to manifest.magic_numbers['profile']['users']['caption'], main_app.root_path %>

<% if user_signed_in? %> diff --git a/app/views/layouts/test.prof.erb b/app/views/layouts/test.prof.erb index 2a17f1d0..e819a265 100644 --- a/app/views/layouts/test.prof.erb +++ b/app/views/layouts/test.prof.erb @@ -7,7 +7,7 @@ <% else %> <%= t("#{params[:controller]}.#{params[:action]}.title") %> <% end %> - - <%= h(MagicNumber['profile']['users']['caption']) %> + - <%= h(manifest.magic_numbers['profile']['users']['caption']) %> <%= stylesheet_link_tag "application" %> <%= javascript_include_tag "application" %> diff --git a/config/application.rb b/config/application.rb index 4b9d94c9..dee52ea7 100644 --- a/config/application.rb +++ b/config/application.rb @@ -56,6 +56,7 @@ config.assets.initialize_on_precompile = false config.assets.version = '1.0' config.autoload_paths += %W(#{config.root}/lib/validators) +=begin def self.licenses=(ary) @@licenses = ary @@ -88,6 +89,7 @@ config.assets.initialize_on_precompile = false def self.elements @@elements || {} end +=end def self.manifest=(arg) @@manifest = Pettanr::Manifest.new arg @@ -104,18 +106,20 @@ config.assets.initialize_on_precompile = false end +=begin Pettanr::Application.licenses = YAML.load(open(Rails.root + 'config/license.yml').read) Pettanr::Application.speech_balloons = YAML.load(open(Rails.root + 'config/speech_balloon.yml').read) Pettanr::Application.writing_formats = YAML.load(open(Rails.root + 'config/writing_format.yml').read) Pettanr::Application.elements = YAML.load(open(Rails.root + 'config/element.yml').read) -MagicNumber = YAML.load(open(Rails.root + 'config/magic_number.yml').read) +=end +Pettanr::Application.manifest = JSON.parse(open(Rails.root + 'public/manifest.json').read) +MagicNumber = Pettanr::Application.manifest.magic_numbers +MagicNumber.merge! Pettanr::Application.manifest.select_items MagicNumber['test_layout'] = if File.exist? Rails.root + 'config/test_layout' 'test' else false end -MagicNumber['profile'] = JSON.parse(open(Rails.root + 'config/profile.json').read).first[1] #strip profile body -Pettanr::Application.manifest = JSON.parse(open(Rails.root + 'public/manifest.json').read) y = YAML.load(open(Rails.root + 'config/picture_io.yml').read) require y[Rails.env]["adapter"] diff --git a/config/routes.rb b/config/routes.rb index 1c0c1d53..a5b00247 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,10 +4,10 @@ Pettanr::Application.routes.draw do devise_for :admins devise_for :demand_users - Pettanr::Application.licenses.each do |name, klass| + Pettanr::Application.manifest.system_resources.licenses.each do |name, klass| mount Module.const_get(klass)::Engine => "/#{name}" end - Pettanr::Application.speech_balloons.each do |klass , name| + Pettanr::Application.manifest.system_resources.speech_balloon_templates.each do |klass , name| mount Module.const_get(klass)::Engine => "/#{name}" end diff --git a/lib/manifest/list.rb b/lib/manifest/list.rb index 047f9cac..1d41e0f3 100644 --- a/lib/manifest/list.rb +++ b/lib/manifest/list.rb @@ -136,7 +136,7 @@ module Pettanr @manifest = @list_manifest.manifest @list_conf = @list_manifest.conf @lists = {} - @list_conf.each {|list_name, conf| + (@list_conf['lists'] || {}).each {|list_name, conf| type = conf['type'] @lists[list_name] = @@types[type] } diff --git a/lib/manifest/manifest.rb b/lib/manifest/manifest.rb index 32b644a9..a61aa4a9 100644 --- a/lib/manifest/manifest.rb +++ b/lib/manifest/manifest.rb @@ -30,44 +30,16 @@ module Pettanr end - class License - attr :conf - def initialize manifest - @manifest = manifest - @conf = @manifest['licenses'] || {} - end - end - - class Element - attr :conf - def initialize manifest - @manifest = manifest - @conf = @manifest['elements'] || {} - end - end - - class SpeechBalloonTemplate - attr :conf - def initialize manifest - @manifest = manifest - @conf = @manifest['speech_balloon_templates'] || {} - end - end - - class WritingFormat - attr :conf - def initialize manifest - @manifest = manifest - @conf = @manifest['writing_formats'] || {} - end - end - - class Profile - attr :conf - def initialize manifest - @manifest = manifest - @conf = @manifest['profile'] || {} + class SystemResources + attr :conf, :licenses, :elements, :speech_balloon_templates, :writing_formats + def initialize system_resource_conf + @conf = system_resource_conf || {} + @licenses = @conf['licenses'] || {} + @elements = @conf['elements'] || {} + @speech_balloon_templates = @conf['speech_balloon_templates'] || {} + @writing_formats = @conf['writing_formats'] || {} end + end class Profiler @@ -111,17 +83,15 @@ module Pettanr end - attr :licenses, :elements, :speech_balloon_templates, :writing_formats, :profile, + attr :system_resources, :magic_numbers, :select_items, :model_managers, :list_managers, :profiler_managers, :filer_managers, :form_managers def initialize manifest @manifest = manifest || {} + @system_resources = SystemResources.new(@manifest['system_resources']) + @magic_numbers = @manifest['magic_numbers'] + @select_items = @manifest['select_items'] @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 = {} diff --git a/public/manifest.json b/public/manifest.json index 12e91e3a..66cabfc5 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -2019,25 +2019,28 @@ }, "lists": { "scroll": { - "public_list": { - "type": "public" - }, - "private_list": { - "type": "private" - }, - "scroll_panels": { - "type": "has_many", - "association_name": "scroll_panels" - }, - "panels": { - "type": "has_many", - "association_name": "panels" - }, - "by_panel": { - "type": "filter", - "filter_key": "scroll_id", - "list": { - "method": "filtered_list" + "default_page_size": 20, + "lists": { + "public_list": { + "type": "public" + }, + "private_list": { + "type": "private" + }, + "scroll_panels": { + "type": "has_many", + "association_name": "scroll_panels" + }, + "panels": { + "type": "has_many", + "association_name": "panels" + }, + "by_panel": { + "type": "filter", + "filter_key": "scroll_id", + "list": { + "method": "filtered_list" + } } } }, @@ -2065,49 +2068,56 @@ "artist": {}, "system_picture": {} }, - "licenses": { - "pettanr_creative_commons_v30_licenses": "PettanrCreativeCommonsV30Licenses", - "pettanr_pettan_commons_v01_licenses": "PettanrPettanCommonsV01Licenses", - "pettanr_pettan_protected_v01_licenses": "PettanrPettanProtectedV01Licenses", - "pettanr_pettan_public_v01_licenses": "PettanrPettanPublicV01Licenses", - "pettanr_public_domain_v01_licenses": "PettanrPublicDomainV01Licenses", - "pettanr_unknown_v01_licenses": "PettanrUnknownV01Licenses" - }, - "elements": { - "PanelPicture": "panel_pictures", - "SpeechBalloon": "speech_balloons", - "GroundPicture": "ground_pictures", - "GroundColor": "ground_colors" - }, - "speech_balloon_templates": { - "CircleSpeechBalloon": "circle_speech_balloon", - "PlainSpeechBalloon": "plain_speech_balloon", - "SquareSpeechBalloon": "square_speech_balloon" - }, - "writing_formats": { - "SimpleFormat": "pettanr_simple_format" - }, - "profile": { - "users": { - "caption": "ƒyƒ“ƒMƒ“‰¤‘", - "url": "http://localhost:3001/", - "description": "ƒyƒ“ƒMƒ“‰¤‘‚̓yƒ“ƒMƒ“‘fÞ‚ð–L•x‚É—pˆÓ‚µ‚½ƒyƒ“ƒMƒ“ƒ}ƒjƒA‚̃TƒCƒg‚Å‚·B" + "system_resources": { + "licenses": { + "pettanr_creative_commons_v30_licenses": "PettanrCreativeCommonsV30Licenses", + "pettanr_pettan_commons_v01_licenses": "PettanrPettanCommonsV01Licenses", + "pettanr_pettan_protected_v01_licenses": "PettanrPettanProtectedV01Licenses", + "pettanr_pettan_public_v01_licenses": "PettanrPettanPublicV01Licenses", + "pettanr_public_domain_v01_licenses": "PettanrPublicDomainV01Licenses", + "pettanr_unknown_v01_licenses": "PettanrUnknownV01Licenses" }, - "admins": { - "caption": "site name for admin", - "url": "http://your.site.url/admins/", - "description": "admin register" + "elements": { + "PanelPicture": "panel_pictures", + "SpeechBalloon": "speech_balloons", + "GroundPicture": "ground_pictures", + "GroundColor": "ground_colors" }, - "demand_users": { - "caption": "provider name", - "url": "http://your.site.url/demanders/", - "description": "provider description" + "speech_balloon_templates": { + "CircleSpeechBalloon": "circle_speech_balloon", + "PlainSpeechBalloon": "plain_speech_balloon", + "SquareSpeechBalloon": "square_speech_balloon" + }, + "writing_formats": { + "SimpleFormat": "pettanr_simple_format" } }, "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": { "provider_status_status_items": [ [ "select_items.provider_status.status.waiting", @@ -2269,9 +2279,6 @@ "select_items.speeches.text_align.center", 3 ] - ], - "provider_sources": [ - "http://sourceforge.jp/projects/pettanr/wiki/ProviderSource/attach/provider_source.json" ] }, "locals": { -- 2.11.0