diff options
| author | 2019-04-20 23:49:12 +0200 | |
|---|---|---|
| committer | 2019-04-20 23:49:12 +0200 | |
| commit | 0e373cd953dd7ee8433cd936a8df050ab097bb08 (patch) | |
| tree | 54061f3d1f33247f0a57efc311167ba275c67c94 /pydis_site/templates | |
| parent | Merge pull request #213 from python-discord/django_front_page (diff) | |
| parent | Replace wiki dep with PyDis fork, add git to Docker (diff) | |
Merge pull request #202 from gdude2002/django+200/wiki
[#200] Django Wiki
Diffstat (limited to 'pydis_site/templates')
45 files changed, 2314 insertions, 2 deletions
diff --git a/pydis_site/templates/base/base.html b/pydis_site/templates/base/base.html index 5d5fe7ec..d7e764a2 100644 --- a/pydis_site/templates/base/base.html +++ b/pydis_site/templates/base/base.html @@ -1,5 +1,6 @@  {# Base template, with a few basic style definitions. #}  {% load django_simple_bulma %} +{% load sekizai_tags %}  {% load static %}  <!DOCTYPE html> @@ -23,6 +24,8 @@    <link rel="stylesheet" href="{% static "css/base/base.css" %}">    {% block head %}{% endblock %} + +  {% render_block "css" %}  </head>  <body class="site"> @@ -32,7 +35,10 @@    {% endblock %}  </main> -{% include "base/footer.html" %} +{% block site_footer %} +  {% include "base/footer.html" %} +{% endblock %} +{% render_block "js" %}  </body>  </html> diff --git a/pydis_site/templates/base/navbar.html b/pydis_site/templates/base/navbar.html index 5e76b3a6..bee503ee 100644 --- a/pydis_site/templates/base/navbar.html +++ b/pydis_site/templates/base/navbar.html @@ -1,4 +1,3 @@ -{% load extra_filters %}  {% load static %}  <nav class="navbar is-primary" role="navigation" aria-label="main navigation"> diff --git a/pydis_site/templates/wiki/article.html b/pydis_site/templates/wiki/article.html new file mode 100644 index 00000000..7f2b3af6 --- /dev/null +++ b/pydis_site/templates/wiki/article.html @@ -0,0 +1,24 @@ +{% extends "wiki/base.html" %} +{% load wiki_tags %} + +{% block wiki_pagetitle %}{{ article.current_revision.title }}{% endblock %} + +{% block wiki_navbar %} +  {% include "wiki/includes/article_menu.html" %} +{% endblock %} + +{% block wiki_breadcrumbs %} +  {% include "wiki/includes/breadcrumbs.html" %} +{% endblock %} + +{% block wiki_contents %} +  <div id="article-container"> +    <h1 id="article-title"> +      {{ article.current_revision.title }} +    </h1> +    <div> +      {% block wiki_contents_tab %} +      {% endblock %} +    </div> +  </div> +{% endblock %} diff --git a/pydis_site/templates/wiki/base.html b/pydis_site/templates/wiki/base.html new file mode 100644 index 00000000..192c25f6 --- /dev/null +++ b/pydis_site/templates/wiki/base.html @@ -0,0 +1,46 @@ +{% extends "base/base.html" %} +{% load static %} +{% load wiki_tags %} + +{% block title %} +  Wiki | {% block wiki_pagetitle %}{% endblock %}{% block wiki_site_title %}{% endblock %} +{% endblock %} + +{% block head %} +  {{ block.super }} + +  <script src="{% static "wiki/js/jquery-3.3.1.min.js" %}" type="text/javascript"></script> +  <script src="{% static "wiki/js/core.js" %}" type="text/javascript"></script> +  <script src="{% static "js/wiki/simplemde.min.js" %}" type="text/javascript"></script> + +  <link rel="stylesheet" href="{% static "css/wiki/simplemde.min.css" %}"> +  <link rel="stylesheet" href="{% static "css/wiki/simplemde-fixes.css" %}"> +  <link rel="stylesheet" href="{% static "css/wiki/style.css" %}"> +{% endblock %} + +{% block content %} +  {% block site_navbar %} +    {% include "base/navbar.html" %} +  {% endblock %} + +  {% block wiki_navbar %}{% endblock %} + +  {% block wiki_breadcrumbs %} +    {% include "wiki/includes/breadcrumbs.html" %} +  {% endblock %} + +  {% block wiki_body %} +    <section class="section"> +      <div class="container"> +        {% wiki_messages %} + +        <div class="content"> +          {% block wiki_contents %}{% endblock %} +        </div> +      </div> +    </section> +  {% endblock %} + +  <script src="{% static "js/wiki/dropdown.js" %}" type="text/javascript"></script> +  <script src="{% static "js/wiki/load_editor.js" %}" type="text/javascript"></script> +{% endblock %} diff --git a/pydis_site/templates/wiki/create.html b/pydis_site/templates/wiki/create.html new file mode 100644 index 00000000..3fbba969 --- /dev/null +++ b/pydis_site/templates/wiki/create.html @@ -0,0 +1,42 @@ +{% extends "wiki/base.html" %} +{% load sekizai_tags %} +{% load static %} +{% load wiki_tags %} + +{% block wiki_pagetitle %}Add new article{% endblock %} + +{% block wiki_contents %} +  {% addtoblock "js" %} +    <script type="text/javascript" src="{% static "admin/js/urlify.js" %}"></script> + +    {% if not create_form.slug.value %} +      <script type="text/javascript" src="{% static "js/wiki/create.js" %}"></script> +    {% endif %} +  {% endaddtoblock %} + +  {% include "wiki/includes/editormedia.html" %} +  <h1 class="page-header">Add new article</h1> + +  <form method="POST" class="form-horizontal"> +    {% wiki_form create_form %} + +    <div class="field is-horizontal is-grouped"> +      <div class="control"> +        <a href="{% url 'wiki:get' path=parent_urlpath.path %}" class="button is-light"> +          <span class="icon"> +            <i class="fa fa-arrow-left"></i> +          </span> +          <span>Go back</span> +        </a> +      </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> +  </form> +{% endblock %} diff --git a/pydis_site/templates/wiki/create_root.html b/pydis_site/templates/wiki/create_root.html new file mode 100644 index 00000000..330fea33 --- /dev/null +++ b/pydis_site/templates/wiki/create_root.html @@ -0,0 +1,52 @@ +{% extends "wiki/base.html" %} +{% load static %} +{% load wiki_tags %} + +{% block wiki_pagetitle %}{Create root article{% endblock %} + +{% block head %} +  {{ block.super }} + +  {% for js in editor.Media.js %} +    <script type="text/javascript" src="{% static js %}"></script> +  {% endfor %} + +  {% for media, srcs in editor.Media.css.items %} +    {% for src in srcs %} +      <link rel="stylesheet" media="{{ media }}" href="{% static src %}" /> +    {% endfor %} +  {% endfor %} +{% endblock %} + +{% block wiki_contents %} +  <h2 class="title is-2">Create First Article</h2> + +  <p> +    Please create the root article. This article will be available at the root of your wiki, +    so consider creating a landing page here. +  </p> +  <p> +    Please note that, to begin with, this article may only be modified by wiki administrators. +    Once it's been created, you may edit the permissions and set up plugins, metadata, and so on. +  </p> + +  <form method="POST" class="form-horizontal"> +    {% wiki_form form %} + +    <div class="field is-horizontal"> +      <div class="field-label"> +        {# Empty for spacing #} +      </div> +      <div class="field-body"> +        <div class="control"> +          <button type="submit" class="button is-primary" name="save_changes"> +            <span class="icon"> +              <i class="fas fa-plus"></i> +            </span> +            <span>Create</span> +          </button> +        </div> +      </div> +    </div> +  </form> +{% endblock %} diff --git a/pydis_site/templates/wiki/delete.html b/pydis_site/templates/wiki/delete.html new file mode 100644 index 00000000..bb7a7966 --- /dev/null +++ b/pydis_site/templates/wiki/delete.html @@ -0,0 +1,90 @@ +{% extends "wiki/base.html" %} +{% load static %} +{% load wiki_tags %} + +{% block wiki_pagetitle %}Delete Article{% endblock %} + +{% block wiki_contents %} +  <h1 class="title is-1">Delete "{{ article.current_revision.title }}"</h1> + +  {% if cannot_delete_root %} +    <article class="message is-warning"> +      <div class="message-body"> +        <p> +          You cannot delete the root article. +        </p> + +        <a href="{% url 'wiki:get' path=urlpath.path article_id=article.id %}" class="button is-primary"> +          <span class="icon"> +            <i class="fas fa-arrow-left"></i> +          </span> +          <span>Go back</span> +        </a> +      </div> +    </article> +  {% else %} +    {% if cannot_delete_children %} +      <article class="message is-warning"> +        <div class="message-body"> +          <p> +            You do not have permission to delete articles that have children. +          </p> + +          <a href="{% url 'wiki:get' path=urlpath.path article_id=article.id %}" class="button is-primary"> +            <span class="icon"> +              <i class="fas fa-arrow-left"></i> +            </span> +            <span>Go back</span> +          </a> +        </div> +      </article> +    {% endif %} + +    {% if delete_children %} +      <div class="message is-danger"> +        <div class="message-body"> +          <p> +            You are deleting an article with children. If you delete this article, then its children will also be deleted. +          </p> +          <p> +            If you choose to purge this article, note that its children will also be purged. +          </p> +        </div> +      </div> + +      <h2 class="title is-2">Child articles</h2> + +      <ul> +        {% for child in delete_children %} +          <li><a href="{% url 'wiki:get' article_id=child.article.id %}" target="_blank">{{ child.article }}</a></li> +        {% endfor %} + +        {% if delete_children_more %} +          <li><em>"...and more!"</em></li> +        {% endif %} +      </ul> + +    {% endif %} + +    {% if not cannot_delete_children %} +      <p>Please confirm that you would like to delete this article.</p> + +      <form method="POST"> +        {% wiki_form delete_form %} + +      <a href="{% url 'wiki:get' path=urlpath.path article_id=article.id %}" class="button is-white"> +        <span class="icon"> +          <i class="fas fa-arrow-left"></i> +        </span> +        <span>Go back</span> +      </a> +      <button type="submit" name="save_changes" class="button is-danger"> +        <span class="icon"> +          <i class="fas fa-trash"></i> +        </span> +        <span>Delete Article</span> +      </button> +      </form> +    {% endif %} +  {% endif %} +{% endblock %} diff --git a/pydis_site/templates/wiki/deleted.html b/pydis_site/templates/wiki/deleted.html new file mode 100644 index 00000000..cdde2c47 --- /dev/null +++ b/pydis_site/templates/wiki/deleted.html @@ -0,0 +1,62 @@ +{% extends "wiki/base.html" %} +{% load wiki_tags %} + +{% block wiki_pagetitle %}Article deleted{% endblock %} + +{% block wiki_contents %} +  <article class="message is-warning"> +    <div class="message-header"> +      <p>Article deleted</p> +    </div> +    <div class="message-body"> +      <p> +        The article you were looking for has been deleted. +      </p> +    </div> +  </article> + +  {% if not article.current_revision.locked or article|can_delete:user %} +    <h2 class="title is-2"> +      Restore Article +    </h2> + +    <p> +      To restore this article and any child articles, click the restore button below. +    </p> +    <a href="?restore=1" class="button is-primary"> +      <span class="icon"> +        <i class="fa fa-sync"></i> +      </span> +      <span>Restore</span> +    </a> +  {% endif %} + +  {% if article|can_moderate:user %} +     <h2 class="title is-2"> +      Purge Article +    </h2> + +    <p> +      To permanently remove this article and any child articles, click the purge button below. This will +      allow you to free up the slugs assigned to these articles, so that they may be used for other +      articles. +    </p> +    <p> +      Please note: <span class="has-text-danger">This action cannot be undone</span>. +    </p> + +    <form method="POST" class="form form-inline"> +      {% csrf_token %} +      {% wiki_form purge_form %} +      <button class="button is-danger" type="submit"> +        <span class="icon"> +          <i class="fas fa-trash"></i> +        </span> +        <span> +          Purge +        </span> +      </button> +    </form> +  {% endif %} + +{% endblock %} diff --git a/pydis_site/templates/wiki/deleted_list.html b/pydis_site/templates/wiki/deleted_list.html new file mode 100644 index 00000000..1a8d203c --- /dev/null +++ b/pydis_site/templates/wiki/deleted_list.html @@ -0,0 +1,45 @@ +{% extends "wiki/base.html" %} +{% load wiki_tags %} + +{% block wiki_pagetitle %}Deleted Articles{% endblock %} + +{% block wiki_contents %} +  <h1 class="title is-1">Deleted Articles</h1> + +  {% if deleted_articles %} +    <table class="table table-striped"> +      <thead> +        <tr> +          <th>Page Title</th> +          <th>Date Deleted</th> +          <th>Restore Article</th> +        </tr> +      </thead> + +      <tbody> +        {% for article in deleted_articles %} +          <tr> +            <td> +              <a href="{{article.get_absolute_url}}">{{ article }}</a> +            </td> +            <td> +              {{article.modified}} +            </td> +            <td> +              <a href="{% url 'wiki:deleted' article_id=article.id %}?restore=1" class="button is-primary"> +                <span class="icon"> +                  <i class="fas fa-sync"></i> +                </span> +                <span>Restore</span> +              </a> +            </td> +          </tr> +        {% endfor %} +      </tbody> +    </table> +  {% else %} +    <p> +      No deleted articles to display. +    </p> +  {% endif %} +{% endblock %} diff --git a/pydis_site/templates/wiki/dir.html b/pydis_site/templates/wiki/dir.html new file mode 100644 index 00000000..5a30de7b --- /dev/null +++ b/pydis_site/templates/wiki/dir.html @@ -0,0 +1,103 @@ +{% extends "wiki/article.html" %} +{% load humanize %} +{% load i18n %} +{% load wiki_extra %} +{% load wiki_tags %} + +{% block wiki_pagetitle %}Listing articles in {{ article.current_revision.title }}{% endblock %} + +{% block wiki_contents_tab %} +  {% url 'wiki:dir' urlpath.path as self_url %} + +  <form class="form-search directory-toolbar"> +    <div class="is-pulled-right"> +      {% render_field filter_form.query render_labels=False %} +    </div> + +    <div class="field is-grouped"> +      <div class="field-body"> +        <div class="control"> +          {% if urlpath.parent %} +            <a href="{% url 'wiki:dir' path=urlpath.parent.path %}" class="button"> +              <span class="icon"> +                <i class="fas fa-arrow-up"></i> +              </span> +              <span>Up one level</span> +            </a> +          {% endif %} +        </div> +        <div class="control"> +          <a href="{% url 'wiki:create' path=urlpath.path %}" class="button is-primary"> +            <span class="icon"> +              <i class="fas fa-plus"></i> +            </span> +            <span>Add Article</span> +          </a> +        </div> +      </div> +    </div> +  </form> + +  <br /> + +  <p> +    {% with paginator.object_list.count as cnt %} +      {% blocktrans with urlpath.path as path and cnt|pluralize:_("article,articles") as articles_plur and cnt|pluralize:_("is,are") as articles_plur_verb trimmed %} +        Browsing <strong><a href="{{ self_url }}">/{{ path }}</a></strong>. There {{ articles_plur_verb }} <strong>{{ cnt }} {{ articles_plur }}</strong> in this level. +      {% endblocktrans %} +    {% endwith %} +  </p> + +  {% include "wiki/includes/pagination.html" %} + +  <table class="table is-striped"> +    <tr> +      <th>Title</th> +      <th>Slug</th> +      <th>Last modified</th> +    </tr> + +    {% for urlpath in directory %} +      <tr> +        <td> +          <a href="{% url 'wiki:get' path=urlpath.path %}">{{ urlpath.article.current_revision.title }}</a> + +          <a href="{% url 'wiki:dir' path=urlpath.path %}" class="list-children"> +            <span class="icon"> +              <i class="fas fa-arrow-right"></i> +            </span> +          </a> + +          {% if urlpath.article.current_revision.deleted %} +            <span class="icon tooltip" data-tooltip="This article has been deleted"> +              <i class="fas fa-trash"></i> +            </span> +          {% endif %} + +          {% if urlpath.article.current_revision.locked %} +            <span class="icon tooltip" data-tooltip="This article is locked"> +              <i class="fas fa-lock"></i> +            </span> +          {% endif %} +        </td> + +        <td> +          {{ urlpath.slug }} +        </td> + +        <td> +          {{ urlpath.article.current_revision.created|naturaltime }} +        </td> +      </tr> + +      {% empty %} +      <tr> +        <td colspan="3"> +          <em>There are no articles at this level</em> +        </td> +      </tr> +    {% endfor %} +  </table> + +  {% include "wiki/includes/pagination.html" %} +{% endblock %} diff --git a/pydis_site/templates/wiki/edit.html b/pydis_site/templates/wiki/edit.html new file mode 100644 index 00000000..c378362a --- /dev/null +++ b/pydis_site/templates/wiki/edit.html @@ -0,0 +1,95 @@ +{% extends "wiki/article.html" %} +{% load static %} +{% load wiki_tags %} + +{% block wiki_pagetitle %} +  Edit: {{ article.current_revision.title }} +{% endblock %} + +{% block wiki_contents_tab %} +  <div class="columns"> +    <div class="column is-two-thirds"> +      <form method="POST" class="form-horizontal" id="article_edit_form"> +        {% with edit_form as form %} +          {% include "wiki/includes/editor.html" %} +        {% endwith %} + +        <button class="button is-light" type="submit" name="preview" value="1" id="id_preview" +                formaction="{% url 'wiki:preview' path=urlpath.path article_id=article.id %}" +                formtarget="previewWindow" +        > +          <span class="icon"> +            <i class="fas fa-eye"></i> +          </span> +          <span>Preview</span> +        </button> +        <button class="button is-primary" type="submit" name="save" value="1" id="id_save"> +          <span class="icon"> +            <i class="fas fa-save"></i> +          </span> +          <span>Save Changes</span> +        </button> + +        <div class="is-pulled-right"> +          {% if user.is_authenticated and urlpath.path %} +            <a href="{% url 'wiki:move' path=urlpath.path article_id=article.id %}" class="button is-warning "> +              <span class="icon"> +                <i class="fas fa-random"></i> +              </span> +              <span>Move Article</span> +            </a> +          {% endif %} +          {% if article|can_delete:user %} +            <a href="{% url 'wiki:delete' path=urlpath.path article_id=article.id %}" class="button is-danger"> +              <span class="icon"> +                <i class="fas fa-trash"></i> +              </span> +              <span>Delete Article</span> +            </a> +          {% endif %} +        </div> + +        <br /> +        <br /> +      </form> +    </div> + +    <div class="column is-one-third" id="wiki-edit-sidebar"> +      {% include "wiki/includes/editor_sidebar.html" %} +    </div> +  </div> + +  <div class="modal" id="previewModal"> +    <div class="modal-background"></div> +    <div class="modal-card" style="height: 80%; width: 80%;"> +      <div class="modal-card-head"> +        <p class="modal-card-title">Article Preview</p> +      </div> +      <div class="modal-card-body" style="padding: 0; overflow: hidden;"> +        <iframe name="previewWindow" frameborder="0" style="width: 100%; height: 100%;"></iframe> +      </div> +      <div class="modal-card-foot"> +        <button class="button is-light" aria-label="close"> +          <span class="icon"> +            <i class="fas fa-arrow-left"></i> +          </span> +          <span>Back</span> +        </button> +        <a class="button is-primary" id="id_preview_save_changes"> +          <span class="icon"> +            <i class="fas fa-save"></i> +          </span> +          <span>Save Changes</span> +        </a> +      </div> +    </div> +  </div> + +  <script src="{% static "js/wiki/modal.js" %}" type="text/javascript"></script> +  <script src="{% static "js/wiki/edit.js" %}" type="text/javascript"></script> +  <script type="text/javascript"> +    $(document).ready(function() { +      $("#id_revision").val('{{ article.current_revision.id }}'); +    }); +  </script> +{% endblock %} diff --git a/pydis_site/templates/wiki/error.html b/pydis_site/templates/wiki/error.html new file mode 100644 index 00000000..d7ee70fd --- /dev/null +++ b/pydis_site/templates/wiki/error.html @@ -0,0 +1,51 @@ +{% extends "wiki/base.html" %} +{% load wiki_tags %} + +{% block wiki_pagetitle %}{% if article %}{{ article.current_revision.title }}{% else %}Error{% endif %}{% endblock %} + +{% block wiki_breadcrumbs %} +  {% include "wiki/includes/breadcrumbs.html" %} +{% endblock %} + +{% block wiki_contents %} +  {% if error_type == "ancestors_missing" %} +    <h1 class="title">Not Found</h1> + +    <article class="message is-primary"> +      <div class="message-body"> +        <p> +          We were unable to find that page. If you think this was in error, please let us know! +        </p> +        <a href="{% url 'wiki:get' path='' %}" class="button is-primary"> +          <span class="icon"> +            <i class="fas fa-arrow-left"></i> +          </span> +          <span>Back to homepage</span> +        </a> +      </div> +    </article> +  {% else %} +    <h1 class="title">Error</h1> + +    <article class="message is-danger"> +      <div class="message-body"> +        <p> +          {% if not error_msg %} +            Unfortunately, an error occurred while retrieving that page. Please let us know! +          {% else %} +            {{ error_msg }} +          {% endif %} +        </p> + +        {% if article %} +          <a href="{% url 'wiki:get' path=urlpath.path article_id=article.id %}" class="button is-primary"> +            <span class="icon"> +              <i class="fas fa-arrow-left"></i> +            </span> +            <span>Back to {{ article.current_revision.title }}</span> +          </a> +        {% endif %} +      </div> +    </article> +  {% endif %} +{% endblock %} diff --git a/pydis_site/templates/wiki/forms/fields/boolean.html b/pydis_site/templates/wiki/forms/fields/boolean.html new file mode 100644 index 00000000..9a8470be --- /dev/null +++ b/pydis_site/templates/wiki/forms/fields/boolean.html @@ -0,0 +1,49 @@ +<div id="div_{{ field.auto_id }}" class="field is-horizontal{% if field.errors %} is-danger{% endif %}"> +  {% 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> +  {% endif %} + +  <div class="field-body"> +    <div class="field"> +      <div class="control"> +        <input class="switch is-rounded{% if field.errors %} is-danger{% endif %}" +               type="checkbox" +               id="{{ field.auto_id }}" +               name="{{ field.name }}" +               {% if field.value %}checked="checked"{% endif %} + +               {% 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 %} +        /> + +        <label for="{{ field.auto_id }}" class="label {% if field.errors %} is-danger{% endif %}"> +          {% if not render_labels %} +            {{ field.label | safe }} {% if field.field.required %}<span class="asterisk has-text-danger">*</span>{% endif %} +          {% else %} +              +          {% endif %} +        </label> +      </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> diff --git a/pydis_site/templates/wiki/forms/fields/char.html b/pydis_site/templates/wiki/forms/fields/char.html new file mode 100644 index 00000000..06e9f1b7 --- /dev/null +++ b/pydis_site/templates/wiki/forms/fields/char.html @@ -0,0 +1,57 @@ +<div id="div_{{ field.auto_id }}" class="field is-horizontal{% if field.errors %} is-danger{% endif %}"> +  {% 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 %}"> +          {{ 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> +  {% endif %} + +  <div class="field-body"{% if is_markitup %} style="display: block; width: 100%;"{% endif %}> +    <div class="field"> +      <div class="control"> +        {% if is_markitup %} +          <textarea class="simple-mde textarea is-family-monospace{% if field.errors %} is-danger{% endif %}" +                    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.field.widget.attrs.placeholder %}placeholder="{{ field.field.widget.attrs.placeholderplaceholder }}"{% endif %} +                    {% if field.empty_value %}placeholder="{{ field.empty_value }}"{% endif %} +          >{% if field.value %}{{ field.value }}{% endif %}</textarea> +        {% else %} +          <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.field.widget.attrs.placeholder %}placeholder="{{ field.field.widget.attrs.placeholder }}"{% endif %} +                 {% if field.empty_value %}placeholder="{{ field.empty_value }}"{% endif %} +                 {% if field.value %}value="{{ field.value }}"{% endif %} +          /> +        {% 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> diff --git a/pydis_site/templates/wiki/forms/fields/image.html b/pydis_site/templates/wiki/forms/fields/image.html new file mode 100644 index 00000000..ce5402be --- /dev/null +++ b/pydis_site/templates/wiki/forms/fields/image.html @@ -0,0 +1,53 @@ +<div id="div_{{ field.auto_id }}" class="field is-horizontal{% if field.errors %} is-danger{% 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> +  {% endif %} + +  <div class="field-body"> +    <div class="field"> +      <div class="control"> +        <div class="file has-name is-fullwidth"> +          <label class="file-label"> +            <input class="file-input" +                   type="file" +                   id="{{ field.auto_id }}" +                   name="{{ field.name }}" +                   accept="image/*" + +                   {% if field.required %}required{% endif %} +            /> +          <span class="file-cta"> +            <span class="file-icon"> +              <i class="fas fa-image"></i> +            </span> +            <span class="file-label"> +              Choose +            </span> +          </span> +          <span class="file-name"></span> +          </label> +        </div> +      </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> diff --git a/pydis_site/templates/wiki/forms/fields/in_place_render.html b/pydis_site/templates/wiki/forms/fields/in_place_render.html new file mode 100644 index 00000000..8591f547 --- /dev/null +++ b/pydis_site/templates/wiki/forms/fields/in_place_render.html @@ -0,0 +1,33 @@ +<div id="div_{{ field.auto_id }}" class="field is-horizontal{% if field.errors %} is-danger{% 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> +  {% endif %} + +  <div class="field-body"> +    <div class="field"> +      <div class="control"> +        {{ field }} +      </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> diff --git a/pydis_site/templates/wiki/forms/fields/model_choice.html b/pydis_site/templates/wiki/forms/fields/model_choice.html new file mode 100644 index 00000000..58c55e04 --- /dev/null +++ b/pydis_site/templates/wiki/forms/fields/model_choice.html @@ -0,0 +1,71 @@ +{% load wiki_extra %} + +<div id="div_{{ field.auto_id }}" class="field is-horizontal{% if field.errors %} is-danger{% 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> +  {% endif %} + +  <div class="field-body"> +    <div class="field"> +      <div class="control"> +        <div class="select"> +          {% get_field_options field %} + +          <select {% if not options %}disabled{% endif %} +                  id="{{ field.auto_id }}" +                  name="{{ field.name }}" + +                  {% if field.required %}required{% endif %} +          > +            {% if options %} +              {% for group_name, group_choices, group_index in options %} +                {% if group_name %} +                  <optgroup label="{{ group_name }}"> +                {% endif %} +                {% for option in group_choices %} +                  <option {% if option.value == field.value %}selected{% endif %} +                          value="{{ option.value|stringformat:'s' }}" +                  > +                    {{ option.label }} +                  </option> +                {% endfor %} +                {% if group_name %} +                  </optgroup> +                {% endif %} +              {% endfor %} +            {% else %} +              <option value=""> +                {% if field.field.empty_label %} +                  {{ field.field.empty_label }} +                {% else %} +                  N/A +                {% endif %} +                </option> +            {% endif %} +          </select> +        </div> + +      </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> 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..ff5c8528 --- /dev/null +++ b/pydis_site/templates/wiki/forms/fields/wiki_slug_render.html @@ -0,0 +1,48 @@ +{% load wiki_extra %} + +<div id="div_{{ field.auto_id }}" class="field is-horizontal{% if field.errors %} is-danger{% 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> +  {% endif %} + +  <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> diff --git a/pydis_site/templates/wiki/history.html b/pydis_site/templates/wiki/history.html new file mode 100644 index 00000000..3788385f --- /dev/null +++ b/pydis_site/templates/wiki/history.html @@ -0,0 +1,128 @@ +{% extends "wiki/article.html" %} +{% load sekizai_tags %} +{% load static %} +{% load wiki_tags %} + +{% block wiki_pagetitle %}History: {{ article.current_revision.title }}{% endblock %} + +{% block wiki_contents_tab %} +  {% include "wiki/includes/modals.html" %} + +  {% addtoblock "js" %} +    <script type="text/javascript" src="{% static "wiki/js/diffview.js" %}"></script> +    <script type="text/javascript" src="{% static "wiki/js/diff.js" %}"></script> +  {% endaddtoblock %} + +  <p> +    Click each revision to see a list of edited lines. Click the Preview +    button to see how the article looked at this stage. At the bottom of +    this page, you can change to a particular revision or merge an old +    revision with the current one. +  </p> + +  {% include "wiki/includes/pagination.html" %} + +  <form method="GET" id="historyForm"> +    <table class="table is-striped"> +      <thead> +        <tr> +          <th>Updated</th> +          <th>Summary</th> +          <th class="has-text-right">Actions</th> +        </tr> +      </thead> +      <tbody> +        {% for revision in revisions %} +          <tr {% if revision == article.current_revision %}class="is-selected"{% endif %}> +            <td> +              {% include "wiki/includes/revision_info.html" with current_revision=article.current_revision %} +            </td> +            <td> +              {% if revision.user_message %} +                {{ revision.user_message }} +              {% elif revision.automatic_log %} +                {{ revision.automatic_log }} +              {% else %} +                <em>No summary</em> +              {% endif %} +            </td> +            <td class="has-text-right"> +              {% if revision == article.current_revision %} +                <a class="button is-static has-text-grey"> +                  <span class="icon"> +                    <i class="fas fa-eye"></i> +                  </span> +                  <span>Preview</span> +                </a> +                <a class="button is-static has-text-grey"> +                  <span class="icon"> +                    <i class="fas fa-sync"></i> +                  </span> +                  <span>Switch</span> +                </a> +              {% else %} +                <button type="submit" class="button" onclick="showPreviewModal('{{ revision.id }}', '{% url 'wiki:preview_revision' article.id %}', '{% url 'wiki:change_revision' path=urlpath.path article_id=article.id revision_id=revision.id %}'); event.preventDefault();"> +                  <span class="icon"> +                    <i class="fas fa-eye"></i> +                  </span> +                  <span>Preview</span> +                </button> +                <a class="button is-primary" href="{% url 'wiki:change_revision' path=urlpath.path article_id=article.id revision_id=revision.id %}"> +                  <span class="icon"> +                    <i class="fas fa-sync"></i> +                  </span> +                  <span>Switch</span> +                </a> +              {% endif %} +            </td> +          </tr> +        {% endfor %} +      </tbody> +    </table> + +    {% include "wiki/includes/pagination.html" %} + +    <input type="hidden" name="r" value="" id="r" /> + +    <div class="modal" id="previewModal"> +      <div class="modal-background"></div> +      <div class="modal-card" style="height: 80%; width: 80%;"> +        <div class="modal-card-head"> +          <p class="modal-card-title">Revision Preview</p> +        </div> +        <div class="modal-card-body" style="padding: 0; overflow: hidden;"> +          <iframe name="previewWindow" id="previewWindow" frameborder="0" style="width: 100%; height: 100%;"></iframe> +        </div> +        <div class="modal-card-foot"> +          <button class="button is-light" aria-label="close"> +            <span class="icon"> +              <i class="fas fa-arrow-left"></i> +            </span> +            <span>Back</span> +          </button> + +          {% if article|can_write:user %} +            <a href="#" class="button is-primary switch-to-revision"> +              <span class="icon"> +                <i class="fas fa-sync"></i> +              </span> +              <span>Switch to this version</span> +            </a> +          {% else %} +            <a class="button is-static"> +              <span class="icon"> +                <i class="fas fa-check"></i> +              </span> +              <span>Switch to this version</span> +            </a> +          {% endif %} +        </div> +      </div> +    </div> +  </form> + +  <script src="{% static "js/wiki/modal.js" %}" type="text/javascript"></script> +  <script src="{% static "js/wiki/history.js" %}" type="text/javascript"></script> +{% endblock %} + + diff --git a/pydis_site/templates/wiki/includes/article_menu.html b/pydis_site/templates/wiki/includes/article_menu.html new file mode 100644 index 00000000..966e8120 --- /dev/null +++ b/pydis_site/templates/wiki/includes/article_menu.html @@ -0,0 +1,78 @@ +{% load wiki_tags %} + +{% if article|can_write:user %} +  {% with selected_tab as selected %} +    <nav class="navbar is-light" role="navigation" aria-label="wiki navigation" id="wikiNavbar"> +      <div class="container"> +        <div class="navbar-brand"> +          {% if not user.is_anonymous %} +            <a class="navbar-item{% if selected == "settings" %} is-active{% endif %}" +               href="{% url 'wiki:settings' article_id=article.id path=urlpath.path %}" +            > +              <span class="icon"> +                <i class="fas fa-wrench"></i> +              </span> + +              <span class="is-hidden-mobile"> Settings</span> +            </a> +          {% endif %} + +          {% for plugin in article_tabs %} +            <a class="navbar-item{% if selected == plugin.slug %} is-active{% endif %}" +               href="{% url 'wiki:plugin' slug=plugin.slug article_id=article.id path=urlpath.path %}" +            > +              <span class="icon"> +                <i class="{{ plugin.article_tab.1 }}"></i> +              </span> + +              <span class="is-hidden-mobile"> {{ plugin.article_tab.0 }}</span> +            </a> +          {% endfor %} + +          <a class="navbar-item{% if selected == "history" %} is-active{% endif %}" +             href="{% url 'wiki:history' article_id=article.id path=urlpath.path %}" +          > +            <span class="icon"> +              <i class="fas fa-clock"></i> +            </span> + +            <span class="is-hidden-mobile"> Changes</span> +          </a> + +          {% if article|can_write:user and not article.current_revision.locked %} +            <a class="navbar-item{% if selected == "edit" %} is-active{% endif %}" +               href="{% url 'wiki:edit' article_id=article.id path=urlpath.path %}" +            > +              <span class="icon"> +                <i class="fas fa-edit"></i> +              </span> + +              <span class="is-hidden-mobile"> Edit</span> +            </a> +          {% else %} +            <a class="navbar-item{% if selected == "source" %} is-active{% endif %}" +               href="{% url 'wiki:source' article_id=article.id path=urlpath.path %}" +            > +              <span class="icon"> +                <i class="fas fa-book-spells"></i> +              </span> + +              <span class="is-hidden-mobile"> View Source</span> +            </a> +          {% endif %} + +          <a class="navbar-item{% if selected == "view" %} is-active{% endif %}" +             href="{% url 'wiki:get' article_id=article.id path=urlpath.path %}" +          > +            <span class="icon"> +              <i class="fas fa-book-open"></i> +            </span> + +            <span class="is-hidden-mobile"> View</span> +          </a> +        </div> + +      </div> +    </nav> +  {% endwith %} +{% endif %} diff --git a/pydis_site/templates/wiki/includes/breadcrumbs.html b/pydis_site/templates/wiki/includes/breadcrumbs.html new file mode 100644 index 00000000..a2359f39 --- /dev/null +++ b/pydis_site/templates/wiki/includes/breadcrumbs.html @@ -0,0 +1,87 @@ +{% if urlpath and article and not user.is_anonymous %} +  <section class="breadcrumb-section section"> +    <div class="container"> +      <nav class="breadcrumb is-pulled-left" aria-label="breadcrumbs"> +        <ul> +          {% for ancestor in urlpath.cached_ancestors %} +            <li> +              <a href="{% url 'wiki:get' path=ancestor.path %}">{{ ancestor.article.current_revision.title|truncatechars:25 }}</a> +            </li> +          {% endfor %} + +          <li class="is-active"> +            <a href="{% url 'wiki:get' path=article.path %}">{{ article.current_revision.title|truncatechars:25 }}</a> +          </li> +        </ul> +      </nav> + +      <div class="dropdown is-pulled-right is-right"> +        <div class="dropdown-trigger"> +          <a aria-haspopup="true" aria-controls="sub-article-dropdown"> +            <span>Sub-Articles</span> +            <span class="icon"> +              <i class="fas fa-angle-down"></i> +            </span> +          </a> +        </div> +        <div class="dropdown-menu" id="sub-article-dropdown" role="menu"> +          <div class="dropdown-content"> +            {% if children_slice %} +              {% for child in children_slice %} +                <a class="dropdown-item" href="{% url 'wiki:get' path=child.path %}"> +                  {{ child.article.current_revision.title }} +                </a> +              {% endfor %} + +              {% if children_slice_more %} +                <a class="dropdown-item" href="{% url 'wiki:dir' path=urlpath.path %}"> +                  ...and more. +                </a> +              {% endif %} + +              <hr class="dropdown-divider"> +            {% endif %} + +            <a class="dropdown-item" href="{% url 'wiki:dir' path=urlpath.path %}"> +              Browse other articles +            </a> +          </div> +        </div> +      </div> + +      {% if request.user.is_authenticated %} +        <div class="dropdown is-pulled-right is-right"> +          <div class="dropdown-trigger"> +            <a aria-haspopup="true" aria-controls="sub-article-dropdown"> +              <span>Create Article</span> +              <span class="icon"> +                <i class="fas fa-angle-down"></i> +              </span> +                +            </a> +          </div> +          <div class="dropdown-menu" id="sub-article-dropdown" role="menu"> +            <div class="dropdown-content"> +              {% if urlpath.parent %} +                <a class="dropdown-item" href="{% url 'wiki:create' path=urlpath.parent.path %}"> +                  <span class="icon"> +                    <i class="fas fa-arrow-right"></i> +                  </span> +                  <span>At current level</span> +                </a> +              {% endif %} + +              <a class="dropdown-item" href="{% url 'wiki:create' path=urlpath.path %}"> +                <span class="icon"> +                  <i class="fas fa-arrow-down"></i> +                </span> +                <span>Below current level</span> +              </a> +            </div> +          </div> +        </div> +      {% endif %} + +    </div> +  </section> +{% endif %} diff --git a/pydis_site/templates/wiki/includes/editor.html b/pydis_site/templates/wiki/includes/editor.html new file mode 100644 index 00000000..6eb6cd45 --- /dev/null +++ b/pydis_site/templates/wiki/includes/editor.html @@ -0,0 +1,4 @@ +{% load wiki_tags %} +{% include "wiki/includes/editormedia.html" %} + +{% wiki_form form %} diff --git a/pydis_site/templates/wiki/includes/editor_sidebar.html b/pydis_site/templates/wiki/includes/editor_sidebar.html new file mode 100644 index 00000000..45ac87a1 --- /dev/null +++ b/pydis_site/templates/wiki/includes/editor_sidebar.html @@ -0,0 +1,38 @@ +{% load static %} + +<section class="accordions"> +  {% for plugin, plugin_form in sidebar %} +    <article class="accordion is-primary"> +      <div class="accordion-header toggle"> +        <p> +          {% if plugin.sidebar.icon_class %} +            <span class="icon"> +              {% if plugin.sidebar.icon_class == "fa-picture-o" %} +                <i class="fas fa-images"></i> +              {% else %} +                <i class="fas {{ plugin.sidebar.icon_class }}"></i> +              {% endif %} +            </span> +          {% endif %} + +          {{ plugin.sidebar.headline }} +        </p> + +      </div> +      <div class="accordion-body"> +        <div class="accordion-content"> +          {% if plugin.sidebar.template %} +            {% with plugin_form as form %} +              <form method="POST" class="form-horizontal sidebar-form" action="?f={{ plugin_form.form_id }}" enctype="multipart/form-data"> +                {% csrf_token %} +                {% include plugin.sidebar.template %} +              </form> +            {% endwith %} +          {% endif %} +        </div> +      </div> +    </article> +  {% endfor %} +</section> + +<script type="application/javascript" src="{% static "js/wiki/editor_sidebar.js" %}"></script> diff --git a/pydis_site/templates/wiki/includes/editormedia.html b/pydis_site/templates/wiki/includes/editormedia.html new file mode 100644 index 00000000..c10fbef8 --- /dev/null +++ b/pydis_site/templates/wiki/includes/editormedia.html @@ -0,0 +1,17 @@ +{% load sekizai_tags %} +{% load static %} + +{% addtoblock "js" %} +  <script type="text/javascript" src="{% static "wiki/js/editor.js" %}"></script> +  {% for js in editor.Media.js %} +    <script type="text/javascript" src="{% static js %}"></script> +  {% endfor %} +{% endaddtoblock %} + +{% addtoblock "css" %} +  {% for media, srcs in editor.Media.css.items %} +    {% for src in srcs %} +      <link rel="stylesheet" media="{{ media }}" href="{% static src %}" /> +    {% endfor %} +  {% endfor %} +{% endaddtoblock %} diff --git a/pydis_site/templates/wiki/includes/form.html b/pydis_site/templates/wiki/includes/form.html new file mode 100644 index 00000000..4ea08de4 --- /dev/null +++ b/pydis_site/templates/wiki/includes/form.html @@ -0,0 +1,16 @@ +{% load sekizai_tags %} +{% csrf_token %} + +{% include "wiki/includes/formerrors.html" %} + +{% addtoblock "js" %} +  {{ form.media.js }} +{% endaddtoblock %} + +{% addtoblock "css" %} +  {{ form.media.css }} +{% endaddtoblock %} + +{% for field in form %} +  {% include "wiki/includes/formfield.html" %} +{% endfor %} diff --git a/pydis_site/templates/wiki/includes/formerrors.html b/pydis_site/templates/wiki/includes/formerrors.html new file mode 100644 index 00000000..c6df2637 --- /dev/null +++ b/pydis_site/templates/wiki/includes/formerrors.html @@ -0,0 +1,15 @@ +{% if form.non_field_errors %} +  <article class="message is-danger"> +    {% if form_error_title %} +      <div class="message-header"> +        <p>{{ form_error_title }}</p> +      </div> +    {% endif %} + +    <div class="message-body"> +      {% for error_message in form.non_field_errors %} +        <p>{{ error_message }}</p> +      {% endfor %} +    </div> +  </article> +{% endif %} diff --git a/pydis_site/templates/wiki/includes/formfield.html b/pydis_site/templates/wiki/includes/formfield.html new file mode 100644 index 00000000..8c42cfbf --- /dev/null +++ b/pydis_site/templates/wiki/includes/formfield.html @@ -0,0 +1,7 @@ +{% load wiki_extra %} + +{% if field.is_hidden %} +  {{ field }} +{% else %} +  {% render_field field render_labels %} +{% endif %} diff --git a/pydis_site/templates/wiki/includes/messages.html b/pydis_site/templates/wiki/includes/messages.html new file mode 100644 index 00000000..cdf58d87 --- /dev/null +++ b/pydis_site/templates/wiki/includes/messages.html @@ -0,0 +1,11 @@ +{% if messages %} +  <!-- Messages for this instance --> +  {% for message in messages %} +    <article class="message {{ message.css_class }}"> +      <div class="message-body"> +        {{ message }} +      </div> +    </article> + +  {% endfor %} +{% endif %} diff --git a/pydis_site/templates/wiki/includes/pagination.html b/pydis_site/templates/wiki/includes/pagination.html new file mode 100644 index 00000000..35dac538 --- /dev/null +++ b/pydis_site/templates/wiki/includes/pagination.html @@ -0,0 +1,27 @@ +{% load i18n %} + +{% if is_paginated %} +  <nav class="pagination" role="navigation" aria-label="pagination"> +    {% if page_obj.has_previous %} +        <a class="pagination-previous" href="?{% if search_query %}q={{ search_query  }}&{% endif %}page={{ page_obj.previous_page_number }}{% if appended_key %}&{{ appended_key }}={{ appended_value }}{% endif %}">Previous</a> +    {% else %} +        <a class="pagination-previous tooltip" data-tooltip="This is the first page" disabled>Previous</a> +    {% endif %} + +    {% if page_obj.has_next %} +        <a class="pagination-next" href="?{% if search_query %}q={{ search_query  }}&{% endif %}page={{ page_obj.next_page_number }}{% if appended_key %}&{{ appended_key }}={{ appended_value }}{% endif %}">Next</a> +    {% else %} +        <a class="pagination-next tooltip" data-tooltip="This is the last page" disabled>Older</a> +    {% endif %} + +    <ul class="pagination-list"> +      {% for pc in paginator.page_range %} +        {% if pc == 0 %} +          <li><span class="pagination-ellipsis">…</span></li> +        {% else %} +          <li><a class="pagination-link{% if pc == page_obj.number %} is-current{% endif %}" href="?{% if search_query %}q={{ search_query  }}&{% endif %}page={{ pc }}{% if appended_key %}&{{ appended_key }}={{ appended_value }}{% endif %}">{{ pc }}</a></li> +        {% endif %} +    {% endfor %} +    </ul> +  </nav> +{% endif %} diff --git a/pydis_site/templates/wiki/includes/render.html b/pydis_site/templates/wiki/includes/render.html new file mode 100644 index 00000000..c0334d98 --- /dev/null +++ b/pydis_site/templates/wiki/includes/render.html @@ -0,0 +1,28 @@ +{% load sekizai_tags %} +{% load static %} + +{% addtoblock "js" %} +  <script type="text/javascript" src="{% static "wiki/js/article.js" %}"></script> +{% endaddtoblock %} + +<div class="wiki-article"> +  {{ content|default:"" }} +</div> + +{% for plugin in plugins %} +  {% if plugin.RenderMedia.css %} +    {% addtoblock "css" %} +      {% for media, url in plugin.RenderMedia.css.items %} +        <link rel="stylesheet" href="{% static url %}" /> +      {% endfor %} +    {% endaddtoblock %} +  {% endif %} + +  {% if plugin.RenderMedia.js %} +    {% addtoblock "js" %} +      {% for url in plugin.RenderMedia.js %} +        <script type="text/javascript" src="{% static url %}"></script> +      {% endfor %} +    {% endaddtoblock %} +  {% endif %} +{% endfor %} diff --git a/pydis_site/templates/wiki/includes/revision_info.html b/pydis_site/templates/wiki/includes/revision_info.html new file mode 100644 index 00000000..f2964034 --- /dev/null +++ b/pydis_site/templates/wiki/includes/revision_info.html @@ -0,0 +1,24 @@ +{% comment %} +  This reusable code is shared between different templates and different inheritors of +  BaseRevision. +{% endcomment %} + +{% load wiki_tags %} + +{% if not hidedate %}{{ revision.created }}{% endif %} {% if not hidenumber %}(#{{ revision.revision_number }}) by{% endif %} {% if revision.user %}{{ revision.user }}{% else %}{% if article|can_moderate:user %}{{ revision.ip_address|default:"anonymous (IP not logged)" }}{% else %}anonymous (IP logged){% endif %}{% endif %} + +{% if revision.deleted %} +  <span class="tag is-danger">deleted</span> +{% endif %} + +{% if revision.previous_revision.deleted and not revision.deleted %} +  <span class="tag is-success">restored</span> +{% endif %} + +{% if revision.locked %} +  <span class="tag is-danger">locked</span> +{% endif %} + +{% if revision.previous_revision.locked and not revision.locked %} +  <span class="tag is-success">unlocked</span> +{% endif %} diff --git a/pydis_site/templates/wiki/includes/searchresult.html b/pydis_site/templates/wiki/includes/searchresult.html new file mode 100644 index 00000000..897ee4a6 --- /dev/null +++ b/pydis_site/templates/wiki/includes/searchresult.html @@ -0,0 +1,33 @@ +{% load humanize %} + +<tr> +  <td> +    {% for urlpath in article.urlpath_set.all %} +      <a href="{% url 'wiki:get' path=urlpath.path %}"> +        {{ article.current_revision.title }} +        <br /> +        <small class="has-text-grey">Slug: /{{ urlpath.path }}</small> +      </a> +    {% empty %} +      <a href="{% url 'wiki:get' article_id=article.id %}"> +        {{ article.current_revision.title }} +      </a> +    {% endfor %} + +    {% if article.current_revision.deleted %} +      <span class="icon"> +        <i class="fas fa-trash"></i> +      </span> +    {% endif %} + +    {% if article.current_revision.locked %} +      <span class="icon"> +        <i class="fas fa-lock"></i> +      </span> +    {% endif %} +  </td> + +  <td class="has-text-right"> +    {{ article.current_revision.created|naturaltime }} +  </td> +</tr> diff --git a/pydis_site/templates/wiki/move.html b/pydis_site/templates/wiki/move.html new file mode 100644 index 00000000..a3f7a5d8 --- /dev/null +++ b/pydis_site/templates/wiki/move.html @@ -0,0 +1,72 @@ +{% extends "wiki/article.html" %} +{% load i18n %} +{% load sekizai_tags %} +{% load static %} +{% load wiki_tags %} + +{% block wiki_pagetitle %}Move: {{ article.current_revision.title }}{% endblock %} + +{% block wiki_contents_tab %} +  <article class="message is-warning"> +    <div class="message-body"> +      {% if urlpath.get_descendants %} +        {% blocktrans count cnt=urlpath.get_descendants.count trimmed %} +          <p> +            Please note that this article has {{ cnt }} child article. If you +            decide to move this article, then links to any child articles will +            not be updated. +          </p> +          {% plural %} +          <p> +            Please note that this article has {{ cnt }} child articles. If you +            decide to move this article, then links to any child articles will +            not be updated. +          </p> +        {% endblocktrans %} +      {% endif %} +      <p> +        Remember: Any links to this article will not be automatically updated. You +        may leave behind a redirect page by specifying that option below, but these +        are temporary - so it's better to update the links directly. +      </p> +    </div> +  </article> + +  <form method="POST" class="form-horizontal" id="article_move_form"> +    {% wiki_form form %} + +    {# Not gonna lie, I have no idea what this is or what it's for #} +    <div class="btn-group" id="dest_selector"> +      <a class="btn btn-default dropdown-toggle" data-toggle="dropdown" href="#"> +        <span class="dest_selector_title"></span> +        <span class="caret"></span> +      </a> + +      <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel"> +          {% with current_path=root_path %}{% include "wiki/includes/move_tree.html" %}{% endwith %} +      </ul> +    </div> + +    <a href="{% url 'wiki:get' path=urlpath.path article_id=article.id %}" class="button is-white"> +      <span class="icon"> +        <i class="fas fa-arrow-left"></i> +      </span> +      <span>Go back</span> +    </a> + +    <button class="button is-warning" type="submit" name="move" id="id_move"> +      <span class="icon"> +        <i class="fas fa-random"></i> +      </span> +      <span>Move article</span> +    </button> +  </form> + +  {% addtoblock "js" %} +    <script type="text/javascript" src="{% static "js/wiki/move.js" %}"></script> +    <script type="text/javascript"> +      $('#id_slug').val('{{ urlpath.slug }}'); +      select_path('{{urlpath.parent.pk}}', '{{urlpath.parent}}'); +    </script> +  {% endaddtoblock %} +{% endblock %} diff --git a/pydis_site/templates/wiki/permission_denied.html b/pydis_site/templates/wiki/permission_denied.html new file mode 100644 index 00000000..58394c8f --- /dev/null +++ b/pydis_site/templates/wiki/permission_denied.html @@ -0,0 +1,36 @@ +{% extends "wiki/base.html" %} +{% load wiki_tags %} + +{% block wiki_pagetitle %}Permission Denied{% endblock %} + +{% block wiki_contents %} +  <article class="message is-danger"> +    <div class="message-header"> +      <p>Permission Denied</p> +    </div> + +    <div class="message-body"> +      <p> +        Sorry, you don't have permission to access this page. +      </p> +      {% if article.current_revision.locked %} +        <p>This article is locked for editing.</p> +      {% endif %} +      {% if not read_denied %} +        <a href="{% url 'wiki:get' article_id=article.id path=urlpath.path %}" class="button is-primary"> +          <span class="icon"> +            <i class="fas fa-arrow-left"></i> +          </span> +          <span>Back to article</span> +        </a> +      {% elif urlpath.parent %} +        <a href="{% url 'wiki:get' path=urlpath.parent.path %}" class="button is-primary"> +          <span class="icon"> +            <i class="fas fa-arrow-left"></i> +          </span> +          <span>Back to article</span> +        </a> +      {% endif %} +    </div> +  </article> +{% endblock %} diff --git a/pydis_site/templates/wiki/plugins/images/index.html b/pydis_site/templates/wiki/plugins/images/index.html new file mode 100644 index 00000000..a76703aa --- /dev/null +++ b/pydis_site/templates/wiki/plugins/images/index.html @@ -0,0 +1,171 @@ +{% extends "wiki/article.html" %} +{% load humanize %} +{% load wiki_tags %} +{% load wiki_thumbnails %} + +{# TODO: This page needs re-styling, but it's functional for now so we're not touching it until after wiki completion #} + +{% block wiki_pagetitle %}Images: {{ article.current_revision.title }}{% endblock %} + +{% block wiki_contents_tab %} +  <p>The following images are available for this article. Copy the markdown tag to directly refer to an image from the article text.</p> + +  <p> +    <a href="{% url 'wiki:edit' path=urlpath.path article_id=article.id %}" class="button is-white"> +      <span class="icon"> +        <i class="fas fa-arrow-left"></i> +      </span> +      <span>Back to edit page</span> +    </a> +  </p> + +  {% include "wiki/includes/pagination.html" %} + +  <table class="table is-fullwidth"> +    {% for image in images %} +      {% with image.current_revision.imagerevision as revision %} +        <thead> +          <tr> +            <th>{{ revision.get_filename|default:_("No filename") }}</th> +            <th>Tag</th> +            <th colspan="3">Updated</th> +            <th>Size</th> +          </tr> +        </thead> + +        <tbody> +          <tr> +            <td rowspan="3"> +              <figure class="image is-128x128"> +                {% thumbnail revision.image "128x128" as thumb %} +                  <a href="{{ revision.image.url }}"> +                    <img src="{{ thumb.url }}" alt="{{ revision.get_filename }}" title="{{ revision.get_filename }}" /> +                  </a> +                {% endthumbnail %} +              </figure> + +              {% if image|can_write:user %} +                {% if revision.deleted %} +                  <a class="button is-success" title="Upload and publish new image" href="{% url 'wiki:images_add_revision' path=urlpath.path article_id=article.id image_id=image.id %}"> +                    <span class="icon"> +                      <i class="fas fa-upload"></i> +                    </span> +                    <span>Upload</span> +                  </a> +                  <a class="button is-primary" title="Restore deleted image" href="{% url 'wiki:images_restore' path=urlpath.path article_id=article.id image_id=image.id %}"> +                    <span class="icon"> +                      <i class="fas fa-sync"></i> +                    </span> +                    <span>Restore</span> +                  </a> +                {% else %} +                  <a class="button is-success" title="Upload replacement image" href="{% url 'wiki:images_add_revision' path=urlpath.path article_id=article.id image_id=image.id %}"> +                    <span class="icon"> +                      <i class="fas fa-upload"></i> +                    </span> +                    <span>Upload</span> +                  </a> +                  <a class="button is-warning" title="Remove image" href="{% url 'wiki:images_delete' path=urlpath.path article_id=article.id image_id=image.id %}"> +                    <span class="icon"> +                      <i class="fas fa-times"></i> +                    </span> +                    <span>Remove</span> +                  </a> +                {% endif %} +                {% if article|can_moderate:user %} +                  <a class="button is-danger" href="{% url 'wiki:images_purge' path=urlpath.path article_id=article.id image_id=image.id %}"> +                    <span class="icon"> +                      <i class="fas fa-trash"></i> +                    </span> +                    <span>Delete</span> +                  </a> +                {% endif %} +              {% endif %} +            </td> + +            <td> +              <code>[image:{{ image.id }}]</code> +            </td> + +            <td colspan="3"> +              {% include "wiki/includes/revision_info.html" %} +            </td> + +            <td> +              {{ revision.get_size|filesizeformat }}<br />{{ revision.width }}x{{ revision.height }} pixels +            </td> +          </tr> + +          <tr> +            <th colspan="5"> +              History +            </th> +          </tr> + +          <tr> +            <td class="is-paddingless" colspan="5"> +              <table class="table is-striped"> +                <thead> +                  <tr> +                    <th></th> +                    <th>Updated</th> +                    <th>Size</th> +                    <th>Dimensions</th> +                    <th></th> +                  </tr> +                </thead> +                <tbody> +                  {% for old_revision in image.revision_set.all %} +                    <tr {% if forloop.first %}class="is-selected"{% endif %}> +                      <td> +                        <figure class="image"> +                          {% thumbnail old_revision.imagerevision.image "50x50" crop="center" as thumb %} +                            <a href="{{ old_revision.imagerevision.image.url }}"> +                              <img src="{{ thumb.url }}" alt="{{ revision.imagerevision.get_filename }}" /> +                            </a> +                          {% endthumbnail %} +                        </figure> +                      </td> + +                      <td> +                        {% include "wiki/includes/revision_info.html" with current_revision=image.current_revision revision=old_revision %} +                      </td> + +                      <td> +                        {{ old_revision.imagerevision.get_size|filesizeformat }} +                      </td> + +                      <td> +                        {{ old_revision.imagerevision.width }}x{{ old_revision.imagerevision.height }} pixels +                      </td> + +                      <td> +                        {% if image|can_write:user and old_revision != image.current_revision %} +                          <a class="button is-primary" href="{% url 'wiki:images_set_revision' path=urlpath.path article_id=article.id image_id=image.id rev_id=old_revision.id %}"> +                            <span class="icon"> +                              <i class="fas fa-sync"></i> +                            </span> +                            <span>Restore</span> +                          </a> +                        {% else %} +                          <a class="button is-static has-text-grey"> +                            <span class="icon"> +                              <i class="fas fa-times"></i> +                            </span> +                            <span>Current</span> +                          </a> +                        {% endif %} +                      </td> +                    </tr> +                  {% endfor %} +                </tbody> +              </table> +            </td> +          </tr> +        </tbody> +      {% endwith %} +    {% endfor %} +  </table> + +  {% include "wiki/includes/pagination.html" %} +{% endblock %} diff --git a/pydis_site/templates/wiki/plugins/images/purge.html b/pydis_site/templates/wiki/plugins/images/purge.html new file mode 100644 index 00000000..3b514e4c --- /dev/null +++ b/pydis_site/templates/wiki/plugins/images/purge.html @@ -0,0 +1,42 @@ +{% extends "wiki/article.html" %} +{% load wiki_tags %} +{% load wiki_thumbnails %} + +{% block wiki_pagetitle %}Purge image: {{ image }}{% endblock %} + +{% block wiki_contents_tab %} +  <div class="columns"> +    <div class="column is-two-thirds"> +      <p> +        Purge image: Completely remove image file and all revisions +      </p> +      <form method="POST" class="form-horizontal" enctype="multipart/form-data"> +        {% wiki_form form %} + +        <a href="{% url 'wiki:images_index' path=urlpath.path article_id=article.id %}" class="button is-white"> +          <span class="icon"> +            <i class="fas fa-arrow-left"></i> +          </span> +          <span>Go Back</span> +        </a> + +        <button class="button is-danger" type="submit"> +          <span class="icon"> +            <i class="fas fa-trash"></i> +          </span> +          <span>Permanently remove</span> +        </button> +      </form> +    </div> + +    <div class="column is-one-third"> +      {% thumbnail image.current_revision.imagerevision.image "250x250" as thumb %} +        <figure class="image"> +          <a href="{{ image.current_revision.imagerevision.image.url }}"> +            <img src="{{ thumb.url }}" alt="{{ revision.get_filename }}" title="{{ revision.get_filename }}" /> +          </a> +        </figure> +      {% endthumbnail %} +    </div> +  </div> +{% endblock %} diff --git a/pydis_site/templates/wiki/plugins/images/render.html b/pydis_site/templates/wiki/plugins/images/render.html new file mode 100644 index 00000000..d14b3de4 --- /dev/null +++ b/pydis_site/templates/wiki/plugins/images/render.html @@ -0,0 +1,25 @@ +{% load wiki_thumbnails %}{% comment %} +  This template is used for the markdown extension that renders images and captions. + +  NB! Watch out for line breaks, markdown might add <br />s and <p>s. +{% endcomment %}{% with image.current_revision.imagerevision as revision %}{% spaceless %} +<figure +    class="image{% if align %} is-pulled-{{ align }}{% endif %}" +    {% if width %}style="width: {{ width }}px;" {% endif %} +> +  <a href="{{ revision.image.url }}"> +    {% if size %} +      {% thumbnail revision.image size upscale=False as thumb %} +        <img src="{{ thumb.url }}" alt="{{ revision.get_filename }}" /> +      {% empty %} +        <figcaption> +          <em>Image not found</em> +        </figcaption> +      {% endthumbnail %} +    {% else %} +      <img src="{{ revision.image.url }}" alt="{{ revision.get_filename }}" /> +    {% endif %} +  </a> +  <figcaption>{{ caption|safe }}</figcaption> +</figure> +{% endspaceless %}{% endwith %} diff --git a/pydis_site/templates/wiki/plugins/images/revision_add.html b/pydis_site/templates/wiki/plugins/images/revision_add.html new file mode 100644 index 00000000..eb872eab --- /dev/null +++ b/pydis_site/templates/wiki/plugins/images/revision_add.html @@ -0,0 +1,43 @@ +{% extends "wiki/article.html" %} +{% load wiki_tags %} +{% load wiki_thumbnails %} + +{% block wiki_pagetitle %}Replace Image: {{ image }}{% endblock %} + +{% block wiki_contents_tab %} +  <div class="columns"> +    <div class="column is-two-thirds"> +      <p> +        Upload an image to replace the current one. +      </p> + +      <form method="POST" class="form-horizontal" enctype="multipart/form-data"> +        {% wiki_form form %} + +        <a href="{% url 'wiki:images_index' path=urlpath.path article_id=article.id %}" class="button is-white"> +          <span class="icon"> +            <i class="fas fa-arrow-left"></i> +          </span> +          <span>Go Back</span> +        </a> + +        <button class="button is-primary" type="submit"> +          <span class="icon"> +            <i class="fas fa-upload"></i> +          </span> +          <span>Upload</span> +        </button> +      </form> +    </div> + +    <div class="column is-one-third"> +      {% thumbnail image.current_revision.imagerevision.image "250x250" as thumb %} +        <figure class="image"> +          <a href="{{ image.current_revision.imagerevision.image.url }}"> +            <img src="{{ thumb.url }}" alt="{{ revision.get_filename }}" title="{{ revision.get_filename }}" /> +          </a> +        </figure> +      {% endthumbnail %} +    </div> +  </div> +{% endblock %} diff --git a/pydis_site/templates/wiki/plugins/images/sidebar.html b/pydis_site/templates/wiki/plugins/images/sidebar.html new file mode 100644 index 00000000..b29ef240 --- /dev/null +++ b/pydis_site/templates/wiki/plugins/images/sidebar.html @@ -0,0 +1,206 @@ +{% load static %} +{% load wiki_images_tags %} +{% load wiki_tags %} +{% load wiki_thumbnails %} + +{% with article|images_for_article as images %} +  {% if article|images_can_add:user %} +    {% include "wiki/includes/formerrors.html" %} + +    {# Include the hidden fields #} +    {% for hidden in form.hidden_fields %} +      {{ hidden }} +    {% endfor %} + +    {% for field in form.visible_fields %} +      {% include "wiki/includes/formfield.html" with render_labels=False %} +    {% endfor %} + +    <button type="button" onClick="add_image(this.form)" name="{{ plugin.slug }}_save" value="1" class="button is-primary is-fullwidth"> +      <span class="icon"> +        <i class="fas fa-upload"></i> +      </span> +      <span>Upload</span> +    </button> + +    <br /> +  {% endif %} + +  {% for image in images %} +    {% with image.current_revision.imagerevision as revision %} +      {% thumbnail revision.image "100x100" crop="center" as thumb %} +        <div class="columns"> +          <div class="column is-half"> +            <img src="{{ thumb.url }}" alt="{{ revision.get_filename }}" title="{{ revision.get_filename }}" /> +          </div> +          <div class="column is-half has-text-right"> +            <div class="tags is-right"> +              <span class="tag is-dark is-medium">Image ID: {{ image.id }}</span> +            </div> + +            <p> +              <a class="button is-primary" title="Insert image" href="javascript:void(insert_image({{ image.id }}))"> +                <span class="icon"> +                  <i class="fa fa-paste"></i> +                </span> +              </a> + +              {% if image|can_write:user %} +                <a class="button is-primary" title="Replace" href="{% url 'wiki:images_add_revision' path=urlpath.path article_id=article.id image_id=image.id %}"> +                  <span class="icon"> +                    <i class="fas fa-upload"></i> +                  </span> +                </a> +              {% endif %} +            </p> +          </div> +        </div> +      {% endthumbnail %} +    {% endwith %} + +  {% empty %} +    <div class="has-text-centered"> +      No images found for this article. +    </div> +    <br /> +  {% endfor %} + +  <p> +    <a class="button is-primary is-fullwidth" href="{% url 'wiki:images_index' path=urlpath.path article_id=article.id %}"> +      <span>Manage Images</span> +      <span class="icon"> +        <i class="fas fa-arrow-right"></i> +      </span> +    </a> +  </p> + +  <h4 class="title is-4">How to use images</h4> + +  <p> +    Images are local to the article, and may only be used in the article they are +    uploaded to. Images may be replaced by clicking the upload button next to it +    above, but note that image revisions are kept and can be found on the +    <a href="{% url 'wiki:images_index' path=urlpath.path article_id=article.id %}">Manage Images page</a>. +  </p> + +  <p> +    To make use of images in an article, use the <code>image</code> wiki tag in +    your Markdown. These tags take some arguments for customisation, and you can +    also include a caption on the next line, indented by four spaces. Note that +    the <code>align</code> and <code>size</code> options are optional. +  </p> +    <p> +    Syntax: <code>[image:ID align:x size:y]</code> +    </p> +  <p> +    The ID to use is the image ID shown next to the image in the list above. +    You can click on the insert button if you'd like to insert an image into the +    editor without manually typing the tag. +  </p> + +  <h5 class="title is-5">Example tag</h5> + +  <pre> +  [image:1 align:left size:orig] +      Python Discord logo +  </pre> + +  <h5 class="title is-5">Options for align</h5> + +  <div class="tags"> +    <span class="tag is-primary">left</span> +    <span class="tag is-primary">right</span> +  </div> + +  <h5 class="title is-5">Options for size</h5> + +  <div class="tags"> +    <span class="tag is-primary">small</span> +    <span class="tag is-primary">medium</span> +    <span class="tag is-primary">large</span> +    <span class="tag is-primary">orig</span> +    <span class="tag is-primary">default</span> +  </div> +{% endwith %} + +<div class="modal" id="imgModal"> +  <div class="modal-background"></div> +  <div class="modal-card" style="height: 80%; width: 80%;"> +    <div class="modal-card-head"> +      <p class="modal-card-title">Insert Image</p> +    </div> +    <div class="modal-card-body" style="padding: 0; overflow: hidden;"> +      <section class="section"> +        <input type="hidden" value="0" id="img_id" /> +        <div class="field is-horizontal"> +          <div class="field-label"> +            <label for="img_align">Image alignment</label> +          </div> +          <div class="field-body"> +            <div class="control has-icons-left is-fullwidth"> +              <div class="select is-fullwidth"> +                <select id="img_align"> +                  <option selected value="">Default</option> +                  <option value="left">Left</option> +                  <option value="right">Right</option> +                </select> +              </div> + +              <span class="icon is-left"> +                <i class="fas fa-align-center"></i> +              </span> +            </div> +          </div> +        </div> + +        <div class="field is-horizontal"> +          <div class="field-label"> +            <label for="img_size">Image size</label> +          </div> +          <div class="field-body"> +            <div class="control has-icons-left is-fullwidth"> +              <div class="select is-fullwidth"> +                <select id="img_size"> +                  <option selected value="">Default</option> +                  <option value="orig">Original</option> + +                  <option value="small">Small</option> +                  <option value="medium">Medium</option> +                  <option value="large">Large</option> +                </select> +              </div> +              <span class="icon is-left"> +                <i class="fas fa-expand-arrows"></i> +              </span> +            </div> +          </div> +        </div> + +        <div class="field is-horizontal"> +          <div class="field-label"> +            <label for="img_caption">Image caption</label> +          </div> +          <div class="field-body"> +            <input class="input" type="text" placeholder="Enter Caption" id="img_caption" /> +          </div> +        </div> +      </section> +    </div> +    <div class="modal-card-foot"> +      <button class="button is-light" aria-label="close"> +        <span class="icon"> +          <i class="fas fa-arrow-left"></i> +        </span> +        <span>Back</span> +      </button> +      <button class="button is-primary" id="id_image_insert"> +        <span class="icon"> +          <i class="fas fa-paste"></i> +        </span> +        <span>Insert</span> +      </button> +    </div> +  </div> +</div> + +<script type="text/javascript" src="{% static "js/wiki/image_sidebar.js" %}"></script> diff --git a/pydis_site/templates/wiki/plugins/links/sidebar.html b/pydis_site/templates/wiki/plugins/links/sidebar.html new file mode 100644 index 00000000..4fdbac72 --- /dev/null +++ b/pydis_site/templates/wiki/plugins/links/sidebar.html @@ -0,0 +1,56 @@ +{% load sekizai_tags %} +{% load static %} + +<h4 class="title is-4">Link to another wiki page</h4> + +<p> +  Type in something from another wiki page's title and auto-complete will help you create a tag for your wiki link. Tags for links look like this:<br /> +</p> + +<pre>[Title of link](wiki:ArticleSlug)</pre> + +{# We do this to prevent accidental form submission - this isn't _really_ a form #} +<input type="submit" disabled style="display: none" aria-hidden="true" /> + +<div class="field"> +  <div class="control has-icons-left"> +    <div class="dropdown"> +      <div class="dropdown-trigger"> +        <input class="input" type="text" id="page_title_input" value="" placeholder="Search: 3+ chars" aria-haspopup="true" aria-controls="page_title_menu"> +      </div> +      <div class="dropdown-menu" id="page_title_menu" role="menu"></div> +    </div> + +    <span class="icon is-small is-left"> +      <i class="fas fa-search"></i> +    </span> +  </div> +</div> + +<div class="is-divider"></div> + +<h4 class="title is-4">An external link</h4> + +<p> +  You can link to another website simply by inserting an address example.com or http://example.com or by using the markdown syntax:<br /> +</p> + +<pre>[Clickable text](http://example.com)</pre> + +{% addtoblock "js" %} +  {% comment %} +    So, for whatever reason, bulmahead doesn't have a LICENSE file. There is one in +    the package.json, but that isn't a standard most projects adhere to - so I've +    declined to include it within the project directly. + +    The package.json states MIT - but there is no prose or license +    text available for the project itself. +  {% endcomment %} + +  <script src="https://cdn.rawgit.com/mattmezza/bulmahead/master/dist/bulmahead.bundle.js"></script> +  <script src="{% static "js/wiki/links_sidebar.js" %}"></script> + +  <script type="text/javascript"> +    setFetchURL("{% url 'wiki:links_query_urlpath' path=urlpath.path article_id=article.id %}"); +  </script> +{% endaddtoblock %} diff --git a/pydis_site/templates/wiki/preview_inline.html b/pydis_site/templates/wiki/preview_inline.html new file mode 100644 index 00000000..a01c963a --- /dev/null +++ b/pydis_site/templates/wiki/preview_inline.html @@ -0,0 +1,73 @@ +{% extends "wiki/base.html" %} +{% load sekizai_tags %} +{% load static %} +{% load wiki_tags %} + +{# We make these empty so they don't appear in the preview #} +{% block site_navbar %}{% endblock %} +{% block site_footer %}{% endblock %} +{% block wiki_breadcrumbs %}{% endblock %} + +{% block wiki_body %} +  {% if revision %} +    <div class="container"> +      <div class="message"> +        <div class="message-header"> +          <p>Previewing Revision</p> +        </div> +        <div class="message-body"> +          {% include "wiki/includes/revision_info.html" %} +        </div> +      </div> +    </div> +  {% endif %} + +  {% if merge %} +    <div class="alert alert-info"> +      <strong>Previewing merge between:</strong> +      {% include "wiki/includes/revision_info.html" with revision=merge1 %} +      <strong>and</strong> +      {% include "wiki/includes/revision_info.html" with revision=merge2 %} +    </div> + +    {% if merge1.deleted %} +      <div class="alert alert-danger"> +        <strong>You cannot merge with a deleted revision</strong> +      </div> +    {% endif %} +  {% endif %} + +  {% if revision and revision.deleted %} +    <div class="warning"> +      <strong>This revision has been deleted.</strong> +      <p>Restoring to this revision will mark the article as deleted.</p> +    </div> +  {% else %} +    <section class="section"> +      <div class="container"> +        <div class="content"> +          <h1 class="title">{{ article.current_revision.title }}</h1> + +          {% wiki_render article content %} +        </div> +      </div> +    </section> + +    {% for plugin in plugins %} +      {% if plugin.RenderMedia.css %} +        {% addtoblock "css" %} +          {% for media, url in plugin.RenderMedia.css.items %} +            <link rel="stylesheet" href="{% static url %}" /> +          {% endfor %} +        {% endaddtoblock %} +      {% endif %} +      {% if plugin.RenderMedia.js %} +        {% addtoblock "js" %} +          {% for url in plugin.RenderMedia.js %} +            <script type="text/javascript" src="{% static url %}"></script> +          {% endfor %} +        {% endaddtoblock %} +      {% endif %} +    {% endfor %} +  {% endif %} +{% endblock %} diff --git a/pydis_site/templates/wiki/root_missing.html b/pydis_site/templates/wiki/root_missing.html new file mode 100644 index 00000000..31ef2eab --- /dev/null +++ b/pydis_site/templates/wiki/root_missing.html @@ -0,0 +1,41 @@ +{% extends "wiki/create_root.html" %} +{% load wiki_tags %} + +{% block wiki_contents %} +  <div class="columns"> +    <div class="column is-two-thirds is-offset-2"> +      <article class="message is-primary"> +        <div class="message-header"> +          <p>No articles found</p> +        </div> +        <div class="message-body"> +          <p> +            It appears that there are no articles available on this wiki. +          </p> + +          {% if not user.is_superuser %} +            <p> +              To get started, please login with a superuser account. +            </p> + +            {% login_url as wiki_login_url %} + +            {% if wiki_login_url %} +              <div class="has-text-centered"> +                <a href="{{ wiki_login_url }}" class="button is-primary">Login</a> +              </div> +            {% endif %} +          {% else %} +            <p> +              Let's get started - click below to create the first article, or to read up on the +              <code>django-wiki</code> documentation. +            </p> + +            <a class="button is-primary" href="{% url 'wiki:root_create' %}">Create Article</a> +            <a class="button is-info" href="http://django-wiki.readthedocs.org/">Documentation</a> +          {% endif %} +        </div> +      </article> +    </div> +  </div> +{% endblock %} diff --git a/pydis_site/templates/wiki/search.html b/pydis_site/templates/wiki/search.html new file mode 100644 index 00000000..154b6934 --- /dev/null +++ b/pydis_site/templates/wiki/search.html @@ -0,0 +1,64 @@ +{% extends "wiki/base.html" %} +{% load i18n %} +{% load wiki_tags %} + + +{% block wiki_pagetitle %}Search results for: "{{ search_query }}"{% endblock %} + +{% block wiki_contents %} +  <h1 class="page-header">Search results for: "{{ search_query }}"</h1> + +  <form class="form-search directory-toolbar"> +    <p> +      {% if urlpath %} +        Searching: <strong>in {{ urlpath.article }}</strong> +      {% else %} +        Searching: <strong>everywhere</strong> +      {% endif %} +    </p> + +    <div class="field has-addons"> +      <div class="control has-icons-left is-expanded"> +        <input type="search" class="input" name="q" value="{{ search_query }}" /> +        <span class="icon is-left"> +          <i class="fas fa-search"></i> +        </span> +      </div> +      <div class="control"> +        <button class="button is-primary" type="submit"> +          Search +        </button> +      </div> +    </div> + +    <p> +      {% blocktrans with paginator.object_list.count as cnt %} +        Your search returned <strong>{{ cnt }}</strong> results. +      {% endblocktrans %} +    </p> +  </form> + +  {% include "wiki/includes/pagination.html" %} + +  <table class="table is-striped"> +    <tr> +      <th>Title</th> +      <th class="has-text-right">Last modified</th> +    </tr> + +    {% for article in articles %} +      {% block wiki_search_loop %} +        {% include "wiki/includes/searchresult.html" %} +      {% endblock %} + +      {% empty %} +        <tr> +          <td colspan="2"> +            <em>No articles were found for that search query.</em> +          </td> +        </tr> +    {% endfor %} +  </table> + +  {% include "wiki/includes/pagination.html" %} +{% endblock %} diff --git a/pydis_site/templates/wiki/settings.html b/pydis_site/templates/wiki/settings.html new file mode 100644 index 00000000..e291621d --- /dev/null +++ b/pydis_site/templates/wiki/settings.html @@ -0,0 +1,30 @@ +{% extends "wiki/article.html" %} +{% load wiki_tags %} + +{% block wiki_pagetitle %}Settings: {{ article.current_revision.title }}{% endblock %} + +{% block wiki_contents_tab %} +  {% for form in forms %} +    <form method="POST" class="form-horizontal" action="?f={{form.action}}"> +      <h3 class="page-header">{{ form.settings_form_headline }}</h3> + +      {% wiki_form form %} + +      <div class="field is-horizontal"> +        <div class="field-label"> +          {# Empty for spacing #} +        </div> +        <div class="field-body"> +          <div class="control"> +            <button type="submit" class="button is-primary" name="save"> +              <span class="icon"> +                <i class="fas fa-save"></i> +              </span> +              <span>Save Changes</span> +            </button> +          </div> +        </div> +      </div> +    </form> +  {% endfor %} +{% endblock %} diff --git a/pydis_site/templates/wiki/source.html b/pydis_site/templates/wiki/source.html new file mode 100644 index 00000000..a6611233 --- /dev/null +++ b/pydis_site/templates/wiki/source.html @@ -0,0 +1,14 @@ +{% extends "wiki/article.html" %} +{% load wiki_tags %} + +{% block wiki_pagetitle %}Source of "{{ article.current_revision.title }}"{% endblock %} + +{% block wiki_contents_tab %} +  {% if article.current_revision.locked %} +    <p>This article is currently locked for editing.</p> +  {% endif %} + +  <pre class="is-fullwidth"> +{{ article.current_revision.content }} +  </pre> +{% endblock %}  |