From 62c02bb06a5d343682992461a43df9188f9a7a2f Mon Sep 17 00:00:00 2001 From: yasushiito Date: Mon, 13 Jan 2014 11:26:45 +0900 Subject: [PATCH] fix Manifest --- .../manifest/work/controllers.js.coffee.erb | 239 +++---- .../javascripts/manifest/work/lists.js.coffee.erb | 60 +- .../javascripts/manifest/work/models.js.coffee.erb | 698 ++++++++++++++++++- app/controllers/application_controller.rb | 16 +- app/controllers/artists_controller.rb | 3 +- app/controllers/authors_controller.rb | 3 +- app/controllers/balloons_controller.rb | 3 +- app/controllers/comics_controller.rb | 3 +- app/controllers/demander_statuses_controller.rb | 1 - app/controllers/demanders_controller.rb | 1 - app/controllers/ground_colors_controller.rb | 3 +- app/controllers/ground_pictures_controller.rb | 3 +- app/controllers/home_controller.rb | 1 - app/controllers/license_groups_controller.rb | 1 - app/controllers/licenses_controller.rb | 3 +- .../original_picture_license_groups_controller.rb | 1 - app/controllers/original_pictures_controller.rb | 1 - app/controllers/panel_pictures_controller.rb | 3 +- app/controllers/panels_controller.rb | 3 +- app/controllers/pictures_controller.rb | 3 +- app/controllers/provider_sources_controller.rb | 1 - app/controllers/provider_statuses_controller.rb | 1 - app/controllers/providers_controller.rb | 1 - app/controllers/resource_pictures_controller.rb | 3 +- app/controllers/scroll_panels_controller.rb | 3 +- app/controllers/scrolls_controller.rb | 3 +- app/controllers/sheet_panels_controller.rb | 3 +- app/controllers/sheets_controller.rb | 3 +- .../speech_balloon_templates_controller.rb | 3 +- app/controllers/speech_balloons_controller.rb | 3 +- app/controllers/speeches_controller.rb | 3 +- app/controllers/stories_controller.rb | 3 +- app/controllers/story_sheets_controller.rb | 3 +- app/controllers/system_pictures_controller.rb | 3 +- app/controllers/top_controller.rb | 3 +- app/controllers/writing_formats_controller.rb | 3 +- app/helpers/application_helper.rb | 2 +- app/models/speech_balloon_template.rb | 4 +- app/models/writing_format.rb | 4 +- app/views/layouts/application.html.erb | 169 +++-- .../{test.prof.erb => application.prof.erb} | 0 app/views/layouts/system.html.erb | 2 +- config/application.rb | 23 +- config/environment.rb | 4 +- config/environments/development.rb | 2 +- config/routes.rb | 5 +- lib/manifest.rb | 16 +- lib/manifest/controller.rb | 135 +--- lib/manifest/controller/list.rb | 62 ++ lib/manifest/controller/show.rb | 43 ++ lib/manifest/filer.rb | 24 +- lib/manifest/form.rb | 13 + lib/manifest/list.rb | 495 ++----------- lib/manifest/manifest.rb | 172 +---- lib/manifest/model.rb | 100 +-- lib/manifest/model/association.rb | 50 ++ lib/manifest/model/association/belongs_to.rb | 29 + lib/manifest/model/association/has_many.rb | 32 + lib/manifest/model/association/has_one.rb | 31 + lib/manifest/model/attribute.rb | 35 + lib/manifest/model/list.rb | 10 + lib/manifest/model/list/base.rb | 95 +++ lib/manifest/model/list/element_filter.rb | 29 + lib/manifest/model/list/filter.rb | 52 ++ lib/manifest/model/list/has_many.rb | 66 ++ lib/manifest/model/list/has_many_through.rb | 53 ++ lib/manifest/model/list/play.rb | 115 +++ lib/manifest/model/list/private.rb | 38 + lib/manifest/model/list/public.rb | 30 + lib/manifest/model/list/system_resource.rb | 23 + lib/manifest/model/list/through_filter.rb | 29 + lib/manifest/profiler.rb | 16 + lib/manifest/system_resources.rb | 36 + public/manifest.json | 775 ++++++++++++++++----- 74 files changed, 2672 insertions(+), 1238 deletions(-) rename app/views/layouts/{test.prof.erb => application.prof.erb} (100%) create mode 100644 lib/manifest/controller/list.rb create mode 100644 lib/manifest/controller/show.rb create mode 100644 lib/manifest/model/association.rb create mode 100644 lib/manifest/model/association/belongs_to.rb create mode 100644 lib/manifest/model/association/has_many.rb create mode 100644 lib/manifest/model/association/has_one.rb create mode 100644 lib/manifest/model/attribute.rb create mode 100644 lib/manifest/model/list.rb create mode 100644 lib/manifest/model/list/base.rb create mode 100644 lib/manifest/model/list/element_filter.rb create mode 100644 lib/manifest/model/list/filter.rb create mode 100644 lib/manifest/model/list/has_many.rb create mode 100644 lib/manifest/model/list/has_many_through.rb create mode 100644 lib/manifest/model/list/play.rb create mode 100644 lib/manifest/model/list/private.rb create mode 100644 lib/manifest/model/list/public.rb create mode 100644 lib/manifest/model/list/system_resource.rb create mode 100644 lib/manifest/model/list/through_filter.rb create mode 100644 lib/manifest/system_resources.rb diff --git a/app/assets/javascripts/manifest/work/controllers.js.coffee.erb b/app/assets/javascripts/manifest/work/controllers.js.coffee.erb index caf24e9c..149f7319 100644 --- a/app/assets/javascripts/manifest/work/controllers.js.coffee.erb +++ b/app/assets/javascripts/manifest/work/controllers.js.coffee.erb @@ -1,41 +1,40 @@ #マニフェスト @controllers = { scroll: { - item_name: 'scroll', actions: { index: { type: 'list', - options: { + args: { list_name: 'public_list', }, }, scroll_panels: { type: 'list', - options: { + args: { list_name: 'scroll_panels', }, }, panels: { type: 'list', - list: { + args: { list_name: 'panels', }, }, by_author: { type: 'list', - list: { + args: { list_name: 'by_author', }, }, by_panel: { type: 'list', - list: { + args: { list_name: 'by_panel', }, }, play: { type: 'list', - list: { + args: { list_name: 'play', }, }, @@ -46,431 +45,417 @@ }, }, scroll_panel: { - model_name: 'scroll_panel', actions: { index: { type: 'list', - list: { + args: { list_name: 'public_list', }, }, by_panel: { type: 'list', - list: { + args: { list_name: 'by_panel', }, }, by_scroll: { type: 'list', - list: { + args: { list_name: 'by_scroll', }, }, }, }, comic: { - model_name: 'comic', actions: { index: { type: 'list', - list: { + args: { list_name: 'public_list', }, }, stories: { type: 'list', - list: { + args: { list_name: 'stories', }, }, by_author: { type: 'list', - list: { + args: { list_name: 'by_author', }, }, }, }, story: { - model_name: 'story', actions: { index: { type: 'list', - list: { + args: { list_name: 'public_list', }, }, story_sheets: { type: 'list', - list: { + args: { list_name: 'story_sheets', }, }, sheets: { type: 'list', - list: { + args: { list_name: 'sheets', }, }, by_comic: { type: 'list', - list: { + args: { list_name: 'by_comic', }, }, by_sheet: { type: 'list', - list: { + args: { list_name: 'by_sheet', }, }, by_author: { type: 'list', - list: { + args: { list_name: 'by_author', }, }, play: { type: 'list', - list: { + args: { list_name: 'play', }, }, }, }, story_sheet: { - model_name: 'story_sheet', actions: { index: { type: 'list', - list: { + args: { list_name: 'public_list', }, }, by_story: { type: 'list', - list: { + args: { list_name: 'by_story', }, }, by_sheet: { type: 'list', - list: { + args: { list_name: 'by_sheet', }, }, }, }, sheet: { - model_name: 'sheet', actions: { index: { type: 'list', - list: { + args: { list_name: 'public_list', }, }, story_sheets: { type: 'list', - list: { + args: { list_name: 'story_sheets', }, }, stories: { type: 'list', - list: { + args: { list_name: 'stories', }, }, sheet_panels: { type: 'list', - list: { + args: { list_name: 'sheet_panels', }, }, panels: { type: 'list', - list: { + args: { list_name: 'panels', }, }, by_story: { type: 'list', - list: { + args: { list_name: 'by_story', }, }, by_panel: { type: 'list', - list: { + args: { list_name: 'by_panel', }, }, by_author: { type: 'list', - list: { + args: { list_name: 'by_author', }, }, play: { type: 'list', - list: { + args: { list_name: 'play', }, }, }, }, sheet_panel: { - model_name: 'sheet_panel', actions: { index: { type: 'list', - list: { + args: { list_name: 'public_list', }, }, by_sheet: { type: 'list', - list: { + args: { list_name: 'by_sheet', }, }, by_panel: { type: 'list', - list: { + args: { list_name: 'by_panel', }, }, }, }, panel: { - model_name: 'panel', actions: { index: { type: 'list', - list: { + args: { list_name: 'public_list', }, }, scroll_panels: { type: 'list', - list: { + args: { list_name: 'scroll_panels', }, }, scrolls: { type: 'list', - list: { + args: { list_name: 'scrolls', }, }, sheet_panels: { type: 'list', - list: { + args: { list_name: 'sheet_panels', }, }, sheets: { type: 'list', - list: { + args: { list_name: 'sheets', }, }, panel_pictures: { type: 'list', - list: { + args: { list_name: 'panel_pictures', }, }, speech_balloons: { type: 'list', - list: { + args: { list_name: 'speech_balloons', }, }, ground_pictures: { type: 'list', - list: { + args: { list_name: 'ground_pictures', }, }, ground_colors: { type: 'list', - list: { + args: { list_name: 'ground_colors', }, }, by_scroll: { type: 'list', - list: { + args: { list_name: 'by_scroll', }, }, by_sheet: { type: 'list', - list: { + args: { list_name: 'by_sheet', }, }, by_author: { type: 'list', - list: { + args: { list_name: 'by_author', }, }, by_speech_balloon_template: { type: 'list', - list: { + args: { list_name: 'by_speech_balloon_template', }, }, }, }, panel_picture: { - model_name: 'panel_picture', actions: { index: { type: 'list', - list: { + args: { list_name: 'public_list', }, }, by_panel: { type: 'list', - list: { + args: { list_name: 'by_panel', }, }, by_author: { type: 'list', - list: { + args: { list_name: 'by_author', }, }, }, }, speech_balloon: { - model_name: 'speech_balloon', actions: { index: { type: 'list', - list: { + args: { list_name: 'public_list', }, }, by_panel: { type: 'list', - list: { + args: { list_name: 'by_panel', }, }, by_author: { type: 'list', - list: { + args: { list_name: 'by_author', }, }, }, }, speech: { - model_name: 'speech', actions: { index: { type: 'list', - list: { + args: { list_name: 'public_list', }, }, by_writing_format: { type: 'list', - list: { + args: { list_name: 'by_writing_format', }, }, }, }, balloon: { - model_name: 'balloon', actions: { index: { type: 'list', - list: { + args: { list_name: 'public_list', }, }, #by_system_picture: { # type: 'list', - # list: { + # args: { # list_name: 'by_system_picture', # }, #}, }, }, ground_picture: { - model_name: 'ground_picture', actions: { index: { type: 'list', - list: { + args: { list_name: 'public_list', }, }, by_panel: { type: 'list', - list: { + args: { list_name: 'by_panel', }, }, by_author: { type: 'list', - list: { + args: { list_name: 'by_author', }, }, }, }, ground_color: { - model_name: 'ground_color', actions: { index: { type: 'list', - list: { + args: { list_name: 'public_list', }, }, by_panel: { type: 'list', - list: { + args: { list_name: 'by_panel', }, }, by_author: { type: 'list', - list: { + args: { list_name: 'by_author', }, }, }, }, original_picture: { - model_name: 'original_picture', actions: { index: { type: 'list', - list: { + args: { list_name: 'private_list', }, @@ -480,215 +465,207 @@ picture: { }, resource_picture: { - model_name: 'resource_picture', actions: { index: { type: 'list', - list: { + args: { list_name: 'public_list', }, }, by_license: { type: 'list', - list: { + args: { list_name: 'by_license', }, }, by_artist: { type: 'list', - list: { + args: { list_name: 'by_artist', }, }, }, }, speech_balloon_template: { - model_name: 'speech_balloon_template', actions: { index: { type: 'list', - list: { + args: { list_name: 'public_list', }, }, speech_balloons: { type: 'list', - list: { + args: { list_name: 'speech_balloons', }, }, panels: { type: 'list', - list: { + args: { list_name: 'panels', }, }, }, }, writing_format: { - model_name: 'writing_format', actions: { index: { type: 'list', - list: { + args: { list_name: 'public_list', }, }, speeches: { type: 'list', - list: { + args: { list_name: 'speeches', }, }, by_system_picture: { type: 'list', - list: { + args: { list_name: 'by_system_picture', }, }, }, }, license_group: { - model_name: 'license_group', actions: { index: { type: 'list', - list: { + args: { list_name: 'public_list', }, }, licenses: { type: 'list', - list: { + args: { list_name: 'licenses', }, }, }, }, license: { - model_name: 'license', actions: { index: { type: 'list', - list: { + args: { list_name: 'public_list', }, }, resource_pictures: { type: 'list', - list: { + args: { list_name: 'resource_pictures', }, }, by_license_group: { type: 'list', - list: { + args: { list_name: 'by_license_group', }, }, by_system_picture: { type: 'list', - list: { + args: { list_name: 'by_system_picture', }, }, }, }, author: { - model_name: 'author', actions: { index: { type: 'list', - list: { + args: { list_name: 'public_list', }, }, scrolls: { type: 'list', - list: { + args: { list_name: 'scrolls', }, }, comics: { type: 'list', - list: { + args: { list_name: 'comics', }, }, stories: { type: 'list', - list: { + args: { list_name: 'stories', }, }, sheets: { type: 'list', - list: { + args: { list_name: 'sheets', }, }, panels: { type: 'list', - list: { + args: { list_name: 'panels', }, }, panel_pictures: { type: 'list', - list: { + args: { list_name: 'panel_pictures', }, }, speech_balloons: { type: 'list', - list: { + args: { list_name: 'speech_balloons', }, }, ground_pictures: { type: 'list', - list: { + args: { list_name: 'ground_pictures', }, }, ground_colors: { type: 'list', - list: { + args: { list_name: 'ground_colors', }, }, }, }, artist: { - model_name: 'artist', actions: { index: { type: 'list', - list: { + args: { list_name: 'public_list', }, }, resource_pictures: { type: 'list', - list: { + args: { list_name: 'resource_pictures', }, }, }, }, system_picture: { - model_name: 'system_picture', actions: { index: { type: 'list', - list: { + args: { list_name: 'public_list', }, @@ -700,7 +677,7 @@ scrolls: { item_name: 'scroll', type: 'list', - list: { + args: { list_name: 'private_list', }, @@ -708,7 +685,7 @@ scroll_panels: { item_name: 'scroll_panel', type: 'list', - list: { + args: { list_name: 'private_list', }, @@ -716,7 +693,7 @@ comics: { item_name: 'comic', type: 'list', - list: { + args: { list_name: 'private_list', }, @@ -724,7 +701,7 @@ stories: { item_name: 'story', type: 'list', - list: { + args: { list_name: 'private_list', }, @@ -732,7 +709,7 @@ story_sheets: { item_name: 'story_sheet', type: 'list', - list: { + args: { list_name: 'private_list', }, @@ -740,7 +717,7 @@ sheets: { item_name: 'sheet', type: 'list', - list: { + args: { list_name: 'private_list', }, @@ -748,7 +725,7 @@ sheet_panels: { item_name: 'sheet_panel', type: 'list', - list: { + args: { list_name: 'private_list', }, @@ -756,7 +733,7 @@ panels: { item_name: 'panel', type: 'list', - list: { + args: { list_name: 'private_list', }, @@ -764,7 +741,7 @@ panel_pictures: { item_name: 'panel_picture', type: 'list', - list: { + args: { list_name: 'private_list', }, @@ -772,7 +749,7 @@ speech_balloons: { item_name: 'speech_balloon', type: 'list', - list: { + args: { list_name: 'private_list', }, @@ -780,7 +757,7 @@ speeches: { item_name: 'speech', type: 'list', - list: { + args: { list_name: 'private_list', }, @@ -788,7 +765,7 @@ balloons: { item_name: 'balloon', type: 'list', - list: { + args: { list_name: 'private_list', }, @@ -796,7 +773,7 @@ ground_pictures: { item_name: 'ground_picture', type: 'list', - list: { + args: { list_name: 'private_list', }, @@ -804,7 +781,7 @@ ground_colors: { item_name: 'ground_color', type: 'list', - list: { + args: { list_name: 'private_list', }, @@ -812,7 +789,7 @@ original_pictures: { item_name: 'original_picture', type: 'list', - list: { + args: { list_name: 'private_list', }, @@ -820,7 +797,7 @@ resource_pictures: { item_name: 'resource_picture', type: 'list', - list: { + args: { list_name: 'private_list', }, diff --git a/app/assets/javascripts/manifest/work/lists.js.coffee.erb b/app/assets/javascripts/manifest/work/lists.js.coffee.erb index 99ef80c3..7bc0110a 100644 --- a/app/assets/javascripts/manifest/work/lists.js.coffee.erb +++ b/app/assets/javascripts/manifest/work/lists.js.coffee.erb @@ -1,35 +1,37 @@ #マニフェスト @lists = { scroll: { - public_list: { - type: 'public', - }, - private_list: { - type: 'private', - }, - scroll_panels: { - type: 'has_many', - association_name: 'scroll_panels', - }, - panels: { - type: 'has_many_through', - association_name: 'panels', - }, - by_author: { - type: 'filter', - from: 'author', - filter_key: 'author_id', - }, - by_panel: { - type: 'through_filter', - from: 'panel', - through: 'scroll_panels', - filter_key: 'panel_id', - }, - play: { - type: 'play', - model: 'scroll_panel', - filter_key: 'scroll_id', + lists: { + public_list: { + type: 'public', + }, + private_list: { + type: 'private', + }, + scroll_panels: { + type: 'has_many', + association_name: 'scroll_panels', + }, + panels: { + type: 'has_many_through', + association_name: 'panels', + }, + by_author: { + type: 'filter', + from: 'author', + filter_key: 'author_id', + }, + by_panel: { + type: 'through_filter', + from: 'panel', + through: 'scroll_panels', + filter_key: 'panel_id', + }, + play: { + type: 'play', + model: 'scroll_panel', + filter_key: 'scroll_id', + }, }, }, scroll_panel: { diff --git a/app/assets/javascripts/manifest/work/models.js.coffee.erb b/app/assets/javascripts/manifest/work/models.js.coffee.erb index 594c6ed0..fa8f5042 100644 --- a/app/assets/javascripts/manifest/work/models.js.coffee.erb +++ b/app/assets/javascripts/manifest/work/models.js.coffee.erb @@ -1,6 +1,5 @@ #マニフェスト @models = { - Scroll: 'scroll', scroll: { class_name: 'Scroll', table_name: 'scrolls', @@ -66,8 +65,49 @@ type: 'datetime', } }, + lists: { + public_list: { + type: 'public', + }, + private_list: { + type: 'private', + }, + scroll_panels: { + type: 'has_many', + args: { + association_name: 'scroll_panels', + }, + }, + panels: { + type: 'has_many_through', + args: { + association_name: 'panels', + }, + }, + by_author: { + type: 'filter', + args: { + from: 'author', + filter_key: 'author_id', + }, + }, + by_panel: { + type: 'through_filter', + args: { + from: 'panel', + through: 'scroll_panels', + filter_key: 'panel_id', + }, + }, + play: { + type: 'play', + args: { + model: 'scroll_panel', + filter_key: 'scroll_id', + }, + }, + }, }, - ScrollPanel: 'scroll_panel', scroll_panel: { class_name: 'ScrollPanel', table_name: 'scroll_panels', @@ -127,8 +167,29 @@ type: 'datetime', } }, + lists: { + public_list: { + type: 'public', + }, + private_list: { + type: 'private', + }, + by_scroll: { + type: 'filter', + args: { + from: 'scroll', + filter_key: 'scroll_id', + }, + }, + by_panel: { + type: 'filter', + args: { + from: 'panel', + filter_key: 'panel_id', + }, + }, + }, }, - Comic: 'comic', comic: { class_name: 'Comic', table_name: 'comics', @@ -191,8 +252,28 @@ type: 'datetime', } }, + lists: { + public_list: { + type: 'public', + }, + private_list: { + type: 'private', + }, + stories: { + type: 'has_many', + args: { + association_name: 'stories', + }, + }, + by_author: { + type: 'filter', + args: { + from: 'author', + filter_key: 'author_id', + }, + }, + }, }, - Story: 'story', story: { class_name: 'Story', table_name: 'stories', @@ -264,8 +345,56 @@ type: 'datetime', } }, + lists: { + public_list: { + type: 'public', + }, + private_list: { + type: 'private', + }, + story_sheets: { + type: 'has_many', + args: { + association_name: 'story_sheets', + }, + }, + sheets: { + type: 'has_many', + args: { + association_name: 'sheets', + }, + }, + by_comic: { + type: 'filter', + args: { + from: 'comic', + filter_key: 'comic_id', + }, + }, + by_sheet: { + type: 'through_filter', + args: { + from: 'sheet', + through: 'story_sheets', + filter_key: 'sheet_id', + }, + }, + by_author: { + args: { + type: 'element_filter', + from: 'author', + filter_key: 'author_id', + }, + }, + play: { + type: 'play', + args: { + model: 'story_sheet', + filter_key: 'story_id', + }, + }, + }, }, - StorySheet: 'story_sheet', story_sheet: { class_name: 'StorySheet', table_name: 'story_sheets', @@ -322,9 +451,30 @@ updated_at: { type: 'datetime', } - } + }, + lists: { + public_list: { + type: 'public', + }, + private_list: { + type: 'private', + }, + by_story: { + type: 'filter', + args: { + from: 'story', + filter_key: 'story_id', + }, + }, + by_sheet: { + type: 'filter', + args: { + from: 'sheet', + filter_key: 'sheet_id', + }, + }, + }, }, - Sheet: 'sheet', sheet: { class_name: 'Sheet', table_name: 'sheets', @@ -407,8 +557,69 @@ type: 'datetime', } }, + lists: { + public_list: { + type: 'public', + }, + private_list: { + type: 'private', + }, + story_sheets: { + type: 'has_many', + args: { + association_name: 'story_sheets', + }, + }, + stories: { + type: 'has_many', + args: { + association_name: 'stories', + }, + }, + sheet_panels: { + type: 'has_many', + args: { + association_name: 'sheet_panels', + }, + }, + panels: { + type: 'has_many', + args: { + association_name: 'panels', + }, + }, + by_story: { + type: 'through_filter', + args: { + from: 'story', + through: 'story_sheets', + filter_key: 'story_id', + }, + }, + by_panel: { + type: 'through_filter', + args: { + from: 'panel', + through: 'sheet_panels', + filter_key: 'panel_id', + }, + }, + by_author: { + type: 'filter', + args: { + from: 'author', + filter_key: 'author_id', + }, + }, + play: { + type: 'play', + args: { + model: 'sheet_panel', + filter_key: 'sheet_id', + }, + }, + }, }, - SheetPanel: 'sheet_panel', sheet_panel: { class_name: 'SheetPanel', table_name: 'sheet_panels', @@ -486,9 +697,31 @@ updated_at: { type: 'datetime', } - } + }, + lists: { + public_list: { + type: 'public', + }, + private_list: { + type: 'private', + }, + by_sheet: { + type: 'filter', + args: { + association_name: 'sheet_panels', + from: 'sheet', + filter_key: 'sheet_id', + }, + }, + by_panel: { + type: 'filter', + args: { + from: 'panel', + filter_key: 'panel_id', + }, + }, + }, }, - Panel: 'panel', panel: { class_name: 'Panel', table_name: 'panels', @@ -597,8 +830,94 @@ type: 'datetime', } }, + lists: { + public_list: { + type: 'public', + }, + private_list: { + type: 'private', + }, + scroll_panels: { + type: 'has_many', + args: { + association_name: 'scroll_panels', + }, + }, + scrolls: { + type: 'has_many', + args: { + association_name: 'scrolls', + }, + }, + sheet_panels: { + type: 'has_many', + args: { + association_name: 'sheet_panels', + }, + }, + sheets: { + type: 'has_many', + args: { + association_name: 'sheets', + }, + }, + panel_pictures: { + type: 'has_many', + args: { + association_name: 'panel_pictures', + }, + }, + speech_balloons: { + type: 'has_many', + args: { + association_name: 'speech_balloons', + }, + }, + ground_pictures: { + type: 'has_many', + args: { + association_name: 'ground_pictures', + }, + }, + ground_colors: { + type: 'has_many', + args: { + association_name: 'ground_colors', + }, + }, + by_scroll: { + type: 'through_filter', + args: { + from: 'scroll', + through: 'scroll_panels', + filter_key: 'scroll_id', + }, + }, + by_sheet: { + type: 'through_filter', + args: { + from: 'sheet', + through: 'sheet_panels', + filter_key: 'sheet_id', + }, + }, + by_author: { + type: 'filter', + args: { + from: 'author', + filter_key: 'author_id', + }, + }, + by_speech_balloon_template: { + type: 'through_filter', + args: { + from: 'speech_balloon_template', + through: 'speech_balloons', + filter_key: 'speech_balloon_template_id', + }, + }, + }, }, - PanelPicture: 'panel_picture', panel_picture: { class_name: 'PanelPicture', table_name: 'panel_pictures', @@ -693,9 +1012,30 @@ updated_at: { type: 'datetime', } - } + }, + lists: { + public_list: { + type: 'public', + }, + private_list: { + type: 'private', + }, + by_panel: { + type: 'filter', + args: { + from: 'panel', + filter_key: 'panel_id', + }, + }, + by_author: { + type: 'element_filter', + args: { + from: 'author', + filter_key: 'author_id', + }, + }, + }, }, - SpeechBalloon: 'speech_balloon', speech_balloon: { class_name: 'SpeechBalloon', table_name: 'speech_balloons', @@ -779,8 +1119,36 @@ type: 'datetime', } }, + lists: { + public_list: { + type: 'public', + }, + private_list: { + type: 'private', + }, + by_panel: { + type: 'filter', + args: { + from: 'panel', + filter_key: 'panel_id', + }, + }, + by_speech_balloon_template: { + type: 'filter', + args: { + from: 'speech_balloon_template', + filter_key: 'speech_balloon_template_id', + }, + }, + by_author: { + type: 'element_filter', + args: { + from: 'author', + filter_key: 'author_id', + }, + }, + }, }, - Balloon: 'balloon', balloon: { class_name: 'Balloon', table_name: 'balloons', @@ -865,9 +1233,37 @@ updated_at: { type: 'datetime', } - } + }, + lists: { + public_list: { + type: 'public', + }, + private_list: { + type: 'private', + }, + by_panel: { + type: 'filter', + args: { + from: 'panel', + filter_key: 'panel_id', + }, + }, + by_speech_balloon_template: { + type: 'filter', + args: { + from: 'speech_balloon_template', + filter_key: 'speech_balloon_template_id', + }, + }, + by_author: { + type: 'element_filter', + args: { + from: 'author', + filter_key: 'author_id', + }, + }, + }, }, - Speech: 'speech', speech: { class_name: 'Speech', table_name: 'speeches', @@ -991,9 +1387,28 @@ updated_at: { type: 'datetime', } - } + }, + lists: { + public_list: { + type: 'public', + }, + by_speech_balloon: { + type: 'filter', + args: { + from: 'speech_balloon', + includes: {speech_balloon: {panel: {}}}, + filter_key: 'speech_balloon_id', + }, + }, + by_writing_format: { + type: 'filter', + args: { + from: 'writing_format', + filter_key: 'writing_format_id', + }, + }, + }, }, - GroundPicture: 'ground_picture', ground_picture: { class_name: 'GroundPicture', table_name: 'ground_pictures', @@ -1080,9 +1495,30 @@ updated_at: { type: 'datetime', } - } + }, + lists: { + public_list: { + type: 'public', + }, + private_list: { + type: 'private', + }, + by_panel: { + type: 'filter', + args: { + from: 'panel', + filter_key: 'panel_id', + }, + }, + by_author: { + type: 'element_filter', + args: { + from: 'author', + filter_key: 'author_id', + }, + }, + }, }, - GroundColor: 'ground_color', ground_color: { class_name: 'GroundColor', table_name: 'ground_colors', @@ -1168,9 +1604,30 @@ updated_at: { type: 'datetime', } - } + }, + lists: { + public_list: { + type: 'public', + }, + private_list: { + type: 'private', + }, + by_panel: { + type: 'filter', + args: { + from: 'panel', + filter_key: 'panel_id', + }, + }, + by_author: { + type: 'element_filter', + args: { + from: 'author', + filter_key: 'author_id', + }, + }, + }, }, - OriginalPicture: 'original_picture', original_picture: { class_name: 'OriginalPicture', table_name: 'original_pictures', @@ -1258,8 +1715,12 @@ type: 'datetime', } }, + lists: { + private_list: { + type: 'private', + }, + }, }, - Picture: 'picture', picture: { class_name: 'Picture', table_name: 'pictures', @@ -1376,7 +1837,6 @@ } } }, - ResourcePicture: 'resource_picture', resource_picture: { class_name: 'ResourcePicture', table_name: 'resource_pictures', @@ -1501,9 +1961,30 @@ updated_at: { type: 'datetime', } - } + }, + lists: { + public_list: { + type: 'public', + }, + private_list: { + type: 'private', + }, + by_license: { + type: 'filter', + args: { + from: 'license', + filter_key: 'license_id', + }, + }, + by_artist: { + type: 'filter', + args: { + from: 'artist', + filter_key: 'artist_id', + }, + }, + }, }, - SpeechBalloonTemplate: 'speech_balloon_template', speech_balloon_template: { class_name: 'SpeechBalloonTemplate', table_name: 'speech_balloon_templates', @@ -1581,8 +2062,27 @@ type: 'datetime', } }, + lists: { + public_list: { + type: 'public', + }, + select_items: { + type: 'system_resource', + }, + speech_balloons: { + type: 'has_many', + args: { + association_name: 'speech_balloons', + }, + }, + panels: { + type: 'has_many', + args: { + association_name: 'panels', + }, + }, + }, }, - WritingFormat: 'writing_format', writing_format: { class_name: 'WritingFormat', table_name: 'writing_formats', @@ -1647,8 +2147,28 @@ type: 'datetime', } }, + lists: { + public_list: { + type: 'public', + }, + select_items: { + type: 'system_resource', + }, + speeches: { + type: 'has_many', + args: { + association_name: 'speeches', + }, + }, + by_system_picture: { + type: 'filter', + args: { + from: 'system_picture', + filter_key: 'system_picture_id', + }, + }, + }, }, - LicenseGroup: 'license_group', license_group: { class_name: 'LicenseGroup', table_name: 'license_groups', @@ -1703,8 +2223,21 @@ type: 'datetime', } }, + lists: { + public_list: { + type: 'public', + }, + select_items: { + type: 'system_resource', + }, + licenses: { + type: 'has_many', + args: { + association_name: 'licenses', + }, + }, + }, }, - License: 'license', license: { class_name: 'License', table_name: 'licenses', @@ -1781,9 +2314,33 @@ updated_at: { type: 'datetime', } - } + }, + lists: { + public_list: { + type: 'public', + }, + resource_pictures: { + type: 'has_many', + args: { + association_name: 'resource_pictures', + }, + }, + by_license_group: { + type: 'filter', + args: { + from: 'license_group', + filter_key: 'license_group_id', + }, + }, + by_system_picture: { + type: 'filter', + args: { + from: 'system_picture', + filter_key: 'system_picture_id', + }, + }, + }, }, - Author: 'author', author: { class_name: 'Author', table_name: 'authors', @@ -1843,8 +2400,66 @@ type: 'datetime', } }, + lists: { + public_list: { + type: 'public', + }, + scrolls: { + type: 'has_many', + args: { + association_name: 'scrolls', + }, + }, + comics: { + type: 'has_many', + args: { + association_name: 'comics', + }, + }, + stories: { + type: 'has_many', + args: { + association_name: 'stories', + }, + }, + sheets: { + type: 'has_many', + args: { + association_name: 'sheets', + }, + }, + panels: { + type: 'has_many', + args: { + association_name: 'panels', + }, + }, + panel_pictures: { + type: 'has_many', + args: { + association_name: 'panel_pictures', + }, + }, + speech_balloons: { + type: 'has_many', + args: { + association_name: 'speech_balloons', + }, + }, + ground_pictures: { + type: 'has_many', + args: { + association_name: 'ground_pictures', + }, + }, + ground_colors: { + type: 'has_many', + args: { + association_name: 'ground_colors', + }, + }, + }, }, - Artist: 'artist', artist: { class_name: 'Artist', table_name: 'artists', @@ -1888,8 +2503,18 @@ type: 'datetime', } }, + lists: { + public_list: { + type: 'public', + }, + resource_pictures: { + type: 'has_many', + args: { + association_name: 'resource_pictures', + }, + }, + }, }, - SystemPicture: 'system_picture', system_picture: { class_name: 'SystemPicture', table_name: 'system_pictures', @@ -1961,7 +2586,12 @@ updated_at: { type: 'datetime', } - } + }, + lists: { + public_list: { + type: 'public', + }, + }, }, } diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 965623ab..9866d9c5 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,6 +1,6 @@ class ApplicationController < ActionController::Base protect_from_forgery - layout :devise_layout if MagicNumber['test_layout'] + layout :devise_layout before_filter :bf def devise_layout @@ -101,11 +101,11 @@ class ApplicationController < ActionController::Base end def self.controller - Pettanr::Application::manifest.controller_managers[self.model.item_name] + Manifest.manifest.controller_managers[self.model.item_name] end def self.profiler_manager - Pettanr::Application::manifest.profiler_managers[self.model.item_name] + Manifest.manifest.profiler_managers[self.model.item_name] end def public_list @@ -128,7 +128,7 @@ class ApplicationController < ActionController::Base def my_list params controller_name = params[:controller] action_name = params[:action] - controller = Pettanr::Application::manifest.controller_managers[controller_name] + controller = Manifest.manifest.controller_managers[controller_name] @action = controller.open(action_name, params, @operators) @items = @action.items @@ -147,13 +147,13 @@ class ApplicationController < ActionController::Base @parent_item = self.class.model.show(params[:id], @operators) controller_name = self.class.model.item_name action_name = params[:action] - controller = Pettanr::Application::manifest.controller_managers[controller_name] + controller = Manifest.manifest.controller_managers[controller_name] @action = controller.open(action_name, params, @operators) many_name = @action.list.association_model_name @items = @action.list.items @parent_item respond_to do |format| format.html { - @filer = Pettanr::Application::manifest.filer_managers[many_name].open(many_name, @items, @operators, @action.list.paginate(@parent_item)) + @filer = Manifest.manifest.filer_managers[many_name].open(many_name, @items, @operators, @action.list.paginate(@parent_item)) render :template => 'system/filer', :locals => { :filer => @filer } @@ -165,14 +165,14 @@ class ApplicationController < ActionController::Base def filter_list controller_name = self.class.model.item_name action_name = params[:action] - controller = Pettanr::Application::manifest.controller_managers[controller_name] + controller = Manifest.manifest.controller_managers[controller_name] @action = controller.open(action_name, params, @operators) @filter_item = @action.list.from_model.show(params[:id], @operators) item_model_name = @action.list.item_name @items = @action.list.items @filter_item respond_to do |format| format.html { - @filer = Pettanr::Application::manifest.filer_managers[item_model_name].open(item_model_name, @items, @operators, @action.list.paginate(@filter_item)) + @filer = Manifest.manifest.filer_managers[item_model_name].open(item_model_name, @items, @operators, @action.list.paginate(@filter_item)) render :template => 'system/filer', :locals => { :filer => @filer } diff --git a/app/controllers/artists_controller.rb b/app/controllers/artists_controller.rb index 7b4e0671..3f980c18 100644 --- a/app/controllers/artists_controller.rb +++ b/app/controllers/artists_controller.rb @@ -1,6 +1,5 @@ class ArtistsController < ApplicationController - layout 'test' if MagicNumber['test_layout'] - if MagicNumber['run_mode'] == 0 + if Manifest.manifest.magic_numbers['run_mode'] == 0 before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] else diff --git a/app/controllers/authors_controller.rb b/app/controllers/authors_controller.rb index 9be51391..f25eba16 100644 --- a/app/controllers/authors_controller.rb +++ b/app/controllers/authors_controller.rb @@ -1,6 +1,5 @@ class AuthorsController < ApplicationController - layout 'test' if MagicNumber['test_layout'] - if MagicNumber['run_mode'] == 0 + if Manifest.manifest.magic_numbers['run_mode'] == 0 before_filter :authenticate_user, :only => [:new, :create, :edit, :update] before_filter :authenticate_author, :only => [:edit, :update] else diff --git a/app/controllers/balloons_controller.rb b/app/controllers/balloons_controller.rb index 74ed219a..556baa1c 100644 --- a/app/controllers/balloons_controller.rb +++ b/app/controllers/balloons_controller.rb @@ -1,6 +1,5 @@ class BalloonsController < ApplicationController - layout 'test' if MagicNumber['test_layout'] - if MagicNumber['run_mode'] == 0 + if Manifest.manifest.magic_numbers['run_mode'] == 0 before_filter :authenticate_user, :only => [] before_filter :authenticate_author, :only => [] else diff --git a/app/controllers/comics_controller.rb b/app/controllers/comics_controller.rb index 10b9e1b1..1c4ed68b 100644 --- a/app/controllers/comics_controller.rb +++ b/app/controllers/comics_controller.rb @@ -1,6 +1,5 @@ class ComicsController < ApplicationController - layout 'test' if MagicNumber['test_layout'] - if MagicNumber['run_mode'] == 0 + if Manifest.manifest.magic_numbers['run_mode'] == 0 before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] else diff --git a/app/controllers/demander_statuses_controller.rb b/app/controllers/demander_statuses_controller.rb index 180f3ee2..32318ac4 100644 --- a/app/controllers/demander_statuses_controller.rb +++ b/app/controllers/demander_statuses_controller.rb @@ -1,5 +1,4 @@ class DemanderStatusesController < ApplicationController - layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_admin!, :only => [:index, :show, :edit, :update, :destroy] def index diff --git a/app/controllers/demanders_controller.rb b/app/controllers/demanders_controller.rb index ccd52849..92d4eeab 100644 --- a/app/controllers/demanders_controller.rb +++ b/app/controllers/demanders_controller.rb @@ -1,5 +1,4 @@ class DemandersController < ApplicationController - layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_demand_user!, :only => [:index, :show, :new, :create, :edit, :update, :destroy, :req, :licenses_export, :artists_export, :original_pictures_export, :pictures_export, :export] def index diff --git a/app/controllers/ground_colors_controller.rb b/app/controllers/ground_colors_controller.rb index e00e3b1a..5917c15c 100644 --- a/app/controllers/ground_colors_controller.rb +++ b/app/controllers/ground_colors_controller.rb @@ -1,6 +1,5 @@ class GroundColorsController < ApplicationController - layout 'test' if MagicNumber['test_layout'] - if MagicNumber['run_mode'] == 0 + if Manifest.manifest.magic_numbers['run_mode'] == 0 before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy] before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy] else diff --git a/app/controllers/ground_pictures_controller.rb b/app/controllers/ground_pictures_controller.rb index dfb16a20..7775cb99 100644 --- a/app/controllers/ground_pictures_controller.rb +++ b/app/controllers/ground_pictures_controller.rb @@ -1,6 +1,5 @@ class GroundPicturesController < ApplicationController - layout 'test' if MagicNumber['test_layout'] - if MagicNumber['run_mode'] == 0 + if Manifest.manifest.magic_numbers['run_mode'] == 0 before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy] before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy] else diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index acde80e0..293ed5d9 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -1,5 +1,4 @@ class HomeController < ApplicationController - layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_user, :only => [ :index, :show, :profile, :configure, :create_token, :delete_token, :scrolls, :scroll_panels, :comics, :stories, :story_sheets, :sheets, :sheet_panels, :panels, :resource_pictures, :panel_pictures, :speech_balloons, :ground_pictures, :ground_colors diff --git a/app/controllers/license_groups_controller.rb b/app/controllers/license_groups_controller.rb index 85a32b33..af36fd5a 100644 --- a/app/controllers/license_groups_controller.rb +++ b/app/controllers/license_groups_controller.rb @@ -1,5 +1,4 @@ class LicenseGroupsController < ApplicationController - layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_admin!, :only => [:list, :browse] def self.model diff --git a/app/controllers/licenses_controller.rb b/app/controllers/licenses_controller.rb index 7e10569c..4ba997a6 100644 --- a/app/controllers/licenses_controller.rb +++ b/app/controllers/licenses_controller.rb @@ -1,6 +1,5 @@ class LicensesController < ApplicationController - layout 'test' if MagicNumber['test_layout'] - before_filter :authenticate_resource_reader, :only => [:resource_pictures, :by_license_group, :by_system_picture] + before_filter :authenticate_resource_reader, :only => [:resource_pictures, :by_license_group, :by_system_picture] def self.model License diff --git a/app/controllers/original_picture_license_groups_controller.rb b/app/controllers/original_picture_license_groups_controller.rb index 6f693bfe..b3616fe6 100644 --- a/app/controllers/original_picture_license_groups_controller.rb +++ b/app/controllers/original_picture_license_groups_controller.rb @@ -1,5 +1,4 @@ class OriginalPictureLicenseGroupsController < ApplicationController - layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_user, :only => [:new, :create] before_filter :authenticate_artist, :only => [:new, :create] diff --git a/app/controllers/original_pictures_controller.rb b/app/controllers/original_pictures_controller.rb index 88428c2f..9a7884ff 100644 --- a/app/controllers/original_pictures_controller.rb +++ b/app/controllers/original_pictures_controller.rb @@ -1,6 +1,5 @@ #原画 class OriginalPicturesController < ApplicationController - layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_reader, :only => [:show, :history] before_filter :authenticate_user, :only => [:index, :new, :edit, :create, :update, :destroy] before_filter :authenticate_artist, :only => [:index, :new, :edit, :create, :update, :destroy] diff --git a/app/controllers/panel_pictures_controller.rb b/app/controllers/panel_pictures_controller.rb index f47a123e..6af49e44 100644 --- a/app/controllers/panel_pictures_controller.rb +++ b/app/controllers/panel_pictures_controller.rb @@ -1,6 +1,5 @@ class PanelPicturesController < ApplicationController - layout 'test' if MagicNumber['test_layout'] - if MagicNumber['run_mode'] == 0 + if Manifest.manifest.magic_numbers['run_mode'] == 0 before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy] before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy] else diff --git a/app/controllers/panels_controller.rb b/app/controllers/panels_controller.rb index c781dce9..7c0c0719 100644 --- a/app/controllers/panels_controller.rb +++ b/app/controllers/panels_controller.rb @@ -1,6 +1,5 @@ class PanelsController < ApplicationController - layout 'test' if MagicNumber['test_layout'] - if MagicNumber['run_mode'] == 0 + if Manifest.manifest.magic_numbers['run_mode'] == 0 before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy, :catch] before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy, :catch] else diff --git a/app/controllers/pictures_controller.rb b/app/controllers/pictures_controller.rb index 5f4d81e7..81b5ad48 100644 --- a/app/controllers/pictures_controller.rb +++ b/app/controllers/pictures_controller.rb @@ -1,6 +1,5 @@ class PicturesController < ApplicationController - layout 'test' if MagicNumber['test_layout'] - if MagicNumber['run_mode'] == 0 + if Manifest.manifest.magic_numbers['run_mode'] == 0 before_filter :authenticate_user, :only => [] before_filter :authenticate_author, :only => [] else diff --git a/app/controllers/provider_sources_controller.rb b/app/controllers/provider_sources_controller.rb index 953fe2c6..f4c48ba5 100644 --- a/app/controllers/provider_sources_controller.rb +++ b/app/controllers/provider_sources_controller.rb @@ -1,5 +1,4 @@ class ProviderSourcesController < ApplicationController - layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_admin!, :only => [:index, :import] def index diff --git a/app/controllers/provider_statuses_controller.rb b/app/controllers/provider_statuses_controller.rb index 2892cf85..c91693e2 100644 --- a/app/controllers/provider_statuses_controller.rb +++ b/app/controllers/provider_statuses_controller.rb @@ -1,5 +1,4 @@ class ProviderStatusesController < ApplicationController - layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_admin!, :only => [:index, :show, :edit, :update, :destroy, :licenses_import, :artists_import, :original_pictures_import, :import, :import_all] def index diff --git a/app/controllers/providers_controller.rb b/app/controllers/providers_controller.rb index 161e5d74..88b6e875 100644 --- a/app/controllers/providers_controller.rb +++ b/app/controllers/providers_controller.rb @@ -1,5 +1,4 @@ class ProvidersController < ApplicationController - layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_admin!, :only => [:index, :show, :destroy] def index diff --git a/app/controllers/resource_pictures_controller.rb b/app/controllers/resource_pictures_controller.rb index bcba9a2d..7c22c2b2 100644 --- a/app/controllers/resource_pictures_controller.rb +++ b/app/controllers/resource_pictures_controller.rb @@ -1,6 +1,5 @@ class ResourcePicturesController < ApplicationController - layout 'test' if MagicNumber['test_layout'] - if MagicNumber['run_mode'] == 0 + if Manifest.manifest.magic_numbers['run_mode'] == 0 before_filter :authenticate_user, :only => [:new, :create, :update, :destroy] before_filter :authenticate_artist, :only => [:new, :create, :update, :destroy] else diff --git a/app/controllers/scroll_panels_controller.rb b/app/controllers/scroll_panels_controller.rb index 1124599f..5c61a55f 100644 --- a/app/controllers/scroll_panels_controller.rb +++ b/app/controllers/scroll_panels_controller.rb @@ -1,6 +1,5 @@ class ScrollPanelsController < ApplicationController - layout 'test' if MagicNumber['test_layout'] - if MagicNumber['run_mode'] == 0 + if Manifest.manifest.magic_numbers['run_mode'] == 0 before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] else diff --git a/app/controllers/scrolls_controller.rb b/app/controllers/scrolls_controller.rb index 87d91a4f..3ee8fb23 100644 --- a/app/controllers/scrolls_controller.rb +++ b/app/controllers/scrolls_controller.rb @@ -1,6 +1,5 @@ class ScrollsController < ApplicationController - layout 'test' if MagicNumber['test_layout'] - if MagicNumber['run_mode'] == 0 + if Manifest.manifest.magic_numbers['run_mode'] == 0 before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] else diff --git a/app/controllers/sheet_panels_controller.rb b/app/controllers/sheet_panels_controller.rb index 0d030e24..218fc824 100644 --- a/app/controllers/sheet_panels_controller.rb +++ b/app/controllers/sheet_panels_controller.rb @@ -1,6 +1,5 @@ class SheetPanelsController < ApplicationController - layout 'test' if MagicNumber['test_layout'] - if MagicNumber['run_mode'] == 0 + if Manifest.manifest.magic_numbers['run_mode'] == 0 before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] else diff --git a/app/controllers/sheets_controller.rb b/app/controllers/sheets_controller.rb index 4f1fbd9e..297f17e3 100644 --- a/app/controllers/sheets_controller.rb +++ b/app/controllers/sheets_controller.rb @@ -1,6 +1,5 @@ class SheetsController < ApplicationController - layout 'test' if MagicNumber['test_layout'] - if MagicNumber['run_mode'] == 0 + if Manifest.manifest.magic_numbers['run_mode'] == 0 before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] else diff --git a/app/controllers/speech_balloon_templates_controller.rb b/app/controllers/speech_balloon_templates_controller.rb index eddcf293..4b4fe8ae 100644 --- a/app/controllers/speech_balloon_templates_controller.rb +++ b/app/controllers/speech_balloon_templates_controller.rb @@ -1,6 +1,5 @@ class SpeechBalloonTemplatesController < ApplicationController - layout 'test' if MagicNumber['test_layout'] - if MagicNumber['run_mode'] == 0 + if Manifest.manifest.magic_numbers['run_mode'] == 0 before_filter :authenticate_user, :only => [] else before_filter :authenticate_reader, :only => [:index, :show, :speech_balloons, :panels, :by_system_picture] diff --git a/app/controllers/speech_balloons_controller.rb b/app/controllers/speech_balloons_controller.rb index 4aede9db..ed47f972 100644 --- a/app/controllers/speech_balloons_controller.rb +++ b/app/controllers/speech_balloons_controller.rb @@ -1,6 +1,5 @@ class SpeechBalloonsController < ApplicationController - layout 'test' if MagicNumber['test_layout'] - if MagicNumber['run_mode'] == 0 + if Manifest.manifest.magic_numbers['run_mode'] == 0 before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy] before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy] else diff --git a/app/controllers/speeches_controller.rb b/app/controllers/speeches_controller.rb index bcf42291..0c4a4168 100644 --- a/app/controllers/speeches_controller.rb +++ b/app/controllers/speeches_controller.rb @@ -1,6 +1,5 @@ class SpeechesController < ApplicationController - layout 'test' if MagicNumber['test_layout'] - if MagicNumber['run_mode'] == 0 + if Manifest.manifest.magic_numbers['run_mode'] == 0 before_filter :authenticate_user, :only => [] before_filter :authenticate_author, :only => [] else diff --git a/app/controllers/stories_controller.rb b/app/controllers/stories_controller.rb index 37832c2b..1fcf0030 100644 --- a/app/controllers/stories_controller.rb +++ b/app/controllers/stories_controller.rb @@ -1,6 +1,5 @@ class StoriesController < ApplicationController - layout 'test' if MagicNumber['test_layout'] - if MagicNumber['run_mode'] == 0 + if Manifest.manifest.magic_numbers['run_mode'] == 0 before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] else diff --git a/app/controllers/story_sheets_controller.rb b/app/controllers/story_sheets_controller.rb index b5478668..ffabccaa 100644 --- a/app/controllers/story_sheets_controller.rb +++ b/app/controllers/story_sheets_controller.rb @@ -1,6 +1,5 @@ class StorySheetsController < ApplicationController - layout 'test' if MagicNumber['test_layout'] - if MagicNumber['run_mode'] == 0 + if Manifest.manifest.magic_numbers['run_mode'] == 0 before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] else diff --git a/app/controllers/system_pictures_controller.rb b/app/controllers/system_pictures_controller.rb index 99bd7400..58bd89b9 100644 --- a/app/controllers/system_pictures_controller.rb +++ b/app/controllers/system_pictures_controller.rb @@ -1,6 +1,5 @@ class SystemPicturesController < ApplicationController - layout 'test' if MagicNumber['test_layout'] - if MagicNumber['run_mode'] == 0 + if Manifest.manifest.magic_numbers['run_mode'] == 0 before_filter :authenticate_user, :only => [] before_filter :authenticate_author, :only => [] else diff --git a/app/controllers/top_controller.rb b/app/controllers/top_controller.rb index 62ec3aeb..eca273ea 100644 --- a/app/controllers/top_controller.rb +++ b/app/controllers/top_controller.rb @@ -1,6 +1,5 @@ class TopController < ApplicationController - layout 'test' if MagicNumber['test_layout'] - if MagicNumber['run_mode'] == 0 + if Manifest.manifest.magic_numbers['run_mode'] == 0 before_filter :authenticate_user, :only => [] before_filter :authenticate_author, :only => [] else diff --git a/app/controllers/writing_formats_controller.rb b/app/controllers/writing_formats_controller.rb index caacfe0e..21ab7ae2 100644 --- a/app/controllers/writing_formats_controller.rb +++ b/app/controllers/writing_formats_controller.rb @@ -1,6 +1,5 @@ class WritingFormatsController < ApplicationController - layout 'test' if MagicNumber['test_layout'] - if MagicNumber['run_mode'] == 0 + if Manifest.manifest.magic_numbers['run_mode'] == 0 before_filter :authenticate_user, :only => [] else before_filter :authenticate_reader, :only => [:index, :show] diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 10fc0512..9fe49677 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,6 +1,6 @@ module ApplicationHelper def manifest - Pettanr::Application.manifest + Manifest.manifest end def full_url filename diff --git a/app/models/speech_balloon_template.rb b/app/models/speech_balloon_template.rb index dd20d250..c2ebbd39 100644 --- a/app/models/speech_balloon_template.rb +++ b/app/models/speech_balloon_template.rb @@ -62,11 +62,11 @@ class SpeechBalloonTemplate < Pettanr::Item end def engine_name - Pettanr::Application.manifest.system_resources.speech_balloon_templates[self.classname] + Manifest.manifest.system_resources.speech_balloon_templates[self.classname] end def enable? - Pettanr::Application.manifest.system_resources.speech_balloon_templates.include? self.classname + Manifest.manifest.system_resources.speech_balloon_templates.include? self.classname end def engine_module_name diff --git a/app/models/writing_format.rb b/app/models/writing_format.rb index cf68b4d1..390c5c6e 100644 --- a/app/models/writing_format.rb +++ b/app/models/writing_format.rb @@ -68,11 +68,11 @@ end end def engine_name - Pettanr::Application.manifest.system_resources.writing_formats[self.classname] + Manifest.manifest.system_resources.writing_formats[self.classname] end def enable? - Pettanr::Application.manifest.system_resources.writing_formats.include? self.classname + Manifest.manifest.system_resources.writing_formats.include? self.classname end def engine_module_name diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 3b798c17..763fb69a 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,59 +1,114 @@ - - - - - - - - - Pettanr - <%= stylesheet_link_tag "system.css" %> - <%= stylesheet_link_tag "peta.common.css" %> - <%= csrf_meta_tags %> - - -
- <%= yield %> -
-
[ESC] キーを押すと Metro ホームに入るよ.ホームの一番最後のタイルをクリックすると このページに戻るよ.
-
ホームへ
- <%= javascript_tag 'var server_result=' + @server_result.to_json + ';' %> - <%= javascript_include_tag "jquery-162min" %> - <%= javascript_include_tag "libs" %> - <%= javascript_include_tag "system" %> + + + + + <% if @page_title %> + <%= h @page_title %> + <% else %> + <%= t("#{params[:controller]}.#{params[:action]}.title") %> + <% end %> + - <%= h(manifest.magic_numbers['profile']['users']['caption']) %> + + <%= stylesheet_link_tag "application" %> + <%= javascript_include_tag "application" %> + <%= raw panel_editor_javascript_include_tags %> + <%= csrf_meta_tags %> + + - - <%= javascript_include_tag "peta-common" %> - <%= javascript_include_tag "peta-apps" %> - <%= javascript_include_tag "pongame" %> - +
+ + + + + + + +
+

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

