Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F84088478
bfe_plots_thumb.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Sep 20, 16:24
Size
2 KB
Mime Type
text/x-python
Expires
Sun, Sep 22, 16:24 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
20938318
Attached To
R3600 invenio-infoscience
bfe_plots_thumb.py
View Options
# -*- coding: utf-8 -*-
##
## $Id: bfe_CERN_plots.py,v 1.3 2009/03/17 10:55:15 jerome Exp $
##
## This file is part of Invenio.
## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 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.
"""BibFormat element - Display image of the plot if we are in selected plots collection
"""
__revision__
=
"$Id: bfe_CERN_plots.py,v 1.3 2009/03/17 10:55:15 jerome Exp $"
from
invenio.bibdocfile
import
BibRecDocs
from
invenio.urlutils
import
create_html_link
from
invenio.config
import
CFG_SITE_URL
def
format_element
(
bfo
):
"""
Display image of the thumbnail plot if we are in selected plots collections
"""
## To achieve this, we take the Thumb file associated with this document
bibarchive
=
BibRecDocs
(
bfo
.
recID
)
img_files
=
[]
for
doc
in
bibarchive
.
list_bibdocs
():
for
_file
in
doc
.
list_latest_files
():
if
_file
.
get_type
()
==
"Plot"
:
caption_text
=
_file
.
get_description
()[
5
:]
index
=
int
(
_file
.
get_description
()[:
5
])
img_location
=
_file
.
get_url
()
if
img_location
==
""
:
continue
img
=
'<img src="
%s
" width="100px"/>'
%
\
(
img_location
)
img_files
.
append
((
index
,
img_location
))
# FIXME: was link here
if
_file
.
get_type
()
==
"Thumb"
:
img_location
=
_file
.
get_url
()
img
=
'<img src="
%s
" width="100px"/>'
%
\
(
img_location
)
return
'<div align="left">'
+
img
+
'</div>'
# then we use the default: the last plot with an image
img_files
=
sorted
(
img_files
,
key
=
lambda
x
:
x
[
0
])
if
img_files
:
return
'<div align="left">'
+
img_files
[
-
1
][
1
]
+
'</div>'
else
:
return
''
def
escape_values
(
bfo
):
"""
Called by BibFormat in order to check if output of this element
should be escaped.
"""
return
0
Event Timeline
Log In to Comment