OSDN Git Service

fix alias action
authoryasushiito <yas@pen-chan.jp>
Sun, 16 Nov 2014 07:37:27 +0000 (16:37 +0900)
committeryasushiito <yas@pen-chan.jp>
Sun, 16 Nov 2014 07:37:27 +0000 (16:37 +0900)
36 files changed:
app/assets/javascripts/work/controllers.js.coffee.erb
app/assets/javascripts/work/list_groups.js.coffee.erb
app/controllers/application_controller.rb
app/controllers/panels_controller.rb
app/controllers/scroll_panels_controller.rb
app/models/artist.rb
app/models/license.rb
app/models/resource_picture.rb
app/views/panels/index.html.erb
app/views/scrolls/play.html.erb
lib/local_manifest/list_group/list.rb
lib/local_manifest/list_group/list/base.rb
lib/local_manifest/list_group/list/play.rb [deleted file]
lib/local_manifest/list_group/list/private.rb [deleted file]
lib/local_manifest/list_group/list/where.rb [deleted file]
lib/local_manifest/list_group/list/where/auto.rb [deleted file]
lib/local_manifest/list_group/list/where/base.rb [deleted file]
lib/local_manifest/list_group/list/where/method.rb [deleted file]
lib/locmare/filer/body/file_body/file_item/caption/default/link/link.rb
lib/locmare/list_group.rb
lib/locmare/list_group/lib/page_status.rb
lib/locmare/list_group/lib/pager.rb
lib/locmare/list_group/list/base.rb
lib/locmare/list_group/list/filter.rb
lib/locmare/list_group/list/foreign_filter.rb
lib/locmare/list_group/list/private.rb [deleted file]
lib/locmare/list_group/list/through_filter.rb
lib/manifest/controller/action/base.rb
lib/manifest/controller/action/list.rb
lib/manifest/manifest.rb
lib/manifest_base/type_name_args.rb
lib/peta/content.rb
lib/peta/item.rb
lib/peta/leaf.rb
public/local_manifest.json
public/manifest.json

index d23b2ce..8f03709 100644 (file)
         args: {\r
           param_id: 'none',\r
           max_page_size: -1,\r
+          order: 't',\r
+          direction: 1\r
         },\r
       },\r
       by_panel: {\r
         args: {\r
           param_id: 'none',\r
           max_page_size: -1,\r
+          order: 't',\r
+          direction: 1\r
         },\r
       },\r
       by_system_picture: {\r
         args: {\r
           param_id: 'none',\r
           max_page_size: -1,\r
+          order: 't',\r
+          direction: 1\r
         },\r
       },\r
       by_resource_picture: {\r
         args: {\r
           param_id: 'none',\r
           max_page_size: -1,\r
+          order: 'name',\r
+          direction: 1\r
         },\r
       },\r
       by_license_group: {\r
         type: 'list',\r
         args: {\r
           param_id: 'suffix',\r
+          order: 'name',\r
+          direction: 1\r
         },\r
       },\r
       by_system_picture: {\r
       scrolls: {\r
         type: 'list',\r
         args: {\r
-          item_name: 'scroll',\r
-          param_id: 'none',\r
+          alias: 'scrolls.index',\r
         },\r
       },\r
       scroll_panels: {\r
         type: 'list',\r
         args: {\r
-          item_name: 'scroll_panel',\r
-          param_id: 'none',\r
+          alias: 'scroll_panels.index',\r
         },\r
       },\r
       comics: {\r
         type: 'list',\r
         args: {\r
-          item_name: 'comic',\r
-          param_id: 'none',\r
+          alias: 'comics.index',\r
         },\r
       },\r
       comic_stories: {\r
         type: 'list',\r
         args: {\r
-          item_name: 'comic_story',\r
-          param_id: 'none',\r
+          alias: 'comic_stories.index',\r
         },\r
       },\r
       stories: {\r
         type: 'list',\r
         args: {\r
-          item_name: 'story',\r
-          param_id: 'none',\r
+          alias: 'stories.index',\r
         },\r
       },\r
       story_sheets: {\r
         type: 'list',\r
         args: {\r
-          item_name: 'story_sheet',\r
-          param_id: 'none',\r
+          alias: 'story_sheets.index',\r
         },\r
       },\r
       sheets: {\r
         type: 'list',\r
         args: {\r
-          item_name: 'sheet',\r
-          param_id: 'none',\r
+          alias: 'sheets.index',\r
         },\r
       },\r
       sheet_panels: {\r
         type: 'list',\r
         args: {\r
-          item_name: 'sheet_panel',\r
-          param_id: 'none',\r
+          alias: 'sheet_panels.index',\r
         },\r
       },\r
       panels: {\r
         type: 'list',\r
         args: {\r
-          item_name: 'panel',\r
-          param_id: 'none',\r
+          alias: 'panels.index',\r
         },\r
       },\r
       panel_pictures: {\r
         type: 'list',\r
         args: {\r
-          item_name: 'panel_picture',\r
-          param_id: 'none',\r
+          alias: 'panel_pictures.index',\r
         },\r
       },\r
       speech_balloons: {\r
         type: 'list',\r
         args: {\r
-          item_name: 'speech_balloon',\r
-          param_id: 'none',\r
+          alias: 'speech_balloons.index',\r
         },\r
       },\r
       speeches: {\r
         type: 'list',\r
         args: {\r
-          item_name: 'speech',\r
-          param_id: 'none',\r
+          alias: 'speeches.index',\r
         },\r
       },\r
       balloons: {\r
         type: 'list',\r
         args: {\r
-          item_name: 'balloon',\r
-          param_id: 'none',\r
+          alias: 'balloons.index',\r
         },\r
       },\r
       ground_pictures: {\r
         type: 'list',\r
         args: {\r
-          item_name: 'ground_picture',\r
-          param_id: 'none',\r
+          alias: 'ground_pictures.index',\r
         },\r
       },\r
       ground_colors: {\r
         type: 'list',\r
         args: {\r
-          item_name: 'ground_color',\r
-          param_id: 'none',\r
+          alias: 'ground_colors.index',\r
         },\r
       },\r
       original_pictures: {\r
         type: 'list',\r
         args: {\r
-          item_name: 'original_picture',\r
-          param_id: 'none',\r
+          alias: 'original_pictures.index',\r
         },\r
       },\r
       resource_pictures: {\r
         type: 'list',\r
         args: {\r
-          item_name: 'resource_picture',\r
-          param_id: 'none',\r
+          alias: 'resource_pictures.index',\r
         },\r
       },\r
     },\r
