Page MenuHomec4science

websearch_results.html
No OneTemporary

File Metadata

Created
Tue, Mar 25, 03:33

websearch_results.html

{#
## This file is part of Invenio.
## Copyright (C) 2012 CERN.
##
## Invenio is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 2 of the
## License, or (at your option) any later version.
##
## Invenio is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Invenio; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#}
{% from "websearch_helpers.html" import record_brief_links with context %}
{% macro render_search_pagination(pagination) %}
{%- set args = request.args.copy().to_dict() -%}
{%- set form_args = request.form.copy().to_dict() -%}
{%- if form_args|length() and 'filter' in form_args -%}
{%- do form_args.pop('filter') -%}
{%- do args.update(form_args) -%}
{%- set hash_tag = '#'+request.form.get('filter','') -%}
{%- else -%}
{%- set hash_tag = '' -%}
{%- endif -%}
<div style="margin:0px;" class="pagination pull-right">
<ul>
<li{{ ' class="disabled"'|safe if not pagination.has_prev }}>
{%- do args.update({'jrec': 1}) -%}
<a title="first" href="{{ url_for('search.search', **args)+hash_tag }}">«</a></li>
<li{{ ' class="disabled"'|safe if not pagination.has_prev }}>
{%- set jrec = (pagination.page-1)*pagination.per_page if pagination.has_prev else 1 -%}
{%- do args.update({'jrec': jrec}) -%}
<a title="prev" href="{{ url_for('search.search', **args)+hash_tag }}">&lsaquo;</a></li>
{%- for page in pagination.iter_pages() %}
{%- if page -%}
<li{{ ' class="active"'|safe if page == pagination.page }}>
{%- do args.update({'jrec': (page-1)*pagination.per_page+1}) -%}
<a href="{{ url_for('search.search', **args)+hash_tag }}">{{ page }}</a>
</li>
{%- else -%}
<li class="disabled"><a href="{{ hash_tag|default('#', true) }}">...</a></li>
{%- endif -%}
{%- endfor -%}
<li{{ ' class="disabled"'|safe if not pagination.has_next }}>
{%- set jrec = (pagination.page+1)*pagination.per_page if pagination.has_next else (pagination.pages-1)*pagination.per_page+1 -%}
{%- do args.update({'jrec': jrec}) -%}
<a href="{{ url_for('search.search', **args)+hash_tag }}">&rsaquo;</a></li>
<li{{ ' class="disabled"'|safe if not pagination.has_next }}>
{%- do args.update({'jrec': (pagination.pages-1)*pagination.per_page+1}) -%}
<a title="last" href="{{ url_for('search.search', **args)+hash_tag }}">»</a>
</li>
</ul>
</div>
{% endmacro %}
{% macro render_search_results(recids, collection, pagination, format_record) %}
<form class="form-horizontal" name="addtobasket" action="{{ url_for('yourbaskets.add') }}" method="post">
<div class="row">
<div class="span10" style="line-height: 28px;">
<span class="btn-group" style="float:left; margin-right: 18px;">
<span onclick="$('[name=recid]').prop('checked', function() {return !$(this).prop('checked')});" class="btn" rel="tooltip" title="{{ _('Toggle all') }}">
<i class="icon icon-check"></i>
</span>
<button class="btn" rel="tooltip" title="{{ _('Add to basket') }}">
<i class="icon icon-bookmark"></i>
</button>
</span>
{%- set r_from = (pagination.page-1)*pagination.per_page+1 -%}
{%- set r_to = pagination.page*pagination.per_page -%}
{%- set r_of = recids|length -%}
{%- set r_to = r_to if r_to < r_of else r_of -%}
{{ _('Showing recods %d to %d out of %d results.') % (r_from, r_to, r_of) }}
<div class="btn-group pull-right">
{%- for (k,v) in [('Most recent',{'so':'d'}), ('Most cited',{'rm':'citation'}), ('Most relevant',{'rm':'wrd'})] -%}
{%- set args = request.args.copy().to_dict() -%}
{%- set form_args = request.form.copy().to_dict() -%}
{%- if form_args|length() and 'filter' in form_args -%}
{%- do form_args.pop('filter') -%}
{%- do args.update(form_args) -%}
{%- endif -%}
{%- set active = v.keys()[0] in args and args[v.keys()[0]] == v.values()[0] -%}
{%- if active -%}
{%- do args.pop(v.keys()[0]) -%}
{%- else -%}
{%- do args.update(v) -%}
{%- endif -%}
<a href="{{ url_for('search.search', **args) }}{{ '#'+request.form.get('filter','')|default('', true) }}"
class="btn{{ ' active' if active }}">{{ _(k) }}</a>
{%- endfor -%}
</div>
</div>
</div>
<hr/>
{%- set of = request.args.get('of', 'hb') -%}
{%- for recid in recids[(pagination.page-1)*rg:pagination.page*rg] -%}
{%- if of[0] == 'h' -%}
<div class="row-fluid">
<div class="span1">
<label class="pull-right">
<input type="checkbox" name="recid" value="{{ recid }}" />
<abbr class="unapi-id" title="{{ recid }}"></abbr>
{{ loop.index+(pagination.page-1)*rg }}
</label>
</div>
<div class="span11">
{{ format_record(recid, of, ln=g.ln)|safe }}
{{ record_brief_links(recid) }}
</div>
</div>
{%- else -%}
{{ format_record(recid, of, ln=g.ln) }}
{%- endif -%}
{%- endfor -%}
<hr/>
<div class="row">
<div class="span10">
<span class="btn-group">
<span onclick="$('[name=recid]').prop('checked', function() {return !$(this).prop('checked')});" class="btn" rel="tooltip" title="{{ _('Toggle all') }}">
<i class="icon icon-check"></i>
</span>
<button class="btn" rel="tooltip" title="{{ _('Add to basket') }}">
<i class="icon icon-bookmark"></i>
</button>
</span>
{{ render_search_pagination(pagination) }}
</div>
</div>
</form>
{% endmacro %}
{{ render_search_results(recids, collection, pagination, format_record) }}

Event Timeline