featured item

This commit is contained in:
j 2021-11-22 13:59:43 +01:00
parent 490c712689
commit 2a24beb579
7 changed files with 89 additions and 10 deletions

View file

@ -95,3 +95,31 @@ nav {
opacity: 1;
}
}
.index {
.home {
z-index: 1000;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
display: flex;
flex-direction: column;
.box {
margin: auto;
background: rgba(0,0,0,0.5);
padding: 16px;
border-radius: 2px;
.font-size-sm {
display: flex;
gap: 16px;
justify-content: center;
}
}
}
}

View file

@ -38,9 +38,11 @@ body {
<h1>
<span class="font-bold">{{ film.data.title | safe }}</span>
</h1>
{% if film.data.date %}
<div class="date">
{{ film.data.date | safe }}
</div>
{% endif %}
<div class="country">
{{ film.data.country|default:''|join:', ' }}
</div>
@ -79,7 +81,8 @@ body {
<figure>
<img src="https://archive.njp.ma/{{ item.id }}/480p.jpg">
<figcaption>
{{ item.title | safe }} ({{item.date | safe }})
{{ item.title | safe }}
{% if item.date %}({{item.date | safe }}){% endif %}
</figcaption>
</figure>
</a>

View file

@ -37,7 +37,8 @@
<img src="https://archive.njp.ma/{{ film.data.items.0.id }}/timeline64p.jpg">
</figcaption>
<figcaption>
{{ film.data.title | safe }} ({{ film.data.date|safe}})
{{ film.data.title | safe }}
{% if film.data.date %}({{ film.data.date|safe}}){% endif %}
</figcaption>
</figure>
</a>

View file

@ -20,15 +20,33 @@
{% block body_class%}animated animated-text body--home{% endblock %}
{% block main %}
<div class="index">
<h1 class="h1-en-home">njp.ma</h1>
<p></p>
<div class="font-size-sm">
<div class="h3"><a href="{% url 'films'%}" class="font-bold">Videos</a></div>
{% if featured %}
<div class="video-block">
<img src="https://archive.njp.ma/{{ featured }}/timelineslitscan64pframe.jpg" class="video-fallback-block">
<video
id="timeline-video"
src="https://archive.njp.ma/{{ featured }}/timelineslitscan64p.mp4"
poster="https://archive.njp.ma/{{ featured }}/timelineslitscan64pframe.jpg"
controlsList="nodownload"
autoplay
loop
muted
playsinline>
</video>
</div>
{% endif %}
<div class="home">
<div class="box">
<h1 class="h1-en-home">njp.ma</h1>
<div class="font-size-sm">
<div class="h3"><a href="{% url 'films'%}" class="font-bold">Videos</a></div>
<div class="h3"><a href="{% url 'texts' %}" class="font-bold">Cuts</a></div>
<div class="h3"><a href="{% url 'about' %}" class="font-bold">About</a></div>
<div class="h3"><a href="{% url 'texts' %}" class="font-bold">Cuts</a></div>
</div>
<div class="font-size-sm">
<div class="h3"><a href="{% url 'about' %}" class="font-bold">About</a></div>
</div>
</div>
</div>
</div>
{% endblock %}

View file

@ -1,3 +1,4 @@
import random
from django.shortcuts import render, redirect, get_object_or_404
from django.conf import settings
@ -17,6 +18,15 @@ def index(request):
context = {}
context['films'] = Film.objects.filter(public=True).count()
context['texts'] = Text.objects.filter(public=True).count()
featured = Film.objects.filter(featured=True)
featured_count = featured.count()
if featured_count:
featured = featured[random.randint(0, featured_count - 1)]
try:
featured = featured.data['items'][0]['id']
except:
featured = None
context['featured'] = featured
return render(request, 'index.html', context)
def page(request, slug=''):

View file

@ -0,0 +1,18 @@
# Generated by Django 3.2.9 on 2021-11-22 12:48
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('video', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='film',
name='featured',
field=models.BooleanField(default=False),
),
]

View file

@ -18,6 +18,7 @@ class Film(models.Model):
slug = models.SlugField()
public = models.BooleanField(default=False)
featured = models.BooleanField(default=False)
position = models.IntegerField(default=0)
pandora_url = models.CharField(max_length=1024)