OSDN Git Service

temp
authoryasushiito <yas@pen-chan.jp>
Sun, 8 Dec 2013 23:32:14 +0000 (08:32 +0900)
committeryasushiito <yas@pen-chan.jp>
Sun, 8 Dec 2013 23:32:14 +0000 (08:32 +0900)
16 files changed:
1  2 
app/assets/javascripts/configurations.js.coffee.erb
app/controllers/comics_controller.rb
app/controllers/home_controller.rb
app/controllers/scrolls_controller.rb
app/models/scroll.rb
app/views/scrolls/_form.html.erb
app/views/system/_filer.html.erb
app/views/system/filer.html.erb
app/views/system/prof.prof.erb
lib/manifest.rb
lib/manifest/controller.rb
lib/manifest/filer.rb
lib/manifest/list.rb
lib/manifest/manifest.rb
lib/manifest/profiler.rb
public/manifest.json

@@@ -2,17 -2,14 +2,31 @@@
  @configurations = {\r
    controllers: {\r
      scroll: {\r
-       item_name: 'scroll',\r
-       index: {\r
-         type: 'list',\r
-         list: {\r
-           list_name: 'public',\r
-           \r
+       model_name: 'scroll',\r
+       actions: {\r
+         index: {\r
++          type: 'list',\r
+           list: {\r
 -            list_name: 'public',\r
++            list_name: 'public_list',\r
++            \r
++          },\r
++        },\r
++        show: {\r
++          type: 'show',\r
++          name: 'show',\r
 +        },\r
 +      },\r
-       show: {\r
-         type: 'show',\r
-         name: 'show',\r
++    },\r
++    home: {\r
++      actions: {\r
++        scrolls: {\r
++          item_name: 'scroll',\r
++          type: 'list',\r
++          list: {\r
++            list_name: 'public_list',\r
+             \r
+           },\r
+         },\r
        },\r
      },\r
    },\r
    },\r
    lists: {\r
      scroll: {\r
--      default_page_size: 20, \r
 -      public_list: {\r
 -        type: 'public',\r
 -      },\r
 -      private_list: {\r
 -        type: 'private',\r
 -      },\r
 -      scroll_panels: {\r
 -        type: 'has_many',\r
 -        association_name: 'scroll_panels',\r
 -      },\r
 -      panels: {\r
 -        type: 'has_many',\r
 -        association_name: 'panels',\r
 -      },\r
 -      by_panel: {\r
 -        type: 'filter',\r
 -        filter_key: 'scroll_id',\r
 -        list: {\r
 -          method: 'filtered_list',\r
++      default_page_size: 25, \r
++      max_page_size: 100, \r
 +      lists: {\r
 +        public_list: {\r
 +          type: 'public',\r
 +        },\r
 +        private_list: {\r
 +          type: 'private',\r
 +        },\r
 +        scroll_panels: {\r
 +          type: 'has_many',\r
 +          association_name: 'scroll_panels',\r
 +        },\r
 +        panels: {\r
 +          type: 'has_many',\r
 +          association_name: 'panels',\r
 +        },\r
 +        by_panel: {\r
 +          type: 'throughfilter',\r
 +          filter_key: 'panel_id',\r
 +          list: {\r
 +            method: 'filtered_list',\r
 +          },\r
          },\r
        },\r
      },\r
    locals: {\r
      profilers: {\r
        scroll: {\r
++        lists: {\r
++          'scroll_panels.by_scroll': {\r
++            model_name: 'scroll_panel',\r
++            list_name: 'by_scroll',\r
++          }, \r
++        }, \r
          columns: [\r
            'id', \r
            'title', \r
              'author',\r
            ],\r
            has_many: [\r
--            'scroll_panels', \r
--            'panels'\r
++            'scroll_panels.by_scroll', \r
++            'panels.by_scroll'\r
            ],\r
          }, \r
        },\r
@@@ -11,15 -11,18 +11,15 @@@ class ComicsController < ApplicationCon
    before_filter :authenticate_admin!, :only => [:list, :browse]
  
    @@model = Comic
 -  @@controller = Pettanr::ControllerManager.new @@model.item_name, Pettanr.manifest
--  @@list_manager = Pettanr::Application::manifest.list_managers[@@model.item_name]
-   @@filer_manager = Pettanr::Application::manifest.list_managers[@@model.item_name]
-   @@profiler_manager = Pettanr::Application::manifest.list_managers[@@model.item_name]
 -  @@filer_manager = Pettanr::Application::manifest.filer_managers[@@model.item_name]
++  @@controller = Pettanr::Application::manifest.controller_managers[@@model.item_name]
+   @@profiler_manager = Pettanr::Application::manifest.profiler_managers[@@model.item_name]
+   
    def index
-     @list = @@list_manager.open('public', @page, @page_size, @operators)
-     @items = @list.items
 -    @c = @@controller.open(params[:action])
 -    @list = @@list_manager.open(@page, @page_size, @operators)
 -    @items = @c.items
++    @action = @@controller.open(params, @operators)
++    @items = @action.items 
      respond_to do |format|
        format.html {
--        @filer = @@filer_manager.open(@items, @operators, @list.paginate)
++        @filer = @action.filer
          render :template => 'system/filer', :locals => {
            :filer => @filer
          }
@@@ -41,19 -41,19 +41,20 @@@ class HomeController < ApplicationContr
    end
    
    def scrolls
--    @page = Author.page params[:page]
--    @page_size = Author.scroll_page_size params[:page_size]
--    @scrolls = Scroll.mylist(@author, @page, @page_size)
++    model = Scroll
++    controller = Pettanr::Application::manifest.controller_managers[model.item_name]
++    action_name = 'private'
++    @action = controller.open(action_name, params, @operators)
++    @items = @action.items 
  
      respond_to do |format|
        format.html {
--        @paginate = Scroll.mylist_paginate(@author, @page, @page_size)
++        @filer = @action.filer
          render :template => 'system/filer', :locals => {
--          :items => @scrolls, :model => Scroll, 
--          :roles => [@user, @admin], :pager => @paginate
++          :filer => @filer
          }
        }
--      format.json { render json: @scrolls.to_json(Scroll.list_json_opt) }
++      format.json { render json: @items.to_json(Scroll.list_json_opt) }
      end
    end
    
@@@ -11,11 -11,11 +11,20 @@@ class ScrollsController < ApplicationCo
    before_filter :authenticate_admin!, :only => [:list, :browse]
  
    @@model = Scroll
++  @@controller = Pettanr::Application::manifest.controller_managers[@@model.item_name]
++  @@profiler_manager = Pettanr::Application::manifest.profiler_managers[@@model.item_name]
++  
    def index
--    set_filer
--
++    action_name = params[:action]
++    @action = @@controller.open(action_name, params, @operators)
++    @items = @action.items 
      respond_to do |format|
--      format_filer format
++      format.html {
++        @filer = @action.filer
++        render :template => 'system/filer', :locals => {
++          :filer => @filer
++        }
++      }
        format.json { render json: @items.to_json(@@model.list_json_opt) }
        format.atom 
        format.rss
          end
        }
        format.json { render json: @item.to_json(Scroll.show_json_opt) }
--      format_prof format
++      format.prof { 
++        @profiler = @@profiler_manager.open(@item, @operators)
++        render :template => 'system/prof', :locals => {
++          :profiler => @profiler
++        }
++      }
        format.atom 
        format.rss 
      end
      @scroll = Scroll.new
      @scroll.supply_default 
      @scroll.attributes = params[:scroll]
--    @scroll.overwrite @author
++    @scroll.overwrite @operators
  
      respond_to do |format|
        if @scroll.save
@@@ -8,6 -8,6 +8,25 @@@ class Scroll < ActiveRecord::Bas
  
    before_validation :valid_encode
    
++  cattr_reader :singular, :plural
++  @@singular = 'Scroll'
++  @@plural = 'Scrolls'
++  def self.item_name
++    self.singular.underscore
++  end
++  
++  def item_name
++    self.class.item_name
++  end
++  
++  def self.path_name with_engine = false
++    self.plural.underscore
++  end
++  
++  def path_name 
++    self.class.path_name
++  end
++  
    def valid_encode
      ['title', 'description'].each do |a|
        next if attributes[a] == nil
@@@ -19,9 -19,9 +38,9 @@@
      self.visible = 0 if self.visible.blank?
    end
    
--  def overwrite au
--    return false unless au
--    self.author_id = au.id
++  def overwrite operators
++    return false unless operators.author
++    self.author_id = operators.author.id
    end
    
    def own? roles
      self.author_id == au.id
    end
    
--  def visible? roles
++  def visible? operators
      if MagicNumber['run_mode'] == 0
--      return false unless guest_role_check(roles)
++      return false unless operators.guest?
      else
--      return false unless reader_role_check(roles)
++      return false unless operators.resource_reader?
      end
--    return true if self.own?(roles)
      self.visible > 0
    end
    
      page_size
    end
    
++  def self.list_order
++    'scrolls.updated_at desc'
++  end
++  
    def self.list_where
      'scrolls.visible > 0'
    end
      {:include => {:scroll_panels => {:include => {:panel => {}}}, :author => {}}}
    end
    
--  def self.show sid, roles
++  def self.show sid, operators
      opt = {}
      opt.merge!(Scroll.show_opt)
      res = Scroll.find(sid, opt)
--    raise ActiveRecord::Forbidden unless res.visible?(roles)
++    raise ActiveRecord::Forbidden unless res.visible?(operators)
      res
    end
    
@@@ -21,7 -21,7 +21,7 @@@
    </div>
    <div class="field">
      <%= f.label :author_id %><br />
--    <%= h @author.name %>
++    <%= h @operators.author.name %>
    </div>
    <div class="row_break">
    </div>
@@@ -1,28 -1,28 +1,17 @@@
--<% model_name = model.to_s.underscore %>
--<% path_name = model.to_s.tableize %>
--<% filer_configurations = configurations['filers'][model.to_s.underscore] || {} %>
--<% symbol = filer_configurations['symbol'] || {} %>
--<% symbol_type = symbol['type'] || 'src' %>
--<% caption = filer_configurations['caption'] || {} %>
--<% caption_type = caption['type'] || 'column' %>
--<% summary = filer_configurations['summary'] || {} %>
--<% summary_type = summary['type'] || 'none' %>
--<% edit = filer_configurations['edit'] || {} %>
--<% edit_type = edit['type'] || 'default' %>
  <div>
--  <%= model.model_name.human %>
++  <%= filer.model.model_name.human %>
  </div>
  <ul class="filer">
--  <li id="" class="filer-head filer-head-<%= model.to_s.underscore -%>">
++  <li id="" class="filer-head filer-head-<%= filer.model_name -%>">
      <div id="" class="filer-head-symbol">
        symbol
      </div>
--    <% unless caption_type == 'none' %>
++    <% if filer.caption.visible? %>
        <div id="" class="filer-head-caption">
          caption
        </div>
      <% end %>
--    <% unless summary_type == 'none' %>
++    <% if filer.summary.visible? %>
        <div id="" class="filer-head-summary">
          summary
        </div>
      <div id="" class="filer-head-date">
        date
      </div>
--    <% unless edit_type == 'none' %>
++    <% if filer.edit.visible? %>
        <div id="" class="filer-head-edit">
          edit
        </div>
      <% end %>
    </li>
--  <% items.each do |item| %>
--    <li id="" class="filer-item filer-item-<%= model.to_s.underscore -%>">
++  <% filer.file_items.each do |file_item| %>
++    <li id="" class="filer-item filer-item-<%= filer.model_name -%>">
        <div id="" class="filer-item-symbol">
--        <%= filer.symbol item, self %>
--      </div>
--      <div id="" class="filer-item-caption">
--        <%= filer.caption item, self %>
--      </div>
--      <div id="" class="filer-item-summary">
--        <%= filer.summary item, self %>
++        <%= file_item.symbol self %>
        </div>
++      <% if filer.caption.visible? %>
++        <div id="" class="filer-item-caption">
++          <%= file_item.caption self %>
++        </div>
++      <% end %>
++      <% if filer.summary.visible? %>
++        <div id="" class="filer-item-summary">
++          <%= file_item.summary self %>
++        </div>
++      <% end %>
        <div id="" class="filer-item-icon">
--        <%= filer.icon item, self %>
++        <%= file_item.icon self %>
        </div>
        <div id="" class="filer-item-date">
--        <%= filer.date item, self %>
--      </div>
--      <div id="" class="filer-item-edit">
--        <%= filer.edit item, self %>
++        <%= file_item.date self %>
        </div>
++      <% if filer.edit.visible? %>
++        <div id="" class="filer-item-edit">
++          <%= file_item.edit self %>
++        </div>
++      <% end %>
      </li>
    <% end %>
  </ul>
  <div class="row_break">
  </div>
--<% if pager %>
--  <%= paginate(pager) %>
++<% if filer.paginate %>
++  <%= paginate(filer.paginate) %>
  <% end %>
@@@ -1,1 -1,1 +1,1 @@@
--<%= render 'system/filer', {:items => items, :model => model, :roles => roles, :pager => pager} %>
++<%= render 'system/filer', {:filer => filer} %>
@@@ -1,32 -1,32 +1,9 @@@
--<% item_name = item.class.to_s.underscore %>\r
--<% profile = configurations['profiles'][item_name] || {} %>\r
--<% model_conf = configurations['models'][item_name] || {} %>\r
--<% model_attributes = model_conf['attributes'] || {} %>\r
--<% model_associations = model_conf['associations'] || {} %>\r
--<% profile_associations = profile['associations'] || {} %>\r
--<%= render 'system/filer.html', :items => [item], :model => item.class, :roles => roles, :pager => nil %>\r
--<% profile['fields'].each do |field_name| %>\r
--  <% field_conf = model_attributes[field_name] || {} %>\r
++<%= render 'system/filer.html', :filer => profiler.header_filer %>\r
++<% profiler.each_column do |column| %>\r
    <div>\r
--    <%= item.class.human_attribute_name(field_name) %>\r
--    <% case field_conf['type'] %>\r
--    <% when 'datetime' %>\r
--      <% if item.attributes[field_name] %>\r
--        <%= l item.attributes[field_name] %>\r
--      <% else %>\r
--        <%= item.attributes[field_name] %>\r
--      <% end %>\r
--    <% else %>\r
--      <%= item.attributes[field_name] %>\r
--    <% end %>\r
--    <% if field_conf['source'] %>\r
--      <% case field_conf['source']['type'] %>\r
--      <% when 'magic_number' %>\r
--        (<%= t_selected_item(field_conf['source']['key'], item.attributes[field_name]) %>)\r
--      <% when 'model' %>\r
--      <% else %>\r
--      <% end %>\r
--    <% end %>\r
++    <%= column.label self %>\r
++    <%= column.disp_value self %>\r
++    <%= column.note self %>\r
    </div>\r
  <% end %>\r
  <div>\r
  <div>\r
    <%= 'belongs_to' %>\r
  </div>\r
--<% (profile_associations['belongs_to'] || []).each do |association_model_name| %>\r
--  <% belongs_to_conf = model_associations['belongs_to'][association_model_name] %>\r
--  <% parent_model = association_model_name.classify.constantize %>\r
--  <% id_column = belongs_to_conf['id_column'] %>\r
--  <% parent = nil %>\r
--  <% begin %>\r
--    <% parent = parent_model.show(item.attributes[id_column], roles) %>\r
--  <% rescue ActiveRecord::RecordNotFound %>\r
--  <% end %>\r
--  <% if parent %>\r
--    <%= render 'system/filer.html', :items => [parent], :model => parent.class, :roles => roles, :pager => nil %>\r
--  <% end %>\r
++<% profiler.each_belongs_to do |parent_filer| %>\r
++  <%= render 'system/filer.html', :filer => parent_filer %>\r
  <% end %>\r
  <div>\r
    <%= 'has_many' %>\r
  </div>\r
--<% (profile_associations['has_many'] || []).each do |association_model_name| %>\r
--  <% has_many_conf = model_associations['has_many'][association_model_name] %>\r
--  <% child_model = association_model_name.classify.constantize %>\r
--  <% foreign_key = has_many_conf['foreign_key'] %>\r
--  <% children = child_model.__send__(has_many_conf['list_method'], item.attributes['id'], roles, 1, 3) %>\r
--  <%= render 'system/filer.html', :items => children, :model => child_model, :roles => roles, :pager => nil %>\r
++<% profiler.each_belongs_to do |has_many_filer| %>\r
++  <%= render 'system/filer.html', :filer => has_many_filer %>\r
  <% end %>\r
  <div>\r
    <%= 'has_one' %>\r
  </div>\r
--<% (profile_associations['has_one'] || []).each do |association_model_name| %>\r
--  <% has_one_conf = model_associations['has_one'][association_model_name] %>\r
--  <% child_model = association_model_name.classify.constantize %>\r
--  <% foreign_key = has_one_conf['foreign_key'] %>\r
--  <% children = child_model.__send__(has_one_conf['list_method'], item.attributes['id'], roles, 1, 3) %>\r
--  <%= render 'system/filer.html', :items => children, :model => child_model, :roles => roles, :pager => nil %>\r
++<% profiler.each_has_one do |has_one_filer| %>\r
++  <%= render 'system/filer.html', :filer => has_one_filer %>\r
  <% end %>\r
diff --cc lib/manifest.rb
@@@ -1,4 -1,4 +1,5 @@@
  require "manifest/manifest"
++require "manifest/controller"
  require "manifest/model"
  require "manifest/list"
  require "manifest/profiler"
index 0000000,17e7ae3..74cb24d
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,41 +1,63 @@@
 -    class Controller
 -      def initialize item_name, conf, manifest
+ module Pettanr
+   class ControllerManager
 -        
 -        @model_name = @conf['odel_name']
++    class ActionList
++      def initialize action_name, item_name, operators, list, conf, manifest
++        @action_name = action_name
+         @item_name = item_name
++        @operators = operators
++        @list = list
+         @conf = conf
+         @manifest = manifest
 -      def items
 -        @model.private_list @operators, @page, @page_size
+       end
+       
 -      def paginate
 -        @model.list_paginate(@page, @page_size)
++      def items 
++        @items ||= @list.items
++      end
++      
++      def filer
++        @filer ||= @manifest.filer_managers[@item_name].open(@item_name, @items, @operators, @list.paginate)
+       end
+       
 -    def initialize item_name, manifest
 -      @item_name = item_namel
 -      @manifest = manifest
 -      @controller_manifest = manifest.controllers(@item_name)
++    end
++    
++    class ActionShow
++      def initialize action_name, item_name, conf, manifest
++        @action_name = action_name
++        @item_name = item_name
++        @conf = conf
++        @manifest = manifest
++        
+       end
+       
+     end
+     
 -      @list_conf.each {|action_name, conf|
++    attr :controller_manifest, :item_name, :manifest, :controller_conf, 
++      :actions
++    @@types = {'list' => ActionList, 'show' => ActionShow}
++    def initialize controller_manifest
++      @controller_manifest = controller_manifest
++      @item_name = @controller_manifest.item_name
++      @manifest = @controller_manifest.manifest
+       @controller_conf = @controller_manifest.conf
+       @actions = {}
 -        @actions[action_name] = Action.new(action_name, conf, @manifest) 
++      @controller_manifest.actions.each {|action_name, conf|
+         type = conf['type']
 -    def open action_name
 -      Controller.new(@actions[action_name], @controller_manifest, @manifest) 
++        @actions[action_name] = @@types[type]
+       }
+     end
+     
++    def open action_name, params, operators
++      name = if @controller_conf['item_name']
++        @controller_conf['item_name']
++      else
++        @item_name
++      end
++      list_name = @controller_manifest.list_name action_name
++      @list = @manifest.list_managers[name].open(list_name, params[:page], params[:page_size], operators)
++      @actions[action_name].new action_name, name, operators, @list, @controller_conf, @manifest
+     end
+     
+   end
+ end
@@@ -78,11 -78,11 +78,15 @@@ module Pettan
          'no.png'
        end
        
++      def visible?
++        self.link_method_name != :link_none
++      end
++      
        def render view, item, operators
          link = self.__send__(@link_method_name, view, item, operators)
          tag = self.__send__(@tag_method_name, view, item, operators)
          unless tag.blank?
--          link_to_unless link.blank?, tag, link
++          view.link_to_unless link.blank?, tag, link
          end
        end
        
        end
        
        def tag_column view, item, operators
--        item.attributes[caption['name']]
++        item.attributes[@caption_conf['name']]
        end
        
        def tag_method view, item, operators
--        item.__send__(caption['name']).to_s
++        item.__send__(@caption_conf['name']).to_s
        end
        
        def tag_else view, item, operators
          'no caption'
        end
        
++      def visible?
++        self.link_method_name != :link_none
++      end
++      
        def render view, item, operators
--        unless caption_type == 'none'
--          link = self.__send__(@link_method_name, view, item, operators)
--          tag = self.__send__(@tag_method_name, view, item, operators)
--          tag = 'no caption' if tag.blank? 
--          unless tag.blank?
--            link_to_unless link.blank?, tag, link
--          end
++        link = self.__send__(@link_method_name, view, item, operators)
++        tag = self.__send__(@tag_method_name, view, item, operators)
++        tag = 'no caption' if tag.blank? 
++        unless tag.blank?
++          view.link_to_unless link.blank?, tag, link
          end
        end
        
          view.render item.path_name + '/' + @summary_conf['name'], :item => item
        end
        
++      def visible?
++        self.type_method != :type_none
++      end
++      
        def render view, item, operators
--        self.__send__(@type_method, view, item)
++        self.__send__(@type_method, view, item, operators)
        end
        
      end
          @icon_conf = icon_conf || {}
        end
        
++      def visible?
++        true
++      end
++      
        def render view, item, operators
          view.link_to view.icon_tag(item.class.to_s, :object => item, :size => 64), 
            view.polymorphic_path(item, :format => :prof)
          @date_conf = date_conf || {}
        end
        
++      def visible?
++        true
++      end
++      
        def render view, item, operators
          view.distance_of_time_in_words_to_now item.updated_at
        end
          ''
        end
        
++      def visible?
++        self.type_method != :type_none
++      end
++      
        def render view, item, operators
          self.__send__(@type_method, view, item, operators)
        end
        
        end
        
--      attr :items, :file_items, :operators
--      def initialize items, operators, symbol, caption, summary, icon, date, edit, manifest
++      attr :items, :file_items, :operators, :paginate, :symbol, :caption, :summary, :icon, :date, :edit
++      def initialize item_name, items, operators, paginate, symbol, caption, summary, icon, date, edit, manifest
++        @item_name = item_name
          @items = items
++        @operators = operators
++        @paginate = paginate
++        @symbol = symbol
++        @caption = caption
++        @summary = summary
++        @icon = icon
++        @date = date
++        @edit = edit
          @manifest = manifest
          @file_items = @items.map {|item| 
            FileItem.new item, operators, symbol, caption, summary, icon, date, edit, manifest
          }
        end
++        
++      def model_name
++        @item_name
++      end
++      
++      def model
++        model_name.classify.constantize
++      end
++      
      end
      
++    attr :filer_manifest, :item_name, :manifest, :filer_conf, 
++      :symbol, :caption, :summary, :icon, :date, :edit
      def initialize filer_manifest
        @filer_manifest = filer_manifest
        @item_name = @filer_manifest.item_name
        @edit = Edit.new @filer_manifest.edit
      end
      
--    def open items, operators
--      Filer.new items, operators, @symbol, @caption, @summary, @icon, @date, @edit, @manifest
++    def open item_name, items, operators, paginate
++      Filer.new item_name, items, operators, paginate, @symbol, @caption, @summary, @icon, @date, @edit, @manifest
      end
      
    end
@@@ -6,7 -6,7 +6,9 @@@ module Pettan
          @item_name = item_name
          @conf = conf
          @manifest = manifest
--        @page = self.page_number(page || @conf['default_page_size']) 
++        @default_page_size = @conf['default_page_size'] || 25
++        @max_page_size = @conf['max_page_size'] || 100
++        @page = self.page_number(page) 
          @page_size = self.page_size page_size
          @operators = operators
          
          @offset = (@page -1) * @page_size
        end
        
--      def self.page_number prm = nil
++      def page_number prm = nil
          page = prm.to_i
          page = 1 if page < 1
          page
        end
        
--      def self.page_size prm
++      def page_size prm
          page_size = prm.to_i
--        page_size = self.max_page_size if page_size > self.max_page_size
--        page_size = self.default_page_size if page_size < 1
++        page_size = @max_page_size if page_size > @max_page_size
++        page_size = @default_page_size if page_size < 1
          page_size
        end
        
          @foreign_key = @association_conf['foreign_key']
        end
        
--      def where
--        [@model.list_where + 'comics.author_id = ?', me.id] 
++      def where parent_item
++        w = @model.list_where
++        w += ' and ' unless w.blank?
++        [w + @association_model_name + '.' + @foreign_key + ' = ?', parent_item.id] 
        end
        
--      def items item
--        method_name = 'list_by_' + item.item_name
--        @association_model.__send__ @method_name, item.id, @operators, @page, @page_size
++      def items parent_item
++        @model.where(self.where(parent_item)).includes(@model.list_opt).order(@model.list_order).offset(@offset).limit(@page_size)
        end
        
        def paginate
        @manifest = @list_manifest.manifest
        @list_conf = @list_manifest.conf
        @lists = {}
-       (@list_conf['lists'] || {}).each {|list_name, conf|
 -      @list_conf.each {|list_name, conf|
++      @list_manifest.lists.each {|list_name, conf|
          type = conf['type']
          @lists[list_name] = @@types[type]
        }
@@@ -1,31 -1,46 +1,48 @@@
  
  module Pettanr
    class Manifest
-     class Model
-       attr :item_name, :conf, :manifest, :attributes, :associations
+     class Controller
 -      attr :conf, :attributes, :associations
++      attr :item_name, :conf, :manifest, :model_name, :actions
        def initialize item_name, conf, manifest
          @item_name = item_name
          @conf = conf || {}
          @manifest = manifest
+         @model_name = @conf['model_name']
++        @actions = @conf['actions'] || {}
        end
        
-       def attributes
-         @model_manifest['attributes'] || {}
 -      def actions
 -        @model_manifest['actions'] || {}
++      def list_name action_name
++        a = @actions[action_name] || {}
++        l = a['list'] || {}
++        l['list_name']
        end
        
-       def associations
-         @conf['name'] || {}
+     end
+     
+     class Model
 -      attr :item_name, :conf, :manifest, :attributes, :associations
++      attr :item_name, :conf, :manifest, :attributes, :associations, :belongs_to, :has_many, :has_one
+       def initialize item_name, conf, manifest
+         @item_name = item_name
+         @conf = conf || {}
+         @manifest = manifest
 -      end
 -      
 -      def attributes
 -        @model_manifest['attributes'] || {}
 -      end
 -      
 -      def associations
 -        @conf['name'] || {}
++        
++        @attributes = @conf['attributes']
++        @associations = @conf['associations'] || {}
++        @belongs_to = @associations['belongs_to'] || {}
++        @has_many = @associations['has_many'] || {}
++        @has_one = @associations['has_one'] || {}
        end
        
      end
      
      class List
--      attr :item_name, :conf, :manifest, :default_page_size
++      attr :item_name, :conf, :manifest, :default_page_size, :lists
        def initialize item_name, conf, manifest
          @item_name = item_name
          @conf = conf || {}
          @manifest = manifest
          @default_page_size = @conf['default_page_size'] || 20
++        @lists = @conf['lists'] || {}
        end
        
      end
      end
      
      class Profiler
--      attr :item_name, :conf, :manifest, :columns, :belongs_to, :has_many, :has_one
++      attr :item_name, :conf, :manifest, :columns, :lists, :belongs_to, :has_many, :has_one
        def initialize item_name, conf, manifest
          @item_name = item_name
          @conf = conf || {}
          @manifest = manifest
          @columns = @conf['columns'] || {}
++        @lists = @conf['lists'] || {}
          @associations_conf = @conf['associations'] || {}
          @belongs_to = @associations_conf['belongs_to'] || []
          @has_many = @associations_conf['has_many'] || []
        
      end
      
 -    attr :licenses, :elements, :speech_balloon_templates, :writing_formats, :profile,
 -      :model_managers, :list_managers, :profiler_managers, :filer_managers, :form_managers
 +    attr :system_resources, :magic_numbers, :select_items,
-       :model_managers, :list_managers, :profiler_managers, :filer_managers, :form_managers
++      :controller_managers, :model_managers, :list_managers, :profiler_managers, :filer_managers, :form_managers
      def initialize manifest
        @manifest = manifest || {}
 +      @system_resources = SystemResources.new(@manifest['system_resources'])
 +      @magic_numbers = @manifest['magic_numbers']
 +      @select_items = @manifest['select_items']
+       @controllers = {}
        @models = {}
        @lists = {}
 -      @licenses = License.new(manifest) 
 -      @elements = Element.new(manifest)
 -      @speech_balloon_templates = SpeechBalloonTemplate.new(manifest)
 -      @writing_formats = WritingFormat.new(manifest)
 -      @profile = Profile.new(manifest)
        @profilers = {}
        @filers = {}
        @forms = {}
++      @controller_managers = {}
        @model_managers = {}
        @list_managers = {}
        @profiler_managers = {}
        @filer_managers = {}
        @form_managers = {}
 -        @controllers[item_name] = Controller.new(item_name, controller_conf, manifest) 
+       (@manifest['controllers'] || {}).each {|item_name, controller_conf|
++        @controllers[item_name] = Controller.new(item_name, controller_conf, self) 
++        @controller_managers[item_name] = Pettanr::ControllerManager.new @controllers[item_name]
+       }
        (@manifest['models'] || {}).each {|item_name, model_conf|
--        @models[item_name] = Model.new(item_name, model_conf, manifest
++        @models[item_name] = Model.new(item_name, model_conf, self
          @model_managers[item_name] = Pettanr::ModelManager.new @models[item_name]
        }
        (@manifest['lists'] || {}).each {|item_name, list_conf|
--        @lists[item_name] = List.new(item_name, list_conf, manifest
++        @lists[item_name] = List.new(item_name, list_conf, self
          @list_managers[item_name] = Pettanr::ListManager.new @lists[item_name]
        }
        @locals = @manifest['locals'] || {}
        (@locals['profilers'] || {}).each {|item_name, profiler_conf|
--        @profilers[item_name] = Profiler.new item_name, profiler_conf, manifest
++        @profilers[item_name] = Profiler.new item_name, profiler_conf, self
          @profiler_managers[item_name] = Pettanr::ProfilerManager.new @profilers[item_name]
        }
        (@locals['filers'] || {}).each {|item_name, filer_conf|
--        @filers[item_name] = Filer.new item_name, filer_conf, manifest
++        @filers[item_name] = Filer.new item_name, filer_conf, self
          @filer_managers[item_name] = Pettanr::FilerManager.new @filers[item_name]
        }
        (@locals['forms'] || {}).each {|item_name, form_conf|
--        @forms[item_name] = Form.new item_name, form_conf, manifest
++        @forms[item_name] = Form.new item_name, form_conf, self
          @form_managers[item_name] = Pettanr::FormManager.new @forms[item_name]
        }
      end
  
  module Pettanr
--  
    class ProfilerManager
--    class Ccolumn
--      def initialize item, attribute_name, attribute_conf
--        @attribute_conf = attribute_conf || {}
--      end
--      
--      def label
--        label = item.class.human_attribute_name(field_name)
--      end
--      
--      def value
--        case field_conf['type']
--        when 'datetime'
--          if item.attributes[field_name]
--            l item.attributes[field_name]
++    class Profiler
++      class Column
++        def initialize item_name, column_name, item, operators, manifest
++          @item_name = item_name
++          @column_name = column_name
++          @item = item
++          @operators = operators
++          @manifest = manifest
++          
++          @model = @item_name.classify.constantize
++          @model_attributes = @manifest.model(@item_name).attributes
++          @column_conf = @model_attributes[@column_name]
++        end
++        
++        def label view
++          @model.human_attribute_name(@column_name)
++        end
++        
++        def date?
++          case @column_conf['type']
++          when 'datetime'
++            if self.value
++              true
++            else
++              false
++            end
            else
--            item.attributes[field_name]
++            false
            end
--        else
--          item.attributes[field_name]
          end
--      end
--      
--      def note
--        if field_conf['source']
--          case field_conf['source']['type']
--          when 'magic_number'
--            t_selected_item(field_conf['source']['key'], item.attributes[field_name])
--          when 'model'
++        
++        def value
++          @item.attributes[@column_name]
++        end
++        
++        def disp_value view
++          if self.date?
++            view.l self.value
            else
++            self.value
            end
          end
--      end
--      
--    end
--    
--    class BelongsTo
--      def initialize belongs_to_conf
--        @belongs_to_conf = belongs_to_conf || {}
--      end
--      
--      def each item, operators
--        belongs_to_conf.each do |association_model_name|
--          model_belongs_to_conf = model_associations['belongs_to'][association_model_name]
--          parent_model = association_model_name.classify.constantize
--          id_column = model_belongs_to_conf['id_column']
--          parent = nil
--          begin
--            parent = parent_model.show(item.attributes[id_column], roles)
--          rescue ActiveRecord::RecordNotFound
++        
++        def note?
++          if @column_conf['source']
++            case @column_conf['source']['type']
++            when 'magic_number'
++              true
++            when 'model'
++              false
++            else
++              false
++            end
++          else
++            false
            end
--          if parent
--            yield parent
++        end
++        
++        def note view
++          if self.note?
++            '(' + view.t_selected_item(@column_conf['source']['key'], self.value) + ')'
++          else
            end
          end
++        
        end
--    end
--    
--    class HasMany
--      def initialize has_many_conf
--        @has_many_conf = has_many_conf || {}
++      
++      def initialize item_name, item, operators, conf, manifest
++        @item_name = item_name
++        @item = item
++        @operators = operators
++        @conf = conf
++        @manifest = manifest
++        
++        @lists = @manifest.profiler(@item_name).lists
++        @belongs_to_conf = @manifest.profiler(@item_name).belongs_to
++        @has_many_conf = @manifest.profiler(@item_name).has_many
++        @has_one_conf = @manifest.profiler(@item_name).has_one
        end
        
--      def each item, operators
--        @has_many_conf.each do |association_model_name|
--          model_has_many_conf = model_associations['has_many'][association_model_name]
--          child_model = association_model_name.classify.constantize
--          foreign_key = model_has_many_conf['foreign_key']
--          children = child_model.__send__(model_has_many_conf['list_method'], item.attributes['id'], operators, 1, 3)
--          yield children, child_model
--        end
++      def modelize str
++        str.classify.constantize
        end
        
--    end
--    
--    class HasOne
--      def initialize has_one_conf
--        @has_one_conf = has_one_conf || {}
++      def header_filer
++        @manifest.filer_managers[@item_name].open @item_name, [@item], @operators, nil
        end
        
--      def each item, operators
--        @has_one_conf.each do |association_model_name|
--          model_has_one_conf = model_associations['has_one'][association_model_name]
--          child_model = association_model_name.classify.constantize
--          foreign_key = model_has_one_conf['foreign_key']
--          children = child_model.__send__(model_has_one_conf['list_method'], item.attributes['id'], operators, 1, 3)
--          yield children, child_model
++      def each_column
++        @conf['columns'].each do |column_name|
++          column = Column.new @item_name, column_name, @item, @operators, @manifest
++          yield column
          end
        end
        
--    end
--    
--    class Profiler
--      def initialize item
--        @attribute_conf = attribute_conf || {}
++      def parent_item parent_model, model_belongs_to_conf
++        r = nil
++        id_column = model_belongs_to_conf['id_column']
++        begin
++          r = parent_model.show(@item.attributes[id_column], @operators)
++        rescue ActiveRecord::RecordNotFound
++        end
++        r
++      end
++      
++      def each_belongs_to
++        @belongs_to_conf.each do |association_model_name|
++          model_belongs_to_conf = @manifest.model(@item_name).belongs_to[association_model_name]
++          parent_model = self.modelize association_model_name
++          parent = self.parent_item parent_model, model_belongs_to_conf
++          if parent
++            parent_filer = @manifest.filer_managers[@item_name].open @item_name, [@item], @operators, nil
++            yield parent_filer
++          end
++        end
        end
        
--      def header
--        ender 'system/filer.html', :items => [item], :model => item.class, :roles => roles, :pager => nil 
++      def each_has_many
++        @has_many_conf.each do |profiler_list_name|
++          model_name = @lists['model_name']
++          list_name = @lists['list_name']
++          list = @manifest.list_managers[model_name].open(list_name, 1, 3, @operators)
++          items = list.items 
++          has_many_filer = @manifest.filer_managers[model_name].open model_name, items, @operators, nil
++          yield has_many_filer
++        end
        end
        
--      def each_column
--        profiler_conf['fields'].each do |field_name|
--          yield label, value, note
++      def each_has_one 
++        @has_one_conf.each do |profiler_list_name|
++          list = @manifest.list_managers[@item_name].open(profiler_list_name, 1, 1, @operators)
++          items = list.items 
++          has_one_filer = @manifest.filer_managers[@item_name].open @item_name, items, @operators, nil
++          yield has_one_filer
          end
        end
        
        @item_name = @profiler_manifest.item_name
        @manifest = profiler_manifest.manifest
        @profiler_conf = @profiler_manifest.conf
--      @associations_conf = @profiler_conf['associations'] || {}
--      @belongs_to = BelongsTo.new @profiler_manifest.belongs_to
--      @bhas_many = HasMany.new @profiler_manifest.has_many
--      @has_one = HasOne.new @profiler_manifest.has_one
      end
      
--    def open
--      Profiler.new item
--    end
--    
--    def render view, operators
--      @belongs_to.each(item, operators) do |parent|
--        render 'system/filer.html', :items => [parent], :model => parent.class, :operators => operators, :pager => nil
--      end
--      @has_many.each(item, operators) do |items, child_model|
--        #child_model.filer.list operators, , 1, 3, items
--        render 'system/filer.html', :items => items, :model => child_model, :operators => operators, :pager => nil
--      end
--      @has_one.each(item, operators) do |items, child_model|
--        render 'system/filer.html', :items => items, :model => child_model, :operators => operators, :pager => nil
--      end
++    def open item, operators
++      Profiler.new @item_name, item, operators, @profiler_conf, @manifest
      end
      
    end
@@@ -1,10 -1,10 +1,28 @@@
  {\r
      "controllers": {\r
          "scroll": {\r
--            "item_name": "scroll",\r
--            "index": {\r
--                "list": {\r
--                    "list_name": "public"\r
++            "model_name": "scroll",\r
++            "actions": {\r
++                "index": {\r
++                    "type": "list",\r
++                    "list": {\r
++                        "list_name": "public_list"\r
++                    }\r
++                },\r
++                "show": {\r
++                    "type": "show",\r
++                    "name": "show"\r
++                }\r
++            }\r
++        },\r
++        "home": {\r
++            "actions": {\r
++                "scrolls": {\r
++                    "item_name": "scroll",\r
++                    "type": "list",\r
++                    "list": {\r
++                        "list_name": "public_list"\r
++                    }\r
                  }\r
              }\r
          }\r
                      }\r
                  }\r
              },\r
++            "filters": {\r
++                "by_author": {\r
++                    "type": "filter",\r
++                    "key": "author_id"\r
++                }\r
++            },\r
++            "through_filters": {\r
++                "by_panel": {\r
++                    "through": "scroll_panels",\r
++                    "key": "panel_id"\r
++                }\r
++            },\r
              "attributes": {\r
                  "id": {\r
                      "type": "number",\r
      },\r
      "lists": {\r
          "scroll": {\r
-             "default_page_size": 20,\r
 -            "public_list": {\r
 -                "type": "public"\r
 -            },\r
 -            "private_list": {\r
 -                "type": "private"\r
 -            },\r
 -            "scroll_panels": {\r
 -                "type": "has_many",\r
 -                "association_name": "scroll_panels"\r
 -            },\r
 -            "panels": {\r
 -                "type": "has_many",\r
 -                "association_name": "panels"\r
 -            },\r
 -            "by_panel": {\r
 -                "type": "filter",\r
 -                "filter_key": "scroll_id",\r
 -                "list": {\r
 -                    "method": "filtered_list"\r
++            "default_page_size": 25,\r
++            "max_page_size": 100,\r
 +            "lists": {\r
 +                "public_list": {\r
 +                    "type": "public"\r
 +                },\r
 +                "private_list": {\r
 +                    "type": "private"\r
 +                },\r
 +                "scroll_panels": {\r
 +                    "type": "has_many",\r
 +                    "association_name": "scroll_panels"\r
 +                },\r
 +                "panels": {\r
 +                    "type": "has_many",\r
 +                    "association_name": "panels"\r
 +                },\r
 +                "by_panel": {\r
++                    "type": "throughfilter",\r
++                    "filter_key": "panel_id",\r
++                    "list": {\r
++                        "method": "filtered_list"\r
++                    }\r
++                }\r
++            }\r
++        },\r
++        "scroll_panel": {\r
++            "default_page_size": 20,\r
++            "lists": {\r
++                "public_list": {\r
++                    "type": "public"\r
++                },\r
++                "private_list": {\r
++                    "type": "private"\r
++                },\r
++                "by_scroll": {\r
 +                    "type": "filter",\r
 +                    "filter_key": "scroll_id",\r
 +                    "list": {\r
 +                        "method": "filtered_list"\r
 +                    }\r
++                },\r
++                "by_panel": {\r
++                    "type": "filter",\r
++                    "filter_key": "panel_id",\r
++                    "list": {\r
++                        "method": "filtered_list"\r
++                    }\r
++                }\r
++            }\r
++        },\r
++        "comic": {\r
++            "default_page_size": 20,\r
++            "lists": {\r
++                "public_list": {\r
++                    "type": "public"\r
++                },\r
++                "private_list": {\r
++                    "type": "private"\r
++                },\r
++                "stories": {\r
++                    "type": "has_many",\r
++                    "association_name": "stories"\r
++                }\r
++            }\r
++        },\r
++        "story": {\r
++            "default_page_size": 20,\r
++            "lists": {\r
++                "public_list": {\r
++                    "type": "public"\r
++                },\r
++                "private_list": {\r
++                    "type": "private"\r
++                },\r
++                "story_sheets": {\r
++                    "type": "has_many",\r
++                    "association_name": "story_sheets"\r
++                },\r
++                "sheets": {\r
++                    "type": "has_many",\r
++                    "association_name": "sheets"\r
++                },\r
++                "by_comic": {\r
++                    "type": "filter",\r
++                    "filter_key": "comic_id",\r
++                    "list": {\r
++                        "method": "filtered_list"\r
++                    }\r
++                }\r
++            }\r
++        },\r
++        "story_sheet": {\r
++            "default_page_size": 20,\r
++            "lists": {\r
++                "public_list": {\r
++                    "type": "public"\r
++                },\r
++                "private_list": {\r
++                    "type": "private"\r
++                },\r
++                "by_story": {\r
++                    "type": "filter",\r
++                    "filter_key": "story_id",\r
++                    "list": {\r
++                        "method": "filtered_list"\r
++                    }\r
++                },\r
++                "by_sheet": {\r
++                    "type": "filter",\r
++                    "filter_key": "sheet_id",\r
++                    "list": {\r
++                        "method": "filtered_list"\r
++                    }\r
++                }\r
++            }\r
++        },\r
++        "sheet": {\r
++            "default_page_size": 20,\r
++            "lists": {\r
++                "public_list": {\r
++                    "type": "public"\r
++                },\r
++                "private_list": {\r
++                    "type": "private"\r
++                },\r
++                "story_sheets": {\r
++                    "type": "has_many",\r
++                    "association_name": "story_sheets"\r
++                },\r
++                "sheet_panels": {\r
++                    "type": "has_many",\r
++                    "association_name": "sheet_panels"\r
++                }\r
++            }\r
++        },\r
++        "sheet_panel": {\r
++            "default_page_size": 20,\r
++            "lists": {\r
++                "public_list": {\r
++                    "type": "public"\r
++                },\r
++                "private_list": {\r
++                    "type": "private"\r
++                },\r
++                "by_sheet": {\r
++                    "type": "filter",\r
++                    "filter_key": "sheet_id",\r
++                    "list": {\r
++                        "method": "filtered_list"\r
++                    }\r
++                },\r
++                "by_panel": {\r
++                    "type": "filter",\r
++                    "filter_key": "panel_id",\r
++                    "list": {\r
++                        "method": "filtered_list"\r
++                    }\r
                  }\r
              }\r
          },\r
--        "scroll_panel": {},\r
--        "comic": {},\r
--        "story": {},\r
--        "story_sheet": {},\r
--        "sheet": {},\r
--        "sheet_panel": {},\r
          "panel": {},\r
          "panel_picture": {},\r
          "speech_balloon": {},\r
      "locals": {\r
          "profilers": {\r
              "scroll": {\r
++                "lists": {\r
++                    "scroll_panels.by_scroll": {\r
++                        "model_name": "scroll_panel",\r
++                        "list_name": "by_scroll"\r
++                    }\r
++                },\r
                  "columns": [\r
                      "id",\r
                      "title",\r
                          "author"\r
                      ],\r
                      "has_many": [\r
--                        "scroll_panels",\r
--                        "panels"\r
++                        "scroll_panels.by_scroll",\r
++                        "panels.by_scroll"\r
                      ]\r
                  }\r
              },\r