class PicturesController < ApplicationController
- layout 'test' if Pettanr::TestLayout
- before_filter :authenticate_user!, :only => [:show, :credit]
+ layout 'test' if Pettanr::Application.test_layout
+ before_filter :authenticate_user!, :only => [:show, :credit, :md5]
+ before_filter :authenticate_artist, :only => [:md5]
def show
- @picture = Picture.show(params[:id])
+ @picture = Picture.show(params[:id], @author)
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.html
format.json { render :json => @picture.to_json}
end
end
def credit
- @picture = Picture.show(params[:id])
+ @picture = Picture.show(params[:id], @author)
respond_to do |format|
format.html { render :layout => false } # show.html.erb
end
end
+ def md5
+ @pictures = Picture.list_by_md5(params[:md5])
+
+ respond_to do |format|
+ format.html
+ format.json { render json: @pictures.to_json }
+ end
+ end
+
end