page titles

This commit is contained in:
dave 2021-08-14 17:24:02 -07:00
parent c04de109a8
commit 3e0ac990fd
16 changed files with 22 additions and 38 deletions

View File

@ -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()

View File

@ -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')

View File

@ -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 %}

View File

@ -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 %}

View File

@ -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 %}

View File

@ -1,3 +1,4 @@
{% set title = "Dates" %}
{% extends "page.html" %}
{% block title %}Photo Dates{% endblock %}
{% block subtitle %}Count per day{% endblock %}

View File

@ -1,3 +1,4 @@
{% set title = status %}
{% extends "page.html" %}
{% block title %}{{ status }}{% endblock %}
{% block subtitle %}{% endblock %}

View File

@ -1,3 +1,4 @@
{% set title = "Feed" %}
{% extends "page.html" %}
{% block title %}Photos by date{% endblock %}
{% block subtitle %}By date, descending{% endblock %}

View File

@ -1,3 +1,4 @@
{% set title = "Map" %}
{% extends "page.html" %}
{% block title %}Photo map{% endblock %}
{% block subtitle %}GPS data{% endblock %}

View File

@ -1,3 +1,4 @@
{% set title = "Server statistics" %}
{% extends "page.html" %}
{% block title %}Server statistics{% endblock %}
{% block subtitle %}{% endblock %}

View File

@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{% if title %}{{ title }} :: {% endif %}Photo App</title>
<title>{% if title %}{{ title }} - {% endif %}Photo App</title>
<link rel="stylesheet" href="/static/style.css" />
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>

View File

@ -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 %}

View File

@ -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 %}

View File

@ -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 }} <a href="/search">reset</a>{% endblock %}
{% block subtitle %}Matched Images: {{ total_sets|number_format }} <a href="/search">reset</a>{% endblock %}
{% block buttons %}{% endblock %}
{% block body %}

View File

@ -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 %}

View File

@ -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 %}
<div class="photo-feed">
{% 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 %}
<div class="feed-divider year"><h4><a href="/date/{{ item.date.strftime("%Y-%m-%d") }}">{{ locals.im_date }}</a></h4></div>
{% endif %}
{% include "fragments/feed-photo.html" %}
{% endfor %}
<br style="clear:both" />
{% include "pager.html" %}
</div>
{% endblock %}