refinerycms-photo-gallery 0.0.2.dev → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/Changelog.md +18 -0
  2. data/README.md +40 -22
  3. data/Rakefile +20 -0
  4. data/app/assets/javascripts/refinery/photo_gallery/admin/{photo_gallery.js → photo_gallery.js.erb} +26 -1
  5. data/app/assets/javascripts/refinery/photo_gallery/photo_gallery.js +28 -0
  6. data/app/controllers/refinery/photo_gallery/admin/albums_controller.rb +2 -1
  7. data/app/controllers/refinery/photo_gallery/admin/photos_controller.rb +2 -0
  8. data/app/helpers/refinery/photo_gallery/admin/photos_helper.rb +4 -2
  9. data/app/helpers/refinery/photo_gallery/photo_gallery_helper.rb +1 -50
  10. data/app/models/refinery/album_page.rb +11 -0
  11. data/app/models/refinery/photo_gallery/album.rb +7 -14
  12. data/app/models/refinery/photo_gallery/collection.rb +3 -2
  13. data/app/models/refinery/photo_gallery/photo.rb +7 -5
  14. data/app/sweepers/refinery/photo_gallery/admin/album_sweeper.rb +33 -0
  15. data/app/sweepers/refinery/photo_gallery/admin/photo_sweeper.rb +27 -0
  16. data/app/uploaders/refinery/photo_gallery/admin/file_uploader.rb +20 -29
  17. data/app/views/refinery/admin/pages/tabs/_form.html.erb +13 -0
  18. data/app/views/refinery/admin/pages/tabs/_photo_gallery.html.erb +12 -0
  19. data/app/views/refinery/admin/pages/tabs/_photo_pages_bar.html.erb +4 -0
  20. data/app/views/refinery/photo_gallery/admin/_submenu.html.erb +43 -36
  21. data/app/views/refinery/photo_gallery/admin/albums/index.html.erb +2 -2
  22. data/app/views/refinery/photo_gallery/admin/photos/_form_fields.html.erb +1 -1
  23. data/app/views/refinery/photo_gallery/admin/photos/upload.html.erb +2 -13
  24. data/app/views/refinery/photo_gallery/albums/_photos.html.erb +20 -0
  25. data/app/views/refinery/photo_gallery/albums/_photos.js.erb +5 -0
  26. data/app/views/refinery/photo_gallery/albums/_show.html.erb +18 -0
  27. data/config/locales/en.yml +45 -27
  28. data/config/locales/sk.yml +47 -27
  29. data/config/routes.rb +1 -11
  30. data/db/migrate/20120805222126_create_album_pages.rb +19 -0
  31. data/lib/generators/refinery/templates/config/initializers/refinery/photo_gallery.rb.erb +3 -7
  32. data/lib/refinery/photo_gallery.rb +5 -3
  33. data/lib/refinery/photo_gallery/configuration.rb +7 -9
  34. data/lib/refinery/photo_gallery/engine.rb +17 -2
  35. data/lib/refinery/photo_gallery/extensions/pages_controller_extension.rb +30 -0
  36. data/lib/refinery/photo_gallery/extensions/pages_extension.rb +50 -0
  37. data/lib/refinery/photo_gallery/version.rb +2 -2
  38. data/{refinerycms-balder-photo-gallery.gemspec → refinerycms-photo-gallery.gemspec} +0 -0
  39. data/screenshots/13_pages.png +0 -0
  40. metadata +23 -16
  41. data/app/controllers/refinery/photo_gallery/albums_controller.rb +0 -22
  42. data/app/controllers/refinery/photo_gallery/collections_controller.rb +0 -28
  43. data/app/middleware/refinery/photo_gallery/admin/flash_session_cookie_middleware.rb +0 -27
  44. data/app/views/refinery/photo_gallery/albums/show.html.erb +0 -34
  45. data/app/views/refinery/photo_gallery/collections/index.html.erb +0 -9
  46. data/app/views/refinery/photo_gallery/collections/show.html.erb +0 -19
  47. data/app/views/refinery/photo_gallery/shared/_layout.html.erb +0 -22
  48. data/app/views/refinery/photo_gallery/shared/_submenu.html.erb +0 -4
  49. data/config/initializers/session_store.rb +0 -10
