diff --git a/gallery/templates/gallery/photo_detail.html b/gallery/templates/gallery/photo_detail.html
index 95ca9f8..5609ed4 100644
--- a/gallery/templates/gallery/photo_detail.html
+++ b/gallery/templates/gallery/photo_detail.html
@@ -88,7 +88,10 @@
@@ -157,7 +160,7 @@
if (data.status === "liked") {
likeText.innerText = "Unlike";
- heartIcon.setAttribute("style", "color: red");
+ heartIcon.setAttribute("style", "color: inherit");
} else {
likeText.innerText = "Like";
heartIcon.setAttribute("style", "color: inherit");
@@ -171,7 +174,7 @@
{% endif %}
diff --git a/gallery/templates/gallery/photo_slideshow.html b/gallery/templates/gallery/photo_slideshow.html
new file mode 100644
index 0000000..6d887e2
--- /dev/null
+++ b/gallery/templates/gallery/photo_slideshow.html
@@ -0,0 +1,52 @@
+
+
+
+ {% load static %}
+
+
+
+ {{ site_config.site_head_title }} : Slideshow : {{ photo.album.name }}
+ {% if next_photo %}
+
+ {% endif %}
+
+
+
+
+
+
\ No newline at end of file
diff --git a/gallery/urls.py b/gallery/urls.py
index 6731ecc..9fa63e2 100644
--- a/gallery/urls.py
+++ b/gallery/urls.py
@@ -1,20 +1,17 @@
-from django.urls import path, register_converter
+from django.urls import path, re_path, register_converter
from . import converters, views
-register_converter(converters.FilenamePathConverter, 'filename')
-
-
app_name = 'gallery'
urlpatterns = [
-
path('', views.AlbumsList.as_view(), name='main_url'),
path('about/', views.About.as_view(), name='about_url'),
path('search/', views.Search.as_view(), name='search_url'),
path('photostream/', views.PhotosList.as_view(), name='photos_url'),
- path('like//', views.PhotoLike.as_view(), name='photo_like_url'),
- path('albums//', views.PhotoDetail.as_view(), name='photo_url'),
+ re_path(r'^like/(?P.+)/(?P[a-zA-Z0-9_-]{1,50}\.[a-zA-Z]{3,4})/?$', views.PhotoLike.as_view(), name='photo_like_url'),
+ re_path(r'^slideshow/(?P.+)/(?P[a-zA-Z0-9_-]{1,50}\.[a-zA-Z]{3,4})/?$', views.PhotoSlideshow.as_view(), name='photo_slideshow_url'),
+ re_path(r'^albums/(?P.+)/(?P[a-zA-Z0-9_-]{1,50}\.[a-zA-Z]{3,4})/?$', views.PhotoDetail.as_view(), name='photo_url'),
path('albums//', views.AlbumDetail.as_view(), name='album_url'),
path('albums/', views.AlbumsList.as_view(), name='albums_url'),
path('/', views.redirect_to_album, name='redirect_to_album'),
diff --git a/gallery/views.py b/gallery/views.py
index a815e8b..2bb8dc0 100644
--- a/gallery/views.py
+++ b/gallery/views.py
@@ -158,6 +158,41 @@ class PhotoLike(View):
return JsonResponse({'success': True, 'likes': photo.likes, 'status': status})
+class PhotoSlideshow(DetailView):
+ model = Photo
+ slug_url_kwarg = 'photo_slug'
+ template_name = 'gallery/photo_slideshow.html'
+
+ def get_object(self, queryset=None):
+ album_slug = self.kwargs.get('album_slug')
+ photo_slug = self.kwargs.get('photo_slug')
+ photo = get_object_or_404(
+ Photo.objects.select_related('album'),
+ slug=photo_slug,
+ album__slug=album_slug
+ )
+
+ if photo.slug not in self.request.session:
+ photo.add_view()
+ self.request.session[photo.slug] = 0
+
+ return photo
+
+ def get_context_data(self, **kwargs):
+ context = super().get_context_data(**kwargs)
+ current_photo = self.object
+
+ next_photo = current_photo.get_next()
+
+ if not next_photo:
+ next_photo = Photo.objects.filter(album=current_photo.album).order_by('taken_at').first()
+
+ context.update({
+ "next_photo": next_photo,
+ "liked": self.request.session.get(f"liked_{current_photo.slug}", False)
+ })
+ return context
+
class Search(TemplateView):
"""Search view for public albums by name, place or city."""
template_name = "gallery/search.html"