diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb
index 81305c0..3ad216d 100644
--- a/app/controllers/photos_controller.rb
+++ b/app/controllers/photos_controller.rb
@@ -19,5 +19,6 @@ class PhotosController < ApplicationController
def log_view
@photo = Photo.find(params[:id])
@photo.log_view
+ render :nothing => true
end
end
diff --git a/app/helpers/photos_helper.rb b/app/helpers/photos_helper.rb
index 0a10d47..e4b0b89 100644
--- a/app/helpers/photos_helper.rb
+++ b/app/helpers/photos_helper.rb
@@ -1,2 +1,5 @@
module PhotosHelper
+ def link_to_photo(photo)
+ link_to '', photo.photo.url, :rel => 'photos', :class => 'fancy', :id => photo.id
+ end
end
diff --git a/app/views/categories/index.html.erb b/app/views/categories/index.html.erb
index 057d69d..487c54b 100644
--- a/app/views/categories/index.html.erb
+++ b/app/views/categories/index.html.erb
@@ -17,7 +17,7 @@
<% @photos.each do |photo| %>
- <%= link_to '', photo.photo.url, :class => 'fancy' %>
+ <%= link_to_photo photo %>
<% end %>
diff --git a/app/views/pages/index.html.erb b/app/views/pages/index.html.erb
index 7ce51b2..292e743 100644
--- a/app/views/pages/index.html.erb
+++ b/app/views/pages/index.html.erb
@@ -8,7 +8,7 @@
<% if @photo %>
- <%= link_to '', @photo.photo.url, :class => 'fancy' %>
+ <%= link_to_photo @photo %>
<% end %>
diff --git a/app/views/photos/index.html.erb b/app/views/photos/index.html.erb
index 7aaca02..9647f47 100644
--- a/app/views/photos/index.html.erb
+++ b/app/views/photos/index.html.erb
@@ -27,7 +27,7 @@
<% @photos.each do |photo| %>
- <%= link_to '', photo.photo.url, :class => 'fancy' %>
+ <%= link_to_photo photo %>
<% end %>
diff --git a/config/routes.rb b/config/routes.rb
index 8278e9d..72decb7 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -56,9 +56,16 @@ Photos::Application.routes.draw do
resources :categories do
resources :photos
+ member do
+ get :log_view
+ end
end
- resources :photos
+ resources :photos do
+ member do
+ get :log_view
+ end
+ end
root :to => 'pages#index'
diff --git a/public/javascripts/photos.js b/public/javascripts/photos.js
index 4187a1f..b437e49 100644
--- a/public/javascripts/photos.js
+++ b/public/javascripts/photos.js
@@ -1,6 +1,9 @@
$(document).ready(function() {
$('.fancy').fancybox({
- 'titlePosition' : 'inside'
+ 'titlePosition' : 'inside',
+ 'onComplete' : function(links, index) {
+ $.get('/photos/'+$(links[index]).attr('id')+'/log_view')
+ }
});
if ($('#contact_form').length) {