Improved users, now /create and /edit require user login, changed savepoint() helper

This commit is contained in:
Yusur 2023-01-07 23:04:06 +01:00
parent 83e2c892b3
commit f4d536dc47
9 changed files with 102 additions and 42 deletions

View file

@ -45,7 +45,13 @@
</ul>
<div class="footer">
<div class="footer-copyright">&copy; 20202023 Sakuragasaki46.</div>
<div class="footer-loggedinas">{% if current_user %}{{ T('logged-in-as') }}: <strong>{{ current_user.username }}</strong>{% else %}{{ T('not-logged-in') }}{% endif %}</div>
<div class="footer-loggedinas">
{% if current_user.is_authenticated %}
{{ T('logged-in-as') }}: <strong>{{ current_user.username }}</strong>
{% else %}
{{ T('not-logged-in') }}. <a href="/accounts/login">{{ T("login") }}</a>
{% endif %}
</div>
<div class="footer-actions" id="page-actions">{% block actions %}{% endblock %}</div>
<div class="footer-versions">{{app_name}} version {{app_version}}</div>
</div>

View file

@ -11,7 +11,7 @@
<meta name="robots" content="noindex,nofollow" />
{% endblock %}
{% block json_info %}<script>window.page_info={{ ( pl_js_info or {} )|tojson|safe }};</script>{% endblock %}
{% block json_info %}<script>/*<![CDATA[*/window.page_info={{ ( pl_js_info or {} )|tojson|safe }};/*]]>*/</script>{% endblock %}
{% block content %}
@ -35,25 +35,32 @@
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<div>
<label for="title"><span class="material-icons">link</span> /</label>
<input type="text" name="url" class="url-input" placeholder="(No URL)" maxlength="64" value="{{ pl_url or '' }}">
<input type="text" name="url" class="url-input" placeholder="(No URL)" maxlength="64" value="{{ pl_url or '' }}" {% if pl_readonly %}disabled=""{% endif %}>
</div>
<div>
<input type="text" required name="title" placeholder="Title (required)" class="title-input" maxlength="256" value="{{ pl_title }}">
<input type="text" required name="title" placeholder="Title (required)" class="title-input" maxlength="256" value="{{ pl_title }}" {% if pl_readonly %}disabled=""{% endif %}>
</div>
<div id="editing-area">
{% if not pl_readonly %}
<div class="pre-text-input">
<p>This editor is using Markdown for text formatting (e.g. bold, italic, headers and tables). <a href="https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet" rel="nofollow">More info on Markdown</a>.</p>
{% if math_version %}
{% if math_version and pl_enablemath %}
<p>Math with KaTeX is <mark>enabled</mark>. <a href="https://katex.org/docs/supported.html">KaTeX guide</a></p>
{% endif %}
</div>
<div class="over-text-input"></div>
<textarea name="text" class="text-input">{{ pl_text }}</textarea>
{% else %}
<div class="pre-text-input">
<p>This page was locked by the owner, and is therefore not editable. You can still copy the source text.</p>
</div>
{% endif %}
<textarea name="text" class="text-input" {% if pl_readonly %}disabled=""{% endif %}>{{ pl_text }}</textarea>
</div>
<div>
<label for="tags">Tags (comma separated):</label>
<input type="text" name="tags" class="tags-input" placeholder="No tags" value="{{ pl_tags }}">
</div>
{% if not pl_readonly %}
<div>
<input type="submit" value="Save" id="save-button" class="submit-primary">
<input type="submit" name="preview" value="Preview" id="preview-button" class="submit-secondary">
@ -63,6 +70,13 @@
<input type="checkbox" id="CB__enablemath" name="enablemath" {% if math_version and pl_enablemath %}checked=""{% elif not math_version %}disabled=""{% endif %}>
<label for="CB__enablemath">Enable math expressions parsing {% if not math_version %}(disabled for this instance){% endif %}</label>
</div>
{% if pl_owner_is_current_user %}
<div>
<input type="checkbox" id="CB__lockpage" name="lockpage" {% if pl_is_locked %}checked=""{% endif %}>
<label for="CB__lockpage">Lock page for editing by other users</label>
</div>
{% endif %}
{% endif %}
</form>
{% endblock %}

View file

@ -16,6 +16,8 @@
#{{ rev.id }}
&middot;
{{ rev.pub_date.strftime("%B %-d, %Y %H:%M:%S") }}
by
{{ rev.user.username }}
</a></li>
{% endfor %}
</ul>

View file

@ -0,0 +1,9 @@
{% extends "base.html" %}
{% block title %}Internal Server Error - {{ app_name }}{% endblock %}
{% block content %}
<h1>Internal Server Error</h1>
<p>Were sorry, an unexpected error occurred. Try refreshing the page.</p>
{% endblock %}

View file

@ -17,18 +17,18 @@
</div>
<div>
<label>{{ T('confirm-password') }}:</label>
<input type="password" name="confirmpassword" />
<input type="password" name="confirm_password" />
</div>
<div>
<label>{{ T('email') }} ({{ T('optional') }}):</label>
<input type="email" name="email" />
<input type="text" name="email" />
</div>
<div>
<input type="checkbox" name="legal" value="1" />
<label>{{ T('have-read-terms').format(T('terms-of-service'), T('privacy-policy')) }}</label>
</div>
<div>
<input type="submit" value="{{ T('login') }}" />
<input type="submit" value="{{ T('sign-up') }}" />
</div>
</form>

View file

@ -38,7 +38,8 @@
<a href="/history/{{ p.id }}/">{{ T('action-history') }}</a> -
<a href="/backlinks/{{ p.id }}/">Backlinks</a> -
{{ T('last-changed') }} <time datetime="{{ rev.pub_date.isoformat() }}">{{ rev.pub_date.strftime('%B %-d, %Y at %H:%M:%S') }}</time> -
{{ T('page-id') }}: {{ p.id }}
{{ T('page-id') }}: {{ p.id }} -
{{ T('owner') }}: {{ p.owner.username }}
{% endblock %}
{% block scripts %}