From 3e0ac990fdfa14937edfb29378e08ce070eef332 Mon Sep 17 00:00:00 2001 From: dave Date: Sat, 14 Aug 2021 17:24:02 -0700 Subject: [PATCH] page titles --- photoapp/daemon.py | 14 +++----------- photoapp/utils.py | 4 ++++ templates/album.html | 1 + templates/create_tags.html | 1 + templates/date.html | 1 + templates/dates.html | 1 + templates/error.html | 1 + templates/feed.html | 1 + templates/map.html | 1 + templates/monthly.html | 1 + templates/page.html | 2 +- templates/photo.html | 1 + templates/photo_edit.html | 1 + templates/search.html | 3 ++- templates/tag_edit.html | 3 ++- templates/untagged.html | 24 ------------------------ 16 files changed, 22 insertions(+), 38 deletions(-) delete mode 100644 templates/untagged.html diff --git a/photoapp/daemon.py b/photoapp/daemon.py index 90d5c07..147afda 100644 --- a/photoapp/daemon.py +++ b/photoapp/daemon.py @@ -11,7 +11,7 @@ from photoapp.dbsession import DatabaseSession from photoapp.common import pwhash from photoapp.api import PhotosApi, LibraryManager from photoapp.dbutils import SAEnginePlugin, SATool, db, get_db_engine, date_format -from photoapp.utils import auth, require_auth, photoset_auth_filter, slugify, cherryparam +from photoapp.utils import auth, require_auth, photoset_auth_filter, slugify, cherryparam, number_format from photoapp.storage import uri_to_storage from jinja2 import Environment, FileSystemLoader, select_autoescape from sqlalchemy import desc, func, and_, or_ @@ -38,7 +38,8 @@ class PhotosWeb(object): self.tpl.filters.update(mime2ext=mime2ext, basename=os.path.basename, ceil=math.ceil, - statusstr=lambda x: str(x).split(".")[-1]) + statusstr=lambda x: str(x).split(".")[-1], + number_format=number_format) self.thumb = ThumbnailView(self) self.photo = PhotoView(self) @@ -355,15 +356,6 @@ class TagView(object): def index(self, uuid, page=0): page = int(page) pgsize = 100 - # if uuid == "untagged": - # numphotos = photoset_auth_filter(db.query(func.count(PhotoSet.id))). \ - # filter(~PhotoSet.id.in_(db.query(TagItem.set_id))).scalar() - # photos = photoset_auth_filter(db.query(PhotoSet)).filter(~PhotoSet.id.in_(db.query(TagItem.set_id))). \ - # order_by(PhotoSet.date.desc()). \ - # offset(page * pgsize). \ - # limit(pgsize).all() - # yield self.master.render("untagged.html", images=photos, total_items=numphotos, pgsize=pgsize, page=page) - # else: tag = db.query(Tag).filter(or_(Tag.uuid == uuid, Tag.slug == uuid)).first() numphotos = photoset_auth_filter(db.query(func.count(Tag.id)).join(TagItem).join(PhotoSet)). \ filter(Tag.id == tag.id).scalar() diff --git a/photoapp/utils.py b/photoapp/utils.py index 39ce12d..f99fe35 100644 --- a/photoapp/utils.py +++ b/photoapp/utils.py @@ -74,3 +74,7 @@ def cherryparam(v, type_=str): if type(v) == type_: v = [v] # one entry return v + + +def number_format(value): + return format(int(value), ',d') diff --git a/templates/album.html b/templates/album.html index 3954cd4..a2d72e2 100644 --- a/templates/album.html +++ b/templates/album.html @@ -1,3 +1,4 @@ +{% set title = tag.title or tag.name %} {% extends "page.html" %} {% block title %}{{ tag.title or tag.name }}{% endblock %} {% block subtitle %}{{ tag.description }}{% endblock %} diff --git a/templates/create_tags.html b/templates/create_tags.html index da44136..e667fcb 100644 --- a/templates/create_tags.html +++ b/templates/create_tags.html @@ -1,3 +1,4 @@ +{% set title = "Edit tags - {} photo{}".format(num_photos, "s" if num_photos > 1 else "") %} {% extends "page.html" %} {% block title %}Tagging {{ num_photos }} photo{% if num_photos > 1 %}s{% endif %}{% endblock %} {% block subtitle %}{% endblock %} diff --git a/templates/date.html b/templates/date.html index b9d977b..87c8582 100644 --- a/templates/date.html +++ b/templates/date.html @@ -1,3 +1,4 @@ +{% set title = date.strftime("%b %d, %Y") %} {% extends "page.html" %} {% block title %}{{ "Photos on {}".format(date.strftime("%b %d, %Y")) }}{% endblock %} {% block subtitle %}{% endblock %} diff --git a/templates/dates.html b/templates/dates.html index 95a1467..0bc95f7 100644 --- a/templates/dates.html +++ b/templates/dates.html @@ -1,3 +1,4 @@ +{% set title = "Dates" %} {% extends "page.html" %} {% block title %}Photo Dates{% endblock %} {% block subtitle %}Count per day{% endblock %} diff --git a/templates/error.html b/templates/error.html index 88544d4..2296baa 100644 --- a/templates/error.html +++ b/templates/error.html @@ -1,3 +1,4 @@ +{% set title = status %} {% extends "page.html" %} {% block title %}{{ status }}{% endblock %} {% block subtitle %}{% endblock %} diff --git a/templates/feed.html b/templates/feed.html index a5f1ced..4d72061 100644 --- a/templates/feed.html +++ b/templates/feed.html @@ -1,3 +1,4 @@ +{% set title = "Feed" %} {% extends "page.html" %} {% block title %}Photos by date{% endblock %} {% block subtitle %}By date, descending{% endblock %} diff --git a/templates/map.html b/templates/map.html index 61f0e0d..4c5d756 100644 --- a/templates/map.html +++ b/templates/map.html @@ -1,3 +1,4 @@ +{% set title = "Map" %} {% extends "page.html" %} {% block title %}Photo map{% endblock %} {% block subtitle %}GPS data{% endblock %} diff --git a/templates/monthly.html b/templates/monthly.html index 3813c2b..a05ffd4 100644 --- a/templates/monthly.html +++ b/templates/monthly.html @@ -1,3 +1,4 @@ +{% set title = "Server statistics" %} {% extends "page.html" %} {% block title %}Server statistics{% endblock %} {% block subtitle %}{% endblock %} diff --git a/templates/page.html b/templates/page.html index e4bbc8a..4212858 100644 --- a/templates/page.html +++ b/templates/page.html @@ -2,7 +2,7 @@ - {% if title %}{{ title }} :: {% endif %}Photo App + {% if title %}{{ title }} - {% endif %}Photo App diff --git a/templates/photo.html b/templates/photo.html index 6e6febe..c34ca14 100644 --- a/templates/photo.html +++ b/templates/photo.html @@ -1,3 +1,4 @@ +{% set title = image.title or image.uuid %} {% extends "page.html" %} {% block title %}{{ image.title or image.uuid }}{% endblock %} {% block subtitle %}{{ image.date }}{% endblock %} diff --git a/templates/photo_edit.html b/templates/photo_edit.html index 354c1d8..245fe9d 100644 --- a/templates/photo_edit.html +++ b/templates/photo_edit.html @@ -1,3 +1,4 @@ +{% set title = "Editing " + (image.title or image.uuid) %} {% extends "page.html" %} {% block title %}Editing {{ image.title or image.uuid }}{% endblock %} {% block subtitle %}{{ image.date }}{% endblock %} diff --git a/templates/search.html b/templates/search.html index f48a5e6..329a031 100644 --- a/templates/search.html +++ b/templates/search.html @@ -1,6 +1,7 @@ +{% set title = "Search - {} results".format(total_sets|number_format) %} {% extends "page.html" %} {% block title %}Search & Bulk Operations{% endblock %} -{% block subtitle %}Matched Images: {{ total_sets }} reset{% endblock %} +{% block subtitle %}Matched Images: {{ total_sets|number_format }} reset{% endblock %} {% block buttons %}{% endblock %} {% block body %} diff --git a/templates/tag_edit.html b/templates/tag_edit.html index ec41e38..502c37d 100644 --- a/templates/tag_edit.html +++ b/templates/tag_edit.html @@ -1,5 +1,6 @@ +{% set title = "Editing tag " + (tag.title or tag.name) %} {% extends "page.html" %} -{% block title %}Editing {{ tag.uuid }}{% endblock %} +{% block title %}Editing {{ tag.title or tag.name }}{% endblock %} {% block subtitle %}{% endblock %} {% block buttons %} diff --git a/templates/untagged.html b/templates/untagged.html deleted file mode 100644 index 8e2ab88..0000000 --- a/templates/untagged.html +++ /dev/null @@ -1,24 +0,0 @@ -{% extends "page.html" %} -{% block title %}Untagged photos{% endblock %} -{% block subtitle %}By date, descending{% endblock %} - -{% block body %} - -{% set locals = namespace() %} -{% set total_pages = (total_items/pgsize)|ceil %} - -
- {% set locals.im_date = "" %} - {% for item in images %} - {% set newdate = item.date.strftime("%b %d, %Y") %} - {% if newdate != locals.im_date %} - {% set locals.im_date = newdate %} - - {% endif %} - {% include "fragments/feed-photo.html" %} - {% endfor %} -
- {% include "pager.html" %} -
- -{% endblock %}