OSDN Git Service

merge
authoryasushiito <yas@pen-chan.jp>
Sun, 12 Jul 2015 09:59:26 +0000 (18:59 +0900)
committeryasushiito <yas@pen-chan.jp>
Sun, 12 Jul 2015 09:59:26 +0000 (18:59 +0900)
136 files changed:
Gemfile
app/assets/javascripts/admin.js
app/assets/javascripts/controllers.js.coffee
app/assets/javascripts/controllers/comics.js.coffee
app/assets/javascripts/controllers/sheets.js.coffee
app/assets/javascripts/controllers/stories.js.coffee
app/assets/javascripts/locmare/filer/body/file_body/file_item/symbol/default/face/picture.js.coffee
app/assets/javascripts/locmare/form/field/tag/select.js.coffee
app/assets/javascripts/locmare/profiler/association/has_many.js.coffee
app/assets/javascripts/locmare/profiler/association/has_one.js.coffee
app/assets/javascripts/manifest/controller/action/list.js.coffee
app/assets/javascripts/models/license.js.coffee
app/assets/javascripts/peta/item.js.coffee
app/assets/javascripts/pettanr/cache.js.coffee
app/assets/javascripts/pettanr/finder.js.coffee [new file with mode: 0644]
app/assets/javascripts/pettanr/remover.js.coffee [deleted file]
app/assets/javascripts/views/artists/show.js.coffee
app/assets/javascripts/views/authors/show.js.coffee
app/assets/javascripts/views/resource_picture_pictures/summary.js.coffee
app/assets/javascripts/views/sheets/play.js.coffee
app/assets/javascripts/views/stories/play.js.coffee
app/assets/javascripts/work/controllers.js.coffee.erb
app/assets/javascripts/yasapp.js
app/controllers/application_controller.rb
app/controllers/artists_controller.rb
app/controllers/authors_controller.rb
app/controllers/balloons_controller.rb
app/controllers/comic_stories_controller.rb
app/controllers/comics_controller.rb
app/controllers/concerns/.keep [new file with mode: 0644]
app/controllers/demander_statuses_controller.rb
app/controllers/demanders_controller.rb
app/controllers/folders_controller.rb
app/controllers/ground_colors_controller.rb
app/controllers/ground_pictures_controller.rb
app/controllers/home_controller.rb
app/controllers/license_groups_controller.rb
app/controllers/licenses_controller.rb
app/controllers/original_picture_license_groups_controller.rb
app/controllers/original_picture_licenses_controller.rb
app/controllers/original_pictures_controller.rb
app/controllers/panel_pictures_controller.rb
app/controllers/panels_controller.rb
app/controllers/pictures_controller.rb
app/controllers/provider_sources_controller.rb
app/controllers/provider_statuses_controller.rb
app/controllers/providers_controller.rb
app/controllers/resource_picture_pictures_controller.rb
app/controllers/resource_pictures_controller.rb
app/controllers/scroll_panels_controller.rb
app/controllers/scrolls_controller.rb
app/controllers/sheet_panels_controller.rb
app/controllers/sheets_controller.rb
app/controllers/speech_balloon_templates_controller.rb
app/controllers/speech_balloons_controller.rb
app/controllers/speeches_controller.rb
app/controllers/stories_controller.rb
app/controllers/story_sheets_controller.rb
app/controllers/system_controller.rb
app/controllers/system_pictures_controller.rb
app/controllers/top_controller.rb
app/controllers/user_sessions_controller.rb
app/controllers/writing_formats_controller.rb
app/models/admin.rb
app/models/artist.rb
app/models/author.rb
app/models/balloon.rb
app/models/comic.rb
app/models/comic_story.rb
app/models/concerns/.keep [new file with mode: 0644]
app/models/demand_user.rb
app/models/folder.rb
app/models/ground_color.rb
app/models/ground_picture.rb
app/models/license.rb
app/models/license_group.rb
app/models/original_picture.rb
app/models/panel.rb
app/models/panel_picture.rb
app/models/picture.rb
app/models/resource_picture.rb
app/models/resource_picture_picture.rb
app/models/scroll.rb
app/models/scroll_panel.rb
app/models/sheet.rb
app/models/sheet_panel.rb
app/models/speech.rb
app/models/speech_balloon.rb
app/models/speech_balloon_template.rb
app/models/story.rb
app/models/story_sheet.rb
app/models/system_picture.rb
app/models/user.rb
app/models/writing_format.rb
app/views/layouts/application.html.erb
app/views/layouts/system.html.erb
app/views/stories/play.html.erb
app/views/templates/r/filer/_filer.html.erb
bin/bundle [new file with mode: 0644]
bin/encode64.rb [moved from script/encode64.rb with 100% similarity]
bin/gem_builder.rb [moved from script/gem_builder.rb with 100% similarity]
bin/ls_helper.rb [moved from script/ls_helper.rb with 100% similarity]
bin/panel_import.rb [moved from script/panel_import.rb with 100% similarity]
bin/preup.rb [moved from script/preup.rb with 100% similarity]
bin/rails [new file with mode: 0644]
bin/rake [new file with mode: 0644]
bin/sbt_helper.rb [moved from script/sbt_helper.rb with 100% similarity]
bin/uploader.rb [moved from script/uploader.rb with 100% similarity]
config/application.rb
config/boot.rb
config/environments/development.rb
config/environments/production.rb
config/environments/test.rb
config/routes.rb
config/secrets.yml [new file with mode: 0644]
db/migrate/20120618023403_connect_story.rb
db/migrate/20130911043458_copy_to_scroll.rb
db/migrate/20131205030518_artist_belongs_to_user_data.rb
db/migrate/20140329222717_fix_extend_system_data.rb
db/migrate/20140409095030_fix_ext_sys_pict_data.rb
db/migrate/20150330234954_gen_resource_picture_pictures.rb
db/migrate/20150702232018_add_t_on_license_groups.rb [new file with mode: 0644]
lib/locmare/booster.rb
lib/locmare/list_group/lib/page_status.rb
lib/locmare/list_group/list/base.rb
lib/locmare/list_group/list/filter.rb
lib/manifest/controller/action/base.rb
lib/manifest/controller/action/list.rb
lib/peta/content.rb
lib/peta/item.rb
lib/peta/leaf.rb
lib/peta/system_resource.rb
lib/peta/template.rb
public/manifest.json
script/cucumber [deleted file]
script/rails [deleted file]

diff --git a/Gemfile b/Gemfile
index 8951587..35c1225 100644 (file)
--- a/Gemfile
+++ b/Gemfile
@@ -1,8 +1,8 @@
 source 'https://rubygems.org'
 
-gem 'rails', '~> 3.2.0'
+gem 'rails', '~> 4.1.0'
 gem 'devise'
-# gem 'devise_token_auth'
+gem 'omniauth'
 gem 'rest-client'
 gem 'underscore-rails'
 # gem 'backbone-rails'
@@ -10,7 +10,8 @@ gem 'rails-timeago'
 gem 'kaminari'
 gem 'sanitize'
 gem 'aws-s3'
-gem 'awesome_nested_set', '~> 2.0'
+gem 'aws-sdk', '< 2.0'
+gem 'awesome_nested_set', '~> 3.0'
 gem 'validates_existence'
 gem "validate_url"
 gem "pettanr_creative_commons_v30_licenses"
@@ -28,13 +29,14 @@ gem 'pettanr_simple_format'
 # Bundle edge Rails instead:
 # gem 'rails',     :git => 'git://github.com/rails/rails.git'
 gem 'i18n-js'
+gem 'nokogiri'
 
 # Gems used only for assets and not required
 # in production environments by default.
 group :assets do
-  gem 'sass-rails',   '~> 3.0'
-  gem 'coffee-rails', '~> 3.0'
-  gem 'uglifier', '>= 1.0.3'
+  gem 'sass-rails',   '~> 4.0'
+  gem 'coffee-rails', '~> 4.0'
+  gem 'uglifier', '>= 1.3.0'
   # http://qiita.com/scivola/items/ec7625118fcf6de5203a
   gem 'coffee-script-source', '~> 1.8.0'
 end
@@ -87,3 +89,4 @@ group :test do
   gem 'factory_girl'
 end
 
+gem 'tzinfo-data'
index c5cb978..3e643e8 100644 (file)
@@ -4,5 +4,6 @@
 // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
 // the compiled file.
 //
+//= require jquery
 //= require_directory ./work
 //= require system
index f9c9fb5..4dd2ab2 100644 (file)
@@ -18,11 +18,7 @@ class Pettanr.AppController
     \r
   set_list: () ->\r
     @set_model()\r
-    @my_list_model = Manifest.manifest().models[@my_action.item_name]\r
-    @my_list_model_class = @my_list_model.classify()\r
-    @list = Locmare.ListGroup.list(\r
-      @my_action.path_name(), @my_action.name, @params\r
-    )\r
+    @list = @my_action.find(@params)\r
   \r
   set_show: (render_func) ->\r
     @set_model()\r
@@ -40,11 +36,7 @@ class Pettanr.AppController
   \r
   set_play: (render_func) ->\r
     @set_list()\r
-    @binder_action = @my_action.original\r
-    @binder_controller = @binder_action.controller()\r
-    @binder_model = Manifest.manifest().models[@binder_action.item_name]\r
-    @binder_model_class = @binder_model.classify()\r
-    @binder_model_class.retrieve(@params['id'], this, {success: render_func})\r
+    @my_model_class.retrieve(@params['id'], this, {success: render_func})\r
   \r
   show_prof: () ->\r
     @item.boosts 'post'\r
index 70f8371..7b19554 100644 (file)
@@ -45,7 +45,7 @@ class Pettanr.ComicsController extends Pettanr.AppController
         @trigger('title', @params, @item.get('title'))\r
         show = new Pettanr.Views.Comic.Play({\r
           item: @item,\r
-          list: items,\r
+          list: @list,\r
         })\r
         show.render()\r
         @trigger('ready', show)\r
index 542d0ae..19b3249 100644 (file)
@@ -48,7 +48,7 @@ class Pettanr.SheetsController extends Pettanr.AppController
         @trigger('title', @params, @item.get('caption'))\r
         show = new Pettanr.Views.Sheet.Play({\r
           item: @item,\r
-          list: items,\r
+          list: @list,\r
         })\r
         show.render()\r
         @trigger('ready', show)\r
index 9e90f63..c573900 100644 (file)
@@ -50,7 +50,7 @@ class Pettanr.StoriesController extends Pettanr.AppController
         @trigger('title', @params, @item.get('title'))\r
         show = new Pettanr.Views.Story.Play({\r
           item: @item,\r
-          list: items,\r
+          list: @list,\r
         })\r
         show.render()\r
         @trigger('ready', show)\r
index 4f98f98..ac07a01 100644 (file)
@@ -55,7 +55,9 @@ class Locmare.FormModule.FieldModule.TagModule.SelectTag extends Locmare.FormMod
         {id: filter_id}\r
       else\r
         {}\r
-      list = Locmare.ListGroup.list(resource_controller_name, resource_action_name, params)\r
+      controller = Manifest.manifest().controllers[resource_controller_name]\r
+      action = controller.actions[resource_action_name]\r
+      list = action.find(params)\r
       list.open(this, {\r
         success: (page_status) ->\r
           members = _.map list.models, (member) ->\r
index fd953c4..6d5af92 100644 (file)
@@ -7,10 +7,7 @@ class Locmare.ProfilerModule.AssociationModule.HasMany extends Pettanr.View
     @filer = null\r
     controller = Manifest.manifest().controllers[@has_many_manifest.controller_name]\r
     action = controller.actions[@has_many_manifest.action_name]\r
-    @list = Locmare.ListGroup.list(\r
-      action.path_name(), action.name, \r
-      {id: @item().get('id'), page: 1, page_size: 3}\r
-    )\r
+    @list = action.find({id: @item().get('id'), page: 1, page_size: 3})\r
     @pager = new Locmare.ListGroupModule.LibModule.PagerModule.More({\r
       params: {controller: action.path_name(), action: action.name, id: @item().get('id')}\r
     })\r
index d1bb3d0..e9e5790 100644 (file)
@@ -7,10 +7,7 @@ class Locmare.ProfilerModule.AssociationModule.HasOne extends Pettanr.View
     @filer = null\r
     controller = Manifest.manifest().controllers[@has_one_manifest.controller_name]\r
     action = controller.actions[@has_one_manifest.action_name]\r
-    @list = Locmare.ListGroup.list(\r
-      action.path_name(), action.name, \r
-      {id: @item().get('id')}\r
-    )\r
+    @list = action.find({id: @item().get('id')})\r
   \r
   clear: () ->\r
     this.$el.html('')\r
index c3a9dcf..766311a 100644 (file)
@@ -12,7 +12,11 @@ class Manifest.ControllerModule.ActionModule.ActionList extends Manifest.Control
     @direction = @args.direction\r
     @default_page_size = @args.default_page_size\r
     @max_page_size = @args.max_page_size\r
+    @return_item_name = @args.return_item_name || @item_name\r
   \r
   a_arg_names: () ->\r
     _.union(super(), ['order', 'direction', 'default_page_size', 'max_page_size'])\r
   \r
+  find: (params = {}) ->\r
+    new Pettanr.Finder(this, params)\r
+  \r
index 9b064ed..44998c1 100644 (file)
@@ -15,11 +15,11 @@ class Pettanr.License extends Peta.SystemResource
       symbol: ['system_picture']\r
     }\r
   \r
-  caption_with_group: () ->\r
+  caption_with_group: (context, options) ->\r
     @get_parent('license_group', this, {\r
       success: (license_group) => \r
         caption = license_group.escape('caption') + '/' + @escape('caption')\r
-        @trigger('ready:caption', caption)\r
+        options.success.call(context, caption)\r
     })\r
   \r
   is_own: () ->\r
index d8c8031..77d01cc 100644 (file)
@@ -135,55 +135,37 @@ class Peta.Item extends Backbone.Model
     ''\r
   \r
   get_association: (routes, context, options) ->\r
-    console.log 'get_association'\r
     routes = [routes] if _.isString(routes)\r
-    console.log routes\r
     route = routes.shift()\r
     if _.isEmpty(routes)\r
       # fetching terminate association. callback\r
-      console.log 'fetching terminate association'\r
       cxt = options.context || context\r
       @fetch_association(route, cxt, {\r
         success: (association_item, options) =>\r
-          console.log 'success'\r
-          console.log association_item\r
-          console.log options\r
           options.success.call(context, association_item)\r
         context: context,\r
         options: options\r
       })\r
     else\r
       # fetching through associations\r
-      console.log 'fetching through associations'\r
       @fetch_association(route, this, {\r
         success: (association_item, options) =>\r
-          console.log 'success'\r
-          console.log association_item\r
-          console.log options\r
           association_item.get_association(routes, this, options)\r
         context: context,\r
         options: options\r
       })\r
   \r
   fetch_association: (name, context, options) =>\r
-    console.log context\r
-    console.log options\r
     a = @my_class().my_manifest().associations\r
     fetch_options = {\r
       success: (association_item) =>\r
         options.success.call(context, association_item, options.options)\r
     }\r
     if a.belongs_to[name]\r
-      console.log 'belongs_to'\r
-      console.log name\r
       @get_parent(name, context, fetch_options)\r
     else if a.has_many[name]\r
-      console.log 'has_many'\r
-      console.log name\r
       @get_children(name, context, fetch_options)\r
     else if a.has_one[name]\r
-      console.log 'has_one'\r
-      console.log name\r
       @get_child(name, context, fetch_options)\r
     else\r
       console.error('association does not exist in model manifest')\r
index 7dd14af..b2ebb3f 100644 (file)
@@ -20,7 +20,7 @@ class Pettanr.Cache
         cached_item  # merge?\r
       else\r
         @data[item.cache_key()] = item\r
-      @refresh(return_items)\r
+      @refresh(return_items)\r
     return_items\r
   \r
   restore: (key) ->\r
diff --git a/app/assets/javascripts/pettanr/finder.js.coffee b/app/assets/javascripts/pettanr/finder.js.coffee
new file mode 100644 (file)
index 0000000..f54ca3e
--- /dev/null
@@ -0,0 +1,32 @@
+class Pettanr.Finder extends Backbone.Collection\r
+  \r
+  initialize: (@action_manifest, @params) ->\r
+    @return_model = Manifest.item_name_to_model @action_manifest.return_item_name\r
+  \r
+  parse: (res) ->\r
+    @page_status = res.page_status\r
+    res.list\r
+  \r
+  items: () ->\r
+    _.map @models, (model) =>\r
+      item = new @return_model(model.attributes)\r
+      Pettanr.cache.store(item)\r
+  \r
+  open: (context, options) ->\r
+    @url = '/' + @action_manifest.url(@params)\r
+    @fetch().done =>\r
+      # @boost(items)\r
+      options.success.call(context, @items())\r
+  \r
+  to_filer: (context, options) ->\r
+    @open(context, {\r
+      success: (items) => \r
+        pager = Locmare.ListGroupModule.LibModule.Pager.factory(@page_status, @params)\r
+        filer = new Locmare.Filer({\r
+          item_name: @action_manifest.return_item_name, \r
+          items: items, \r
+          pager: pager\r
+        })\r
+        options.success.call(context, filer)\r
+    })\r
+  \r
diff --git a/app/assets/javascripts/pettanr/remover.js.coffee b/app/assets/javascripts/pettanr/remover.js.coffee
deleted file mode 100644 (file)
index 663af13..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-class Pettanr.Remover\r
-  \r
-  constructor: (options) ->\r
-    _.extend(this, Backbone.Events)\r
-    @item = options.item\r
-  \r
index ed65650..00561e1 100644 (file)
@@ -15,17 +15,12 @@ class Pettanr.Views.Artist.ShowModule.ResourcePictures extends Pettanr.View
       controller: 'resource_pictures', action: 'by_artist', id: @item.get('id'),\r
       page_size: 5\r
     }\r
