diff options
author | 2019-04-18 18:12:04 +0100 | |
---|---|---|
committer | 2019-04-18 18:12:04 +0100 | |
commit | 06fed91f6515e08a0e62cc48ade80d65257fcbd9 (patch) | |
tree | 9dd7be80f78dda8f3ef629828e2382738be2f552 /pydis_site/templates | |
parent | Source page (diff) |
Searching and pagination
Diffstat (limited to 'pydis_site/templates')
-rw-r--r-- | pydis_site/templates/base/paginator.html | 64 | ||||
-rw-r--r-- | pydis_site/templates/wiki/dir.html | 4 | ||||
-rw-r--r-- | pydis_site/templates/wiki/history.html | 4 | ||||
-rw-r--r-- | pydis_site/templates/wiki/includes/pagination.html | 24 | ||||
-rw-r--r-- | pydis_site/templates/wiki/includes/searchresult.html | 7 | ||||
-rw-r--r-- | pydis_site/templates/wiki/plugins/images/index.html | 4 | ||||
-rw-r--r-- | pydis_site/templates/wiki/search.html | 62 |
7 files changed, 113 insertions, 56 deletions
diff --git a/pydis_site/templates/base/paginator.html b/pydis_site/templates/base/paginator.html new file mode 100644 index 00000000..8eaa37ee --- /dev/null +++ b/pydis_site/templates/base/paginator.html @@ -0,0 +1,64 @@ +{% comment %} +This template inserts a Bulma paginator wherever one is required. Simply include it as follows: + +{% include "base/paginator.html" with page=paginator_object %} +{% endcomment %} + +<nav class="pagination" role="navigation" aria-label="pagination"> + {% if page.has_previous %} + <a class="pagination-previous" href="{% url "blog.posts" page=page.previous_page_number %}">Newer</a> + {% else %} + <a class="pagination-previous" title="This is the first page" disabled>Newer</a> + {% endif %} + + {% if page.has_next %} + <a class="pagination-next" href="{% url "" page=1 %}">Older</a> + {% else %} + <a class="pagination-next" title="This is the last page" disabled>Older</a> + {% endif %} + + <ul class="pagination-list"> + {% if page.has_previous %} + <li> + <a class="pagination-link" aria-label="Goto page 1" + href="{% url "blog.posts" page=1 %}"> + 1 + </a> + </li> + <li> + <span class="pagination-ellipsis">…</span> + </li> + <li> + <a class="pagination-link" aria-label="Goto page {{ page.previous_page_number }}" + href="{% url "blog.posts" page=page.previous_page_number %}"> + {{ page.previous_page_number }} + </a> + </li> + {% endif %} + + <li> + <a class="pagination-link is-current" aria-label="Page {{ page.number }}" aria-current="page" + href="{% url "blog.posts" page=page.number %}"> + {{ page.number }} + </a> + </li> + + {% if page.has_next %} + <li> + <a class="pagination-link" aria-label="Goto page {{ page.next_page_number }}" + href="{% url "blog.posts" page=page.next_page_number %}"> + {{ page.next_page_number }} + </a> + </li> + <li> + <span class="pagination-ellipsis">…</span> + </li> + <li> + <a class="pagination-link" aria-label="Goto page {{ page.paginator.num_pages }}" + href="{% url "blog.posts" page=page.paginator.num_pages %}"> + {{ page.paginator.num_pages }} + </a> + </li> + {% endif %} + </ul> +</nav> diff --git a/pydis_site/templates/wiki/dir.html b/pydis_site/templates/wiki/dir.html index 86b04c85..283fe598 100644 --- a/pydis_site/templates/wiki/dir.html +++ b/pydis_site/templates/wiki/dir.html @@ -77,6 +77,8 @@ {% endfor %} </table> -{% include "wiki/includes/pagination.html" %} +{% if is_paginated %} + {% include "base/paginator.html" with page=page_obj %} +{% endif %} {% endblock %} diff --git a/pydis_site/templates/wiki/history.html b/pydis_site/templates/wiki/history.html index d7a3a4da..d0a0d868 100644 --- a/pydis_site/templates/wiki/history.html +++ b/pydis_site/templates/wiki/history.html @@ -118,7 +118,9 @@ </div> {% endfor %} - {% include "wiki/includes/pagination.html" %} + {% if is_paginated %} + {% include "base/paginator.html" with page=page_obj %} + {% endif %} {% if revisions.count > 1 and article|can_write:user and not article.current_revision.locked %} diff --git a/pydis_site/templates/wiki/includes/pagination.html b/pydis_site/templates/wiki/includes/pagination.html deleted file mode 100644 index 6e7ec608..00000000 --- a/pydis_site/templates/wiki/includes/pagination.html +++ /dev/null @@ -1,24 +0,0 @@ -{% load i18n %} -{% if is_paginated %} -<ul class="pagination"> - {% if page_obj.has_previous %} - <li><a class="prev btn btn-info" href="?{% if search_query %}q={{ search_query }}&{% endif %}page={{ page_obj.previous_page_number }}{% if appended_key %}&{{ appended_key }}={{ appended_value }}{% endif %}">«</a></li> - {% else %} - <li class="disabled"><span>«</span></li> - {% endif %} - - {% for pc in paginator.page_range %} - {% if pc == 0 %} - <li class="disabled"><span>...</span></li> - {% else %} - <li class="{% if pc == page_obj.number %} active{% endif %}"><a href="?{% if search_query %}q={{ search_query }}&{% endif %}page={{ pc }}{% if appended_key %}&{{ appended_key }}={{ appended_value }}{% endif %}">{{ pc }}</a></li> - {% endif %} - {% endfor %} - - {% if page_obj.has_next %} - <li><a class="next btn btn-info" href="?{% if search_query %}q={{ search_query }}&{% endif %}page={{ page_obj.next_page_number }}{% if appended_key %}&{{ appended_key }}={{ appended_value }}{% endif %}">»</a></li> - {% else %} - <li class="disabled"><span>»</span></li> - {% endif %} -</ul> -{% endif %} diff --git a/pydis_site/templates/wiki/includes/searchresult.html b/pydis_site/templates/wiki/includes/searchresult.html index f6dd7a09..350280a0 100644 --- a/pydis_site/templates/wiki/includes/searchresult.html +++ b/pydis_site/templates/wiki/includes/searchresult.html @@ -4,19 +4,20 @@ <tr> <td> {% for urlpath in article.urlpath_set.all %} - <a href="{% url 'wiki:get' path=urlpath.path %}">{{ article.current_revision.title }}<br /><small class="muted">/{{ urlpath.path }}</small></a> + <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="fa fa-trash"></span> {% endif %} + {% if article.current_revision.locked %} <span class="fa fa-lock"></span> {% endif %} - <p class="muted"><small>{{ article.render|get_content_snippet:search_query }}</small></p> </td> - <td style="white-space: nowrap"> + <td class="has-text-right"> {{ article.current_revision.created|naturaltime }} </td> </tr> diff --git a/pydis_site/templates/wiki/plugins/images/index.html b/pydis_site/templates/wiki/plugins/images/index.html index 4973ea6f..64515208 100644 --- a/pydis_site/templates/wiki/plugins/images/index.html +++ b/pydis_site/templates/wiki/plugins/images/index.html @@ -149,6 +149,8 @@ {% endfor %} </table> - {% include "wiki/includes/pagination.html" %} + {% if is_paginated %} + {% include "base/paginator.html" with page=page_obj %} + {% endif %} {% endblock %} diff --git a/pydis_site/templates/wiki/search.html b/pydis_site/templates/wiki/search.html index 080cf40d..700ed8c4 100644 --- a/pydis_site/templates/wiki/search.html +++ b/pydis_site/templates/wiki/search.html @@ -2,52 +2,62 @@ {% load wiki_tags i18n humanize %} -{% block wiki_pagetitle %}{% trans "Search results for:" %} {{ search_query }}{% endblock %} +{% block wiki_pagetitle %}Search results for: "{{ search_query }}"{% endblock %} {% block wiki_contents %} -<h1 class="page-header">{% trans "Search results for:" %} {{ search_query }}</h1> +<h1 class="page-header">Search results for: "{{ search_query }}"</h1> <form class="form-search directory-toolbar"> -<p class="lead"> - <div class="pull-right"> + <p> {% if urlpath %} - {% trans "Searching in" %} {{ urlpath.article }} + Searching: <strong>in {{ urlpath.article }}</strong> {% else %} - {% trans "Searching whole wiki" %} + Searching: <strong>everywhere</strong> {% endif %} - <div class="input-group"> - <input type="search" class="form-control search-query" name="q" value="{{ search_query }}" /> - <span class="input-group-btn"> - <button class="btn btn-default" type="submit"> - <span class="fa fa-search"></span> - </button> + </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> - <div class="clearfix"></div> -</p> + + <p> + {% blocktrans with paginator.object_list.count as cnt %} + Your search returned <strong>{{ cnt }}</strong> results. + {% endblocktrans %} + </p> </form> -<table class="table table-striped"> +<table class="table is-striped"> <tr> - <th style="width: 75%">{% trans "Title" %}</th> - <th>{% trans "Last modified" %}</th> + <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" %} + {% include "wiki/includes/searchresult.html" %} {% endblock %} - {% empty%} - <tr> - <td colspan="100"> - <em>{% trans "There are no articles in this level" %}</em> - </td> - </tr> + {% empty %} + <tr> + <td colspan="2"> + <em>No articles were found for that search query.</em> + </td> + </tr> {% endfor %} </table> -{% include "wiki/includes/pagination.html" %} +{% if is_paginated %} + {% include "base/paginator.html" with page=page_obj %} +{% endif %} {% endblock %} |