OSDN Git Service

t#29505:md5 search wrote test on picture
[pettanr/pettanr.git] / app / controllers / pictures_controller.rb
1 class PicturesController < ApplicationController
2   layout 'test' if Pettanr::Application.test_layout
3   before_filter :authenticate_user!, :only => [:show, :credit, :md5]
4   before_filter :authenticate_artist, :only => [:md5]
5   
6   def show
7     @picture = Picture.show(params[:id], @author)
8
9     respond_to do |format|
10       opt = {:type => @picture.mime_type, :disposition=>"inline"}
11       format.png { send_data(@picture.restore(params[:subdir]), opt ) }
12       format.gif { send_data(@picture.restore(params[:subdir]), opt ) }
13       format.jpeg { send_data(@picture.restore(params[:subdir]), opt ) }
14       format.html 
15       format.json { render :json => @picture.to_json}
16     end
17   end
18   
19   def credit
20     @picture = Picture.show(params[:id], @author)
21
22     respond_to do |format|
23       format.html { render :layout => false } # show.html.erb
24       format.json { render :json => @picture.to_json}
25     end
26   end
27   
28   def md5
29     @pictures = Picture.list_by_md5(params[:md5])
30     
31     respond_to do |format|
32       format.html
33       format.json { render json: @pictures.to_json }
34     end
35   end
36   
37 end