2025.10.06-03:08:05

This commit is contained in:
2025-10-06 03:08:05 +02:00
parent 38a85cb9d5
commit e08b03bb42
57 changed files with 3222 additions and 157 deletions

View File

@@ -4,7 +4,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>TinyWiki</title>
<title>{% block head_title %}TinyWiki{% endblock %}</title>
{% block extra_css %}{% endblock %}
{% block scripts %}{% endblock %}
</head>

View File

@@ -12,12 +12,15 @@
{% else %}
<h1>Welcome to TinyWiki</h1>
<p>{% blocktranslate %}You are seeing this welcome page because there is no Welcome page
configured for your Wiki. To configure a welcome page create a new page with the
slug <i>tw-home</i> and put the content for your welcome-page there.{% endblocktranslate %}</p>
<p>{% blocktranslate %}You can use Markdown or BBCode to write your pages. If you don't know
Markdown read the <a href="#">Guide for Markdown used by TinyWiki</a>. Or if you want to use
BBCode there is a <a href="#">Guide for BBCode used by TinyWiki</a> too.{% endblocktranslate %}
<p style="text-align:justify">{% blocktranslate %}You are seeing this welcome page because there is no Welcome page
configured for your Wiki. To configure a welcome page {{ create_tw_home }} and put the content for your welcome-page there.{% endblocktranslate %}</p>
<p style="text-align:justify">{% blocktranslate %}You can use BBCode or Markdown to write your pages. If you don't know
Markdown or BBCode there are two guides you can consult before you start editing your pages.{% endblocktranslate %}
<ol>
<li>{{ bbcode_guide }}</li>
<li>{{ markdown_guide }}</li>
</ol>
</p>
{% endif %}
{% endblock content %}

View File

@@ -1,3 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-book" viewBox="0 0 16 16">
<path d="M1 2.828c.885-.37 2.154-.769 3.388-.893 1.33-.134 2.458.063 3.112.752v9.746c-.935-.53-2.12-.603-3.213-.493-1.18.12-2.37.461-3.287.811zm7.5-.141c.654-.689 1.782-.886 3.112-.752 1.234.124 2.503.523 3.388.893v9.923c-.918-.35-2.107-.692-3.287-.81-1.094-.111-2.278-.039-3.213.492zM8 1.783C7.015.936 5.587.81 4.287.94c-1.514.153-3.042.672-3.994 1.105A.5.5 0 0 0 0 2.5v11a.5.5 0 0 0 .707.455c.882-.4 2.303-.881 3.68-1.02 1.409-.142 2.59.087 3.223.877a.5.5 0 0 0 .78 0c.633-.79 1.814-1.019 3.222-.877 1.378.139 2.8.62 3.681 1.02A.5.5 0 0 0 16 13.5v-11a.5.5 0 0 0-.293-.455c-.952-.433-2.48-.952-3.994-1.105C10.413.809 8.985.936 8 1.783"/>
</svg>

Before

Width:  |  Height:  |  Size: 772 B

View File

@@ -1,4 +0,0 @@
<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" fill=\"currentColor\" class=\"bi bi-box-arrow-up-right\" viewBox=\"0 0 16 16\">
<path fill-rule=\"evenodd\" d=\"M8.636 3.5a.5.5 0 0 0-.5-.5H1.5A1.5 1.5 0 0 0 0 4.5v10A1.5 1.5 0 0 0 1.5 16h10a1.5 1.5 0 0 0 1.5-1.5V7.864a.5.5 0 0 0-1 0V14.5a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h6.636a.5.5 0 0 0 .5-.5\"/>
<path fill-rule=\"evenodd\" d=\"M16 .5a.5.5 0 0 0-.5-.5h-5a.5.5 0 0 0 0 1h3.793L6.146 9.146a.5.5 0 1 0 .708.708L15 1.707V5.5a.5.5 0 0 0 1 0z\"/>
</svg>

Before

Width:  |  Height:  |  Size: 552 B

View File

@@ -1,4 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-file-earmark-x" viewBox="0 0 16 16">
<path d="M6.854 7.146a.5.5 0 1 0-.708.708L7.293 9l-1.147 1.146a.5.5 0 0 0 .708.708L8 9.707l1.146 1.147a.5.5 0 0 0 .708-.708L8.707 9l1.147-1.146a.5.5 0 0 0-.708-.708L8 8.293z"/>
<path d="M14 14V4.5L9.5 0H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2M9.5 3A1.5 1.5 0 0 0 11 4.5h2V14a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1h5.5z"/>
</svg>

