Skip to content

Commit

Permalink
WebSubmit: auto-completion for authors
Browse files Browse the repository at this point in the history
* NEW Provides an author auto-completion facility for WebSubmit. The
  author auto-completion interface can easily be configured for each
  submission. Author sources can be defined as plugins that return
  results in JSON. (closes inveniosoftware#2276) (PR inveniosoftware#2893)

* Author submission and modification are fully compatible with existing
  BibConvert templates.

* Uses typeahead.js for autocompletion.

Co-authored-by: Harris Tzovanakis <[email protected]>
Co-authored-by: Esteban J. G. Gabancho <[email protected]>
Co-authored-by: Nikolaos Kasioumis <[email protected]>
Co-authored-by: Sebastian Witowski <[email protected]>
Signed-off-by: Nikolaos Kasioumis <[email protected]>
  • Loading branch information
5 people authored and tiborsimko committed Mar 31, 2016
1 parent a018bdb commit bd691cd
Show file tree
Hide file tree
Showing 24 changed files with 1,391 additions and 45 deletions.
8 changes: 8 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ install-jquery-plugins:
wget -N --no-check-certificate http://invenio-software.org/download/jquery/parsley.js &&\
wget -N --no-check-certificate http://invenio-software.org/download/jquery/spin.min.js &&\
rm -f jquery.bookmark.package-1.4.0.zip && \
wget https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.3.0/handlebars.min.js && \
wget https://twitter.github.com/typeahead.js/releases/0.10.5/typeahead.bundle.min.js && \
wget https://raw.githubusercontent.com/es-shims/es5-shim/v4.0.3/es5-shim.min.js && \
wget https://raw.githubusercontent.com/es-shims/es5-shim/v4.0.3/es5-shim.map && \
mkdir -p ${prefix}/var/www/img && \
cd ${prefix}/var/www/img && \
wget -r -np -nH --cut-dirs=4 -A "png,css" -P jquery-ui/themes http://jquery-ui.googlecode.com/svn/tags/1.8.17/themes/base/ && \
Expand Down Expand Up @@ -236,6 +240,10 @@ uninstall-jquery-plugins:
rm -f jquery.dataTables.min.js && \
rm -f ui.core.js && \
rm -f jquery.bookmark.min.js && \
rm -f handlebars.min.js && \
rm -f typeahead.bundle.min.js && \
rm -f es5-shim.min.js && \
rm -f es5-shim.map && \
rm -f jquery.dataTables.ColVis.min.js && \
rm -f jquery.hotkeys.js && \
rm -f jquery.tablesorter.min.js && \
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,7 @@ AC_CONFIG_FILES([config.nice \
modules/websubmit/etc/Makefile \
modules/websubmit/lib/Makefile \
modules/websubmit/lib/functions/Makefile \
modules/websubmit/lib/author_sources/Makefile \
modules/websubmit/web/Makefile \
modules/websubmit/web/admin/Makefile \
modules/docextract/Makefile \
Expand Down
18 changes: 18 additions & 0 deletions modules/bibfield/lib/bibfield_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,3 +443,21 @@ def _validate(self, document, schema=None, update=False):
self._validate_required_fields()

return len(self._errors) == 0

def retrieve_authorid_type(id_string):
"""Retrieve the type part of the author id_string (e.g. inspireid)."""

if not id_string or type(id_string) is not str:
return ""
if id_string.find("|(") != -1 and id_string.split("|(")[1].find(")") != -1:
return id_string.split("|(")[1].split(")")[0]
return "id"

def retrieve_authorid_id(id_string):
"""Retrieve the id part of the author id_string."""

if not id_string or type(id_string) is not str:
return ""
if id_string.find("|(") != -1 and id_string.split("|(")[1].find(")") != -1:
return id_string.split(")")[1]
return ""
27 changes: 15 additions & 12 deletions modules/miscutil/demo/democfgdata.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1211,7 +1211,7 @@ INSERT INTO sbmFIELD VALUES ('SRVDEMOPIC',1,2,'DEMOPIC_CONT','<br /><br /></td><
INSERT INTO sbmFIELD VALUES ('SBIDEMOTHE',1,1,'DEMOTHE_REP','<TABLE WIDTH=\"100%\" BGCOLOR=\"#D3E3E2\" ALIGN=\"center\" CELLSPACING=\"2\" CELLPADDING=\"2\" BORDER=\"1\"><TR><TD ALIGN=\"left\"><br /><b>Submit an ATLANTIS Thesis:</b><br /><br />Your thesis will be given a reference number automatically.<br /> However, if it has other reference numbers, please enter them here:<br /><i>(one per line)</i><br />','O','Other Report Numbers','','2008-03-02','2008-03-06',NULL,NULL);
INSERT INTO sbmFIELD VALUES ('SBIDEMOTHE',1,2,'DEMOTHE_TITLE','<br /><br /><span style=\"color: red;\">*</span>Thesis Title:<br />','M','Title','','2008-03-02','2008-03-06',NULL,NULL);
INSERT INTO sbmFIELD VALUES ('SBIDEMOTHE',1,3,'DEMOTHE_SUBTTL','<br /><br />Thesis Subtitle <i>(if any)</i>:<br />','O','Subtitle','','2008-03-02','2008-03-06',NULL,NULL);
INSERT INTO sbmFIELD VALUES ('SBIDEMOTHE',1,4,'DEMOTHE_AU','<br /><br /><table width=\"100%\"><tr><td valign=\"top\"><span style=\"color: red;\">*</span>Author of the Thesis: <i>(one per line)</i><br />','M','Author(s)','','2008-03-02','2008-03-06',NULL,NULL);
INSERT INTO sbmFIELD VALUES ('SBIDEMOTHE',1,4,'DEMOTHE_AU','<br /><br /><table width=\"100%\"><tr><td valign=\"top\"><span style=\"color: red;\">*</span>Author of the Thesis:<br />','M','Author(s)','','2008-03-02','2008-03-06',NULL,NULL);
INSERT INTO sbmFIELD VALUES ('SBIDEMOTHE',1,5,'DEMOTHE_SUPERV','</td></tr><tr><td valign=\"top\"><br>Thesis Supervisor(s): <i>(one per line)</i><br />','O','Thesis Supervisor(s)','','2008-03-02','2008-03-06',NULL,NULL);
INSERT INTO sbmFIELD VALUES ('SBIDEMOTHE',1,6,'DEMOTHE_ABS','</td></tr></table><br /><span style=\"color: red;\">*</span>Abstract:<br />','M','Abstract','','2008-03-02','2008-03-06',NULL,NULL);
INSERT INTO sbmFIELD VALUES ('SBIDEMOTHE',1,7,'DEMOTHE_NUMP','<br /><br />Number of Pages: ','O','Number of Pages','','2008-03-02','2008-03-06',NULL,NULL);
Expand Down Expand Up @@ -1302,7 +1302,7 @@ INSERT INTO sbmFIELDDESC VALUES ('DEMOPIC_CONT',NULL,'','D',NULL,NULL,NULL,NULL,
INSERT INTO sbmFIELDDESC VALUES ('DEMOTHE_REP',NULL,'088__a','T',NULL,4,30,NULL,NULL,NULL,'2008-03-02','2008-03-02','<br />Other Report Numbers (one per line):',NULL,0);
INSERT INTO sbmFIELDDESC VALUES ('DEMOTHE_TITLE',NULL,'245__a','T',NULL,5,60,NULL,NULL,NULL,'2008-03-02','2008-03-02','<br />Title:<br />',NULL,0);
INSERT INTO sbmFIELDDESC VALUES ('DEMOTHE_SUBTTL',NULL,'245__b','T',NULL,3,60,NULL,NULL,NULL,'2008-03-02','2008-03-02','<br /><br />Thesis Subtitle (if any):<br />',NULL,0);
INSERT INTO sbmFIELDDESC VALUES ('DEMOTHE_AU',NULL,'100__a','T',NULL,6,60,NULL,NULL,NULL,'2008-03-02','2008-03-02','<br />Authors:<br />(one per line):<br />',NULL,0);
INSERT INTO sbmFIELDDESC VALUES ('DEMOTHE_AU',NULL,'100__a','R',NULL,6,60,NULL,NULL,'from invenio.websubmit_engine import get_authors_autocompletion\r\n\r\nrecid = action == "MBI" and sysno or None\r\nauthor_sources = ["bibauthority"]\r\nextra_options = {\r\n "allow_custom_authors": True,\r\n "highlight_principal_author": True,\r\n}\r\nextra_fields = {\r\n "contribution": False,\r\n}\r\n\r\ntext = get_authors_autocompletion(\r\n element=element,\r\n recid=recid,\r\n curdir=curdir,\r\n author_sources=author_sources,\r\n extra_options=extra_options,\r\n extra_fields=extra_fields\r\n)','2008-03-02','2014-06-30','<br />Authors:<br />(one per line):<br />',NULL,0);
INSERT INTO sbmFIELDDESC VALUES ('DEMOTHE_SUPERV',NULL,'','T',NULL,6,60,NULL,NULL,NULL,'2008-03-02','2008-03-02','<br />Thesis Supervisor(s)<br />(one per line):<br />',NULL,0);
INSERT INTO sbmFIELDDESC VALUES ('DEMOTHE_ABS',NULL,'520__a','T',NULL,12,80,NULL,NULL,NULL,'2008-03-02','2008-03-02','<br />Abstract:<br />',NULL,0);
INSERT INTO sbmFIELDDESC VALUES ('DEMOTHE_NUMP',NULL,'300__a','I',5,NULL,NULL,NULL,NULL,NULL,'2008-03-02','2008-03-06','<br />Number of Pages:&nbsp;',NULL,0);
Expand Down Expand Up @@ -1414,11 +1414,12 @@ INSERT INTO sbmFUNCTIONS VALUES ('SRV','DEMOPIC','Mail_Submitter',40,2);
INSERT INTO sbmFUNCTIONS VALUES ('SRV','DEMOPIC','Move_Uploaded_Files_to_Storage',30,2);
INSERT INTO sbmFUNCTIONS VALUES ('SRV','DEMOPIC','Is_Original_Submitter',20,2);
INSERT INTO sbmFUNCTIONS VALUES ('SRV','DEMOPIC','Get_Recid',10,2);
INSERT INTO sbmFUNCTIONS VALUES ('SBI','DEMOTHE','Move_to_Done',90,1);
INSERT INTO sbmFUNCTIONS VALUES ('SBI','DEMOTHE','Mail_Submitter',80,1);
INSERT INTO sbmFUNCTIONS VALUES ('SBI','DEMOTHE','Make_Record',50,1);
INSERT INTO sbmFUNCTIONS VALUES ('SBI','DEMOTHE','Insert_Record',60,1);
INSERT INTO sbmFUNCTIONS VALUES ('SBI','DEMOTHE','Print_Success',70,1);
INSERT INTO sbmFUNCTIONS VALUES ('SBI','DEMOTHE','Move_to_Done',100,1);
INSERT INTO sbmFUNCTIONS VALUES ('SBI','DEMOTHE','Mail_Submitter',90,1);
INSERT INTO sbmFUNCTIONS VALUES ('SBI','DEMOTHE','Print_Success',80,1);
INSERT INTO sbmFUNCTIONS VALUES ('SBI','DEMOTHE','Insert_Record',70,1);
INSERT INTO sbmFUNCTIONS VALUES ('SBI','DEMOTHE','Make_Record',60,1);
INSERT INTO sbmFUNCTIONS VALUES ('SBI','DEMOTHE','process_authors_json',50,1);
INSERT INTO sbmFUNCTIONS VALUES ('SBI','DEMOTHE','Move_Files_to_Storage',40,1);
INSERT INTO sbmFUNCTIONS VALUES ('SBI','DEMOTHE','Stamp_Uploaded_Files',30,1);
INSERT INTO sbmFUNCTIONS VALUES ('SBI','DEMOTHE','Report_Number_Generation',20,1);
Expand All @@ -1427,11 +1428,12 @@ INSERT INTO sbmFUNCTIONS VALUES ('MBI','DEMOTHE','Get_Report_Number',10,1);
INSERT INTO sbmFUNCTIONS VALUES ('MBI','DEMOTHE','Get_Recid',20,1);
INSERT INTO sbmFUNCTIONS VALUES ('MBI','DEMOTHE','Is_Original_Submitter',30,1);
INSERT INTO sbmFUNCTIONS VALUES ('MBI','DEMOTHE','Create_Modify_Interface',40,1);
INSERT INTO sbmFUNCTIONS VALUES ('MBI','DEMOTHE','Move_to_Done',80,2);
INSERT INTO sbmFUNCTIONS VALUES ('MBI','DEMOTHE','Send_Modify_Mail',70,2);
INSERT INTO sbmFUNCTIONS VALUES ('MBI','DEMOTHE','Print_Success_MBI',60,2);
INSERT INTO sbmFUNCTIONS VALUES ('MBI','DEMOTHE','Insert_Modify_Record',50,2);
INSERT INTO sbmFUNCTIONS VALUES ('MBI','DEMOTHE','Make_Modify_Record',40,2);
INSERT INTO sbmFUNCTIONS VALUES ('MBI','DEMOTHE','Move_to_Done',90,2);
INSERT INTO sbmFUNCTIONS VALUES ('MBI','DEMOTHE','Send_Modify_Mail',80,2);
INSERT INTO sbmFUNCTIONS VALUES ('MBI','DEMOTHE','Print_Success_MBI',70,2);
INSERT INTO sbmFUNCTIONS VALUES ('MBI','DEMOTHE','Insert_Modify_Record',60,2);
INSERT INTO sbmFUNCTIONS VALUES ('MBI','DEMOTHE','Make_Modify_Record',50,2);
INSERT INTO sbmFUNCTIONS VALUES ('MBI','DEMOTHE','process_authors_json',40,2);
INSERT INTO sbmFUNCTIONS VALUES ('MBI','DEMOTHE','Is_Original_Submitter',30,2);
INSERT INTO sbmFUNCTIONS VALUES ('MBI','DEMOTHE','Get_Recid',20,2);
INSERT INTO sbmFUNCTIONS VALUES ('MBI','DEMOTHE','Get_Report_Number',10,2);
Expand Down Expand Up @@ -1621,6 +1623,7 @@ INSERT INTO sbmPARAMETERS VALUES ('DEMOTHE','fieldnameMBI','DEMOTHE_CHANGE');
INSERT INTO sbmPARAMETERS VALUES ('DEMOTHE','modifyTemplate','DEMOTHEmodify.tpl');
INSERT INTO sbmPARAMETERS VALUES ('DEMOTHE','addressesMBI','');
INSERT INTO sbmPARAMETERS VALUES ('DEMOTHE','sourceDoc','Thesis');
INSERT INTO sbmPARAMETERS VALUES ('DEMOTHE','authors_json','DEMOTHE_AU');
INSERT INTO sbmPARAMETERS VALUES ('DEMOART','addressesMBI','');
INSERT INTO sbmPARAMETERS VALUES ('DEMOART','authorfile','DEMOART_AU');
INSERT INTO sbmPARAMETERS VALUES ('DEMOART','autorngen','Y');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# -*- coding: utf-8 -*-
#
# This file is part of Invenio.
# Copyright (C) 2014 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.

"""Upgrade recipe for new column tag.recjson_value."""

import os

from invenio.dbquery import run_sql
from invenio.config import CFG_PREFIX

depends_on = ['invenio_release_1_1_0']


def info():
"""Upgrade recipe information."""
return "Set up autocompletion for DEMOTHE authors"


def do_upgrade():
"""Upgrade recipe procedure."""
os.system("cd %(prefix)s/var/www/js && \
wget https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.3.0/handlebars.min.js && \
wget https://twitter.github.com/typeahead.js/releases/0.10.5/typeahead.bundle.min.js && \
wget https://raw.githubusercontent.com/es-shims/es5-shim/v4.0.3/es5-shim.min.js && \
wget https://raw.githubusercontent.com/es-shims/es5-shim/v4.0.3/es5-shim.map"
% {'prefix': CFG_PREFIX})

# Remove "one line per author" info on author textbox
run_sql("""UPDATE sbmFIELD
set fitext='<br /><br /><table width="100%"><tr><td valign="top"><span style="color: red;">*</span>Author of the Thesis:<br />'
where fidesc="DEMOTHE_AU";""")

# Add the response logic to the DEMOTHE_AU element
run_sql("""REPLACE sbmFIELDDESC VALUES ('DEMOTHE_AU',NULL,'100__a','R',NULL,6,60,NULL,NULL,'from invenio.websubmit_engine import get_authors_autocompletion\r\n\r\nrecid = action == "MBI" and sysno or None\r\nauthor_sources = ["bibauthority"]\r\nextra_options = {\r\n "allow_custom_authors": True,\r\n "highlight_principal_author": True,\r\n}\r\nextra_fields = {\r\n "contribution": False,\r\n}\r\n\r\ntext = get_authors_autocompletion(\r\n element=element,\r\n recid=recid,\r\n curdir=curdir,\r\n author_sources=author_sources,\r\n extra_options=extra_options,\r\n extra_fields=extra_fields\r\n)','2008-03-02','2014-06-30','',NULL,0);""")

# Create the process_author_json_function
run_sql("INSERT INTO sbmFUNDESC VALUES ('process_authors_json','authors_json');")

# Add it to the DEMOTHE workflow
run_sql("INSERT INTO sbmPARAMETERS VALUES ('DEMOTHE','authors_json','DEMOTHE_AU');")

# Add proccess_author_json into the submission function sequence for DEMOTHESIS
run_sql("INSERT INTO sbmFUNCTIONS VALUES ('SBI','DEMOTHE','process_authors_json',50,1);")
run_sql("UPDATE sbmFUNCTIONS set score=100 where action='SBI' and doctype='DEMOTHE' and function='Move_to_Done';")
run_sql("UPDATE sbmFUNCTIONS set score=90 where action='SBI' and doctype='DEMOTHE' and function='Mail_Submitter';")
run_sql("UPDATE sbmFUNCTIONS set score=80 where action='SBI' and doctype='DEMOTHE' and function='Print_Success';")
run_sql("UPDATE sbmFUNCTIONS set score=70 where action='SBI' and doctype='DEMOTHE' and function='Insert_Record';")
run_sql("UPDATE sbmFUNCTIONS set score=60 where action='SBI' and doctype='DEMOTHE' and function='Make_Record';")

# Add proccess_author_json into the modification function sequence for DEMOTHESIS
run_sql("INSERT INTO sbmFUNCTIONS VALUES ('MBI','DEMOTHE','process_authors_json',40,2);")
run_sql("UPDATE sbmFUNCTIONS set score=90 where action='MBI' and doctype='DEMOTHE' and function='Move_to_Done';")
run_sql("UPDATE sbmFUNCTIONS set score=80 where action='MBI' and doctype='DEMOTHE' and function='Send_Modify_Mail';")
run_sql("UPDATE sbmFUNCTIONS set score=70 where action='MBI' and doctype='DEMOTHE' and function='Print_Success_MBI';")
run_sql("UPDATE sbmFUNCTIONS set score=60 where action='MBI' and doctype='DEMOTHE' and function='Insert_Modify_Record';")
run_sql("UPDATE sbmFUNCTIONS set score=50 where action='MBI' and doctype='DEMOTHE' and function='Make_Modify_Record';")


def estimate():
"""Upgrade recipe time estimate."""
return 1
1 change: 1 addition & 0 deletions modules/miscutil/sql/tabfill.sql
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,7 @@ INSERT INTO sbmFUNDESC VALUES ('Run_PlotExtractor','with_docname');
INSERT INTO sbmFUNDESC VALUES ('Run_PlotExtractor','with_doctype');
INSERT INTO sbmFUNDESC VALUES ('Run_PlotExtractor','with_docformat');
INSERT INTO sbmFUNDESC VALUES ('Run_PlotExtractor','extract_plots_switch_file');
INSERT INTO sbmFUNDESC VALUES ('process_authors_json','authors_json');

INSERT INTO sbmGFILERESULT VALUES ('HTML','HTML document');
INSERT INTO sbmGFILERESULT VALUES ('WORD','data');
Expand Down
6 changes: 5 additions & 1 deletion modules/webstyle/css/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@

webdir = $(localstatedir)/www/img

web_DATA = invenio.css invenio-ie7.css tablesorter.css jquery.ajaxPager.css
web_DATA = invenio.css \
invenio-ie7.css \
tablesorter.css \
jquery.ajaxPager.css \
author_autocompletion.css

EXTRA_DIST = $(web_DATA)

Expand Down
Loading

0 comments on commit bd691cd

Please sign in to comment.