index 1712ae6..97b3a4b 100644 (file)
         },\r
       },\r
       play: {\r
-        type: 'play',\r
+        type: 'filter',\r
+        args: {\r
+          filter_item_name: 'scroll',\r
+          item_wheres: ['index'],\r
+          list_wheres: ['play'],\r
+        },\r
       },\r
     },\r
   },\r
@@ -62,7 +67,7 @@
         },\r
       },\r
       play: {\r
-        type: 'play',\r
+        type: 'public',\r
       },\r
     },\r
   },\r
         type: 'filter',\r
       },\r
       play: {\r
-        type: 'play',\r
+        type: 'public',\r
       },\r
     },\r
   },\r
         type: 'filter',\r
       },\r
       play: {\r
-        type: 'play',\r
+        type: 'public',\r
       },\r
     },\r
   },\r
   original_pictures: {\r
     lists: {\r
       index: {\r
-        type: 'private',\r
+        type: 'public',\r
+        args: {\r
+          item_wheres: ['index'],\r
+          list_wheres: ['private'],\r
+        },\r
       },\r
     },\r
   },\r
     lists: {\r
       index: {\r
         type: 'public',\r
+        args: {\r
+          after_method_name: 'enable',\r
+        },\r
       },\r
       by_system_picture: {\r
         type: 'filter',\r
   home: {\r
     lists: {\r
       scrolls: {\r
-        type: 'private',\r
+        type: 'public',\r
+        args: {\r
+          item_wheres: ['index'],\r
+          list_wheres: ['private'],\r
+        },\r
       },\r
       scroll_panels: {\r
-        type: 'private',\r
+        type: 'public',\r
+        args: {\r
+          item_wheres: ['index'],\r
+          list_wheres: ['private'],\r
+        },\r
       },\r
       comics: {\r
-        type: 'private',\r
+        type: 'public',\r
+        args: {\r
+          item_wheres: ['index'],\r
+          list_wheres: ['private'],\r
+        },\r
       },\r
       comic_stories: {\r
-        type: 'private',\r
+        type: 'public',\r
+        args: {\r
+          item_wheres: ['index'],\r
+          list_wheres: ['private'],\r
+        },\r
       },\r
       stories: {\r
-        type: 'private',\r
+        type: 'public',\r
+        args: {\r
+          item_wheres: ['index'],\r
+          list_wheres: ['private'],\r
+        },\r
       },\r
       story_sheets: {\r
-        type: 'private',\r
+        type: 'public',\r
+        args: {\r
+          item_wheres: ['index'],\r
+          list_wheres: ['private'],\r
+        },\r
       },\r
       sheets: {\r
-        type: 'private',\r
+        type: 'public',\r
+        args: {\r
+          item_wheres: ['index'],\r
+          list_wheres: ['private'],\r
+        },\r
       },\r
       sheet_panels: {\r
-        type: 'private',\r
+        type: 'public',\r
+        args: {\r
+          item_wheres: ['index'],\r
+          list_wheres: ['private'],\r
+        },\r
       },\r
       panels: {\r
-        type: 'private',\r
+        type: 'public',\r
+        args: {\r
+          item_wheres: ['index'],\r
+          list_wheres: ['private'],\r
+        },\r
       },\r
       panel_pictures: {\r
-        type: 'private',\r
+        type: 'public',\r
+        args: {\r
+          item_wheres: ['index'],\r
+          list_wheres: ['private'],\r
+        },\r
       },\r
       speech_balloons: {\r
-        type: 'private',\r
+        type: 'public',\r
+        args: {\r
+          item_wheres: ['index'],\r
+          list_wheres: ['private'],\r
+        },\r
       },\r
       speeches: {\r
-        type: 'private',\r
+        type: 'public',\r
+        args: {\r
+          item_wheres: ['index'],\r
+          list_wheres: ['private'],\r
+        },\r
       },\r
       balloons: {\r
-        type: 'private',\r
+        type: 'public',\r
+        args: {\r
+          item_wheres: ['index'],\r
+          list_wheres: ['private'],\r
+        },\r
       },\r
       ground_pictures: {\r
-        type: 'private',\r
+        type: 'public',\r
+        args: {\r
+          item_wheres: ['index'],\r
+          list_wheres: ['private'],\r
+        },\r
       },\r
       ground_colors: {\r
-        type: 'private',\r
+        type: 'public',\r
+        args: {\r
+          item_wheres: ['index'],\r
+          list_wheres: ['private'],\r
+        },\r
       },\r
       original_pictures: {\r
-        type: 'private',\r
+        type: 'public',\r
+        args: {\r
+          item_wheres: ['index'],\r
+          list_wheres: ['private'],\r
+        },\r
       },\r
       resource_pictures: {\r
-        type: 'private',\r
+        type: 'public',\r
+        args: {\r
+          item_wheres: ['index'],\r
+          list_wheres: ['private'],\r
+        },\r
       },\r
     },\r
   },\r
index dd35650..8a751a7 100644 (file)
@@ -114,7 +114,7 @@ class ApplicationController < ActionController::Base
     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_controller.name, @my_action.action_name, @operators, params
+    @list = Locmare::ListGroup.list @my_action.controller.name, @my_action.action_name, @operators, params
   end
   
   def filer_list
@@ -146,8 +146,8 @@ class ApplicationController < ActionController::Base
   
   def set_play
     set_list
-    @binder_controller = Manifest.manifest.controllers[params[:controller].to_s]
-    @binder_action = @my_controller.actions[params[:action].to_s]
+    @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)
@@ -155,11 +155,13 @@ class ApplicationController < ActionController::Base
   
   def play_list
     @options = params
-    @options[:my_play] = @item.own?(@operators)
-    list_result = @list.open(@operators)
-    @items = list_result.items 
-    @count = list_result.count
-    @pager = list_result.paginate
+    if @item.own?(@operators)
+      @list.item_wheres = []
+      @list.list_wheres = ['private', 'play']
+    end
+    @items = @list.items #.map {|sp| sp.root }
+    @count = @list.total
+    @pager = @list.page_status.pager
   end
   
   def set_show
@@ -415,10 +417,9 @@ class ApplicationController < ActionController::Base
     }
   end
   
