gaisen/templates/main.html

111 lines
2.9 KiB
HTML
Raw Normal View History

2024-02-24 05:46:16 +00:00
{% extends 'base.html' %}
{% block title %}{{ path }}{% endblock %}
2024-02-24 12:38:56 +00:00
{% macro render_tree(tree, root='') %}
<ul>
{% for entry in tree %}
<li>
2024-02-24 09:35:36 +00:00
{% set url = path_join(root, entry.name) %}
2024-02-24 12:38:56 +00:00
{#{% if loop.last or entry.children|length > 0 %}#}
{% if entry.children|length > 0 %}
{% else %}
·
{% endif %}
<a href="{{ path_join('/', url ) }}">{{ entry.name }}</a>
2024-02-24 09:35:36 +00:00
{{ render_tree(entry.children, url) }}
</li>
{% endfor %}
</ul>
2024-02-24 05:46:16 +00:00
{% endmacro %}
{% block body %}
<main>
2024-02-24 12:38:56 +00:00
<nav>
2024-02-24 12:38:56 +00:00
<div>
&gt; <a href="/">index</a>/{{ path }}
</div>
<hr/>
{{ render_tree(document_tree.root.children) }}
</nav>
2024-02-24 05:46:16 +00:00
<article>
2024-02-24 12:38:56 +00:00
<main>
{% if not edit %}
2024-02-24 09:35:36 +00:00
{% if path != '' %}
2024-02-24 10:03:36 +00:00
<a href="/{{ path }}?edit">Edit</a>
2024-02-24 09:35:36 +00:00
{% endif %}
{% if content is not none %}
{% autoescape false %}
{{ markdown(content, extensions=['extra']) }}
{% endautoescape %}
{% else %}
<p class="grayed">This document doesn't exist</p>
{% endif %}
{% else %}
2024-02-24 10:03:36 +00:00
<form method="POST" action="/{{ path }}">
{% set edit_content = content %}
{% if content is none %}
{% set edit_content = '# Title\n\nContent' %}
{% endif %}
<textarea id="markdown-textarea" name="text">{{ edit_content }}</textarea>
<input type="submit" value="Save"/>
<form>
<script>
const easyMDE = new EasyMDE({
element: document.getElementById('markdown-textarea'),
autosave: {
enabled: false,
uniqueId: "whatever-i-guess",
delay: 1000,
submit_delay: 5000,
timeFormat: {
locale: 'en-US',
format: {
//year: 'numeric',
//month: 'long',
//day: '2-digit',
hour: '2-digit',
minute: '2-digit',
2024-02-24 05:46:16 +00:00
},
},
text: "Autosaved: "
},
});
</script>
{% endif %}
2024-02-24 12:38:56 +00:00
</main>
2024-02-24 09:35:36 +00:00
<hr/>
{% for child in document_tree.get_node(path).children %}
2024-02-24 12:38:56 +00:00
2024-02-24 09:35:36 +00:00
{% if loop.first %}
2024-02-24 12:38:56 +00:00
<footer>
<h1>Children</h1>
{% endif %}
<a href="{{ path_join(path, child.name) }}">{{child.name}}</a>{% if not loop.last %},{% endif %}
{% if loop.last %}
</footer>
2024-02-24 09:35:36 +00:00
{% endif %}
{% endfor %}
</article>
</main>
2024-02-24 05:46:16 +00:00
{% set footer = config.get('foote') %}
{% if footer not in [None, False, ""] %}
<footer>{{ config.get('footer') }}</footer>
{% endif %}
2024-02-24 05:46:16 +00:00
{% endblock %}