diff --git a/frontends/etiquette_flask/etiquette_flask/common.py b/frontends/etiquette_flask/etiquette_flask/common.py index 57fa35f..772056e 100644 --- a/frontends/etiquette_flask/etiquette_flask/common.py +++ b/frontends/etiquette_flask/etiquette_flask/common.py @@ -9,6 +9,7 @@ from voussoirkit import bytestring from voussoirkit import pathclass from . import caching +from . import jinja_filters from . import jsonify from . import sessions @@ -31,6 +32,7 @@ site.config.update( site.jinja_env.add_extension('jinja2.ext.do') site.jinja_env.trim_blocks = True site.jinja_env.lstrip_blocks = True +site.jinja_env.filters['bytestring'] = jinja_filters.bytestring site.debug = True P = etiquette.photodb.PhotoDB() diff --git a/frontends/etiquette_flask/etiquette_flask/jinja_filters.py b/frontends/etiquette_flask/etiquette_flask/jinja_filters.py new file mode 100644 index 0000000..1f93b64 --- /dev/null +++ b/frontends/etiquette_flask/etiquette_flask/jinja_filters.py @@ -0,0 +1,9 @@ +import etiquette + +import voussoirkit.bytestring + +def bytestring(x): + try: + return voussoirkit.bytestring.bytestring(x) + except Exception: + return '??? b' diff --git a/frontends/etiquette_flask/templates/album.html b/frontends/etiquette_flask/templates/album.html index 5f52607..5f9e112 100644 --- a/frontends/etiquette_flask/templates/album.html +++ b/frontends/etiquette_flask/templates/album.html @@ -108,13 +108,13 @@ p Download: {% if has_local_photos %} - These files ({{album.sum_bytes(recurse=False, string=True)}}) + These files ({{album.sum_bytes(recurse=False)|bytestring }}) {% endif %} {% if has_local_photos and has_child_photos %}—{% endif %} {% if has_child_photos %} - Include children ({{album.sum_bytes(recurse=True, string=True)}}) + Include children ({{album.sum_bytes(recurse=True)|bytestring }}) {% endif %} {% endif %}