Add JS page info
This commit is contained in:
parent
2b7d990bb9
commit
0394e4b0d4
5 changed files with 25 additions and 5 deletions
15
app.py
15
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)
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
<link rel="stylesheet" href="/static/style.css">
|
||||
<!-- material icons -->
|
||||
<link rel="stylesheet" href="https://cdn.sakuragasaki46.local/common/material-icons.css">
|
||||
{% block json_info %}{% endblock %}
|
||||
</head>
|
||||
<body{% if request.cookies.get('dark') == '1' %} class="dark"{% endif %}>
|
||||
<div id="__top"></div>
|
||||
|
|
|
|||
|
|
@ -31,5 +31,6 @@
|
|||
|
||||
<h2>{{ T('latest-uploads') }}</h2>
|
||||
|
||||
{# TODO security flaw; find a way to do this in a more safe manner! #}
|
||||
{{ gallery|safe }}
|
||||
{% endblock %}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
{% block title %}{{ p.title }} - {{ app_name }}{% endblock %}
|
||||
|
||||
{% block json_info %}<script>window.page_info={{ p.js_info()|tojson|safe }};</script>{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>{{ p.title }}</h1>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue