aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site
diff options
context:
space:
mode:
authorGravatar Gareth Coles <[email protected]>2019-04-15 12:18:49 +0100
committerGravatar Gareth Coles <[email protected]>2019-04-15 12:18:49 +0100
commitb6f6dcd6d9b3246a16a803f094bd1329b6797d20 (patch)
tree79c73c8e77697844d958aa8a6b121f2cc6be41f7 /pydis_site
parentRemove TOC, link headers, fix breadcrumb padding (diff)
Finish creation form, remove weird article title addons
Diffstat (limited to 'pydis_site')
-rw-r--r--pydis_site/apps/home/templatetags/wiki_extra.py9
-rw-r--r--pydis_site/templates/wiki/article.html11
-rw-r--r--pydis_site/templates/wiki/create.html60
-rw-r--r--pydis_site/templates/wiki/forms/fields/wiki_slug_render.html46
4 files changed, 88 insertions, 38 deletions
diff --git a/pydis_site/apps/home/templatetags/wiki_extra.py b/pydis_site/apps/home/templatetags/wiki_extra.py
index ab70eeb4..ae168ae3 100644
--- a/pydis_site/apps/home/templatetags/wiki_extra.py
+++ b/pydis_site/apps/home/templatetags/wiki_extra.py
@@ -8,6 +8,8 @@ from django.template import Template
from django.template.loader import get_template
from django.utils.safestring import mark_safe
from wiki.editors.markitup import MarkItUpWidget
+from wiki.forms import WikiSlugField
+from wiki.models import URLPath
from wiki.plugins.notifications.forms import SettingsModelChoiceField
TEMPLATE_PATH = "wiki/forms/fields/{0}.html"
@@ -45,6 +47,7 @@ TEMPLATES = {
ModelMultipleChoiceField: TEMPLATE_PATH.format("model_multiple_choice"),
SettingsModelChoiceField: TEMPLATE_PATH.format("model_choice"),
+ WikiSlugField: TEMPLATE_PATH.format("wiki_slug_render"),
}
@@ -88,3 +91,9 @@ def get_field_options(context, field: BoundField):
context["options"] = widget.optgroups(field.name, value)
return ""
+
+
+def render_urlpath(value: URLPath):
+ return value.path or "/"
+
diff --git a/pydis_site/templates/wiki/article.html b/pydis_site/templates/wiki/article.html
index 03c007e6..39e1728d 100644
--- a/pydis_site/templates/wiki/article.html
+++ b/pydis_site/templates/wiki/article.html
@@ -16,17 +16,6 @@
<div id="article-container">
<h1 id="article-title">
{{ article.current_revision.title }}
- <small style="font-size: 14px;">
- {% if urlpath.parent %}
- <a href="{% url 'wiki:get' path=urlpath.path %}"><span class="fa fa-bookmark"></span> {{ urlpath.slug }}</a>
- {% endif %}
-
- {% if article.current_revision.locked %}
- <span class="icon">
- <i class="fas fa-lock"></i>
- </span> locked
- {% endif %}
- </small>
</h1>
<div>
{% block wiki_contents_tab %}
diff --git a/pydis_site/templates/wiki/create.html b/pydis_site/templates/wiki/create.html
index 669a5ac4..8a68a1c6 100644
--- a/pydis_site/templates/wiki/create.html
+++ b/pydis_site/templates/wiki/create.html
@@ -7,24 +7,24 @@
{% block wiki_contents %}
{% addtoblock "js" %}
- <script type="text/javascript" src="{% static "admin/js/urlify.js" %}"></script>
- <script type="text/javascript">
- {% if not create_form.slug.value %}
- //<![CDATA[
- (function($) {
- $(document).ready(function (){
- $("#id_title").keyup(function () {
- var e = $("#id_slug")[0];
- if(!e._changed) {
- slug = URLify(this.value, 50);
- e.value = slug;
- }
- });
- });
- })(jQuery);
- //]]>
- {% endif %}
- </script>
+ <script type="text/javascript" src="{% static "admin/js/urlify.js" %}"></script>
+ <script type="text/javascript">
+ {% if not create_form.slug.value %}
+ //<![CDATA[
+ (function($) {
+ $(document).ready(function (){
+ $("#id_title").keyup(function () {
+ var e = $("#id_slug")[0];
+ if(!e._changed) {
+ slug = URLify(this.value, 50);
+ e.value = slug;
+ }
+ });
+ });
+ })(jQuery);
+ //]]>
+ {% endif %}
+ </script>
{% endaddtoblock %}
{% include "wiki/includes/editormedia.html" %}
@@ -32,16 +32,22 @@
<form method="POST" class="form-horizontal">
{% wiki_form create_form %}
- <div class="form-group form-actions">
- <div class="col-lg-2"></div>
- <div class="col-lg-10">
- <a href="{% url 'wiki:get' path=parent_urlpath.path %}" class="btn btn-default">
- <span class="fa fa-arrow-left"></span>
- {% trans "Go back" %}
+
+ <div class="field is-horizontal is-grouped">
+ <div class="control">
+ <a href="{% url 'wiki:get' path=parent_urlpath.path %}" class="button is-white">
+ <span class="icon">
+ <i class="fa fa-arrow-left"></i>
+ </span>
+ <span>Go back</span>
</a>
- <button type="submit" name="save_changes" class="btn btn-primary">
- <span class="fa fa-plus"></span>
- {% trans "Create article" %}
+ </div>
+ <div class="control">
+ <button type="submit" name="save_changes" class="button is-primary">
+ <span class="icon">
+ <i class="fa fa-plus"></i>
+ </span>
+ <span>Create Article</span>
</button>
</div>
</div>
diff --git a/pydis_site/templates/wiki/forms/fields/wiki_slug_render.html b/pydis_site/templates/wiki/forms/fields/wiki_slug_render.html
new file mode 100644
index 00000000..c87fda7a
--- /dev/null
+++ b/pydis_site/templates/wiki/forms/fields/wiki_slug_render.html
@@ -0,0 +1,46 @@
+{% load wiki_extra %}
+
+<div id="div_{{ field.auto_id }}" class="field is-horizontal{% if field.errors %} is-danger{% endif %}">
+ <div class="field-label">
+ {% if field.label %}
+ <label for="{{ field.auto_id }}" class="label {% if field.errors %} is-danger{% endif %}">
+ {{ field.label | safe }} {% if field.field.required %}<span class="asterisk has-text-danger">*</span>{% endif %}
+ </label>
+ {% endif %}
+
+ {% if field.help_text %}
+ <p id="hint_{{ field.auto_id }}" class="help has-text-grey">
+ {{ field.help_text|safe }}
+ </p>
+ {% endif %}
+ </div>
+
+ <div class="field-body">
+ <div class="field has-addons">
+ <div class="control">
+ <a class="button is-static">{{ field.form.urlpath_parent | render_urlpath }}</a>
+ </div>
+ <div class="control is-expanded">
+ <input class="input{% if field.errors %} is-danger{% endif %}"
+ type="text"
+ id="{{ field.auto_id }}"
+ name="{{ field.name }}"
+
+ {% if field.required %}required{% endif %}
+ {% if field.max_length %}maxlength="{{ field.max_length }}"{% endif %}
+ {% if field.min_length %}minlength="{{ field.min_length }}"{% endif %}
+ {% if field.empty_value %}placeholder="{{ field.empty_value }}"{% endif %}
+ {% if field.value %}value="{{ field.value }}"{% endif %}
+ >
+ </div>
+
+ {% if field.errors %}
+ <p class="help is-danger">
+ {% for error in field.errors %}
+ <span id="error_{{ forloop.counter }}_{{ field.auto_id }}">{{ error }}</span><br />
+ {% endfor %}
+ </p>
+ {% endif %}
+ </div>
+ </div>
+</div>