Updated "Search" pages with modern design.

This commit is contained in:
Jonathan S. Katz
2018-04-16 00:01:35 -04:00
parent 2527b08239
commit 900946df03
2 changed files with 107 additions and 86 deletions

View File

@ -3,60 +3,76 @@
{%block contents%} {%block contents%}
<form method="get" action="/search/"> <form method="get" action="/search/">
<input type="hidden" name="m" value="1"> <input type="hidden" name="m" value="1">
<div class="tblBasic"> <div class="row">
<table border="0" cellpadding="0" cellspacing="0" class="tblBasicGrey" width="590"> <div class="col-lg-6">
<tr> <div class="input-group">
<td class="colFirst">Search for</td> <input type="text" name="q" value="{{query}}" class="form-control" placeholder="Search for...">
<th class="colLast"><input type="text" name="q" value="{{query}}" /> <input type="submit" value="Search" /></th> <span class="input-group-btn">
</tr> <button class="btn btn-default" type="submit">
<tr> <i class="fas fa-search"></i>
<td class="colFirstR">List:</td> </button>
<td class="colLast"><select name="l"> </span>
<option value="">-- All lists</option> </div><!-- /input-group -->
{%for l in lists %} <div class="form-group">
{%ifchanged l.group%} <label for="allsites">List:</label>
<option value="{{l.group.negid}}"{%if l.group.negid == listid%} SELECTED{%endif%}>-- {{l.group}}</option> <select name="l">
{%endifchanged%} <option value="">-- All lists</option>
<option value="{{l.id}}"{%if l.id == listid%} SELECTED{%endif%}>{{l}}</option> {%for l in lists %}
{%endfor%} {%ifchanged l.group%}
</select></td> <option value="{{l.group.negid}}"{%if l.group.negid == listid%} SELECTED{%endif%}>-- {{l.group}}</option>
</tr> {%endifchanged%}
<tr> <option value="{{l.id}}"{%if l.id == listid%} SELECTED{%endif%}>{{l}}</option>
<td class="colFirstR">Post date:</td> {%endfor%}
<td class="colLast"><select name="d">{%for d in dates%} </select>
<option value="{{d.val}}"{%if d.val == dateval %} SELECTED{%endif%}>{{d.text}}</option>{%endfor%} </div>
</select></td> <div class="form-group">
</tr> <label for="search-lists">List:</label>
<tr class="lastrow"> <select id="search-lists" class="custom-select" name="l">
<td class="colFirst" align="right">Sort by:</td> <option value="">-- All lists</option>
<td class="colLast"><select name="s">{%for s in sortoptions%} {%for l in lists %}
<option value="{{s.val}}"{%if s.selected%} SELECTED{%endif%}>{{s.text}}</option>{%endfor%} {%ifchanged l.group%}
</select></td> <option value="{{l.group.negid}}"{%if l.group.negid == listid%} SELECTED{%endif%}>-- {{l.group}}</option>
</tr> {%endifchanged%}
</table> <option value="{{l.id}}"{%if l.id == listid%} SELECTED{%endif%}>{{l}}</option>
</div> {%endfor%}
</select>
</div>
<div class="form-group">
<label for="search-postdate">Date:</label>
<select id="search-postdate" class="custom-select" name="d">{%for d in dates%}
<option value="{{d.val}}"{%if d.val == dateval %} SELECTED{%endif%}>{{d.text}}</option>{%endfor%}
</select>
</div>
<div class="form-group">
<label for="search-sortby">Sort By:</label>
<select id="search-sortby" class="custom-select" name="s">{%for s in sortoptions%}
<option value="{{s.val}}"{%if s.selected%} SELECTED{%endif%}>{{s.text}}</option>{%endfor%}
</select>
</div>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
</form> </form>
<div id="pgSearchContent"> <div class="row">
{%if search_error %} {%if search_error %}
<div>{{search_error}}</div> <div>{{search_error}}</div>
{%else%}
<!-- docbot goes here -->
{%if hitcount == 0 %}
<p>Your search for <strong>{{query}}</strong> returned no hits.</p>
{%else%} {%else%}
<h2>Results {{firsthit}}-{{lasthit}} of {%if hitcount == 1000%}more than 1000{%else%}{{hitcount}}{%endif%}.</h2> <!-- docbot goes here -->
{%if pagelinks %}Result pages: {{pagelinks|safe}}<br/><br/>{%endif%} {%if hitcount == 0 %}
{%for hit in hits %} <p>Your search for <b>{{query}}</b> returned no hits.</p>
{{forloop.counter0|add:firsthit}}. <a href="https://www.postgresql.org/message-id/{{hit.messageid}}">{{hit.subject}}</a> [{{hit.rank|floatformat:2}}]<br/> {%else%}
From {{hit.author}} on {{hit.date}}.<br/> <h2>Results {{firsthit}}-{{lasthit}} of {%if hitcount == 1000%}more than 1000{%else%}{{hitcount}}{%endif%}.</h2>
{{hit.abstract|safe}}<br/> {%if pagelinks %}Result pages: {{pagelinks|safe}}<br/><br/>{%endif%}
<a href="https://www.postgresql.org/message-id/{{hit.messageid}}">https://www.postgresql.org/message-id/{{hit.messageid}}</a><br/> {%for hit in hits %}
<br/> {{forloop.counter0|add:firsthit}}. <a href="https://www.postgresql.org/message-id/{{hit.messageid}}">{{hit.subject}}</a> [{{hit.rank|floatformat:2}}]<br/>
{%endfor%} From {{hit.author}} on {{hit.date}}.<br/>
{%if pagelinks %}Result pages: {{pagelinks|safe}}<br/><br/>{%endif%} {{hit.abstract|safe}}<br/>
<a href="https://www.postgresql.org/message-id/{{hit.messageid}}">https://www.postgresql.org/message-id/{{hit.messageid}}</a><br/>
<br/>
{%endfor%}
{%if pagelinks %}Result pages: {{pagelinks|safe}}<br/><br/>{%endif%}
{%endif%}
{%endif%} {%endif%}
{%endif%}
</div> </div>
{%endblock%} {%endblock%}

