Compare commits

...

2 commits

Author SHA1 Message Date
j
ea0bde27e7 em->italic 2025-02-22 12:11:24 -05:00
j
250fa43c19 only allow /m/ 2025-02-22 12:04:28 -05:00
2 changed files with 11 additions and 3 deletions

View file

@ -7,6 +7,7 @@ import lxml.html
from django.conf import settings
from django.contrib.auth import get_user_model
from django.core.exceptions import ValidationError
from django.db import models
from django.db.models.functions import ExtractWeek, ExtractYear
from django.urls import reverse
@ -48,6 +49,10 @@ class Item(models.Model):
self.get_hue()
super().save(*args, **kwargs)
def clean(self):
if '/m/' not in self.url:
raise ValidationError("You can only use mobile urls(/m/)")
def __str__(self):
return '%s (%s)' % (self.title, self.url)
@ -101,12 +106,14 @@ class Item(models.Model):
return week, archive
def get_week(self):
return int(self.published.strftime('%W'))
return int(self.published.strftime('%W')) if self.published else None
def get_year(self):
return int(self.published.strftime('%Y'))
return int(self.published.strftime('%Y')) if self.published else None
def get_monday(self):
if not self.published:
return None
d = '%s-W%s' % (self.get_year(), self.get_week())
return datetime.strptime(d + '-1', "%Y-W%W-%w").strftime('%Y-%m-%d')

View file

@ -52,9 +52,10 @@ html, body {
}
i {
i, em {
font-style: italic;
}
header, footer {
max-width: 1000px;
padding-top: 16px;