Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ Contents
natively in UTF-8 mode by setting "default-character-set=utf8"
in various parts of your "my.cnf" file, such as in the
"[mysql]" part and elsewhere; but this is not really required.
Note also that you may encounter problems when MySQL is run in
"strict mode"; you may want to configure your "my.cnf" in order
to avoid using strict mode (such as `STRICT_ALL_TABLES`).
<http://mysql.com/>

c) Redis server (may be on a remote machine) for user session
Expand Down Expand Up @@ -313,6 +316,7 @@ Contents
$ make install
$ make install-mathjax-plugin ## optional
$ make install-jquery-plugins ## optional
$ make install-font-awesome ## optional
$ make install-ckeditor-plugin ## optional
$ make install-pdfa-helper-files ## optional
$ make install-mediaelement ## optional
Expand Down Expand Up @@ -522,6 +526,16 @@ Contents

Note that `unzip' is needed when installing jquery plugins.

$ make install-font-awesome ## optional

This will automatically download and install Font Awesome,
the iconic font and CSS framework.

Note that in order to include Font Awesome in the HTML head
you have to set the CFG_WEBSTYLE_SUPPORT_FONTAWESOME to True

Note that `unzip' is needed when installing Font Awesome.

$ make install-ckeditor-plugin ## optional

This will automatically download and install in the proper
Expand Down
35 changes: 34 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# This file is part of Invenio.
# Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 CERN.
# Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
# 2011, 2012, 2013, 2014, 2015, 2016 CERN.
#
# Invenio is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
Expand Down Expand Up @@ -265,6 +266,38 @@ uninstall-jquery-plugins:
@echo "** The jquery plugins were successfully uninstalled. **"
@echo "***********************************************************"