-  def assist_items controller_name, list_name
-    list = Locmare::ListGroup.list controller_name, list_name, @operators, {:id => @item.id, :page => 1, :page_size => 5}
-    list_result = list.open(@operators)
-    list_result.items
+  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
   end
   
   def set_image(file)
index 8d5d44b..f97960c 100644 (file)
@@ -13,9 +13,8 @@ class PanelsController < ApplicationController
   private
   def panel_list
     set_list
-    list_result = @list.open(@operators)
-    @items = list_result.items 
-    @pager = list_result.paginate
+    @items = @list.items 
+    @pager = @list.page_status.pager
     respond_to do |format|
       format.html 
       format.json { render json: @items.map{|i| i.attributes}.to_json }
@@ -136,11 +135,11 @@ class PanelsController < ApplicationController
       jsn = JSON.parse(params[:json])
     end
     @prm = params[:panel] || jsn
-    self.model.fold_extend_settings @prm
+    @item.class.fold_extend_settings @prm
     @item.attributes = @prm
-    @item.refresh
+    @item.refresh
     respond_to do |format|
-      if @item.store @item.packed_attributes, @operators
+      if @item.store @prm, @operators
         updated_html_format format
         updated_json_format format
       else
index e0fbda4..2f8b930 100644 (file)
@@ -4,7 +4,7 @@ class ScrollPanelsController < ApplicationController
     before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
   else
     before_filter :authenticate_reader, :only => [
-      :index, :show, :by_panel, :by_scroll, :by_author, :play :play
+      :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]
@@ -26,10 +26,6 @@ class ScrollPanelsController < ApplicationController
     filer_list
   end
   
-  def play
-    filer_list
-  end
-  
   def show
     set_show
     respond_to do |format|
index 83ecf69..e37ceb8 100644 (file)
@@ -18,7 +18,7 @@ class Artist < Peta::Owner
     Artist.find( :first, :conditions => ['author_id = ?', author.id])
   end
   
-  def self.list_where
+  def self.index_list_where
     'artists.provider_id is null'
   end
   
index 53e6344..ea2a716 100644 (file)
@@ -21,14 +21,10 @@ class License < Peta::SystemResource
     self.license_group.caption + '/' + self.caption
   end
   
-  def self.list_where
+  def self.index_list_where
     ''
   end
   
-  def self.list_order
-    'licenses.name'
-  end
-  
   def self.show_opt
     {:include => {:license_group => {}}}
   end
index 57c2a8e..b74b115 100644 (file)
@@ -95,14 +95,6 @@ class ResourcePicture < Peta::Content
     self.tmb_opt_img_tag
   end
   
-  def self.list_order
-    'resource_pictures.updated_at desc'
-  end
-  
-  def self.list_where
-    ''
-  end
-  
   def self.list_opt
     {:license => {}, :artist => {}, :picture => {} }
   end
index 8cd2db6..4c3e69c 100644 (file)
@@ -2,11 +2,11 @@
   <h2><%= t('panels.empty') %></h2>
 <% else %>
   <h2><%= link_to t('panels.filer'), main_app.panels_path(:mode => 'filer', :page => params[:page], :page_size => params[:page_size]) %></h2>
-  <%= paginate(@pager) %>
+  <%= render @pager.template_name, :pager => @pager %>
   <% @items.each do |panel| %>
     <%= render 'body', :panel => panel, :operators => @operators, :spot => nil %>
     <%= render 'panels/footer', :panel => panel, :operators => @operators %>
   <% end %>
+  <%= render @pager.template_name, :pager => @pager %>
   <%= render 'panels/licensed_pictures', :licensed_pictures => Panel.licensed_pictures(@items) %>
-  <%= paginate(@pager) %>
 <% end %>
index 90c22fb..9b3163a 100644 (file)
@@ -9,7 +9,7 @@
 <% if @items.empty? -%>
   <h2><%= t('scrolls.play.empty') %></h2>
 <% else %>
-  <%= paginate(@pager) %>
+  <%# paginate(@pager) %>
   <% @items.each do |scroll_panel| %>
     <% if scroll_panel.panel -%>
       <%= render 'panels/body', :panel => scroll_panel.panel, :operators => @operators, :spot => nil %>
@@ -17,7 +17,7 @@
     <%= render 'scroll_panels/footer', :scroll_panel => scroll_panel, :operators => @operators %>
   <% end %>
   <%= render 'panels/licensed_pictures', :licensed_pictures => ScrollPanel.licensed_pictures(@items) %>