Before

Width:  |  Height:  |  Size: 485 B

View File

@@ -1,3 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-house" viewBox="0 0 16 16">
<path d="M8.707 1.5a1 1 0 0 0-1.414 0L.646 8.146a.5.5 0 0 0 .708.708L2 8.207V13.5A1.5 1.5 0 0 0 3.5 15h9a1.5 1.5 0 0 0 1.5-1.5V8.207l.646.647a.5.5 0 0 0 .708-.708L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293zM13 7.207V13.5a.5.5 0 0 1-.5.5h-9a.5.5 0 0 1-.5-.5V7.207l5-5z"/>
</svg>

Before

Width:  |  Height:  |  Size: 415 B

View File

@@ -1,4 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-journal" viewBox="0 0 16 16">
<path d="M3 0h10a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2v-1h1v1a1 1 0 0 0 1 1h10a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1H3a1 1 0 0 0-1 1v1H1V2a2 2 0 0 1 2-2"/>
<path d="M1 5v -.5a.5.5 0 0 1 1 0V5h.5a.5.5 0 0 1 0 1h-2a.5.5 0 0 1 0-1zm0 3v-.5a.5.5 0 0 1 1 0V8h.5a.5.5 0 0 1 0 1h-2a.5.5 0 0 1 0-1zm0 3v-.5a.5.5 0 0 1 1 0v.5h.5a.5.5 0 0 1 0 1h-2a.5.5 0 0 1 0-1z"/>
</svg>

Before

Width:  |  Height:  |  Size: 498 B

View File

@@ -0,0 +1,35 @@
{% extends "tinywiki/page/bs-model-base.html" %}
{% load i18n %}
{% block head_title %}{{ site_title }} - {% translate "Create a new Wiki page" %}{% endblock %}
{% block title %}{% translate "Create a new Wiki page" %}{% endblock title%}
{% block scripts %}
<script>
function save_and_continue() {
form = document.getElementById("wiki-page-form");
form.action = form.action + "?save=1";
form.submit();
}
</script>
{% endblock scripts %}
{% block form_buttons %}
<button class="btn btn-primary" type="button" onclick="save_and_continue();">{% translate "Create page and continue" %}<button>
<button class="btn btn-success">{% translate "Create Page" %}</button>
<a class="btn btn-secondary" href="{% url 'tinywiki:home' %}">{% translate "Cancel" %}</a>
{% endblock form_buttons %}
{% block extended_extra_scripts %}
<script>
document.addEventListener('keydown',function(e) {
if (e.ctrlKey && e.key == "s") {
e.preventDefault();
var form = document.getElementById('wiki-page-form');
form.action = form.action + "?save=1";
form.submit();
}
});
</script>
{% endblock extended_extra_scripts%}

View File

@@ -0,0 +1,45 @@
{% extends "tinywiki/page/bs-model-base.html" %}
{% load i18n static %}
{% block head_title %}{{ site_title }} - {% translate "Edit Wiki Page" %}{% endblock head_title %}
{% block title %}{% translate "Edit Wiki Page" %}{% endblock title%}
{% block scripts %}
<script src="{% static "tinywiki/js/htmx.min.js" %}"></script>
{% endblock %}
{% block form_buttons %}
<span id="popover-btn-save-and-continue">
<button id="btn-save-and-continue"
type="button"
class="btn btn-primary"
id="btn-save-and-continue"
data-bs-toggle="popopver"
data-bs-placement="top"
hx-target="#popover-btn-save-and-continue"
hx-post="{% url "tinywiki:hx-page-edit" pk=page.pk %}"
>
{% translate "Save and continue" %}
</button>
</span>
<button type="submit" class="btn btn-success">{% translate "Save and show" %}</button>
<a class="btn btn-secondary" href="{% url "tinywiki:page" form.instance.slug %}">{% translate "Cancel" %}</a>
{% endblock form_buttons %}
{% block extended_extra_scripts%}
<script>
document.addEventListener('keydown',function(e) {
if (e.ctrlKey && e.key == "s") {
e.preventDefault();
btn = document.getElementById("btn-save-and-continue")
btn.click()
}
});
</script>
<script>
btn_save_popover = new bootstrap.Popover(document.getElementById("btn-save-and-continue"),trigger="manual");
btn_save_popover.show();
setTimeout(()=>{btn_save_popover.hide();},3000);
</script>
{% endblock %}