install-font-awesome:
@echo "***********************************************************"
@echo "** Installing Font Awesome, please wait... **"
@echo "***********************************************************"
rm -rf /tmp/font-awesome
mkdir /tmp/font-awesome
mkdir -p ${prefix}/var/www/static/css
mkdir -p ${prefix}/var/www/static/fonts
(cd /tmp/font-awesome && \
wget 'https://fortawesome.github.io/Font-Awesome/assets/font-awesome-4.5.0.zip' && \
unzip -u font-awesome-4.5.0.zip && \
mv font-awesome-4.5.0/css/font-awesome.min.css ${prefix}/var/www/static/css && \
mv font-awesome-4.5.0/fonts/* ${prefix}/var/www/static/fonts)
rm -rf /tmp/font-awesome
@echo "***********************************************************"
@echo "** Font Awesome was successfully installed. **"
@echo "** It is disabled by default. To enable it, edit **"
@echo "** CFG_WEBSTYLE_SUPPORT_FONTAWESOME in invenio.conf. **"
@echo "***********************************************************"

uninstall-font-awesome:
@rm -vf ${prefix}/var/www/static/css/font-awesome.min.css
@rm -vf ${prefix}/var/www/static/fonts/FontAwesome.otf
@rm -vf ${prefix}/var/www/static/fonts/fontawesome-webfont.eot
@rm -vf ${prefix}/var/www/static/fonts/fontawesome-webfont.svg
@rm -vf ${prefix}/var/www/static/fonts/fontawesome-webfont.ttf
@rm -vf ${prefix}/var/www/static/fonts/fontawesome-webfont.woff
@rm -vf ${prefix}/var/www/static/fonts/fontawesome-webfont.woff2
@echo "***********************************************************"
@echo "** Font Awesome was successfully uninstalled. **"
@echo "***********************************************************"

install-ckeditor-plugin:
@echo "***********************************************************"
@echo "** Installing CKeditor plugin, please wait... **"
Expand Down
4 changes: 4 additions & 0 deletions THANKS
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,8 @@ contributed by Yoav Goldberg <yoav.goldberg@gmail.com>, new version by
Jason Kirtland from Python cookbook.
<http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/523034>

Some icons are used from the iconic font and CSS toolkit
Font Awesome by Dave Gandy.
<http://fontawesome.io>

- end of file -
4 changes: 4 additions & 0 deletions config/invenio.conf
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,10 @@ CFG_WEBSTYLE_CDSPAGEBOXRIGHTTOP =
# HTML right bottom box:
CFG_WEBSTYLE_CDSPAGEBOXRIGHTBOTTOM =

# CFG_WEBSTYLE_SUPPORT_FONTAWESOME -- enables Font Awesome, the iconic
# font and CSS framework.
CFG_WEBSTYLE_SUPPORT_FONTAWESOME = False

# CFG_WEBSTYLE_HTTP_STATUS_ALERT_LIST -- when certain HTTP status
# codes are raised to the WSGI handler, the corresponding exceptions
# and error messages can be sent to the system administrator for
Expand Down
65 changes: 59 additions & 6 deletions modules/bibdocfile/lib/bibdocfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import cgi
import sys
import copy
import tarfile

if sys.hexversion < 0x2060000:
from md5 import md5
Expand Down Expand Up @@ -102,6 +103,7 @@
encode_for_xml
from invenio.urlutils import create_url, make_user_agent_string
from invenio.textutils import nice_size
from invenio.webuser import collect_user_info
from invenio.access_control_engine import acc_authorize_action
from invenio.access_control_admin import acc_is_user_in_role, acc_get_role_id
from invenio.access_control_firerole import compile_role_definition, acc_firerole_check_user
Expand All @@ -123,7 +125,7 @@
CFG_BIBCATALOG_SYSTEM
from invenio.bibcatalog import BIBCATALOG_SYSTEM
from invenio.bibdocfile_config import CFG_BIBDOCFILE_ICON_SUBFORMAT_RE, \
CFG_BIBDOCFILE_DEFAULT_ICON_SUBFORMAT
CFG_BIBDOCFILE_DEFAULT_ICON_SUBFORMAT, CFG_BIBDOCFILE_STREAM_ARCHIVE_FORMATS
from invenio.pluginutils import PluginContainer

import invenio.template
Expand Down Expand Up @@ -797,17 +799,22 @@ def get_xml_8564(self):

return out

def get_total_size_latest_version(self):
def get_total_size_latest_version(self, user_info=None, subformat=None):
"""
Returns the total size used on disk by all the files belonging
to this record and corresponding to the latest version.

@param user_info: the user_info dictionary, used to check restrictions
@type: dict
@param subformat: if subformat is specified, it limits files
only to those from that specific subformat
@type subformat: string
@return: the total size.
@rtype: integer
"""
size = 0
for (bibdoc, _) in self.bibdocs.values():
size += bibdoc.get_total_size_latest_version()
size += bibdoc.get_total_size_latest_version(user_info, subformat)
return size

def get_total_size(self):
Expand Down Expand Up @@ -1564,6 +1571,36 @@ def get_text(self, extract_text_if_necessary=True):

return " ".join(texts)

def stream_archive_of_latest_files(self, req, files_size=''):
"""
Streams the tar archive with all files of a certain file size (that
are not restricted or hidden) to the user.
File size should be a string that can be compared with the output of
BibDocFile.get_subformat() function.

@param req: Apache Request Object
@type req: Apache Request Object
@param files_size: size of the files (they can be defined in
bibdocfile_config). Empty string means the original size.
@type files_size: string
"""
# Get the internal size from the user-friendly file size name
internal_format = [f[1] for f in CFG_BIBDOCFILE_STREAM_ARCHIVE_FORMATS if f[0] == files_size]
if len(internal_format) < 1:
# Incorrect file size
return
internal_format = internal_format[0]
tarname = str(self.id) + "_" + files_size + '.tar'

# Select files that user can download (not hidden nor restricted)
user_info = collect_user_info(req)
req.content_type = "application/x-tar"
req.headers_out["Content-Disposition"] = 'attachment; filename="%s"' % tarname
tar = tarfile.open(fileobj=req, mode='w|')
for f in self.list_latest_files():
if f.get_subformat() == internal_format and f.is_restricted(user_info)[0] == 0 and not f.hidden:
tar.add(f.get_path(), arcname=f.get_full_name(), recursive=False)
tar.close()

class BibDoc(object):
"""
Expand Down Expand Up @@ -2801,12 +2838,28 @@ def _build_related_file_list(self):
cur_doc = BibDoc.create_instance(docid=docid, human_readable=self.human_readable)
self.related_files[doctype].append(cur_doc)

def get_total_size_latest_version(self):
def get_total_size_latest_version(self, user_info=None, subformat=None):
"""Return the total size used on disk of all the files belonging
to this bibdoc and corresponding to the latest version."""
to this bibdoc and corresponding to the latest version. Restricted
and hidden files are not counted, unless there is no user_info.
@param user_info: the user_info dictionary, used to check restrictions
@type: dict
@param subformat: if subformat is specified, it limits files
only to those from that specific subformat
@type subformat: string
"""
ret = 0
all_files = False
# If we are calling this function without user_info, then we want to
# see all the files
if not user_info:
all_files = True
for bibdocfile in self.list_latest_files():
ret += bibdocfile.get_size()
# First check for restrictions
if all_files or (bibdocfile.is_restricted(user_info)[0] == 0 and not bibdocfile.hidden):
# Then check if the format is correct
if subformat is None or bibdocfile.get_subformat() == subformat:
ret += bibdocfile.get_size()
return ret

def get_total_size(self):
Expand Down
9 changes: 9 additions & 0 deletions modules/bibdocfile/lib/bibdocfile_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,12 @@
# CFG_BIBDOCFILE_DEFAULT_ICON_SUBFORMAT -- this is the default subformat used
# when creating new icons.
CFG_BIBDOCFILE_DEFAULT_ICON_SUBFORMAT = "icon"

# CFG_BIBDOCFILE_STREAM_ARCHIVE_FORMATS -- a list (not dictionary, because
# we want to preserve the order) that connects the different format sizes
# (like 'small', 'medium', etc.) with internal format sizes (like 'icon-180', 'icon-640', etc.)
CFG_BIBDOCFILE_STREAM_ARCHIVE_FORMATS = [
('small', 'icon-180'),
('medium', 'icon-640'),
('large', 'icon-1440'),
('original', '')]
6 changes: 6 additions & 0 deletions modules/bibdocfile/lib/bibdocfile_webinterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ def _lookup(self, component, path):
def getfile(req, form):
args = wash_urlargd(form, bibdocfile_templates.files_default_urlargd)
ln = args['ln']
if filename[:9] == "allfiles-":
files_size = filename[9:]
# stream a tar package to the user
brd = BibRecDocs(self.recid)
brd.stream_archive_of_latest_files(req, files_size)
return

_ = gettext_set_language(ln)

Expand Down
6 changes: 5 additions & 1 deletion modules/bibformat/lib/bibreformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,11 @@ def task_run_core():
if task_has_option("last"):
recids += outdated_caches(fmt, last_updated)

if task_has_option('ignore_without'):
if task_has_option('ignore_without') or \
task_has_option('collection') or \
task_has_option('field') or \
task_has_option('pattern') or \
task_has_option('recids'):
without_fmt = intbitset()
else:
without_fmt = missing_caches(fmt)
Expand Down
2 changes: 1 addition & 1 deletion modules/webaccess/doc/hacking/webaccess-api.webdoc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<pre>
Invenio Access Control Engine can be called from within your Python programs
via both a regular Python API and CLI.
In addition the you get an explanation of the program flow.
In addition to the above features, you also get an explanation of the program flow.

Contents:
1. Regular API
Expand Down
13 changes: 10 additions & 3 deletions modules/websearch/lib/search_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@
InvenioWebSearchReferstoLimitError, \
InvenioWebSearchCitedbyLimitError, \
CFG_WEBSEARCH_IDXPAIRS_FIELDS,\
CFG_WEBSEARCH_IDXPAIRS_EXACT_SEARCH
CFG_WEBSEARCH_IDXPAIRS_EXACT_SEARCH, \
CFG_WEBSEARCH_BLACKLISTED_FORMATS
from invenio.search_engine_utils import (get_fieldvalues,
get_fieldvalues_alephseq_like,
record_exists)
Expand Down Expand Up @@ -1711,14 +1712,20 @@ def get_synonym_terms(term, kbr_name, match_type, use_memoise=False):
return dterms.keys()


def wash_output_format(ouput_format):
def wash_output_format(ouput_format, verbose=False, req=None):
"""Wash output format FORMAT. Currently only prevents input like
'of=9' for backwards-compatible format that prints certain fields
only. (for this task, 'of=tm' is preferred)"""
if str(ouput_format[0:3]).isdigit() and len(ouput_format) != 6:
# asked to print MARC tags, but not enough digits,
# so let's switch back to HTML brief default
return 'hb'
elif format in CFG_WEBSEARCH_BLACKLISTED_FORMATS:
if verbose:
write_warning("Selected format is not available through perform_request_search", req=req)
# Returning an empty list seems dangerous because you wouldn't know
# right away that the list is not supposed to be empty.
return 'hb'
else:
return ouput_format

Expand Down Expand Up @@ -5714,7 +5721,7 @@ def prs_wash_arguments(req=None, cc=CFG_SITE_NAME, c=None, p="", f="", rg=CFG_WE
"""

# wash output format:
of = wash_output_format(of)
of = wash_output_format(of, verbose=verbose, req=req)

# wash all arguments requiring special care
p = wash_pattern(p)
Expand Down
5 changes: 5 additions & 0 deletions modules/websearch/lib/search_engine_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
# interfaces (0=simple, 1=advanced, 2=add-to-search):
CFG_WEBSEARCH_ENABLED_SEARCH_INTERFACES = [0,1,2]

# CFG_WEBSEARCH_BLACKLISTED_FORMATS -- list of formats that will be refused
# by perform_request_search:
# * recstruct is an internal format thus should not be exposed
CFG_WEBSEARCH_BLACKLISTED_FORMATS = ["recstruct", "wapaff", "wapdat"]


class InvenioWebSearchUnknownCollectionError(Exception):
"""Exception for bad collection."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_async_download(self):
## - test 1 bad IP: 1.2.3.4
## Return the list of errors.
checks = [
{'url': 'http://invenio-software.org', 'content': 'About Invenio'},
{'url': 'http://invenio-software.org', 'content': 'Invenio'},
{'url': 'http://rjfreijoiregjreoijgoirg.fr'},
{'url': 'http://1.2.3.4/'}]

Expand Down
9 changes: 8 additions & 1 deletion modules/webstyle/lib/webstyle_templates.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# This file is part of Invenio.
# Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 CERN.
# Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013,
# 2014, 2016 CERN.
#
# Invenio is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
Expand Down Expand Up @@ -38,6 +39,7 @@
CFG_SITE_URL, \
CFG_VERSION, \
CFG_WEBSTYLE_INSPECT_TEMPLATES, \
CFG_WEBSTYLE_SUPPORT_FONTAWESOME, \
CFG_WEBSTYLE_TEMPLATE_SKIN, \
CFG_INSPIRE_SITE, \
CFG_WEBLINKBACK_TRACKBACK_ENABLED
Expand Down Expand Up @@ -374,6 +376,7 @@ def tmpl_pageheader(self, req, ln=CFG_SITE_LANG, headertitle="",
%(metabase)s
<link rev="made" href="mailto:%(sitesupportemail)s" />
<link rel="stylesheet" href="%(cssurl)s/img/invenio%(cssskin)s.css" type="text/css" />
%(font_awesome)s
<!--[if lt IE 8]>
<link rel="stylesheet" type="text/css" href="%(cssurl)s/img/invenio%(cssskin)s-ie7.css" />
<![endif]-->
Expand Down Expand Up @@ -460,6 +463,10 @@ def tmpl_pageheader(self, req, ln=CFG_SITE_LANG, headertitle="",
'canonical_and_alternate_urls' : self.tmpl_canonical_and_alternate_urls(uri),
'cssurl' : CFG_BASE_URL,
'cssskin' : CFG_WEBSTYLE_TEMPLATE_SKIN != 'default' and '_' + CFG_WEBSTYLE_TEMPLATE_SKIN or '',
'font_awesome': (
'<link rel="stylesheet"'
'href="/static/css/font-awesome.min.css">') if (
CFG_WEBSTYLE_SUPPORT_FONTAWESOME) else '',
'rssurl': rssurl,
'ln' : ln,
'ln_iso_639_a' : ln.split('_', 1)[0],
Expand Down
8 changes: 6 additions & 2 deletions modules/websubmit/lib/functions/Stamp_Uploaded_Files.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,8 @@ def visit_for_stamping(visit_for_stamping_arguments, dirname, filenames):
'file_stamper_options' members.
@param dirname: (string) - the path to the directory in which the
files are to be stamped.
@param filenames: (list) - the names of each file in dirname. An
attempt will be made to stamp each of these files.
@param filenames: (list) - the names of each file and subdirectory in
dirname. An attempt will be made to stamp each of the files.
@Exceptions Raised:
+ InvenioWebSubmitFunctionWarning;
+ InvenioWebSubmitFunctionError;
Expand Down Expand Up @@ -345,6 +345,10 @@ def visit_for_stamping(visit_for_stamping_arguments, dirname, filenames):
path_to_subject_file = "%s/%s" % (dirname, file_to_stamp)
file_stamper_options['input-file'] = path_to_subject_file

if not os.path.isfile(path_to_subject_file):
# If it's not a file, we can't stamp it. Continue with next file
continue

## Just before attempting to stamp the file, log the dictionary of
## options (file_stamper_options) that will be passed to websubmit-
## file-stamper:
Expand Down