initial commit (it has come late tho 🙁)

This commit is contained in:
Yusur 2021-02-23 22:54:08 +01:00
commit c2bf966dac
27 changed files with 1618 additions and 0 deletions

34
templates/base.html Normal file
View file

@ -0,0 +1,34 @@
<!DOCTYPE html>
<html>
<head>
{% set app_name = 'Salvi' %}
<title>{% block title %}{{ app_name }}{% endblock %}</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/static/style.css">
<!-- material icons -->
<link rel="stylesheet" href="https://cdn.sakuragasaki46.local/common/material-icons.css">
</head>
<body>
<div id="__top"></div>
<div class="content">
{% for msg in get_flashed_messages() %}
<div class="flash">{{ msg }}</div>
{% endfor %}
{% block content %}{% endblock %}
</div>
<ul class="top-menu">
<li class="dark-theme-toggle-anchor"><a href="javascript:toggleDarkTheme(true)" class="dark-theme-toggle-on" title="Dark theme"><span class="material-icons">brightness_3</span></a><a href="javascript:toggleDarkTheme(false)" class="dark-theme-toggle-off" title="Light theme"><span class="material-icons">brightness_5</span></a><script>function toggleDarkTheme(a){document.cookie="dark="+(+a)+";max-age=31556952;path=/";document.body.classList.toggle("dark",a)}if(document.cookie.match(/\bdark=1\b/)){document.body.classList.add("dark")}</script></li>
<li><a href="/" title="{{ T('homepage') }}"><span class="material-icons">home</span></a></li>
<li><a href="/search/" title="{{ T('search') }}"><span class="material-icons">search</span></a></li>
<li><a href="/p/random/" title="{{ T('random-page') }}"><span class="material-icons">shuffle</span></a></li>
<li><a href="/create/" title="{{ T('new-note') }}"><span class="material-icons">create</span></a></li>
</ul>
<div class="footer">
<div class="footer-copyright">&copy; 2020 Sakuragasaki46.</div>
<div class="footer-actions" id="page-actions">{% block actions %}{% endblock %}</div>
</div>
<div class="backontop"><a href="#__top" title="Back on top"><span class="material-icons">arrow_upward</span></a></div>
{% block scripts %}{% endblock %}
</body>
</html>

29
templates/easter.html Normal file
View file

@ -0,0 +1,29 @@
{% extends "base.html" %}
{% block title %}{{ T('easter-date-calc') }} - {{ app_name }}{% endblock %}
{% block content %}
<h1>{{ T('easter-date-calc') }}</h1>
<form>
<div>
<label for="y">Year: </label>
<input type="text" name="y" value="{{ y }}">
<input type="submit" value="Calculate">
</div>
</form>
{% if easter_dates %}
<div class="easter-results">
<p class="easter-date">{{ T('easter') }}: <strong>{{ easter_dates['easter'].strftime('%B %-d, %Y') }}</strong></p>
<h2>{{ T('other-dates') }}</h2>
<ul>
<li>Mercoledì delle Ceneri: <strong>{{ easter_dates['ceneri'].strftime('%B %-d, %Y') }}</strong></li>
<li>Ascensione: <strong>{{ easter_dates['ascensione'].strftime('%B %-d, %Y') }}</strong></li>
<li>Pentecoste: <strong>{{ easter_dates['pentecoste'].strftime('%B %-d, %Y') }}</strong></li>
<li>Prima Domenica d'Avvento: <strong>{{ easter_dates['avvento1'].strftime('%B %-d, %Y') }}</strong></li>
</ul>
</div>
{% endif %}
{% endblock %}

48
templates/edit.html Normal file
View file

