Remove main page, add parallax
This commit is contained in:
parent
669f9b999b
commit
3f5efe8f81
7 changed files with 53 additions and 43 deletions
|
@ -4,6 +4,10 @@
|
|||
<!-- Title -->
|
||||
{% block title %} Gallery : Albums {% endblock %}
|
||||
|
||||
<!-- Parallax -->
|
||||
{% block parallax %}
|
||||
{% include "./partials/parallax.html" %}
|
||||
{% endblock %}
|
||||
|
||||
<!-- Content -->
|
||||
{% block content %}
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
{% extends "base_dark.html" %}
|
||||
{% load top_tags %}
|
||||
|
||||
<!-- Title -->
|
||||
{% block title %} Gallery {% endblock %}
|
||||
|
||||
<!-- Content -->
|
||||
{% block content %}
|
||||
Hello World!
|
||||
|
||||
<ul>
|
||||
{% last_albums as albums %}
|
||||
{% for album in albums %}
|
||||
<li>{{ album.name }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<ul>
|
||||
{% top_photos as photos %}
|
||||
{% for photo in photos %}
|
||||
<li>{{ photo.views }} {{ photo.likes }} {{ photo.is_favorite }} {{ photo }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<p>Istunto vanhenee: {{ session_expiry|date:"d.m.Y H:i" }}</p>
|
||||
|
||||
{% endblock %}
|
21
gallery/templates/gallery/partials/parallax.html
Normal file
21
gallery/templates/gallery/partials/parallax.html
Normal file
|
@ -0,0 +1,21 @@
|
|||
{% load top_tags %}
|
||||
{% load static %}
|
||||
|
||||
<div class="uk-position-relative uk-visible-toggle uk-light" tabindex="-1" uk-slideshow="ratio: 7:3; autoplay: true; animation: fade">
|
||||
<ul class="uk-slideshow-items">
|
||||
{% random_photos_landscape as top_photos %}
|
||||
{% if top_photos %}
|
||||
{% for photo in top_photos %}
|
||||
<li>
|
||||
<img src="{{ photo.photo_bg.url }}" alt="{{ photo.album.name }} - {{ photo.slug }}" loading="lazy" uk-cover />
|
||||
</li>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<li>
|
||||
<img src="{% static 'img/placeholder.png' %}" alt="" uk-cover />
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
<a class="uk-position-center-left uk-position-small uk-hidden-hover" href="#" uk-slidenav-previous uk-slideshow-item="previous"></a>
|
||||
<a class="uk-position-center-right uk-position-small uk-hidden-hover" href="#" uk-slidenav-next uk-slideshow-item="next"></a>
|
||||
</div>
|
|
@ -1,16 +1,22 @@
|
|||
{% extends "base_dark.html" %}
|
||||
|
||||
{% load static %}
|
||||
|
||||
<!-- Title -->
|
||||
{% block title %} Gallery : Photostream {% endblock %}
|
||||
|
||||
<!-- Parallax -->
|
||||
{% block parallax %}
|
||||
{% include "./partials/parallax.html" %}
|
||||
{% endblock %}
|
||||
|
||||
<!-- Content -->
|
||||
{% block content %}
|
||||
|
||||
{% load link_tags %}
|
||||
<ul class="uk-tab uk-flex-left uk-margin-remove-top">
|
||||
|
||||
<ul class="uk-subnav uk-subnav-divider uk-margin-remove-top" uk-margin>
|
||||
<li {% if order == 'latest' %}class="uk-active" {% endif %}><a href="{% search_link 'latest' request.GET %}">Latest</a></li>
|
||||
<li {% if order == 'liked' %}class="uk-active" {% endif %}><a href="{% search_link 'liked' request.GET %}">Top Liked</a></li>
|
||||
<li {% if order == 'liked' %}class="uk-active" {% endif %}><a href="{% search_link 'liked' request.GET %}">Liked</a></li>
|
||||
<li {% if order == 'popular' %}class="uk-active" {% endif %}><a href="{% search_link 'popular' request.GET %}">Popular</a></li>
|
||||
</ul>
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from django import template
|
||||
from django.db.models import F
|
||||
|
||||
from gallery.models import Album, Photo
|
||||
|
||||
|
@ -10,12 +11,25 @@ def last_albums(count=5):
|
|||
albums = Album.objects.filter(is_public=True).order_by("-album_date")[:count]
|
||||
return albums
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
def top_photos(count=5):
|
||||
photos = Photo.objects.filter(album__is_public=True).order_by('-is_favorite', '-likes', '-views').select_related('album')[:count]
|
||||
return photos
|
||||
|
||||
@register.simple_tag
|
||||
def random_photos_landscape(count=5):
|
||||
photos = Photo.objects.filter(album__is_public=True, width__gt=F('height')).order_by('?')[:count]
|
||||
return photos
|
||||
|
||||
@register.simple_tag
|
||||
def top_photos_landscape(count=5):
|
||||
photos = Photo.objects.filter(album__is_public=True, width__gt=F('height')).order_by('-views').select_related('album')[:count]
|
||||
return photos
|
||||
|
||||
@register.simple_tag
|
||||
def top_photos_portrait(count=5):
|
||||
photos = Photo.objects.filter(album__is_public=True, height__gt=F('width')).order_by('-views').select_related('album')[:count]
|
||||
return photos
|
||||
|
||||
@register.simple_tag
|
||||
def top_photos_in_album(album, count=5):
|
||||
|
|
|
@ -6,7 +6,7 @@ app_name = 'gallery'
|
|||
|
||||
urlpatterns = [
|
||||
|
||||
path('', views.Main.as_view(), name='main_url'),
|
||||
path('', views.AlbumsList.as_view(), name='main_url'),
|
||||
path('photostream/', views.PhotosList.as_view(), name='photos_url'),
|
||||
path('albums/<path:album_slug>/<int:photo_slug>/', views.PhotoDetail.as_view(), name='photo_url'),
|
||||
path('albums/<path:album_slug>/', views.AlbumDetail.as_view(), name='album_url'),
|
||||
|
|
|
@ -1,20 +1,12 @@
|
|||
from collections import defaultdict
|
||||
|
||||
from django.core.paginator import Paginator
|
||||
from django.shortcuts import get_object_or_404, redirect, render
|
||||
from django.shortcuts import get_object_or_404, redirect
|
||||
from django.views.generic import DetailView, ListView, TemplateView
|
||||
|
||||
from .models import Album, Photo, Redir
|
||||
|
||||
|
||||
class Main(TemplateView):
|
||||
template_name = "gallery/main.html"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
session_expiry = self.request.session.get_expiry_date()
|
||||
context['session_expiry'] = session_expiry
|
||||
return context
|
||||
|
||||
|
||||
class AlbumsList(ListView):
|
||||
model = Album
|
||||
template_name = 'gallery/album_list.html'
|
||||
|
|
Loading…
Add table
Reference in a new issue