View File

@@ -0,0 +1,66 @@
{% extends base_template %}
{% load i18n widget_tweaks %}
{% block style %}
{% endblock %}
{% block content %}
<h1>{% block title %}{% endblock title%}</h1>
<form method="POST"
class="mb-4"
id="wiki-page-form"
action="{% if create %}{% url "tinywiki:page-create" %}{% else %}{% url "tinywiki:page-edit" slug=form.instance.slug|default:"1" %}{% endif %}">
{% csrf_token %}
<div class="form-floating form-floating-lg mb-3">
{% render_field form.title class="form-control form-control-lg" %}
{{ form.title.label_tag }}
</div>
<div class="form-floating form-floating-sm mb-3">
{% if create and slug %}
{% render_field form.slug class="form-control form-control-sm" value=slug placeholder="slug" %}
{% else %}
{% render_field form.slug class="form-control form-control-sm" palceholder="slug" %}
{% endif %}
{{ form.slug.label_tag }}
</div>
<div class="row">
<div class="col-lg-6">
<div class="form-floating form-floating-sm mb-3">
{% render_field form.content_type_data class="form-select form-select-sm" %}
{{ form.content_type_data.label_tag }}
</div>
</div>
<div class="col-lg-6">
<div class="form-floating form-floating-sm mb-3">
{% render_field form.status_data class="form-select form-select-sm" %}
{{ form.status_data.label_tag }}
</div>
</div>
</div>
<div class="form-floating mb-3">
{% render_field form.content class="form-control h-100" style="font-family:monospace;" rows=25 %}
{{ form.content.label_tag }}
</div>
<div class="text-end">
{% block form_buttons %}{% endblock form_buttons %}
</div>
</form>
{% endblock content%}
{% block extra_scripts %}
<script>
document.getElementById("id_content").addEventListener('keydown',function(e) {
if (e.key == "Tab") {
e.preventDefault();
var start = this.selectionStart;
var end = this.selectionEnd;
console.log(this.value);
// set textarea value to: text before caret + 4 spaces + text after caret
this.value = this.value.substring(0,start) + " " + this.value.substring(end);
this.selectionStart = this.selectionEnd = start + 4;
}
});
</script>
{% block extended_extra_scripts %}{% endblock %}
{% endblock extra_scripts %}

View File

