refinerycms-photo-gallery 0.0.2.dev → 0.1.0

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.
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,27 @@
1
+ module Refinery
2
+ module PhotoGallery
3
+ module Admin
4
+ class PhotoSweeper < ActionController::Caching::Sweeper
5
+ observe Photo
6
+
7
+ def sweep(photo)
8
+ # only file store supports regexp
9
+ begin
10
+ # TODO This is slow, but I was unable to get the actual cache folder path.
11
+ # This should be replaced with FileUtils.rm to get better speed
12
+ expire_fragment( %r{refinery/photo_gallery/albums/#{photo.album_id}/page/\d*})
13
+ rescue NotImplementedError
14
+ Rails.cache.clear
15
+ 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 ***"
16
+ ensure
17
+ return true
18
+ end
19
+ end
20
+
21
+ alias_method :after_create, :sweep
22
+ alias_method :after_update, :sweep
23
+ alias_method :after_destroy, :sweep
24
+ end
25
+ end
26
+ end
27
+ end
@@ -27,12 +27,6 @@ module Refinery
27
27
  storage :file
28
28
  end
29
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
30
 
37
31
  # Override the directory where uploaded files will be stored
38
32
  # This is a sensible default for uploaders that are meant to be mounted:
@@ -44,44 +38,33 @@ module Refinery
44
38
  "tmp"
45
39
  end
46
40
 
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
41
 
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
42
  version :album do
67
- process :resize_to_fill => Refinery::PhotoGallery.album_dimensions
43
+ resize_to_fill(Refinery::PhotoGallery.album_dimensions[0], Refinery::PhotoGallery.album_dimensions[1], 'North')
44
+ process :auto_orient
45
+
68
46
  def store_dir
69
47
  "thumbs/#{model.album.path}"
70
48
  end
71
49
  end
72
50
  version :preview do
73
51
  process :resize_to_fit => Refinery::PhotoGallery.preview_dimensions
52
+ process :auto_orient
74
53
  def store_dir
75
54
  "thumbs/#{model.album.path}"
76
55
  end
77
56
  end
78
57
  version :single do
58
+
79
59
  process :resize_to_limit => Refinery::PhotoGallery.single_dimensions
60
+ process :auto_orient
61
+
80
62
  def store_dir
81
63
  "thumbs/#{model.album.path}"
82
64
  end
83
65
  end
84
66
 
67
+
85
68
  # Add a white list of extensions which are allowed to be uploaded,
86
69
  def extension_white_list
87
70
  Refinery::PhotoGallery.extension_white_list
@@ -93,12 +76,20 @@ module Refinery
93
76
  # end
94
77
 
95
78
 
79
+ def auto_orient
80
+ manipulate! do |image|
81
+ image.auto_orient
82
+ image
83
+ end
84
+ end
85
+
86
+
96
87
  # Deleting uploaded file in files/ dir. This method dont do removing of original file in tmp
97
88
  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
89
+ if version_name.blank? && Refinery::PhotoGallery.delete_uploaded_file
90
+ filename_to_delete = File.join(Rails.root.to_s,Refinery::PhotoGallery.photo_gallery_dir_relative_to_root, store_dir, filename )
91
+ File.delete(filename_to_delete)
92
+ end
102
93
  end
103
94
 
104
95
  # store! nil's the cache_id after it finishes so we need to remember it for deletion
@@ -0,0 +1,13 @@
1
+
2
+ <%= f.fields_for @page.album_page do |album_page_form| %>
3
+ <%= album_page_form.label :album_id, t('.join_page_with_album') %>
4
+ <%= album_page_form.grouped_collection_select( :album_id, Refinery::PhotoGallery::Collection.includes(:albums).all, :albums, :title, :id, :title,
5
+ { :include_blank => true},
6
+ { :data => {
7
+ :placeholder=> t('.choose_album')},
8
+ :multiple=> false,
9
+ :class=> "chzn-select-deselect",
10
+ :style=>"min-width: 300px;"
11
+ }) %>
12
+ <% end %>
13
+
@@ -0,0 +1,12 @@
1
+ <div class='wym_skin_refinery page_part'>
2
+ <%= render '/refinery/admin/pages/tabs/photo_pages_bar' %>
3
+
4
+ <div id="photo_gallery_wym_editation" class='wym_box field ' style="height: 300px;">
5
+ <% if @page.album_page.nil?
6
+ @page.build_album_page
7
+ end %>
8
+
9
+
10
+ <%= render "/refinery/admin/pages/tabs/form", :f => f %>
11
+ </div>
12
+ </div>
@@ -0,0 +1,4 @@
1
+ <div >
2
+ <span class='clearfix label_inline_with_link'></span>
3
+
4
+ </div>
@@ -1,44 +1,51 @@
1
1
  <nav id='actions' class='multilist'>
2
2
  <ul class='search_list'>
3
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>
4
+ <% if params[:controller] == "refinery/photo_gallery/admin/collections" %>
5
+ <%= render :partial => "/refinery/admin/search",
6
+ :locals => {
7
+ :url => refinery.photo_gallery_admin_collections_path
8
+ } %>
9
+ <% elsif params[:controller] == "refinery/photo_gallery/admin/albums" %>
10
+ <%= render :partial => "/refinery/admin/search",
11
+ :locals => {
12
+ :url => refinery.photo_gallery_admin_albums_path
13
+ } %>
14
+ <% end %>
15
+ </li>
16
+ </ul>
10
17
 
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>
18
+ <ul class='collapsible_menu'>
19
+ <li class='not_a_link'>
20
+ <%= link_to t('.collections.title'), '#',
21
+ :class => 'folder_icon' %>
22
+ </li>
23
+ <li>
24
+ <%= link_to t('.collections.manage'), refinery.photo_gallery_admin_collections_path,
25
+ :class => 'folder_edit_icon' %>
26
+ </li>
27
+ <li>
28
+ <%= link_to t('.collections.new'), refinery.new_photo_gallery_admin_collection_path,
29
+ :class => 'folder_add_icon' %>
30
+ </li>
31
+ </ul>
25
32
 
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>
33
+ <ul class='collapsible_menu'>
34
+ <li class='not_a_link'>
35
+ <%= link_to t('.albums.title'), '#',
36
+ :class => 'album_icon' %>
37
+ </li>
38
+ <li>
39
+ <%= link_to t('.albums.manage'), refinery.photo_gallery_admin_albums_path,
40
+ :class => 'album_edit_icon' %>
41
+ </li>
42
+ <li>
43
+ <%= link_to t('.albums.new'), refinery.new_photo_gallery_admin_album_path,
44
+ :class => 'album_add_icon' %>
45
+ </li>
46
+ </ul>
40
47
 
41
48
 
42
- </nav>
49
+ </nav>
43
50
 
44
- <% content_for :stylesheets, stylesheet_link_tag('refinery/photo_gallery/admin/backend') %>
51
+ <% content_for :stylesheets, stylesheet_link_tag('refinery/photo_gallery/admin/backend') %>
@@ -5,7 +5,7 @@
5
5
  <h2><%= t('results_for', :scope => 'refinery.admin.search', :query => params[:search]) %></h2>
6
6
  <% if @albums.any? %>
7
7
  <ul>
8
- <%= render :partial => "album", :album => @albums %>
8
+ <%= render :partial => "album", :collection => @albums %>
9
9
  </ul>
10
10
  <% else %>
11
11
  <p><%= t('no_results', :scope => 'refinery.admin.search') %></p>
@@ -25,4 +25,4 @@
25
25
  </p>
26
26
  <% end %>
27
27
  <% end %>
28
- </div>
28
+ </div>
@@ -1,7 +1,7 @@
1
1
  <div id="photo-<%= photo.id %>" class="form-photo-field">
2
2
  <%= fields_for "photos[photo]", photo, :index => photo.id do |p|%>
3
3
  <div class="form_photo_left">
4
- <%= link_to (image_tag photo.file.collection.url), photo.file.single.url, {:target=> "_blank"} %>
4
+ <%= link_to (image_tag photo.file.preview.url), photo.file.single.url, {:target=> "_blank"} %>
5
5
  </div>
6
6
 
7
7
  <div class="form_photo_right">
@@ -3,9 +3,7 @@
3
3
 
4
4
  <%= javascript_include_tag "/assets/refinery/photo_gallery/admin/plupload/plupload.full.js" -%>
5
5
  <%= javascript_include_tag "/assets/refinery/photo_gallery/admin/plupload/jquery.plupload.queue.js" -%>
6
- <% if Refinery::PhotoGallery.plupload_locale.present? %>
7
- <%= javascript_include_tag "/assets/refinery/photo_gallery/admin/plupload/i18n/" + Refinery::PhotoGallery.plupload_locale + ".js" -%>
8
- <% end %>
6
+ <%= javascript_include_tag "/assets/refinery/photo_gallery/admin/plupload/i18n/" + Refinery::PhotoGallery.plupload_locale.to_s + ".js" -%>
9
7
 
10
8
  <script type="text/javascript">
11
9
  <% session_key = Rails.application.config.session_options[:key] %>
@@ -31,12 +29,6 @@
31
29
  quality : <%= Refinery::PhotoGallery.client_side_resize_params[:quality] %>},
32
30
  <% end %>
33
31
 
34
- // Flash settings
35
- flash_swf_url : '/assets/refinery/photo_gallery/admin/plupload/plupload.flash.swf',
36
-
37
- // Silverlight settings
38
- silverlight_xap_url : '/assets/refinery/photo_gallery/admin/plupload/plupload.silverlight.xap',
39
-
40
32
  // Post init events, bound after the internal events
41
33
  init : {
42
34
  FileUploaded: function(up, file, info) {
@@ -81,7 +73,4 @@
81
73
  </div>
82
74
  <% end %>
83
75
 
84
-
85
-
86
- <br><%#= link_to "Edit uploaded photos", untouched_album_photos_path( @album ) %>
87
- <br><%#= link_to "Back to #{@album.title}", @album %>
76
+ <br><br>
@@ -0,0 +1,20 @@
1
+ <% cache "refinery/photo_gallery/albums/#{@page.album.id}/page/#{params[:page]}" do %>
2
+ <% photos_for_page = @page.photos_for_page(params[:page]) %>
3
+
4
+ <%= will_paginate photos_for_page %>
5
+
6
+ <ul id="gallery" class="clearfix">
7
+ <% photos_for_page.each_with_index do |photo, index| %>
8
+ <li>
9
+ <%= link_to (image_tag photo.file.url(:album), :width => Refinery::PhotoGallery.album_dimensions[0], :height => Refinery::PhotoGallery.album_dimensions[1] ), photo.file.single.url, {
10
+ :target=> "_blank",
11
+ :class=>"fancybox",
12
+ :data =>{:title=> t('.image') + ' ' + (index + 1 ).to_s + '/' + photos_for_page.total_pages.to_s + ' ' + photo.title + '<br/><br/>' + photo.description},
13
+ :rel=>"group",
14
+ :title=> photo.title } %>
15
+ </li>
16
+ <% end %>
17
+ </ul>
18
+
19
+ <%= will_paginate photos_for_page %>
20
+ <% end %>
@@ -0,0 +1,5 @@
1
+ $(document).ready(function(){
2
+ $('#photo_gallery').html("<%= escape_javascript( render :partial => "refinery/photo_gallery/albums/photos", :formats => [:html] ) %>");
3
+ // Needed for Fancybox 1.3.4. Fancybox v2 can handle ajax content replacement
4
+ $('#photo_gallery').trigger('gallery_loaded');
5
+ });
@@ -0,0 +1,18 @@
1
+ <% if @page.album.present? %>
2
+
3
+ <% cache "refinery/photo_gallery/albums/#{@page.album.id}" do %>
4
+ <h2 >
5
+ <%= @page.album.title %>
6
+ </h2>
7
+
8
+ <div>
9
+ <%= raw @page.album.description %>
10
+ </div>
11
+ <% end %>
12
+
13
+ <div id="photo_gallery">
14
+ <%= render :partial => "/refinery/photo_gallery/albums/photos" %>
15
+ </div>
16
+
17
+ <% end %>
18
+
@@ -1,19 +1,21 @@
1
1
  en:
2
+ chosen:
3
+ no_results: "No results matched"
2
4
  refinery:
5
+ admin:
6
+ pages:
7
+ tabs:
8
+ form:
9
+ join_page_with_album: "Join page with album:"
10
+ choose_album: "Click to choose photo album"
11
+ flash:
12
+ connection_destroyed: "Connection between album and page was successfully deleted."
3
13
  plugins:
4
14
  refinerycms_photo_gallery:
5
15
  title: Photo Gallery
6
16
  description: Provides advanced photo gallery
17
+ tab_name: Photo Gallery
7
18
  photo_gallery:
8
- albums:
9
- show:
10
- image: Image
11
- no_photos: There are no photos in this album yet
12
- collections:
13
- show:
14
- no_albums: There are no albums in this collection yet
15
- index:
16
- no_collections: There are no collections yet
17
19
  admin:
18
20
  submenu:
19
21
  collections:
@@ -26,24 +28,26 @@ en:
26
28
  new: Create new album
27
29
  collections:
28
30
  collection:
29
- view_live_html: 'View this collection live <br/><em>(opens in a new window)</em>'
31
+ view_live_html: View this collection live <br/><em>(opens in a new window)</em>
30
32
  delete: Remove this collection forever
31
33
  edit: Edit this collection
32
34
  index:
33
- no_items_yet: 'There are no collections yet. Click "%{create}" to add your first collection.'
35
+ no_items_yet: There are no collections yet. Click "%{create}" to add your
36
+ first collection.
34
37
  new:
35
38
  title: Create new collection
36
39
  edit:
37
40
  title: Edit collection
38
41
  albums:
39
42
  album:
40
- view_live_html: 'View this album live <br/><em>(opens in a new window)</em>'
43
+ view_live_html: View this album live <br/><em>(opens in a new window)</em>
41
44
  delete: Remove this album forever
42
45
  edit: Edit this album
43
46
  upload_photos: Upload new photos to album
44
47
  edit_photos: Edit photos in album
45
48
  index:
46
- no_items_yet: 'There are no albums yet. Click "%{create}" to add your first album.'
49
+ no_items_yet: There are no albums yet. Click "%{create}" to add your first
50
+ album.
47
51
  new:
48
52
  title: Create new album
49
53
  edit:
@@ -51,7 +55,8 @@ en:
51
55
  form:
52
56
  album_belongs_to_collection: Album belongs to collection(s)
53
57
  more_options: More options
54
- more_options_tooltip: Enable edit more fields like adress, latitude, longitude, note
58
+ more_options_tooltip: Enable edit more fields like adress, latitude, longitude,
59
+ note
55
60
  choose_collection: Choose collection(s)
56
61
  path_prefix: Path prefix
57
62
  number_of_photos: Contains %{number} photos
@@ -61,19 +66,30 @@ en:
61
66
  manage: Manage
62
67
  new: Upload new photos
63
68
  edit_multiple:
64
- no_photos_yet: There are no photos in album yet. Click "%{create} to add your first photos to album.'
69
+ no_photos_yet: There are no photos in album yet. Click "%{create} to add
70
+ your first photos to album.'
65
71
  photo:
66
72
  delete: Remove this photo forever
67
73
  deleted: Deleted photo "%{title}"
68
74
  form_fields:
69
75
  use_decimal_format: Use decimal format
70
-
71
-
76
+ photo_pages:
77
+ show:
78
+ other: Other Photo Pages
79
+ albums:
80
+ show:
81
+ no_photos: There are no photos in this album yet
82
+ photos:
83
+ image: Image
84
+ collections:
85
+ show:
86
+ no_albums: There are no albums in this collection yet
87
+ index:
88
+ no_collections: There are no collections yet
72
89
  activerecord:
73
- models:
74
- refinery/photo_gallery/collection: Collection
75
- refinery/photo_gallery/collection: Album
76
90
  attributes:
91
+ refinery/photo_gallery/photo_page:
92
+ page_id: Page
77
93
  refinery/photo_gallery/collection:
78
94
  title: Title
79
95
  description: Description
@@ -81,15 +97,17 @@ en:
81
97
  title: Title
82
98
  description: Description
83
99
  longitude: Longitude
84
- latitude: Latitude
100
+ latitude: Latitude
85
101
  path: Path
86
102
  adress: Adress
87
103
  note: Note
88
104
  tags: Tags
89
105
  refinery/photo_gallery/photo:
90
- title: Title
91
- description: Description
92
- longitude: Longitude
93
- latitude: Latitude
94
- path: Path
95
- file: File
106
+ title: Title
107
+ description: Description
108
+ longitude: Longitude
109
+ latitude: Latitude
110
+ path: Path
111
+ file: File
112
+ models:
113
+ refinery/photo_gallery/collection: Album