class PicturesController < ApplicationController
- layout 'test' if Pettanr::TestLayout
- before_filter :authenticate_user!, :only => [:show, :credit]
+ if Manifest.manifest.magic_numbers['run_mode'] == 0
+ before_filter :authenticate_user, :only => []
+ before_filter :authenticate_author, :only => []
+ else
+ before_filter :authenticate_user, :only => []
+ before_filter :authenticate_resource_reader, :only => [:show, :credit, :search]
+ before_filter :authenticate_author, :only => []
+ end
+ before_filter :authenticate_admin, :only => [:index, :by_artist, :count, :count_by_artist]
+
+ def index
+ filer_list
+ end
+
+ def by_artist
+ filer_list
+ end
+
+ def show_html_format format
+ format.html {
+ @item.boosts 'post'
+ @picture = @item
+ }
+ end
def show
- @picture = Picture.show(params[:id])
-
+ set_show
respond_to do |format|
- opt = {:type => @picture.mime_type, :disposition=>"inline"}
- format.png { send_data(@picture.restore(params[:subdir]), opt ) }
- format.gif { send_data(@picture.restore(params[:subdir]), opt ) }
- format.jpeg { send_data(@picture.restore(params[:subdir]), opt ) }
- format.json { render :json => @picture.to_json}
+ opt = {:type => @item.mime_type, :disposition=>"inline"}
+ format.png { send_data(@item.restore(params[:subdir]), opt ) }
+ format.gif { send_data(@item.restore(params[:subdir]), opt ) }
+ format.jpeg { send_data(@item.restore(params[:subdir]), opt ) }
+ show_html_format format
+ show_json_format format
+ show_prof_format format
end
end
def credit
- @picture = Picture.show(params[:id])
+ @picture = Picture.show(params[:id], @operators)
respond_to do |format|
- format.html { render :layout => false } # show.html.erb
+ format.html { render :layout => false }
format.json { render :json => @picture.to_json}
end
end
+ def search
+ @pictures = Picture.list_by_md5(params[:md5])
+
+ respond_to do |format|
+ format.html
+ format.json { render json: @pictures.to_json }
+ end
+ end
+
+ def count
+ list_count
+ end
+
+ def count_by_artist
+ list_count
+ end
+
end