Commit 46edde1f authored by Martin Markech's avatar Martin Markech
Browse files

Merge pull request #7 from QEDio/css_class_preview_type

Css class && preview type
parents 101559cf c46bac17
......@@ -5,7 +5,7 @@ module Refinery
mount_uploader :file, Refinery::PhotoGallery::Admin::FileUploader
acts_as_indexed :fields => [:title, :description]
attr_accessible :album_id, :title, :description, :longitude, :latitude, :url
attr_accessible :album_id, :title, :description, :longitude, :latitude, :url, :css_class, :preview_type
validates :title, :presence => true
#TODO validate latitude/longitude - convert from nondecimal to decimal using inspiration from https://github.com/airblade/geo_tools/tree/master/lib/geo_tools
......@@ -24,6 +24,15 @@ module Refinery
self.url.blank? ? file.single.url : self.url
end
def preview_link(ext_type = :album)
begin
type = self.preview_type.blank? ? ext_type : self.preview_type
file.url(type)
rescue Exception => e
file.url(:error_wrong_preview_version)
end
end
private
def set_title
......
......@@ -47,6 +47,7 @@ module Refinery
"thumbs/#{model.album.path}"
end
end
version :preview do
process :resize_to_fit => Refinery::PhotoGallery.preview_dimensions
process :auto_orient
......@@ -54,8 +55,8 @@ module Refinery
"thumbs/#{model.album.path}"
end
end
version :single do
version :single do
process :resize_to_limit => Refinery::PhotoGallery.single_dimensions
process :auto_orient
......@@ -64,6 +65,11 @@ module Refinery
end
end
version :error_wrong_preview_version do
def store_dir
"error/wrong_preview_version.png"
end
end
# Add a white list of extensions which are allowed to be uploaded,
def extension_white_list
......
......@@ -15,10 +15,26 @@
<%= p.text_area :description, :rows => "5", :cols=> "57" %>
</div>
<% if Refinery::PhotoGallery.admin_photo_options_show_url %>
<div class='field'>
<%= p.label :url %>
<%= p.text_field :url, :class => "larger" %>
</div>
<% end %>
<% if Refinery::PhotoGallery.admin_photo_options_show_css_class %>
<div class='field'>
<%= p.label :css_class %>
<%= p.text_field :css_class, :class => "larger" %>
</div>
<% end %>
<% if Refinery::PhotoGallery.admin_photo_options_show_preview_type %>
<div class='field'>
<%= p.label :preview_type %>
<%= p.text_field :preview_type, :class => "larger" %>
</div>
<% end %>
<div class='field-group'>
<%= p.label :longitude, :tooltip=> t('.use_decimal_format') %>
......
......@@ -5,8 +5,12 @@
<ul id="gallery" class="clearfix">
<% photos_for_page.each_with_index do |photo, index| %>
<% if photo.css_class.present? %>
<li class="<%= photo.css_class %>" >
<% else %>
<li>
<%= link_to (image_tag photo.file.url(:album), :width => Refinery::PhotoGallery.album_dimensions[0], :height => Refinery::PhotoGallery.album_dimensions[1] ), photo.link_url, {
<% end %>
<%= link_to (image_tag photo.preview_link(:album), :width => Refinery::PhotoGallery.album_dimensions[0], :height => Refinery::PhotoGallery.album_dimensions[1] ), photo.link_url, {
:target=> "_blank",
:class=>"fancybox",
:data =>{:title=> t('.image') + ' ' + (index + 1 ).to_s + '/' + photos_for_page.total_pages.to_s + ' ' + photo.title + '<br/><br/>' + photo.description},
......
class AddCssStylesAndShowOriginalFieldsToPhotos < ActiveRecord::Migration
def change
add_column :refinery_photo_gallery_photos, :css_class, :string
add_column :refinery_photo_gallery_photos, :preview_type, :string
end
end
......@@ -31,6 +31,7 @@ Refinery::PhotoGallery.configure do |config|
# config.albums_per_page = <%= Refinery::PhotoGallery.albums_per_page.inspect %>
# config.photos_per_page = <%= Refinery::PhotoGallery.photos_per_page.inspect %>
# config.admin_photo_options_show_url = <%= Refinery::PhotoGallery.admin_photo_options_show_url.inspect %>
# config.admin_photo_options_show_css_class = <%= Refinery::PhotoGallery.admin_photo_options_show_css_class.inspect %>
# config.admin_photo_options_show_preview_type = <%= Refinery::PhotoGallery.admin_photo_options_show_preview_type.inspect %>
end
......@@ -4,7 +4,9 @@ module Refinery
config_accessor :runtimes, :max_file_size,:client_side_resize, :client_side_resize_params, :plupload_locale, :extension_white_list,:photo_gallery_dir,
:delete_uploaded_file,:collection_dimensions, :album_dimensions, :preview_dimensions, :single_dimensions, :photo_gallery_dir_relative_to_root,
:photos_per_page, :albums_per_page, :collections_per_page
:photos_per_page, :albums_per_page, :collections_per_page,
:admin_photo_options_show_url, :admin_photo_options_show_css_class,
:admin_photo_options_show_preview_type
......@@ -27,5 +29,9 @@ module Refinery
self.albums_per_page = 10
self.collections_per_page = 10
self.photos_per_page = 10
self.admin_photo_options_show_url = true
self.admin_photo_options_show_css_class = true
self.admin_photo_options_show_preview_type = true
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment