aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/templates
diff options
context:
space:
mode:
authorGravatar Gareth Coles <[email protected]>2019-04-15 14:56:50 +0100
committerGravatar Gareth Coles <[email protected]>2019-04-15 14:56:50 +0100
commitf27987070e40fcf4b017f91c23c4747373e85c9d (patch)
tree7dac1a67b2709f73add6d8ac7c15ec04c30a2b3a /pydis_site/templates
parentSmall styling fixes (diff)
Images sidebar work, and allow fields to be rendered without labels
Diffstat (limited to 'pydis_site/templates')
-rw-r--r--pydis_site/templates/wiki/forms/fields/boolean.html29
-rw-r--r--pydis_site/templates/wiki/forms/fields/char.html2
-rw-r--r--pydis_site/templates/wiki/forms/fields/image.html26
-rw-r--r--pydis_site/templates/wiki/forms/fields/in_place_render.html26
-rw-r--r--pydis_site/templates/wiki/forms/fields/model_choice.html26
-rw-r--r--pydis_site/templates/wiki/forms/fields/wiki_slug_render.html26
-rw-r--r--pydis_site/templates/wiki/includes/formfield.html2
-rw-r--r--pydis_site/templates/wiki/plugins/images/sidebar.html88
-rw-r--r--pydis_site/templates/wiki/plugins/macros/article_list.html14
-rw-r--r--pydis_site/templates/wiki/plugins/macros/sidebar.html20
10 files changed, 109 insertions, 150 deletions
diff --git a/pydis_site/templates/wiki/forms/fields/boolean.html b/pydis_site/templates/wiki/forms/fields/boolean.html
index 9d054083..9a8470be 100644
--- a/pydis_site/templates/wiki/forms/fields/boolean.html
+++ b/pydis_site/templates/wiki/forms/fields/boolean.html
@@ -1,15 +1,17 @@
<div id="div_{{ field.auto_id }}" class="field is-horizontal{% if field.errors %} is-danger{% endif %}">
- <div class="field-label">
- <label class="label {% if field.errors %} is-danger{% endif %}">
- {{ field.label | safe }} {% if field.field.required %}<span class="asterisk has-text-danger">*</span>{% endif %}
- </label>
+ {% if render_labels %}
+ <div class="field-label">
+ <label class="label {% if field.errors %} is-danger{% endif %}">
+ {{ field.label | safe }} {% if field.field.required %}<span class="asterisk has-text-danger">*</span>{% endif %}
+ </label>
- {% if field.help_text %}
- <p id="hint_{{ field.auto_id }}" class="help has-text-grey">
- {{ field.help_text|safe }}
- </p>
- {% endif %}
- </div>
+ {% if field.help_text %}
+ <p id="hint_{{ field.auto_id }}" class="help has-text-grey">
+ {{ field.help_text|safe }}
+ </p>
+ {% endif %}
+ </div>
+ {% endif %}
<div class="field-body">
<div class="field">
@@ -25,8 +27,13 @@
{% if field.min_length %}minlength="{{ field.min_length }}"{% endif %}
{% if field.empty_value %}placeholder="{{ field.empty_value }}"{% endif %}
/>
+
<label for="{{ field.auto_id }}" class="label {% if field.errors %} is-danger{% endif %}">
- &nbsp;
+ {% if not render_labels %}
+ {{ field.label | safe }} {% if field.field.required %}<span class="asterisk has-text-danger">*</span>{% endif %}
+ {% else %}
+ &nbsp;
+ {% endif %}
</label>
</div>
diff --git a/pydis_site/templates/wiki/forms/fields/char.html b/pydis_site/templates/wiki/forms/fields/char.html
index 4c48d300..83600dae 100644
--- a/pydis_site/templates/wiki/forms/fields/char.html
+++ b/pydis_site/templates/wiki/forms/fields/char.html
@@ -1,5 +1,5 @@
<div id="div_{{ field.auto_id }}" class="field is-horizontal{% if field.errors %} is-danger{% endif %}">
- {% if not is_markitup %}
+ {% if render_labels and not is_markitup %}
<div class="field-label">
{% if field.label %}
<label for="{{ field.auto_id }}" class="label {% if field.errors %} is-danger{% endif %}">
diff --git a/pydis_site/templates/wiki/forms/fields/image.html b/pydis_site/templates/wiki/forms/fields/image.html
index 47e115fe..8591f547 100644
--- a/pydis_site/templates/wiki/forms/fields/image.html
+++ b/pydis_site/templates/wiki/forms/fields/image.html
@@ -1,17 +1,19 @@
<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 %}">
- IN PLACE RENDER: {{ field.label | safe }} {% if field.field.required %}<span class="asterisk has-text-danger">*</span>{% endif %}
- </label>
- {% endif %}
+ {% if render_labels %}
+ <div class="field-label">
+ {% if field.label %}
+ <label for="{{ field.auto_id }}" class="label {% if field.errors %} is-danger{% endif %}">
+ IN PLACE RENDER: {{ 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>
+ {% if field.help_text %}
+ <p id="hint_{{ field.auto_id }}" class="help has-text-grey">
+ {{ field.help_text|safe }}
+ </p>
+ {% endif %}
+ </div>
+ {% endif %}
<div class="field-body">
<div class="field">
diff --git a/pydis_site/templates/wiki/forms/fields/in_place_render.html b/pydis_site/templates/wiki/forms/fields/in_place_render.html
index 47e115fe..8591f547 100644
--- a/pydis_site/templates/wiki/forms/fields/in_place_render.html
+++ b/pydis_site/templates/wiki/forms/fields/in_place_render.html
@@ -1,17 +1,19 @@
<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 %}">
- IN PLACE RENDER: {{ field.label | safe }} {% if field.field.required %}<span class="asterisk has-text-danger">*</span>{% endif %}
- </label>
- {% endif %}
+ {% if render_labels %}
+ <div class="field-label">
+ {% if field.label %}
+ <label for="{{ field.auto_id }}" class="label {% if field.errors %} is-danger{% endif %}">
+ IN PLACE RENDER: {{ 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>
+ {% if field.help_text %}
+ <p id="hint_{{ field.auto_id }}" class="help has-text-grey">
+ {{ field.help_text|safe }}
+ </p>
+ {% endif %}
+ </div>
+ {% endif %}
<div class="field-body">
<div class="field">
diff --git a/pydis_site/templates/wiki/forms/fields/model_choice.html b/pydis_site/templates/wiki/forms/fields/model_choice.html
index c6cd53ab..58c55e04 100644
--- a/pydis_site/templates/wiki/forms/fields/model_choice.html
+++ b/pydis_site/templates/wiki/forms/fields/model_choice.html
@@ -1,19 +1,21 @@
{% 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 render_labels %}
+ <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>
+ {% if field.help_text %}
+ <p id="hint_{{ field.auto_id }}" class="help has-text-grey">
+ {{ field.help_text|safe }}
+ </p>
+ {% endif %}
+ </div>
+ {% endif %}
<div class="field-body">
<div class="field">
diff --git a/pydis_site/templates/wiki/forms/fields/wiki_slug_render.html b/pydis_site/templates/wiki/forms/fields/wiki_slug_render.html
index c87fda7a..ff5c8528 100644
--- a/pydis_site/templates/wiki/forms/fields/wiki_slug_render.html
+++ b/pydis_site/templates/wiki/forms/fields/wiki_slug_render.html
@@ -1,19 +1,21 @@
{% 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 render_labels %}
+ <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>
+ {% if field.help_text %}
+ <p id="hint_{{ field.auto_id }}" class="help has-text-grey">
+ {{ field.help_text|safe }}
+ </p>
+ {% endif %}
+ </div>
+ {% endif %}
<div class="field-body">
<div class="field has-addons">
diff --git a/pydis_site/templates/wiki/includes/formfield.html b/pydis_site/templates/wiki/includes/formfield.html
index c466719b..8c42cfbf 100644
--- a/pydis_site/templates/wiki/includes/formfield.html
+++ b/pydis_site/templates/wiki/includes/formfield.html
@@ -3,5 +3,5 @@
{% if field.is_hidden %}
{{ field }}
{% else %}
- {% render_field field %}
+ {% render_field field render_labels %}
{% endif %}
diff --git a/pydis_site/templates/wiki/plugins/images/sidebar.html b/pydis_site/templates/wiki/plugins/images/sidebar.html
index 909bf6c9..d25fe48e 100644
--- a/pydis_site/templates/wiki/plugins/images/sidebar.html
+++ b/pydis_site/templates/wiki/plugins/images/sidebar.html
@@ -40,6 +40,39 @@ function add_image(form) {
<style type="text/css">
#image-list tr:first-child td {border:0;}
</style>
+
+ <h4>Add image</h4>
+
+ {% if article|images_can_add:user %}
+ {% include "wiki/includes/formerrors.html" %}
+
+ {# Include the hidden fields #}
+ {% for hidden in form.hidden_fields %}
+ {{ hidden }}
+ {% endfor %}
+
+ <p>
+ {% for field in form.visible_fields %}
+ {% include "wiki/includes/formfield.html" with render_labels=False %}
+ {% endfor %}
+
+ <p>
+ <button type="button" onClick="add_image(this.form)" name="{{ plugin.slug }}_save" value="1" class="button is-primary">
+ <span class="icon">
+ <i class="fas fa-upload"></i>
+ </span>
+ <span>Upload</span>
+ </button>
+ </p>
+ {% else %}
+
+ {% if user.is_anonymous %}
+ {% include "wiki/includes/anonymous_blocked.html" %}
+ {% else %}
+ <p><em>{% trans "You do not have permissions to add images." %}</em></p>
+ {% endif %}
+ {% endif %}
+
<div style="max-height: 300px; overflow: auto;">
<table class="table table-responsive table-bordered" id="image-list">
{% for image in images %}
@@ -78,61 +111,6 @@ function add_image(form) {
</p>
<hr />
-<h4>{% trans "Add new image" %}</h4>
-
-{% if article|images_can_add:user %}
- {% if form.non_field_errors %}
- {% if form_error_title %}<h4 class="alert-heading">{{ form_error_title }}</h4>{% endif %}
- {% for error_message in form.non_field_errors %}
- <div class="alert alert-block alert-danger">
- {{ error_message }}
- </div>
- {% endfor %}
- {% endif %}
-
- {# Include the hidden fields #}
- {% for hidden in form.hidden_fields %}
- {{ hidden }}
- {% endfor %}
-
- <p>
- {% for field in form.visible_fields %}
- <fieldset id="div_{{ field.auto_id }}" class="control-group fields {% if field.errors %} error{% endif %}">
- {% if field.label %}
- <!--<label for="{{ field.id_for_label }}" class="{% if field.field.required %}requiredField{% endif %}">
- {{ field.label|safe }}
- </label>-->
- {% endif %}
- {{ field }}
- {% if field.errors %}
- <div id="error_{{ forloop.counter }}_{{ field.auto_id }}" class="help-block">
- {% for error in field.errors %}
- <div>{{ error }}</div>
- {% endfor %}
- </div>
- {% endif %}
- </fieldset>
- {% if field.help_text %}
- <p id="hint_{{ field.auto_id }}" class="help-block">{{ field.help_text|safe }}</p>
- {% endif %}
- {% endfor %}
- </p>
-
- <p>
- <button type="button" onClick="add_image(this.form)" name="{{ plugin.slug }}_save" value="1" class="btn btn-default btn-md">
- <span class="fa fa-upload"></span>
- {% trans "Add image" %}
- </button>
- </p>
-{% else %}
-
- {% if user.is_anonymous %}
- {% include "wiki/includes/anonymous_blocked.html" %}
- {% else %}
- <p><em>{% trans "You do not have permissions to add images." %}</em></p>
- {% endif %}
-{% endif %}
-
<hr />
<h4>
diff --git a/pydis_site/templates/wiki/plugins/macros/article_list.html b/pydis_site/templates/wiki/plugins/macros/article_list.html
deleted file mode 100644
index c9261f1e..00000000
--- a/pydis_site/templates/wiki/plugins/macros/article_list.html
+++ /dev/null
@@ -1,14 +0,0 @@
-{% load i18n wiki_macro_tags %}
-
-{% if article_children %}
- <div class="article-list">
- <ul>
- <li class="nav-header">{% trans "Article index" %} <i class="fa fa-list"></i></li>
- {% for child in article_children %}
- {% article_list child depth %}
- {% empty %}
- <i>{% trans "Nothing below this level" %}</i>
- {% endfor %}
- </ul>
- </div>
-{% endif %}
diff --git a/pydis_site/templates/wiki/plugins/macros/sidebar.html b/pydis_site/templates/wiki/plugins/macros/sidebar.html
deleted file mode 100644
index 31b68520..00000000
--- a/pydis_site/templates/wiki/plugins/macros/sidebar.html
+++ /dev/null
@@ -1,20 +0,0 @@
-{% load i18n wiki_macro_tags %}
-{% allowed_macros as macros %}
-
-{% for macro in macros %}
-<h4>{{ macro.short_description }}</h4>
-{{ macro.help_text|safe|linebreaks }}
-{% if macro.example_code %}
-<pre>{{ macro.example_code }}</pre>
-{% endif %}
-{% if macro.args %}
-<table class="table table-compact">
-{% for arg,description in macro.args.items %}
- <tr>
- <th>{{ arg }}</th>
- <td>{{ description }}</td>
- </tr>
-{% endfor %}
-</table>
-{% endif %}
-{% endfor %}