-  <%= paginate(@pager) %>
+  <%# paginate(@pager) %>
 <% end %>
 <% if @item.own? @operators -%>
   <h3 id="editor"><%= t('editor') -%></h3>
index 1309e08..3ea261e 100644 (file)
@@ -1,5 +1,5 @@
 ManifestBase.require_modules "local_manifest/list_group/list/", 
-  %w|base public private system_resource filter through_filter foreign_filter play|
+  %w|base public system_resource filter through_filter foreign_filter|
 
 module LocalManifest
   module ListGroupModule
@@ -8,9 +8,8 @@ module LocalManifest
       
       def self.types
         {
-          'public' => PublicList, 'private' => PrivateList, 'system_resource' => SystemResourceList,
-          'filter' => FilterList, 'through_filter' => ThroughFilterList, 'foreign_filter' => ForeignFilterList, 
-          'play' => PlayList
+          'public' => PublicList, 'system_resource' => SystemResourceList,
+          'filter' => FilterList, 'through_filter' => ThroughFilterList, 'foreign_filter' => ForeignFilterList
         }
       end
       
index d0a0c41..91f7511 100644 (file)
@@ -1,24 +1,30 @@
 ManifestBase.require_modules "local_manifest/list_group/list/", 
-  %w|where includes|
+  %w|includes|
 
 module LocalManifest
   module ListGroupModule
     module ListModule
       class Base < ManifestBase::TypeNameArgs
-        attr :where, :includes
+        attr :list_wheres, :includes
         
         def set_default
           super
-          @args['where'] ||= {}
+          @args['list_wheres'] ||= []
           @args['includes'] ||= {}
         end
         
         def init
           super
-          @where = ManifestBase.load_type_args self, @args, 'where', WhereFactory
+          @item_wheres = @args['item_wheres']
+          @list_wheres = @args['list_wheres']
           @includes = ManifestBase.load_type_args self, @args, 'includes', IncludeFactory
         end
         
+        def item_wheres
+          return @item_wheres if @item_wheres
+          @item_wheres = @args['item_wheres'] || (self.model.content? ? ['index', 'public'] : ['index'])
+        end
+        
         def model_manifest
           ::Manifest.manifest.models[self.item_name]
         end
diff --git a/lib/local_manifest/list_group/list/play.rb b/lib/local_manifest/list_group/list/play.rb
deleted file mode 100644 (file)
index bdc688b..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-module LocalManifest
-  module ListGroupModule
-    module ListModule
-      class PlayList < Base
-        attr :filter_item_name, :filter_key
-        
-        def set_default
-          super
-          @args['filter_item_name'] ||= @name.gsub(/^by_/, '')
-          @args['filter_key'] ||= @args['filter_item_name'] + '_id'
-        end
-        
-        def init
-          super
-          @filter_item_name = @args['filter_item_name']
-          @filter_key = @args['filter_key']
-        end
-        
-      end
-    end
-  end
-end
diff --git a/lib/local_manifest/list_group/list/private.rb b/lib/local_manifest/list_group/list/private.rb
deleted file mode 100644 (file)
index 580ceee..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-module LocalManifest
-  module ListGroupModule
-    module ListModule
-      class PrivateList < Base
-      end
-      
-    end
-  end
-end
diff --git a/lib/local_manifest/list_group/list/where.rb b/lib/local_manifest/list_group/list/where.rb
deleted file mode 100644 (file)
index f27c8ae..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-ManifestBase.require_modules "local_manifest/list_group/list/where/", 
-  %w|base method auto|
-
-module LocalManifest
-  module ListGroupModule
-    module ListModule
-      class WhereFactory < ManifestBase::Factory
-        include WhereModule
-        
-        def self.types
-          {
-            'method' => WhereMethod, 'auto' => WhereAuto
-          }
-        end
-        
-        def self.default_type
-          'auto'
-        end
-        
-      end
-    end
-  end
-end
diff --git a/lib/local_manifest/list_group/list/where/auto.rb b/lib/local_manifest/list_group/list/where/auto.rb
deleted file mode 100644 (file)
index ae97558..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-module LocalManifest
-  module ListGroupModule
-    module ListModule
-      module WhereModule
-        class WhereAuto < Base
-          def set_default
-            super
-          end
-          
-          def init
-            super
-          end
-          
-          def method_name
-            if self.model.content?
-              'public_list_where'
-            else
-              'list_where'
-            end
-          end
-          
-          def conditions
-            yield self.method_name
-          end
-          
-        end
-        
-      end
-    end
-  end
-end
diff --git a/lib/local_manifest/list_group/list/where/base.rb b/lib/local_manifest/list_group/list/where/base.rb
deleted file mode 100644 (file)
index b84cae2..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-module LocalManifest
-  module ListGroupModule
-    module ListModule
-      module WhereModule
-        class Base < ManifestBase::TypeArgs
-          
-          def set_default
-            super
-          end
-          
-          def init
-            super
-          end
-          
-          def item_name
-            @parent.item_name
-          end
-          
-          def list_name
-            @parent.name
-          end
-          
-          def model
-            @parent.model
-          end
-          
-        end
-        
-      end
-    end
-  end
-end
diff --git a/lib/local_manifest/list_group/list/where/method.rb b/lib/local_manifest/list_group/list/where/method.rb
deleted file mode 100644 (file)
index 72e79de..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-module LocalManifest
-  module ListGroupModule
-    module ListModule
-      module WhereModule
-        class WhereMethod < Base
-          attr :method_name
-          
-          def set_default
-            super
-            @args['method_name'] ||= @parent.name + '_list_where'
-          end
-          
-          def init
-            super
-            @method_name = @args['method_name']
-          end
-          
-          def conditions
-            yield @method_name
-          end
-          
-        end
-        
-      end
-    end
-  end
-end
index 0e75bb1..b1ab894 100644 (file)
@@ -25,7 +25,8 @@ module Locmare
                   def url
                     controller_manifest = @item.class.my_controller
                     action_manifest = controller_manifest.actions[@link_manifest.action_name]
