[ehn] Add possibility to add icon in results (more ugly html / css, need fix)

This commit is contained in:
pw3t 2014-01-13 22:24:05 +01:00
parent cf8f444e85
commit fdb6fac214
5 changed files with 29 additions and 14 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View file

@ -1,5 +1,14 @@
<div class="result {{ result.class }}"> <div class="result {{ result.class }}">
<h3 class="result_title"><a href="{{ result.url }}">{{ result.title|safe }}</a></h3>
{% if result['favicon'] %}
<div style="float:left; margin:2px;">
<img width="24" height="24" src="static/img/icon_{{result['favicon']}}.png" alt="{{result['favicon']}}.png" title="{{result['favicon']}}.png" />
</div>
{% endif %}
<div>
<h3 class="result_title"><a href="{{ result.url }}">{{ result.title|safe }}</a></h3></br>
<p class="content">{% if result.content %}{{ result.content|safe }}<br />{% endif %}</p> <p class="content">{% if result.content %}{{ result.content|safe }}<br />{% endif %}</p>
<p class="url">{{ result.pretty_url }}</p> <p class="url">{{ result.pretty_url }}</p>
</div>
</div> </div>

View file

@ -0,0 +1,10 @@
<div id="fr">
{% for result in featured_results %}
{% if result['template'] %}
{% include 'result_templates/'+result['template'] %}
{% else %}
{% include 'result_templates/default.html' %}
{% endif %}
{% endfor %}
</div>

View file

@ -15,16 +15,7 @@
Number of results: {{ number_of_results }} Number of results: {{ number_of_results }}
</div> </div>
{% if featured_results %} {% if featured_results %}
<div id="fr"> {% include 'result_templates/featured_results.html' %}
{% for result in featured_results %}
{% if result['template'] %}
{% include 'result_templates/'+result['template'] %}
{% else %}
{% include 'result_templates/default.html' %}
{% endif %}
{% endfor %}
</div>
{% endif %} {% endif %}
{% for result in results %} {% for result in results %}

View file

@ -140,9 +140,14 @@ def index():
else: else:
result['pretty_url'] = result['url'] result['pretty_url'] = result['url']
if 'wikipedia' in result['engines'] or 'ddg definitions' in result['engines']: for engine in result['engines']:
featured_results.append(result) if engine in ['wikipedia']:
results.remove(result) result['favicon'] = engine
featured_results.append(result)
results.remove(result)
elif engine in ['ddg definitions']:
featured_results.append(result)
results.remove(result)
if request_data.get('format') == 'json': if request_data.get('format') == 'json':
return Response(json.dumps({'query': query, 'results': results}), mimetype='application/json') return Response(json.dumps({'query': query, 'results': results}), mimetype='application/json')