Compare commits
3 commits
688e0d22d4
...
85c4917fa7
Author | SHA1 | Date | |
---|---|---|---|
85c4917fa7 | |||
9526133f9b | |||
82edae60fb |
9 changed files with 78 additions and 5 deletions
17
app/item/migrations/0009_week_byline.py
Normal file
17
app/item/migrations/0009_week_byline.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
# Generated by Django 4.2.3 on 2024-02-06 16:24
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("item", "0008_alter_week_title"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="week",
|
||||
name="byline",
|
||||
field=models.CharField(blank=True, default="", max_length=2048),
|
||||
),
|
||||
]
|
|
@ -190,6 +190,7 @@ class Week(models.Model):
|
|||
modified = models.DateTimeField(auto_now=True)
|
||||
monday = models.DateField(unique=True)
|
||||
title = models.CharField(max_length=2048, blank=True, default="")
|
||||
byline = models.CharField(max_length=2048, blank=True, default="")
|
||||
published = models.DateTimeField(null=True, default=None, blank=True, editable=False)
|
||||
|
||||
def __str__(self):
|
||||
|
|
|
@ -42,6 +42,10 @@ def format_week(week):
|
|||
extra = ''
|
||||
return '%s - %s%s' % (a, b, extra)
|
||||
|
||||
def get_byline(week):
|
||||
extra = models.Week.objects.filter(monday=week).first()
|
||||
if extra:
|
||||
return extra.byline
|
||||
|
||||
def get_weeks(archive):
|
||||
weeks = sorted(set(archive.values_list('year', 'week')))
|
||||
|
@ -103,6 +107,7 @@ def archive(request, year=None, month=None, day=None, week=None):
|
|||
extra = models.Week.objects.filter(monday=context['this_week']).first()
|
||||
if extra:
|
||||
context['week_title'] = extra.title
|
||||
context['week_byline'] = extra.byline
|
||||
elif week:
|
||||
week = int(week)
|
||||
year = int(year)
|
||||
|
|
|
@ -7,7 +7,7 @@ from django.utils.timezone import datetime, timedelta
|
|||
|
||||
|
||||
from ..item import models
|
||||
from ..item.views import get_weeks, format_week, get_monday
|
||||
from ..item.views import get_weeks, format_week, get_monday, get_byline
|
||||
|
||||
|
||||
def week(year, month, day):
|
||||
|
@ -28,6 +28,7 @@ def week(year, month, day):
|
|||
monday = context['this_week'] = date.strftime('%Y-%m-%d')
|
||||
context['this_year'] = date.strftime('%Y')
|
||||
context['week_title'] = 'Phantas.ma weekly update %s' % format_week(monday)
|
||||
context['week_byline'] = get_byline(monday)
|
||||
context['week_link'] = settings.URL + '/_' + monday
|
||||
context['items'] = archive_week
|
||||
return render_to_string("weekly_email.html", context)
|
||||
|
|
|
@ -139,6 +139,30 @@ header {
|
|||
padding-bottom: 8px;
|
||||
margin-bottom: 8px;
|
||||
border-bottom: 1px solid blueviolet;
|
||||
|
||||
&.with-byline {
|
||||
display: flex;
|
||||
margin-left: 4px;
|
||||
margin-right: 4px;
|
||||
div {
|
||||
flex-grow: 1;
|
||||
text-align: left;
|
||||
}
|
||||
.byline {
|
||||
text-align: right;
|
||||
}
|
||||
@media(max-width:768px) {
|
||||
display: block;
|
||||
div {
|
||||
margin-left: 4px;
|
||||
margin-right: 4px;
|
||||
}
|
||||
.byline {
|
||||
text-align: left;
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.item > a {
|
||||
display: flex;
|
||||
|
|
|
@ -90,6 +90,18 @@ async function sortClips(edit, sort) {
|
|||
}
|
||||
}
|
||||
|
||||
function getClip(edit, position) {
|
||||
const response = {}
|
||||
let pos = 0
|
||||
edit.clips.forEach(function(clip) {
|
||||
if (clip.position < position && clip.position + clip.duration > position) {
|
||||
response.item = clip.id
|
||||
response.position = position - clip.position
|
||||
}
|
||||
});
|
||||
return response
|
||||
}
|
||||
|
||||
async function loadEdit(id, args) {
|
||||
var data = window.data = {}
|
||||
data.id = id
|
||||
|
@ -235,8 +247,11 @@ async function loadEdit(id, args) {
|
|||
data.title = data.edit.name
|
||||
data.byline = data.edit.description
|
||||
data.link = `${pandora.proto}://${data.site}/edits/${data.edit.id}`
|
||||
const poster = data.edit.posterFrames[0]
|
||||
if (poster) {
|
||||
let poster = data.edit.posterFrames[0]
|
||||
if (args.parts[2] && args.parts[2].indexOf(':') > -1) {
|
||||
poster = getClip(data.edit, parseDuration(args.parts[2]))
|
||||
}
|
||||
if (poster && poster.item) {
|
||||
data.poster = `${pandora.proto}://${data.site}/${poster.item}/480p${poster.position}.jpg`
|
||||
} else {
|
||||
data.poster = data.videos[0].src.split('/48')[0] + `/480p${data.videos[0].in}.jpg`
|
||||
|
|
|
@ -5,7 +5,14 @@
|
|||
{% block content %}
|
||||
<div class="index archive">
|
||||
{% if week_title %}
|
||||
<h2 class="week">{{ week_title }}</h2>
|
||||
<h2 class="week{% if week_byline %} with-byline{% endif %}">
|
||||
{% if week_byline %}
|
||||
<div>{{ week_title }}</div>
|
||||
<div class="byline">{{ week_byline }}</div>
|
||||
{% else %}
|
||||
{{ week_title }}
|
||||
{% endif %}
|
||||
</h2>
|
||||
{% endif %}
|
||||
{% for item in items %}
|
||||
{% include "listitem.html" with item=item %}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimal-ui">
|
||||
{% compress css file site %}
|
||||
<link rel="stylesheet" href="/static/css/reset.css"></link>
|
||||
<link rel="stylesheet" href="{% sass_src 'css/site.scss' %}"></link>
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
{% if week_title %}
|
||||
<a style="color: #F0F0F0;text-decoration: underline;font-size: 18px;font-weight: bold" href="{{ week_link }}">{{ week_title }}</a>
|
||||
{% if week_byline %}<br>
|
||||
{{ week_byline }}
|
||||
{% endif %}
|
||||
<br>
|
||||
<br>
|
||||
{% endif %}
|
||||
|
|
Loading…
Reference in a new issue