OSDN Git Service

add editor
[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
12     @item = Picture.show(params[:id], @operators)
13
14     respond_to do |format|
15       opt = {:type => @item.mime_type, :disposition=>"inline"}
16       format.png { send_data(@item.restore(params[:subdir]), opt ) }
17       format.gif { send_data(@item.restore(params[:subdir]), opt ) }
18       format.jpeg { send_data(@item.restore(params[:subdir]), opt ) }
19       format.html {
20         @picture = @item
21       }
22       format_prof format
23       format.json { render :json => @item.to_json}
24     end
25   end
26   
27   def credit
28     @picture = Picture.show(params[:id], @operators)
29
30     respond_to do |format|
31       format.html { render :layout => false }
32       format.json { render :json => @picture.to_json}
33     end
34   end
35   
36   def search
37     @pictures = Picture.list_by_md5(params[:md5])
38     
39     respond_to do |format|
40       format.html
41       format.json { render json: @pictures.to_json }
42     end
43   end
44   
45 end