-    @list = Locmare.ListGroup.list(\r
-      params['controller'], params['action'], params\r
-    )\r
-    @list.open(this, {\r
-      success: (items) => \r
+    controller = Manifest.manifest().controllers[params['controller']]\r
+    action = controller.actions[params['action']]\r
+    @list = action.find(params)\r
+    @list.to_filer(this, {\r
+      success: (filer) => \r
         pager = Locmare.ListGroupModule.LibModule.Pager.factory(@list.page_status, params)\r
-        filer = new Locmare.Filer({\r
-          item_name: @list.item_name, \r
-          items: items, \r
-          pager: pager\r
-        })\r
         @listenTo(filer, 'http_get', @http_get)\r
         this.$el.append(filer.render().el)\r
     })\r
index b88468d..8dbe721 100644 (file)
@@ -15,17 +15,12 @@ class Pettanr.Views.Author.ShowModule.Scrolls extends Pettanr.View
       controller: 'scrolls', action: 'by_author', id: @item.get('id'),\r
       page_size: 5\r
     }\r
-    @list = Locmare.ListGroup.list(\r
-      params['controller'], params['action'], params\r
-    )\r
-    @list.open(this, {\r
-      success: (items) => \r
+    controller = Manifest.manifest().controllers[params['controller']]\r
+    action = controller.actions[params['action']]\r
+    @list = action.find(params)\r
+    @list.to_filer(this, {\r
+      success: (filer) => \r
         pager = Locmare.ListGroupModule.LibModule.Pager.factory(@list.page_status, params)\r
-        filer = new Locmare.Filer({\r
-          item_name: @list.item_name, \r
-          items: items, \r
-          pager: pager\r
-        })\r
         @listenTo(filer, 'http_get', @http_get)\r
         this.$el.append(filer.render().el)\r
     })\r
index e0b1482..ca38b7f 100644 (file)
@@ -6,10 +6,11 @@ class Pettanr.Views.ResourcePicturePicture.Summary extends Pettanr.Views.Common.
     @load()\r
   \r
   load: () ->\r
-    @picture = @item.picture()\r
-    @picture.fetch({cache: true}).done =>\r
-      @credit = @picture.credit_view(false)\r
-      @trigger('ready')\r
+    @item.get_parent('picture', this, {\r
+      success: (@picture) =>\r
+        @credit = @picture.credit_view(false)\r
+        @trigger('ready')\r
+    })\r
   \r
   render: () ->\r
     this.$el.html('')\r
index 3260540..a415763 100644 (file)
@@ -106,7 +106,7 @@ class Pettanr.Views.Sheet.PlayModule.Body extends Pettanr.View
   render: () ->\r
     this.$el.html('')\r
     # paginate(@pager)\r
-    credits = new Pettanr.Views.Sheet.PlayModule.Credits({parent: this})\r
+    credits = new Pettanr.Views.Common.Credits({parent: this})\r
     panels = new Pettanr.Views.Sheet.PlayModule.Panels({\r
       parent: this,\r
       items: @items,\r
index d1b32f3..04be484 100644 (file)
@@ -51,11 +51,14 @@ class Pettanr.Views.Story.PlayModule.Sheet extends Pettanr.View
   \r
   render: () ->\r
     this.$el.html('')\r
-    body = new Pettanr.Views.Sheet.PlayModule.Body({\r
-      parent: this,\r
-      list: [], # list of sheets/by_story/1\r
+    @sheet.get_children('panel', this, {\r
+      success: (panels) => \r
+        body = new Pettanr.Views.Sheet.PlayModule.Body({\r
+          parent: this,\r
+          list: [], # list of sheets/by_story/1\r
+        })\r
+        this.$el.append(body.render().el)\r
     })\r
-    this.$el.append(body.render().el)\r
     this\r
   \r
 class Pettanr.Views.Story.PlayModule.Sheets extends Pettanr.View\r
index 6057f46..3024b42 100644 (file)
@@ -51,7 +51,7 @@
       play: {\r
         type: 'list',\r
         args: {\r
-          alias: 'scroll_panels.by_scroll',\r
+          return_item_name: 'scroll_panel',\r
           order: 't',\r
           direction: 1\r
         },\r
       play: {\r
         type: 'list',\r
         args: {\r
-          alias: 'comic_stories.by_comic',\r
+          return_item_name: 'comic_story',\r
           max_page_size: -1,\r
           order: 't',\r
           direction: 1\r
       play: {\r
         type: 'list',\r
         args: {\r
-          alias: 'story_sheets.by_story',\r
+          return_item_name: 'story_sheet',\r
           max_page_size: -1,\r
           order: 't',\r
           direction: 1\r
       play: {\r
         type: 'list',\r
         args: {\r
-          alias: 'sheet_panels.by_sheet',\r
+          return_item_name: 'sheet_panel',\r
           order: 't',\r
           direction: 1\r
         },\r
       scrolls: {\r
         type: 'list',\r
         args: {\r
-          alias: 'scrolls.index',\r
+          item_name: 'scroll',\r
         },\r
       },\r
       scroll_panels: {\r
         type: 'list',\r
         args: {\r
-          alias: 'scroll_panels.index',\r
+          item_name: 'scroll_panel',\r
         },\r
       },\r
       comics: {\r
         type: 'list',\r
         args: {\r
-          alias: 'comics.index',\r
+          item_name: 'comic',\r
         },\r
       },\r
       comic_stories: {\r
         type: 'list',\r
         args: {\r
-          alias: 'comic_stories.index',\r
+          item_name: 'comic_story',\r
         },\r
       },\r
       stories: {\r
         type: 'list',\r
         args: {\r
-          alias: 'stories.index',\r
+           item_name: 'story',\r
         },\r
       },\r
       story_sheets: {\r
         type: 'list',\r
         args: {\r
-          alias: 'story_sheets.index',\r
+          item_name: 'story_sheet',\r
         },\r
       },\r
       sheets: {\r
         type: 'list',\r
         args: {\r
-          alias: 'sheets.index',\r
+          item_name: 'sheet',\r
         },\r
       },\r
       sheet_panels: {\r
         type: 'list',\r
         args: {\r
-          alias: 'sheet_panels.index',\r
+          item_name: 'sheet_panel',\r
         },\r
       },\r
       panels: {\r
         type: 'list',\r
         args: {\r
-          alias: 'panels.index',\r
+          item_name: 'panel',\r
         },\r
       },\r
       panel_pictures: {\r
         type: 'list',\r
         args: {\r
-          alias: 'panel_pictures.index',\r
+          item_name: 'panel_picture',\r
         },\r
       },\r
       speech_balloons: {\r
         type: 'list',\r
         args: {\r
-          alias: 'speech_balloons.index',\r
+          item_name: 'speech_balloon',\r
         },\r
       },\r
       speeches: {\r
         type: 'list',\r
         args: {\r
-          alias: 'speeches.index',\r
+          item_name: 'speech',\r
         },\r
       },\r
       balloons: {\r
         type: 'list',\r
         args: {\r
-          alias: 'balloons.index',\r
+          item_name: 'balloon',\r
         },\r
       },\r
       ground_pictures: {\r
         type: 'list',\r
         args: {\r
-          alias: 'ground_pictures.index',\r
+          item_name: 'ground_picture',\r
         },\r
       },\r
       ground_colors: {\r
         type: 'list',\r
         args: {\r
-          alias: 'ground_colors.index',\r
+          item_name: 'ground_color',\r
         },\r
       },\r
       original_pictures: {\r
         type: 'list',\r
         args: {\r
-          alias: 'original_pictures.index',\r
+          item_name: 'original_picture',\r
         },\r
       },\r
       resource_pictures: {\r
         type: 'list',\r
         args: {\r
-          alias: 'resource_pictures.index',\r
+          item_name: 'resource_picture',\r
         },\r
       },\r
     },\r
index 770983d..7aa6446 100644 (file)
 //= require ./pettanr/proxy
 //= require ./pettanr/cache
 //= require ./pettanr/inspire
+//= require ./pettanr/finder
 //= require ./backbone.fetch-cache
 //= require main
index 9072fb3..634b9c3 100644 (file)
@@ -1,7 +1,9 @@
 class ApplicationController < ActionController::Base
   protect_from_forgery
+  protect_from_forgery with: :null_session, if: Proc.new {|c| c.request.format == 'application/json'}
   layout :devise_layout
-  before_filter :bf
+  before_action :bf
+  before_action :authenticate_user_from_token!, if: -> {params[:email].present?}
   
   def devise_layout
     if devise_controller?
@@ -51,6 +53,14 @@ class ApplicationController < ActionController::Base
     @operators = Operator.new [user, author, artist, admin, demand_user]
   end
   
+  def authenticate_user_from_token!
+    user = User.find_by(email: params[:email])
+    if Devise.secure_compare(user.try(:authentication_token), params[:auth_token])
+      sign_in user, store: false
+      self.bf
+    end
+  end
+  
   def authenticate_reader
     authenticate_user! unless @operators.reader?
   end
@@ -110,24 +120,26 @@ class ApplicationController < ActionController::Base
     @my_model_class = @my_model.classify
   end
   
-  def set_list
+  def set_list options = {}
     set_model
-    @my_list_model = Manifest.manifest.models[@my_action.item_name]
-    @my_list_model_class = @my_list_model.classify
-    @list = Locmare::ListGroup.list @my_action.controller.name, @my_action.action_name, @operators, params
+    # params merge to options
+    options[:page] ||= params[:page]
+    options[:page_size] ||= params[:page_size]
+    options[:order] ||= params[:order]
+    options[:direction] ||= params[:direction]
+    @finder = @my_action.find options
   end
   
-  def filer_list
-    set_list
-    @items = @list.items 
+  def filer_list options = {}
+    set_list options
     respond_to do |format|
       format.html {
-        @filer = Locmare::Filer.new @list.item_name, @items, @list.page_status, @operators
+        @filer = Locmare::Filer.new @my_action.return_item_name, @finder, @finder, @operators
         render @filer.template_name, :locals => {
           :filer => @filer
         }
       }
-      list_json_format @list, format
+      list_json_format @finder, format
       format.atom 
       format.rss
     end
@@ -136,31 +148,37 @@ class ApplicationController < ActionController::Base
   def list_json_format list, format
     format.json {
       res = {
-        :page_status => list.page_status.to_hash,
+        :page_status => {
+          :type => :default, :total => @finder.total_count, :total_page => @finder.total_pages, 
+          :page => @finder.page, :page_size => @finder.limit_value, 
+          :item_name => @my_action.return_item_name
+        },
         # rails3.2 has problem
         # y method defined as private
         # attribute y conflict at PanelPicture, balloon ..etc
         # use i.attributes[name]
-        :list => list.items.map{|i| i.attributes}
-        # :list => @items.to_json
+        :list => list.map{|i| i.attributes}
+        # :list => @finder.to_json
       }
       render json:  res.to_json
     }
   end
   
   def set_play
-    set_list
-    @binder_action = @my_action.original
-    @binder_controller = @binder_action.controller
-    @binder_model = Manifest.manifest.models[@binder_action.item_name]
-    @binder_model_class = @binder_model.classify
-    @item = @binder_model_class.show(params[:id], @operators)
+    set_model
+    @item = @my_model_class.show(params[:id], @operators)
+    options = if @item.own?(@operators)
+      {finder: :find_private_play, param: [params[:id], @operators]}
+    else
+      {finder: :find_play, param: params[:id]}
+    end
+    set_list options
   end
   
   def play_list
-    @items = @list.items #.map {|sp| sp.root }
-    @count = @list.total
-    @pager = @list.page_status.pager
+    @items = @finder #.map {|sp| sp.root }
+    @count = @finder.total_count
+    @pager = @finder
   end
   
   def set_show
@@ -430,9 +448,13 @@ class ApplicationController < ActionController::Base
     }
   end
   
-  def assist_items controller_name, action_name
-    list = Locmare::ListGroup.list controller_name, action_name, @operators, {:id => @item.id, :page => 1, :page_size => 5}
-    list.items
+  def assist_items controller_name, action_name, options = {}
+    controller = Manifest.manifest.controllers[controller_name]
+    action = controller.actions[action_name]
+    options[:page] = 1
+    options[:page_size] = 5
+    finder = action.find options
+    finder
   end
   
   def set_image(file)
index e5e582d..4e7f961 100644 (file)
@@ -1,13 +1,13 @@
 class ArtistsController < ApplicationController
   if Manifest.manifest.magic_numbers['run_mode'] == 0
-    before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
-    before_filter :authenticate_artist, :only => [:edit, :update, :destroy]
+    before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
+    before_action :authenticate_artist, :only => [:edit, :update, :destroy]
   else
-    before_filter :authenticate_resource_reader, :only => [
+    before_action :authenticate_resource_reader, :only => [
       :index, :show
     ]
-    before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
-    before_filter :authenticate_artist, :only => [:edit, :update, :destroy]
+    before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
+    before_action :authenticate_artist, :only => [:edit, :update, :destroy]
   end
   
   def index
@@ -40,14 +40,14 @@ class ArtistsController < ApplicationController
     set_model
     @item = @my_model_class.new
     @item.supply_default 
-    @item.attributes = params[@my_model_class.item_name]
+    @item.attributes = @item.permit_params params
     @item.overwrite @operators
     render_create root_path
   end
   
   def update
     set_edit
-    @item.attributes = params[@my_model_class.item_name]
+    @item.attributes = @item.permit_params params
     @item.overwrite @operators
     render_update '/home/configure'
   end
index 2b01c91..320d74e 100644 (file)
@@ -1,11 +1,11 @@
 class AuthorsController < ApplicationController
   if Manifest.manifest.magic_numbers['run_mode'] == 0
-    before_filter :authenticate_user, :only => [:new, :create, :edit, :update]
-    before_filter :authenticate_author, :only => [:edit, :update]
+    before_action :authenticate_user, :only => [:new, :create, :edit, :update]
+    before_action :authenticate_author, :only => [:edit, :update]
   else
-    before_filter :authenticate_reader, :only => [:index, :show]
-    before_filter :authenticate_user, :only => [:new, :create, :edit, :update]
-    before_filter :authenticate_author, :only => [:edit, :update]
+    before_action :authenticate_reader, :only => [:index, :show]
+    before_action :authenticate_user, :only => [:new, :create, :edit, :update]
+    before_action :authenticate_author, :only => [:edit, :update]
   end
 
   def index
@@ -38,14 +38,14 @@ class AuthorsController < ApplicationController
     set_model
     @item = @my_model_class.new
     @item.supply_default 
-    @item.attributes = params[@my_model_class.item_name]
+    @item.attributes = @item.permit_params params
     @item.overwrite @operators
     render_create root_path
   end
   
   def update
     set_edit
-    @item.attributes = params[@my_model_class.item_name]
+    @item.attributes = @item.permit_params params
     @item.overwrite @operators
     render_update '/home/configure'
   end
index f9079cc..3e97f89 100644 (file)
@@ -1,14 +1,14 @@
 class BalloonsController < ApplicationController
   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]
+    before_action :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
+    before_action :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
   else
-    before_filter :authenticate_reader, :only => [
+    before_action :authenticate_reader, :only => [
       :index, :show, 
       :by_author, :by_speech_balloon, :by_speech_balloon_template, :by_system_picture
     ]
-    before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
-    before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
+    before_action :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
+    before_action :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
   end
   
   def index
@@ -16,19 +16,19 @@ class BalloonsController < ApplicationController
   end
   
   def by_author
-    filer_list
+    filer_list param: params[:id]
   end
   
   def by_speech_balloon
-    filer_list
+    filer_list param: params[:id]
   end
   
   def by_speech_balloon_template
-    filer_list
+    filer_list param: params[:id]
   end
   
   def by_system_picture
-    filer_list
+    filer_list param: params[:id]
   end
   
   def show_html_format format
index 120935b..449dd21 100644 (file)
@@ -1,13 +1,13 @@
 class ComicStoriesController < ApplicationController
   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]
+    before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
+    before_action :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
   else
-    before_filter :authenticate_reader, :only => [
+    before_action :authenticate_reader, :only => [
       :index, :show, :by_story, :by_comic, :by_author
     ]
-    before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
-    before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
+    before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
+    before_action :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
   end
   
   def index
@@ -15,15 +15,15 @@ class ComicStoriesController < ApplicationController
   end
   
   def by_story
-    filer_list
+    filer_list param: params[:id]
   end
   
   def by_comic
-    filer_list
+    filer_list param: params[:id]
   end
   
   def by_author
-    filer_list
+    filer_list param: params[:id]
   end
   
   def show
@@ -50,7 +50,7 @@ class ComicStoriesController < ApplicationController
     set_model
     @item = @my_model_class.new
     @item.supply_default
-    @item.attributes = params[@item.item_name]
+    @item.attributes = @item.permit_params params
     @item.overwrite @operators
     @binder = @my_model_class.binder_model.edit(@item.binder_id, @operators) if @item.binder_id
     @panel = @my_model_class.destination_model.show(@item.destination_id, @operators) if @item.destination_id
@@ -62,7 +62,7 @@ class ComicStoriesController < ApplicationController
     set_model
     @item = @my_model_class.edit(params[:id], @operators)
     ot = @item.t
-    @item.attributes = params[@item.item_name]
+    @item.attributes = @item.permit_params params
     @item.overwrite @operators
     @binder = @my_model_class.binder_model.edit(@item.binder_id, @operators) if @item.binder_id
     # no check permission for destination
index 838d7d8..73851fc 100644 (file)
@@ -1,13 +1,13 @@
 class ComicsController < ApplicationController
   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]
+    before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
+    before_action :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
   else
-    before_filter :authenticate_reader, :only => [
+    before_action :authenticate_reader, :only => [
       :index, :show, :play, :by_story, :by_author
     ]
-    before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
-    before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
+    before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
+    before_action :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
   end
   
   def index
@@ -15,11 +15,11 @@ class ComicsController < ApplicationController
   end
   
   def by_story
-    filer_list
+    filer_list param: params[:id]
   end
   
   def by_author
-    filer_list
+    filer_list param: params[:id]
   end
   
   def show_html_format format
@@ -44,16 +44,15 @@ class ComicsController < ApplicationController
   
   def play
     set_play
-    @list.options.merge!({'page_size' => -1})    # no limit no pager
-    @list.reset
+    @finder.per(-1)    # no limit no pager
     play_list
     respond_to do |format|
       format.html {
         if @item.own? @operators
-          @new_story_items = assist_items('home', 'stories')
+          @new_story_items = assist_items('home', 'stories', finder: :find_private, param: @operators)
         end
       }
-      list_json_format @list, format
+      list_json_format @finder, format
     end
   end
   
@@ -70,7 +69,7 @@ class ComicsController < ApplicationController
     @item = @my_model_class.new
     @item.supply_default 
     @my_model_class.fold_extend_settings params[@my_model_class.item_name]
-    @item.attributes = params[@my_model_class.item_name]
+    @item.attributes = @item.permit_params params
     @item.overwrite @operators
     render_create
   end
@@ -78,7 +77,7 @@ class ComicsController < ApplicationController
   def update
     set_edit
     @my_model_class.fold_extend_settings params[@my_model_class.item_name]
-    @item.attributes = params[@my_model_class.item_name]
+    @item.attributes = @item.permit_params params
     @item.overwrite @operators
     render_update
   end
diff --git a/app/controllers/concerns/.keep b/app/controllers/concerns/.keep
new file mode 100644 (file)
index 0000000..e69de29
index 32318ac..1d947e0 100644 (file)
@@ -1,5 +1,5 @@
 class DemanderStatusesController < ApplicationController
-  before_filter :authenticate_admin!, :only => [:index, :show, :edit, :update, :destroy]
+  before_action :authenticate_admin!, :only => [:index, :show, :edit, :update, :destroy]
 
   def index
     @page = DemanderStatus.page params[:page]
index 92d4eea..ac54721 100644 (file)
@@ -1,5 +1,5 @@
 class DemandersController < ApplicationController
-  before_filter :authenticate_demand_user!, :only => [:index, :show, :new, :create, :edit, :update, :destroy, :req, :licenses_export, :artists_export, :original_pictures_export, :pictures_export, :export]
+  before_action :authenticate_demand_user!, :only => [:index, :show, :new, :create, :edit, :update, :destroy, :req, :licenses_export, :artists_export, :original_pictures_export, :pictures_export, :export]
   
   def index
     @demander = @demand_user.demander
index f535d7a..73623fa 100644 (file)
@@ -1,9 +1,9 @@
 class FoldersController < ApplicationController
   if Manifest.manifest.magic_numbers['run_mode'] == 0
-    before_filter :authenticate_admin, :only => [:new, :create, :edit, :update, :destroy]
+    before_action :authenticate_admin, :only => [:new, :create, :edit, :update, :destroy]
   else
-    before_filter :authenticate_reader, :only => [:root, :index, :show, :watch]
-    before_filter :authenticate_admin, :only => [:new, :create, :edit, :update, :destroy]
+    before_action :authenticate_reader, :only => [:root, :index, :show, :watch]
+    before_action :authenticate_admin, :only => [:new, :create, :edit, :update, :destroy]
   end
   
   def root
index 0f031f9..c9be0d3 100644 (file)
@@ -1,13 +1,13 @@
 class GroundColorsController < ApplicationController
   if Manifest.manifest.magic_numbers['run_mode'] == 0
-    before_filter :authenticate_user, :only => []
-    before_filter :authenticate_author, :only => []
+    before_action :authenticate_user, :only => []
+    before_action :authenticate_author, :only => []
   else
-    before_filter :authenticate_reader, :only => [
+    before_action :authenticate_reader, :only => [
       :index, :show, :by_panel, :by_author
     ]
-    before_filter :authenticate_user, :only => []
-    before_filter :authenticate_author, :only => []
+    before_action :authenticate_user, :only => []
+    before_action :authenticate_author, :only => []
   end
   
   def index
@@ -15,11 +15,11 @@ class GroundColorsController < ApplicationController
   end
   
   def by_panel
-    filer_list
+    filer_list param: params[:id]
   end
   
   def by_author
-    filer_list
+    filer_list param: params[:id]
   end
   
   def show_html_format format
index db7c553..974cc6e 100644 (file)
@@ -1,13 +1,13 @@
 class GroundPicturesController < ApplicationController
   if Manifest.manifest.magic_numbers['run_mode'] == 0
-    before_filter :authenticate_user, :only => []
-    before_filter :authenticate_author, :only => []
+    before_action :authenticate_user, :only => []
+    before_action :authenticate_author, :only => []
   else
-    before_filter :authenticate_reader, :only => [
+    before_action :authenticate_reader, :only => [
       :index, :show, :by_panel, :by_author
     ]
-    before_filter :authenticate_user, :only => []
-    before_filter :authenticate_author, :only => []
+    before_action :authenticate_user, :only => []
+    before_action :authenticate_author, :only => []
   end
   
   def index
@@ -15,11 +15,11 @@ class GroundPicturesController < ApplicationController
   end
   
   def by_panel
-    filer_list
+    filer_list param: params[:id]
   end
   
   def by_author
-    filer_list
+    filer_list param: params[:id]
   end
   
   def show_html_format format
index 38af1a3..7a9c6cd 100644 (file)
@@ -1,16 +1,16 @@
 class HomeController < ApplicationController
-  before_filter :authenticate_user, :only => [
+  before_action :authenticate_user, :only => [
     :index, :show, :profile, :configure, :create_token, :delete_token, 
     :scrolls, :scroll_panels, :comics, :comic_stories, :stories, :story_sheets, 
     :sheets, :sheet_panels, 
     :panels, :panel_pictures, :speech_balloons, :balloons, :speeches, :ground_pictures, :ground_colors
   ]
-  before_filter :authenticate_author, :only => [
+  before_action :authenticate_author, :only => [
     :scrolls, :scroll_panels, :comics, :comic_stories, :stories, :story_sheets, 
     :sheets, :sheet_panels, 
     :panels, :panel_pictures, :speech_balloons, :balloons, :speeches, :ground_pictures, :ground_colors
   ]
-  before_filter :authenticate_artist, :only => [:resource_pictures]
+  before_action :authenticate_artist, :only => [:resource_pictures]
   
   def index
   end
@@ -60,67 +60,67 @@ class HomeController < ApplicationController
   end
   
   def scrolls
-    filer_list
+    filer_list finder: :find_private, param: @operators
   end
   
   def scroll_panels
-    filer_list
+    filer_list finder: :find_private, param: @operators
   end
   
   def comics
-    filer_list
+    filer_list finder: :find_private, param: @operators
   end
   
   def comic_stories
-    filer_list
+    filer_list finder: :find_private, param: @operators
   end
   
   def stories
-    filer_list
+    filer_list finder: :find_private, param: @operators
   end
   
   def story_sheets
-    filer_list
+    filer_list finder: :find_private, param: @operators
   end
   
   def sheets
-    filer_list
+    filer_list finder: :find_private, param: @operators
   end
   
   def sheet_panels
-    filer_list
+    filer_list finder: :find_private, param: @operators
   end
   
   def panels
-    filer_list
+    filer_list finder: :find_private, param: @operators
   end
   
   def panel_pictures
-    filer_list
+    filer_list finder: :find_private, param: @operators
   end
   
   def speech_balloons
-    filer_list
+    filer_list finder: :find_private, param: @operators
   end
   
   def balloons
-    filer_list
+    filer_list finder: :find_private, param: @operators
   end
   
   def speeches
-    filer_list
+    filer_list finder: :find_private, param: @operators
   end
   
   def ground_pictures
-    filer_list
+    filer_list finder: :find_private, param: @operators
   end
   
   def ground_colors
-    filer_list
+    filer_list finder: :find_private, param: @operators
   end
   
   def resource_pictures
-    filer_list
+    filer_list finder: :find_private, param: @operators
   end
   
 end
index c4c487f..28f6379 100644 (file)
@@ -1,18 +1,18 @@
 class LicenseGroupsController < ApplicationController
   if Manifest.manifest.magic_numbers['run_mode'] == 0
   else
-    before_filter :authenticate_reader, :only => [
+    before_action :authenticate_reader, :only => [
       :by_resource_picture
     ]
   end
-  before_filter :authenticate_admin, :only => [:new, :create, :edit, :update, :destroy]
+  before_action :authenticate_admin, :only => [:new, :create, :edit, :update, :destroy]
   
   def index
     filer_list
   end
   
   def by_resource_picture
-    filer_list
+    filer_list param: params[:id]
   end
   
   def show_html_format format
@@ -43,7 +43,7 @@ class LicenseGroupsController < ApplicationController
     @item = @my_model_class.new
     @item.supply_default 
     @my_model_class.fold_extend_settings params[@my_model_class.item_name]
-    @item.attributes = params[@my_model_class.item_name]
+    @item.attributes = @item.permit_params params
     @item.overwrite 
     render_create
   end
@@ -51,7 +51,7 @@ class LicenseGroupsController < ApplicationController
   def update
     set_edit
     @my_model_class.fold_extend_settings params[@my_model_class.item_name]
-    @item.attributes = params[@my_model_class.item_name]
+    @item.attributes = @item.permit_params params
     @item.overwrite 
     render_update
   end
index cd697dd..b0f3007 100644 (file)
@@ -1,19 +1,19 @@
 class LicensesController < ApplicationController
-  before_filter :authenticate_resource_reader, :only => [
+  before_action :authenticate_resource_reader, :only => [
     :by_license_group, :by_system_picture
   ]
-  before_filter :authenticate_admin, :only => [:new, :create, :edit, :update, :destroy]
+  before_action :authenticate_admin, :only => [:new, :create, :edit, :update, :destroy]
   
   def index
     filer_list
   end
   
   def by_license_group
-    filer_list
+    filer_list param: params[:id]
   end
   
   def by_system_picture
-    filer_list
+    filer_list param: params[:id]
   end
   
   def show_html_format format
@@ -30,7 +30,7 @@ class LicensesController < ApplicationController
       show_json_format format
     end
   end
-
+  
   def search
     @licenses = License.list_by_name(params[:name])
     
@@ -53,7 +53,7 @@ class LicensesController < ApplicationController
     @item = @my_model_class.new
     @item.supply_default 
     @my_model_class.fold_extend_settings params[@my_model_class.item_name]
-    @item.attributes = params[@my_model_class.item_name]
+    @item.attributes = @item.permit_params params
     @item.overwrite 
     render_create
   end
@@ -61,7 +61,7 @@ class LicensesController < ApplicationController
   def update
     set_edit
     @my_model_class.fold_extend_settings params[@my_model_class.item_name]
-    @item.attributes = params[@my_model_class.item_name]
+    @item.attributes = @item.permit_params params
     @item.overwrite 
     render_update
   end
index 9b78878..3f74b0e 100644 (file)
@@ -1,6 +1,6 @@
 class OriginalPictureLicenseGroupsController < ApplicationController
-  before_filter :authenticate_user, :only => [:new, :create]
-  before_filter :authenticate_artist, :only => [:new, :create]
+  before_action :authenticate_user, :only => [:new, :create]
+  before_action :authenticate_artist, :only => [:new, :create]
   
   def new
     @original_picture = OriginalPicture.show params[:original_picture_id], @operators
@@ -20,7 +20,7 @@ class OriginalPictureLicenseGroupsController < ApplicationController
     
     @item = @my_model_class.new
     @my_model_class.fold_extend_settings params[@my_model_class.item_name]
-    @item.attributes = params[@my_model_class.item_name]
+    @item.attributes = @item.permit_params params
     @item.overwrite 
     @original_picture = OriginalPicture.show @item.original_picture, @operators
     
index 9a6543e..7300cb3 100644 (file)
@@ -1,6 +1,6 @@
 class OriginalPictureLicensesController < ApplicationController
-  before_filter :authenticate_user, :only => [:new, :create]
-  before_filter :authenticate_artist, :only => [:new, :create]
+  before_action :authenticate_user, :only => [:new, :create]
+  before_action :authenticate_artist, :only => [:new, :create]
   
   def new
     # use @item, @original_picture, @form
@@ -15,14 +15,14 @@ class OriginalPictureLicensesController < ApplicationController
     
     @item = @my_model_class.new
     @my_model_class.fold_extend_settings params[@my_model_class.item_name]
-    @item.attributes = params[@my_model_class.item_name]
+    @item.attributes = @item.permit_params params
     @item.overwrite 
     @item.boosts 'post'
     @original_picture = OriginalPicture.show @item.original_picture, @operators
     
     if @item.valid?
       # switch my_model_class
-      @item = OriginalPictureLicense.build_resource_picture @item, @original_picture, params[@my_model_class.item_name]
+      @item = OriginalPictureLicense.build_resource_picture @item, @original_picture, @item.permit_params(params)
       respond_to do |format|
         format.html {
           render main_app.new_resource_picture_path
index 59c0678..67604b1 100644 (file)
@@ -1,11 +1,11 @@
 #原画
 class OriginalPicturesController < ApplicationController
-  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]
+  before_action :authenticate_reader, :only => [:show, :history]
+  before_action :authenticate_user, :only => [:index, :new, :edit, :create, :update, :destroy]
+  before_action :authenticate_artist, :only => [:index, :new, :edit, :create, :update, :destroy]
   
   def index
-    filer_list
+    filer_list param: @operators
   end
 
   def show_html_format format
index 3ae4dac..d2f310b 100644 (file)
@@ -1,13 +1,13 @@
 class PanelPicturesController < ApplicationController
   if Manifest.manifest.magic_numbers['run_mode'] == 0
-    before_filter :authenticate_user, :only => []
-    before_filter :authenticate_author, :only => []
+    before_action :authenticate_user, :only => []
+    before_action :authenticate_author, :only => []
   else
-    before_filter :authenticate_reader, :only => [
+    before_action :authenticate_reader, :only => [
       :index, :show, :by_panel, :by_author
     ]
-    before_filter :authenticate_user, :only => []
-    before_filter :authenticate_author, :only => []
+    before_action :authenticate_user, :only => []
+    before_action :authenticate_author, :only => []
   end
   
   def index
@@ -15,11 +15,11 @@ class PanelPicturesController < ApplicationController
   end
   
   def by_panel
-    filer_list
+    filer_list param: params[:id]
   end
   
   def by_author
-    filer_list
+    filer_list param: params[:id]
   end
   
   def show_html_format format
index 301b774..27f6c4d 100644 (file)
@@ -1,23 +1,23 @@
 class PanelsController < ApplicationController
   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]
+    before_action :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
+    before_action :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
   else
-    before_filter :authenticate_reader, :only => [
+    before_action :authenticate_reader, :only => [
       :index, :show, :by_scroll, :by_sheet, :by_author, :by_speech_balloon_template
     ]
-    before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
-    before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
+    before_action :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
+    before_action :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
   end
   
   private
   def panel_list
     set_list
-    @items = @list.items 
-    @pager = @list.page_status.pager
+    @items = @finder
+    @pager = @finder
     respond_to do |format|
       format.html 
-      list_json_format @list, format
+      list_json_format @finder, format
       format.atom 
       format.rss
     end
@@ -32,19 +32,19 @@ class PanelsController < ApplicationController
   end
   
   def by_scroll
-    filer_list
+    filer_list param: params[:id]
   end
   
   def by_sheet
-    filer_list
+    filer_list param: params[:id]
   end
   
   def by_author
-    filer_list
+    filer_list param: params[:id]
   end
   
   def by_speech_balloon_template
-    filer_list
+    filer_list param: params[:id]
   end
   
   def show_html_format format
@@ -114,9 +114,9 @@ class PanelsController < ApplicationController
       jsn = JSON.parse_no_except(params[:json])
     end
     @prm = if params[:panel] == nil or params[:panel].empty?
-       jsn
+      jsn
     else
-       params[:panel]
+      @item.permit_params(params)
     end
     @item.class.fold_extend_settings @prm
     #@item.refresh
@@ -138,7 +138,11 @@ class PanelsController < ApplicationController
     if params[:json]
       jsn = JSON.parse(params[:json])
     end
-    @prm = params[:panel] || jsn
+    @prm = if params[:panel] == nil or params[:panel].empty?
+      jsn
+    else
+      @item.permit_params(params)
+    end
     @item.class.fold_extend_settings @prm
     # @item.refresh
     respond_to do |format|
index 1dd8e5b..435b481 100644 (file)
@@ -1,22 +1,22 @@
 class PicturesController < ApplicationController
   if Manifest.manifest.magic_numbers['run_mode'] == 0
-    before_filter :authenticate_user, :only => []
-    before_filter :authenticate_author, :only => []
+    before_action :authenticate_user, :only => []
+    before_action :authenticate_author, :only => []
   else
-    before_filter :authenticate_user, :only => []
-    before_filter :authenticate_resource_reader, :only => [
+    before_action :authenticate_user, :only => []
+    before_action :authenticate_resource_reader, :only => [
       :show, :credit, :search
     ]
-    before_filter :authenticate_author, :only => []
+    before_action :authenticate_author, :only => []
   end
-  before_filter :authenticate_admin, :only => [:index, :by_artist ]
+  before_action :authenticate_admin, :only => [:index, :by_artist ]
   
   def index
     filer_list
   end
   
   def by_artist
-    filer_list
+    filer_list param: params[:id]
   end
   
   def show_html_format format
index f4c48ba..baf83a9 100644 (file)
@@ -1,5 +1,5 @@
 class ProviderSourcesController < ApplicationController
-  before_filter :authenticate_admin!, :only => [:index, :import]
+  before_action :authenticate_admin!, :only => [:index, :import]
   
   def index
     @urls = MagicNumber['provider_sources']
index c91693e..799bc75 100644 (file)
@@ -1,5 +1,5 @@
 class ProviderStatusesController < ApplicationController
-  before_filter :authenticate_admin!, :only => [:index, :show, :edit, :update, :destroy, :licenses_import, :artists_import, :original_pictures_import, :import, :import_all]
+  before_action :authenticate_admin!, :only => [:index, :show, :edit, :update, :destroy, :licenses_import, :artists_import, :original_pictures_import, :import, :import_all]
   
   def index
     @page = ProviderStatus.page params[:page]
index 88b6e87..526a465 100644 (file)
@@ -1,5 +1,5 @@
 class ProvidersController < ApplicationController
-  before_filter :authenticate_admin!, :only => [:index, :show, :destroy]
+  before_action :authenticate_admin!, :only => [:index, :show, :destroy]
 
   def index
     @page = Provider.page params[:page]
index 8a0ddc3..84cd98d 100644 (file)
@@ -1,9 +1,9 @@
 class ResourcePicturePicturesController < ApplicationController
   if Manifest.manifest.magic_numbers['run_mode'] == 0
-    before_filter :authenticate_admin, :only => [:new, :create, :edit, :update, :destroy]
+    before_action :authenticate_admin, :only => [:new, :create, :edit, :update, :destroy]
   else
-    before_filter :authenticate_reader, :only => [:index, :show, :by_original_picture, :by_resource_picture, :by_picture]
-    before_filter :authenticate_admin, :only => [:new, :create, :edit, :update, :destroy]
+    before_action :authenticate_reader, :only => [:index, :show, :by_original_picture, :by_resource_picture, :by_picture]
+    before_action :authenticate_admin, :only => [:new, :create, :edit, :update, :destroy]
   end
   
   def index
@@ -11,15 +11,15 @@ class ResourcePicturePicturesController < ApplicationController
   end
   
   def by_original_picture
-    filer_list
+    filer_list param: params[:id]
   end
   
   def by_resource_picture
-    filer_list
+    filer_list param: params[:id]
   end
   
   def by_picture
-    filer_list
+    filer_list param: params[:id]
   end
   
   def show
index 27b1b31..a392b4c 100644 (file)
@@ -1,14 +1,14 @@
 class ResourcePicturesController < ApplicationController
   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]
+    before_action :authenticate_user, :only => [:new, :create, :update, :destroy]
+    before_action :authenticate_artist, :only => [:new, :create, :update, :destroy]
   else
-    before_filter :authenticate_resource_reader, :only => [
+    before_action :authenticate_resource_reader, :only => [
       :index, :show, :credit, 
       :by_original_picture, :by_license_group, :by_license, :by_artist
     ]
-    before_filter :authenticate_user, :only => [:new, :create, :update, :destroy]
-    before_filter :authenticate_artist, :only => [:new, :create, :update, :destroy]
+    before_action :authenticate_user, :only => [:new, :create, :update, :destroy]
+    before_action :authenticate_artist, :only => [:new, :create, :update, :destroy]
   end
   
   def index
@@ -16,19 +16,19 @@ class ResourcePicturesController < ApplicationController
   end
   
   def by_original_picture
-    filer_list
+    filer_list param: params[:id]
   end
   
   def by_license_group
-    filer_list
+    filer_list param: params[:id]
   end
   
   def by_license
-    filer_list
+    filer_list param: params[:id]
   end
   
   def by_artist
-    filer_list
+    filer_list param: params[:id]
   end
   
   def show_html_format format
@@ -72,12 +72,12 @@ class ResourcePicturesController < ApplicationController
     if params[:json]
       jsn = JSON.parse_no_except(params[:json])
     end
+    @item = @original_picture.resource_picture || ResourcePicture.new
     @prm = if params[:resource_picture] == nil or params[:resource_picture].empty?
-       jsn
+      jsn
     else
-       params[:resource_picture]
+      @item.permit_params(params)
     end
-    @item = @original_picture.resource_picture || ResourcePicture.new
     @item.attributes = @prm
     @item.overwrite @original_picture
     @item.boosts 'post'
index a35d0b3..a2811ad 100644 (file)
@@ -1,13 +1,13 @@
 class ScrollPanelsController < ApplicationController
   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]
+    before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
+    before_action :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
   else
-    before_filter :authenticate_reader, :only => [
+    before_action :authenticate_reader, :only => [
       :index, :show, :by_panel, :by_scroll, :by_author
     ]
-    before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
-    before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
+    before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
+    before_action :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
   end
   
   def index
@@ -15,15 +15,15 @@ class ScrollPanelsController < ApplicationController
   end
   
   def by_panel
-    filer_list
+    filer_list param: params[:id]
   end
   
   def by_scroll
-    filer_list
+    filer_list param: params[:id]
   end
   
   def by_author
-    filer_list
+    filer_list param: params[:id]
   end
   
   def show
@@ -46,7 +46,7 @@ class ScrollPanelsController < ApplicationController
     set_model
     @item = @my_model_class.new
     @item.supply_default
-    @item.attributes = params[@item.item_name]
+    @item.attributes = @item.permit_params params
     @item.overwrite @operators
     @binder = @my_model_class.binder_model.edit(@item.binder_id, @operators) if @item.binder_id
     @panel = @my_model_class.destination_model.show(@item.destination_id, @operators) if @item.destination_id
@@ -58,7 +58,7 @@ class ScrollPanelsController < ApplicationController
     set_model
     @item = @my_model_class.edit(params[:id], @operators)
     ot = @item.t
-    @item.attributes = params[@item.item_name]
+    @item.attributes = @item.permit_params params
     @item.overwrite @operators
     @binder = @my_model_class.binder_model.edit(@item.binder_id, @operators) if @item.binder_id
     # no check permission for destination
index 246411f..943d7d2 100644 (file)
@@ -1,13 +1,13 @@
 class ScrollsController < ApplicationController
   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]
+    before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
+    before_action :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
   else
-    before_filter :authenticate_reader, :only => [
+    before_action :authenticate_reader, :only => [
       :top, :index, :show, :play, :by_panel, :by_author
     ]
-    before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
-    before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
+    before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
+    before_action :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
   end
   
   def index
@@ -15,11 +15,11 @@ class ScrollsController < ApplicationController
   end
   
   def by_author
-    filer_list
+    filer_list param: params[:id]
   end
   
   def by_panel
-    filer_list
+    filer_list param: params[:id]
   end
   
   def show_html_format format
@@ -47,10 +47,10 @@ class ScrollsController < ApplicationController
       format.html {
         if @item.own? @operators
           @fresh_panel_items = assist_items('panels', 'index')
-          @new_panel_items = assist_items('home', 'panels')
+          @new_panel_items = assist_items('home', 'panels', finder: :find_private, param: @operators)
         end
       }
-      list_json_format @list, format
+      list_json_format @finder, format
     end
   end
   
@@ -66,14 +66,14 @@ class ScrollsController < ApplicationController
     set_model
     @item = @my_model_class.new
     @item.supply_default 
-    @item.attributes = params[@my_model_class.item_name]
+    @item.attributes = @item.permit_params params
     @item.overwrite @operators
     render_create
   end
   
   def update
     set_edit
-    @item.attributes = params[@my_model_class.item_name]
+    @item.attributes = @item.permit_params params
     @item.overwrite @operators
     render_update
   end
index aaa1969..66fa870 100644 (file)
@@ -1,13 +1,13 @@
 class SheetPanelsController < ApplicationController
   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]
+    before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
+    before_action :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
   else
-    before_filter :authenticate_reader, :only => [
+    before_action :authenticate_reader, :only => [
       :index, :show, :by_sheet, :by_panel, :by_author
     ]
-    before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
-    before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
+    before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
+    before_action :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
   end
   
   def index
@@ -15,15 +15,15 @@ class SheetPanelsController < ApplicationController
   end
   
   def by_sheet
-    filer_list
+    filer_list param: params[:id]
   end
   
   def by_panel
-    filer_list
+    filer_list param: params[:id]
   end
   
   def by_author
-    filer_list
+    filer_list param: params[:id]
   end
   
   def show
index f0a1455..24c6d1b 100644 (file)
@@ -1,13 +1,13 @@
 class SheetsController < ApplicationController
   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]
+    before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
+    before_action :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
   else
-    before_filter :authenticate_reader, :only => [
+    before_action :authenticate_reader, :only => [
       :index, :show, :play, :by_story, :by_panel, :by_author
     ]
-    before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
-    before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
+    before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
+    before_action :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
   end
   
   def index
@@ -15,15 +15,15 @@ class SheetsController < ApplicationController
   end
   
   def by_story
-    filer_list
+    filer_list param: params[:id]
   end
   
   def by_panel
-    filer_list
+    filer_list param: params[:id]
   end
   
   def by_author
-    filer_list
+    filer_list param: params[:id]
   end
   
   def show_html_format format
@@ -48,16 +48,15 @@ class SheetsController < ApplicationController
   
   def play
     set_play
-    @list.options.merge!({'page_size' => -1})    # no limit no pager
-    @list.reset
+    @finder.per(-1)    # no limit no pager
     play_list
     respond_to do |format|
       format.html {
-        if @operators.author
-          @new_panel_items = assist_items('home', 'panels')
+        if @item.own? @operators
+          @new_panel_items = assist_items('home', 'panels', finder: :find_private, param: @operators)
         end
       }
-      list_json_format @list, format
+      list_json_format @finder, format
     end
   end
   
@@ -102,11 +101,11 @@ class SheetsController < ApplicationController
     set_model
     @item = @my_model_class.new
     @item.supply_default 
-    jsn = nil
-    if params[:json]
-      jsn = JSON.parse_no_except(params[:json])
+    @prm = if params[:json]
+      JSON.parse_no_except(params[:json])
+    else
+      @item.permit_params params
     end
-    @prm = params[:sheet] || jsn
     
     respond_to do |format|
       if @item.store @prm, @operators
@@ -122,10 +121,11 @@ class SheetsController < ApplicationController
   def update
     set_edit
     jsn = nil
-    if params[:json]
-      jsn = JSON.parse(params[:json])
+    @prm = if params[:json]
+      JSON.parse(params[:json])
+    else
+      @item.permit_params params
     end
-    @prm = params[:sheet] || jsn
     respond_to do |format|
       if @item.store @prm, @operators
         updated_html_format format
index 2499e6e..2b38a27 100644 (file)
@@ -1,13 +1,13 @@
 class SpeechBalloonTemplatesController < ApplicationController
   if Manifest.manifest.magic_numbers['run_mode'] == 0
-    before_filter :authenticate_user, :only => []
+    before_action :authenticate_user, :only => []
   else
-    before_filter :authenticate_reader, :only => [
+    before_action :authenticate_reader, :only => [
       :index, :show, :by_panel, :by_system_picture
     ]
-    before_filter :authenticate_user, :only => []
+    before_action :authenticate_user, :only => []
   end
-  before_filter :authenticate_admin, :only => [:new, :create, :edit, :update, :destroy]
+  before_action :authenticate_admin, :only => [:new, :create, :edit, :update, :destroy]
   
   def index
     filer_list
index 3b8e400..191172f 100644 (file)
@@ -1,13 +1,13 @@
 class SpeechBalloonsController < ApplicationController
   if Manifest.manifest.magic_numbers['run_mode'] == 0
-    before_filter :authenticate_user, :only => []
-    before_filter :authenticate_author, :only => []
+    before_action :authenticate_user, :only => []
+    before_action :authenticate_author, :only => []
   else
-    before_filter :authenticate_reader, :only => [
+    before_action :authenticate_reader, :only => [
       :index, :show, :by_panel, :by_author, :by_speech_balloon_template
     ]
-    before_filter :authenticate_user, :only => []
-    before_filter :authenticate_author, :only => []
+    before_action :authenticate_user, :only => []
+    before_action :authenticate_author, :only => []
   end
   
   def index
@@ -15,15 +15,15 @@ class SpeechBalloonsController < ApplicationController
   end
   
   def by_panel
-    filer_list
+    filer_list param: params[:id]
   end
   
   def by_author
-    filer_list
+    filer_list param: params[:id]
   end
   
   def by_speech_balloon_template
-    filer_list
+    filer_list param: params[:id]
   end
   
   def show_html_format format
index fb37d66..6248d6c 100644 (file)
@@ -1,35 +1,35 @@
 class SpeechesController < ApplicationController
   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]
+    before_action :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
+    before_action :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
   else
-    before_filter :authenticate_reader, :only => [
+    before_action :authenticate_reader, :only => [
       :index, :show, 
       :by_author, :by_speech_balloon, :by_speech_balloon_template, :by_writing_format 
     ]
-    before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
-    before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
+    before_action :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
+    before_action :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
   end
-  before_filter :authenticate_admin!, :only => []
+  before_action :authenticate_admin!, :only => []
   
   def index
     filer_list
   end
   
   def by_author
-    filer_list
+    filer_list param: params[:id]
   end
   
   def by_speech_balloon
-    filer_list
+    filer_list param: params[:id]
   end
   
   def by_speech_balloon_template
-    filer_list
+    filer_list param: params[:id]
   end
   
   def by_writing_format
-    filer_list
+    filer_list param: params[:id]
   end
   
   def show_html_format format
index 67ba22a..0792326 100644 (file)
@@ -1,13 +1,13 @@
 class StoriesController < ApplicationController
   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]
+    before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
+    before_action :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
   else
-    before_filter :authenticate_reader, :only => [
+    before_action :authenticate_reader, :only => [
       :index, :show, :play, :by_comic, :by_sheet, :by_author
     ]
-    before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
-    before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
+    before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
+    before_action :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
   end
   
   def index
@@ -15,15 +15,15 @@ class StoriesController < ApplicationController
   end
   
   def by_comic
-    filer_list
+    filer_list param: params[:id]
   end
   
   def by_sheet
-    filer_list
+    filer_list param: params[:id]
   end
   
   def by_author
-    filer_list
+    filer_list param: params[:id]
   end
   
   def show_html_format format
@@ -46,17 +46,16 @@ class StoriesController < ApplicationController
   
   def play
     set_play
-    @list.options.merge!({'per_page' => 1})    # show one sheet
-    @list.reset
+    @finder.per( 1)   # show one sheet
     play_list
     respond_to do |format|
       format.html {
-        @pager = @list.page_status.pager
+        @pager = @finder
         if @item.own? @operators
-          @new_sheet_items = assist_items('home', 'sheets')
+          @new_sheet_items = assist_items('home', 'sheets', finder: :find_private, param: @operators)
         end
       }
-      list_json_format @list, format
+      list_json_format @finder, format
     end
   end
   
@@ -73,7 +72,7 @@ class StoriesController < ApplicationController
     @story = @item
     @item = @my_model_class.new
     @item.supply_default 
-    @item.attributes = params[@my_model_class.item_name]
+    @item.attributes = @item.permit_params params
     @item.overwrite @operators
     render_create
   end
@@ -81,7 +80,7 @@ class StoriesController < ApplicationController
   def update
     set_edit
     @story = @item
-    @item.attributes = params[@my_model_class.item_name]
+    @item.attributes = @item.permit_params params
     @item.overwrite @operators
     render_update
   end
index 262b5da..793bb6e 100644 (file)
@@ -1,13 +1,13 @@
 class StorySheetsController < ApplicationController
   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]
+    before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
+    before_action :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
   else
-    before_filter :authenticate_reader, :only => [
+    before_action :authenticate_reader, :only => [
       :index, :show, :by_story, :by_sheet, :by_author
     ]
-    before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
-    before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
+    before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
+    before_action :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
   end
   
   def index
@@ -15,15 +15,15 @@ class StorySheetsController < ApplicationController
   end
   
   def by_story
-    filer_list
+    filer_list param: params[:id]
   end
   
   def by_sheet
-    filer_list
+    filer_list param: params[:id]
   end
   
   def by_author
-    filer_list
+    filer_list param: params[:id]
   end
   
   def show
@@ -46,7 +46,7 @@ class StorySheetsController < ApplicationController
     set_model
     @item = @my_model_class.new
     @item.supply_default
-    @item.attributes = params[@item.item_name]
+    @item.attributes = @item.permit_params params
     @item.overwrite @operators
     @binder = @my_model_class.binder_model.edit(@item.binder_id, @operators) if @item.binder_id
     @panel = @my_model_class.destination_model.show(@item.destination_id, @operators) if @item.destination_id
@@ -58,7 +58,7 @@ class StorySheetsController < ApplicationController
     set_model
     @item = @my_model_class.edit(params[:id], @operators)
     ot = @item.t
-    @item.attributes = params[@item.item_name]
+    @item.attributes = @item.permit_params params
     @item.overwrite @operators
     @binder = @my_model_class.binder_model.edit(@item.binder_id, @operators) if @item.binder_id
     # no check permission for destination
index be48d47..f5f8d95 100644 (file)
@@ -1,5 +1,5 @@
 class SystemController < ApplicationController
-  before_filter :authenticate_admin!, :except => [:start]
+  before_action :authenticate_admin!, :except => [:start]
   
   #layout :system
   
@@ -64,7 +64,7 @@ class SystemController < ApplicationController
   end
   
   def waiting_list
-    @waits = Admin.find(:all, :conditions => ['approve = 0'])
+    @waits = Admin.where(approve: 0)
   end
   
   def accept_admin
index 3917ca6..4b544d3 100644 (file)
@@ -1,13 +1,13 @@
 class SystemPicturesController < ApplicationController
   if Manifest.manifest.magic_numbers['run_mode'] == 0
-    before_filter :authenticate_user, :only => []
-    before_filter :authenticate_author, :only => []
+    before_action :authenticate_user, :only => []
+    before_action :authenticate_author, :only => []
   else
-    before_filter :authenticate_resource_reader, :only => [:index, :show]
-    before_filter :authenticate_user, :only => []
-    before_filter :authenticate_author, :only => []
+    before_action :authenticate_resource_reader, :only => [:index, :show]
+    before_action :authenticate_user, :only => []
+    before_action :authenticate_author, :only => []
   end
-  before_filter :authenticate_admin!, :only => []
+  before_action :authenticate_admin!, :only => []
   
   def index
     filer_list
index 91fb1d8..14f8f15 100644 (file)
@@ -1,11 +1,11 @@
 class TopController < ApplicationController
   if Manifest.manifest.magic_numbers['run_mode'] == 0
-    before_filter :authenticate_user, :only => []
-    before_filter :authenticate_author, :only => []
+    before_action :authenticate_user, :only => []
+    before_action :authenticate_author, :only => []
   else
-    before_filter :authenticate_reader, :only => []#[:index]
-    before_filter :authenticate_user, :only => []
-    before_filter :authenticate_author, :only => []
+    before_action :authenticate_reader, :only => []#[:index]
+    before_action :authenticate_user, :only => []
+    before_action :authenticate_author, :only => []
   end
   
   def index
index 93be44e..11f4103 100644 (file)
@@ -1,11 +1,11 @@
 class UserSessionsController < Devise::SessionsController
-  prepend_before_filter :require_no_authentication, :only => [:create ]
+  prepend_before_action :require_no_authentication, :only => [:create ]
   respond_to :json
-
+  skip_before_filter :verify_authenticity_token, only: [:create]
+  
   def create
     if request.xhr?
-      resource = warden.authenticate!(scope: resource_name, recall: "#{controller_path}#failure")
-      sign_in(resource_name, resource)
+      resource = warden.authenticate!(scope: resource_name, recall: "#{controller_path}#xhr_failure")
       return render :json => current_user.to_json({:include => {:author => {}, :artist => {}} })
     else
       super
index 0e4c663..4f9e0ec 100644 (file)
@@ -1,20 +1,20 @@
 class WritingFormatsController < ApplicationController
   if Manifest.manifest.magic_numbers['run_mode'] == 0
-    before_filter :authenticate_user, :only => []
+    before_action :authenticate_user, :only => []
   else
-    before_filter :authenticate_reader, :only => [
+    before_action :authenticate_reader, :only => [
       :index, :by_system_picture, :show
     ]
-    before_filter :authenticate_user, :only => []
+    before_action :authenticate_user, :only => []
   end
-  before_filter :authenticate_admin, :only => [:new, :create, :edit, :update, :destroy]
+  before_action :authenticate_admin, :only => [:new, :create, :edit, :update, :destroy]
   
   def index
     filer_list
   end
   
   def by_system_picture
-    filer_list
+    filer_list param: params[:id]
   end
   
   def show_html_format format
@@ -44,7 +44,7 @@ class WritingFormatsController < ApplicationController
     @item = @my_model_class.new
     @item.supply_default 
     @my_model_class.fold_extend_settings params[@my_model_class.item_name]
-    @item.attributes = params[@my_model_class.item_name]
+    @item.attributes = @item.permit_params params
     @item.overwrite 
     render_create
   end
@@ -52,7 +52,7 @@ class WritingFormatsController < ApplicationController
   def update
     set_edit
     @my_model_class.fold_extend_settings params[@my_model_class.item_name]
-    @item.attributes = params[@my_model_class.item_name]
+    @item.attributes = @item.permit_params params
     @item.overwrite 
     render_update
   end
index 0788a94..5ec56f9 100644 (file)
@@ -3,9 +3,6 @@ class Admin < ActiveRecord::Base
   # , :encryptable, :lockable, :timeoutable and :omniauthable, :confirmable
   devise :database_authenticatable, :registerable,
          :recoverable, :rememberable, :trackable, :validatable 
-
-  # Setup accessible (or protected) attributes for your model
-  attr_accessible :email, :password, :password_confirmation, :remember_me
   
   def active_for_authentication?
     super && (self.approve == 1)
@@ -27,15 +24,16 @@ class Admin < ActiveRecord::Base
   end
   
   def self.start(email, passwd)
-    a = Admin.find(:first, :conditions => ['email = ?', email])
-    if a
-      a.password = passwd
-      a.password_confirmation = passwd
-    else
-      a = Admin.create! :email => email, :password => passwd, :password_confirmation => passwd
-    end
+    a = Admin.find_or_initialize_by(email: email)
+    a.password = passwd
+    a.password_confirmation = passwd
     a.approve = 1
     a.save!
   end
   
+  private
+  def admin_params
+    params.require(:admin).permit(:email, :password, :password_confirmation, :remember_me, :authentication_token)
+  end
+  
 end
index 3fc4bc9..6c97a5e 100644 (file)
@@ -9,13 +9,17 @@ class Artist < Peta::Owner
   validates :user_id, :numericality => true, :existence => {:both => false}
   validates :provider_id, :numericality => {:allow_nil => true}
   
+  scope :find_index, -> do
+    self
+  end
+  
   def supply_default
     self.name = 'no name' if self.name.blank?
     self.user_id = nil
   end
   
   def self.find_by_author author
-    Artist.find( :first, :conditions => ['author_id = ?', author.id])
+    Artist.where(author_id: author.id).first
   end
   
   def self.index_list_where list
@@ -27,15 +31,9 @@ class Artist < Peta::Owner
   end
   
   def self.export(dt = nil)
-    opt = {}
-    cond = if dt
-      ['artists.artists.provider = 0 and artists.updated_at >= ?', dt]
-    else
-      'artists.artists.provider = 0'
-    end
-    opt.merge!({:conditions => cond}) 
-    opt.merge!({:order => 'id'})
-    Artist.find(:all, opt)
+    artists = Artist.where('artists.provider = 0')
+    artists = artists.where(['artists.updated_at >= ?', dt]) if dt
+    artists.order(:id)
   end
   
 end
index 594e36c..c598a8a 100644 (file)
@@ -9,6 +9,10 @@ class Author < Peta::Owner
   validates :name, :presence => true, :length => {:maximum => 30}
   validates :user_id, :numericality => true, :existence => {:both => false}
   
+  scope :find_index, -> do
+    self
+  end
+  
   def supply_default
     self.name = 'no name' if self.name.blank?
     self.user_id = nil
index f4287fe..bf3d7f4 100644 (file)
@@ -16,6 +16,42 @@ class Balloon < Peta::Element
 #  validates :caption, :presence => true
   validates :speech_balloon_template_settings, :boost => {:boost_name => :speech_balloon_template}
 
+  scope :with_panel, -> do
+    includes(speech_balloon: :panel)
+  end
+  
+  scope :with_speech_balloon_template, -> do
+    includes(:speech_balloon_template)
+  end
+  
+  scope :find_index, -> do
+    with_panel.where(Panel.arel_table[:publish].gt 0).references(:panel)
+  end
+  
+  scope :find_private, -> (operators) do 
+    with_panel.where(Panel.arel_table[:author_id].eq operators.author.id).references(:panel)
+  end
+  
+  scope :find_by_panel, -> (panel_id) do 
+    find_index.where(panel_id: panel_id).references(:panel)
+  end
+  
+  scope :find_by_speech_balloon, -> (speech_balloon_id) do 
+    find_index.where(speech_balloon_id: speech_balloon_id).references(:panel)
+  end
+  
+  scope :find_by_speech_balloon_template, -> (speech_balloon_template_id) do 
+    find_index.where(speech_balloon_template_id: speech_balloon_template_id).references(:panel)
+  end
+  
+  scope :find_by_system_picture, -> (system_picture_id) do 
+    find_index.where(system_picture_id: system_picture_id).references(:panel)
+  end
+  
+  scope :find_by_author, -> (author_id) do 
+    find_index.where(Panel.arel_table[:author_id].eq author_id).references(:panel)
+  end
+  
   def y
     self.attributes['y']
   end
index ed15468..269f07b 100644 (file)
@@ -8,6 +8,36 @@ class Comic < Peta::Binder
   validates :visible, :presence => true, :numericality => true, :inclusion => {:in => 0..1}
   validates :author_id, :presence => true, :numericality => true, :existence => {:both => false}
   
+  scope :find_index, -> do
+    where(arel_table[:visible].gt 0)
+  end
+  
+  scope :find_private, -> (operators) do 
+    where(author_id: operators.author.id)
+  end
+  
+  scope :find_by_author, -> (author_id) do 
+    find_index.where(author_id: author_id)
+  end
+  
+  scope :with_stories, -> do
+    includes(comic_stories: :story)
+  end
+  
+  scope :find_by_story, -> (story_id) do 
+    with_stories.find_index.where(Story.arel_table[:id].eq story_id).references(:story)
+  end
+  
+  # scope of find_play
+  def self.find_play(id)
+    ComicStory.find_play(id)
+  end
+  
+  # scope of find_private_play
+  def self.find_private_play(id, operators)
+    ComicStory.find_private_play(id, operators)
+  end
+  
   def supply_default
     self.visible = 0 if self.visible.blank?
     self.author_id = nil
index 12213ba..7f773d8 100644 (file)
@@ -8,6 +8,42 @@ class ComicStory < Peta::Leaf
   validates :story_id, :presence => true, :numericality => true, :existence => {:both => false}
   validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
   
+  scope :with_comic, -> do
+    includes(:comic)
+  end
+  
+  scope :find_index, -> do
+    with_comic.where(Comic.arel_table[:visible].gt 0).references(:comic)
+  end
+  
+  scope :find_private, -> (operators) do 
+    with_comic.where(Comic.arel_table[:author_id].eq operators.author.id).references(:comic)
+  end
+  
+  scope :by_comic, -> (comic_id) do 
+    where(comic_id: comic_id)
+  end
+  
+  scope :find_by_comic, -> (comic_id) do 
+    find_index.by_comic(comic_id)
+  end
+  
+  scope :find_by_story, -> (story_id) do 
+    find_index.where(story_id: story_id).references(:comic)
+  end
+  
+  scope :find_by_author, -> (author_id) do 
+    find_index.where(Comic.arel_table[:author_id].eq author_id).references(:comic)
+  end
+  
+  scope :find_play, -> (comic_id) do 
+    find_by_comic(comic_id)
+  end
+  
+  scope :find_private_play, -> (comic_id, operators) do 
+   find_private(operators).by_comic(comic_id)
+  end
+  
   def supply_default
     self.comic_id = nil
     self.story_id = nil
diff --git a/app/models/concerns/.keep b/app/models/concerns/.keep
new file mode 100644 (file)
index 0000000..e69de29
index 6c2a2c0..b92fda7 100644 (file)
@@ -5,8 +5,6 @@ class DemandUser < ActiveRecord::Base
   # :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
   devise :database_authenticatable, :registerable,
          :recoverable, :rememberable, :trackable, :validatable 
-  # Setup accessible (or protected) attributes for your model
-  attr_accessible :email, :password, :password_confirmation, :remember_me
   
   def create_token
     self.ensure_authentication_token
@@ -18,4 +16,9 @@ class DemandUser < ActiveRecord::Base
     self.save
   end
   
+  private
+  def demand_user_params
+    params.require(:demand_user).permit(:email, :password, :password_confirmation, :remember_me, :authentication_token)
+  end
+  
 end
index e004a57..14548a7 100644 (file)
@@ -7,6 +7,10 @@ class Folder < Peta::SystemResource
   validates :category_id, :presence => true, :numericality => true
   validates :t, :presence => true, :numericality => true
   
+  scope :find_index, -> do
+    self
+  end
+  
   #remove last dir name
   def dir
     r = name.split('/')
@@ -31,7 +35,7 @@ class Folder < Peta::SystemResource
     attr = {
       :name => key, :category_id => 0, :t => 0
     }
-    if i = self.find_by_name(key)
+    if i = self.find_by(name: key)
       i.attributes = attr
       i.save
     else
@@ -48,7 +52,7 @@ class Folder < Peta::SystemResource
       :controller_name => (controller_name || name), 
       :action_name => action_name
     }
-    if i = self.find_by_name(key)
+    if i = self.find_by(name: key)
       i.attributes = attr
       i.save
     else
@@ -59,7 +63,7 @@ class Folder < Peta::SystemResource
   end
   
   def self.generate
-    if r = self.find_by_name('/')
+    if r = self.find_by(name: '/')
     else
       r = self.create :name => '/', :category_id => 0, :t => 0
     end
index 588196e..a4c9a66 100644 (file)
@@ -11,6 +11,26 @@ class GroundColor < Peta::Element
   validates :z, :presence => true, :numericality => {:greater_than => 0}
   validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
   
+  scope :with_panel, -> do
+    includes(:panel)
+  end
+  
+  scope :find_index, -> do
+    with_panel.where(Panel.arel_table[:publish].gt 0).references(:panel)
+  end
+  
+  scope :find_private, -> (operators) do 
+    with_panel.where(Panel.arel_table[:author_id].eq operators.author.id).references(:panel)
+  end
+  
+  scope :find_by_panel, -> (panel_id) do 
+    find_index.where(panel_id: panel_id).references(:panel)
+  end
+  
+  scope :find_by_author, -> (author_id) do 
+    find_index.where(Panel.arel_table[:author_id].eq author_id).references(:panel)
+  end
+  
   def self.by_author_list_includes
     {
       :panel => {
index ab5a244..bd1d16d 100644 (file)
@@ -11,6 +11,26 @@ class GroundPicture < Peta::Element
   validates :z, :presence => true, :numericality => {:greater_than => 0}
   validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
   
+  scope :with_panel, -> do
+    includes(:panel)
+  end
+  
+  scope :find_index, -> do
+    with_panel.where(Panel.arel_table[:publish].gt 0).references(:panel)
+  end
+  
+  scope :find_private, -> (operators) do 
+    with_panel.where(Panel.arel_table[:author_id].eq operators.author.id).references(:panel)
+  end
+  
+  scope :find_by_panel, -> (panel_id) do 
+    find_index.where(panel_id: panel_id).references(:panel)
+  end
+  
+  scope :find_by_author, -> (author_id) do 
+    find_index.where(Panel.arel_table[:author_id].eq author_id).references(:panel)
+  end
+  
   @@repeat_texts = ['repeat', 'repeat-x', 'repeat-y', 'no-repeat']
   
   def self.pickup_item_name
index 009f51e..f0ebd78 100644 (file)
@@ -14,6 +14,18 @@ class License < Peta::SystemResource
   validates :license_group_settings, :boost => {:boost_name => :license_group}
   validates :credit_picture_settings, :boost => {:boost_name => :credit_picture}
   
+  scope :find_index, -> do
+    self.all
+  end
+  
+  scope :find_by_license_group, -> (license_group_id) do 
+    where(license_group_id: license_group_id)
+  end
+  
+  scope :find_by_system_picture, -> (system_picture_id) do 
+    where(system_picture_id: system_picture_id)
+  end
+  
   def overwrite 
   end
   
@@ -30,7 +42,7 @@ class License < Peta::SystemResource
   end
   
   def self.list_by_name name
-    License.find :all, :conditions => ['licenses.name = ?', name], :order => 'licenses.updated_at desc'
+    License.where(name: name).order(updated_at: :desc)
   end
   
   def self.store name, attr
@@ -59,10 +71,9 @@ class License < Peta::SystemResource
   end
   
   def self.export(dt = nil)
-    opt = {}
-    opt.merge!({:conditions => ['updated_at >= ?', dt]}) if dt
-#    opt.merge!({:order => 'name'})
-    License.find(:all, opt)
+    licenses = License.all
+    licenses = licenses.where(['licenses.updated_at >= ?', dt]) if dt
+    licenses.order(:id)
   end
   
 end
index 61c6179..9578164 100644 (file)
@@ -9,6 +9,10 @@ class LicenseGroup < Peta::Template
   validates :caption, :presence => true, :length => {:maximum => 30}
   validates :url, :presence => true, :length => {:maximum => 200}, :url => {:message => I18n.t('errors.messages.url')}
   
+  scope :find_index, -> do
+    self.all
+  end
+  
   def supply_default
   end
   
index 65d99d1..5380713 100644 (file)
@@ -13,6 +13,10 @@ class OriginalPicture < Peta::Content
   validates :artist_id, :presence => true, :numericality => true, :existence => {:both => false}
   validates :md5, :presence => true, :length => {:minimum => 32, :maximum => 32}
   
+  scope :find_index, -> (operators) do 
+    where(artist_id: operators.artist.id)
+  end
+  
   def supply_default
     self.artist_id = nil
   end
@@ -79,7 +83,7 @@ class OriginalPicture < Peta::Content
   end
   
   def history 
-    Picture.find(:all, {:conditions => ['pictures.original_picture_id = ?', self.id], :order => 'pictures.revision desc'} )
+    Picture.where(original_picture_id: self.id).order(revision: :desc)
   end
   
   def self.show_opt
@@ -112,15 +116,9 @@ class OriginalPicture < Peta::Content
   end
   
   def self.export(dt = nil)
-    opt = {}
-    cond = if dt
-      ['artists.author_id is not null and original_pictures.updated_at >= ?', dt]
-    else
-      'artists.author_id is not null'
-    end
-    opt.merge!({:conditions => cond}) 
-    opt.merge!({:include => {:resource_picture => {}, :artist => {}}, :order => 'original_pictures.id'})
-    OriginalPicture.find(:all, opt)
+    original_pictures = OriginalPicture.includes(:resource_picture, :artist).where('artists.author_id is not null')
+    original_pictures = original_pictures.where(['original_pictures.updated_at >= ?', dt]) if dt
+    original_pictures.order('original_pictures.id').references(:artist)
   end
   
   def list_as_json_with_resource_picture
@@ -160,7 +158,7 @@ class OriginalPicture < Peta::Content
   end
   
   def self.publish oid, lsname, attr
-    l = License.find_by_name lsname
+    l = License.find_by(name: lsname)
     op = OriginalPicture.find oid
     lg = l.license_group
     attr[:license_id] = l.id
index f6fc3c7..daa7bf7 100644 (file)
@@ -19,6 +19,42 @@ class Panel < Peta::Root
   validates :author_id, :presence => true, :numericality => true, :existence => {:both => false}
   validates :publish, :presence => true, :numericality => true
   
+  scope :find_index, -> do
+    where(arel_table[:publish].gt 0)
+  end
+  
+  scope :find_private, -> (operators) do 
+    where(author_id: operators.author.id)
+  end
+  
+  scope :find_by_author, -> (author_id) do 
+    find_index.where(author_id: author_id)
+  end
+  
+  scope :with_scrolls, -> do
+    includes(scroll_panels: :scroll)
+  end
+  
+  scope :find_by_scroll, -> (scroll_id) do 
+    with_scrolls.find_index.where(Scroll.arel_table[:id].eq scroll_id).references(:scroll)
+  end
+  
+  scope :with_sheets, -> do
+    includes(sheet_panels: :sheet)
+  end
+  
+  scope :find_by_sheet, -> (sheet_id) do 
+    with_sheets.find_index.where(Sheet.arel_table[:id].eq sheet_id).references(:sheet)
+  end
+  
+  scope :with_speech_balloons, -> do
+    includes(:speech_balloons)
+  end
+  
+  scope :find_by_speech_balloon_template, -> (speech_balloon_template_id) do 
+    with_speech_balloons.find_index.where(SpeechBalloon.arel_table[:speech_balloon_template_id].eq speech_balloon_template_id).references(:speech_balloon)
+  end
+  
   def supply_default
     self.border = 2
     self.publish = 0
index 80cf323..3713764 100644 (file)
@@ -13,6 +13,26 @@ class PanelPicture < Peta::Element
   validates :z, :presence => true, :numericality => {:greater_than => 0}
   validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
   
+  scope :with_panel, -> do
+    includes(:panel)
+  end
+  
+  scope :find_index, -> do
+    with_panel.where(Panel.arel_table[:publish].gt 0).references(:panel)
+  end
+  
+  scope :find_private, -> (operators) do 
+    with_panel.where(Panel.arel_table[:author_id].eq operators.author.id).references(:panel)
+  end
+  
+  scope :find_by_panel, -> (panel_id) do 
+    find_index.where(panel_id: panel_id).references(:panel)
+  end
+  
+  scope :find_by_author, -> (author_id) do 
+    find_index.where(Panel.arel_table[:author_id].eq author_id).references(:panel)
+  end
+  
   def self.pickup_item_name
     Picture.item_name
   end
index 39645a7..e987d93 100644 (file)
@@ -20,6 +20,14 @@ class Picture < Peta::Content
   validates :artist_id, :presence => true, :numericality => true, :existence => {:both => false}
   validates :license_group_module_name, :presence => true, :length => {:maximum => 50}
   
+  scope :find_index, -> do
+    self
+  end
+  
+  scope :find_by_artist, -> (artist_id) do 
+    find_index.where(artist_id: artist_id)
+  end
+  
   def supply_default
   end
   
@@ -90,7 +98,7 @@ class Picture < Peta::Content
   end
   
   def new_revision
-    Picture.maximum(:revision, :conditions => ['original_picture_id = ?', self.original_picture_id]).to_i + 1
+    Picture.where(original_picture_id: self.original_picture_id).maximum(:revision).to_i + 1
   end
   
   def enable?
@@ -99,7 +107,7 @@ class Picture < Peta::Content
   end
   
   def self.head opid
-    Picture.find(:first, :conditions => ['original_picture_id = ?', opid], :order => 'pictures.revision desc')
+    Picture.where(original_picture_id: opid).order('pictures.revision desc').first
   end
   
   def head
@@ -119,16 +127,16 @@ class Picture < Peta::Content
   end
   
   def self.find_by_md5 md5
-    r = Picture.find :all, :conditions => ['pictures.md5 = ?', md5], :order => 'pictures.updated_at desc'
+    r = Picture.where(md5: md5).order(updated_at: :desc)
   end
   
   def self.list_by_md5 md5, opid = nil
     cond = if opid.blank?
-      ['pictures.md5 = ?', md5]
+      {md5: md5}
     else
-      ['pictures.md5 = ? and pictures.original_picture_id <> ?', md5, opid]
+      ['md5 = :md5 and original_picture_id <> :opid', {md5: md5, opid: opid}]
     end
-    r = Picture.find :all, :conditions => cond, :order => 'pictures.updated_at desc'
+    r = Picture.where(cond).order(updated_at: :desc)
   end
   
   def self.exist_by_md5 md5, opid
@@ -182,15 +190,9 @@ class Picture < Peta::Content
   end
   
   def self.export(dt = nil)
-    opt = {}
-    cond = if dt
-      ['artists.author_id is not null and pictures.updated_at >= ?', dt]
-    else
-      'artists.author_id is not null'
-    end
-    opt.merge!({:conditions => cond}) 
-    opt.merge!({:include => {:artist => {}}, :order => 'pictures.updated_at desc'})
-    Picture.find(:all, opt)
+    pictures = Picture.includes(:artist).where('artists.author_id is not null')
+    pictures = pictures.where(['pictures.updated_at >= ?', dt]) if dt
+    pictures.order('pictures.updated_at desc').references(:artist)
   end
   
   def self.list_as_json_text ary
index e087b99..521a071 100644 (file)
@@ -24,6 +24,30 @@ class ResourcePicture < Peta::Content
   validates :license_group_settings, :boost => {:boost_name => :license_group}
   validates :credit_picture_settings, :boost => {:boost_name => :credit_picture}
   
+  scope :find_index, -> do
+    self.all
+  end
+  
+  scope :find_private, -> (operators) do 
+    where(artist_id: operators.artist.id)
+  end
+  
+  scope :find_by_original_picture, -> (original_picture_id) do 
+    find_index.where(original_picture_id: original_picture_id)
+  end
+  
+  scope :find_by_license_group, -> (license_group_id) do 
+    find_index.where(license_group_id: license_group_id)
+  end
+  
+  scope :find_by_license, -> (license_id) do 
+    find_index.where(license_id: license_id)
+  end
+  
+  scope :find_by_artist, -> (artist_id) do 
+    find_index.where(artist_id: artist_id)
+  end
+  
   def self.pickup_item_name
     Picture.item_name
   end
@@ -235,7 +259,7 @@ class ResourcePicture < Peta::Content
   end
   
   def self.remake_all
-    ResourcePicture.find(:all).each do |resource_picture|
+    ResourcePicture.find_each do |resource_picture|
       resource_picture.boosts 'post'
       full = resource_picture.restore 'full'
       imager = PettanImager.load full
index 3be419a..7a24ec9 100644 (file)
@@ -4,6 +4,22 @@ class ResourcePicturePicture < Peta::Item
   belongs_to :resource_picture
   belongs_to :picture
   
+  scope :find_index, -> do
+    self
+  end
+  
+  scope :find_by_original_picture, -> (original_picture_id) do 
+    find_index.where(original_picture_id: original_picture_id)
+  end
+  
+  scope :find_by_resource_picture, -> (resource_picture_id) do 
+    find_index.where(resource_picture_id: resource_picture_id)
+  end
+  
+  scope :find_by_picture, -> (picture_id) do 
+    find_index.where(picture_id: picture_id)
+  end
+  
   def symbol_option
     self.picture.tmb_opt_img_tag
   end
index a206662..3a50002 100644 (file)
@@ -3,10 +3,42 @@ class Scroll < Peta::Binder
   has_many :scroll_panels
   belongs_to :author
   
+  has_many :panels, :through => :scroll_panels
+  
   validates :title, :presence => true, :length => {:maximum => 100}
   validates :visible, :presence => true, :numericality => true, :inclusion => {:in => 0..1}
   validates :author_id, :presence => true, :numericality => true, :existence => {:both => false}
   
+  scope :find_index, -> do
+    where(arel_table[:visible].gt 0)
+  end
+  
+  scope :find_private, -> (operators) do 
+    where(author_id: operators.author.id)
+  end
+  
+  scope :find_by_author, -> (author_id) do 
+    find_index.where(author_id: author_id)
+  end
+  
+  scope :with_panels, -> do
+    includes(scroll_panels: :panel)
+  end
+  
+  scope :find_by_panel, -> (panel_id) do 
+    with_panels.find_index.where(Panel.arel_table[:id].eq panel_id).references(:panel)
+  end
+  
+  # scope of find_play
+  def self.find_play(id)
+    ScrollPanel.find_play(id)
+  end
+  
+  # scope of find_private_play
+  def self.find_private_play(id, operators)
+    ScrollPanel.find_private_play(id, operators)
+  end
+  
   def supply_default
     self.visible = 0 if self.visible.blank?
     self.author_id = nil
index 12fab0f..dbc4de2 100644 (file)
@@ -8,6 +8,42 @@ class ScrollPanel < Peta::Leaf
   validates :panel_id, :presence => true, :numericality => true, :existence => {:both => false}
   validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
   
+  scope :with_scroll, -> do
+    includes(:scroll)
+  end
+  
+  scope :find_index, -> do
+    with_scroll.where(Scroll.arel_table[:visible].gt 0).references(:scroll)
+  end
+  
+  scope :find_private, -> (operators) do 
+    with_scroll.where(Scroll.arel_table[:author_id].eq operators.author.id).references(:scroll)
+  end
+  
+  scope :by_scroll, -> (scroll_id) do 
+    where(scroll_id: scroll_id)
+  end
+  
+  scope :find_by_scroll, -> (scroll_id) do 
+    find_index.by_scroll(scroll_id).references(:scroll)
+  end
+  
+  scope :find_by_panel, -> (panel_id) do 
+    find_index.where(panel_id: panel_id).references(:scroll)
+  end
+  
+  scope :find_by_author, -> (author_id) do 
+    find_index.where(Scroll.arel_table[:author_id].eq author_id).references(:scroll)
+  end
+  
+  scope :find_play, -> (scroll_id) do 
+    find_by_scroll(scroll_id)
+  end
+  
+  scope :find_private_play, -> (scroll_id, operators) do 
+    find_private(operators).by_scroll(scroll_id)
+  end
+  
   def supply_default
     self.scroll_id = nil
     self.panel_id = nil
@@ -22,11 +58,7 @@ class ScrollPanel < Peta::Leaf
   end
   
   def self.by_author_list_includes
-    {
-      :scroll => {
-        :author => {}
-      }
-    }
+    [:scroll => :author]
   end
   
   def self.show_opt
index dd4d5eb..6d5360e 100644 (file)
@@ -10,6 +10,44 @@ class Sheet < Peta::Root
   validates :visible, :presence => true, :numericality => true, :inclusion => {:in => 0..1}
   accepts_nested_attributes_for :sheet_panels, :allow_destroy => true
   
+  scope :find_index, -> do
+    where(arel_table[:visible].gt 0)
+  end
+  
+  scope :find_private, -> (operators) do 
+    where(author_id: operators.author.id)
+  end
+  
+  scope :find_by_author, -> (author_id) do 
+    find_index.where(author_id: author_id)
+  end
+  
+  scope :with_panels, -> do
+    includes(sheet_panels: :panel)
+  end
+  
+  scope :find_by_panel, -> (panel_id) do 
+    with_panels.find_index.where(Panel.arel_table[:id].eq panel_id).references(:panel)
+  end
+  
+  scope :with_stories, -> do
+    includes(story_sheets: :story)
+  end
+  
+  scope :find_by_story, -> (story_id) do 
+    with_stories.find_index.where(Story.arel_table[:id].eq story_id).references(:story)
+  end
+  
+  # scope of find_play
+  def self.find_play(id)
+    SheetPanel.find_play(id)
+  end
+  
+  # scope of find_private_play
+  def self.find_private_play(id, operators)
+    SheetPanel.find_private_play(id, operators)
+  end
+  
   def supply_default
     self.visible = 0 if self.visible.blank?
     self.author_id = nil
index fa0c1b6..4cc2654 100644 (file)
@@ -12,6 +12,42 @@ class SheetPanel < Peta::Element
   validates :z, :presence => true, :numericality => {:greater_than => 0}
   validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
   
+  scope :with_sheet, -> do
+    includes(:sheet)
+  end
+  
+  scope :find_index, -> do
+    with_sheet.where(Sheet.arel_table[:visible].gt 0).references(:sheet)
+  end
+  
+  scope :find_private, -> (operators) do 
+    with_sheet.where(Sheet.arel_table[:author_id].eq operators.author.id).references(:sheet)
+  end
+  
+  scope :by_sheet, -> (sheet_id) do 
+    where(sheet_id: sheet_id)
+  end
+  
+  scope :find_by_sheet, -> (sheet_id) do 
+    find_index.by_sheet(sheet_id).references(:sheet)
+  end
+  
+  scope :find_by_panel, -> (panel_id) do 
+    find_index.where(panel_id: panel_id).references(:sheet)
+  end
+  
+  scope :find_by_author, -> (author_id) do 
+    find_index.where(Sheet.arel_table[:author_id].eq author_id).references(:sheet)
+  end
+  
+  scope :find_play, -> (sheet_id) do 
+    find_by_sheet(sheet_id)
+  end
+  
+  scope :find_private_play, -> (sheet_id, operators) do 
+    find_private(operators).by_sheet(sheet_id)
+  end
+  
   def y
     self.attributes['y']
   end
index 24cb701..263f6cf 100644 (file)
@@ -20,6 +20,42 @@ class Speech < Peta::Element
   validates :speech_balloon_template_settings, :boost => {:boost_name => :speech_balloon_template}
   #validates :writing_format_settings
   
+  scope :with_panel, -> do
+    includes(speech_balloon: :panel)
+  end
+  
+  scope :with_speech_balloon_template, -> do
+    includes(:speech_balloon_template)
+  end
+  
+  scope :find_index, -> do
+    with_panel.where(Panel.arel_table[:publish].gt 0).references(:panel)
+  end
+  
+  scope :find_private, -> (operators) do 
+    with_panel.where(Panel.arel_table[:author_id].eq operators.author.id).references(:panel)
+  end
+  
+  scope :find_by_panel, -> (panel_id) do 
+    find_index.where(panel_id: panel_id).references(:panel)
+  end
+  
+  scope :find_by_speech_balloon, -> (speech_balloon_id) do 
+    find_index.where(speech_balloon_id: speech_balloon_id).references(:panel)
+  end
+  
+  scope :find_by_speech_balloon_template, -> (speech_balloon_template_id) do 
+    find_index.where(speech_balloon_template_id: speech_balloon_template_id).references(:panel)
+  end
+  
+  scope :find_by_writing_format, -> (writing_format_id) do 
+    find_index.where(writing_format_id: writing_format_id).references(:panel)
+  end
+  
+  scope :find_by_author, -> (author_id) do 
+    find_index.where(Panel.arel_table[:author_id].eq author_id).references(:panel)
+  end
+  
   @@text_align_texts = ['left', 'left', 'right', 'center']
   
   def y
index 5f7c63d..367af4a 100644 (file)
@@ -15,6 +15,34 @@ class SpeechBalloon < Peta::Element
   validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
   validates :speech_balloon_template_settings, :boost => {:boost_name => :speech_balloon_template}
   
+  scope :with_panel, -> do
+    includes(:panel)
+  end
+  
+  scope :with_speech_balloon_template, -> do
+    includes(:speech_balloon_template)
+  end
+  
+  scope :find_index, -> do
+    with_panel.where(Panel.arel_table[:publish].gt 0).references(:panel)
+  end
+  
+  scope :find_private, -> (operators) do 
+    with_panel.where(Panel.arel_table[:author_id].eq operators.author.id).references(:panel)
+  end
+  
+  scope :find_by_panel, -> (panel_id) do 
+    find_index.where(panel_id: panel_id).references(:panel)
+  end
+  
+  scope :find_by_speech_balloon_template, -> (speech_balloon_template_id) do 
+    find_index.where(speech_balloon_template_id: speech_balloon_template_id).references(:panel)
+  end
+  
+  scope :find_by_author, -> (author_id) do 
+    find_index.where(Panel.arel_table[:author_id].eq author_id).references(:panel)
+  end
+  
   def self.by_author_list_includes
     {
       :panel => {
index 5217f5d..4660b97 100644 (file)
@@ -11,6 +11,26 @@ class SpeechBalloonTemplate < Peta::Template
   validates :system_picture_id, :presence => true, :numericality => true, :existence => {:both => false}
   validates :settings, :presence => true
   
+  scope :find_index, -> do
+    self
+  end
+  
+  scope :find_by_original_picture, -> (original_picture_id) do 
+    find_index.where(original_picture_id: original_picture_id)
+  end
+  
+  scope :with_panels, -> do
+    includes(speech_balloons: panel)
+  end
+  
+  scope :find_by_panel, -> (panel_id) do 
+    with_panels.where(Panel.arel_table[:id].eq panel_id).references(:panel)
+  end
+  
+  scope :find_by_system_picture, -> (system_picture_id) do 
+    find_index.where(system_picture_id: system_picture_id)
+  end
+  
   def supply_default
   end
   
index 7c3354d..cd02e7f 100644 (file)
@@ -9,6 +9,44 @@ class Story < Peta::Binder
   validates :visible, :presence => true, :numericality => true, :inclusion => {:in => 0..1}
   validates :author_id, :presence => true, :numericality => true, :existence => {:both => false}
   
+  scope :find_index, -> do
+    where(arel_table[:visible].gt 0)
+  end
+  
+  scope :find_private, -> (operators) do 
+    where(author_id: operators.author.id)
+  end
+  
+  scope :find_by_author, -> (author_id) do 
+    find_index.where(author_id: author_id)
+  end
+  
+  scope :with_comics, -> do
+    includes(comic_stories: :comic)
+  end
+  
+  scope :find_by_comic, -> (comic_id) do 
+    with_comics.find_index.where(Comic.arel_table[:id].eq comic_id).references(:comic)
+  end
+  
+  scope :with_sheets, -> do
+    includes(story_sheets: :sheet)
+  end
+  
+  scope :find_by_sheet, -> (sheet_id) do 
+    with_sheets.find_index.where(Sheet.arel_table[:id].eq sheet_id).references(:sheet)
+  end
+  
+  # scope of find_play
+  def self.find_play(id)
+    StorySheet.find_play(id)
+  end
+  
+  # scope of find_private_play
+  def self.find_private_play(id, operators)
+    StorySheet.find_private_play(id, operators)
+  end
+  
   def supply_default
     self.visible = 0 if self.visible.blank?
     self.author_id = nil
index 0d09dcb..f4aff82 100644 (file)
@@ -7,6 +7,42 @@ class StorySheet < Peta::Leaf
   validates :sheet_id, :presence => true, :numericality => true, :existence => {:both => false}
   validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
   
+  scope :with_story, -> do
+    includes(:story)
+  end
+  
+  scope :find_index, -> do
+    with_story.where(Story.arel_table[:visible].gt 0).references(:story)
+  end
+  
+  scope :find_private, -> (operators) do 
+    with_story.where(Story.arel_table[:author_id].eq operators.author.id).references(:story)
+  end
+  
+  scope :by_story, -> (story_id) do 
+    where(story_id: story_id)
+  end
+  
+  scope :find_by_story, -> (story_id) do 
+    find_index.by_story(story_id)
+  end
+  
+  scope :find_by_sheet, -> (sheet_id) do 
+    find_index.where(sheet_id: sheet_id).references(:story)
+  end
+  
+  scope :find_by_author, -> (author_id) do 
+    find_index.where(Story.arel_table[:author_id].eq author_id).references(:story)
+  end
+  
+  scope :find_play, -> (story_id) do 
+    find_by_story(story_id)
+  end
+  
+  scope :find_private_play, -> (story_id, operators) do 
+    find_private(operators).by_story(story_id)
+  end
+  
   def supply_default
     self.story_id = nil
     self.sheet_id = nil
index 8b25d19..fae8c10 100644 (file)
@@ -13,6 +13,10 @@ class SystemPicture < Peta::SystemResource
   
   before_destroy :destroy_with_file
   
+  scope :find_index, -> do
+    self
+  end
+  
   def destroy_with_file
     PictureIO.system_picture_io.delete self.filename
   end
index 20c2250..d9872ca 100644 (file)
@@ -5,15 +5,23 @@ class User < ActiveRecord::Base
   # Include default devise modules. Others available are:
   # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
   devise :database_authenticatable, :registerable,
-         :recoverable, :rememberable, :trackable,  :validatable#, :confirmable
-
-  # Setup accessible (or protected) attributes for your model
-  attr_accessible :id, :name, :password, :password_confirmation, :remember_me , :email
+         :recoverable, :rememberable, :trackable,  :validatable, 
+         :omniauthable#, :confirmable
 
   def create_token
-    self.ensure_authentication_token
+    loop do
+      token = Devise.friendly_token
+      if token_suitable?(token)
+        self.authentication_token = token
+        break
+      end
+    end
     self.save
   end
+
+  def token_suitable?(token)
+    !self.class.exists?(authentication_token: token)
+  end
   
   def delete_token
     self.authentication_token = nil
@@ -42,4 +50,9 @@ class User < ActiveRecord::Base
     res
   end
   
+  private
+  def user_params
+    params.require(:user).permit(:email, :password, :password_confirmation, :remember_me, :authentication_token)
+  end
+  
 end
index 7060fb2..ebcde00 100644 (file)
@@ -10,6 +10,14 @@ class WritingFormat < Peta::Template
   validates :system_picture_id, :presence => true, :numericality => true, :existence => {:both => false}
   validates :settings, :presence => true
   
+  scope :find_index, -> do
+    self
+  end
+  
+  scope :find_by_system_picture, -> (system_picture_id) do 
+    find_index.where(system_picture_id: system_picture_id)
+  end
+  
   def supply_default
   end
   
@@ -31,7 +39,7 @@ def self.list
 end
 
   def self.enable_list include_available = false
-    r = WritingFormat.find(:all)
+    r = WritingFormat.all
     unless include_available
       r.delete_if {|wf|
         wf.enable? == false
index 91801bc..4e5eb40 100644 (file)
@@ -10,7 +10,7 @@
     - <%= h(manifest.magic_numbers['profile']['users']['caption']) %>\r
   </title>\r
   <%= stylesheet_link_tag "test" %>\r
-  <%= javascript_include_tag "application" %>\r
+  <%= javascript_include_tag "admin" %>\r
   <%= csrf_meta_tags %>\r
 </head>\r
 <body>\r
index ce898c3..315bcd7 100644 (file)
@@ -1,9 +1,9 @@
 <!DOCTYPE html>
 <html>
 <head>
-  <title><%= h(Manifest.manifest.magic_numbers['profile']['admins']['caption']) %></title>
+  <title><%= Manifest.manifest.magic_numbers['profile']['admins']['caption'] %></title>
   <%= stylesheet_link_tag "application" %>
-  <%= javascript_include_tag "application" %>
+  <%# javascript_include_tag "application" %>
   <%= javascript_include_tag "admin" %>
   <%= raw panel_editor_javascript_include_tags %>
   <%= csrf_meta_tags %>
index 2ba7b81..da08533 100644 (file)
@@ -13,7 +13,7 @@
 <% if @items.empty? -%>
   <h2><%= t('stories.play.empty') %></h2>
 <% else %>
-  <%= render @pager.template_name, :pager => @pager %>
+  <%= paginate @pager %>
   <% @items.each do |story_sheet| %>
     <% if story_sheet.sheet and story_sheet.sheet.visible?(@operators) -%>
       <%= render 'sheets/standard', :sheet => story_sheet.sheet, :operators => @operators %>
@@ -21,7 +21,7 @@
       sheet is hidden or deleted
     <% end %>
   <% end %>
-  <%= render @pager.template_name, :pager => @pager %>
+  <%= paginate @pager %>
 <% end %>
 
 <% if @item.own? @operators -%>
index 50d9e8d..86e8f35 100644 (file)
@@ -1,8 +1,7 @@
 <div class="filer">
   <%= render filer.header.template_name, :header => filer.header %>
   <%= render filer.body.template_name, :body => filer.body %>
-  <% if filer.page_status and filer.page_status.pageable? %>
-    <% pager = filer.page_status.pager %>
-    <%= render pager.template_name, :pager => pager %>
+  <% if filer.page_status  %>
+    <%= paginate filer.page_status %>
   <% end %>
 </div>
diff --git a/bin/bundle b/bin/bundle
new file mode 100644 (file)
index 0000000..e3c2f62
--- /dev/null
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby.exe
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
+load Gem.bin_path('bundler', 'bundle')
similarity index 100%
rename from script/encode64.rb
rename to bin/encode64.rb
similarity index 100%
rename from script/gem_builder.rb
rename to bin/gem_builder.rb
similarity index 100%
rename from script/ls_helper.rb
rename to bin/ls_helper.rb
similarity index 100%
rename from script/panel_import.rb
rename to bin/panel_import.rb
similarity index 100%
rename from script/preup.rb
rename to bin/preup.rb
diff --git a/bin/rails b/bin/rails
new file mode 100644 (file)
index 0000000..b9f8787
--- /dev/null
+++ b/bin/rails
@@ -0,0 +1,4 @@
+#!/usr/bin/env ruby.exe
+APP_PATH = File.expand_path('../../config/application',  __FILE__)
+require_relative '../config/boot'
+require 'rails/commands'
diff --git a/bin/rake b/bin/rake
new file mode 100644 (file)
index 0000000..f6ed5a2
--- /dev/null
+++ b/bin/rake
@@ -0,0 +1,4 @@
+#!/usr/bin/env ruby.exe
+require_relative '../config/boot'
+require 'rake'
+Rake.application.run
similarity index 100%
rename from script/sbt_helper.rb
rename to bin/sbt_helper.rb
similarity index 100%
rename from script/uploader.rb
rename to bin/uploader.rb
index 17af8a0..e358681 100644 (file)
@@ -4,7 +4,6 @@ require File.expand_path('../boot', __FILE__)
 require "active_record/railtie"
 require "action_controller/railtie"
 require "action_mailer/railtie"
-require "active_resource/railtie"
 require "sprockets/railtie"
 # require "rails/test_unit/railtie"
 require 'digest/md5'
index 4489e58..6b750f0 100644 (file)
@@ -1,6 +1,3 @@
-require 'rubygems'
-
-# Set up gems listed in the Gemfile.
 ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
 
-require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
+require 'bundler/setup' # Set up gems listed in the Gemfile.
index e16e8c4..72d98a8 100644 (file)
@@ -15,9 +15,6 @@ end
   # since you don't have to restart the web server when you make code changes.
   config.cache_classes = false
 
-  # Log error messages when you accidentally call methods on nil.
-  config.whiny_nils = true
-
   # Show full error reports and disable caching
   config.consider_all_requests_local       = true
   config.action_controller.perform_caching = false
@@ -28,9 +25,6 @@ end
   # Print deprecation notices to the Rails logger
   config.active_support.deprecation = :log
 
-  # Only use best-standards-support built into browsers
-  config.action_dispatch.best_standards_support = :builtin
-
   # Do not compress assets
   config.assets.compress = false
 
@@ -39,5 +33,7 @@ end
   
   # config.assets.digest = true
   # config.static_cache_control = "public, max-age=1"
+config.eager_load = false
+config.active_record.migration_error = :page_load
 end
 
index 12104b0..3e74fdd 100644 (file)
@@ -61,6 +61,8 @@ config.assets.precompile += %w( *.css *.js )
 
   # Send deprecation notices to registered listeners
   config.active_support.deprecation = :notify
+config.eager_load = true
+config.active_record.migration_error = :page_load
 end
 require 'aws/s3'
 require 'yaml'
index 3ceac7c..a3e7fdd 100644 (file)
@@ -11,9 +11,6 @@ Pettanr::Application.configure do
   config.serve_static_assets = true
   config.static_cache_control = "public, max-age=3600"
 
-  # Log error messages when you accidentally call methods on nil
-  config.whiny_nils = true
-
   # Show full error reports and disable caching
   config.consider_all_requests_local       = true
   config.action_controller.perform_caching = false
@@ -36,6 +33,8 @@ Pettanr::Application.configure do
 
   # Print deprecation notices to the stderr
   config.active_support.deprecation = :stderr
+config.eager_load = false
+config.active_record.migration_error = :page_load
 end
 
 module Pettanr
index e159c8a..80aff45 100644 (file)
@@ -1,5 +1,4 @@
 Pettanr::Application.routes.draw do
-
   devise_for :users, controllers: {sessions: 'user_sessions'}
   devise_for :admins
   devise_for :demand_users
@@ -548,9 +547,9 @@ Pettanr::Application.routes.draw do
   # match 'resource_pictures/full/:id(.:format)/' => 'resource_pictures#show'
   # match 'pictures/:subdir/:id(.:format)/' => 'pictures#show'
   #match 'scroll_panels/scroll/:id(.:format)' => 'scroll_panels#scroll'
-  match 'top/(:action)', :controller => 'top'
-  match 'home/(:action)', :controller => 'home'
-  match 'system/(:action)', :controller => 'system'
+  match 'top/(:action)', :controller => 'top', via: [:get]
+  match 'home/(:action)', :controller => 'home', via: [:get]
+  match 'system/(:action)', :controller => 'system', via: [:get, :post]
   #match 'authors/(:action(/:id))', :controller => 'authors'
   
   # Sample of named route:
@@ -601,5 +600,5 @@ Pettanr::Application.routes.draw do
 
   # This is a legacy wild controller route that's not recommended for RESTful applications.
   # Note: This route will make all actions in every controller accessible via GET requests.
-  match ':controller(/:action(/:id(.:format)))'
+  match ':controller(/:action(/:id(.:format)))', via: [:get, :post]
 end
diff --git a/config/secrets.yml b/config/secrets.yml
new file mode 100644 (file)
index 0000000..19d32f8
--- /dev/null
@@ -0,0 +1,8 @@
+development:\r
+  secret_key_base: 6809ff947425908bae66f4c4b2d9a88366d900609d88034914d5719ddf434123772c9cd26fd9d0a15fa080164c6fef77d74033a05de57f0694df0d52dad4e37a\r
+\r
+test:\r
+  secret_key_base: 6809ff947425908bae66f4c4b2d9a88366d900609d88034914d5719ddf434123772c9cd26fd9d0a15fa080164c6fef77d74033a05de57f0694df0d52dad4e37a\r
+\r
+production:\r
+  secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>\r
index 1806125..efae69d 100644 (file)
@@ -1,12 +1,11 @@
 class ConnectStory < ActiveRecord::Migration
   def up
-    pn = Panel.find :all
-    pn.each do |i|
+    pn = Panel.find_each do |i|
       c = i.comic_id
       t = i.t
       a = i.author_id
       s = i.id
-      st = Story.find(:first, :conditions => ['comic_id = ? and panel_id = ? and t = ?', c, s, t])
+      st = Story.where(['comic_id = ? and panel_id = ? and t = ?', c, s, t]).first
       st = Story.new(:comic_id => c, :panel_id => s, :t => t) unless st
       st.author_id = a
       st.save!
@@ -22,8 +21,7 @@ class ConnectStory < ActiveRecord::Migration
     add_column :panels, :comic_id, :integer, :null => false, :default => 0
     add_column :panels, :t, :integer, :null => false, :default => 0
     remove_column :panels, :publish
-    st = Story.find :all
-    st.each do |i|
+    st = Story.find_each do |i|
       c = i.comic_id
       t = i.t
       pn = Panel.find(i.panel_id)
index 37f9f54..b93852d 100644 (file)
@@ -1,12 +1,12 @@
 require Rails.root + 'config/environment'
 class CopyToScroll < ActiveRecord::Migration
   def up
-    ::Comic.find(:all).each do |i|
+    ::Comic.find_each do |i|
       attr = i.attributes
       attr.delete 'id'
       ::Scroll.create! attr
     end
-    ::Story.find(:all).each do |i|
+    ::Story.find_each do |i|
       attr = i.attributes
       attr.delete 'id'
       attr.delete 'x'
index 51eef28..35547c2 100644 (file)
@@ -1,6 +1,6 @@
 class ArtistBelongsToUserData < ActiveRecord::Migration
   def up
-    Artist.find(:all).each do |artist|
+    Artist.find_each do |artist|
       if artist.author_id
         artist.user_id = Author.find(artist.author_id).user_id
       else
index 7868231..6e87e62 100644 (file)
@@ -1,6 +1,6 @@
 class FixExtendSystemData < ActiveRecord::Migration
   def up
-    Balloon.find(:all).each do |balloon|
+    Balloon.find_each do |balloon|
       sbt = balloon.speech_balloon.speech_balloon_template
       if balloon.speech_balloon_template_classname == 'noname'
         balloon.speech_balloon_template_id = sbt.id
@@ -9,7 +9,7 @@ class FixExtendSystemData < ActiveRecord::Migration
       end
       balloon.save!
     end
-    Speech.find(:all).each do |speech|
+    Speech.find_each do |speech|
       sbt = speech.speech_balloon.speech_balloon_template
       if speech.speech_balloon_template_classname == 'noname'
         speech.speech_balloon_template_id = sbt.id
@@ -22,7 +22,7 @@ class FixExtendSystemData < ActiveRecord::Migration
       speech.boosts 'post'
       speech.save!
     end
-    License.find(:all).each do |license|
+    License.find_each do |license|
       lg = license.license_group
       if license.license_group_classname == 'noname'
         license.license_group_classname = lg.classname
index c1299f3..23a4bd6 100644 (file)
@@ -1,11 +1,11 @@
 class FixExtSysPictData < ActiveRecord::Migration
   def up
-    ResourcePicture.find(:all).each do |resource_picture|
+    ResourcePicture.find_each do |resource_picture|
       license = resource_picture.license
       resource_picture.credit_picture_settings = license.credit_picture_settings
       resource_picture.save!
     end
-    Picture.find(:all).each do |picture|
+    Picture.find_each do |picture|
       license = picture.license
       picture.credit_picture_settings = license.credit_picture_settings
       picture.save!
index b143c95..31e0128 100644 (file)
@@ -1,7 +1,7 @@
 class GenResourcePicturePictures < ActiveRecord::Migration
   def up
-    Picture.find(:all).each do |picture|
-      resource_picture_picture = ResourcePicturePicture.find(:first, {:conditions => ['picture_id = ?', picture.id]})
+    Picture.find_each do |picture|
+      resource_picture_picture = ResourcePicturePicture.where(['picture_id = ?', picture.id]}).first
       opid = picture.original_picture ? picture.original_picture.id : nil
       rpid = picture.original_picture.resource_picture ? picture.original_picture.resource_picture.id : nil
       if resource_picture_picture
diff --git a/db/migrate/20150702232018_add_t_on_license_groups.rb b/db/migrate/20150702232018_add_t_on_license_groups.rb
new file mode 100644 (file)
index 0000000..7ef9979
--- /dev/null
@@ -0,0 +1,5 @@
+class AddTOnLicenseGroups < ActiveRecord::Migration
+  def change
+    add_column :license_groups, :t, :integer, :null => false, :default => 0
+  end
+end
index 8fef236..be64fa1 100644 (file)
@@ -1,6 +1,6 @@
 module Locmare
   class Booster
-    attr :boost
+    attr :boost, :manifest
     
     def initialize manifest, item
       @manifest = manifest
index 4999935..d19add1 100644 (file)
@@ -15,7 +15,7 @@ module Locmare
           def to_hash
             {
               :type => :default, :total => @total, :total_page => self.total_page, 
-              :page => self.page, :page_size => self.limit
+              :page => self.page, :page_size => self.limit, :item_name => @list.item_name
             }
           end
           
index bc15c90..88fee26 100644 (file)
@@ -3,7 +3,7 @@ module Locmare
     class Base
       attr_accessor :list_group_name, :list_name, :operators, :options, :item_name, 
         :controller_manifest, :action_manifest, :list_manifest, :model, :table_name,
-        :page_status, :item_wheres, :list_wheres
+        :page_status, :item_wheres, :list_wheres, :wheres
       
       def initialize list_group_name, list_name, operators, options = {}
         @list_group_name = list_group_name
@@ -90,13 +90,7 @@ module Locmare
       
       def arel
         r = @model
-        @wheres.each do |key|
-          n = key + '_list_where'
-          r = r.where(@model.respond_to?(n) ? @model.__send__(n, self) : self.__send__(n))
-        end
-        r.includes(
-          self.include_hash
-        )
+        return @model.__send__('find_' + @action_name)
       end
       
       def items
index 846d60f..b2d4bf8 100644 (file)
@@ -31,6 +31,11 @@ module Locmare
         r
       end
       
+      def arel
+        r = @model
+        return @model.__send__('find_' + @action_name, self.filter_id)
+      end
+      
     end
     
   end
index 2dc905b..720cb2b 100644 (file)
@@ -32,6 +32,14 @@ module Manifest
           @parent
         end
         
+        def has_param
+          @param_id != 'none'
+        end
+        
+        def has_alias_action
+          @alias.any?
+        end
+        
         def alias_action
           s = @alias.split('.')
           c = ::Manifest.manifest.controllers[s[0]]
index c6779b6..dec4beb 100644 (file)
@@ -2,7 +2,7 @@ module Manifest
   module ControllerModule
     module ActionModule
       class ActionList < Base
-        attr :order, :direction, :default_page_size, :max_page_size
+        attr :order, :direction, :default_page_size, :max_page_size, :return_item_name
         
         def set_default
           super
@@ -17,12 +17,64 @@ module Manifest
           @direction = @args['direction'].to_i
           @default_page_size = @args['default_page_size']
           @max_page_size = @args['max_page_size']
+          @return_item_name = @args['return_item_name'] || @item_name
         end
         
         def a_arg_names
           super + ['order', 'direction', 'default_page_size', 'max_page_size']
         end
         
+        def find options = {}
+          self.finder(options).order(
+            self.order_sql(options[:order], options[:direction])
+          ).page(options[:page]).per(options[:page_size])
+        end
+        
+        def finder options = {}
+          finder_name = options[:finder] || 'find_' + @name
+          finder = if args = options[:param]
+            args = [args] unless options[:param].is_a?(Array)  # param to array
+            self.finder_model.__send__(finder_name, *args)
+          else
+            self.finder_model.__send__(finder_name)
+          end
+        end
+        
+        def finder_model
+          Manifest.manifest.models[@item_name].classify
+        end
+        
+        def return_model
+          Manifest.manifest.models[@return_item_name].classify
+        end
+        
+        def order_sql order, direction
+          order ||= self.order
+          direction ||= (self.direction < 0 ? :desc : :asc)
+          self.return_model.arel_table[order].__send__(direction)
+        end
+        
+        def page page
+          page.to_i
+          page = 1 if page < 1
+          page
+        end
+        
+        def page_size page_size
+          page_size ||= self.default_page_size
+          page_size = -1 if page_size < 0
+          page_size = self.max_page_size if page_size > self.max_page_size
+          page_size
+        end
+        
+        def limited?
+          self.max_page_size > 0
+        end
+        
+        def unlimited?
+          !self.limited?
+        end
+        
       end
       
     end
index 11050f4..65a10fa 100644 (file)
@@ -39,7 +39,7 @@ module Peta
     end
     
     def self.edit content_id, operators
-      content = self.find content_id, self.show_opt
+      content = self.find content_id
       raise ActiveRecord::Forbidden unless content.own?(operators)
       content
     end
index b6f2ca6..5e50ed5 100644 (file)
@@ -129,7 +129,7 @@ module Peta
     def self.show item_id, operators = nil
       opt = {}
       opt.merge!(self.show_opt)
-      item = self.find(item_id, opt)
+      item = self.find(item_id)
       item.boosts 'read'
       raise ActiveRecord::Forbidden if operators and item.visible?(operators) == false
       item
@@ -154,6 +154,10 @@ module Peta
     
     #InstanceMethods
     
+    def my_manifest
+      self.class.my_manifest
+    end
+    
     def singular
       self.class.singular
     end
@@ -251,6 +255,22 @@ module Peta
       true
     end
     
+    def permit_params params
+      attrs = self.class.permit_attributes
+      params.require(self.item_name.to_sym).permit(attrs)
+    end
+    
+    def self.permit_attributes
+      attrs = self.my_manifest.attributes.keys
+      self.child_models.each do |element_model|
+        name = self.my_manifest.associations.child_element_name(element_model) + '_attributes'
+        child_attrs = {}
+        child_attrs[name] = element_model.permit_attributes
+        attrs.push child_attrs
+      end
+      attrs
+    end
+    
     def editize?
       self.respond_to? :editor
     end
index 4ed0c3c..a736a71 100644 (file)
@@ -71,15 +71,15 @@ module Peta
     end
     
     def self.max_t binder_id
-      self.maximum(:t, :conditions => [self.binder_key + ' = ?', binder_id])
+      self.where([self.binder_key + ' = ?', binder_id]).maximum(:t)
     end
     
     def self.find_t binder_id, t
-      self.find(:first, :conditions => [self.binder_key + ' = ? and t = ?', binder_id, t])
+      self.where([self.binder_key + ' = ? and t = ?', binder_id, t]).first
     end
     
     def self.collect_t binder_id
-      r = self.find(:all, :conditions => [self.binder_key + ' = ?', binder_id], :order => 't')
+      r = self.where([self.binder_key + ' = ?', binder_id]).order('t')
       r.map {|sp| sp.t}
     end
     
index 7799ed3..1fdabd0 100644 (file)
@@ -7,7 +7,7 @@ module Peta
     # ClassMethods
     
     def self.edit system_resource_id, operators
-      system_resource = self.find system_resource_id, self.show_opt
+      system_resource = self.find system_resource_id
       raise ActiveRecord::Forbidden unless system_resource.own?(operators)
       system_resource
     end
index 097b306..e7faa6f 100644 (file)
@@ -7,7 +7,7 @@ module Peta
     # ClassMethods
     
     def self.enable_list
-      self.find(:all).delete_if {|i|
+      self.all.delete_if {|i|
         i.enable? == false
       }
     end
index e045a5c..ed9e2d2 100644 (file)
         "play": {\r
           "type": "list",\r
           "args": {\r
-            "alias": "scroll_panels.by_scroll",\r
+            "return_item_name": "scroll_panel",\r
             "order": "t",\r
             "direction": 1\r
           }\r
         "play": {\r
           "type": "list",\r
           "args": {\r
-            "alias": "comic_stories.by_comic",\r
+            "return_item_name": "comic_story",\r
             "max_page_size": -1,\r
             "order": "t",\r
             "direction": 1\r
         "play": {\r
           "type": "list",\r
           "args": {\r
-            "alias": "story_sheets.by_story",\r
+            "return_item_name": "story_sheet",\r
             "max_page_size": -1,\r
             "order": "t",\r
             "direction": 1\r
         "play": {\r
           "type": "list",\r
           "args": {\r
-            "alias": "sheet_panels.by_sheet",\r
+            "return_item_name": "sheet_panel",\r
             "order": "t",\r
             "direction": 1\r
           }\r
         "scrolls": {\r
           "type": "list",\r
           "args": {\r
-            "alias": "scrolls.index"\r
+            "item_name": "scroll"\r
           }\r
         },\r
         "scroll_panels": {\r
           "type": "list",\r
           "args": {\r
-            "alias": "scroll_panels.index"\r
+            "item_name": "scroll_panel"\r
           }\r
         },\r
         "comics": {\r
           "type": "list",\r
           "args": {\r
-            "alias": "comics.index"\r
+            "item_name": "comic"\r
           }\r
         },\r
         "comic_stories": {\r
           "type": "list",\r
           "args": {\r
-            "alias": "comic_stories.index"\r
+            "item_name": "comic_story"\r
           }\r
         },\r
         "stories": {\r
           "type": "list",\r
           "args": {\r
-            "alias": "stories.index"\r
+            "item_name": "story"\r
           }\r
         },\r
         "story_sheets": {\r
           "type": "list",\r
           "args": {\r
-            "alias": "story_sheets.index"\r
+            "item_name": "story_sheet"\r
           }\r
         },\r
         "sheets": {\r
           "type": "list",\r
           "args": {\r
-            "alias": "sheets.index"\r
+            "item_name": "sheet"\r
           }\r
         },\r
         "sheet_panels": {\r
           "type": "list",\r
           "args": {\r
-            "alias": "sheet_panels.index"\r
+            "item_name": "sheet_panel"\r
           }\r
         },\r
         "panels": {\r
           "type": "list",\r
           "args": {\r
-            "alias": "panels.index"\r
+            "item_name": "panel"\r
           }\r
         },\r
         "panel_pictures": {\r
           "type": "list",\r
           "args": {\r
-            "alias": "panel_pictures.index"\r
+            "item_name": "panel_picture"\r
           }\r
         },\r
         "speech_balloons": {\r
           "type": "list",\r
           "args": {\r
-            "alias": "speech_balloons.index"\r
+            "item_name": "speech_balloon"\r
           }\r
         },\r
         "speeches": {\r
           "type": "list",\r
           "args": {\r
-            "alias": "speeches.index"\r
+            "item_name": "speech"\r
           }\r
         },\r
         "balloons": {\r
           "type": "list",\r
           "args": {\r
-            "alias": "balloons.index"\r
+            "item_name": "balloon"\r
           }\r
         },\r
         "ground_pictures": {\r
           "type": "list",\r
           "args": {\r
-            "alias": "ground_pictures.index"\r
+            "item_name": "ground_picture"\r
           }\r
         },\r
         "ground_colors": {\r
           "type": "list",\r
           "args": {\r
-            "alias": "ground_colors.index"\r
+            "item_name": "ground_color"\r
           }\r
         },\r
         "original_pictures": {\r
           "type": "list",\r
           "args": {\r
-            "alias": "original_pictures.index"\r
+            "item_name": "original_picture"\r
           }\r
         },\r
         "resource_pictures": {\r
           "type": "list",\r
           "args": {\r
-            "alias": "resource_pictures.index"\r
+            "item_name": "resource_picture"\r
           }\r
         }\r
       }\r
diff --git a/script/cucumber b/script/cucumber
deleted file mode 100644 (file)
index 7fa5c92..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/usr/bin/env ruby
-
-vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
-if vendored_cucumber_bin
-  load File.expand_path(vendored_cucumber_bin)
-else
-  require 'rubygems' unless ENV['NO_RUBYGEMS']
-  require 'cucumber'
-  load Cucumber::BINARY
-end
diff --git a/script/rails b/script/rails
deleted file mode 100644 (file)
index 81eab02..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/usr/bin/env ruby.exe
-# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
-
-APP_PATH = File.expand_path('../../config/application',  __FILE__)
-require File.expand_path('../../config/boot',  __FILE__)
-require 'rails/commands'