-                    action_manifest.url({'id' => @item.id.to_s})
+                    mani = action_manifest.original || action_manifest
+                    mani.url({'id' => @item.id.to_s})
                   end
                   
                 end
index dabc160..7db471a 100644 (file)
@@ -1,6 +1,5 @@
 require_dependency "locmare/list_group/list/base"
 require_dependency "locmare/list_group/list/public"
-require_dependency "locmare/list_group/list/private"
 require_dependency "locmare/list_group/list/system_resource"
 require_dependency "locmare/list_group/list/filter"
 require_dependency "locmare/list_group/list/through_filter"
@@ -14,7 +13,7 @@ module Locmare
     
     def self.types
       {
-        'public' => PublicList, 'private' => PrivateList, 'system_resource' => SystemResourceList,
+        'public' => PublicList, 'system_resource' => SystemResourceList,
         'filter' => FilterList, 'through_filter' => ThroughFilterList, 'foreign_filter' => ForeignFilterList, 
         'play' => PlayList
       }
index 0c58d0a..06e5395 100644 (file)
@@ -56,8 +56,16 @@ module Locmare
             @list.max_page_size
           end
           
+          def mod
+            @total % self.limit
+          end
+          
+          def adjust
+            self.mod == 0 ? 0 : 1
+          end
+          
           def total_page
-            (@total / self.limit) + 1
+            (@total / self.limit) + self.adjust
           end
           
           def pageable?
index cf5d4d0..7b5897a 100644 (file)
@@ -18,6 +18,7 @@ module Locmare
             @template_name = @template_dir + 'default'
             @controller = Manifest.manifest.controllers[@options['controller'].to_s]
             @action = @controller.actions[@options['action'].to_s]
+            @action = @action.original if @action.original
             
             @current_page = @page_status.page
             @per_page = @page_status.limit
index e9fbbc9..ab10b2f 100644 (file)
@@ -1,9 +1,9 @@
 module Locmare
   module ListGroupModule
     class Base
-      attr :list_group_name, :list_name, :options, :item_name, 
-        :controller_manifest, :action_manifest, :list_manifest, :model,
-        :page_status
+      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
       
       def initialize list_group_name, list_name, operators, options = {}
         @list_group_name = list_group_name
@@ -13,7 +13,8 @@ module Locmare
         
         @list_group_manifest = LocalManifest.manifest.list_groups[@list_group_name]
         @list_manifest = @list_group_manifest.lists[@list_name]
-        @where = @list_manifest.where
+        @item_wheres = @list_manifest.item_wheres
+        @list_wheres = @list_manifest.list_wheres
         @includes = @list_manifest.includes
         
         @controller_name = @list_group_name
@@ -28,7 +29,6 @@ module Locmare
       
       def init
         @page_status = LibModule::PageStatus.load self, self.total, @options
-        self.boost items
       end
       
       def model_name
@@ -76,38 +76,35 @@ module Locmare
         self.order + ' ' + self.direction
       end
       
-      def base_where_condition
-        method_name = @where.conditions do |name|
-          name
-        end
-        @model.__send__ method_name
-      end
-      
       def where_condition
-        base_where_condition
+        @item_wheres.map {|key| @model.__send__(key + '_list_where')}.compact.join(' and ')
       end
       
       def include_hash
         @includes.includes
       end
       
+      def arel
+        r = @model.where(self.where_condition)
+        @list_wheres.each do |key|
+          r = r.where(@model.__send__(key + '_list_where', self))
+        end
+        r.includes(
+          self.include_hash
+        )
+      end
+      
       def items
         return [] unless @page_status
