OSDN Git Service

rename model name
[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   before_filter :authenticate_admin, :only => [:index, :by_artist, :count, :count_by_artist]
11   
12   def index
13     filer_list
14   end
15   
16   def by_artist
17     filer_list
18   end
19   
20   def show_html_format format
21     format.html {
22       @item.boosts 'post'
23       @picture = @item
24     }
25   end
26   
27   def show
28     set_show
29     respond_to do |format|
30       opt = {:type => @item.mime_type, :disposition=>"inline"}
31       format.png { send_data(@item.restore(params[:subdir]), opt ) }
32       format.gif { send_data(@item.restore(params[:subdir]), opt ) }
33       format.jpeg { send_data(@item.restore(params[:subdir]), opt ) }
34       show_html_format format
35       show_json_format format
36       show_prof_format format
37     end
38   end
39   
40   def credit
41     @picture = Picture.show(params[:id], @operators)
42
43     respond_to do |format|
44       format.html { render :layout => false }
45       format.json { render :json => @picture.to_json}
46     end
47   end
48   
49   def search
50     @pictures = Picture.list_by_md5(params[:md5])
51     
52     respond_to do |format|
53       format.html
54       format.json { render json: @pictures.to_json }
55     end
56   end
57   
58   def count
59     list_count
60   end
61   
62   def count_by_artist
63     list_count
64   end
65   
66 end