Implement full-text search functionality
This commit is contained in:
parent
46d921c29e
commit
51ec52499f
7 changed files with 229 additions and 7 deletions
|
|
@ -48,6 +48,16 @@
|
|||
<a href="{% url 'twitch:game_list' %}">Games</a> |
|
||||
<a href="{% url 'twitch:org_list' %}">Organizations</a> |
|
||||
<a href="{% url 'twitch:docs_rss' %}">RSS Docs</a> |
|
||||
<form action="{% url 'twitch:search' %}"
|
||||
method="get"
|
||||
style="display: inline">
|
||||
<input type="search"
|
||||
name="q"
|
||||
placeholder="Search..."
|
||||
value="{{ request.GET.q }}">
|
||||
<button type="submit">Search</button>
|
||||
</form>
|
||||
|
|
||||
{% if user.is_authenticated %}
|
||||
<a href="{% url 'twitch:debug' %}">Debug</a> |
|
||||
{% if user.is_staff %}
|
||||
|
|
|
|||
59
templates/twitch/search_results.html
Normal file
59
templates/twitch/search_results.html
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
{% extends "base.html" %}
|
||||
{% block title %}
|
||||
Search Results for "{{ query }}"
|
||||
{% endblock title %}
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
<h1>Search Results for "{{ query }}"</h1>
|
||||
{% if not results.organizations and not results.games and not results.campaigns and not results.drops and not results.benefits %}
|
||||
<p>No results found.</p>
|
||||
{% else %}
|
||||
{% if results.organizations %}
|
||||
<h2>Organizations</h2>
|
||||
<ul>
|
||||
{% for org in results.organizations %}
|
||||
<li>
|
||||
<a href="{% url 'twitch:organization_detail' org.pk %}">{{ org.name }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
{% if results.games %}
|
||||
<h2>Games</h2>
|
||||
<ul>
|
||||
{% for game in results.games %}
|
||||
<li>
|
||||
<a href="{% url 'twitch:game_detail' game.pk %}">{{ game.display_name }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
{% if results.campaigns %}
|
||||
<h2>Campaigns</h2>
|
||||
<ul>
|
||||
{% for campaign in results.campaigns %}
|
||||
<li>
|
||||
<a href="{% url 'twitch:campaign_detail' campaign.pk %}">{{ campaign.name }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
{% if results.drops %}
|
||||
<h2>Drops</h2>
|
||||
<ul>
|
||||
{% for drop in results.drops %}
|
||||
<li>
|
||||
<a href="{% url 'twitch:campaign_detail' drop.campaign.pk %}#drop-{{ drop.id }}">{{ drop.name }}</a> (in {{ drop.campaign.name }})
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
{% if results.benefits %}
|
||||
<h2>Benefits</h2>
|
||||
<ul>
|
||||
{% for benefit in results.benefits %}<li>{{ benefit.name }}</li>{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock content %}
|
||||
Loading…
Add table
Add a link
Reference in a new issue