aboutsummaryrefslogtreecommitdiffstats
path: root/templates/wiki
diff options
context:
space:
mode:
authorGravatar Gareth Coles <[email protected]>2018-05-06 18:21:34 +0100
committerGravatar Gareth Coles <[email protected]>2018-05-06 18:21:34 +0100
commitefb902f3f293db4aac6e57b9f3a84143d84a90e9 (patch)
tree69fd91e690f1b8e150b839927c8bb312ebf81abc /templates/wiki
parentI linted that, I swear (diff)
[Wiki] Misc improvements, plus a beta search feature
Diffstat (limited to 'templates/wiki')
-rw-r--r--templates/wiki/base.html21
-rw-r--r--templates/wiki/page_edit.html27
-rw-r--r--templates/wiki/page_move.html4
-rw-r--r--templates/wiki/search.html23
-rw-r--r--templates/wiki/search_results.html39
5 files changed, 104 insertions, 10 deletions
diff --git a/templates/wiki/base.html b/templates/wiki/base.html
index a71f09e6..9b31d83b 100644
--- a/templates/wiki/base.html
+++ b/templates/wiki/base.html
@@ -154,12 +154,31 @@
{% endif %}
<li class="uk-nav-divider"></li>
+{# <li><a href="{{ url_for("wiki.search") }}">#}
+{# <i class="uk-icon fas fa-fw fa-search"></i> &nbsp;Search#}
+{# </a></li>#}
<li><a href="{{ url_for("wiki.special") }}">
<i class="uk-icon fas fa-fw fa-ellipsis-h"></i> &nbsp;Special Pages
</a></li>
<li><a href="{{ url_for("wiki.page", page="help") }}">
- <i class="fas fa-fw fa-question-circle"></i> &nbsp;Help
+ <i class="uk-icon fas fa-fw fa-question-circle"></i> &nbsp;Help
</a></li>
+
+ <li>
+ <form action="{{ url_for("wiki.search") }}" method="post">
+ {% if query is undefined %}
+ <input type="text" class="uk-input" placeholder="Search (BETA)" id="query" name="query" style="padding-right: 0; margin-top: 5px; border-left: 0; border-right: 0;" required>
+ {% else %}
+ <input type="text" class="uk-input" placeholder="Search (BETA)" id="query" name="query" value="{{ query }}" style="padding-right: 0; margin-top: 5px; border-left: 0; border-right: 0;" required>
+ {% endif %}
+ <br />
+ <button class="uk-button uk-button-darkish uk-button-small" type="submit" id="search" title="Search" style="width: 100%; border: 0;">
+ <i class="uk-icon fas fa-fw fa-search"></i>
+ </button>
+
+ <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
+ </form>
+ </li>
</ul>
</div>
<div class="uk-section" style="flex-grow: 1; margin: 0 1rem 1rem;">
diff --git a/templates/wiki/page_edit.html b/templates/wiki/page_edit.html
index 51ce70db..138292f9 100644
--- a/templates/wiki/page_edit.html
+++ b/templates/wiki/page_edit.html
@@ -8,7 +8,7 @@
{% block content %}
<form uk-grid class="uk-grid-small" action="{{ url_for("wiki.edit", page=page) }}" method="post">
<div class="uk-width-expand">
- <input name="title" id="title" placeholder="Page Title" value="{{ title }}" class="uk-input" />
+ <input name="title" id="title" placeholder="Page Title" value="{{ title }}" class="uk-input" required />
</div>
<div class="uk-width-auto">
<button class="uk-button uk-button-secondary" type="button" value="Preview" id="preview">Preview</button>
@@ -37,7 +37,7 @@
let csrf_token = "{{ csrf_token() }}";
- document.getElementById("preview").onclick = function(event) {
+ function do_preview() {
let oReq = new XMLHttpRequest();
oReq.addEventListener("load", function() {
@@ -63,7 +63,7 @@
let data = editor.getValue();
- if (data.replace("\s", "").length < 1) {
+ if (data.replace("\s", "").length < 1 || document.getElementById("title").value.length < 1) {
document.getElementById("submit").disabled = true;
return false;
}
@@ -76,7 +76,9 @@
oReq.send(JSON.stringify({"data": editor.getValue()}));
return false;
- };
+ }
+
+ document.getElementById("preview").onclick = do_preview;
let editor = ace.edit("editor");
let timer;
@@ -93,15 +95,26 @@
if (timer !== undefined) {
clearTimeout(timer);
}
- timer = setTimeout(function() {document.getElementById("preview").click()}, 1000);
+ timer = setTimeout(do_preview, 1000);
});
document.getElementById("title").oninput = function() {
+ if (document.getElementById("title").value.length < 1) {
+ document.getElementById("submit").disabled = true;
+ }
+
document.getElementById("preview-title").textContent = document.getElementById("title").value;
- }
+
+ document.getElementById("rst").value = editor.getValue();
+
+ if (timer !== undefined) {
+ clearTimeout(timer);
+ }
+ timer = setTimeout(do_preview, 1000);
+ };
function refreshLock(){
- console.log("Refreshing lock")
+ console.log("Refreshing lock");
let xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState === 4 && this.status === 204) {
diff --git a/templates/wiki/page_move.html b/templates/wiki/page_move.html
index e2d52807..409c02e7 100644
--- a/templates/wiki/page_move.html
+++ b/templates/wiki/page_move.html
@@ -14,10 +14,10 @@
<form uk-grid class="uk-grid-small" action="{{ url_for("wiki.move", page=page) }}" method="post">
<input type="text" class="uk-width-1-1 uk-input" placeholder="{{ page }}" id="location" name="location" style="margin-left: 15px;" required>
<div class="uk-width-1-2">
- <a href="{{ url_for("wiki.page", page=page) }}" class="uk-button uk-button-primary uk-width-1-1" type="button" id="cancel">Cancel</a>
+ <a href="{{ url_for("wiki.page", page=page) }}" class="uk-button uk-button-secondary uk-width-1-1" type="button" id="cancel">Cancel</a>
</div>
<div class="uk-width-1-2">
- <input class="uk-button uk-button-secondary uk-width-1-1" type="submit" id="move" value="Move" />
+ <input class="uk-button uk-button-primary uk-width-1-1" type="submit" id="move" value="Move" />
</div>
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
diff --git a/templates/wiki/search.html b/templates/wiki/search.html
new file mode 100644
index 00000000..6b15522e
--- /dev/null
+++ b/templates/wiki/search.html
@@ -0,0 +1,23 @@
+{% extends "wiki/base.html" %}
+{% block title %}Wiki | Search{% endblock %}
+{% block og_title %}Wiki | Search{% endblock %}
+{% block og_description %}Search for pages by content{% endblock %}
+{% block content %}
+ <div class="uk-container uk-container-small">
+ <h2 class="uk-title">
+ Search
+ </h2>
+
+ <form uk-grid class="uk-grid-small" action="{{ url_for("wiki.search") }}" method="post">
+ <input type="text" class="uk-width-1-1 uk-input" placeholder="Search Query" id="query" name="query" style="margin-left: 15px;" required>
+ <div class="uk-width-1-4">
+ &nbsp;
+ </div>
+ <div class="uk-width-1-2">
+ <input class="uk-button uk-button-primary uk-width-1-1" type="submit" id="search" value="Search" />
+ </div>
+
+ <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
+ </form>
+ </div>
+{% endblock %} \ No newline at end of file
diff --git a/templates/wiki/search_results.html b/templates/wiki/search_results.html
new file mode 100644
index 00000000..08c303e2
--- /dev/null
+++ b/templates/wiki/search_results.html
@@ -0,0 +1,39 @@
+{% extends "wiki/base.html" %}
+{% block title %}Wiki | Search Results{% endblock %}
+{% block og_title %}Wiki | Search Results{% endblock %}
+{% block og_description %}Search results{% endblock %}
+{% block content %}
+ <div class="uk-container uk-container-small">
+ {% if not pages %}
+ <h2 class="uk-title">
+ Search
+ </h2>
+ <div class="uk-alert uk-alert-warning uk-text-center">
+ <p>
+ Sorry, no results were found. Please check your query and try again.
+ </p>
+ </div>
+ {% else %}
+ <h2 class="uk-title">
+ Search Results
+ </h2>
+
+ {% for page in pages %}
+ <h4>
+ <a href="{{ url_for("wiki.page", page=page["slug"]) }}">{{ page.title }}</a>
+ (<span style="font-family: monospace;">{{ page.slug }}</span>)
+ </h4>
+
+ {% for snippet in page["matches"] %}
+ <div class="quote">
+ <i class="uk-icon far fa-ellipsis-h"></i>
+ <br />
+ {{ snippet | safe }}
+ <br />
+ <i class="uk-icon far fa-ellipsis-h"></i>
+ </div>
+ {% endfor %}
+ {% endfor %}
+ {% endif %}
+ </div>
+{% endblock %} \ No newline at end of file