OSDN Git Service

t#30169:show, index action create all resource
[pettanr/pettanr.git] / app / controllers / speeches_controller.rb
index 0cb0e2d..88a9bcb 100644 (file)
@@ -1,8 +1,28 @@
 class SpeechesController < ApplicationController
   layout 'test' if MagicNumber['test_layout']
   before_filter :authenticate_user!, :only => [:index, :show]
+  before_filter :authenticate_author, :only => [:index, :show]
   before_filter :authenticate_admin!, :only => [:list, :browse]
 
+  def index
+    @page = Speech.page params[:page]
+    @page_size = Speech.page_size params[:page_size]
+    @speeches = Speech.list(@page, @page_size)
+
+    respond_to do |format|
+      format.html # index.html.erb
+      format.json { render json: @speeches.to_json(Speech.list_json_opt) }
+    end
+  end
+  
+  def show
+    @speech = Speech.show(params[:id], @author)
+    respond_to do |format|
+      format.html # show.html.erb
+      format.json { render json: @speech.to_json(Speech.show_json_opt) }
+    end
+  end
+  
   def list
     @speeches = Speech.all