View File

@ -2,42 +2,47 @@
{%block title%}Search results{%endblock%} {%block title%}Search results{%endblock%}
{%block contents%} {%block contents%}
<h1>Site Search <i class="fas fa-link"></i></h1>
<form method="get" action="/search/"> <form method="get" action="/search/">
{%if suburl%} {%if suburl%}
<input type="hidden" name="u" value="{{suburl}}"> <input type="hidden" name="u" value="{{suburl}}">
{%endif%} {%endif%}
<div class="tblBasic"> <div class="row">
<table border="0" cellpadding="0" cellspacing="0" class="tblBasicGrey" width="590"> <div class="col-lg-6">
<tr> <div class="input-group">
<td class="colFirst">Search for</td> <input type="text" name="q" value="{{query}}" class="form-control" placeholder="Search for...">
<th class="colLast"><input type="text" name="q" value="{{query}}" /> <input type="submit" value="Search" /></th> <span class="input-group-btn">
</tr> <button class="btn btn-default" type="submit">
<tr class="lastrow"> <i class="fas fa-search"></i>
<td class="colFirst"></td> </button>
<td class="colLast"><input type="checkbox" name="a" value="1" {%if allsites%}checked="checked"{%endif%}/>Include community sites</td> </span>
</tr> </div><!-- /input-group -->
</table> <div class="form-check search">
</div> <input class="form-check-input" type="checkbox" value="" name="a" value="1" {%if allsites%}checked="checked"{%endif%} id="allsites">
<label class="form-check-label" for="allsites">
Include community sites
</label>
</div>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
</form> </form>
<div id="pgSearchContent"> {%if search_error %}
{%if search_error %} <div>{{search_error}}</div>
<div>{{search_error}}</div> {%else%}
{%else%} <!-- docbot goes here -->
<!-- docbot goes here --> {%if hitcount == 0 %}
{%if hitcount == 0 %} <p>Your search for <b>{{query}}</b> returned no hits.</p>
<p>Your search for <strong>{{query}}</strong> returned no hits.</p> {%else%}
{%else%} <h2>Results {{firsthit}}-{{lasthit}} of {%if hitcount == 1000%}more than 1000{%else%}{{hitcount}}{%endif%}.</h2>
<h2>Results {{firsthit}}-{{lasthit}} of {%if hitcount == 1000%}more than 1000{%else%}{{hitcount}}{%endif%}.</h2> {%if pagelinks %}Result pages: {{pagelinks|safe}}<br/><br/>{%endif%}
{%if pagelinks %}Result pages: {{pagelinks|safe}}<br/><br/>{%endif%} {%for hit in hits %}
{%for hit in hits %} {{forloop.counter0|add:firsthit}}. <a href="{{hit.url}}">{{hit.title}}</a> [{{hit.rank|floatformat:2}}]<br/>
{{forloop.counter0|add:firsthit}}. <a href="{{hit.url}}">{{hit.title}}</a> [{{hit.rank|floatformat:2}}]<br/> <div>...{{hit.abstract|safe}}...</div>
<div>...{{hit.abstract|safe}}...</div> <a href="{{hit.url}}">{{hit.url}}</a><br/>
<a href="{{hit.url}}">{{hit.url}}</a><br/> <br/>
<br/> {%endfor%}
{%endfor%} {%if pagelinks %}Result pages: {{pagelinks|safe}}<br/><br/>{%endif%}
{%if pagelinks %}Result pages: {{pagelinks|safe}}<br/><br/>{%endif%} {%endif%}
{%endif%} {%endif%}
{%endif%}
</div>
{%endblock%} {%endblock%}