Skip to content

Commit

Permalink
Merge pull request #241 from B2SHARE/search/preview-file-#213
Browse files Browse the repository at this point in the history
Search/preview file #213
  • Loading branch information
llehtine committed Apr 8, 2014
2 parents 9adf4e5 + e03431e commit 9ac0789
Show file tree
Hide file tree
Showing 4 changed files with 155 additions and 13 deletions.
2 changes: 1 addition & 1 deletion deployment/deploy_overlay-rh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if [ -f /opt/invenio/lib/python/invenio/bibfield_functions/is_type_isbn_issn_uni
fi

# add invenio-specific overlay
cp -vf invenio/templates/* /opt/invenio/etc/templates/
cp -vrf invenio/templates/* /opt/invenio/etc/templates/
cp -vrf invenio/lib/* /opt/invenio/lib/python/invenio/
cp -vrf invenio/etc/* /opt/invenio/etc/
cp -vrf invenio/var/* /opt/invenio/var/
Expand Down
10 changes: 4 additions & 6 deletions invenio/lib/bibformat_elements/bfe_fulltext.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def format_element(bfo, style, separator='; ', show_icons='no', focus_on_main_fi
style = 'class="'+style+'"'

if show_icons.lower() == 'yes':
file_icon = '<img style="border:none" src="%s/img/file-icon-text-12x16.gif" alt="%s"/>' % (CFG_SITE_URL, _("Download fulltext"))
file_icon = '<img style="border:none" src="/img/file-icon-text-12x16.gif" alt="%s"/>' % _("Download fulltext")
else:
file_icon = ''

Expand All @@ -87,11 +87,11 @@ def format_element(bfo, style, separator='; ', show_icons='no', focus_on_main_fi

additional_str = ''
if additionals:
additional_str = ' <small>(<a '+style+' href="'+CFG_SITE_URL+'/%s/' % CFG_SITE_RECORD + str(bfo.recID)+'/files/">%s</a>)</small>' % _("additional files")
additional_str = ' <small>(<a '+style+' href="/%s/' % CFG_SITE_RECORD + str(bfo.recID)+'/files/">%s</a>)</small>' % _("additional files")

versions_str = ''
#if old_versions:
#versions_str = ' <small>(<a '+style+' href="'+CFG_SITE_URL+'/CFG_SITE_RECORD/'+str(bfo.recID)+'/files/">%s</a>)</small>' % _("older versions")
#versions_str = ' <small>(<a '+style+' href="/CFG_SITE_RECORD/'+str(bfo.recID)+'/files/">%s</a>)</small>' % _("older versions")

if main_urls:
out = []
Expand Down Expand Up @@ -177,8 +177,6 @@ def format_element(bfo, style, separator='; ', show_icons='no', focus_on_main_fi
out += separator.join(url_list)

if others_urls:
external_link = len(others_urls) == 1 and _('external link') or _('external links')
out += '<strong>%s</strong>: ' % external_link.capitalize()
url_list = []
for url, descr in others_urls:
url_list.append('<a '+style+' href="'+escape(url)+'">'+ \
Expand Down Expand Up @@ -275,7 +273,7 @@ def get_files(bfo, distinguish_main_and_additional_files=True, include_subformat
## This format should be hidden.
continue

descr = _("Fulltext")
descr = filename
if complete_url.has_key('y'):
descr = complete_url['y']
if descr == 'Fulltext':
Expand Down
12 changes: 6 additions & 6 deletions invenio/lib/bibformat_elements/bfe_fulltext_mini.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ def format_element(bfo, style, separator='; ', show_icons='no', focus_on_main_fi
if len(main_urls.keys()) == 1 and len(main_urls.items()[0][1]) == 1 and \
(not CFG_CERN_SITE or len(cern_urls) == 0) and len(others_urls) == 0 and \
show_icons.lower() == 'yes':
file_icon = '<img style="border:none" src="%s/img/file-icon-text-34x48.gif" alt="%s" /><br />' % (CFG_SITE_URL, _("Download fulltext"))
file_icon = '<img style="border:none" src="/img/file-icon-text-34x48.gif" alt="%s" /><br />' % _("Download fulltext")

elif show_icons.lower() == 'yes':
file_icon = '<img style="border:none" src="%s/img/file-icon-text-12x16.gif" alt="%s"/>' % (CFG_SITE_URL, _("Download fulltext"))
file_icon = '<img style="border:none" src="/img/file-icon-text-12x16.gif" alt="%s"/>' % _("Download fulltext")
else:
file_icon = ''

Expand Down Expand Up @@ -110,10 +110,10 @@ def format_element(bfo, style, separator='; ', show_icons='no', focus_on_main_fi
if len(main_urls.keys()) == 0 and \
len(cern_urls) == 1 and len(others_urls) == 0 and \
show_icons.lower() == 'yes':
file_icon = '<img style="border:none" src="%s/img/file-icon-text-34x48.gif" alt="%s" /><br />' % (CFG_SITE_URL, _("Download fulltext"))
file_icon = '<img style="border:none" src="/img/file-icon-text-34x48.gif" alt="%s" /><br />' % _("Download fulltext")

elif show_icons.lower() == 'yes':
file_icon = '<img style="border:none" src="%s/img/file-icon-text-12x16.gif" alt="%s"/>' % (CFG_SITE_URL, _("Download fulltext"))
file_icon = '<img style="border:none" src="/img/file-icon-text-12x16.gif" alt="%s"/>' % _("Download fulltext")
else:
file_icon = ''

Expand All @@ -130,9 +130,9 @@ def format_element(bfo, style, separator='; ', show_icons='no', focus_on_main_fi
if len(main_urls.keys()) == 0 and \
(not CFG_CERN_SITE or len(cern_urls) == 0) and len(others_urls) == 1 and \
show_icons.lower() == 'yes':
file_icon = '<img style="border:none" src="%s/img/file-icon-text-34x48.gif" alt="%s" /><br />' % (CFG_SITE_URL, _("Download fulltext"))
file_icon = '<img style="border:none" src="/img/file-icon-text-34x48.gif" alt="%s" /><br />' % _("Download fulltext")
elif show_icons.lower() == 'yes':
file_icon = '<img style="border:none" src="%s/img/file-icon-text-12x16.gif" alt="%s"/>' % (CFG_SITE_URL, _("Download fulltext"))
file_icon = '<img style="border:none" src="/img/file-icon-text-12x16.gif" alt="%s"/>' % _("Download fulltext")
else:
file_icon = ''
external_link = len(others_urls) == 1 and _('external link') or _('external links')
Expand Down
144 changes: 144 additions & 0 deletions invenio/templates/format_templates/Default_HTML_brief.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
{% macro render_record_footer(number_of_displayed_authors) %}
<p>
{% if record.get('number_of_authors', 0) > 0 %}
<i class="icon-user"></i> by
{% set authors = record.get('authors[:].full_name', []) %}
{% set sep = joiner("; ") %}
{% for full_name in authors[0:number_of_displayed_authors] %} {{ sep() }}
<a href="{{ url_for('search.search', p='author:"' + full_name + '"') }}">
{{ full_name }}
</a>
{% endfor %}
{% if record.get('number_of_authors', 0) > number_of_displayed_authors %}
{{ sep() }}
<a href="#authors_{{ record['recid'] }}"
class="muted" data-toggle="modal"
data-target="#authors_{{ record['recid'] }}">
<em>{{ _(' et al') }}</em>
</a>
{% endif %}

|
{% endif %}
<i class="icon-calendar"></i> {{ record['creation_date']|invenio_format_date() }}
{# Citations link #}
{%- if config.CFG_BIBRANK_SHOW_CITATION_LINKS -%}
{%- set num_citations = record['_cited_by_count'] -%}
{%- if num_citations -%}
|
<a href="{{ url_for('.search', p="refersto:recid:%d" % recid) }}">
<i class="icon-share"></i>
{{ _("%i citations") % num_citations if num_citations > 1 else _("1 citation") }}
</a>
{%- endif -%}
{%- endif -%}

{# Comments link #}
{%- if config.CFG_WEBCOMMENT_ALLOW_COMMENTS and config.CFG_WEBSEARCH_SHOW_COMMENT_COUNT -%}
{%- set num_comments = record['_number_of_comments'] -%}
{%- if num_comments -%}
|
<a href="{{ url_for('webcomment.comments', recid=recid) }}">
<i class="icon-comment"></i>
{{ _("%i comments") % num_comments if num_comments > 1 else _("1 comment") }}
</a>
{%- endif -%}
{%- endif -%}

{# Reviews link #}
{%- if config.CFG_WEBCOMMENT_ALLOW_REVIEWS and config.CFG_WEBSEARCH_SHOW_REVIEW_COUNT -%}
{%- set num_reviews = record['_number_of_reviews'] -%}
{%- if num_reviews -%}
|
<a href="{{ url_for('webcomment.reviews', recid=recid) }}">
<i class="icon-eye-open"></i>
{{ _("%i reviews") % num_reviews if num_reviews > 1 else _("1 review") }}
</a>
{%- endif -%}
{%- endif -%}

| <a href="{{ url_for('search.search', p='recid:%s' % recid, rm='wrd') }}">{{ _("Similar records") }}</a>

{% if record['keywords']|length %} | <i class="icon-tag"></i>
{% for keyword in record['keywords'] %}
<span class="label">
<a href="{{ url_for('search.search', p='keyword:' + keyword['term']) }}">
{{ keyword['term'] }}
</a>
</span>
{% endfor %}
{% endif %}

{# WebTags #}
{{ tfn_webtag_record_tags(record['recid'], current_user.get_id())|prefix('|') }}
</p>
{% if record.get('number_of_authors', 0) > number_of_displayed_authors %}
{% set sep = joiner("; ") %}
<div id="authors_{{ record['recid'] }}" class="modal hide fade">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3>{{ _('Authors') }}</h3>
</div>
<div class="modal-body">
{% for full_name in authors %} {{ sep() }}
<a href="{{ url_for('search.search', p='author:"' + full_name + '"') }}">
{{ full_name }}
</a>
{% endfor %}
</div>
</div>
{% endif %}
{% endmacro %}

{% macro render_fulltext_snippets() %}
{{ tfn_get_fulltext_snippets(record['recid'], request.args['p'], current_user) | wrap(prefix='<p><small>', suffix='</small></p>') }}
{% endmacro %}

{% macro record_info() %}
{{ bfe_primary_report_number(bfo, prefix='<i class="icon-qrcode"></i> ') }}
{{ bfe_additional_report_numbers(bfo, prefix='<i class="icon-qrcode"></i> ',
separator=' <i class="icon-qrcode"></i> ') }}

{{ bfe_publi_info(bfo, prefix='| <i class="icon-book"></i> ') }}
{{ bfe_doi(bfo, prefix='| <i class="icon-barcode"></i> ') }}
{# '<a href="http://dx.doi.org/%(doi)s" title="DOI" target="_blank"><i class="icon-barcode"></i> %(doi)s</a>'|format(doi=record['doi']) if record.get('doi') #}

{% endmacro %}

{% block record_brief %}
<div class="htmlbrief">
{{ bfe_fulltext(bfo, show_icons="yes",
prefix='<ul class="nav nav-pills pull-right" style="margin-top: -10px;"><li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" rel="tooltip" title="Download" href="#"><i class="icon-download-alt"></i><span class="caret"></span></a><ul class="dropdown-menu pull-right"><li>',
suffix='</li></ul></li></ul>', focus_on_main_file="yes", separator="</li><li>") }}
{% block record_header %}
<h4 class="media-heading">
<a href="{{ url_for('record.metadata', recid=record['recid']) }}">
{{ record.get('title.title', '') }}
{{- record.get('title.volume', '')|prefix(', ') }}
{{- record.get('title.subtitle', '')|prefix(': ') }}
{{- record.get('edition_statement', '')|prefix('; ') }}
</a>
</h4>
{% endblock %}
{% block record_content %}
<div>
<p class="record-abstract">
{{ record.get('abstract.summary', '')|sentences(3) }}
</p>

<p class="record-info">
{{ record_info() }}
</p>
</div>
{% endblock %}

<div class="clearfix"></div>
{% block fulltext_snippets %}
{{ render_fulltext_snippets() }}
{% endblock %}

{% block record_footer %}
{{ render_record_footer(4) }}
{% endblock %}
</div>
{% endblock %}

0 comments on commit 9ac0789

Please sign in to comment.