OSDN Git Service

9e1bae8c35acf1ba91e2afe3ecba35cb6d8d19ed
[pettanr/pettanr.git] / app / controllers / pictures_controller.rb
1 class PicturesController < ApplicationController
2   if Manifest.manifest.magic_numbers['run_mode'] == 0
3     before_filter :authenticate_user, :only => []
4     before_filter :authenticate_author, :only => []
5   else
6     before_filter :authenticate_user, :only => []
7     before_filter :authenticate_resource_reader, :only => [:show, :credit, :search]
8     before_filter :authenticate_author, :only => []
9   end
10   
11   def show_html_format format
12     format.html {
13       @picture = @item
14     }
15   end
16   
17   def show
18     set_show
19     respond_to do |format|
20       opt = {:type => @item.mime_type, :disposition=>"inline"}
21       format.png { send_data(@item.restore(params[:subdir]), opt ) }
22       format.gif { send_data(@item.restore(params[:subdir]), opt ) }
23       format.jpeg { send_data(@item.restore(params[:subdir]), opt ) }
24       show_html_format format
25       show_prof_format format
26       show_json_format format
27     end
28   end
29   
30   def credit
31     @picture = Picture.show(params[:id], @operators)
32
33     respond_to do |format|
34       format.html { render :layout => false }
35       format.json { render :json => @picture.to_json}
36     end
37   end
38   
39   def search
40     @pictures = Picture.list_by_md5(params[:md5])
41     
42     respond_to do |format|
43       format.html
44       format.json { render json: @pictures.to_json }
45     end
46   end
47   
48 end