-        @items ||= @model.where(
-          self.where_condition
-        ).includes(
-          self.include_hash
-        ).order(
+        @items ||= self.arel.order(
           self.order_by
         ).offset(@page_status.offset).limit(@page_status.limit)
+        self.boost
+        @items
       end
       
       def total
-        @model.where(
-          self.where_condition
-        ).includes(
-          self.include_hash
-        ).count
+        self.arel.count
         # return string : =>"25"
       end
       
@@ -117,9 +114,9 @@ module Locmare
         end
       end
       
-      def boost items
+      def boost
         manifests = self.boost_manifests
-        items.each do |item|
+        @items.each do |item|
           manifests.each do |boost_manifest|
             item.boost_manifest # ?
           end
index 97200dd..66084d3 100644 (file)
@@ -12,7 +12,7 @@ module Locmare
       end
       
       def where_condition
-        w = self.base_where_condition
+        w = super
         w += ' and ' unless w.blank?
         [w + @table_name + '.' + @filter_key + ' = ?', self.filter_id] 
       end
index c86a453..7eee78c 100644 (file)
@@ -8,7 +8,7 @@ module Locmare
       end
       
       def where_condition
-        w = self.base_where_condition
+        w = super
         w += ' and ' unless w.blank?
         [w + @filter_table_name + '.id' + ' = ?', self.filter_id] 
       end
diff --git a/lib/locmare/list_group/list/private.rb b/lib/locmare/list_group/list/private.rb
deleted file mode 100644 (file)
index 3b05203..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-module Locmare
-  module ListGroupModule
-    class PrivateList < Base
-      
-      def init
-        super
-      end
-      
-      def where_condition
-        owner_model = if @model.element?
-          @model.root_model
-        else
-          @model
-        end
-        case owner_model.owner_type
-        when :author
-          operator = @operators.author
-        when :artist
-          operator = @operators.artist
-        end
-        [owner_model.table_name + '.' + owner_model.owner_type.to_s + '_id = ?', operator.id]
-      end
-      
-      def items
-        @model.where(
-          self.where_condition
-        ).includes(
-          self.include_hash
-        ).order(
-          self.order_by
-        ).offset(@offset).limit(@limit)
-      end
-      
-      def count
-        @model.where(
-          self.where_condition
-        ).includes(
-          self.include_hash
-        ).count
-      end
-      
-    end
-    
-  end
-end
index 16d0fc2..930c236 100644 (file)
@@ -13,7 +13,7 @@ module Locmare
       end
       
       def where_condition
-        w = self.base_where_condition
+        w = super
         w += ' and ' unless w.blank?
         [w + @filter_table_name + '.id' + ' = ?', self.filter_id] 
       end
index ebed55a..2dc905b 100644 (file)
@@ -2,7 +2,7 @@ module Manifest
   module ControllerModule
     module ActionModule
       class Base < ManifestBase::TypeNameArgs
-        attr :param_id, :item_name, :action_name
+        attr :alias, :param_id, :item_name, :action_name, :original
         
         def set_default
           super
@@ -13,8 +13,29 @@ module Manifest
         def init
           super
           @action_name = @name
+          @alias = @args['alias']
           @item_name = @args['item_name']
           @param_id = @args['param_id']
+          # source manifest of alias manifest
+          @original = @args['original']
+        end
+        
+        def a_arg_names
+          []
+        end
+        
+        def b_arg_names
+          ['item_name', 'param_id']
+        end
+        
+        def controller
+          @parent
+        end
+        
+        def alias_action
+          s = @alias.split('.')
+          c = ::Manifest.manifest.controllers[s[0]]
+          c.actions[s[1]]
         end
         
         def path_name
index 3a54483..c6779b6 100644 (file)
@@ -2,7 +2,7 @@ module Manifest
   module ControllerModule
     module ActionModule
       class ActionList < Base
-        attr :alias, :order, :direction, :default_page_size, :max_page_size
+        attr :order, :direction, :default_page_size, :max_page_size
         
         def set_default
           super
@@ -13,17 +13,14 @@ module Manifest
         
         def init
           super
-          @alias = @args['alias']
           @order = @args['order'] || 'updated_at'
           @direction = @args['direction'].to_i
           @default_page_size = @args['default_page_size']
           @max_page_size = @args['max_page_size']
         end
         
-        def alias_action
-          s = @alias.split('.')
-          c = ::Manifest.manifest.controllers[s[0]]
-          c.actions[s[1]]
+        def a_arg_names
+          super + ['order', 'direction', 'default_page_size', 'max_page_size']
         end
         
       end
index 1fc9df7..bc56116 100644 (file)
@@ -26,6 +26,7 @@ module Manifest
       end
       @items = ManifestBase.load_type_name_args(self, @global_json, 'items', ItemFactory)
       @controllers = Controller.load(self, @global_json, 'controllers')
+      self.replace_action_alias
       @models = Model.load(self, @global_json, 'models')
     end
     
@@ -33,6 +34,36 @@ module Manifest
       @system_resources.init
     end
     
+    def replace_action_alias
+      replaces = {}
+      @controllers.each do |controller_name, controller_manifest|
+        controller_manifest.actions.each do |action_name, action_manifest|
+          next unless action_manifest.alias
+          alias_action = action_manifest.alias_action
+          next unless alias_action.type == action_manifest.type
+          args = {}
+          action_manifest.a_arg_names.each do |name|
+            args[name] = action_manifest.__send__(name) || alias_action.__send__(name)
+          end
+          action_manifest.b_arg_names.each do |name|
+            args[name] = alias_action.__send__(name) || action_manifest.__send__(name)
+          end
+          args['original'] = action_manifest
+          json = {'type' => alias_action.type, 'args' => args}
+          new_action_manifest = ControllerModule::ActionFactory.factory(
+            controller_manifest, action_manifest.name, json, action_manifest.module_name
+          )
+          replaces[controller_name] ||= {}
+          replaces[controller_name][action_name] = new_action_manifest
+        end
+      end
+      replaces.each do |controller_name, controller|
+        controller.each do |action_name, action_manifest|
+          ::Manifest.manifest.controllers[controller_name].actions[action_name] = action_manifest
+        end
+      end
+    end
+    
     def load_models_manifest
       @models.each do |model_name, model|
         # skip extend model.
index 688bbe6..3eb0394 100644 (file)
@@ -1,6 +1,6 @@
 module ManifestBase
   class TypeNameArgs
-    attr :parent, :name, :json, :type, :module_name
+    attr :parent, :name, :json, :type, :args, :module_name
     
     def initialize parent, name, json, module_name
       @parent = parent
index 5ff3f9b..083ac39 100644 (file)
@@ -35,7 +35,22 @@ module Peta
     end
     
     def self.public_list_where
-      ''
+      nil
+    end
+    
+    def self.private_list_where list
+      owner_model = if self.element?
+        self.root_model
+      else
+        self
+      end
+      case owner_model.owner_type
+      when :author
+        operator = list.operators.author
+      when :artist
+        operator = list.operators.artist
+      end
+      [owner_model.table_name + '.' + owner_model.owner_type.to_s + '_id = ?', operator.id]
     end
     
     def self.edit content_id, operators
index 0dadd32..7bb9cb6 100644 (file)
@@ -114,8 +114,8 @@ module Peta
       self.my_peta.extend_column? column_name
     end
     
-    def self.list_where
-      ''
+    def self.index_list_where
+      nil
     end
     
     def self.list_opt
index 6d987c6..d6e86b8 100644 (file)
@@ -65,6 +65,10 @@ module Peta
       self.table_name + '.t'
     end
     
+    def self.play_list_where list
+        [list.table_name + '.' + list.filter_key + ' = ?', list.filter_id] 
+    end
+    
     def self.new_t binder_id
       r = self.max_t(binder_id)
       r.blank? ? 0 : r.to_i + 1
index e8da658..cd2c50d 100644 (file)
           }\r
         },\r
         "play": {\r
-          "type": "play"\r
+          "type": "filter",\r
+          "args": {\r
+            "filter_item_name": "scroll",\r
+            "item_wheres": [\r
+              "index"\r
+            ],\r
+            "list_wheres": [\r
+              "play"\r
+            ]\r
+          }\r
         }\r
       }\r
     },\r
