app/controllers/papermill_controller.rb in BBenezech-papermill-0.2.0 vs app/controllers/papermill_controller.rb in BBenezech-papermill-0.2.1
- old
+ new
@@ -2,21 +2,23 @@
skip_before_filter :verify_authenticity_token
def show
begin
- if Papermill::PAPERMILL_DEFAULTS[:alias_only]
- style = Papermill::PAPERMILL_DEFAULTS[:aliases][params[:style]]
+ asset = PapermillAsset.find(params[:id])
+ raise if asset.nil? || params[:style] == "original"
+ style = Papermill::PAPERMILL_DEFAULTS[:aliases][params[:style]] || !Papermill::PAPERMILL_DEFAULTS[:alias_only] && params[:style]
+ raise unless style
+
+ if asset.image?
+ temp_thumbnail = Paperclip::Thumbnail.make(asset_file = asset.file, style)
+ new_parent_folder_path = File.dirname(new_image_path = asset_file.path(params[:style]))
+ FileUtils.mkdir_p new_parent_folder_path unless File.exists? new_parent_folder_path
+ FileUtils.cp temp_thumbnail.path, new_image_path
+ redirect_to asset.url(params[:style])
else
- style = Papermill::PAPERMILL_DEFAULTS[:aliases][params[:style]] || params[:style]
+ redirect_to asset.url
end
- raise unless style
- asset = PapermillAsset.find(params[:id])
- temp_thumbnail = Paperclip::Thumbnail.make(asset_file = asset.file, style)
- new_parent_folder_path = File.dirname(new_image_path = asset_file.path(params[:style]))
- FileUtils.mkdir_p new_parent_folder_path unless File.exists? new_parent_folder_path
- FileUtils.cp temp_thumbnail.path, new_image_path
- redirect_to asset.url(params[:style])
rescue
render :text => t("not-processed", :scope => "papermill"), :status => "500"
end
end
\ No newline at end of file