OSDN Git Service

t#30328:create op import ...and pull
[pettanr/pettanr.git] / app / controllers / speech_balloons_controller.rb
index 2152cd1..ba0be88 100644 (file)
@@ -1,7 +1,33 @@
 class SpeechBalloonsController < ApplicationController
   layout 'test' if MagicNumber['test_layout']
+  if MagicNumber['run_mode'] == 0
+    before_filter :authenticate_user!, :only => []
+    before_filter :authenticate_author, :only => []
+  else
+    before_filter :authenticate_user!, :only => [:index, :show]
+    before_filter :authenticate_author, :only => [:index, :show]
+  end
   before_filter :authenticate_admin!, :only => [:list, :browse]
 
+  def index
+    @page = SpeechBalloon.page params[:page]
+    @page_size = SpeechBalloon.page_size params[:page_size]
+    @speech_balloons = SpeechBalloon.list(@page, @page_size)
+
+    respond_to do |format|
+      format.html # index.html.erb
+      format.json { render json: @speech_balloons.to_json(SpeechBalloon.list_json_opt) }
+    end
+  end
+  
+  def show
+    @speech_balloon = SpeechBalloon.show(params[:id], @author)
+    respond_to do |format|
+      format.html # show.html.erb
+      format.json { render json: @speech_balloon.to_json(SpeechBalloon.show_json_opt) }
+    end
+  end
+  
   def list
     @speech_balloons = SpeechBalloon.all