OSDN Git Service

t#31223:add them contents list for author and artist
[pettanr/pettanr.git] / app / controllers / home_controller.rb
index cc3895a..6d4babc 100644 (file)
@@ -1,8 +1,11 @@
 class HomeController < ApplicationController
-  
-  def start
-    
-  end
+  layout 'test' if MagicNumber['test_layout']
+  before_filter :authenticate_user, :only => [
+    :index, :show, :profile, :configure, :create_token, :delete_token, 
+    :comic, :story, :panel, :resource_picture, :panel_picture, :panel_color, :ground_picture, :ground_color
+  ]
+  before_filter :authenticate_author, :only => [:comic, :story, :panel, :panel_picture, :panel_color, :ground_picture, :ground_color]
+  before_filter :authenticate_artist, :only => [:resource_picture]
   
   def index
   end
@@ -10,4 +13,119 @@ class HomeController < ApplicationController
   def profile
   end
   
+  def configure
+  end
+  
+  def create_token
+    if @user.create_token
+      respond_to do |format|
+        flash[:notice] = I18n.t('flash.notice.created', :model => User.human_attribute_name(:authentication_token))
+        format.html { redirect_to({:action => :configure}) }
+      end
+    else
+      flash[:notice] = I18n.t('flash.notice.not_created', :model => User.human_attribute_name(:authentication_token))
+      format.html { render action: "configure" }
+    end
+  end
+  
+  def delete_token
+    if @user.delete_token
+      respond_to do |format|
+        flash[:notice] = I18n.t('flash.notice.destroyed', :model => User.human_attribute_name(:authentication_token))
+        format.html { redirect_to :action => :configure}
+      end
+    else
+      flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => User.human_attribute_name(:authentication_token))
+      format.html { render action: "configure" }
+    end
+  end
+  
+  def comic
+    @page = Author.page params[:page]
+    @page_size = Author.comic_page_size params[:page_size]
+    @comics = Comic.mylist(@author, @page, @page_size)
+
+    respond_to do |format|
+      format.html # index.html.erb
+      format.json { render json: @comics.to_json(Comic.list_json_opt) }
+    end
+  end
+  
+  def story
+    @page = Author.page params[:page]
+    @page_size = Author.story_page_size params[:page_size]
+    @stories = Story.mylist(@author, @page, @page_size)
+
+    respond_to do |format|
+      format.html # index.html.erb
+      format.json { render text: Story.list_as_json_text(@stories) }
+    end
+  end
+  
+  def panel
+    @page = Author.page params[:page]
+    @page_size = Author.panel_page_size params[:page_size]
+    @panels = Panel.mylist(@author, @page, @page_size)
+
+    respond_to do |format|
+      format.html # index.html.erb
+      format.json { render text: Panel.list_as_json_text(@panels) }
+    end
+  end
+  
+  def panel_picture
+    @page = Author.page params[:page]
+    @page_size = Author.panel_picture_page_size params[:page_size]
+    @panel_pictures = PanelPicture.mylist(@author, @page, @page_size)
+
+    respond_to do |format|
+      format.html # index.html.erb
+      format.json { render json: @panel_pictures.to_json(PanelPicture.list_json_opt) }
+    end
+  end
+  
+  def panel_color
+    @page = Author.page params[:page]
+    @page_size = Author.panel_colorl_page_size params[:page_size]
+    @panel_colors = PanelColor.mylist(@author, @page, @page_size)
+
+    respond_to do |format|
+      format.html # index.html.erb
+      format.json { render json: @panel_colors.to_json(PanelColor.list_json_opt) }
+    end
+  end
+  
+  def ground_picture
+    @page = Author.page params[:page]
+    @page_size = Author.ground_picture_page_size params[:page_size]
+    @ground_pictures = GroundPicture.mylist(@author, @page, @page_size)
+
+    respond_to do |format|
+      format.html # index.html.erb
+      format.json { render json: @ground_pictures.to_json(GroundPicture.list_json_opt) }
+    end
+  end
+  
+  def ground_color
+    @page = Author.page params[:page]
+    @page_size = Author.ground_color_page_size params[:page_size]
+    @ground_colors = GroundColor.mylist(@author, @page, @page_size)
+
+    respond_to do |format|
+      format.html # index.html.erb
+      format.json { render json: @ground_colors.to_json(GroundColor.list_json_opt) }
+    end
+  end
+  
+  def resource_picture
+    @page = Author.page params[:page]
+    @page_size = Author.resource_picture_page_size params[:page_size]
+    @resource_pictures = ResourcePicture.mylist(@artist, @page, @page_size)
+
+    respond_to do |format|
+      format.html # index.html.erb
+      format.json { render json: @resource_pictures.to_json(ResourcePicture.list_json_opt) }
+    end
+  end
+  
 end