forked from 00dani/lemoncurry
Switch to another relative-date-formatting library which supports tiny abbreviated formats
This commit is contained in:
parent
0d1d102f47
commit
c8faa30724
5 changed files with 52 additions and 71 deletions
|
@ -1,4 +1,3 @@
|
|||
from django.contrib.humanize.templatetags.humanize import naturaltime
|
||||
from django.contrib.staticfiles.storage import staticfiles_storage
|
||||
from django.conf import settings
|
||||
from django.urls import reverse
|
||||
|
@ -8,6 +7,7 @@ from compressor.contrib.jinja2ext import CompressorExtension
|
|||
from django_activeurl.ext.django_jinja import ActiveUrl
|
||||
|
||||
from entries.kinds import all as entry_kinds
|
||||
from .ago import ago
|
||||
from .markdown import markdown
|
||||
from ..theme import color as theme_color
|
||||
from ..utils import friendly_url, load_package_json
|
||||
|
@ -21,9 +21,9 @@ def environment(**options):
|
|||
**options
|
||||
)
|
||||
env.filters.update({
|
||||
'ago': ago,
|
||||
'friendly_url': friendly_url,
|
||||
'markdown': markdown,
|
||||
'naturaltime': naturaltime,
|
||||
})
|
||||
env.globals.update({
|
||||
'entry_kinds': entry_kinds,
|
||||
|
|
6
lemoncurry/jinja2/ago.py
Normal file
6
lemoncurry/jinja2/ago.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
from ago import human
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
def ago(dt: datetime) -> str:
|
||||
return human(dt, past_tense='{}', abbreviate=True)
|
Loading…
Add table
Add a link
Reference in a new issue