@@ -1,11 +1,19 @@
{% extends base_template %}
{% load i18n %}
{% load i18n static %}
{% block extra_css %}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.11.1/build/styles/default.min.css">
<link rel="stylesheet" id="hljs-theme" href="{% static 'tinywiki/css/atom-one-light.min.css' %}">
{% endblock %}
{% block scripts %}
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.11.1/build/highlight.min.js"></script>
<script>
const theme=(window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light');
if (theme==="dark") {
let hljs_theme = document.getElementById('hljs-theme');
hljs_theme.setAttribute('href',href="{% static 'tinywiki/css/atom-one-dark.min.css' %}");
}
</script>
<script src="{% static 'tinywiki/js/highlight.min.js' %}"></script>
<script src="{% static 'tinywiki/js/bbcode.js' %}"></script>
{% endblock %}
{% block extra_scripts %}
@@ -18,9 +26,24 @@
<a class="btn btn-primary" href="{% url 'tinywiki:page-edit' slug=page.slug %}">{% translate "Edit Page" %}</a>
{% endif %}
{% if user_can_delete_wiki_page %}
<button class="btn btn-danger" type="button">Delete Page</button>
<button class="btn btn-danger"
hx-get="{% url 'tinywiki:hx-page-delete' pk=page.pk %}"
hx-target="#modal-here"
hx-swap="innerHTML"
hx-trigger="clicked"
data-bs-toggle="modal"
data-bs-target="#modal-here"
>{% translate "Delete Page" %}</button>
{% endif %}
</div>
<h1>{{ page.title }}</h1>
{{ page.html_content }}
{% endblock content %}
{% endblock content %}
{% block extra_body %}
<div id="modal-here" class="modal modal-blur fade" style="display:none;" aria-hidden="false" tab-index="-1">
<div class="modal-dialog modal-md modal-dialog-centered" role="document">
<div class="modal-content"></div>
</div>
</div>
{% endblock extra_body%}

View File

@@ -4,13 +4,6 @@
{% block title %}{% translate "Create a new Wiki page" %}{% endblock title%}
{% block form_buttons %}
{% if use_bootstrap %}
<div class="text-end">
<button class="btn btn-primary">{% translate "Create Page" %}</button>
<a class="btn btn-secondary" href="{% url 'tinywiki:home' %}">{% translate "Cancel" %}</a>
</div>
{% else %}
<button type="submit">{% translate "Create Page" %}</button>
<a class="button button-secondary" href="{% url 'tinywiki:home' %}">{% translate "Cancel" %}</a>
{% endif %}
{% endblock form_buttons %}

View File

@@ -0,0 +1,12 @@
{% extends base_template %}
{% load i18n %}
{% block content %}
<form method="POST">
{% csrf_token %}
<p>Type <b>{{ page.slug }}</b> in the field to delete the page.</p>
{{ form.as_p }}
<button class="button button-danger" type="submit">{% translate "Delete Page" %}</button>
<a class="button button-secondary" href="{% url 'tinywiki:page' page.slug %}">Cancel</a>
</form>
{% endblock content %}

View File

@@ -4,13 +4,6 @@
{% block title %}{% translate "Edit Wiki Page" %}{% endblock title%}
{% block form_buttons %}
{% if use_bootstrap %}
<div class="text-end">
<button type="submit" class="btn btn-primary">{% translate "Save Changes" %}</button>
<a class="btn btn-secondary" href="{% url "tinywiki:page" form.instance.slug %}">{% translate "Cancel" %}</a>
</div>
{% else %}
<button type="submit">{% translate "Save Changes" %}</button>
<a class="button button-secondary" href="{% url "tinywiki:page" form.instance.slug %}">{% translate "Cancel" %}</a>
{% endif %}
{% endblock form_buttons %}
{% endblock form_buttons %}

View File

@@ -0,0 +1,27 @@
{% load i18n widget_tweaks %}
<div class="modal-dialog modal-md modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="exampleModalLabel">{% translate "Delete Wiki-Page" %}</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form method="POST">
{% csrf_token %}
<p>
{% with page.slug as page_slug %}
{% blocktranslate %}Type <b>{{ page_slug }}</b> in the field below to delete the Wiki-Page.{% endblocktranslate %}
{% endwith %}
<div class="form-floating form-floating-sm">
{% render_field form.slug class="form-control form-cotrol-sm" placeholder=page.slug %}
<label for="{{ form.slug.auto_id }}">{{ form.slug }}</label>
</div>
<div class="text-end">
<button class="btn btn-danger" type="submit">{% translate "Delete the page" %}</button>
<button clasS="btn btn-secondary" type="button" data-bs-dismiss="modal">{% translate "Cancel" %}</button>
</div>
</p>
</form>
</div>
</div>
</div>

View File

@@ -0,0 +1,26 @@
{% load i18n %}
<span id="popover-btn-save-and-continue">
<button type="button"
class="btn btn-primary"
id="btn-save-and-continue"
data-bs-toggle="popopver"
data-bs-placement="top"
hx-target="#popover-btn-save-and-continue"
hx-post="{% url "tinywiki:hx-page-edit" pk=page.pk %}"
{% if save_success %}
data-bs-title="Successfully saved"
data-bs-content="Your Wiki page has been successfully saved!"
{% else %}
data-bs-title="Saving failed"
data-bs-content="Your Wiki page could not be saved!"
{% endif %}
>
Save and continue
</button>
<script>
btn_save_popover = new bootstrap.Popover(document.getElementById("btn-save-and-continue"),trigger="manual");
btn_save_popover.show();
setTimeout(() => {btn_save_popover.hide();},3000)
</script>
</span>

View File

@@ -4,77 +4,44 @@
{% block content %}
<h1>{% block title %}{% endblock title%}</h1>
<form method="POST"
class="mb-4"
id="wiki-page-form"
action="{% if create %}{% url "tinywiki:page-create" %}{% else %}{% url "tinywiki:page-edit" slug=form.instance.slug|default:"1" %}{% endif %}">
{% csrf_token %}
{% if use_bootstrap %}
<div class="form-floating mb-2">
{% with "form-control form-control-lg "|add:title_extra as title_class %}
{% render_field form.title class=title_class placeholder="{{ form.title.label }}" %}
{% endwith %}
<label for="{{ form.title.auto_id }}">{{ form.title.label }}</label>
</div>
<div class="form-floating mb-2">
{% with "form-control form-control-sm "|add:slug_extra as slug_class%}
{% render_field form.slug class=slug_class placeholder="{{ form.slug.label }}" %}
{% endwith %}
<label for="{{ form.slug.auto_id }}">{{ form.slug.label }}</label>
</div>
<div class="row">
<div class="col-md-6 mb-2">
<div class="form-floating mb-2">
{% with "form-select form-select-sm "|add:content_type_extra as content_type_class %}
{% render_field form.content_type_data class=content_type_class %}
{% endwith %}
<label for="{{ for.content_type_data.auto_id }}">{{ form.content_type_data.label }}</label>
</div>
</div>
<div class="col-md-6">
<div class="form-floating mb-2">
{% with "form-select form-select-sm "|add:status_extra as status_class %}
{% render_field form.status_data class=status_class %}
{% endwith %}
<label for="{{ for.status_data.auto_id }}">{{ form.status_data.label }}</label>
</div>
</div>
</div>
<div class="form-floating mb-3">
{% with "form-control h-100 "|add:content_extra as content_class %}
{% render_field form.content class=content_class rows="25"%}
{% endwith %}
<label for="{{ form.content.auto_id }}">{{ form.content.label }}</label>
</div>
<div class="text-end">
</div>
{% else %}
<p>
{% with title_extra|default:"" as title_class %}
{{ form.title.label_tag }}{% render_field form.title class=Title_class %}
{{ form.title.label_tag }} {% render_field form.title class="{{ title_class }}" %}
{% endwith %}
</p>
<p>
{% with slug_extra|default:"" as slug_class %}
{{ form.slug.label_tag }}{% render_field form.slug class=slug_class %}
{{ form.slug.label_tag }}
{% with slug_extra|default:"" as slug_class%}
{% if create and slug %}
{% render_field form.slug class=slug_class value=slug placeholder="slug" %}
{% else %}
{% render_field form.slug class=slug_class palceholder="slug" %}
{% endif %}
{% endwith %}
</p>
<p>
{% with content_type_extra|default:"" as content_type_class %}
{{ form.content_type_data.label_tag }}{% render_field form.content_type_data class=content_type_class %}
{{ form.content_type_data.label_tag }} {% render_field form.content_type_data class=content_type_class %}
{% endwith %}
</p>
<p>
{% with status_extra|default:"" as status_class %}
{{ form.status_data.label_tag }}{% render_field form.status_data class=status_class %}
{{ form.status_data.label_tag }} {% render_field form.status_data class=status_class %}
{% endwith %}
</p>
<p>
{% with content_extra|default:"" as content_class %}
{{ form.content.label_tag }}{% render_field form.content class=content_class cols=80 rows=30 %}
{{ form.content.label_tag }} {% render_field form.content class=content_class cols=80 rows=30 %}
{% endwith %}
</p>
{% endif %}
</p>
<div class="text-end">
{% block form_buttons %}{% endblock form_buttons %}
</div>
</form>
{% endblock content%}

View File

@@ -1,11 +1,13 @@
{% extends base_template %}
{% load i18n %}
{% load i18n static %}
{% block extra_css %}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.11.1/build/styles/default.min.css">
{% endblock %}
{% block scripts %}
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.11.1/build/highlight.min.js"></script>
<script src="{% static 'tinywiki/js/htmx.min.js' %}"></script>
<script src="{% static 'tinywiki/js/highlight.min.js' %}"></script>
<script src="{% static 'tinywiki/js/bbcode.js' %}"></script>
{% endblock %}
{% block extra_scripts %}
@@ -17,8 +19,11 @@
<a href="{% url 'tinywiki:page-edit' slug=page.slug %}">{% translate "Edit Page" %}</a>
{% endif %}
{% if user_can_delete_wiki_page %}
<a href="#">Delete Page</a>
<a href="{% url 'tinywiki:page-delete' slug=page.slug %}">{% translate "Delete Page" %}</a>
{% endif %}
<h1>{{ page.title }}</h1>
{{ page.html_content }}
{% endblock content %}
{% endblock content %}
{% block extra_body %}
{% block %}