refinerycms-6hoursdaily-photo-gallery 0.0.4.dev
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +27 -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/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 +23 -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 +113 -0
- data/app/middleware/refinery/photo_gallery/admin/flash_session_cookie_middleware.rb +27 -0
- data/app/models/refinery/photo_gallery/album.rb +63 -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 +63 -0
- data/app/uploaders/refinery/photo_gallery/admin/file_uploader.rb +122 -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 +49 -0
- data/app/views/refinery/photo_gallery/collections/index.html.erb +13 -0
- data/app/views/refinery/photo_gallery/collections/show.html.erb +33 -0
- data/app/views/refinery/photo_gallery/shared/_layout.html.erb +22 -0
- data/app/views/refinery/photo_gallery/shared/_submenu.html.erb +5 -0
- data/config/initializers/carrierwave.rb +5 -0
- data/config/initializers/form_builder.rb +26 -0
- data/config/initializers/refinery/core.rb +10 -0
- data/config/initializers/s3.rb +11 -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/configuration.rb +33 -0
- data/lib/refinery/photo_gallery/engine.rb +33 -0
- data/lib/refinery/photo_gallery/version.rb +17 -0
- data/lib/refinery/photo_gallery.rb +30 -0
- data/lib/refinerycms-photo-gallery.rb +1 -0
- data/refinerycms-6hoursdaily-photo-gallery.gemspec +38 -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 +353 -0
@@ -0,0 +1,67 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Refinery
|
4
|
+
module PhotoGallery
|
5
|
+
module Admin
|
6
|
+
class PhotosController < ::Refinery::AdminController
|
7
|
+
include PhotosHelper
|
8
|
+
helper :"refinery/photo_gallery/admin/photos"
|
9
|
+
|
10
|
+
#TODO delete update method from routes
|
11
|
+
#TODO delete edit action from routes
|
12
|
+
|
13
|
+
#TODO after destroying album, delete empty folders
|
14
|
+
|
15
|
+
def upload
|
16
|
+
@album = Album.find( params[:album_id])
|
17
|
+
end
|
18
|
+
|
19
|
+
def create
|
20
|
+
@photo = Photo.new(params[:photo])
|
21
|
+
@photo.file = params[:file]
|
22
|
+
|
23
|
+
if @photo.save!
|
24
|
+
render :partial=> 'form_fields', :locals => {:photo => @photo }
|
25
|
+
else
|
26
|
+
render :text => @photo.errors.full_messages.join(" "), :status=> 500
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def edit_multiple
|
31
|
+
@album = Album.find( params[:album_id] )
|
32
|
+
@photos = @album.photos.order("created_at DESC")
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
def update_multiple
|
37
|
+
photo_ids = params[:photos][:photo].map{ |key, hash| key }
|
38
|
+
|
39
|
+
@photos = Photo.find(photo_ids)
|
40
|
+
@photos.each do |photo|
|
41
|
+
photo.update_attributes(params[:photos][:photo][photo.id.to_s]) #TODO use ! method and validate exceptions
|
42
|
+
end
|
43
|
+
|
44
|
+
flash[:notice] = t('updated', :scope=> 'refinery.photo_gallery.admin.photos')
|
45
|
+
redirect_to refinery.photo_gallery_admin_albums_path
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
def destroy
|
50
|
+
@photo = Photo.find( params[:id])
|
51
|
+
|
52
|
+
if @photo.destroy
|
53
|
+
respond_to do |format|
|
54
|
+
format.js {
|
55
|
+
render :partial=> "destroy", :locals => {:photo => @photo}
|
56
|
+
}
|
57
|
+
end
|
58
|
+
else
|
59
|
+
render :text => "Error" , :status=> 500
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Refinery
|
2
|
+
module PhotoGallery
|
3
|
+
class AlbumsController < ::ApplicationController
|
4
|
+
include PhotoGalleryHelper, AlbumsHelper
|
5
|
+
helper :'refinery/photo_gallery/photo_gallery'
|
6
|
+
|
7
|
+
|
8
|
+
def show
|
9
|
+
@collections = Collection.has_albums
|
10
|
+
|
11
|
+
@albums = Album.find_by_collection_id(params[:collection_id])
|
12
|
+
@album = Album.find(params[:id])
|
13
|
+
@collection = Collection.find_by_id(params[:collection_id])
|
14
|
+
|
15
|
+
@photos = Photo.where("album_id = ? ", params[:id]).paginate(:page => params[:page], :per_page => 12).order("id ASC")
|
16
|
+
|
17
|
+
respond_to do |format|
|
18
|
+
format.html
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Refinery
|
2
|
+
module PhotoGallery
|
3
|
+
class CollectionsController < ::ApplicationController
|
4
|
+
include PhotoGalleryHelper
|
5
|
+
helper :'refinery/photo_gallery/photo_gallery'
|
6
|
+
|
7
|
+
def index
|
8
|
+
@collections = Collection.has_albums
|
9
|
+
|
10
|
+
respond_to do |format|
|
11
|
+
format.html
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def show
|
16
|
+
@collections = Collection.has_albums
|
17
|
+
|
18
|
+
@albums = Album.find_by_collection_id(params[:id])
|
19
|
+
|
20
|
+
respond_to do |format|
|
21
|
+
format.html
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
module Refinery
|
2
|
+
module PhotoGallery
|
3
|
+
module PhotoGalleryHelper
|
4
|
+
|
5
|
+
def message_albums_length_is_zero
|
6
|
+
if @albums.length == 0
|
7
|
+
t('.no_albums')
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def message_photos_length_is_zero
|
12
|
+
if @photos.length == 0
|
13
|
+
t('.no_photos')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def message_collections_length_is_zero
|
18
|
+
if @collections.length == 0
|
19
|
+
t('.no_collections')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
def generate_photo_gallery_menu( collections, albums, options = {} )
|
26
|
+
content_tag(:ul, {}, options[:ul] ) do
|
27
|
+
collections.each do |collection|
|
28
|
+
|
29
|
+
if params[:collection_id].present? && params[:id].present? # in albums controller
|
30
|
+
collection_id = params[:collection_id]
|
31
|
+
elsif params[:id].present? #in collection controller
|
32
|
+
collection_id = params[:id]
|
33
|
+
else
|
34
|
+
collection_id = 0 #only ensure initialization
|
35
|
+
end
|
36
|
+
|
37
|
+
concat(content_tag(:li, {:style => 'list-style-type: none;
|
38
|
+
text-align:center;
|
39
|
+
font-size: 1.89em;'}, options[:li]) do
|
40
|
+
concat(link_to (collection.title + " <span style='font-size: .89em; font-style: italic;'>
|
41
|
+
(#{collection.updated_at.strftime('%B %d')})</span>").html_safe,
|
42
|
+
refinery.photo_gallery_collection_path(collection))
|
43
|
+
|
44
|
+
# display albums of active collection
|
45
|
+
concat(
|
46
|
+
content_tag(:table, :class => 'table table-hover table-striped table-bordered', :style => 'margin-top: 25px;') do
|
47
|
+
|
48
|
+
if collection_id == collection.id.to_s
|
49
|
+
albums.each do |album|
|
50
|
+
concat(
|
51
|
+
content_tag(:tr) do
|
52
|
+
concat(
|
53
|
+
# album cover
|
54
|
+
content_tag(:td, :style => 'width: 150px;') do
|
55
|
+
concat(
|
56
|
+
link_to image_tag(album.photos.first.file.album.url),
|
57
|
+
refinery.photo_gallery_collection_album_path({:id=> album.id,
|
58
|
+
:collection_id => collection_id})
|
59
|
+
)
|
60
|
+
end
|
61
|
+
)
|
62
|
+
# album info
|
63
|
+
concat(
|
64
|
+
content_tag(:td) do
|
65
|
+
concat(
|
66
|
+
content_tag(:ul) do
|
67
|
+
concat(
|
68
|
+
content_tag(:li, :style => 'list-style-type: none;') do
|
69
|
+
concat(
|
70
|
+
content_tag(:h3, :style => 'font-size: .75em') do
|
71
|
+
concat(
|
72
|
+
link_to album.title, refinery.photo_gallery_collection_album_path({:id=> album.id, :collection_id => collection_id})
|
73
|
+
)
|
74
|
+
end
|
75
|
+
)
|
76
|
+
end
|
77
|
+
)
|
78
|
+
concat(
|
79
|
+
content_tag(:li, "Description", :style => 'list-style-type: none; font-size: 15px; font-style: italic;')
|
80
|
+
)
|
81
|
+
concat(
|
82
|
+
content_tag(:li, :style => 'list-style-type: none; font-size: 18px;') do
|
83
|
+
concat(
|
84
|
+
album.description
|
85
|
+
)
|
86
|
+
end
|
87
|
+
)
|
88
|
+
concat(
|
89
|
+
content_tag(:li, :style => 'list-style-type: none; font-size: 15px; text-align: right;') do
|
90
|
+
concat(
|
91
|
+
link_to 'View Album', refinery.photo_gallery_collection_album_path({:id=> album.id, :collection_id => collection_id}),
|
92
|
+
:class => 'btn btn-small btn-info'
|
93
|
+
)
|
94
|
+
end
|
95
|
+
)
|
96
|
+
end
|
97
|
+
)
|
98
|
+
end
|
99
|
+
)
|
100
|
+
end
|
101
|
+
)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end )
|
105
|
+
|
106
|
+
|
107
|
+
end)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
@@ -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,63 @@
|
|
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? && self.path.blank?
|
53
|
+
self.path = self.title.parameterize
|
54
|
+
elsif self.path.present? && self.title.present?
|
55
|
+
# dont't update path, when album has photos and we change title
|
56
|
+
else
|
57
|
+
self.path = [self.path_prefix, self.title.parameterize].join('-')
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
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,63 @@
|
|
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
|
+
begin
|
31
|
+
photo = MiniExiftool.new(self.file.file.file, {:numerical=> true})
|
32
|
+
|
33
|
+
self.longitude = photo.GPSLongitude if self.longitude.nil?
|
34
|
+
self.latitude = photo.GPSLatitude if self.latitude.nil?
|
35
|
+
self.title = photo.DocumentName if photo.DocumentName.present?
|
36
|
+
self.description = photo.ImageDescription if self.description.nil? && photo.ImageDescription != 'Exif_JPEG_PICTURE'
|
37
|
+
# TODO read keywords from exif
|
38
|
+
rescue
|
39
|
+
p "ERROR raised exception during MiniExiftool reading"
|
40
|
+
ensure
|
41
|
+
self.description = "" if self.description.nil? # Because description is concating in helpers, this can't be null
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
=begin
|
47
|
+
#TODO add checkbox to check if it should be writed to exif, globally on/off writing
|
48
|
+
def exif_write
|
49
|
+
# should only write if tags are changed as images can be large and thus ExifTool will take a while to write to the file
|
50
|
+
photo = MiniExiftool.new(self.file.file.file)
|
51
|
+
photo.GPSLongitude = self.longitude
|
52
|
+
photo.GPSLatitude = self.latitude
|
53
|
+
photo.DocumentName = self.title
|
54
|
+
photo.ImageDescription = self.description
|
55
|
+
photo.Keywords = self.tags
|
56
|
+
photo.save
|
57
|
+
end
|
58
|
+
=end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
@@ -0,0 +1,122 @@
|
|
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
|
+
|
29
|
+
def cache_dir
|
30
|
+
"tmp"
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
=begin
|
36
|
+
#Fix for bug TypeError: can't convert nil into String #TODO it should work without this method, but don't. Why?
|
37
|
+
def to_s
|
38
|
+
store_dir + '/' + full_filename(original_filename)
|
39
|
+
end
|
40
|
+
=end
|
41
|
+
|
42
|
+
# Override the directory where uploaded files will be stored
|
43
|
+
# This is a sensible default for uploaders that are meant to be mounted:
|
44
|
+
def store_dir
|
45
|
+
"photogallery/#{model.album.path}"
|
46
|
+
end
|
47
|
+
|
48
|
+
# Provide a default URL as a default if there hasn't been a file uploaded
|
49
|
+
# def default_url
|
50
|
+
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
|
51
|
+
# end
|
52
|
+
|
53
|
+
# Process files as they are uploaded.
|
54
|
+
# process :scale => [200, 300]
|
55
|
+
#
|
56
|
+
# def scale(width, height)
|
57
|
+
# # do something
|
58
|
+
# end
|
59
|
+
|
60
|
+
# Create different versions of your uploaded files
|
61
|
+
version :collection do
|
62
|
+
process :resize_to_fill => Refinery::PhotoGallery.collection_dimensions
|
63
|
+
def store_dir
|
64
|
+
"thumbs/#{model.album.path}"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
version :album do
|
68
|
+
process :resize_to_fill => Refinery::PhotoGallery.album_dimensions
|
69
|
+
def store_dir
|
70
|
+
"thumbs/#{model.album.path}"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
version :preview do
|
74
|
+
process :resize_to_fit => Refinery::PhotoGallery.preview_dimensions
|
75
|
+
def store_dir
|
76
|
+
"thumbs/#{model.album.path}"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
version :single do
|
80
|
+
process :resize_to_limit => Refinery::PhotoGallery.single_dimensions
|
81
|
+
def store_dir
|
82
|
+
"thumbs/#{model.album.path}"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
# Add a white list of extensions which are allowed to be uploaded,
|
87
|
+
def extension_white_list
|
88
|
+
Refinery::PhotoGallery.extension_white_list
|
89
|
+
end
|
90
|
+
|
91
|
+
# Override the filename of the uploaded files
|
92
|
+
# def filename
|
93
|
+
# "something.jpg" if original_filename
|
94
|
+
# end
|
95
|
+
|
96
|
+
|
97
|
+
# Deleting uploaded file in files/ dir. This method dont do removing of original file in tmp
|
98
|
+
def delete_uploaded_file(new_file)
|
99
|
+
if version_name.blank? && Refinery::PhotoGallery.delete_uploaded_file
|
100
|
+
filename_to_delete = File.join(Rails.root.to_s,Refinery::PhotoGallery.photo_gallery_dir_relative_to_root, store_dir, filename )
|
101
|
+
File.delete(filename_to_delete)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
# store! nil's the cache_id after it finishes so we need to remember it for deletion
|
106
|
+
def remember_cache_id(new_file)
|
107
|
+
@cache_id_was = cache_id
|
108
|
+
end
|
109
|
+
|
110
|
+
# 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.
|
111
|
+
def delete_tmp_dir(new_file)
|
112
|
+
# versions hash is inicialized after storing all versions. We want to delete folder after all versions are restored
|
113
|
+
# make sure we don't delete other things accidentally by checking the name pattern
|
114
|
+
if versions.length > 0 && @cache_id_was.present? && @cache_id_was =~ /\A[\d]{8}\-[\d]{4}\-[\d]+\-[\d]{4}\z/
|
115
|
+
FileUtils.rm_rf(File.join(Rails.root.to_s,Refinery::PhotoGallery.photo_gallery_dir_relative_to_root, cache_dir, @cache_id_was))
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
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>
|