@@ -62,7 +71,7 @@
           }\r
         },\r
         "play": {\r
-          "type": "play"\r
+          "type": "public"\r
         }\r
       }\r
     },\r
           "type": "filter"\r
         },\r
         "play": {\r
-          "type": "play"\r
+          "type": "public"\r
         }\r
       }\r
     },\r
           "type": "filter"\r
         },\r
         "play": {\r
-          "type": "play"\r
+          "type": "public"\r
         }\r
       }\r
     },\r
     "original_pictures": {\r
       "lists": {\r
         "index": {\r
-          "type": "private"\r
+          "type": "public",\r
+          "args": {\r
+            "item_wheres": [\r
+              "index"\r
+            ],\r
+            "list_wheres": [\r
+              "private"\r
+            ]\r
+          }\r
         }\r
       }\r
     },\r
     "writing_formats": {\r
       "lists": {\r
         "index": {\r
-          "type": "public"\r
+          "type": "public",\r
+          "args": {\r
+            "after_method_name": "enable"\r
+          }\r
         },\r
         "by_system_picture": {\r
           "type": "filter"\r
     "home": {\r
       "lists": {\r
         "scrolls": {\r
-          "type": "private"\r
+          "type": "public",\r
+          "args": {\r
+            "item_wheres": [\r
+              "index"\r
+            ],\r
+            "list_wheres": [\r
+              "private"\r
+            ]\r
+          }\r
         },\r
         "scroll_panels": {\r
-          "type": "private"\r
+          "type": "public",\r
+          "args": {\r
+            "item_wheres": [\r
+              "index"\r
+            ],\r
+            "list_wheres": [\r
+              "private"\r
+            ]\r
+          }\r
         },\r
         "comics": {\r
-          "type": "private"\r
+          "type": "public",\r
+          "args": {\r
+            "item_wheres": [\r
+              "index"\r
+            ],\r
+            "list_wheres": [\r
+              "private"\r
+            ]\r
+          }\r
         },\r
         "comic_stories": {\r
-          "type": "private"\r
+          "type": "public",\r
+          "args": {\r
+            "item_wheres": [\r
+              "index"\r
+            ],\r
+            "list_wheres": [\r
+              "private"\r
+            ]\r
+          }\r
         },\r
         "stories": {\r
-          "type": "private"\r
+          "type": "public",\r
+          "args": {\r
+            "item_wheres": [\r
+              "index"\r
+            ],\r
+            "list_wheres": [\r
+              "private"\r
+            ]\r
+          }\r
         },\r
         "story_sheets": {\r
-          "type": "private"\r
+          "type": "public",\r
+          "args": {\r
+            "item_wheres": [\r
+              "index"\r
+            ],\r
+            "list_wheres": [\r
+              "private"\r
+            ]\r
+          }\r
         },\r
         "sheets": {\r
-          "type": "private"\r
+          "type": "public",\r
+          "args": {\r
+            "item_wheres": [\r
+              "index"\r
+            ],\r
+            "list_wheres": [\r
+              "private"\r
+            ]\r
+          }\r
         },\r
         "sheet_panels": {\r
-          "type": "private"\r
+          "type": "public",\r
+          "args": {\r
+            "item_wheres": [\r
+              "index"\r
+            ],\r
+            "list_wheres": [\r
+              "private"\r
+            ]\r
+          }\r
         },\r
         "panels": {\r
-          "type": "private"\r
+          "type": "public",\r
+          "args": {\r
+            "item_wheres": [\r
+              "index"\r
+            ],\r
+            "list_wheres": [\r
+              "private"\r
+            ]\r
+          }\r
         },\r
         "panel_pictures": {\r
-          "type": "private"\r
+          "type": "public",\r
+          "args": {\r
+            "item_wheres": [\r
+              "index"\r
+            ],\r
+            "list_wheres": [\r
+              "private"\r
+            ]\r
+          }\r
         },\r
         "speech_balloons": {\r
-          "type": "private"\r
+          "type": "public",\r
+          "args": {\r
+            "item_wheres": [\r
+              "index"\r
+            ],\r
+            "list_wheres": [\r
+              "private"\r
+            ]\r
+          }\r
         },\r
         "speeches": {\r
-          "type": "private"\r
+          "type": "public",\r
+          "args": {\r
+            "item_wheres": [\r
+              "index"\r
+            ],\r
+            "list_wheres": [\r
+              "private"\r
+            ]\r
+          }\r
         },\r
         "balloons": {\r
-          "type": "private"\r
+          "type": "public",\r
+          "args": {\r
+            "item_wheres": [\r
+              "index"\r
+            ],\r
+            "list_wheres": [\r
+              "private"\r
+            ]\r
+          }\r
         },\r
         "ground_pictures": {\r
-          "type": "private"\r
+          "type": "public",\r
+          "args": {\r
+            "item_wheres": [\r
+              "index"\r
+            ],\r
+            "list_wheres": [\r
+              "private"\r
+            ]\r
+          }\r
         },\r
         "ground_colors": {\r
-          "type": "private"\r
+          "type": "public",\r
+          "args": {\r
+            "item_wheres": [\r
+              "index"\r
+            ],\r
+            "list_wheres": [\r
+              "private"\r
+            ]\r
+          }\r
         },\r
         "original_pictures": {\r
-          "type": "private"\r
+          "type": "public",\r
+          "args": {\r
+            "item_wheres": [\r
+              "index"\r
+            ],\r
+            "list_wheres": [\r
+              "private"\r
+            ]\r
+          }\r
         },\r
         "resource_pictures": {\r
-          "type": "private"\r
+          "type": "public",\r
+          "args": {\r
+            "item_wheres": [\r
+              "index"\r
+            ],\r
+            "list_wheres": [\r
+              "private"\r
+            ]\r
+          }\r
         }\r
       }\r
     }\r
index da1b7f7..85f150a 100644 (file)
           "type": "list",\r
           "args": {\r
             "param_id": "none",\r
-            "max_page_size": -1\r
+            "max_page_size": -1,\r
+            "order": "t",\r
+            "direction": 1\r
           }\r
         },\r
         "by_panel": {\r
           "type": "list",\r
           "args": {\r
             "param_id": "none",\r
-            "max_page_size": -1\r
+            "max_page_size": -1,\r
+            "order": "t",\r
+            "direction": 1\r
           }\r
         },\r
         "by_system_picture": {\r
           "type": "list",\r
           "args": {\r
             "param_id": "none",\r
-            "max_page_size": -1\r
+            "max_page_size": -1,\r
+            "order": "t",\r
+            "direction": 1\r
           }\r
         },\r
         "by_resource_picture": {\r
           "type": "list",\r
           "args": {\r
             "param_id": "none",\r
-            "max_page_size": -1\r
+            "max_page_size": -1,\r
+            "order": "name",\r
+            "direction": 1\r
           }\r
         },\r
         "by_license_group": {\r
           "type": "list",\r
           "args": {\r
-            "param_id": "suffix"\r
+            "param_id": "suffix",\r
+            "order": "name",\r
+            "direction": 1\r
           }\r
         },\r
         "by_system_picture": {\r
         "scrolls": {\r
           "type": "list",\r
           "args": {\r
-            "item_name": "scroll",\r
-            "param_id": "none"\r
+            "alias": "scrolls.index"\r
           }\r
         },\r
         "scroll_panels": {\r
           "type": "list",\r
           "args": {\r
-            "item_name": "scroll_panel",\r
-            "param_id": "none"\r
+            "alias": "scroll_panels.index"\r
           }\r
         },\r
         "comics": {\r
           "type": "list",\r
           "args": {\r
-            "item_name": "comic",\r
-            "param_id": "none"\r
+            "alias": "comics.index"\r
           }\r
         },\r
         "comic_stories": {\r
           "type": "list",\r
           "args": {\r
-            "item_name": "comic_story",\r
-            "param_id": "none"\r
+            "alias": "comic_stories.index"\r
           }\r
         },\r
         "stories": {\r
           "type": "list",\r
           "args": {\r
-            "item_name": "story",\r
-            "param_id": "none"\r
+            "alias": "stories.index"\r
           }\r
         },\r
         "story_sheets": {\r
           "type": "list",\r
           "args": {\r
-            "item_name": "story_sheet",\r
-            "param_id": "none"\r
+            "alias": "story_sheets.index"\r
           }\r
         },\r
         "sheets": {\r
           "type": "list",\r
           "args": {\r
-            "item_name": "sheet",\r
-            "param_id": "none"\r
+            "alias": "sheets.index"\r
           }\r
         },\r
         "sheet_panels": {\r
           "type": "list",\r
           "args": {\r
-            "item_name": "sheet_panel",\r
-            "param_id": "none"\r
+            "alias": "sheet_panels.index"\r
           }\r
         },\r
         "panels": {\r
           "type": "list",\r
           "args": {\r
-            "item_name": "panel",\r
-            "param_id": "none"\r
+            "alias": "panels.index"\r
           }\r
         },\r
         "panel_pictures": {\r
           "type": "list",\r
           "args": {\r
-            "item_name": "panel_picture",\r
-            "param_id": "none"\r
+            "alias": "panel_pictures.index"\r
           }\r
         },\r
         "speech_balloons": {\r
           "type": "list",\r
           "args": {\r
-            "item_name": "speech_balloon",\r
-            "param_id": "none"\r
+            "alias": "speech_balloons.index"\r
           }\r
         },\r
         "speeches": {\r
           "type": "list",\r
           "args": {\r
-            "item_name": "speech",\r
-            "param_id": "none"\r
+            "alias": "speeches.index"\r
           }\r
         },\r
         "balloons": {\r
           "type": "list",\r
           "args": {\r
-            "item_name": "balloon",\r
-            "param_id": "none"\r
+            "alias": "balloons.index"\r
           }\r
         },\r
         "ground_pictures": {\r
           "type": "list",\r
           "args": {\r
-            "item_name": "ground_picture",\r
-            "param_id": "none"\r
+            "alias": "ground_pictures.index"\r
           }\r
         },\r
         "ground_colors": {\r
           "type": "list",\r
           "args": {\r
-            "item_name": "ground_color",\r
-            "param_id": "none"\r
+            "alias": "ground_colors.index"\r
           }\r
         },\r
         "original_pictures": {\r
           "type": "list",\r
           "args": {\r
-            "item_name": "original_picture",\r
-            "param_id": "none"\r
+            "alias": "original_pictures.index"\r
           }\r
         },\r
         "resource_pictures": {\r
           "type": "list",\r
           "args": {\r
-            "item_name": "resource_picture",\r
-            "param_id": "none"\r
+            "alias": "resource_pictures.index"\r
           }\r
         }\r
       }\r