OSDN Git Service

t#28985:add credit
[pettanr/pettanr.git] / app / controllers / pictures_controller.rb
index 5aea247..4661dbf 100644 (file)
@@ -1,11 +1,25 @@
 class PicturesController < ApplicationController
   layout 'test' if Pettanr::TestLayout
+  before_filter :authenticate_user!, :only => [:show, :credit]
+  
+  def show
+    @picture = Picture.show(params[:id])
+
+    respond_to do |format|
+      opt = {:type => @picture.mime_type, :disposition=>"inline"}
+      format.png { send_data(@picture.restore(params[:subdir]), opt ) }
+      format.gif { send_data(@picture.restore(params[:subdir]), opt ) }
+      format.jpeg { send_data(@picture.restore(params[:subdir]), opt ) }
+      format.json { render :json => @picture.to_json}
+    end
+  end
+  
   def credit
     @picture = Picture.show(params[:id])
 
     respond_to do |format|
-      format.html # show.html.erb
-      format.json { render :json => @picture.to_json(Picture.list_json_opt)}
+      format.html { render :layout => false } # show.html.erb
+      format.json { render :json => @picture.to_json}
     end
   end