1
0
mirror of https://github.com/djohnlewis/stackdump synced 2025-12-06 07:53:28 +00:00

Implemented site-specific search.

Added site logos to searches across all sites for easier identification.
Added hints to make it more obvious which site you are searching.
Minor CSS tweaks.
This commit is contained in:
Samuel Lai
2012-02-05 17:54:13 +11:00
parent 6d32f93452
commit 7e87726b74
6 changed files with 236 additions and 133 deletions

View File

@@ -0,0 +1,59 @@
<ul id="search-results">
{% for r in results %}
<li>
{% if not site %}
<div class="post-logo">
<img src="{{ SETTINGS.APP_URL_ROOT }}media/logos/{{ r.site.key }}.png" alt="{{ r.site.name }} logo" />
</div>
{% endif %}
<div class="post-stats-vertical">
<div class="post-stat">
<p class="post-stat-value {% if r.question.score < 0 %}post-stat-value-poor{% endif %}">
{{ r.question.score }}
</p>
<p>vote{% if r.question.score != 1 %}s{% endif %}</p>
</div>
<div class="post-stat">
<p class="post-stat-value {% if r.answers|length == 0 %}post-stat-value-poor{% endif %}">
{{ r.answers|length }}
</p>
<p>answer{% if r.answers|length != 1 %}s{% endif %}</p>
</div>
</div>
<div class="post-summary {% if not site %}post-summary-with-logo{% endif %}">
<h3><a href="#">{{ r.question.title }}</a></h3>
<p>{{ r.question.body|striptags|truncate(256) }}</p>
<p class="post-details">
Asked by <strong>{{ r.question.ownerUser.displayName }}</strong> on
<strong>{{ r.question.creationDate|format_datetime }}</strong>.
</p>
<div class="post-tags">
{% for t in r.question.tags %}
<span class="label">{{ t }}</span>
{% endfor %}
</div>
</div>
{# hack to force a clear on all internal elements #}
<div class="clearfix"></div>
</li>
{% endfor %}
</ul>
<div class="pagination">
<ul>
{% if current_page > 1 %}
{# the prev page is current_page - 2 because current_page is ones-based, but the p GET parameter is zero-based #}
<li class="prev"><a href="{{ REQUEST.url|set_get_parameters('p=' ~ (current_page - 2)) }}">&larr; Previous</a></li>
{% else %}
<li class="prev disabled"><a href="#">&larr; Previous</a></li>
{% endif %}
{% for p in range(1, total_pages + 1) %}
<li {% if p == current_page %}class="active"{% endif %}><a href="{{ REQUEST.url|set_get_parameters('p=' ~ (p-1)) }}">{{ p }}</a></li>
{% endfor %}
{% if current_page != total_pages %}
{# the next page is just current_page because current_page is ones-based, but the p GET parameter is zero-based #}
<li class="next"><a href="{{ REQUEST.url|set_get_parameters('p=' ~ current_page) }}">&rarr; Next</a></li>
{% else %}
<li class="next disabled"><a href="#">&rarr; Next</a></li>
{% endif %}
</ul>
</div>