@@ -0,0 +1,18 @@
1
+ ## 0.1.0 [24 September 2012]
2
+ * drop collection thumbnail version
3
+ * support for old fancybox v1.3
4
+ * auto photo orientation, by default
5
+ * added admin tab to pages, enable attach photo album to page
6
+ * added fragment caching for photos on frontend
7
+ * added ajaxified pagination with history.pushState for photos on frontend
8
+ * taking filename before uploading as photo title (fixes problems with filenames with diacritic - it took filename after carrierwave preprocessing as photo title - with broken diacritic)
9
+ * fixed backend searching
10
+
11
+ ## 0.0.3.dev [16 August 2012]
12
+ * bugfixes
13
+
14
+ ## 0.0.2.dev [11 August 2012]
15
+ * bugfixes
16
+
17
+ ## 0.0.1.dev [8 August 2012]
18
+ * initial commit
data/README.md CHANGED
@@ -6,23 +6,22 @@ __Photo gallery engine for Refinery CMS.__
6
6
 
7
7
  This version of refinerycms-photo-gallery supports Rails 3.2.x and Refinery CMS ~> 2.0.3.
8
8
 
9
- Client side image resizing with Plupload is possible on Firefox 3.5+ (with fixed quality) and Chrome.
10
- Safari doesn't support direct data access to the selected files. Opera 12.00 + supports drag&drop and also client side image resizing.
11
-
12
-
13
9
  ## Features
14
10
 
