refinerycms-photo-gallery 0.0.1.dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +26 -0
- data/LICENSE.md +8 -0
- data/README.md +224 -0
- data/app/assets/images/refinery/photo_gallery/admin/chosen-sprite.png +0 -0
- data/app/assets/images/refinery/photo_gallery/admin/icons/album.png +0 -0
- data/app/assets/images/refinery/photo_gallery/admin/icons/album_add.png +0 -0
- data/app/assets/images/refinery/photo_gallery/admin/icons/album_edit.png +0 -0
- data/app/assets/images/refinery/photo_gallery/admin/icons/cog.png +0 -0
- data/app/assets/images/refinery/photo_gallery/admin/icons/down.gif +0 -0
- data/app/assets/images/refinery/photo_gallery/admin/icons/folder.png +0 -0
- data/app/assets/images/refinery/photo_gallery/admin/icons/folder_add.png +0 -0
- data/app/assets/images/refinery/photo_gallery/admin/icons/folder_edit.png +0 -0
- data/app/assets/images/refinery/photo_gallery/admin/icons/loading.gif +0 -0
- data/app/assets/images/refinery/photo_gallery/admin/icons/page_copy.png +0 -0
- data/app/assets/images/refinery/photo_gallery/admin/icons/photo.png +0 -0
- data/app/assets/images/refinery/photo_gallery/admin/icons/photo_add.png +0 -0
- data/app/assets/images/refinery/photo_gallery/admin/icons/photo_edit.png +0 -0
- data/app/assets/images/refinery/photo_gallery/admin/icons/up.gif +0 -0
- data/app/assets/images/refinery/photo_gallery/admin/plupload/jquery.plupload.queue/backgrounds.gif +0 -0
- data/app/assets/images/refinery/photo_gallery/admin/plupload/jquery.plupload.queue/buttons-disabled.png +0 -0
- data/app/assets/images/refinery/photo_gallery/admin/plupload/jquery.plupload.queue/buttons.png +0 -0
- data/app/assets/images/refinery/photo_gallery/admin/plupload/jquery.plupload.queue/delete.gif +0 -0
- data/app/assets/images/refinery/photo_gallery/admin/plupload/jquery.plupload.queue/done.gif +0 -0
- data/app/assets/images/refinery/photo_gallery/admin/plupload/jquery.plupload.queue/error.gif +0 -0
- data/app/assets/images/refinery/photo_gallery/admin/plupload/jquery.plupload.queue/throbber.gif +0 -0
- data/app/assets/images/refinery/photo_gallery/admin/plupload/jquery.plupload.queue/transp50.png +0 -0
- data/app/assets/images/refinery/photo_gallery/admin/plupload/jquery.ui.plupload/plupload-bw.png +0 -0
- data/app/assets/images/refinery/photo_gallery/admin/plupload/jquery.ui.plupload/plupload.png +0 -0
- data/app/assets/images/refinery/photo_gallery/admin/rss-feed.png +0 -0
- data/app/assets/images/refinery/photo_gallery/fancybox/blank.gif +0 -0
- data/app/assets/images/refinery/photo_gallery/fancybox/fancybox_loading.gif +0 -0
- data/app/assets/images/refinery/photo_gallery/fancybox/fancybox_sprite.png +0 -0
- data/app/assets/images/refinery/photo_gallery/fancybox/helpers/fancybox_buttons.png +0 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/jquery.chosen.min.js +10 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/photo_gallery.js +28 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/changelog.txt +218 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/i18n/cs.js +14 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/i18n/da.js +12 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/i18n/de.js +24 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/i18n/el.js +14 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/i18n/es.js +25 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/i18n/et.js +33 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/i18n/fa.js +37 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/i18n/fi.js +33 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/i18n/fr-ca.js +35 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/i18n/fr.js +25 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/i18n/hr.js +25 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/i18n/hu.js +33 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/i18n/it.js +24 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/i18n/ja.js +37 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/i18n/ko.js +36 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/i18n/lv.js +33 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/i18n/nl.js +21 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/i18n/pl.js +24 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/i18n/pt-br.js +35 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/i18n/ro.js +24 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/i18n/ru.js +21 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/i18n/sk.js +37 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/i18n/sr.js +14 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/i18n/sv.js +12 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/jquery.plupload.queue.js +195 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/jquery.ui.plupload.js +383 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/license.txt +339 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/plupload.browserplus.js +1 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/plupload.flash.js +226 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/plupload.flash.swf +0 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/plupload.full.js +2525 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/plupload.full.js.default +2525 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/plupload.gears.js +1 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/plupload.html4.js +1 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/plupload.html5.js +765 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/plupload.html5.js.default +765 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/plupload.js +618 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/plupload.silverlight.js +1 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/plupload.silverlight.xap +0 -0
- data/app/assets/javascripts/refinery/photo_gallery/admin/plupload/readme.md +46 -0
- data/app/assets/javascripts/refinery/photo_gallery/fancybox/CHANGELOG.md +68 -0
- data/app/assets/javascripts/refinery/photo_gallery/fancybox/README.md +212 -0
- data/app/assets/javascripts/refinery/photo_gallery/fancybox/helpers/jquery.fancybox-buttons.js +115 -0
- data/app/assets/javascripts/refinery/photo_gallery/fancybox/helpers/jquery.fancybox-media.js +85 -0
- data/app/assets/javascripts/refinery/photo_gallery/fancybox/helpers/jquery.fancybox-thumbs.js +157 -0
- data/app/assets/javascripts/refinery/photo_gallery/fancybox/jquery.fancybox.js +1463 -0
- data/app/assets/javascripts/refinery/photo_gallery/fancybox/jquery.fancybox.pack.js +35 -0
- data/app/assets/javascripts/refinery/photo_gallery/fancybox/lib/jquery.mousewheel-3.0.6.pack.js +13 -0
- data/app/assets/stylesheets/refinery/photo_gallery/admin/chosen.css.scss +396 -0
- data/app/assets/stylesheets/refinery/photo_gallery/admin/photo_gallery.css.scss +109 -0
- data/app/assets/stylesheets/refinery/photo_gallery/admin/plupload/jquery.plupload.queue.css.scss +177 -0
- data/app/assets/stylesheets/refinery/photo_gallery/admin/plupload/jquery.ui.plupload.css.scss +147 -0
- data/app/assets/stylesheets/refinery/photo_gallery/fancybox/helpers/jquery.fancybox-buttons.css.scss +85 -0
- data/app/assets/stylesheets/refinery/photo_gallery/fancybox/helpers/jquery.fancybox-thumbs.css +54 -0
- data/app/assets/stylesheets/refinery/photo_gallery/fancybox/jquery.fancybox.css.scss +234 -0
- data/app/controllers/refinery/photo_gallery/admin/albums_controller.rb +23 -0
- data/app/controllers/refinery/photo_gallery/admin/collections_controller.rb +10 -0
- data/app/controllers/refinery/photo_gallery/admin/photos_controller.rb +67 -0
- data/app/controllers/refinery/photo_gallery/albums_controller.rb +21 -0
- data/app/controllers/refinery/photo_gallery/collections_controller.rb +28 -0
- data/app/helpers/refinery/photo_gallery/admin/photos_helper.rb +10 -0
- data/app/helpers/refinery/photo_gallery/albums_helper.rb +11 -0
- data/app/helpers/refinery/photo_gallery/photo_gallery_helper.rb +58 -0
- data/app/middleware/refinery/photo_gallery/admin/flash_session_cookie_middleware.rb +27 -0
- data/app/models/refinery/photo_gallery/album.rb +60 -0
- data/app/models/refinery/photo_gallery/collection.rb +29 -0
- data/app/models/refinery/photo_gallery/collection_album.rb +8 -0
- data/app/models/refinery/photo_gallery/photo.rb +54 -0
- data/app/uploaders/refinery/photo_gallery/admin/file_uploader.rb +121 -0
- data/app/views/refinery/photo_gallery/admin/_submenu.html.erb +44 -0
- data/app/views/refinery/photo_gallery/admin/albums/_album.html.erb +31 -0
- data/app/views/refinery/photo_gallery/admin/albums/_form.html.erb +78 -0
- data/app/views/refinery/photo_gallery/admin/albums/_sortable_list.html.erb +7 -0
- data/app/views/refinery/photo_gallery/admin/albums/edit.html.erb +2 -0
- data/app/views/refinery/photo_gallery/admin/albums/index.html.erb +28 -0
- data/app/views/refinery/photo_gallery/admin/albums/new.html.erb +2 -0
- data/app/views/refinery/photo_gallery/admin/collections/_collection.html.erb +23 -0
- data/app/views/refinery/photo_gallery/admin/collections/_form.html.erb +32 -0
- data/app/views/refinery/photo_gallery/admin/collections/_sortable_list.html.erb +7 -0
- data/app/views/refinery/photo_gallery/admin/collections/edit.html.erb +2 -0
- data/app/views/refinery/photo_gallery/admin/collections/index.html.erb +28 -0
- data/app/views/refinery/photo_gallery/admin/collections/new.html.erb +2 -0
- data/app/views/refinery/photo_gallery/admin/collections/test.html.erb +39 -0
- data/app/views/refinery/photo_gallery/admin/photos/_destroy.js.erb +15 -0
- data/app/views/refinery/photo_gallery/admin/photos/_form.html.erb +7 -0
- data/app/views/refinery/photo_gallery/admin/photos/_form_actions.html.erb +6 -0
- data/app/views/refinery/photo_gallery/admin/photos/_form_fields.html.erb +31 -0
- data/app/views/refinery/photo_gallery/admin/photos/_form_fields_actions.html.erb +15 -0
- data/app/views/refinery/photo_gallery/admin/photos/edit_multiple.html.erb +9 -0
- data/app/views/refinery/photo_gallery/admin/photos/upload.html.erb +87 -0
- data/app/views/refinery/photo_gallery/albums/show.html.erb +26 -0
- data/app/views/refinery/photo_gallery/collections/index.html.erb +9 -0
- data/app/views/refinery/photo_gallery/collections/show.html.erb +19 -0
- data/app/views/refinery/photo_gallery/shared/_layout.html.erb +22 -0
- data/app/views/refinery/photo_gallery/shared/_submenu.html.erb +4 -0
- data/config/initializers/carrierwave.rb +7 -0
- data/config/initializers/form_builder.rb +26 -0
- data/config/initializers/refinery/core.rb +10 -0
- data/config/initializers/s3.rb +13 -0
- data/config/initializers/session_store.rb +10 -0
- data/config/locales/en.yml +95 -0
- data/config/locales/sk.yml +94 -0
- data/config/routes.rb +37 -0
- data/db/migrate/20120804063842_create_albums.rb +18 -0
- data/db/migrate/20120805131321_create_collections.rb +14 -0
- data/db/migrate/20120805131547_create_collection_albums.rb +12 -0
- data/db/migrate/20120805165238_create_photos.rb +19 -0
- data/db/migrate/20120805222125_add_indexes.rb +24 -0
- data/db/seeds.rb +21 -0
- data/lib/generators/refinery/photo_gallery_generator.rb +25 -0
- data/lib/generators/refinery/templates/config/initializers/refinery/photo_gallery.rb.erb +40 -0
- data/lib/refinery/photo_gallery.rb +30 -0
- data/lib/refinery/photo_gallery/configuration.rb +33 -0
- data/lib/refinery/photo_gallery/engine.rb +33 -0
- data/lib/refinery/photo_gallery/version.rb +17 -0
- data/lib/refinerycms-photo-gallery.rb +1 -0
- data/refinerycms-balder-photo-gallery.gemspec +30 -0
- data/screenshots/01_collections#index.png +0 -0
- data/screenshots/02_albums#create.png +0 -0
- data/screenshots/03_photos#upload.png +0 -0
- data/screenshots/04_photos#upload- chooser.png +0 -0
- data/screenshots/05_photo#upoad-queue.png +0 -0
- data/screenshots/06_photos#upload-uploading.png +0 -0
- data/screenshots/07_photos#upload-uploading_2.png +0 -0
- data/screenshots/08_photos#edit_multiple.png +0 -0
- data/screenshots/09_albums#index.png +0 -0
- data/screenshots/10_albums_EXIF_reading.png +0 -0
- data/screenshots/11_frontend_show.png +0 -0
- data/screenshots/12_show_photo_using_fancybox.png +0 -0
- metadata +323 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#TODO fix Flash runtime
|
|
3
|
+
require 'rack/utils'
|
|
4
|
+
|
|
5
|
+
module Refinery
|
|
6
|
+
module PhotoGallery
|
|
7
|
+
module Admin
|
|
8
|
+
class FlashSessionCookieMiddleware
|
|
9
|
+
def initialize(app, session_key = '_session_id')
|
|
10
|
+
@app = app
|
|
11
|
+
@session_key = session_key
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def call(env)
|
|
15
|
+
if env['HTTP_USER_AGENT'] =~ /^(Adobe|Shockwave) Flash/
|
|
16
|
+
req = Rack::Request.new(env)
|
|
17
|
+
env['HTTP_COOKIE'] = [ @session_key,
|
|
18
|
+
req.params[@session_key] ].join('=').freeze unless req.params[@session_key].nil?
|
|
19
|
+
env['HTTP_ACCEPT'] = "#{req.params['_http_accept']}".freeze unless req.params['_http_accept'].nil?
|
|
20
|
+
end
|
|
21
|
+
@app.call(env)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
=end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
module Refinery
|
|
2
|
+
module PhotoGallery
|
|
3
|
+
class Album < ActiveRecord::Base
|
|
4
|
+
has_many :photos, :dependent => :destroy
|
|
5
|
+
has_many :collection_albums , :dependent => :destroy
|
|
6
|
+
has_many :collections, :through => :collection_albums
|
|
7
|
+
|
|
8
|
+
before_validation :set_path
|
|
9
|
+
validates :title, :presence => true
|
|
10
|
+
validates :path, :presence => true, :uniqueness => true
|
|
11
|
+
|
|
12
|
+
attr_accessor :path_prefix
|
|
13
|
+
attr_accessible :title, :description, :address, :note, :tags, :longitude, :latitude, :path, :path_prefix, :collection_ids
|
|
14
|
+
acts_as_indexed :fields => [:title, :description]
|
|
15
|
+
|
|
16
|
+
self.per_page = Refinery::PhotoGallery.albums_per_page
|
|
17
|
+
|
|
18
|
+
scope :find_by_collection_id, lambda {|collection_id|
|
|
19
|
+
select("refinery_photo_gallery_albums.*").
|
|
20
|
+
joins(:collection_albums).
|
|
21
|
+
where("refinery_photo_gallery_collection_albums.collection_id = ?
|
|
22
|
+
", collection_id).
|
|
23
|
+
order('created_at DESC, title ASC')
|
|
24
|
+
}
|
|
25
|
+
=begin
|
|
26
|
+
#TODO marked photo as photo album preview
|
|
27
|
+
scope :find_by_collection_id, lambda {|collection_id|
|
|
28
|
+
select("refinery_photo_gallery_albums.*, refinery_photo_gallery_photos.file").
|
|
29
|
+
joins(:collection_albums, :photos).
|
|
30
|
+
where("refinery_photo_gallery_collection_albums.collection_id = ? AND
|
|
31
|
+
refinery_photo_gallery_photos.album_id = refinery_photo_gallery_albums.id AND
|
|
32
|
+
refinery_photo_gallery_photos.preview_image = true
|
|
33
|
+
", collection_id).
|
|
34
|
+
order('created_at DESC, title ASC')
|
|
35
|
+
}
|
|
36
|
+
=end
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def collection_ids
|
|
40
|
+
Refinery::PhotoGallery::CollectionAlbum.select('collection_id').where("album_id = ?", self.id ).map{|ca| ca.collection_id }
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
=begin # Prety url. Problems with :id
|
|
45
|
+
def to_param
|
|
46
|
+
"#{id}-#{title.parameterize}"
|
|
47
|
+
end
|
|
48
|
+
=end
|
|
49
|
+
def set_path
|
|
50
|
+
#Replaces special characters in tile
|
|
51
|
+
|
|
52
|
+
if self.path_prefix.blank?
|
|
53
|
+
self.path = self.title.parameterize
|
|
54
|
+
else
|
|
55
|
+
self.path = [self.path_prefix, self.title.parameterize].join('-')
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Refinery
|
|
2
|
+
module PhotoGallery
|
|
3
|
+
class Collection < ActiveRecord::Base
|
|
4
|
+
has_many :collection_albums
|
|
5
|
+
has_many :albums, :through => :collection_albums
|
|
6
|
+
|
|
7
|
+
#TODO Allow to remove collection only if no album belongs to it
|
|
8
|
+
|
|
9
|
+
attr_accessible :title, :description
|
|
10
|
+
|
|
11
|
+
validates :title, :presence => true
|
|
12
|
+
acts_as_indexed :fields => [:title, :description]
|
|
13
|
+
|
|
14
|
+
self.per_page = Refinery::PhotoGallery.collections_per_page
|
|
15
|
+
|
|
16
|
+
scope :has_albums, lambda {
|
|
17
|
+
select("refinery_photo_gallery_collections.*").uniq.
|
|
18
|
+
joins(:collection_albums).
|
|
19
|
+
order('created_at DESC, title ASC')
|
|
20
|
+
}
|
|
21
|
+
=begin
|
|
22
|
+
def to_param
|
|
23
|
+
"#{id}-#{title.parameterize}"
|
|
24
|
+
end
|
|
25
|
+
=end
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
module Refinery
|
|
2
|
+
module PhotoGallery
|
|
3
|
+
class Photo < ActiveRecord::Base
|
|
4
|
+
belongs_to :album
|
|
5
|
+
|
|
6
|
+
mount_uploader :file, Refinery::PhotoGallery::Admin::FileUploader
|
|
7
|
+
acts_as_indexed :fields => [:title, :description]
|
|
8
|
+
attr_accessible :album_id, :title, :description, :longitude, :latitude
|
|
9
|
+
validates :title, :presence => true
|
|
10
|
+
#TODO validate latitude/longitude - convert from nondecimal to decimal using inspiration from https://github.com/airblade/geo_tools/tree/master/lib/geo_tools
|
|
11
|
+
|
|
12
|
+
before_validation :set_title
|
|
13
|
+
before_create :exif_read
|
|
14
|
+
#before_update :exif_write #TODO or use it after update?
|
|
15
|
+
#TODO delete photo path from db? is it used?
|
|
16
|
+
|
|
17
|
+
self.per_page = Refinery::PhotoGallery.photos_per_page
|
|
18
|
+
|
|
19
|
+
def to_param
|
|
20
|
+
"#{id}-#{title.parameterize}"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
def set_title
|
|
26
|
+
self.title = self.file.file.basename.titleize unless self.title
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def exif_read
|
|
30
|
+
photo = MiniExiftool.new(self.file.file.file, {:numerical=> true})
|
|
31
|
+
self.longitude = photo.GPSLongitude if self.longitude.nil?
|
|
32
|
+
self.latitude = photo.GPSLatitude if self.latitude.nil?
|
|
33
|
+
self.title = photo.DocumentName if photo.DocumentName.present?
|
|
34
|
+
self.description = photo.ImageDescription if self.description.nil? && photo.ImageDescription != 'Exif_JPEG_PICTURE'
|
|
35
|
+
# TODO read keywords from exif
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
=begin
|
|
39
|
+
#TODO add checkbox to check if it should be writed to exif, globally on/off writing
|
|
40
|
+
def exif_write
|
|
41
|
+
# should only write if tags are changed as images can be large and thus ExifTool will take a while to write to the file
|
|
42
|
+
photo = MiniExiftool.new(self.file.file.file)
|
|
43
|
+
photo.GPSLongitude = self.longitude
|
|
44
|
+
photo.GPSLatitude = self.latitude
|
|
45
|
+
photo.DocumentName = self.title
|
|
46
|
+
photo.ImageDescription = self.description
|
|
47
|
+
photo.Keywords = self.tags
|
|
48
|
+
photo.save
|
|
49
|
+
end
|
|
50
|
+
=end
|
|
51
|
+
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
#TODO tests
|
|
4
|
+
module Refinery
|
|
5
|
+
module PhotoGallery
|
|
6
|
+
module Admin
|
|
7
|
+
class FileUploader < CarrierWave::Uploader::Base
|
|
8
|
+
before :store, :remember_cache_id
|
|
9
|
+
after :store, :delete_tmp_dir
|
|
10
|
+
after :store, :delete_uploaded_file
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
# Include RMagick or ImageScience support
|
|
14
|
+
# include CarrierWave::RMagick
|
|
15
|
+
# include CarrierWave::ImageScience
|
|
16
|
+
include CarrierWave::MiniMagick
|
|
17
|
+
|
|
18
|
+
#TODO
|
|
19
|
+
# Choose what kind of storage to use for this uploader
|
|
20
|
+
if ENV['S3_KEY']
|
|
21
|
+
storage :fog
|
|
22
|
+
|
|
23
|
+
def cache_dir
|
|
24
|
+
"#{Rails.root.to_s}/tmp/uploads" if ENV['HEROKU'] == 'true'
|
|
25
|
+
end
|
|
26
|
+
else
|
|
27
|
+
storage :file
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
=begin
|
|
31
|
+
#Fix for bug TypeError: can't convert nil into String #TODO it should work without this method, but don't. Why?
|
|
32
|
+
def to_s
|
|
33
|
+
store_dir + '/' + full_filename(original_filename)
|
|
34
|
+
end
|
|
35
|
+
=end
|
|
36
|
+
|
|
37
|
+
# Override the directory where uploaded files will be stored
|
|
38
|
+
# This is a sensible default for uploaders that are meant to be mounted:
|
|
39
|
+
def store_dir
|
|
40
|
+
"files/#{model.album.path}"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def cache_dir
|
|
44
|
+
"tmp"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Provide a default URL as a default if there hasn't been a file uploaded
|
|
48
|
+
# def default_url
|
|
49
|
+
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
|
|
50
|
+
# end
|
|
51
|
+
|
|
52
|
+
# Process files as they are uploaded.
|
|
53
|
+
# process :scale => [200, 300]
|
|
54
|
+
#
|
|
55
|
+
# def scale(width, height)
|
|
56
|
+
# # do something
|
|
57
|
+
# end
|
|
58
|
+
|
|
59
|
+
# Create different versions of your uploaded files
|
|
60
|
+
version :collection do
|
|
61
|
+
process :resize_to_fill => Refinery::PhotoGallery.collection_dimensions
|
|
62
|
+
def store_dir
|
|
63
|
+
"thumbs/#{model.album.path}"
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
version :album do
|
|
67
|
+
process :resize_to_fill => Refinery::PhotoGallery.album_dimensions
|
|
68
|
+
def store_dir
|
|
69
|
+
"thumbs/#{model.album.path}"
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
version :preview do
|
|
73
|
+
process :resize_to_fit => Refinery::PhotoGallery.preview_dimensions
|
|
74
|
+
def store_dir
|
|
75
|
+
"thumbs/#{model.album.path}"
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
version :single do
|
|
79
|
+
process :resize_to_limit => Refinery::PhotoGallery.single_dimensions
|
|
80
|
+
def store_dir
|
|
81
|
+
"thumbs/#{model.album.path}"
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# Add a white list of extensions which are allowed to be uploaded,
|
|
86
|
+
def extension_white_list
|
|
87
|
+
Refinery::PhotoGallery.extension_white_list
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# Override the filename of the uploaded files
|
|
91
|
+
# def filename
|
|
92
|
+
# "something.jpg" if original_filename
|
|
93
|
+
# end
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
# Deleting uploaded file in files/ dir. This method dont do removing of original file in tmp
|
|
97
|
+
def delete_uploaded_file(new_file)
|
|
98
|
+
if version_name.blank? && Refinery::PhotoGallery.delete_uploaded_file
|
|
99
|
+
filename_to_delete = File.join(Rails.root.to_s,Refinery::PhotoGallery.photo_gallery_dir_relative_to_root, store_dir, filename )
|
|
100
|
+
File.delete(filename_to_delete)
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# store! nil's the cache_id after it finishes so we need to remember it for deletion
|
|
105
|
+
def remember_cache_id(new_file)
|
|
106
|
+
@cache_id_was = cache_id
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# Delete empty dir after restoring cached files to thumb dir. If an error during uploading occured, tmp dir will not be deleted, because will not be empty.
|
|
110
|
+
def delete_tmp_dir(new_file)
|
|
111
|
+
# versions hash is inicialized after storing all versions. We want to delete folder after all versions are restored
|
|
112
|
+
# make sure we don't delete other things accidentally by checking the name pattern
|
|
113
|
+
if versions.length > 0 && @cache_id_was.present? && @cache_id_was =~ /\A[\d]{8}\-[\d]{4}\-[\d]+\-[\d]{4}\z/
|
|
114
|
+
FileUtils.rm_rf(File.join(Rails.root.to_s,Refinery::PhotoGallery.photo_gallery_dir_relative_to_root, cache_dir, @cache_id_was))
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<nav id='actions' class='multilist'>
|
|
2
|
+
<ul class='search_list'>
|
|
3
|
+
<li class='not_a_link'>
|
|
4
|
+
<%= render :partial => "/refinery/admin/search",
|
|
5
|
+
:locals => {
|
|
6
|
+
:url => refinery.photo_gallery_admin_collections_path
|
|
7
|
+
} %>
|
|
8
|
+
</li>
|
|
9
|
+
</ul>
|
|
10
|
+
|
|
11
|
+
<ul class='collapsible_menu'>
|
|
12
|
+
<li class='not_a_link'>
|
|
13
|
+
<%= link_to t('.collections.title'), '#',
|
|
14
|
+
:class => 'folder_icon' %>
|
|
15
|
+
</li>
|
|
16
|
+
<li>
|
|
17
|
+
<%= link_to t('.collections.manage'), refinery.photo_gallery_admin_collections_path,
|
|
18
|
+
:class => 'folder_edit_icon' %>
|
|
19
|
+
</li>
|
|
20
|
+
<li>
|
|
21
|
+
<%= link_to t('.collections.new'), refinery.new_photo_gallery_admin_collection_path,
|
|
22
|
+
:class => 'folder_add_icon' %>
|
|
23
|
+
</li>
|
|
24
|
+
</ul>
|
|
25
|
+
|
|
26
|
+
<ul class='collapsible_menu'>
|
|
27
|
+
<li class='not_a_link'>
|
|
28
|
+
<%= link_to t('.albums.title'), '#',
|
|
29
|
+
:class => 'album_icon' %>
|
|
30
|
+
</li>
|
|
31
|
+
<li>
|
|
32
|
+
<%= link_to t('.albums.manage'), refinery.photo_gallery_admin_albums_path,
|
|
33
|
+
:class => 'album_edit_icon' %>
|
|
34
|
+
</li>
|
|
35
|
+
<li>
|
|
36
|
+
<%= link_to t('.albums.new'), refinery.new_photo_gallery_admin_album_path,
|
|
37
|
+
:class => 'album_add_icon' %>
|
|
38
|
+
</li>
|
|
39
|
+
</ul>
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
</nav>
|
|
43
|
+
|
|
44
|
+
<% content_for :stylesheets, stylesheet_link_tag('refinery/photo_gallery/admin/backend') %>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<li class='clearfix record <%= cycle("on", "on-hover") %>' id="<%= dom_id(album) -%>">
|
|
2
|
+
<span class='title'>
|
|
3
|
+
<%= album.title %>
|
|
4
|
+
<%#= album.photos.count %>
|
|
5
|
+
<span class="preview">
|
|
6
|
+
<%= album.created_at.try(:strftime, '%b %d, %Y') %>
|
|
7
|
+
</span>
|
|
8
|
+
</span>
|
|
9
|
+
<span class='actions'>
|
|
10
|
+
<%#= link_to refinery_icon_tag("application_go.png"), refinery.photo_gallery_album_path(album),
|
|
11
|
+
:title => t('.view_live_html'),
|
|
12
|
+
:target => "_blank" %>
|
|
13
|
+
|
|
14
|
+
<%= link_to (image_tag 'refinery/photo_gallery/admin/icons/photo_add.png'),
|
|
15
|
+
refinery.upload_photo_gallery_admin_album_photos_path(album),
|
|
16
|
+
:title => t('.upload_photos') %>
|
|
17
|
+
<%= link_to (image_tag 'refinery/photo_gallery/admin/icons/photo_edit.png'),
|
|
18
|
+
refinery.edit_multiple_photo_gallery_admin_album_photos_path(album),
|
|
19
|
+
:title => t('.edit_photos') %>
|
|
20
|
+
<%= link_to (image_tag 'refinery/photo_gallery/admin/icons/album_edit.png'),
|
|
21
|
+
refinery.edit_photo_gallery_admin_album_path(album),
|
|
22
|
+
:title => t('.edit') %>
|
|
23
|
+
<%= link_to refinery_icon_tag("delete.png"), refinery.photo_gallery_admin_album_path(album),
|
|
24
|
+
:class => "cancel confirm-delete",
|
|
25
|
+
:title => t('.delete'),
|
|
26
|
+
:method => :delete,
|
|
27
|
+
:data => {
|
|
28
|
+
:confirm => t('message', :scope => 'refinery.admin.delete', :title => album.title)
|
|
29
|
+
} %>
|
|
30
|
+
</span>
|
|
31
|
+
</li>
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<%= form_for [refinery, :photo_gallery_admin, @album] do |f| -%>
|
|
2
|
+
<% album_photos_count = @album.photos.count #reduce sql queries%>
|
|
3
|
+
<%= render :partial => "/refinery/admin/error_messages",
|
|
4
|
+
:locals => {
|
|
5
|
+
:object => f.object,
|
|
6
|
+
:include_object_name => true
|
|
7
|
+
} %>
|
|
8
|
+
|
|
9
|
+
<div class='field'>
|
|
10
|
+
<%= f.label :title, :class=>"required" %><br />
|
|
11
|
+
<%= f.text_field :title, {:class => 'larger widest'} %><br />
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
<%# TODO use pop up to create collection %>
|
|
15
|
+
<div class='field'>
|
|
16
|
+
<%= label :collection, t('.album_belongs_to_collection') %>
|
|
17
|
+
<%= collection_select(:album, :collection_ids, Refinery::PhotoGallery::Collection.all(:order=> "title ASC"), :id, :title,
|
|
18
|
+
{ },
|
|
19
|
+
{ :data => {:placeholder=> t('.choose_collection')}, :multiple=> true, :class=> "chzn-select", :style=>"width:400px;"}) %>
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
<% if @album.title.blank? || @album.path.blank? # during creating album %>
|
|
23
|
+
<div class='field'>
|
|
24
|
+
<%= f.label :path_prefix, t('.path_prefix') %><br />
|
|
25
|
+
<%= f.text_field :path_prefix, :size=> 5, :maxlength=> 5 %><br />
|
|
26
|
+
</div>
|
|
27
|
+
<% elsif album_photos_count == 0 # allow to edit path only if there are no photos in album %>
|
|
28
|
+
<%#TODO if there are some photos in album, we must change folder paths on disk %>
|
|
29
|
+
<div class='field'>
|
|
30
|
+
<%= f.label :path %><br />
|
|
31
|
+
<%= f.text_field :path %><br />
|
|
32
|
+
</div>
|
|
33
|
+
<% end %>
|
|
34
|
+
|
|
35
|
+
<div class='field'>
|
|
36
|
+
<%= f.label :description %><br />
|
|
37
|
+
<%= f.text_area :description, :cols=>'65', :rows=>'7' %><br />
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
<div id="more_photo_options_field">
|
|
41
|
+
<p><a href="#" id="toggle_advanced_options" title="<%= t('.more_options_tooltip') %>"><%= t('.more_options') %></a></p>
|
|
42
|
+
</div>
|
|
43
|
+
|
|
44
|
+
<div id="more_options" style="display: none;">
|
|
45
|
+
<div class='field'>
|
|
46
|
+
<%= f.label :address %><br />
|
|
47
|
+
<%= f.text_area :address, { :rows => 3} %><br />
|
|
48
|
+
</div>
|
|
49
|
+
|
|
50
|
+
<div class='field'>
|
|
51
|
+
<%= f.label :latitude %><br />
|
|
52
|
+
<%= f.text_field :latitude %><br />
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
<div class='field'>
|
|
56
|
+
<%= f.label :longitude %><br />
|
|
57
|
+
<%= f.text_field :longitude %><br />
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
<div class='field'>
|
|
62
|
+
<%= f.label :note %><br />
|
|
63
|
+
<%= f.text_area :note, :cols=>65, :rows=> 7 %><br />
|
|
64
|
+
</div>
|
|
65
|
+
</div>
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
<br />
|
|
69
|
+
<%= t('.number_of_photos', :number=> album_photos_count ) %><br/>
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
<%= render :partial => "/refinery/admin/form_actions",
|
|
73
|
+
:locals => {
|
|
74
|
+
:f => f,
|
|
75
|
+
:continue_editing => false,
|
|
76
|
+
:delete_title => t('delete', :scope => 'refinery.photo_gallery.admin.albums.album')
|
|
77
|
+
} %>
|
|
78
|
+
<% end %>
|