OSDN Git Service

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