OSDN Git Service

4ebe33a3afd81de1f63a3f91c335a52d954cb09e
[pettanr/pettanr.git] / app / controllers / pictures_controller.rb
1 class PicturesController < ApplicationController
2   layout 'test' if Pettanr::TestLayout
3   before_filter :authenticate_user!, :only => [:show, :credit]
4   
5   def show
6     @picture = Picture.show(params[:id])
7
8     respond_to do |format|
9       opt = {:type => @picture.mime_type, :disposition=>"inline"}
10       format.png { send_data(@picture.restore(params[:subdir]), opt ) }
11       format.gif { send_data(@picture.restore(params[:subdir]), opt ) }
12       format.jpeg { send_data(@picture.restore(params[:subdir]), opt ) }
13       format.html 
14       format.json { render :json => @picture.to_json}
15     end
16   end
17   
18   def credit
19     @picture = Picture.show(params[:id])
20
21     respond_to do |format|
22       format.html { render :layout => false } # show.html.erb
23       format.json { render :json => @picture.to_json}
24     end
25   end
26   
27 end