OSDN Git Service

temp
[pettanr/pettanr.git] / app / controllers / comics_controller.rb
index 0539fe5..a95fa02 100644 (file)
@@ -10,28 +10,45 @@ class ComicsController < ApplicationController
   end
   before_filter :authenticate_admin!, :only => [:list, :browse]
 
-  def top
-    respond_to do |format|
-      format.html 
-    end
-  end
+  @@model = Comic
+  @@controller = Pettanr::ControllerManager.new @@model.item_name, Pettanr.manifest
+  @@filer_manager = Pettanr::FilerManager.new @@model.item_name, Pettanr.manifest
+  @@profiler_manager = Pettanr::ProfilerManager.new @@model.item_name, Pettanr.manifest
+  @@list_manager = Pettanr::ListManager.new @@model.item_name, Pettanr.manifest
   
   def index
-    @page = Comic.page params[:page]
-    @page_size = Comic.page_size params[:page_size]
-    @comics = Comic.list(@page, @page_size)
+    set_filer
+    @c = @@controller.open(params[:action])
+    @list = @c.list.open(@page, @page_size, @operators)
+    @items = @list.items
     respond_to do |format|
-      format.html # index.html.erb
-      format.json { render json: @comics.to_json(Comic.list_json_opt) }
+      format.html {
+        @filer = @@filer_manager.open(@items, @operators, @list.paginate)
+        render :template => 'system/filer', :locals => {
+          :filer => @filer
+        }
+      }
+      format.json { render json: @items.to_json(@@model.list_json_opt) }
+      format.atom 
+      format.rss
     end
   end
 
   def show
-    @comic = Comic.show(params[:id], [@user, @admin])
-
+    @item = Comic.show(params[:id], @operators)
     respond_to do |format|
-      format.html # show.html.erb
-      format.json { render json: @comic.to_json(Comic.show_json_opt) }
+      format.html {
+        @comic = @item
+      }
+      format.prof { 
+        @profiler = @@profiler_manager.open(@item, @operators)
+        render :template => 'system/prof', :locals => {
+          :profiler => @profiler
+        }
+      }
+      format.json { render json: @item.to_json(Comic.show_json_opt) }
+      format.atom 
+      format.rss 
     end
   end
 
@@ -90,6 +107,7 @@ class ComicsController < ApplicationController
         format.html { redirect_to @comic }
         format.json { render json: @comic.to_json(Comic.show_json_opt), status: :created, location: @comic }
       else
+        flash[:notice] = I18n.t('flash.notice.not_created', :model => Comic.model_name.human)
         format.html { render action: "new" }
         format.json { render json: @comic.errors, status: :unprocessable_entity }
       end
@@ -106,6 +124,7 @@ class ComicsController < ApplicationController
         format.html { redirect_to @comic }
         format.json { head :ok }
       else
+        flash[:notice] = I18n.t('flash.notice.not_updated', :model => Comic.model_name.human)
         format.html { render action: "edit" }
         format.json { render json: @comic.errors, status: :unprocessable_entity }
       end
@@ -117,7 +136,7 @@ class ComicsController < ApplicationController
     respond_to do |format|
       if @comic.destroy_with_story
         flash[:notice] = I18n.t('flash.notice.destroyed', :model => Comic.model_name.human)
-        format.html { redirect_to '/home/comic' }
+        format.html { redirect_to '/home/comics' }
         format.json { head :ok }
       else
         flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Comic.model_name.human)