+
+ <% if user_signed_in? %> + <%# link_to t('top.metro.title'), '/top/metro' %> + <% end %> + +
+ <% if @operators.author %> + <%= link_to h(truncate(@operators.author.name, :length => 12)), main_app.author_path(@operators.author) %> + <% end %> +
+
+ <% if @operators.artist %> + <%= link_to h(truncate(@operators.artist.name, :length => 12)), main_app.artist_path(@operators.artist) %> + <% end %> +
+
+ <% if user_signed_in? %> + <%= link_to t('home.configure.title'), '/home/configure' %> + <%= link_to t('home.sign_out.title'), main_app.destroy_user_session_path, :method => :delete %> + <% else %> + <%= link_to "sign in", main_app.new_user_session_path %> + <% end %> +
+
+
+ <%= link_to t('tab.reader.title'), '/' %> + <%= link_to t_m('Comic'), main_app.comics_path %> + <%= link_to t_m('Scroll'), main_app.scrolls_path %> + <%= link_to t_m('Panel'), main_app.panels_path %> + <%= link_to t_m('ResourcePicture'), main_app.resource_pictures_path %> + <%= link_to t_m('SpeechBalloonTemplate'), main_app.speech_balloon_templates_path %> + : + <%= link_to t_m('Author'), main_app.authors_path %> + <%= link_to t_m('Artist'), main_app.artists_path %> +
+
+ <%= link_to t('tab.creator.home'), '/home' %> + <% if @operators.author %> + <%= link_to t('tab.creator.comic'), '/home/comics' %> + <%= link_to t('*'), main_app.new_comic_path %> + <%= link_to t('tab.creator.story'), '/home/stories' %> + <%= link_to t('tab.creator.sheet'), '/home/sheets' %> + <%= link_to t('*'), main_app.new_sheet_path %> + <%= link_to t('tab.creator.scroll'), '/home/scrolls' %> + <%= link_to t('*'), main_app.new_scroll_path %> + <%= link_to t('tab.creator.panel'), '/home/panels' %> + <%= link_to t('*'), main_app.new_panel_path %> + <% end -%> + <% if @operators.artist %> + <%= link_to t('tab.creator.original_picture'), main_app.original_pictures_path %> + <%= link_to t('*'), main_app.new_original_picture_path %> + <%= link_to t('tab.creator.resource_picture'), '/home/resource_pictures' %> + <% end %> + <% if @operators.author and @operators.author.working? -%> + <%= link_to t('tab.creator..catch'), main_app.panel_path(@operators.author.working_panel) %> + <% end %> +
+<%= yield %> +
+ <%= link_to t('tab.demander.title'), main_app.demanders_path %> + <% if demand_user_signed_in? %> + <%= link_to t_m('Demander'), main_app.demanders_path %> + <%= link_to t('home.sign_out.title'), main_app.destroy_demand_user_session_path, :method => :delete %> + <% else %> + <%= link_to t('home.sign_in.title'), main_app.new_demand_user_session_path %> + <% end %> +
+
+ <%= link_to t('tab.system.title'), '/system' %> + <% if admin_signed_in? %> + <%= link_to t('tab.system.browse'), '/system/browse' %> + <%= link_to t('tab.system.approve'), '/system/waiting_list' %> + <%= link_to t('tab.system.port'), '/system/import' %> + <%= link_to t('tab.system.token'), '/system/auth_token' %> + <%= t('tab.system.layout') %>: + <%= link_to t('tab.system.test'), '/system/test_layout' %> + <%= link_to t('tab.system.production'), '/system/production_layout' %> + <%= link_to t('home.sign_out.title'), main_app.destroy_admin_session_path, :method => :delete %> + <% else %> + <%= link_to t('home.sign_in.title'), main_app.new_admin_session_path %> + <% end %> +
+<%= javascript_tag 'var server_result=' + @server_result.to_json + ';' %> + + diff --git a/app/views/layouts/test.prof.erb b/app/views/layouts/application.prof.erb similarity index 100% rename from app/views/layouts/test.prof.erb rename to app/views/layouts/application.prof.erb diff --git a/app/views/layouts/system.html.erb b/app/views/layouts/system.html.erb index 4bec89d5..b5e8db35 100644 --- a/app/views/layouts/system.html.erb +++ b/app/views/layouts/system.html.erb @@ -1,7 +1,7 @@ - <%= h(MagicNumber['profile']['admins']['caption']) %> + <%= h(Manifest.manifest.magic_numbers['profile']['admins']['caption']) %> <%= stylesheet_link_tag "application" %> <%= javascript_include_tag "application" %> <%= raw panel_editor_javascript_include_tags %> diff --git a/config/application.rb b/config/application.rb index 6a815d6b..1d97308b 100644 --- a/config/application.rb +++ b/config/application.rb @@ -15,7 +15,8 @@ if defined?(Bundler) # If you want your assets lazily compiled in production, use this line # Bundler.require(:default, :assets, Rails.env) end -require "manifest" +require 'manifest' +Manifest::load JSON.parse(open(File.expand_path('../../public/manifest.json', __FILE__)).read) module Pettanr VERSION = '0.6.2' @@ -58,30 +59,10 @@ config.assets.initialize_on_precompile = false #config.autoload_paths += Dir["#{config.root}/lib/validators/*", "#{config.root}/lib/editor/*", "#{config.root}/lib/manifest/*"] config.autoload_paths += %W(#{config.root}/lib/validators) - def self.manifest=(arg) - @@manifest = arg - end - - def self.manifest - @@manifest - end - end - - def manifest - Application::manifest end end -Pettanr::Application.manifest = Pettanr::Manifest.new 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 - y = YAML.load(open(Rails.root + 'config/picture_io.yml').read) require y[Rails.env]["adapter"] pio = PictureIO.const_get y[Rails.env]["io"] diff --git a/config/environment.rb b/config/environment.rb index 38a20947..9ac495ea 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -15,7 +15,7 @@ require 'owner' require 'content' require 'element' require 'element_part' -require 'editor/editor' +require 'editor' # Initialize the rails application Pettanr::Application.initialize! -Pettanr::Application.manifest.init +Manifest.manifest.init diff --git a/config/environments/development.rb b/config/environments/development.rb index 7b83a881..79542a14 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,7 +1,7 @@ Pettanr::Application.configure do ActiveSupport::Dependencies.autoload_paths << File::join( Rails.root, 'lib') - ActiveSupport::Dependencies.explicitly_unloadable_constants << 'Editor' + ActiveSupport::Dependencies.explicitly_unloadable_constants << 'Editor' # Settings specified here will take precedence over those in config/application.rb # In the development environment your application's code is reloaded on diff --git a/config/routes.rb b/config/routes.rb index d5f7c6df..670f49e4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,10 +4,11 @@ Pettanr::Application.routes.draw do devise_for :admins devise_for :demand_users - Pettanr::Application.manifest.system_resources.license_groups.each do |klass, name| + Manifest.manifest.system_resources.license_groups.each do |klass, name| + p klass mount Module.const_get(klass)::Engine => "/#{name}" end - Pettanr::Application.manifest.system_resources.speech_balloon_templates.each do |klass , name| + Manifest.manifest.system_resources.speech_balloon_templates.each do |klass , name| mount Module.const_get(klass)::Engine => "/#{name}" end diff --git a/lib/manifest.rb b/lib/manifest.rb index 9a62e8b8..6aedbd0e 100644 --- a/lib/manifest.rb +++ b/lib/manifest.rb @@ -1,8 +1,10 @@ -require_dependency "manifest/manifest" -require_dependency "manifest/controller" -require_dependency "manifest/model" -require_dependency "manifest/list" -require_dependency "manifest/profiler" -require_dependency "manifest/filer" -require_dependency "manifest/form" +module Manifest +end + require "manifest/manifest" + require "manifest/controller" + require "manifest/model" + require "manifest/profiler" + require "manifest/filer" + require "manifest/form" + require "manifest/system_resources" diff --git a/lib/manifest/controller.rb b/lib/manifest/controller.rb index 6f26f455..8377e290 100644 --- a/lib/manifest/controller.rb +++ b/lib/manifest/controller.rb @@ -1,101 +1,40 @@ - -module Pettanr - module Manifest - class Controller - def self.set_default my_manifest - my_manifest.each {|item_name, controller_manifest| - controller_manifest|['model_name'] ||= item_name - controller_manifest|['actions'] ||= {} - controller_manifest|['actions'].each {|action_name, action_manifest| - action_manifest['options'] ||= {} - action_manifest['options'].each {option_name, option_manifest| - raise "undefined list_name for controllers > #{item_name} > actions > #{action_name} > options\n" unless option_manifest['list_name'] - } - } - } - end - - class ActionList - attr :list - def initialize my_item_name, action_name, conf - # get home list_name - @my_item_name = conf['item_name'] if conf['item_name'] - @action_name = action_name - @conf = conf - end - - def list params, operators - list_name = @controller_manifest.list_name action_name - @list = @manifest.list_managers[@my_item_name].open(list_name, params[:page], params[:page_size], operators) - end - - def ready params, operators - @items = @action.items - - end - - def exec - end - - def render - format.html { - @filer = @action.filer - render :template => 'system/filer', :locals => { - :filer => @filer - } - } - end - - def cook params, operators - @action.ready params, operators - @action.exec - @action.render - end - - end - - class ActionShow - def initialize my_item_name, action_name, conf - @my_item_name = conf['item_name'] if conf['item_name'] - @action_name = action_name - @conf = conf - end - - def ready - @item = Comic.show(params[:id], @operators) - end - - def exec - end - - def render - format.html { - } - end - - end - - class Recipe - end - - attr :controller_manifest, :item_name, :manifest, :controller_conf, - :actions - @@types = {'list' => ActionList, 'show' => ActionShow} - def initialize controller_manifest - @controller_manifest = controller_manifest - @item_name = @controller_manifest.item_name - @manifest = @controller_manifest.manifest - @controller_conf = @controller_manifest.conf - @actions = {} - @my_item_name = @controller_conf['item_name'] || @item_name - @controller_manifest.actions.each {|action_name, conf| - type = conf['type'] - @actions[action_name] = @@types[type].new @my_item_name, action_name, conf - } - end - - +require "manifest/controller/list" +require "manifest/controller/show" +module Manifest + class Controller + include ControllerModule + def self.manager manifest, my_manifests + my_manifests.map {|controller_name, controller_manifest| + self.new(manifest, controller_name, controller_manifest) + } end + + class Recipe + end + + attr :manifest, :controller_name, :controller_manifest, :item_name, :actions + @@types = {'list' => ActionList, 'show' => ActionShow} + def initialize manifest, controller_name, controller_manifest + @manifest = manifest + @controller_name = controller_name + @controller_manifest = controller_manifest + self.set_default + self.init + end + + def set_default + @controller_manifest['item_name'] ||= @controller_name + @controller_manifest['actions'] ||= {} + end + + def init + @item_name = @controller_manifest['item_name'] + @actions = {} + @controller_manifest['actions'].each {|action_name, action_manifest| + raise "undefined class for controllers > #{@controller_name} > actions > #{action_name} > type > #{action_manifest['type']}\n" unless @@types[action_manifest['type']] + @actions[action_name] = @@types[action_manifest['type']].new(self, action_name, action_manifest) + } + end + end end - diff --git a/lib/manifest/controller/list.rb b/lib/manifest/controller/list.rb new file mode 100644 index 00000000..9050a31a --- /dev/null +++ b/lib/manifest/controller/list.rb @@ -0,0 +1,62 @@ +module Manifest + module ControllerModule + class ActionList + attr :controller, :action_name, :action_manifest, :item_name, :list_name + def initialize controller, action_name, action_manifest + @controller = controller + @action_name = action_name + @action_manifest = action_manifest + self.set_default + self.init + end + + def set_default + @action_manifest['item_name'] ||= self.controller.item_name + @action_manifest['args'] ||= {} + end + + def init + @item_name = @action_manifest['item_name'] + @args = @action_manifest['args'] + raise "undefined list_name for controllers > #{self.controller_name} > actions > #{@action_name} > args\n" unless @args['list_name'] + @list_name = @args['list_name'] + end + + def controller_name + @controller.controller_name + end + + def controller_manifest + @controller.controller_manifest + end + + def list params, operators + Manifest.list_managers[@item_name].open(@list_name) + end + + def ready params, operators + @items = self.list.items params, operators + end + + def exec + end + + def render + format.html { + @filer = self.list.filer + render :template => 'system/filer', :locals => { + :filer => @filer + } + } + end + + def cook params, operators + self.ready params, operators + self.exec + self.render + end + + end + + end +end diff --git a/lib/manifest/controller/show.rb b/lib/manifest/controller/show.rb new file mode 100644 index 00000000..2b0ac62f --- /dev/null +++ b/lib/manifest/controller/show.rb @@ -0,0 +1,43 @@ +module Manifest + module ControllerModule + class ActionShow + attr :controller, :action_name, :action_manifest, :item_name + def initialize controller, action_name, action_manifest + @controller = controller + @action_name = action_name + @action_manifest = action_manifest + self.set_default + self.init + end + + def set_default + @action_manifest['item_name'] ||= self.controller.item_name + @action_manifest['args'] ||= {} + end + + def init + @item_name = @action_manifest['item_name'] + end + + def ready params, operators + @item = @model.show(params[:id], operators) + end + + def exec + end + + def render + format.html { + } + end + + def cook params, operators + self.ready params, operators + self.exec + self.render + end + + end + + end +end diff --git a/lib/manifest/filer.rb b/lib/manifest/filer.rb index e49d3706..82c09a69 100644 --- a/lib/manifest/filer.rb +++ b/lib/manifest/filer.rb @@ -1,6 +1,22 @@ + class Filer + attr :item_name, :conf, :manifest, :icon, :symbol, :caption, :summary, :date, :edit + def initialize item_name, conf, manifest + @item_name = item_name + @conf = conf || {} + @manifest = manifest + @symbol = @conf['symbol'] + @caption = @conf['caption'] + @summary = @conf['summary'] + @icon = @conf['icon'] + @date = @conf['date'] + @edit = @conf['edit'] + end + + end + -module Pettanr - class FilerManager +module Manifest + class Filer class Symbol def initialize symbol_conf @symbol_conf = symbol_conf || {} @@ -306,8 +322,8 @@ module Pettanr end - class Filer - class FileItem + class FilerView + class FileItemView attr :item, :operators def initialize item, operators, symbol, caption, summary, icon, date, edit, manifest @item = item diff --git a/lib/manifest/form.rb b/lib/manifest/form.rb index 4dde25d0..a220afc8 100644 --- a/lib/manifest/form.rb +++ b/lib/manifest/form.rb @@ -1,3 +1,16 @@ + class Form + attr :item_name, :conf, :manifest, :base, :fields, :field_names + def initialize item_name, conf, manifest + @item_name = item_name + @conf = conf || {} + @manifest = manifest + @base = @conf['base'] + @fields = @conf['fields'] || {} + @field_names = @conf['field_names'] || [] + end + + end + module Pettanr class FormManager diff --git a/lib/manifest/list.rb b/lib/manifest/list.rb index 06c62ffb..7dc85cd3 100644 --- a/lib/manifest/list.rb +++ b/lib/manifest/list.rb @@ -1,445 +1,64 @@ +require "manifest/list/base" -module Pettanr - module Manifest - class List - def self.set_default my_manifest - my_manifest.each {|item_name, list_manifest| - raise "undefined type for lists > #{item_name} > #{list_name}\n" unless list_manifest['type'] - list_manifest['options'] ||= {} - list_manifest|['options'].each {|option_name, option_manifest| - option_manifest['default_page_size'] ||= 25 - option_manifest['max_page_size'] ||= 100 - } - @@types[list_manifest['type']].set_default list_manifest['options'] - # 'required' 'number' - } - end - - class BaseList - def initialize page, page_size, operators, item_name, list_name, conf, manifest - @operators = operators - @item_name = item_name - @list_name = list_name - @conf = conf - @manifest = manifest - @default_page_size = @conf['default_page_size'] || 25 - @max_page_size = @conf['max_page_size'] || 100 - @page = self.page_number(page) - @page_size = self.page_size page_size - - @model = @item_name.classify.constantize - @offset = (@page -1) * @page_size - @table_name = @model.table_name - if @model.content? - @owner_model = @model.owner_model - @owner_table_name = @owner_model.table_name if @owner_model - end - end - - def page_number prm = nil - page = prm.to_i - page = 1 if page < 1 - page - end - - def page_size prm - page_size = prm.to_i - page_size = @max_page_size if page_size > @max_page_size - page_size = @default_page_size if page_size < 1 - page_size - end - - def where - @model.list_where - end - - def includes - if @owner_model - if @owner_model.owner_model - {@owner_model.item_name => {@owner_model.owner_model.item_name => {}}} - else - {@owner_model.item_name => {}} - end - else - {} - end - end - - def order - @model.list_order - end - - def items - @model.where(self.where()).includes(self.includes).order(self.order).offset(@offset).limit(@page_size) - end - - def paginate - c = @model.where(self.where()).includes(self.includes).count - Kaminari.paginate_array(Array.new(c, nil)).page(@offset).per(@page_size) - end - - def self.add_action item_name, action_name, list_name, list_conf - return - end - end - - class PublicList < BaseList - - def self.set_default option_manifest - end - - def self._add_action item_name, action_name, list_name, list_conf - model = item_name.classify.constantize - controller_name = model.plural + 'Controller' - controller = controller_name.constantize - return if controller.method_defined?(action_name) - controller.define_method(action_name) do - public_list - end - end - end - - class PrivateList < BaseList - def self.set_default option_manifest - end - - def where - case @model.owner_type - when :author - operator = @operators.author - when :artist - operator = @operators.artist - end - t = if @owner_model - if @owner_model.owner_model - @owner_model.owner_model.table_name - else - @owner_model.table_name - end - else - @table_name - end - [t + '.' + @model.owner_type.to_s + '_id = ?', operator.id] - end - end - - class SystemResourceList < BaseList - def items - @model.enable_list - end - - end - - class HasManyList < BaseList - attr :association_model_name - def initialize page, page_size, operators, item_name, list_name, conf, manifest - super - @list_list_conf = @manifest.list(@item_name).lists[list_name] || {} - @association_name = @list_list_conf['association_name'] - @has_many_conf = @manifest.model(@item_name).associations['has_many'] || {} - @association_conf = @has_many_conf[@association_name] || {} - @association_model_name = @association_conf['model'] - @association_model = @association_model_name.classify.constantize - @foreign_key = @association_conf['foreign_key'] - if @association_model.content? - @owner_model = @association_model.owner_model - @owner_table_name = @owner_model.table_name if @owner_model - end - end - - def self.set_default option_manifest - option_manifest['association_name'] ||= 100 - end - - def where parent_item - w = @association_model.list_where - w += ' and ' unless w.blank? - [w + @association_model.table_name + '.' + @foreign_key + ' = ?', parent_item.id] - end - - def includes - # @with_model_name ? {@with_model_name.classify.constantize.table_name => {}} : {} - w = @owner_model ? {@owner_model.item_name => {}} : {} - w.merge({}) - end - - def items parent_item - @association_model.where(self.where(parent_item)).includes(self.includes).order(self.order).offset(@offset).limit(@page_size) - end - - def paginate parent_item - Kaminari.paginate_array(Array.new(@association_model.where(self.where(parent_item)).includes(self.includes).count, nil)).page(@offset).per(@page_size) - end - - def self._add_action item_name, action_name, list_name, list_conf - model = item_name.classify.constantize - controller_name = model.plural + 'Controller' - controller = controller_name.constantize - association_name = list_conf['association_name'] - has_many_conf = Pettanr::Application::manifest.model(item_name).associations['has_many'] || {} - association_conf = has_many_conf[association_name] || {} - association_model_name = association_conf['model'] - return if controller.method_defined?(action_name) - controller.define_method(action_name) do - has_many_list item_name, list_name, association_model_name, params - end - end - - end - - class HasManyThroughList < BaseList - attr :association_model_name - def initialize page, page_size, operators, item_name, list_name, conf, manifest - super - @list_list_conf = @manifest.list(@item_name).lists[list_name] || {} - @association_name = @list_list_conf['association_name'] - @has_many_conf = @manifest.model(@item_name).associations['has_many'] || {} - @association_conf = @has_many_conf[@association_name] || {} - @association_through_model_name = @association_conf['through'] - @association_through_model = @association_through_model_name.classify.constantize - @association_model_name = @association_conf['model'] - @association_model = @association_model_name.classify.constantize - @foreign_key = @association_conf['foreign_key'] - if @association_model.content? - @owner_model = @association_model.owner_model - @owner_table_name = @owner_model.table_name if @owner_model - end - end - - def where root_item - w = @association_model.list_where - w += ' and ' unless w.blank? - [w + @association_through_model.table_name + '.' + @foreign_key + ' = ?', root_item.id] - end - - def includes - {@association_through_model.table_name => {@item_name => {}}} - end - - def items root_item - @association_model.where(self.where(root_item)).includes(self.includes).order(self.order).offset(@offset).limit(@page_size) - end - - def paginate root_item - Kaminari.paginate_array(Array.new(@association_model.where(self.where(root_item)).includes(self.includes).count, nil)).page(@offset).per(@page_size) - end - - end - - class FilterList < BaseList - attr :item_name, :from_model - def initialize page, page_size, operators, item_name, list_name, conf, manifest - super - @list_list_conf = @manifest.list(@item_name).lists[list_name] || {} - @from = @list_list_conf['from'] - @from_model = @from.classify.constantize - @filter_key = @list_list_conf['filter_key'] - @includes = @list_list_conf['includes'] - - @with_model_name = @list_list_conf['with'] - end - - def self.set_default my_manifest - option_manifest['from'] ||= 100 - option_manifest['filter_key'] ||= 100 - end - - def where filter_item - w = @model.list_where - w += ' and ' unless w.blank? - [w + @table_name + '.' + @filter_key + ' = ?', filter_item.id] - end - - def includes - return @includes if @includes - w = @owner_model ? {@owner_model.item_name => {}} : {} - w.merge({@from => {} }) - end - - def items filter_item - @model.where(self.where(filter_item)).includes(self.includes).order(self.order).offset(@offset).limit(@page_size) - end - - def paginate filter_item - Kaminari.paginate_array(Array.new(@model.where(self.where(filter_item)).includes(self.includes).count, nil)).page(@offset).per(@page_size) - end - - def self._add_action item_name, action_name, list_name, list_conf - model = item_name.classify.constantize - controller_name = model.plural + 'Controller' - controller = controller_name.constantize - list_list_conf = Pettanr::Application::manifest.list(item_name).lists[list_name] || {} - from = list_list_conf['from'] - filter_model = from.classify.constantize - filter_key = list_list_conf['filter_key'] - return if controller.method_defined?(action_name) - controller.define_method(action_name) do - filter_list filter_model, params - end - end - - end - - class ThroughFilterList < FilterList - def initialize page, page_size, operators, item_name, list_name, conf, manifest - super - @through = @list_list_conf['through'] - end - - def includes - {@through => {@from => {}} } - end - - def where filter_item - w = @model.list_where - w += ' and ' unless w.blank? - [w + @through + '.' + @filter_key + ' = ?', filter_item.id] - end - - end - - class ElementFilterList < FilterList - def includes - {@owner_model.item_name => {}} - end - - def where filter_item - w = @model.list_where - w += ' and ' unless w.blank? - [w + @owner_table_name + '.' + @filter_key + ' = ?', filter_item.id] - end - - end - - class PlayList - attr :params_offset, :params_count, :offset, :count, :limit - def initialize params_offset, params_count, operators, item_name, list_name, conf, manifest - @operators = operators - @item_name = item_name - @list_name = list_name - @conf = conf - @manifest = manifest - - @default_page_size = @conf['default_page_size'] || 25 - @max_page_size = @conf['max_page_size'] || 100 - @params_offset = params_offset - @params_count = params_count - @list_list_conf = @manifest.list(@item_name).lists[list_name] || {} - @model_name = @list_list_conf['model'] - @filter_key = @list_list_conf['filter_key'] - @model = @model_name.classify.constantize - @table_name = @model.table_name - if @model.content? - @owner_model = @model.owner_model - @owner_table_name = @owner_model.table_name if @owner_model - end - end - - def offset cnt, prm = nil - offset = prm.to_i - offset = cnt - 1 if offset >= cnt - offset = cnt - offset.abs if offset < 0 - offset = 0 if offset < 0 - offset - end - - def limit prm - prm ||= @default_page_size - count = prm.to_i - count = @max_page_size if count > @max_page_size - count = @default_page_size if count < 1 - count - end - - def count filter_item - @count ||= @model.count(:conditions => self.where(filter_item), :include => self.includes).to_i - end - - def where filter_item - w = @model.list_where - w += ' and ' unless w.blank? - [w + @table_name + '.' + @filter_key + ' = ?', filter_item.id] - end - - def includes - {@owner_model.item_name => {}} - end - - def order - @table_name + '.t' - end - - def items filter_item - c = @count || self.count(filter_item) - o = self.offset c, @offset - l = self.limit @count - @model.where(self.where(filter_item)).includes(self.includes).order(self.order).offset(o).limit(l) - end - - def prev_offset filter_item - c = @count || self.count(filter_item) - o = self.offset c, @offset - l = self.limit @count - if o > 0 - if o - l < 0 - 0 - else - o - l - end - else - nil - end - end - - def next_offset filter_item - c = @count || self.count(filter_item) - o = self.offset c, @offset - l = self.limit @count - if o + l > c - nil - else - o + l - end - end - - def self.add_action item_name, action_name, list_name, list_conf - return - end - end - - @@types = { - 'public' => PublicList, 'private' => PrivateList, 'system_resource' => SystemResourceList, - 'has_many' => HasManyList, 'has_many_through' => HasManyThroughList, 'filter' => FilterList, - 'through_filter' => ThroughFilterList, 'element_filter' => ElementFilterList, - 'play' => PlayList +module Manifest + class List + include ListModule + + def self.manager manifest, my_manifests + my_manifests.each {|list_name, list_manifest| + self.new(manifest, list_name, list_manifest) } - def initialize list_manifest - @list_manifest = list_manifest - @item_name = @list_manifest.item_name - @manifest = @list_manifest.manifest - @list_conf = @list_manifest.conf - @lists = {} - @list_manifest.lists.each {|list_name, conf| - type = conf['type'] - @lists[list_name] = @@types[type] - } - end - - def open list_name, page, page_size, operators - raise "undefined list for #{@item_name}::#{list_name}\nconf:#{@list_conf}\n" unless @lists[list_name] - @lists[list_name].new page, page_size, operators, @item_name, list_name, @list_conf, @manifest - end - - def filer opt = nil - paginate = opt ? @list.paginate(opt) : @list.paginate - @filer ||= @manifest.filer_managers[@item_name].open(@item_name, @items, @operators, paginate) - end - - def add_action action_name, list_name - @lists[list_name].add_action @item_name, action_name, list_name, @list_conf + end + + @@types = { + 'public' => PublicList, 'private' => PrivateList, 'system_resource' => SystemResourceList, + 'has_many' => HasManyList, 'has_many_through' => HasManyThroughList, 'filter' => FilterList, + 'through_filter' => ThroughFilterList, 'element_filter' => ElementFilterList, + 'play' => PlayList + } + attr :list_name, :list_manifest, + :default_page_size, :max_page_size + def initialize manifest, list_name, list_manifest + @manifest = manifest + @list_name = list_name + @list_manifest = list_manifest + self.set_default + self.init + @list_manifest.lists.each {|list_name, conf| + type = conf['type'] + @lists[list_name] = @@types[type] + } + end + + def set_default + @list_manifest['lists'] ||= {} + @list_manifest['default_page_size'] ||= 25 + @list_manifest['max_page_size'] ||= 100 + end + + def init + @default_page_size = @list_manifest['default_page_size'] + @max_page_size = @list_manifest['max_page_size'] + @lists = {} + @list_manifest['lists'].each {|list_name, list_manifest| + raise "undefined type for models > #{@model_name} > attributes > #{attribute_name}\n" unless attribute_manifest['type'] + @lists[list_name] = List.new(self, list_name, list_manifest) + } + end + + def open list_name, page, page_size, operators + raise "undefined list for #{@item_name}::#{list_name}\nconf:#{@list_conf}\n" unless @lists[list_name] + @lists[list_name].new page, page_size, operators, @item_name, list_name, @list_conf, @manifest + end + + def filer opt = nil + paginate = opt ? @list.paginate(opt) : @list.paginate + @filer ||= @manifest.filer_managers[@item_name].open(@item_name, @items, @operators, paginate) end + def add_action action_name, list_name + @lists[list_name].add_action @item_name, action_name, list_name, @list_conf end + end end - diff --git a/lib/manifest/manifest.rb b/lib/manifest/manifest.rb index 0fb89ca9..1d3fb467 100644 --- a/lib/manifest/manifest.rb +++ b/lib/manifest/manifest.rb @@ -1,141 +1,34 @@ - -module Pettanr - module Manifest - class List - attr :item_name, :conf, :manifest, :default_page_size, :lists - def initialize item_name, conf, manifest - @item_name = item_name - @conf = conf || {} - @manifest = manifest - @default_page_size = @conf['default_page_size'] || 20 - @lists = @conf['lists'] || {} - end - - end - - class SystemResources - attr :conf, :license_groups, :elements, :speech_balloon_templates, :writing_formats - def initialize system_resource_conf - @conf = system_resource_conf || {} - @engine_resources = @conf['engine_resources'] || {} - @license_groups = @engine_resources['license_groups'] || {} - @speech_balloon_templates = @engine_resources['speech_balloon_templates'] || {} - @writing_formats = @engine_resources['writing_formats'] || {} - @elements = @conf['elements'] || {} - end - - end - - class Profiler - attr :item_name, :conf, :manifest, :columns, :lists, :belongs_to, :has_many, :has_one - def initialize item_name, conf, manifest - @item_name = item_name - @conf = conf || {} - @manifest = manifest - @columns = @conf['columns'] || {} - @lists = @conf['lists'] || {} - @associations_conf = @conf['associations'] || {} - @belongs_to = @associations_conf['belongs_to'] || [] - @has_many = @associations_conf['has_many'] || [] - @has_one = @associations_conf['has_one'] || [] - end - - end - - class Filer - attr :item_name, :conf, :manifest, :icon, :symbol, :caption, :summary, :date, :edit - def initialize item_name, conf, manifest - @item_name = item_name - @conf = conf || {} - @manifest = manifest - @symbol = @conf['symbol'] - @caption = @conf['caption'] - @summary = @conf['summary'] - @icon = @conf['icon'] - @date = @conf['date'] - @edit = @conf['edit'] - end - - end - - class Form - attr :item_name, :conf, :manifest, :base, :fields, :field_names - def initialize item_name, conf, manifest - @item_name = item_name - @conf = conf || {} - @manifest = manifest - @base = @conf['base'] - @fields = @conf['fields'] || {} - @field_names = @conf['field_names'] || [] - end - - end - +module Manifest class Manifest + cattr_accessor :manifest attr :system_resources, :magic_numbers, :select_items, - :controller_managers, :model_managers, :list_managers, :profiler_managers, :filer_managers, :form_managers + :controllers, :models, :lists, :profilers, :filers, :forms + # call me before load routes.rb + # routes.rb needs engine_resources manifest in system_resources + # ex. it's adding license_groups routes def initialize manifest @manifest = manifest || {} - @system_resources = SystemResources.new(@manifest['system_resources']) + @system_resources = SystemResources.new(self, SystemResources.set_default(@manifest['system_resources'])) @magic_numbers = @manifest['magic_numbers'] @select_items = @manifest['select_items'] - @controllers = Controller.set_default(@manifest['controllers'] || {}) - @models = Model.set_default(@manifest['models'] || {}) - @lists = List.set_default(@manifest['lists'] || {}) - @profilers = {} - @filers = {} - @forms = {} - @controller_managers = {} - @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, self) - @controller_managers[item_name] = Pettanr::ControllerManager.new @controllers[item_name] - } - (@manifest['models'] || {}).each {|item_name, model_conf| - @models[item_name] = Model.new(item_name, model_conf, self) - @model_managers[item_name] = Pettanr::ModelManager.new @models[item_name] - } - (@manifest['lists'] || {}).each {|item_name, list_conf| - @lists[item_name] = List.new(item_name, list_conf, self) - @list_managers[item_name] = Pettanr::ListManager.new @lists[item_name] - } - @locals = @manifest['locals'] || {} - (@locals['profilers'] || {}).each {|item_name, profiler_conf| - @profilers[item_name] = Profiler.new item_name, profiler_conf, self - @profiler_managers[item_name] = Pettanr::ProfilerManager.new @profilers[item_name] - } - (@locals['filers'] || {}).each {|item_name, filer_conf| - @filers[item_name] = Filer.new item_name, filer_conf, self - @filer_managers[item_name] = Pettanr::FilerManager.new @filers[item_name] - } - (@locals['forms'] || {}).each {|form_name, form_conf| - @forms[form_name] = Form.new form_name, form_conf, self - @form_managers[form_name] = Pettanr::FormManager.new @forms[form_name] - } end + # managers can't initialize at application.rb + # call me after configured Rails Application def init + @controllers = Controller.manager(self, @manifest['controllers']) + @models = Model.manager(self, @manifest['models']) +# @lists = List.manager(self, @manifest['lists']) + @profilers = {} + @filers = {} + @forms = {} select_items_loader - select_items_font_size add_action end - #oh my ... - #JSON.stringify couldn't print 1.0 - # 1 == 1.0 ? - #change class - def select_items_font_size - (@select_items['magic_number']['speech_font_size_items']).each {|conf| - conf[1] = conf[1].to_f - } - end - + # call after load app def select_items_loader - (@select_items['model_loader'] || {}).each {|name, conf| + @system_resources.select_items['model_loader'].each {|name, conf| list = Pettanr::Application::manifest.list_managers[conf['model']].open conf['list_name'], nil, nil, nil @select_items['model'] ||= {} @select_items['model'][name] = list.items.map {|item| [item.caption, item.id]} @@ -143,6 +36,7 @@ module Pettanr end def add_action + return @controllers.each do |controller_name, controller| model_name = controller.model_name next if model_name.blank? @@ -155,31 +49,23 @@ module Pettanr end end - def controller item_name - @controllers[item_name] || @mcontrollers[item_name.tableize] - end - - def model item_name - @models[item_name] || @models[item_name.tableize] - end - - def list item_name - @lists[item_name] || @lists[item_name.tableize] - end - - def profiler item_name - @profilers[item_name] || @profilers[item_name.tableize] + end + + module ModuleMethods + def manifest + Manifest.manifest end - def filer item_name - @filers[item_name] || @filers[item_name.tableize] + def load json + Manifest.manifest = Manifest.new json end - def form form_name - @forms[form_name] || @forms[form_name.tableize] + def item_name_to_model item_name + item_name.classify.constantize end end - + + extend ModuleMethods end diff --git a/lib/manifest/model.rb b/lib/manifest/model.rb index d414bb10..4ba9c428 100644 --- a/lib/manifest/model.rb +++ b/lib/manifest/model.rb @@ -1,51 +1,59 @@ +require "manifest/model/attribute" +require "manifest/model/association" +require "manifest/model/list" -module Pettanr - module Manifest - class Model - def self.set_default my_manifest - my_manifest.each {|item_name, model_manifest| - model_manifest['attributes'] ||= {} - model_manifest['associations'] ||= {} - model_manifest|['attributes'].each {|attribute_name, attribute_manifest| - attribute_manifest.each {|attribute_name, attribute_manifest| - raise "undefined type for models > #{item_name} > attributes > #{attribute_name}\n" unless attribute_manifest['type'] - attribute_manifest['primary_key'] ||= 0 - attribute_manifest['rules'] ||= {} - attribute_manifest['rules'].each {|rule_name, rule_manifest| - # 'required' 'number' - } - } - } - model_manifest|['associations'].each {|association_name, association_manifest| - association_manifest['belongs_to'] ||= {} - association_manifest['has_many'] ||= {} - association_manifest['has_one'] ||= {} - association_manifest['belongs_to'].each {|belongs_to_name, belongs_to_manifest| - belongs_to_manifest['id_column'] ||= belongs_to_name + '_id' - } - association_manifest['has_many'].each {|has_many_name, has_many_manifest| - raise "undefined foreign_key for models > #{item_name} > associations > has_many > #{has_many_name}\n" unless has_many_manifest['foreign_key'] - has_many_manifest['model'] ||= has_many_name.singularize - # 'through' - } - association_manifest['belongs_to'].each {|belongs_to_name, belongs_to_manifest| - belongs_to_manifest['id_column'] ||= belongs_to_name + '_id' - } - } - } - end - - def initialize model_manifest - @model_manifest = model_manifest - @item_name = @model_manifest.item_name - @manifest = @model_manifest.manifest - @model_conf = @model_manifest.conf - end - - def open list_name, page, page_size, operators - end - +module Manifest + class Model + include ModelModule + include ListModule + + def self.manager manifest, my_manifests + my_manifests.map {|model_name, model_manifest| + self.new(manifest, model_name, model_manifest) + } end + + @@types = { + 'public' => PublicList, 'private' => PrivateList, 'system_resource' => SystemResourceList, + 'has_many' => HasManyList, 'has_many_through' => HasManyThroughList, 'filter' => FilterList, + 'through_filter' => ThroughFilterList, 'element_filter' => ElementFilterList, + 'play' => PlayList + } + attr :model_name, :model_manifest + def initialize manifest, model_name, model_manifest + @manifest = manifest + @model_name = model_name + @model_manifest = model_manifest + self.set_default + self.init + end + + def set_default + @model_manifest['attributes'] ||= {} + @model_manifest['associations'] ||= {} + @model_manifest['lists'] ||= {} + end + + def init + @attributes = {} + @model_manifest['attributes'].each {|attribute_name, attribute_manifest| + raise "undefined type for models > #{@model_name} > attributes > #{attribute_name}\n" unless attribute_manifest['type'] + @attributes[attribute_name] = Attribute.new(self, attribute_name, attribute_manifest) + } + @associations = {} + @model_manifest['associations'].each {|association_name, association_manifest| + @associations[association_name] = Association.new(self, association_name, association_manifest) + } + @lists = {} + @model_manifest['lists'].each {|list_name, list_manifest| + type = list_manifest['type'] + raise "undefined type for models > #{@model_name} > lists > #{list_name}\n" unless type + list = @@types[type] + raise "undefined class for models > #{@model_name} > actions > #{list_name} > type > #{type}\n" unless list + @lists[list_name] = list.new(self, list_name, list_manifest) + } + end + end end diff --git a/lib/manifest/model/association.rb b/lib/manifest/model/association.rb new file mode 100644 index 00000000..5d74e667 --- /dev/null +++ b/lib/manifest/model/association.rb @@ -0,0 +1,50 @@ +require "manifest/model/association/belongs_to" +require "manifest/model/association/has_many" +require "manifest/model/association/has_one" +module Manifest + module ModelModule + class Association + include AssociationModule + attr :model, :association_name, :association_manifest, + :belongs_to, :has_many, :has_one + def initialize model, association_name, association_manifest + @model = model + @association_name = association_name + @association_manifest = association_manifest + self.set_default + self.init + end + + def set_default + @association_manifest['belongs_to'] ||= {} + @association_manifest['has_many'] ||= {} + @association_manifest['has_one'] ||= {} + end + + def init + @belongs_to = {} + @has_many = {} + @has_one = {} + @association_manifest['belongs_to'].each {|belongs_to_name, belongs_to_manifest| + @belongs_to[belongs_to_name] = BelongsTo.new(self, belongs_to_name, belongs_to_manifest) + } + @association_manifest['has_many'].each {|has_many_name, has_many_manifest| + @has_many[has_many_name] = HasMany.new(self, has_many_name, has_many_manifest) + } + @association_manifest['has_one'].each {|has_one_name, has_one_manifest| + @has_one[has_one_name] = HasOne.new(self, has_one_name, has_one_manifest) + } + end + + def model_name + @model.model_name + end + + def model_manifest + @model.model_manifest + end + + end + + end +end diff --git a/lib/manifest/model/association/belongs_to.rb b/lib/manifest/model/association/belongs_to.rb new file mode 100644 index 00000000..81d88b3b --- /dev/null +++ b/lib/manifest/model/association/belongs_to.rb @@ -0,0 +1,29 @@ +module Manifest + module AssociationModule + class BelongsTo + attr :association, :belongs_to_name, :belongs_to_manifest, + :id_column + def initialize association, belongs_to_name, belongs_to_manifest + @association = association + @belongs_to_name = belongs_to_name + @belongs_to_manifest = belongs_to_manifest + self.set_default + self.init + end + + def set_default + @belongs_to_manifest['id_column'] ||= @belongs_to_name + '_id' + end + + def init + @id_column = @belongs_to_manifest['id_column'] + end + + def association_name + @association.association_name + end + + end + + end +end diff --git a/lib/manifest/model/association/has_many.rb b/lib/manifest/model/association/has_many.rb new file mode 100644 index 00000000..a42a9a5c --- /dev/null +++ b/lib/manifest/model/association/has_many.rb @@ -0,0 +1,32 @@ +module Manifest + module AssociationModule + class HasMany + attr :association, :has_many_name, :has_many_manifest, + :model, :foreign_key, :through + def initialize association, has_many_name, has_many_manifest + @association = association + @has_many_name = has_many_name + @has_many_manifest = has_many_manifest + self.set_default + self.init + end + + def set_default + @has_many_manifest['model'] ||= @has_many_name.singularize + end + + def init + @model = @has_many_manifest['model'] + raise "undefined foreign_key for models > #{@association.model.model_name} > associations > has_many > #{@association.association_name}\n" unless @has_many_manifest['foreign_key'] + @foreign_key = @has_many_manifest['foreign_key'] + @through = @has_many_manifest['through'] + end + + def association_name + @association.association_name + end + + end + + end +end diff --git a/lib/manifest/model/association/has_one.rb b/lib/manifest/model/association/has_one.rb new file mode 100644 index 00000000..83b03ed7 --- /dev/null +++ b/lib/manifest/model/association/has_one.rb @@ -0,0 +1,31 @@ +module Manifest + module AssociationModule + class HasOne + attr :association, :has_one_name, :has_one_manifest, + :model, :foreign_key + def initialize association, has_one_name, has_one_manifest + @association = association + @has_one_name = has_one_name + @has_one_manifest = has_one_manifest + self.set_default + self.init + end + + def set_default + @has_one_manifest['model'] ||= @has_one_name + end + + def init + @model = @has_one_manifest['model'] + raise "undefined foreign_key for models > #{@association.model.model_name} > associations > has_one > #{@association.association_name}\n" unless @has_one_manifest['foreign_key'] + @foreign_key = @has_one_manifest['foreign_key'] + end + + def association_name + @association.association_name + end + + end + + end +end diff --git a/lib/manifest/model/attribute.rb b/lib/manifest/model/attribute.rb new file mode 100644 index 00000000..f093ae79 --- /dev/null +++ b/lib/manifest/model/attribute.rb @@ -0,0 +1,35 @@ +module Manifest + module ModelModule + class Attribute + attr :model, :attribute_name, :attribute_manifest, + :primary_key, :rules + def initialize model, attribute_name, attribute_manifest + @model = model + @attribute_name = attribute_name + @attribute_manifest = attribute_manifest + self.set_default + self.init + end + + def set_default + @attribute_manifest['primary_key'] ||= 0 + @attribute_manifest['rules'] ||= {} + end + + def init + @primary_key = @attribute_manifest['primary_key'] + @rules = @attribute_manifest['rules'] + end + + def model_name + @model.model_name + end + + def model_manifest + @model.model_manifest + end + + end + + end +end diff --git a/lib/manifest/model/list.rb b/lib/manifest/model/list.rb new file mode 100644 index 00000000..1b93aa09 --- /dev/null +++ b/lib/manifest/model/list.rb @@ -0,0 +1,10 @@ +require "manifest/model/list/base" +require "manifest/model/list/public" +require "manifest/model/list/private" +require "manifest/model/list/system_resource" +require "manifest/model/list/has_many" +require "manifest/model/list/has_many_through" +require "manifest/model/list/filter" +require "manifest/model/list/through_filter" +require "manifest/model/list/element_filter" +require "manifest/model/list/play" diff --git a/lib/manifest/model/list/base.rb b/lib/manifest/model/list/base.rb new file mode 100644 index 00000000..805f3154 --- /dev/null +++ b/lib/manifest/model/list/base.rb @@ -0,0 +1,95 @@ +module Manifest + module ListModule + class BaseList + attr :model, :list_name, :list_manifest, + :default_page_size, :max_page_size + def initialize model, list_name, list_manifest + @model = model + @list_name = list_name + @list_manifest = list_manifest + self.set_default + self.init + + @model = ::Manifest.item_name_to_model self.model_name + @table_name = @model.table_name + if @model.content? + @owner_model = @model.owner_model + @owner_table_name = @owner_model.table_name if @owner_model + end + end + + def set_default + self.list_manifest['args'] ||= {} + @list_manifest['args']['default_page_size'] ||= 25 + @list_manifest['args']['max_page_size'] ||= 100 + end + + def init + @args = @list_manifest['args'] + @default_page_size = @list_manifest['args']['default_page_size'] + @max_page_size = @list_manifest['args']['max_page_size'] + end + + def model_name + @model.model_name + end + + def model_manifest + @model.model_manifest + end + + def page_number prm = nil + page = prm.to_i + page = 1 if page < 1 + page + end + + def page_size prm + page_size = prm.to_i + page_size = @max_page_size if page_size > @max_page_size + page_size = @default_page_size if page_size < 1 + page_size + end + + def where + @model.list_where + end + + def includes + if @owner_model + if @owner_model.owner_model + {@owner_model.item_name => {@owner_model.owner_model.item_name => {}}} + else + {@owner_model.item_name => {}} + end + else + {} + end + end + + def order + @model.list_order + end + + def a page, page_size, operators + @page = self.page_number(page) + @page_size = self.page_size page_size + @offset = (@page -1) * @page_size + end + + def items + @model.where(self.where()).includes(self.includes).order(self.order).offset(@offset).limit(@page_size) + end + + def paginate + c = @model.where(self.where()).includes(self.includes).count + Kaminari.paginate_array(Array.new(c, nil)).page(@offset).per(@page_size) + end + + def self.add_action item_name, action_name, list_name, list_conf + return + end + end + + end +end diff --git a/lib/manifest/model/list/element_filter.rb b/lib/manifest/model/list/element_filter.rb new file mode 100644 index 00000000..b8462686 --- /dev/null +++ b/lib/manifest/model/list/element_filter.rb @@ -0,0 +1,29 @@ +module Manifest + module ListModule + class ElementFilterList < FilterList + + def set_default + super + end + + def init + super + end + + def includes + {@owner_model.item_name => {}} + end + + def where filter_item + w = @model.list_where + w += ' and ' unless w.blank? + [w + @owner_table_name + '.' + @filter_key + ' = ?', filter_item.id] + end + + def self.add_action item_name, action_name, list_name, list_conf + return + end + end + + end +end diff --git a/lib/manifest/model/list/filter.rb b/lib/manifest/model/list/filter.rb new file mode 100644 index 00000000..c8eee973 --- /dev/null +++ b/lib/manifest/model/list/filter.rb @@ -0,0 +1,52 @@ +module Manifest + module ListModule + class FilterList < BaseList + + def set_default + super + end + + def init + super + return + end + + def where filter_item + w = @model.list_where + w += ' and ' unless w.blank? + [w + @table_name + '.' + @filter_key + ' = ?', filter_item.id] + end + + def includes + return @includes if @includes + w = @owner_model ? {@owner_model.item_name => {}} : {} + w.merge({@from => {} }) + end + + def items filter_item + @model.where(self.where(filter_item)).includes(self.includes).order(self.order).offset(@offset).limit(@page_size) + end + + def paginate filter_item + Kaminari.paginate_array(Array.new(@model.where(self.where(filter_item)).includes(self.includes).count, nil)).page(@offset).per(@page_size) + end + + def self._add_action item_name, action_name, list_name, list_conf + return + model = item_name.classify.constantize + controller_name = model.plural + 'Controller' + controller = controller_name.constantize + list_list_conf = Pettanr::Application::manifest.list(item_name).lists[list_name] || {} + from = list_list_conf['from'] + filter_model = from.classify.constantize + filter_key = list_list_conf['filter_key'] + return if controller.method_defined?(action_name) + controller.define_method(action_name) do + filter_list filter_model, params + end + end + + end + + end +end diff --git a/lib/manifest/model/list/has_many.rb b/lib/manifest/model/list/has_many.rb new file mode 100644 index 00000000..4a97cdc1 --- /dev/null +++ b/lib/manifest/model/list/has_many.rb @@ -0,0 +1,66 @@ +module Manifest + module ListModule + class HasManyList < BaseList + def initialize list, list_name, list_manifest + super + end + + def set_default + super + return + option_manifest['association_name'] ||= 100 + end + + def init + super + return + @list_list_conf = @manifest.list(@item_name).lists[list_name] || {} + @association_name = @list_list_conf['association_name'] + @has_many_conf = @manifest.model(@item_name).associations['has_many'] || {} + @association_conf = @has_many_conf[@association_name] || {} + @association_model_name = @association_conf['model'] + @association_model = @association_model_name.classify.constantize + @foreign_key = @association_conf['foreign_key'] + if @association_model.content? + @owner_model = @association_model.owner_model + @owner_table_name = @owner_model.table_name if @owner_model + end + end + + def where parent_item + w = @association_model.list_where + w += ' and ' unless w.blank? + [w + @association_model.table_name + '.' + @foreign_key + ' = ?', parent_item.id] + end + + def includes + # @with_model_name ? {@with_model_name.classify.constantize.table_name => {}} : {} + w = @owner_model ? {@owner_model.item_name => {}} : {} + w.merge({}) + end + + def items parent_item + @association_model.where(self.where(parent_item)).includes(self.includes).order(self.order).offset(@offset).limit(@page_size) + end + + def paginate parent_item + Kaminari.paginate_array(Array.new(@association_model.where(self.where(parent_item)).includes(self.includes).count, nil)).page(@offset).per(@page_size) + end + + def self._add_action item_name, action_name, list_name, list_conf + model = item_name.classify.constantize + controller_name = model.plural + 'Controller' + controller = controller_name.constantize + association_name = list_conf['association_name'] + has_many_conf = Pettanr::Application::manifest.model(item_name).associations['has_many'] || {} + association_conf = has_many_conf[association_name] || {} + association_model_name = association_conf['model'] + return if controller.method_defined?(action_name) + controller.define_method(action_name) do + has_many_list item_name, list_name, association_model_name, params + end + end + end + + end +end diff --git a/lib/manifest/model/list/has_many_through.rb b/lib/manifest/model/list/has_many_through.rb new file mode 100644 index 00000000..a4e1bd66 --- /dev/null +++ b/lib/manifest/model/list/has_many_through.rb @@ -0,0 +1,53 @@ +module Manifest + module ListModule + class HasManyThroughList < BaseList + attr :list, :list_name, :list_manifest, + :belongs_to, :has_many, :has_one + + def set_default + super + end + + def init + super + return + @list_list_conf = @manifest.list(@item_name).lists[list_name] || {} + @association_name = @list_list_conf['association_name'] + @has_many_conf = @manifest.model(@item_name).associations['has_many'] || {} + @association_conf = @has_many_conf[@association_name] || {} + @association_through_model_name = @association_conf['through'] + @association_through_model = @association_through_model_name.classify.constantize + @association_model_name = @association_conf['model'] + @association_model = @association_model_name.classify.constantize + @foreign_key = @association_conf['foreign_key'] + if @association_model.content? + @owner_model = @association_model.owner_model + @owner_table_name = @owner_model.table_name if @owner_model + end + end + + def where root_item + w = @association_model.list_where + w += ' and ' unless w.blank? + [w + @association_through_model.table_name + '.' + @foreign_key + ' = ?', root_item.id] + end + + def includes + {@association_through_model.table_name => {@item_name => {}}} + end + + def items root_item + @association_model.where(self.where(root_item)).includes(self.includes).order(self.order).offset(@offset).limit(@page_size) + end + + def paginate root_item + Kaminari.paginate_array(Array.new(@association_model.where(self.where(root_item)).includes(self.includes).count, nil)).page(@offset).per(@page_size) + end + + def self.add_action item_name, action_name, list_name, list_conf + return + end + end + + end +end diff --git a/lib/manifest/model/list/play.rb b/lib/manifest/model/list/play.rb new file mode 100644 index 00000000..a916a8cd --- /dev/null +++ b/lib/manifest/model/list/play.rb @@ -0,0 +1,115 @@ +module Manifest + module ListModule + class PlayList + attr :model, :list_name, :list_manifest + + def initialize model, list_name, list_manifest + @model = model + @list_name = list_name + @list_manifest = list_manifest + self.set_default + self.init + end + + def set_default + return + @default_page_size = @conf['default_page_size'] || 25 + @max_page_size = @conf['max_page_size'] || 100 + @params_offset = params_offset + @params_count = params_count + @list_list_conf = @manifest.list(@item_name).lists[list_name] || {} + @model_name = @list_list_conf['model'] + @filter_key = @list_list_conf['filter_key'] + @model = @model_name.classify.constantize + @table_name = @model.table_name + if @model.content? + @owner_model = @model.owner_model + @owner_table_name = @owner_model.table_name if @owner_model + end + end + + def init + end + + def list_name + @list.list_name + end + + def list_manifest + @list.list_manifest + end + + def offset cnt, prm = nil + offset = prm.to_i + offset = cnt - 1 if offset >= cnt + offset = cnt - offset.abs if offset < 0 + offset = 0 if offset < 0 + offset + end + + def limit prm + prm ||= @default_page_size + count = prm.to_i + count = @max_page_size if count > @max_page_size + count = @default_page_size if count < 1 + count + end + + def count filter_item + @count ||= @model.count(:conditions => self.where(filter_item), :include => self.includes).to_i + end + + def where filter_item + w = @model.list_where + w += ' and ' unless w.blank? + [w + @table_name + '.' + @filter_key + ' = ?', filter_item.id] + end + + def includes + {@owner_model.item_name => {}} + end + + def order + @table_name + '.t' + end + + def items filter_item + c = @count || self.count(filter_item) + o = self.offset c, @offset + l = self.limit @count + @model.where(self.where(filter_item)).includes(self.includes).order(self.order).offset(o).limit(l) + end + + def prev_offset filter_item + c = @count || self.count(filter_item) + o = self.offset c, @offset + l = self.limit @count + if o > 0 + if o - l < 0 + 0 + else + o - l + end + else + nil + end + end + + def next_offset filter_item + c = @count || self.count(filter_item) + o = self.offset c, @offset + l = self.limit @count + if o + l > c + nil + else + o + l + end + end + + def self.add_action item_name, action_name, list_name, list_conf + return + end + end + + end +end diff --git a/lib/manifest/model/list/private.rb b/lib/manifest/model/list/private.rb new file mode 100644 index 00000000..4d9cc1bb --- /dev/null +++ b/lib/manifest/model/list/private.rb @@ -0,0 +1,38 @@ +module Manifest + module ListModule + class PrivateList < BaseList + + def set_default + super + end + + def init + super + end + + def where + case @model.owner_type + when :author + operator = @operators.author + when :artist + operator = @operators.artist + end + t = if @owner_model + if @owner_model.owner_model + @owner_model.owner_model.table_name + else + @owner_model.table_name + end + else + @table_name + end + [t + '.' + @model.owner_type.to_s + '_id = ?', operator.id] + end + + def self.add_action item_name, action_name, list_name, list_conf + return + end + end + + end +end diff --git a/lib/manifest/model/list/public.rb b/lib/manifest/model/list/public.rb new file mode 100644 index 00000000..3395610e --- /dev/null +++ b/lib/manifest/model/list/public.rb @@ -0,0 +1,30 @@ +module Manifest + module ListModule + class PublicList < BaseList + + def initialize model, list_name, list_manifest + super + end + + def set_default + super + end + + def init + super + end + + def self.add_action item_name, action_name, list_name, list_conf + return + model = item_name.classify.constantize + controller_name = model.plural + 'Controller' + controller = controller_name.constantize + return if controller.method_defined?(action_name) + controller.define_method(action_name) do + public_list + end + end + end + + end +end diff --git a/lib/manifest/model/list/system_resource.rb b/lib/manifest/model/list/system_resource.rb new file mode 100644 index 00000000..0378b073 --- /dev/null +++ b/lib/manifest/model/list/system_resource.rb @@ -0,0 +1,23 @@ +module Manifest + module ListModule + class SystemResourceList < BaseList + + def set_default + super + end + + def init + super + end + + def items + @model.enable_list + end + + def self.add_action item_name, action_name, list_name, list_conf + return + end + end + + end +end diff --git a/lib/manifest/model/list/through_filter.rb b/lib/manifest/model/list/through_filter.rb new file mode 100644 index 00000000..d8b35dde --- /dev/null +++ b/lib/manifest/model/list/through_filter.rb @@ -0,0 +1,29 @@ +module Manifest + module ListModule + class ThroughFilterList < FilterList + attr :list, :list_name, :list_manifest + + def set_default + super + end + + def init + super + return + @through = @list_list_conf['through'] + end + + def includes + {@through => {@from => {}} } + end + + def where filter_item + w = @model.list_where + w += ' and ' unless w.blank? + [w + @through + '.' + @filter_key + ' = ?', filter_item.id] + end + + end + + end +end diff --git a/lib/manifest/profiler.rb b/lib/manifest/profiler.rb index e9e27275..81cc8d44 100644 --- a/lib/manifest/profiler.rb +++ b/lib/manifest/profiler.rb @@ -1,3 +1,19 @@ + class Profiler + attr :item_name, :conf, :manifest, :columns, :lists, :belongs_to, :has_many, :has_one + def initialize item_name, conf, manifest + @item_name = item_name + @conf = conf || {} + @manifest = manifest + @columns = @conf['columns'] || {} + @lists = @conf['lists'] || {} + @associations_conf = @conf['associations'] || {} + @belongs_to = @associations_conf['belongs_to'] || [] + @has_many = @associations_conf['has_many'] || [] + @has_one = @associations_conf['has_one'] || [] + end + + end + module Pettanr class ProfilerManager diff --git a/lib/manifest/system_resources.rb b/lib/manifest/system_resources.rb new file mode 100644 index 00000000..42b2daea --- /dev/null +++ b/lib/manifest/system_resources.rb @@ -0,0 +1,36 @@ +module Manifest + class SystemResources + 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| + conf[1] = conf[1].to_f + } + system_resources_manifest + end + + attr :engine_resources, :license_groups, :speech_balloon_templates, :writing_formats, :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'] + @elements = system_resources_manifest['elements'] + @select_items = system_resources_manifest['select_items'] + end + + end +end + diff --git a/public/manifest.json b/public/manifest.json index d10ace73..ab2dda93 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -1,41 +1,40 @@ { "controllers": { "scroll": { - "model_name": "scroll", "actions": { "index": { "type": "list", - "list": { + "args": { "list_name": "public_list" } }, "scroll_panels": { "type": "list", - "list": { + "args": { "list_name": "scroll_panels" } }, "panels": { "type": "list", - "list": { + "args": { "list_name": "panels" } }, "by_author": { "type": "list", - "list": { + "args": { "list_name": "by_author" } }, "by_panel": { "type": "list", - "list": { + "args": { "list_name": "by_panel" } }, "play": { "type": "list", - "list": { + "args": { "list_name": "play" } }, @@ -46,412 +45,398 @@ } }, "scroll_panel": { - "model_name": "scroll_panel", "actions": { "index": { "type": "list", - "list": { + "args": { "list_name": "public_list" } }, "by_panel": { "type": "list", - "list": { + "args": { "list_name": "by_panel" } }, "by_scroll": { "type": "list", - "list": { + "args": { "list_name": "by_scroll" } } } }, "comic": { - "model_name": "comic", "actions": { "index": { "type": "list", - "list": { + "args": { "list_name": "public_list" } }, "stories": { "type": "list", - "list": { + "args": { "list_name": "stories" } }, "by_author": { "type": "list", - "list": { + "args": { "list_name": "by_author" } } } }, "story": { - "model_name": "story", "actions": { "index": { "type": "list", - "list": { + "args": { "list_name": "public_list" } }, "story_sheets": { "type": "list", - "list": { + "args": { "list_name": "story_sheets" } }, "sheets": { "type": "list", - "list": { + "args": { "list_name": "sheets" } }, "by_comic": { "type": "list", - "list": { + "args": { "list_name": "by_comic" } }, "by_sheet": { "type": "list", - "list": { + "args": { "list_name": "by_sheet" } }, "by_author": { "type": "list", - "list": { + "args": { "list_name": "by_author" } }, "play": { "type": "list", - "list": { + "args": { "list_name": "play" } } } }, "story_sheet": { - "model_name": "story_sheet", "actions": { "index": { "type": "list", - "list": { + "args": { "list_name": "public_list" } }, "by_story": { "type": "list", - "list": { + "args": { "list_name": "by_story" } }, "by_sheet": { "type": "list", - "list": { + "args": { "list_name": "by_sheet" } } } }, "sheet": { - "model_name": "sheet", "actions": { "index": { "type": "list", - "list": { + "args": { "list_name": "public_list" } }, "story_sheets": { "type": "list", - "list": { + "args": { "list_name": "story_sheets" } }, "stories": { "type": "list", - "list": { + "args": { "list_name": "stories" } }, "sheet_panels": { "type": "list", - "list": { + "args": { "list_name": "sheet_panels" } }, "panels": { "type": "list", - "list": { + "args": { "list_name": "panels" } }, "by_story": { "type": "list", - "list": { + "args": { "list_name": "by_story" } }, "by_panel": { "type": "list", - "list": { + "args": { "list_name": "by_panel" } }, "by_author": { "type": "list", - "list": { + "args": { "list_name": "by_author" } }, "play": { "type": "list", - "list": { + "args": { "list_name": "play" } } } }, "sheet_panel": { - "model_name": "sheet_panel", "actions": { "index": { "type": "list", - "list": { + "args": { "list_name": "public_list" } }, "by_sheet": { "type": "list", - "list": { + "args": { "list_name": "by_sheet" } }, "by_panel": { "type": "list", - "list": { + "args": { "list_name": "by_panel" } } } }, "panel": { - "model_name": "panel", "actions": { "index": { "type": "list", - "list": { + "args": { "list_name": "public_list" } }, "scroll_panels": { "type": "list", - "list": { + "args": { "list_name": "scroll_panels" } }, "scrolls": { "type": "list", - "list": { + "args": { "list_name": "scrolls" } }, "sheet_panels": { "type": "list", - "list": { + "args": { "list_name": "sheet_panels" } }, "sheets": { "type": "list", - "list": { + "args": { "list_name": "sheets" } }, "panel_pictures": { "type": "list", - "list": { + "args": { "list_name": "panel_pictures" } }, "speech_balloons": { "type": "list", - "list": { + "args": { "list_name": "speech_balloons" } }, "ground_pictures": { "type": "list", - "list": { + "args": { "list_name": "ground_pictures" } }, "ground_colors": { "type": "list", - "list": { + "args": { "list_name": "ground_colors" } }, "by_scroll": { "type": "list", - "list": { + "args": { "list_name": "by_scroll" } }, "by_sheet": { "type": "list", - "list": { + "args": { "list_name": "by_sheet" } }, "by_author": { "type": "list", - "list": { + "args": { "list_name": "by_author" } }, "by_speech_balloon_template": { "type": "list", - "list": { + "args": { "list_name": "by_speech_balloon_template" } } } }, "panel_picture": { - "model_name": "panel_picture", "actions": { "index": { "type": "list", - "list": { + "args": { "list_name": "public_list" } }, "by_panel": { "type": "list", - "list": { + "args": { "list_name": "by_panel" } }, "by_author": { "type": "list", - "list": { + "args": { "list_name": "by_author" } } } }, "speech_balloon": { - "model_name": "speech_balloon", "actions": { "index": { "type": "list", - "list": { + "args": { "list_name": "public_list" } }, "by_panel": { "type": "list", - "list": { + "args": { "list_name": "by_panel" } }, "by_author": { "type": "list", - "list": { + "args": { "list_name": "by_author" } } } }, "speech": { - "model_name": "speech", "actions": { "index": { "type": "list", - "list": { + "args": { "list_name": "public_list" } }, "by_writing_format": { "type": "list", - "list": { + "args": { "list_name": "by_writing_format" } } } }, "balloon": { - "model_name": "balloon", "actions": { "index": { "type": "list", - "list": { + "args": { "list_name": "public_list" } } } }, "ground_picture": { - "model_name": "ground_picture", "actions": { "index": { "type": "list", - "list": { + "args": { "list_name": "public_list" } }, "by_panel": { "type": "list", - "list": { + "args": { "list_name": "by_panel" } }, "by_author": { "type": "list", - "list": { + "args": { "list_name": "by_author" } } } }, "ground_color": { - "model_name": "ground_color", "actions": { "index": { "type": "list", - "list": { + "args": { "list_name": "public_list" } }, "by_panel": { "type": "list", - "list": { + "args": { "list_name": "by_panel" } }, "by_author": { "type": "list", - "list": { + "args": { "list_name": "by_author" } } } }, "original_picture": { - "model_name": "original_picture", "actions": { "index": { "type": "list", - "list": { + "args": { "list_name": "private_list" } } @@ -459,208 +444,200 @@ }, "picture": {}, "resource_picture": { - "model_name": "resource_picture", "actions": { "index": { "type": "list", - "list": { + "args": { "list_name": "public_list" } }, "by_license": { "type": "list", - "list": { + "args": { "list_name": "by_license" } }, "by_artist": { "type": "list", - "list": { + "args": { "list_name": "by_artist" } } } }, "speech_balloon_template": { - "model_name": "speech_balloon_template", "actions": { "index": { "type": "list", - "list": { + "args": { "list_name": "public_list" } }, "speech_balloons": { "type": "list", - "list": { + "args": { "list_name": "speech_balloons" } }, "panels": { "type": "list", - "list": { + "args": { "list_name": "panels" } } } }, "writing_format": { - "model_name": "writing_format", "actions": { "index": { "type": "list", - "list": { + "args": { "list_name": "public_list" } }, "speeches": { "type": "list", - "list": { + "args": { "list_name": "speeches" } }, "by_system_picture": { "type": "list", - "list": { + "args": { "list_name": "by_system_picture" } } } }, "license_group": { - "model_name": "license_group", "actions": { "index": { "type": "list", - "list": { + "args": { "list_name": "public_list" } }, "licenses": { "type": "list", - "list": { + "args": { "list_name": "licenses" } } } }, "license": { - "model_name": "license", "actions": { "index": { "type": "list", - "list": { + "args": { "list_name": "public_list" } }, "resource_pictures": { "type": "list", - "list": { + "args": { "list_name": "resource_pictures" } }, "by_license_group": { "type": "list", - "list": { + "args": { "list_name": "by_license_group" } }, "by_system_picture": { "type": "list", - "list": { + "args": { "list_name": "by_system_picture" } } } }, "author": { - "model_name": "author", "actions": { "index": { "type": "list", - "list": { + "args": { "list_name": "public_list" } }, "scrolls": { "type": "list", - "list": { + "args": { "list_name": "scrolls" } }, "comics": { "type": "list", - "list": { + "args": { "list_name": "comics" } }, "stories": { "type": "list", - "list": { + "args": { "list_name": "stories" } }, "sheets": { "type": "list", - "list": { + "args": { "list_name": "sheets" } }, "panels": { "type": "list", - "list": { + "args": { "list_name": "panels" } }, "panel_pictures": { "type": "list", - "list": { + "args": { "list_name": "panel_pictures" } }, "speech_balloons": { "type": "list", - "list": { + "args": { "list_name": "speech_balloons" } }, "ground_pictures": { "type": "list", - "list": { + "args": { "list_name": "ground_pictures" } }, "ground_colors": { "type": "list", - "list": { + "args": { "list_name": "ground_colors" } } } }, "artist": { - "model_name": "artist", "actions": { "index": { "type": "list", - "list": { + "args": { "list_name": "public_list" } }, "resource_pictures": { "type": "list", - "list": { + "args": { "list_name": "resource_pictures" } } } }, "system_picture": { - "model_name": "system_picture", "actions": { "index": { "type": "list", - "list": { + "args": { "list_name": "public_list" } } @@ -671,112 +648,112 @@ "scrolls": { "item_name": "scroll", "type": "list", - "list": { + "args": { "list_name": "private_list" } }, "scroll_panels": { "item_name": "scroll_panel", "type": "list", - "list": { + "args": { "list_name": "private_list" } }, "comics": { "item_name": "comic", "type": "list", - "list": { + "args": { "list_name": "private_list" } }, "stories": { "item_name": "story", "type": "list", - "list": { + "args": { "list_name": "private_list" } }, "story_sheets": { "item_name": "story_sheet", "type": "list", - "list": { + "args": { "list_name": "private_list" } }, "sheets": { "item_name": "sheet", "type": "list", - "list": { + "args": { "list_name": "private_list" } }, "sheet_panels": { "item_name": "sheet_panel", "type": "list", - "list": { + "args": { "list_name": "private_list" } }, "panels": { "item_name": "panel", "type": "list", - "list": { + "args": { "list_name": "private_list" } }, "panel_pictures": { "item_name": "panel_picture", "type": "list", - "list": { + "args": { "list_name": "private_list" } }, "speech_balloons": { "item_name": "speech_balloon", "type": "list", - "list": { + "args": { "list_name": "private_list" } }, "speeches": { "item_name": "speech", "type": "list", - "list": { + "args": { "list_name": "private_list" } }, "balloons": { "item_name": "balloon", "type": "list", - "list": { + "args": { "list_name": "private_list" } }, "ground_pictures": { "item_name": "ground_picture", "type": "list", - "list": { + "args": { "list_name": "private_list" } }, "ground_colors": { "item_name": "ground_color", "type": "list", - "list": { + "args": { "list_name": "private_list" } }, "original_pictures": { "item_name": "original_picture", "type": "list", - "list": { + "args": { "list_name": "private_list" } }, "resource_pictures": { "item_name": "resource_picture", "type": "list", - "list": { + "args": { "list_name": "private_list" } } @@ -784,7 +761,6 @@ } }, "models": { - "Scroll": "scroll", "scroll": { "class_name": "Scroll", "table_name": "scrolls", @@ -848,9 +824,40 @@ "updated_at": { "type": "datetime" } + }, + "lists": { + "public_list": { + "type": "public" + }, + "private_list": { + "type": "private" + }, + "scroll_panels": { + "type": "has_many", + "association_name": "scroll_panels" + }, + "panels": { + "type": "has_many_through", + "association_name": "panels" + }, + "by_author": { + "type": "filter", + "from": "author", + "filter_key": "author_id" + }, + "by_panel": { + "type": "through_filter", + "from": "panel", + "through": "scroll_panels", + "filter_key": "panel_id" + }, + "play": { + "type": "play", + "model": "scroll_panel", + "filter_key": "scroll_id" + } } }, - "ScrollPanel": "scroll_panel", "scroll_panel": { "class_name": "ScrollPanel", "table_name": "scroll_panels", @@ -908,9 +915,26 @@ "updated_at": { "type": "datetime" } + }, + "lists": { + "public_list": { + "type": "public" + }, + "private_list": { + "type": "private" + }, + "by_scroll": { + "type": "filter", + "from": "scroll", + "filter_key": "scroll_id" + }, + "by_panel": { + "type": "filter", + "from": "panel", + "filter_key": "panel_id" + } } }, - "Comic": "comic", "comic": { "class_name": "Comic", "table_name": "comics", @@ -970,9 +994,25 @@ "updated_at": { "type": "datetime" } + }, + "lists": { + "public_list": { + "type": "public" + }, + "private_list": { + "type": "private" + }, + "stories": { + "type": "has_many", + "association_name": "stories" + }, + "by_author": { + "type": "filter", + "from": "author", + "filter_key": "author_id" + } } }, - "Story": "story", "story": { "class_name": "Story", "table_name": "stories", @@ -1041,9 +1081,45 @@ "updated_at": { "type": "datetime" } + }, + "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", + "from": "comic", + "filter_key": "comic_id" + }, + "by_sheet": { + "type": "through_filter", + "from": "sheet", + "through": "story_sheets", + "filter_key": "sheet_id" + }, + "by_author": { + "type": "element_filter", + "from": "author", + "filter_key": "author_id" + }, + "play": { + "type": "play", + "model": "story_sheet", + "filter_key": "story_id" + } } }, - "StorySheet": "story_sheet", "story_sheet": { "class_name": "StorySheet", "table_name": "story_sheets", @@ -1099,9 +1175,26 @@ "updated_at": { "type": "datetime" } + }, + "lists": { + "public_list": { + "type": "public" + }, + "private_list": { + "type": "private" + }, + "by_story": { + "type": "filter", + "from": "story", + "filter_key": "story_id" + }, + "by_sheet": { + "type": "filter", + "from": "sheet", + "filter_key": "sheet_id" + } } }, - "Sheet": "sheet", "sheet": { "class_name": "Sheet", "table_name": "sheets", @@ -1182,9 +1275,54 @@ "updated_at": { "type": "datetime" } + }, + "lists": { + "public_list": { + "type": "public" + }, + "private_list": { + "type": "private" + }, + "story_sheets": { + "type": "has_many", + "association_name": "story_sheets" + }, + "stories": { + "type": "has_many", + "association_name": "stories" + }, + "sheet_panels": { + "type": "has_many", + "association_name": "sheet_panels" + }, + "panels": { + "type": "has_many", + "association_name": "panels" + }, + "by_story": { + "type": "through_filter", + "from": "story", + "through": "story_sheets", + "filter_key": "story_id" + }, + "by_panel": { + "type": "through_filter", + "from": "panel", + "through": "sheet_panels", + "filter_key": "panel_id" + }, + "by_author": { + "type": "filter", + "from": "author", + "filter_key": "author_id" + }, + "play": { + "type": "play", + "model": "sheet_panel", + "filter_key": "sheet_id" + } } }, - "SheetPanel": "sheet_panel", "sheet_panel": { "class_name": "SheetPanel", "table_name": "sheet_panels", @@ -1261,9 +1399,27 @@ "updated_at": { "type": "datetime" } + }, + "lists": { + "public_list": { + "type": "public" + }, + "private_list": { + "type": "private" + }, + "by_sheet": { + "type": "filter", + "association_name": "sheet_panels", + "from": "sheet", + "filter_key": "sheet_id" + }, + "by_panel": { + "type": "filter", + "from": "panel", + "filter_key": "panel_id" + } } }, - "Panel": "panel", "panel": { "class_name": "Panel", "table_name": "panels", @@ -1370,9 +1526,71 @@ "updated_at": { "type": "datetime" } + }, + "lists": { + "public_list": { + "type": "public" + }, + "private_list": { + "type": "private" + }, + "scroll_panels": { + "type": "has_many", + "association_name": "scroll_panels" + }, + "scrolls": { + "type": "has_many", + "association_name": "scrolls" + }, + "sheet_panels": { + "type": "has_many", + "association_name": "sheet_panels" + }, + "sheets": { + "type": "has_many", + "association_name": "sheets" + }, + "panel_pictures": { + "type": "has_many", + "association_name": "panel_pictures" + }, + "speech_balloons": { + "type": "has_many", + "association_name": "speech_balloons" + }, + "ground_pictures": { + "type": "has_many", + "association_name": "ground_pictures" + }, + "ground_colors": { + "type": "has_many", + "association_name": "ground_colors" + }, + "by_scroll": { + "type": "through_filter", + "from": "scroll", + "through": "scroll_panels", + "filter_key": "scroll_id" + }, + "by_sheet": { + "type": "through_filter", + "from": "sheet", + "through": "sheet_panels", + "filter_key": "sheet_id" + }, + "by_author": { + "type": "filter", + "from": "author", + "filter_key": "author_id" + }, + "by_speech_balloon_template": { + "type": "through_filter", + "from": "speech_balloon_template", + "through": "speech_balloons", + "filter_key": "speech_balloon_template_id" + } } }, - "PanelPicture": "panel_picture", "panel_picture": { "class_name": "PanelPicture", "table_name": "panel_pictures", @@ -1465,9 +1683,26 @@ "updated_at": { "type": "datetime" } + }, + "lists": { + "public_list": { + "type": "public" + }, + "private_list": { + "type": "private" + }, + "by_panel": { + "type": "filter", + "from": "panel", + "filter_key": "panel_id" + }, + "by_author": { + "type": "element_filter", + "from": "author", + "filter_key": "author_id" + } } }, - "SpeechBalloon": "speech_balloon", "speech_balloon": { "class_name": "SpeechBalloon", "table_name": "speech_balloons", @@ -1547,9 +1782,31 @@ "updated_at": { "type": "datetime" } + }, + "lists": { + "public_list": { + "type": "public" + }, + "private_list": { + "type": "private" + }, + "by_panel": { + "type": "filter", + "from": "panel", + "filter_key": "panel_id" + }, + "by_speech_balloon_template": { + "type": "filter", + "from": "speech_balloon_template", + "filter_key": "speech_balloon_template_id" + }, + "by_author": { + "type": "element_filter", + "from": "author", + "filter_key": "author_id" + } } }, - "Balloon": "balloon", "balloon": { "class_name": "Balloon", "table_name": "balloons", @@ -1632,9 +1889,31 @@ "updated_at": { "type": "datetime" } + }, + "lists": { + "public_list": { + "type": "public" + }, + "private_list": { + "type": "private" + }, + "by_panel": { + "type": "filter", + "from": "panel", + "filter_key": "panel_id" + }, + "by_speech_balloon_template": { + "type": "filter", + "from": "speech_balloon_template", + "filter_key": "speech_balloon_template_id" + }, + "by_author": { + "type": "element_filter", + "from": "author", + "filter_key": "author_id" + } } }, - "Speech": "speech", "speech": { "class_name": "Speech", "table_name": "speeches", @@ -1760,9 +2039,28 @@ "updated_at": { "type": "datetime" } + }, + "lists": { + "public_list": { + "type": "public" + }, + "by_speech_balloon": { + "type": "filter", + "from": "speech_balloon", + "includes": { + "speech_balloon": { + "panel": {} + } + }, + "filter_key": "speech_balloon_id" + }, + "by_writing_format": { + "type": "filter", + "from": "writing_format", + "filter_key": "writing_format_id" + } } }, - "GroundPicture": "ground_picture", "ground_picture": { "class_name": "GroundPicture", "table_name": "ground_pictures", @@ -1850,9 +2148,26 @@ "updated_at": { "type": "datetime" } + }, + "lists": { + "public_list": { + "type": "public" + }, + "private_list": { + "type": "private" + }, + "by_panel": { + "type": "filter", + "from": "panel", + "filter_key": "panel_id" + }, + "by_author": { + "type": "element_filter", + "from": "author", + "filter_key": "author_id" + } } }, - "GroundColor": "ground_color", "ground_color": { "class_name": "GroundColor", "table_name": "ground_colors", @@ -1942,9 +2257,26 @@ "updated_at": { "type": "datetime" } + }, + "lists": { + "public_list": { + "type": "public" + }, + "private_list": { + "type": "private" + }, + "by_panel": { + "type": "filter", + "from": "panel", + "filter_key": "panel_id" + }, + "by_author": { + "type": "element_filter", + "from": "author", + "filter_key": "author_id" + } } }, - "OriginalPicture": "original_picture", "original_picture": { "class_name": "OriginalPicture", "table_name": "original_pictures", @@ -2030,9 +2362,13 @@ "updated_at": { "type": "datetime" } + }, + "lists": { + "private_list": { + "type": "private" + } } }, - "Picture": "picture", "picture": { "class_name": "Picture", "table_name": "pictures", @@ -2145,7 +2481,6 @@ } } }, - "ResourcePicture": "resource_picture", "resource_picture": { "class_name": "ResourcePicture", "table_name": "resource_pictures", @@ -2266,9 +2601,26 @@ "updated_at": { "type": "datetime" } + }, + "lists": { + "public_list": { + "type": "public" + }, + "private_list": { + "type": "private" + }, + "by_license": { + "type": "filter", + "from": "license", + "filter_key": "license_id" + }, + "by_artist": { + "type": "filter", + "from": "artist", + "filter_key": "artist_id" + } } }, - "SpeechBalloonTemplate": "speech_balloon_template", "speech_balloon_template": { "class_name": "SpeechBalloonTemplate", "table_name": "speech_balloon_templates", @@ -2344,9 +2696,24 @@ "updated_at": { "type": "datetime" } + }, + "lists": { + "public_list": { + "type": "public" + }, + "select_items": { + "type": "system_resource" + }, + "speech_balloons": { + "type": "has_many", + "association_name": "speech_balloons" + }, + "panels": { + "type": "has_many", + "association_name": "panels" + } } }, - "WritingFormat": "writing_format", "writing_format": { "class_name": "WritingFormat", "table_name": "writing_formats", @@ -2409,9 +2776,25 @@ "updated_at": { "type": "datetime" } + }, + "lists": { + "public_list": { + "type": "public" + }, + "select_items": { + "type": "system_resource" + }, + "speeches": { + "type": "has_many", + "association_name": "speeches" + }, + "by_system_picture": { + "type": "filter", + "from": "system_picture", + "filter_key": "system_picture_id" + } } }, - "LicenseGroup": "license_group", "license_group": { "class_name": "LicenseGroup", "table_name": "license_groups", @@ -2463,9 +2846,20 @@ "updated_at": { "type": "datetime" } + }, + "lists": { + "public_list": { + "type": "public" + }, + "select_items": { + "type": "system_resource" + }, + "licenses": { + "type": "has_many", + "association_name": "licenses" + } } }, - "License": "license", "license": { "class_name": "License", "table_name": "licenses", @@ -2539,9 +2933,27 @@ "updated_at": { "type": "datetime" } + }, + "lists": { + "public_list": { + "type": "public" + }, + "resource_pictures": { + "type": "has_many", + "association_name": "resource_pictures" + }, + "by_license_group": { + "type": "filter", + "from": "license_group", + "filter_key": "license_group_id" + }, + "by_system_picture": { + "type": "filter", + "from": "system_picture", + "filter_key": "system_picture_id" + } } }, - "Author": "author", "author": { "class_name": "Author", "table_name": "authors", @@ -2598,9 +3010,49 @@ "updated_at": { "type": "datetime" } + }, + "lists": { + "public_list": { + "type": "public" + }, + "scrolls": { + "type": "has_many", + "association_name": "scrolls" + }, + "comics": { + "type": "has_many", + "association_name": "comics" + }, + "stories": { + "type": "has_many", + "association_name": "stories" + }, + "sheets": { + "type": "has_many", + "association_name": "sheets" + }, + "panels": { + "type": "has_many", + "association_name": "panels" + }, + "panel_pictures": { + "type": "has_many", + "association_name": "panel_pictures" + }, + "speech_balloons": { + "type": "has_many", + "association_name": "speech_balloons" + }, + "ground_pictures": { + "type": "has_many", + "association_name": "ground_pictures" + }, + "ground_colors": { + "type": "has_many", + "association_name": "ground_colors" + } } }, - "Artist": "artist", "artist": { "class_name": "Artist", "table_name": "artists", @@ -2641,9 +3093,17 @@ "updated_at": { "type": "datetime" } + }, + "lists": { + "public_list": { + "type": "public" + }, + "resource_pictures": { + "type": "has_many", + "association_name": "resource_pictures" + } } }, - "SystemPicture": "system_picture", "system_picture": { "class_name": "SystemPicture", "table_name": "system_pictures", @@ -2712,13 +3172,16 @@ "updated_at": { "type": "datetime" } + }, + "lists": { + "public_list": { + "type": "public" + } } } }, "lists": { "scroll": { - "default_page_size": 25, - "max_page_size": 100, "lists": { "public_list": { "type": "public" -- 2.11.0