OSDN Git Service

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