From 0394e4b0d4c59498a94ea918a8d468253b98403f Mon Sep 17 00:00:00 2001 From: Mattia Succurro Date: Sun, 14 Mar 2021 22:50:49 +0100 Subject: [PATCH] Add JS page info --- app.py | 15 +++++++++++++++ static/style.css | 11 ++++++----- templates/base.html | 1 + templates/home.html | 1 + templates/view.html | 2 ++ 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/app.py b/app.py index 7d85075..15a14a8 100644 --- a/app.py +++ b/app.py @@ -76,6 +76,21 @@ class Page(BaseModel): (PageTag.name << (old_tags - new_tags))).execute() for tag in (new_tags - old_tags): PageTag.create(page=self, name=tag) + def js_info(self): + latest = self.latest + return dict( + id=self.id, + url=self.url, + title=self.title, + is_redirect=self.is_redirect, + touched=self.touched.timestamp(), + latest=dict( + id=latest.id if latest else None, + length=latest.length, + pub_date=latest.pub_date.timestamp() if latest and latest.pub_date else None + ), + tags=[x.name for x in self.tags] + ) @property def prop(self): return PagePropertyDict(self) diff --git a/static/style.css b/static/style.css index 1f7d2af..9305fbd 100644 --- a/static/style.css +++ b/static/style.css @@ -23,11 +23,12 @@ body{font-family:sans-serif} .nl-desc{font-size:0.9em;opacity:.75;font-family:serif} .nl-new{margin:6px 0 12px 0;display:flex;justify-content:start} .nl-new > a{margin-right:12px} -input[type="text"]{border:0;border-bottom:3px solid #ccc;font:inherit;color:#181818;background-color:transparent} -input[type="text"]:focus{color:black;border-bottom-color:#09f} -input[type="text"].error{border-bottom-color:#ff1800} -.submit-primary{color:white;background-color:#37b92e;font-family:inherit;border:1px solid #37b92e;font-size:1.2em;height:2em;min-width:8em;border-radius:12px;display:inline-block} -.submit-secondary{color:black;background-color:white;font-family:inherit;border:1px solid #809980;font-size:1.2em;height:2em;min-width:8em;border-radius:12px;display:inline-block} +input{border:0;border-bottom:3px solid #ccc;font:inherit;color:#181818;background-color:transparent} +input:focus{color:black;border-bottom-color:#09f} +input.error{border-bottom-color:#ff1800} +input[type="submit"],input[type="reset"],input[type="button"],button{font-family:inherit;border-radius:12px;border:1px solid #ccc;display:inline-block} +.submit-primary{color:white;background-color:#37b92e;font-family:inherit;border:1px solid #37b92e;font-size:1.2em;height:2em;min-width:8em} +.submit-secondary{color:black;background-color:white;font-family:inherit;border:1px solid #809980;font-size:1.2em;height:2em;min-width:8em} .flash{background-color:#fff2b4;padding:12px;border-radius:4px;border:1px #ffe660 solid} .page-tags p{display:inline-block} .page-tags ul{padding:0;margin:0;list-style:none;display:inline-block} diff --git a/templates/base.html b/templates/base.html index df00da0..7908bda 100644 --- a/templates/base.html +++ b/templates/base.html @@ -8,6 +8,7 @@ + {% block json_info %}{% endblock %}
diff --git a/templates/home.html b/templates/home.html index 8dfae20..08136de 100644 --- a/templates/home.html +++ b/templates/home.html @@ -31,5 +31,6 @@

{{ T('latest-uploads') }}

+{# TODO security flaw; find a way to do this in a more safe manner! #} {{ gallery|safe }} {% endblock %} diff --git a/templates/view.html b/templates/view.html index de27e83..3c0a813 100644 --- a/templates/view.html +++ b/templates/view.html @@ -2,6 +2,8 @@ {% block title %}{{ p.title }} - {{ app_name }}{% endblock %} +{% block json_info %}{% endblock %} + {% block content %}

{{ p.title }}