oscar template: implement first version of results page

* implement results page
* improve search form template
* implement all result_templates
* fix youtube engine
This commit is contained in:
Thomas Pointhuber 2014-09-27 12:33:22 +02:00
parent 9158571059
commit f3b565e17e
10 changed files with 127 additions and 15 deletions

View File

@ -69,12 +69,8 @@ def response(resp):
if result['media$group']['media$thumbnail']:
thumbnail = result['media$group']['media$thumbnail'][0]['url']
content += '<a href="{0}" title="{0}" ><img src="{1}" /></a>'.format(url, thumbnail) # noqa
if content:
content += '<br />' + result['content']['$t']
else:
content = result['content']['$t']
content = result['content']['$t']
# append result
results.append({'url': url,

View File

@ -25,3 +25,29 @@ input[type=checkbox]:checked ~ .label_hide_if_checked {
input[type=checkbox]:not(:checked) ~ .label_hide_if_not_checked {
display:none;
}
.search_categories {
margin:10px 0;
}
.result-default {
clear: both;
}
.result-images {
float: left !important;
}
.result-videos {
clear: both;
}
.result-torrents {
clear: both;
}
.img-thumbnail {
margin: 5px;
max-height: 128px;
min-height: 128px;
}

View File

@ -8,7 +8,7 @@
</div>
<div class="row">
<div class="text-center col-sm-12 col-md-12">
{% include 'oscar/search.html' %}
{% include 'oscar/search_full.html' %}
</div>
</div>
</div>

View File

@ -0,0 +1,8 @@
<h3><a href="{{ result.url }}">{{ result.title|safe }}</a></h3>
{% if result.publishedDate %}<time class="text-muted" datetime="{{ result.publishedDate }}" pubdate>{{ result.publishedDate }}</time>{% endif %}
{% if result.content %}<p>{{ result.content|safe }}</p>{% endif %}
<span class="label label-default pull-right">{{ result.engine }}</span>
<p class="text-muted">{% if result['favicon'] %}<img width="14" height="14" class="favicon" src="static/{{ theme }}/img/icon_{{ result['favicon'] }}.ico" />{% endif %} {{ result.pretty_url }}</p>

View File

@ -0,0 +1,21 @@
<a href="#" data-toggle="modal" data-target="#modal-{{ index }}">
<img src="{{ result.img_src }}" alt="{{ result.title|e }}" class="img-thumbnail">
</a>
<div class="modal fade" id="modal-{{ index }}" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<h4 class="modal-title">{{ result.title|striptags }}</h4>
</div>
<div class="modal-body">
<img class="img-responsive center-block" src="{{ result.img_src }}" alt="{{ result.title }}">
</div>
<div class="modal-footer">
<a href="{{ result.img_src }}" class="btn btn-default">{{ _('Get image') }}</a>
<a href="{{ result.url }}" class="btn btn-default">{{ _('View source') }}</a>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,14 @@
{% from 'oscar/macros.html' import icon %}
<h3><a href="{{ result.url }}">{{ result.title|safe }}</a></h3>
{% if result.publishedDate %}<time class="text-muted" datetime="{{ result.publishedDate }}" pubdate>{{ result.publishedDate }}</time>{% endif %}
<p>{{ icon('transfer') }} {{ _('Seeder') }} <span class="badge">{{ result.seed }}</span>, {{ _('Leecher') }} <span class="badge">{{ result.leech }}</span></p>
<p><a href="{{ result.magnetlink }}" class="magnetlink">{{ icon('magnet') }} magnet link</a></p>
{% if result.content %}<p>{{ result.content|safe }}</p>{% endif %}
<span class="label label-default pull-right">{{ result.engine }}</span>
<p class="text-muted">{% if result['favicon'] %}<img width="14" height="14" class="favicon" src="static/{{ theme }}/img/icon_{{ result['favicon'] }}.ico" />{% endif %} {{ result.pretty_url }}</p>

View File

@ -0,0 +1,13 @@
<h3><a href="{{ result.url }}">{{ result.title|safe }}</a></h3>
{% if result.publishedDate %}<time class="text-muted" datetime="{{ result.publishedDate }}" pubdate>{{ result.publishedDate }}</time>{% endif %}
<div class="container-fluid">
<div class="row">
<img class="thumbnail col-xs-6 col-sm-4 col-md-4" src="{{ result.thumbnail|safe }}" />
{% if result.content %}<p class="col-xs-12 col-sm-8 col-md-8">{{ result.content|safe }}</p>{% endif %}
</div>
</div>
<span class="label label-default pull-right">{{ result.engine }}</span>
<p class="text-muted">{% if result['favicon'] %}<img width="14" height="14" class="favicon" src="static/{{theme}}/img/icon_{{result['favicon']}}.ico" />{% endif %} {{ result.pretty_url }}</p>

View File

@ -0,0 +1,22 @@
{% extends "oscar/base.html" %}
{% block title %}{{ q }} - {% endblock %}
{% block content %}
<div class="row">
<div class="col-sm-8" id="main_results">
<h1 class="sr-only">{{ _('Search results') }}</h1>
{% include 'oscar/search.html' %}
{% for result in results %}
<div class="result {% if result['template'] %}result-{{ result.template|replace('.html', '') }}{% else %}result-default{% endif %}">
{% set index = loop.index %}
{% if result.template %}{% include 'oscar/result_templates/'+result['template'] %}{% else %}{% include 'oscar/result_templates/default.html' %}{% endif %}
</div>
{% endfor %}
<div class="clearfix"></div>
</div>
<div class="col-sm-4" id="sidebar_results">
</div>
</div>
{% endblock %}

View File

@ -1,17 +1,12 @@
{% from 'oscar/macros.html' import icon %}
<form method="{{ method or 'POST' }}" action="{{ url_for('index') }}" id="search_form" role="search">
<div class="input-group col-md-8 col-md-offset-2">
<input type="search" name="q" class="form-control input-lg" id="q" placeholder="{{ _('Search for...') }}" autocomplete="off" value="{{ q }}">
<div class="input-group col-sm-12">
<input type="search" name="q" class="form-control" id="q" placeholder="{{ _('Search for...') }}" autocomplete="off" value="{{ q }}">
<span class="input-group-btn">
<button type="submit" class="btn btn-default input-lg">{{ icon('search') }}<span class="sr-only">{{ _('Start search') }}</span></button>
<button type="submit" class="btn btn-default">{{ icon('search') }}<span class="sr-only">{{ _('Start search') }}</span></button>
</span>
</div>
<button type="button" class="btn btn-link btn-collapse center-block collapsed" data-toggle="collapse" data-target="#search_categories" data-btn-text-collapsed="{{ _('Show search filters') }}" data-btn-text-not-collapsed="{{ _('Hide search filters') }}">{{ _('Show search filters') }}</button>
<div class="row collapse" id="search_categories">
<div class="col-md-12 text-center">
<div class="search_categories">
{% include 'oscar/categories.html' %}
</div>
</div><!-- / #search_categories -->
</form><!-- / #search_form_full -->

View File

@ -0,0 +1,17 @@
{% from 'oscar/macros.html' import icon %}
<form method="{{ method or 'POST' }}" action="{{ url_for('index') }}" id="search_form" role="search">
<div class="input-group col-md-8 col-md-offset-2">
<input type="search" name="q" class="form-control input-lg" id="q" placeholder="{{ _('Search for...') }}" autocomplete="off" value="{{ q }}">
<span class="input-group-btn">
<button type="submit" class="btn btn-default input-lg">{{ icon('search') }}<span class="sr-only">{{ _('Start search') }}</span></button>
</span>
</div>
<button type="button" class="btn btn-link btn-collapse center-block collapsed" data-toggle="collapse" data-target="#search_categories" data-btn-text-collapsed="{{ _('Show search filters') }}" data-btn-text-not-collapsed="{{ _('Hide search filters') }}">{{ _('Show search filters') }}</button>
<div class="row collapse" id="search_categories">
<div class="col-md-12 text-center">
{% include 'oscar/categories.html' %}
</div>
</div><!-- / #search_categories -->
</form><!-- / #search_form_full -->