spud_photos 0.9.0.2 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/photo_albums_controller.rb +22 -9
- data/app/controllers/photo_galleries_controller.rb +1 -1
- data/app/models/spud_photo_sweeper.rb +7 -1
- data/app/views/photo_albums/index.html.erb +8 -2
- data/app/views/photo_albums/show.html.erb +11 -1
- data/app/views/photo_galleries/index.html.erb +1 -1
- data/db/migrate/20120228232329_create_spud_photo_albums.rb +3 -3
- data/db/migrate/20120228232344_create_spud_photo_galleries.rb +3 -3
- data/lib/spud_photos/version.rb +1 -1
- metadata +4 -4
@@ -3,6 +3,10 @@ class PhotoAlbumsController < ApplicationController
|
|
3
3
|
respond_to :html, :json, :xml
|
4
4
|
layout Spud::Photos.base_layout
|
5
5
|
|
6
|
+
if Spud::Photos.galleries_enabled
|
7
|
+
before_filter :get_gallery
|
8
|
+
end
|
9
|
+
|
6
10
|
after_filter :only => [:show, :index] do |c|
|
7
11
|
if Spud::Photos.enable_full_page_caching
|
8
12
|
c.cache_page(nil, nil, false)
|
@@ -10,14 +14,8 @@ class PhotoAlbumsController < ApplicationController
|
|
10
14
|
end
|
11
15
|
|
12
16
|
def index
|
13
|
-
if
|
14
|
-
@
|
15
|
-
if @photo_gallery.blank?
|
16
|
-
flash[:error] = 'Photo gallery could not be found!'
|
17
|
-
redirect_to photo_galleries_path and return false
|
18
|
-
else
|
19
|
-
@photo_albums = @photo_gallery.albums.order('created_at desc')
|
20
|
-
end
|
17
|
+
if @photo_gallery
|
18
|
+
@photo_albums = @photo_gallery.albums.order('created_at desc')
|
21
19
|
else
|
22
20
|
@photo_albums = SpudPhotoAlbum.order('created_at desc')
|
23
21
|
end
|
@@ -27,7 +25,7 @@ class PhotoAlbumsController < ApplicationController
|
|
27
25
|
def show
|
28
26
|
@photo_album = SpudPhotoAlbum.find_by_url_name(params[:id])
|
29
27
|
if @photo_album.blank?
|
30
|
-
flash[:error] = "
|
28
|
+
flash[:error] = "Could not find the requested Photo Album"
|
31
29
|
if params[:photo_gallery_id]
|
32
30
|
redirect_to photo_gallery_photo_albums_path(params[:photo_gallery_id])
|
33
31
|
else
|
@@ -38,4 +36,19 @@ class PhotoAlbumsController < ApplicationController
|
|
38
36
|
end
|
39
37
|
end
|
40
38
|
|
39
|
+
private
|
40
|
+
|
41
|
+
def get_gallery
|
42
|
+
@photo_gallery = SpudPhotoGallery.find_by_url_name(params[:photo_gallery_id])
|
43
|
+
if @photo_gallery.blank?
|
44
|
+
flash[:error] = "Could not find the requested Photo Gallery"
|
45
|
+
if request.xhr?
|
46
|
+
render :nothing => true, :status => 404
|
47
|
+
else
|
48
|
+
redirect_to photo_galleries_path
|
49
|
+
end
|
50
|
+
return false
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
41
54
|
end
|
@@ -10,7 +10,7 @@ class PhotoGalleriesController < ApplicationController
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def index
|
13
|
-
@photo_galleries = SpudPhotoGallery.order('created_at desc')
|
13
|
+
@photo_galleries = SpudPhotoGallery.order('created_at desc').includes(:albums)
|
14
14
|
respond_with @photo_galleries
|
15
15
|
end
|
16
16
|
|
@@ -22,6 +22,12 @@ private
|
|
22
22
|
if File.directory?(cache_path)
|
23
23
|
FileUtils.rm_rf(cache_path)
|
24
24
|
end
|
25
|
+
if Spud::Photos.config.galleries_enabled
|
26
|
+
expire_page photo_galleries_path
|
27
|
+
else
|
28
|
+
expire_page photo_albums_path
|
29
|
+
end
|
30
|
+
|
25
31
|
if !Spud::Photos.config.page_caches_to_sweep.blank?
|
26
32
|
Spud::Photos.config.page_caches_to_sweep.each do |route|
|
27
33
|
expire_page(route)
|
@@ -30,4 +36,4 @@ private
|
|
30
36
|
end
|
31
37
|
end
|
32
38
|
|
33
|
-
end
|
39
|
+
end
|
@@ -6,12 +6,18 @@
|
|
6
6
|
|
7
7
|
<% end %>
|
8
8
|
|
9
|
-
<h2><%= (@photo_gallery ? @photo_gallery.title : 'Photo Albums') %></h2>
|
9
|
+
<h2><%= (@photo_gallery ? "Photo Gallery: #{@photo_gallery.title}" : 'Photo Albums') %></h2>
|
10
|
+
|
11
|
+
<% if Spud::Photos.galleries_enabled %>
|
12
|
+
<p><%= link_to 'Back to Galleries', photo_galleries_path %></p>
|
13
|
+
<% end %>
|
10
14
|
|
11
15
|
<div id="spud_photo_albums">
|
12
16
|
<% @photo_albums.each do |album| %>
|
13
17
|
<div class="spud_photo_album_thumbnail">
|
14
|
-
<h3
|
18
|
+
<h3>
|
19
|
+
<%= link_to album.title, (@photo_gallery ? photo_gallery_photo_album_path(@photo_gallery.url_name, album.url_name) : photo_album_path(album.url_name)) %>
|
20
|
+
</h3>
|
15
21
|
<%= image_tag album.top_photo_url(:medium), :title => album.title %>
|
16
22
|
</div>
|
17
23
|
<% end %>
|
@@ -6,7 +6,17 @@
|
|
6
6
|
|
7
7
|
<% end %>
|
8
8
|
|
9
|
-
<h2>Photo Album:
|
9
|
+
<h2>Photo Album: <%= @photo_album.title %></h2>
|
10
|
+
|
11
|
+
<% if @photo_gallery %>
|
12
|
+
<% if @photo_gallery.albums.count == 1 %>
|
13
|
+
<p><%= link_to 'Back to Galleries', photo_galleries_path %>
|
14
|
+
<% else %>
|
15
|
+
<p><%= link_to 'Back to Gallery', photo_gallery_photo_albums_path(@photo_gallery.url_name) %>
|
16
|
+
<% end %>
|
17
|
+
<% else %>
|
18
|
+
<p><%= link_to 'Back to Albums', photo_albums_path %>
|
19
|
+
<% end %>
|
10
20
|
|
11
21
|
<div id="spud_photo_galleries">
|
12
22
|
<% @photo_album.photos.each do |photo| %>
|
@@ -11,7 +11,7 @@
|
|
11
11
|
<div id="spud_photo_galleries">
|
12
12
|
<% @photo_galleries.each do |gallery| %>
|
13
13
|
<div class="spud_photo_gallery_thumbnail">
|
14
|
-
<h3><%= link_to gallery.title, photo_gallery_photo_albums_path(gallery.url_name) %></h3>
|
14
|
+
<h3><%= link_to gallery.title, (gallery.albums.length == 1 ? photo_gallery_photo_album_path(gallery.url_name, gallery.albums.first.url_name) : photo_gallery_photo_albums_path(gallery.url_name)) %></h3>
|
15
15
|
<%= image_tag gallery.top_photo_url(:medium), :title => gallery.title %>
|
16
16
|
</div>
|
17
17
|
<% end %>
|
@@ -9,7 +9,7 @@ class CreateSpudPhotoAlbums < ActiveRecord::Migration
|
|
9
9
|
t.integer :spud_photo_album_id
|
10
10
|
t.integer :spud_photo_id
|
11
11
|
end
|
12
|
-
add_index :spud_photo_albums, :url_name
|
13
|
-
add_index :spud_photo_albums_photos, :spud_photo_album_id
|
12
|
+
add_index :spud_photo_albums, :url_name, :name => "idx_album_url_name"
|
13
|
+
add_index :spud_photo_albums_photos, :spud_photo_album_id, :name => "idx_album_id"
|
14
14
|
end
|
15
|
-
end
|
15
|
+
end
|
@@ -9,7 +9,7 @@ class CreateSpudPhotoGalleries < ActiveRecord::Migration
|
|
9
9
|
t.integer :spud_photo_gallery_id
|
10
10
|
t.integer :spud_photo_album_id
|
11
11
|
end
|
12
|
-
add_index :spud_photo_galleries, :url_name
|
13
|
-
add_index :spud_photo_galleries_albums, :spud_photo_gallery_id
|
12
|
+
add_index :spud_photo_galleries, :url_name, :name => "idx_gallery_url_name"
|
13
|
+
add_index :spud_photo_galleries_albums, :spud_photo_gallery_id, :name => "idx_gallery_id"
|
14
14
|
end
|
15
|
-
end
|
15
|
+
end
|
data/lib/spud_photos/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spud_photos
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11
|
12
|
+
date: 2012-12-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -276,7 +276,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
276
276
|
version: '0'
|
277
277
|
segments:
|
278
278
|
- 0
|
279
|
-
hash:
|
279
|
+
hash: -1716932056523986828
|
280
280
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
281
281
|
none: false
|
282
282
|
requirements:
|
@@ -285,7 +285,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
285
285
|
version: '0'
|
286
286
|
segments:
|
287
287
|
- 0
|
288
|
-
hash:
|
288
|
+
hash: -1716932056523986828
|
289
289
|
requirements: []
|
290
290
|
rubyforge_project:
|
291
291
|
rubygems_version: 1.8.24
|