@ -0,0 +1,48 @@
{% extends "base.html" %}
{% block title %}Edit note - {{ app_name }}{% endblock %}
{% block content %}
{% if preview %}
<h1>{{ pl_title }} (preview)</h1>
<div class="preview-area">
<div class="preview-warning">
Remember this is only a preview.
<strong>Your changes were not saved yet!</strong>
<a href="#editing-area">Jump to editing area</a></div>
<div class="inner-content">{{ preview|safe }}</div>
<div style="clear:both"></div>
</div>
{% endif %}
<form method="POST">
<div>
<label for="title">URL: </label>
<input type="text" name="url" class="url-input" placeholder="No URL" maxlength="64" value="{{ pl_url or '' }}">
</div>
<div>
<input type="text" required name="title" placeholder="Title (required)" class="title-input" maxlength="256" value="{{ pl_title }}">
</div>
<div id="editing-area">
<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>
</div>
<div class="over-text-input"></div>
<textarea name="text" class="text-input">{{ 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>
<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">
</div>
</form>
{% endblock %}
{% block scripts %}
<script src="/static/edit.js"></script>
{% endblock %}

View file

@ -0,0 +1,20 @@
{% extends "base.html" %}
{% block title %}Export pages - {{ app_name }}{% endblock %}
{% block content %}
<h1>Export pages</h1>
<p>You can export how many pages you want, that will be downloaded in JSON format and can be imported in another {{ app_name }} instance.</p>
<p>In order to add page to export list, please enter exact title, /url, #tag or +id. Entering a tag will add all pages with that tag to list. Each page or tag is separated by a newline.</p>
<form method="POST">
<div>
<textarea style="height:20em;width:100%" name="export-list" placeholder="Title, /url, #tag, or +id, newline-separated"></textarea>
</div>
<div>
<input type="submit" value="Download">
</div>
</form>
{% endblock %}

17
templates/history.html Normal file
View file

@ -0,0 +1,17 @@
{% extends "base.html" %}
{% block title %}Page history - {{ app_name }}{% endblock %}
{% block content %}
<h1>Page history for "{{ p.title }}"</h1>
<ul>
{% for rev in history %}
<li><a href="/history/revision/{{ rev.id }}/">
#{{ rev.id }}
&middot;
{{ rev.pub_date.strftime("%B %-d, %Y %H:%M:%S") }}
</a></li>
{% endfor %}
</ul>
{% endblock %}

35
templates/home.html Normal file
View file

@ -0,0 +1,35 @@
{% extends "base.html" %}
{% block title %}{{ T('homepage') }} - {{ app_name }}{% endblock %}
{% block content %}
<h1>{{ T('welcome').format(app_name) }}</h1>
<h2>{{ T('latest-notes') }}</h2>
<ul class="nl-list">
<li class="nl-new">
<a href="/create/"><button class="submit-primary">{{ T('new-note') }}</button></a>
<a href="/upload/"><button class="submit-secondary">{{ T('upload-file') }}</button></a>
</li>
{% for n in new_notes %}
<li>
<a href="{{ n.get_url() }}" class="nl-title">{{ n.title }}</a>
<p class="nl-desc">{{ n.short_desc() }}</p>
{% if n.tags %}
<p class="nl-tags">{{ T('tags') }}:
{% for tag in n.tags %}
{% set tn = tag.name %}
<a href="/tags/{{ tn }}/" class="nl-tag">#{{ tn }}</a>
{% endfor %}
</p>
{% endif %}
</li>
{% endfor %}
<li><a href="/p/most_recent/">Show all</a></li>
</ul>
<h2>{{ T('latest-uploads') }}</h2>
{{ gallery|safe }}
{% endblock %}

View file

@ -0,0 +1,14 @@
<p class="nl-title">
<a href="{{ n.get_url() }}" class="nl-title">{{ n.title }}</a>
</p>
<p class="nl-desc">{{ n.short_desc() }}</p>
<p class="nl-tags">Tags:
{% for tag in n.tags %}
{% set tn = tag.name %}
{% if hl_tag_name and tn == hl_tag_name %}
<strong class="nl-tag-hl">#{{ tn }}</strong>
{% else %}
<a href="/tags/{{ tn }}/" class="nl-tag">#{{ tn }}</a>
{% endif %}
{% endfor %}
</p>

27
templates/listrecent.html Normal file
View file

@ -0,0 +1,27 @@
{% extends "base.html" %}
{% block content %}
<h1>Notes by date</h1>
<p class="nl-pagination">Showing results <strong>{{ page_n * 20 - 19 }}</strong> to <strong>{{ min(page_n * 20, total_count) }}</strong> of <strong>{{ total_count }}</strong> total.</p>
<ul class="nl-list">
{% if page_n > 1 %}
<li class="nl-prev"><a href="/p/most_recent/{{ page_n - 1 }}">&laquo; Previous page</a></li>
{% endif %}
{% for n in notes %}
<li>
<a href="{{ n.get_url() }}" class="nl-title">{{ n.title }}</a>
<p class="nl-desc">{{ n.short_desc() }}</p>
<p class="nl-tags">Tags:
{% for tag in n.tags %}
<a href="/tags/{{ tag.name }}/" class="nl-tag">#{{ tag.name }}</a>
{% endfor %}
</p>
</li>
{% endfor %}
{% if page_n <= total_count // 20 %}
<li class="nl-next"><a href="/p/most_recent/{{ page_n + 1 }}/">Next page &raquo;</a></li>
{% endif %}
</ul>
{% endblock %}

40
templates/listtag.html Normal file
View file

@ -0,0 +1,40 @@
{% extends "base.html" %}
{% block title %}Notes tagged #{{ tagname }} - {{ app_name }}{% endblock %}
{% block content %}
<h1>{{ T('notes-tagged') }} #{{ tagname }}</h1>
{% if total_count > 0 %}
<p class="nl-pagination">Showing results <strong>{{ page_n * 20 - 19 }}</strong> to <strong>{{ min(page_n * 20, total_count) }}</strong> of <strong>{{ total_count }}</strong> total.</p>
<ul class="nl-list">
{% if page_n > 1 %}
<li class="nl-prev"><a href="/tags/{{ tagname }}/{{ page_n - 1 }}/">&laquo; Previous page</a></li>
{% endif %}
{% for n in tagged_notes %}
<li>
<a href="{{ n.get_url() }}" class="nl-title">{{ n.title }}</a>
<p class="nl-desc">{{ n.short_desc() }}</p>
<p class="nl-tags">Tags:
{% for tag in n.tags %}
{% set tn = tag.name %}
{% if tn == tagname %}
<strong class="nl-tag-hl">#{{ tn }}</strong>
{% else %}
<a href="/tags/{{ tn }}/" class="nl-tag">#{{ tn }}</a>
{% endif %}
{% endfor %}
</p>
</li>
{% endfor %}
{% if page_n < total_count // 20 %}
<li class="nl-next"><a href="/tags/{{ tagname }}/{{ page_n + 1 }}/">Next page &raquo;</a></li>
{% endif %}
</ul>
{% else %}
<p class="nl-placeholder">{{ T('notes-tagged-empty') }}</p>
{% endif %}
{% endblock %}

9
templates/notfound.html Normal file
View file

@ -0,0 +1,9 @@
{% extends "base.html" %}
{% block title %}Not found - {{ app_name }}{% endblock %}
{% block content %}
<h1>Not Found</h1>
<p>The url at <strong>{{ request.path }}</strong> does not exist.</p>
{% endblock %}

31
templates/search.html Normal file
View file

@ -0,0 +1,31 @@
{% extends "base.html" %}
{% block title %}{% if q %}Search results for "{{ q }}"{% else %}Search{% endif %} - {{ app_name }}{% endblock %}
{% block content %}
<h1>Search</h1>
<form method="POST">
<div>
<label for="q">Search for: </label>
<input type="search" name="q" value="{{ q }}" class="search-input">
</div>
<div>
<input type="checkbox" name="include-tags" value="1" {% if pl_include_tags %}checked{% endif %}>
<label for="include-tags">{{ T('include-tags') }}</label>
</div>
</form>
{% if results %}
<h2>Search results for <em>{{ q }}</em></h2>
<ul class="nl-list">
{% for n in results %}
<li>{% include "includes/nl_item.html" %}</li>
{% endfor %}
</ul>
{% elif q %}
<h2>{{ T('search-no-results') }} <em>{{ q }}</em></h2>
{% endif %}
{% endblock %}

15
templates/stats.html Normal file
View file

@ -0,0 +1,15 @@
{% extends "base.html" %}
{% block title %}Statistics - {{ app_name }}{% endblock %}
{% block content %}
<h1>Statistics</h1>
<ul>
<li>Number of pages: <strong>{{ notes_count }}</strong></li>
<li>Number of pages with URL set: <strong>{{ notes_with_url }}</strong></li>
<li>Number of uploads: <strong>{{ upload_count }}</strong></li>
<li>Number of revisions: <strong>{{ revision_count }}</strong></li>
<li>Average revisions per page: <strong>{{ (revision_count / notes_count)|round(2) }}</strong></li>
</ul>
{% endblock %}

43
templates/upload.html Normal file
View file

@ -0,0 +1,43 @@
{% extends "base.html" %}
{% block content %}
<h1>Upload new file</h1>
<p>Types supported: <strong>.jpeg</strong>, <strong>.jpg</strong>, <strong>.png</strong>.</p>
<form method="POST" enctype="multipart/form-data">
<div>
<label for="name">Name: </label>
<input type="text" id="name-input" name="name" required maxlength="256">
</div>
<div>
<label for="file">File: </label>
<input type="file" id="file-input" name="file" accept="image/jpeg, image/png">
</div>
<div>
<input type="submit" class="submit-primary" value="Upload">
</div>
</form>
{% endblock %}
{% block scripts %}
<script>
(function(){
function last(a){
return a[a.length-1];
}
var fileInput = document.getElementById('file-input');
var nameInput = document.getElementById('name-input');
fileInput.onchange = function(){
var name = last(fileInput.value.split(/[\/\\]/));
if(name.indexOf('.') >= 0){
name = name.replace(/\..*$/, '');
}
nameInput.value = name;
// TODO: add image preview
}
})();
</script>
{% endblock %}

23
templates/uploadinfo.html Normal file
View file

@ -0,0 +1,23 @@
{% extends "base.html" %}
{% block title %}Info on file "{{ upl.name }}" - {{ app_name }}{% endblock %}
{% block content %}
<h1>Info on file "{{ upl.name }}"</h1>
<div class="upload-frame">
<img src="{{ upl.url }}" alt="{{ upl.name }}">
</div>
<p>You can include this file in other pages with <strong>{{ '{{' }}media:{{ upl.id }}{{ '}}' }}</strong>.</p>
<h2>File info</h2>
<p>Type: {{ type_list[upl.filetype] }}</p>
<p>Upload ID: {{ upl.id }}</p>
<p>Uploaded on: {{ upl.upload_date.strftime('%B %-d, %Y %H:%M:%S') }}</p>
<p>Size: {{ upl.filesize }} bytes</p>
{% endblock %}

33
templates/view.html Normal file
View file

@ -0,0 +1,33 @@
{% extends "base.html" %}
{% block title %}{{ p.title }} - {{ app_name }}{% endblock %}
{% block content %}
<h1>{{ p.title }}</h1>
<div class="jump-to-actions"><a href="#page-actions">{{ T('jump-to-actions') }}</a></div>
{% block history_nav %}{% endblock %}
<div class="inner-content">
{{ rev.html()|safe }}
</div>
{% if p.tags %}
<div class="page-tags">
<p>{{ T('tags') }}:</p>
<ul>
{% for tag in p.tags %}
<li><a href="/tags/{{ tag.name }}/">#{{ tag.name }}</a> <span class="tag-count">({{ tag.popularity() }})</span></li>
{% endfor %}
</ul>
</div>
{% endif %}
{% endblock %}
{% block actions %}
<a href="/edit/{{ p.id }}/">{{ T('action-edit') }}</a> -
<a href="/history/{{ p.id }}/">{{ T('action-history') }}</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 }}
{% endblock %}

9
templates/viewold.html Normal file
View file

@ -0,0 +1,9 @@
{% extends "view.html" %}
{% block history_nav %}
<div class="history-nav">
<p>{{ T('old-revision-notice') }}
<time datetime="{{ rev.pub_date.isoformat() }}">{{ rev.pub_date.strftime('%B %-d, %Y at %H:%M:%S') }}</time>
(ID #{{ rev.id }}). <a href="{{ p.get_url() }}">Show latest</a></p>
</div>
{% endblock %}