15
11
  * Multiple photo uploading with [Plupload](http://www.plupload.com/) 1.5.4
16
- * Support for multiple runtimes (because of bug now works only HTML5): HTML5, Flash, Gears, Silverlight, HTML4
12
+ * Currently supported HTML5 runtime, flash implementation is broken
17
13
  * Client side photo resizing to do faster uploading on slow connections
18
14
  * Server side resizing with Carrierwave
15
+ * Attach album to page. One album can be attached to many pages.
19
16
  * Grouping albums to collections. Album can be placed in one or more collections.
20
- * Ajax photo edit during uploading
17
+ * Ajaxified photo editation during uploading
21
18
  * Reading EXIF records from file - GPS latitude/longitude, photo title, photo description (In Linux you can put EXIF data using [digiKam](www.digikam.org/) )
22
19
  * Multiple photo editing at once
23
- * Fully configurable, fully translatable, searchable
20
+ * Fully configurable, searchable
24
21
  * Using [Fancybox](http://fancyapps.com/fancybox/) 2.0.6 for frontend image slideshow. Read Fancybox license before you
25
22
  use it on profit websites.
23
+ * Fragment caching on frontend
24
+ * Ajaxified pagination with history.pushState on frontend
26
25
 
27
26
  ## Screenshots
28
27
 
@@ -53,11 +52,10 @@ TODO
53
52
  Gem is fully translated to slovak and english. Plupload is translated to 24 languages. You can add your own to
54
53
  photo_gallery/app/assets/javascripts/refinery/photo_gallery/admin/plupload/i18n and enable it in config.plupload_locale
55
54
 
55
+ ## Browser support
56
+ Client side image resizing with Plupload is possible on Firefox 3.5+ (with fixed quality) and Chrome.
57
+ Safari doesn't support direct data access to the selected files. Opera 12.00 + supports drag&drop and also client side image resizing.
56
58
 
57
- ## Working status
58
-
59
- This is development snapshot. It is not suitable to production now, I'm going to fix bug list and todo list and then I will create stable branch/version.
60
- But gem works, so if you want, feel free to try it and contribute :).
61
59
 
62
60
  ## Installation
63
61
 
@@ -75,7 +73,7 @@ Instructions for installation you can find under [www.sno.phy.queensu.ca/~phil/e
75
73
  Open up your ``Gemfile`` and add at the bottom this line:
76
74
 
77
75
  ```ruby
78
- gem 'refinerycms-photo-gallery', '~> 0.0.1.dev', :git => 'git://github.com/Matho/refinerycms-photo-gallery.git'
76
+ gem 'refinerycms-photo-gallery', '~> 0.1.0', :git => 'git://github.com/Matho/refinerycms-photo-gallery.git', :branch=>'0-1-stable'
79
77
  ```
80
78
 
81
79
  Now, run
@@ -104,6 +102,8 @@ rake db:seed
104
102
 
105
103
  You can configure gem in ``your_app_name/config/initializers/refinery/photo_gallery.rb``
106
104
 
105
+ If you want to use ajaxy pagination, copy ``app/assets/javascripts/refinery/photo_gallery/photo_gallery.js`` to your app's asset and add to manifest.
106
+
107
107
  Check, if you have ``jquery.js`` included in your backend.
108
108
 
109
109
  If you want to use Fancybox in frontend, copy ``photo_gallery/app/assets/images/refinery/photo_gallery/fancybox``, ``photo_gallery/app/assets/javascripts/refinery/photo_gallery/fancybox``, ``photo_gallery/app/assets/refinery/photo_gallery/stylesheets/fancybox`` to your
@@ -154,6 +154,30 @@ in your app, override it using rake refinery:override command and add this line
154
154
  </script>
155
155
  ```
156
156
 
157
+ If you want to use Fancybox 1.3, use this javascipt to initialize:
158
+ ```javascript
159
+ <script type="text/javascript">
160
+ $(document).ready(function() {
161
+ var load_fancybox = function loadFancybox() {
162
+ $("a[rel=group]").fancybox({
163
+ 'transitionIn' : 'none',
164
+ 'transitionOut' : 'none',
165
+ 'titlePosition' : 'over',
166
+ 'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
167
+ return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
168
+ }
169
+ });
170
+ };
171
+ load_fancybox();
172
+
173
+ $("#photo_gallery").on("gallery_loaded", function() {
174
+ load_fancybox();
175
+ });
176
+
177
+ });
178
+ </script>
179
+ ```
180
+
157
181
  Before production, don't forget to precompile assets by:
158
182
 
159
183
  ```ruby
@@ -185,17 +209,13 @@ Remove gem from Gemfile
185
209
 
186
210
  ## Todo list
187
211
 
188
- * fix support for refinerycms-search gem in backend/frontend
189
- * add support for amazon S3 storage
190
212
  * create app tests
191
- * repair problems with Flash runtime and test gears, silverlight and HTML4 runtime
192
213
  * show live links in admin
193
- * allow to check which photo is photo album preview
194
- * set albums public/not public.
214
+ * create pop-up window to upload photos from pages area, like page-images
195
215
  * add checkboxes to delete multiple/all photos in album
196
216
  * stop uploading
217
+ * add support for amazon S3 storage
197
218
  * travis, codeclimate
198
- * push to rubygem
199
219
 
200
220
 
201
221
  ## Known bugs
@@ -208,11 +228,9 @@ file extensions to upload queue. ( But server side validation reject these files
208
228
 
209
229
  ## Road map ?
210
230
 
211
- * album/photo tags using acts_as_taggable
212
- * show photo location on google maps
213
- * caching ?
214
231
  * GPS editing in degrees,minute,seconds format
215
- * album grouping by year (configurable)
232
+ * album/photo tags using acts_as_taggable ?
233
+ * show photo location on google maps ?
216
234
 
217
235
  ## Testing
218
236
 
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+
8
+ ENGINE_PATH = File.dirname(__FILE__)
9
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
10
+
11
+ if File.exists?(APP_RAKEFILE)
12
+ load 'rails/tasks/engine.rake'
13
+ end
14
+
15
+ require "refinerycms-testing"
16
+ Refinery::Testing::Railtie.load_tasks
17
+ Refinery::Testing::Railtie.load_dummy_tasks(ENGINE_PATH)
18
+
19
+ load File.expand_path('../tasks/testing.rake', __FILE__)
20
+ load File.expand_path('../tasks/rspec.rake', __FILE__)
@@ -1,3 +1,5 @@
1
+ <%# encoding: utf-8 %>
2
+
1
3
  $(function() {
2
4
  $('form#form_edit_photos').on("click", ".form-photo-field .form-actions-right .confirm-delete", function() {
3
5
  if ( confirm( $(this).attr('data-confirm') ) ) {
@@ -23,6 +25,29 @@ $(function() {
23
25
  }, 250);
24
26
  });
25
27
 
26
- $(".chzn-select").chosen();
28
+ $(".chzn-select").chosen(
29
+ {
30
+ no_results_text: "<%= I18n.t('chosen.no_results') %>"
31
+ }
32
+ );
33
+
34
+
35
+ $(".chzn-select-deselect").chosen({
36
+ no_results_text: "<%= I18n.t('chosen.no_results') %>",
37
+ allow_single_deselect:true}
38
+ );
39
+
40
+
41
+ $('#photo_gallery_wym_editation').on("click", ".form-actions .button", function() {
42
+
43
+ $.ajax({
44
+ type: "POST",
45
+ dataType: 'script',
46
+ data: { '_method': $(this).attr('data-method') },
47
+ url: this.href
48
+ });
49
+
50
+ return false;
51
+ });
27
52
 
28
53
  });
@@ -0,0 +1,28 @@
1
+ if (history && history.pushState) {
2
+ function slide_to(target){
3
+ var scrollToPosition = $(target).offset().top;
4
+ console.log(scrollToPosition);
5
+
6
+ $('html').animate({ 'scrollTop': scrollToPosition }, 600, function(){
7
+ //window.location.hash = "" + target;
8
+ // This hash change will jump the page to the top of the div with the same id
9
+ // so we need to force the page to back to the end of the animation
10
+ $('html').animate({ 'scrollTop': scrollToPosition }, 0);
11
+ });
12
+
13
+ }
14
+
15
+ $(document).ready(function(){
16
+
17
+ $('#photo_gallery').on("click", ".pagination a[href]", function() {
18
+ slide_to($('#photo_gallery'));
19
+ $.getScript(this.href);
20
+ history.pushState(null,"",this.href);
21
+ return false;
22
+ });
23
+
24
+ $(window).bind("popstate", function() {
25
+ $.getScript(location.href);
26
+ });
27
+ });
28
+ }
@@ -2,7 +2,7 @@ module Refinery
2
2
  module PhotoGallery
3
3
  module Admin
4
4
  class AlbumsController < ::Refinery::AdminController
5
-
5
+ cache_sweeper AlbumSweeper
6
6
  crudify :'refinery/photo_gallery/album', :order => "created_at DESC" , :xhr_paging => true
7
7
 
8
8
  def create
@@ -17,6 +17,7 @@ module Refinery
17
17
  end
18
18
  end
19
19
 
20
+
20
21
  end
21
22
  end
22
23
  end
@@ -6,6 +6,7 @@ module Refinery
6
6
  class PhotosController < ::Refinery::AdminController
7
7
  include PhotosHelper
8
8
  helper :"refinery/photo_gallery/admin/photos"
9
+ cache_sweeper PhotoSweeper
9
10
 
10
11
  #TODO delete update method from routes
11
12
  #TODO delete edit action from routes
@@ -19,6 +20,7 @@ module Refinery
19
20
  def create
20
21
  @photo = Photo.new(params[:photo])
21
22
  @photo.file = params[:file]
23
+ @photo.title = get_filename_part(params[:name])
22
24
 
23
25
  if @photo.save!
24
26
  render :partial=> 'form_fields', :locals => {:photo => @photo }
@@ -3,8 +3,10 @@ module Refinery
3
3
  module Admin
4
4
  module PhotosHelper
5
5
 
6
-
6
+ def get_filename_part(filename)
7
+ filename[0, filename.rindex('.') ]
8
+ end
7
9
  end
8
10
  end
9
11
  end
10
- end
12
+ end
@@ -2,57 +2,8 @@ module Refinery
2
2
  module PhotoGallery
3
3
  module PhotoGalleryHelper
4
4
 
5
- def message_albums_length_is_zero
6
- if @albums.length == 0
7
- t('.no_albums')
8
- end
9
- end
10
5
 
11
- def message_photos_length_is_zero
12
- if @photos.length == 0
13
- t('.no_photos')
14
- end
15
- end
16
6
 
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, {}, options[:li]) do
38
- concat(link_to collection.title, refinery.photo_gallery_collection_path(collection))
39
-
40
- # display albums of active collection
41
- concat(content_tag(:ul, {}, options[:ul] ) do
42
- if collection_id == collection.id.to_s
43
- albums.each do |album|
44
- concat(content_tag(:li, {}, options[:li]) do
45
- link_to album.title, refinery.photo_gallery_collection_album_path({:id=> album.id, :collection_id => collection_id})
46
- end )
47
- end
48
- end
49
- end )
50
-
51
-
52
- end)
53
- end
54
- end
55
- end
56
7
  end
57
8
  end
58
- end
9
+ end
@@ -0,0 +1,11 @@
1
+ module Refinery
2
+ class AlbumPage < Refinery::Core::BaseModel
3
+
4
+ belongs_to :album , :class_name => Refinery::PhotoGallery::Album
5
+ belongs_to :page, :polymorphic => true
6
+
7
+
8
+ attr_accessible :page_id, :page_type, :album_id
9
+
10
+ end
11
+ end
@@ -5,6 +5,7 @@ module Refinery
5
5
  has_many :collection_albums , :dependent => :destroy
6
6
  has_many :collections, :through => :collection_albums
7
7
 
8
+
8
9
  before_validation :set_path
9
10
  validates :title, :presence => true
10
11
  validates :path, :presence => true, :uniqueness => true
@@ -15,26 +16,18 @@ module Refinery
15
16
 
16
17
  self.per_page = Refinery::PhotoGallery.albums_per_page
17
18
 
19
+
20
+ def self.with_collection_id
21
+ select("refinery_photo_gallery_albums.*, refinery_photo_gallery_collection_albums.collection_id ").joins(:collection_albums)
22
+ end
23
+
18
24
  scope :find_by_collection_id, lambda {|collection_id|
19
- select("refinery_photo_gallery_albums.*").
25
+ select("refinery_photo_gallery_albums.*").
20
26
  joins(:collection_albums).
21
27
  where("refinery_photo_gallery_collection_albums.collection_id = ?
22
28
  ", collection_id).
23
29
  order('created_at DESC, title ASC')
24
30
  }
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
31
 
39
32
  def collection_ids
40
33
  Refinery::PhotoGallery::CollectionAlbum.select('collection_id').where("album_id = ?", self.id ).map{|ca| ca.collection_id }
@@ -13,11 +13,12 @@ module Refinery
13
13
 
14
14
  self.per_page = Refinery::PhotoGallery.collections_per_page
15
15
 
16
- scope :has_albums, lambda {
16
+ def self.has_albums
17
17
  select("refinery_photo_gallery_collections.*").uniq.
18
18
  joins(:collection_albums).
19
19
  order('created_at DESC, title ASC')
20
- }
20
+ end
21
+
21
22
  =begin
22
23
  def to_param
23
24
  "#{id}-#{title.parameterize}"
@@ -27,22 +27,23 @@ module Refinery
27
27
  end
28
28
 
29
29
  def exif_read
30
- begin
30
+ begin
31
31
  photo = MiniExiftool.new(self.file.file.file, {:numerical=> true})
32
32
 
33
+ self.title = photo.DocumentName if !photo.DocumentName.nil?
33
34
  self.longitude = photo.GPSLongitude if self.longitude.nil?
34
35
  self.latitude = photo.GPSLatitude if self.latitude.nil?
35
- self.title = photo.DocumentName if photo.DocumentName.present?
36
36
  self.description = photo.ImageDescription if self.description.nil? && photo.ImageDescription != 'Exif_JPEG_PICTURE'
37
- # TODO read keywords from exif
37
+ # TODO read keywords from exif
38
38
  rescue
39
39
  p "ERROR raised exception during MiniExiftool reading"
40
- ensure
40
+
41
+ ensure
41
42
  self.description = "" if self.description.nil? # Because description is concating in helpers, this can't be null
42
43
  end
43
- end
44
44
  end
45
45
 
46
+
46
47
  =begin
47
48
  #TODO add checkbox to check if it should be writed to exif, globally on/off writing
48
49
  def exif_write
@@ -60,3 +61,4 @@ module Refinery
60
61
  end
61
62
  end
62
63
  end
64
+
@@ -0,0 +1,33 @@
1
+ module Refinery
2
+ module PhotoGallery
3
+ module Admin
4
+ class AlbumSweeper < ActionController::Caching::Sweeper
5
+ observe Album
6
+
7
+
8
+ def sweep_album(album)
9
+ expire_fragment("refinery/photo_gallery/albums/#{album.id}")
10
+ end
11
+
12
+ def sweep_album_with_photos(album)
13
+ sweep_album(album)
14
+
15
+ # only file store supports regexp
16
+ begin
17
+ # This is slow, but I was unable to get the actual cache folder path.
18
+ expire_fragment( %r{refinery/photo_gallery/albums/#{photo.album_id}/page/\d*})
19
+ rescue NotImplementedError
20
+ Rails.cache.clear
21
+ warn "**** [REFINERY PHOTO GALLERY] The cache store you are using is not compatible with this engine. Only file_store is supported. Clearing entire cache instead ***"
22
+ ensure
23
+ return true
24
+ end
25
+ end
26
+
27
+ alias_method :after_create, :sweep_album
28
+ alias_method :after_update, :sweep_album
29
+ alias_method :after_destroy, :sweep_album_with_photos
30
+ end
31
+ end
32
+ end
33
+ end