Show page when tag not found

This commit is contained in:
RunasSudo 2020-07-23 22:30:52 +10:00
parent d60516420b
commit badc2a452f
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
2 changed files with 39 additions and 0 deletions

View File

@ -202,6 +202,9 @@ def tags_list():
@app.route('/tag/<name>')
def tag_view(name):
if name not in index['tags']:
return flask.render_template('tag_404.html', name=name)
pages = index['tags'][name]
pages.sort(key=lambda p: p['kind'])
pages.sort(key=lambda p: p['path'])

View File

@ -0,0 +1,36 @@
{#
WikiNote3
Copyright © 2020 Lee Yingtong Li (RunasSudo)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
#}
{% extends 'base.html' %}
{% block title %}Tag: {{ name }} • WikiNote{% endblock %}
{% block content %}
<nav class="breadcrumbs">
<a href="/"><img src="{{ url_for('static', filename='img/icons/home.svg') }}"></a>
&rsaquo;
<a href="{{ url_for('tags_list') }}">Tags</a>
&rsaquo;
</nav>
<h1>{{ name }}</h1>
<div class="admonition error">
There are no indexed pages with the name <em>{{ name }}</em>.
</div>
{% endblock %}