diff --git a/entries/jinja2/entries/entry.html b/entries/jinja2/entries/entry.html new file mode 100644 index 0000000..00d76c0 --- /dev/null +++ b/entries/jinja2/entries/entry.html @@ -0,0 +1,16 @@ +{% extends 'lemoncurry/layout.html' %} +{% block head %} + + +{% endblock %} + +{% block styles %} + +{% endblock %} + +{% import 'entries/h-entry.html' as h %} +{% block main %} +
+ {{ h.hEntry(entry, indent_width=8) }} +
+{% endblock %} diff --git a/entries/jinja2/entries/h-entry.html b/entries/jinja2/entries/h-entry.html new file mode 100644 index 0000000..0cf7a80 --- /dev/null +++ b/entries/jinja2/entries/h-entry.html @@ -0,0 +1,64 @@ +{% macro hEntry(entry, indent_width) -%} +{%- set i = ' ' * indent_width -%} +
+ {% if entry.photo %} + {{i}} + + {% endif %} + {{i}}
+ {% if entry.name %} + {{i}}

{{ entry.name }}

+ {% endif %} + {{i}}
+ {{i}}{{ entry.content | indent(indent_width + 6) }} + {{i}}
+ {{i}}
+ + {{i}} + + {% if entry.cats.exists() %} + {{i}} + + {% endif %} + {% if entry.syndications.exists() %} + {{i}} + + {% endif %} + {{i}} +{{i}}
+{%- endmacro %} diff --git a/lemoncurry/jinja2.py b/lemoncurry/jinja2.py index c459fe5..57fcfdf 100644 --- a/lemoncurry/jinja2.py +++ b/lemoncurry/jinja2.py @@ -1,3 +1,4 @@ +from django.contrib.humanize.templatetags.humanize import naturaltime from django.contrib.staticfiles.storage import staticfiles_storage from django.urls import reverse from jinja2 import Environment @@ -6,7 +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 .utils import load_package_json +from .utils import friendly_url, load_package_json def environment(**options): @@ -16,6 +17,10 @@ def environment(**options): lstrip_blocks=True, **options ) + env.filters.update({ + 'friendly_url': friendly_url, + 'naturaltime': naturaltime, + }) env.globals.update({ 'entry_kinds': entry_kinds, 'package': load_package_json(), diff --git a/lemoncurry/jinja2/lemoncurry/layout.html b/lemoncurry/jinja2/lemoncurry/layout.html index 6987368..8519fce 100644 --- a/lemoncurry/jinja2/lemoncurry/layout.html +++ b/lemoncurry/jinja2/lemoncurry/layout.html @@ -5,6 +5,7 @@ {% if title %}{{ title }} ~ {% endif %}{{ request.site.name }} + {% block head %}{% endblock %} diff --git a/lemoncurry/utils.py b/lemoncurry/utils.py index 4f00dd7..6b5b3ad 100644 --- a/lemoncurry/utils.py +++ b/lemoncurry/utils.py @@ -7,13 +7,18 @@ from django.http import HttpResponseForbidden, HttpResponseBadRequest from django.utils.html import strip_tags from os.path import join from types import SimpleNamespace -from urllib.parse import urlencode, urljoin +from urllib.parse import urlencode, urljoin, urlparse from .templatetags.markdown import markdown cache = SimpleNamespace(package_json=None) +def friendly_url(url): + (scheme, netloc, path, params, q, fragment) = urlparse(url) + return netloc + path + + def load_package_json(): if cache.package_json: return cache.package_json