diff --git a/configure.ac b/configure.ac index 3835cef4c..7da5c5a57 100644 --- a/configure.ac +++ b/configure.ac @@ -1,970 +1,969 @@ ## This file is part of Invenio. ## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 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. ## This is Invenio main configure.ac file. If you change this ## file, then please run "autoreconf" to regenerate the "configure" ## script. ## Initialize autoconf and automake: AC_INIT([invenio],[m4_esyscmd(./git-version-gen .tarball-version)],[info@invenio-software.org]) AM_INIT_AUTOMAKE([tar-ustar]) ## By default we shall install into /opt/invenio. (Do not use ## AC_PREFIX_DEFAULT for this, because it would not work well with ## the localstatedir hack below.) test "${prefix}" = NONE && prefix=/opt/invenio ## Remove eventual trailing slashes from the prefix value: test "${prefix%/}" != "" && prefix=${prefix%/} ## Check for install: AC_PROG_INSTALL ## Check for gettext support: AM_GNU_GETTEXT(external) AM_GNU_GETTEXT_VERSION(0.14.4) ## Check for MySQL client: AC_MSG_CHECKING(for mysql) AC_ARG_WITH(mysql, AS_HELP_STRING([--with-mysql],[path to a specific MySQL binary (optional)]), MYSQL=${withval}) if test -n "$MYSQL"; then AC_MSG_RESULT($MYSQL) else AC_PATH_PROG(MYSQL, mysql) if test -z "$MYSQL"; then AC_MSG_ERROR([ MySQL command-line client was not found in your PATH. Please install it first. Available from <http://mysql.com/>.]) fi fi ## Check for Python: AC_MSG_CHECKING(for python) AC_ARG_WITH(python, AS_HELP_STRING([--with-python],[path to a specific Python binary (optional)]), PYTHON=${withval}) if test -n "$PYTHON"; then AC_MSG_RESULT($PYTHON) else AC_PATH_PROG(PYTHON, python) if test -z "$PYTHON"; then AC_MSG_ERROR([ Python was not found in your PATH. Please either install it in your PATH or specify --with-python configure option. Python is available from <http://python.org/>.]) fi fi ## Check for OpenOffice.org Python binary: AC_MSG_CHECKING(for OpenOffice.org Python binary) AC_ARG_WITH(openoffice-python, AS_HELP_STRING([--with-openoffice-python],[path to a specific OpenOffice.org Python binary (optional)]), OPENOFFICE_PYTHON=`which ${withval}`) if test -z "$OPENOFFICE_PYTHON"; then OPENOFFICE_PYTHON=`locate -l 1 -r "o.*office/program/python$"` OPENOFFICE_PYTHON="$PYTHON $OPENOFFICE_PYTHON" if test -n "$OPENOFFICE_PYTHON" && ($OPENOFFICE_PYTHON -c "import uno" 2> /dev/null); then AC_MSG_RESULT($OPENOFFICE_PYTHON) else AC_MSG_WARN([ You have not specified the path ot the OpenOffice.org Python binary. OpenOffice.org and Microsoft Office document conversion and fulltext indexing will not be available. We recommend you to install OpenOffice.org first and to rerun the configure script. OpenOffice.org is available from <http://www.openoffice.org/>.]) fi elif ($OPENOFFICE_PYTHON -c "import uno" 2> /dev/null); then AC_MSG_RESULT($OPENOFFICE_PYTHON) else AC_MSG_ERROR([ The specified OpenOffice.org Python binary is not correctly configured. Please specify the correct path to the specific OpenOffice Python binary (OpenOffice.org is available from <http://www.openoffice.org/>).]) fi ## Check for Python version and modules: AC_MSG_CHECKING(for required Python modules) $PYTHON ${srcdir}/configure-tests.py if test $? -ne 0; then AC_MSG_ERROR([Please fix the above Python problem before continuing.]) fi AC_MSG_RESULT(found) ## Check for PHP: AC_PATH_PROG(PHP, php) ## Check for gzip: AC_PATH_PROG(GZIP, gzip) if test -z "$GZIP"; then AC_MSG_WARN([ Gzip was not found in your PATH. It is used in the WebSubmit module to compress the data submitted in an archive. You can continue without it but you will miss some Invenio functionality. We recommend you to install it first and to rerun the configure script. Gzip is available from <http://www.gzip.org/>.]) fi ## Check for gunzip: AC_PATH_PROG(GUNZIP, gunzip) if test -z "$GUNZIP"; then AC_MSG_WARN([ Gunzip was not found in your PATH. It is used in the WebSubmit module to correctly deal with submitted compressed files. You can continue without it but you will miss some Invenio functionality. We recommend you to install it first and to rerun the configure script. Gunzip is available from <http://www.gzip.org/>.]) fi ## Check for tar: AC_PATH_PROG(TAR, tar) if test -z "$TAR"; then AC_MSG_WARN([ Tar was not found in your PATH. It is used in the WebSubmit module to pack the submitted data into an archive. You can continue without it but you will miss some Invenio functionality. We recommend you to install it first and to rerun the configure script. Tar is available from <ftp://prep.ai.mit.edu/pub/gnu/tar/>.]) fi ## Check for wget: AC_PATH_PROG(WGET, wget) if test -z "$WGET"; then AC_MSG_WARN([ wget was not found in your PATH. It is used for the fulltext file retrieval. You can continue without it but we recomend you to install it first and to rerun the configure script. wget is available from <http://www.gnu.org/software/wget/>.]) fi ## Check for md5sum: AC_PATH_PROG(MD5SUM, md5sum) if test -z "$MD5SUM"; then AC_MSG_WARN([ md5sum was not found in your PATH. It is used for the fulltext file checksum verification. You can continue without it but we recomend you to install it first and to rerun the configure script. md5sum is available from <http://www.gnu.org/software/coreutils/>.]) fi ## Check for ps2pdf: AC_PATH_PROG(PS2PDF, ps2pdf) if test -z "$PS2PDF"; then AC_MSG_WARN([ ps2pdf was not found in your PATH. It is used in the WebSubmit module to convert submitted PostScripts into PDF. You can continue without it but you will miss some Invenio functionality. We recommend you to install it first and to rerun the configure script. ps2pdf is available from <http://www.cs.wisc.edu/~ghost/doc/AFPL/>.]) fi ## Check for pdflatex: AC_PATH_PROG(PDFLATEX, pdflatex) if test -z "$PDFLATEX"; then AC_MSG_WARN([ pdflatex was not found in your PATH. It is used in the WebSubmit module to stamp PDF files. You can continue without it but you will miss some Invenio functionality. We recommend you to install it first and to rerun the configure script.]) fi ## Check for tiff2pdf: AC_PATH_PROG(TIFF2PDF, tiff2pdf) if test -z "$TIFF2PDF"; then AC_MSG_WARN([ tiff2pdf was not found in your PATH. It is used in the WebSubmit module to convert submitted TIFF file into PDF. You can continue without it but you will miss some Invenio functionality. We recommend you to install it first and to rerun the configure script. tiff2pdf is available from <http://www.remotesensing.org/libtiff/>.]) fi ## Check for gs: AC_PATH_PROG(GS, gs) if test -z "$GS"; then AC_MSG_WARN([ gs was not found in your PATH. It is used in the WebSubmit module to convert submitted PostScripts into PDF. You can continue without it but you will miss some Invenio functionality. We recommend you to install it first and to rerun the configure script. gs is available from <http://www.cs.wisc.edu/~ghost/doc/AFPL/>.]) fi ## Check for pdftotext: AC_PATH_PROG(PDFTOTEXT, pdftotext) if test -z "$PDFTOTEXT"; then AC_MSG_WARN([ pdftotext was not found in your PATH. It is used for the fulltext indexation of PDF files. You can continue without it but you may miss fulltext searching capability of Invenio. We recomend you to install it first and to rerun the configure script. pdftotext is available from <http://www.foolabs.com/xpdf/home.html>. ]) fi ## Check for pdftotext: AC_PATH_PROG(PDFINFO, pdfinfo) if test -z "$PDFINFO"; then AC_MSG_WARN([ pdfinfo was not found in your PATH. It is used for gathering information on PDF files. You can continue without it but you may miss this feature of Invenio. We recomend you to install it first and to rerun the configure script. pdftotext is available from <http://www.foolabs.com/xpdf/home.html>. ]) fi ## Check for pdftk: AC_PATH_PROG(PDFTK, pdftk) if test -z "$PDFTK"; then AC_MSG_WARN([ pdftk was not found in your PATH. It is used for the fulltext file stamping. You can continue without it but you may miss this feature of Invenio. We recomend you to install it first and to rerun the configure script. pdftk is available from <http://www.accesspdf.com/pdftk/>. ]) fi ## Check for pdf2ps: AC_PATH_PROG(PDF2PS, pdf2ps) if test -z "$PDF2PS"; then AC_MSG_WARN([ pdf2ps was not found in your PATH. It is used in the WebSubmit module to convert submitted PDFs into PostScript. You can continue without it but you will miss some Invenio functionality. We recommend you to install it first and to rerun the configure script. pdf2ps is available from <http://www.cs.wisc.edu/~ghost/doc/AFPL/>.]) fi ## Check for pdftops: AC_PATH_PROG(PDFTOPS, pdftops) if test -z "$PDFTOPS"; then AC_MSG_WARN([ pdftops was not found in your PATH. It is used in the WebSubmit module to convert submitted PDFs into PostScript. You can continue without it but you will miss some Invenio functionality. We recommend you to install it first and to rerun the configure script. pdftops is available from <http://poppler.freedesktop.org/>.]) fi ## Check for pdfopt: AC_PATH_PROG(PDFOPT, pdfopt) if test -z "$PDFOPT"; then AC_MSG_WARN([ pdfopt was not found in your PATH. It is used in the WebSubmit module to linearized submitted PDFs. You can continue without it but you will miss some Invenio functionality. We recommend you to install it first and to rerun the configure script. pdfopt is available from <http://www.cs.wisc.edu/~ghost/doc/AFPL/>.]) fi ## Check for pdfimages: AC_PATH_PROG(PDFTOPPM, pdftoppm) if test -z "$PDFTOPPM"; then AC_MSG_WARN([ pdftoppm was not found in your PATH. It is used in the WebSubmit module to extract images from PDFs for OCR. You can continue without it but you will miss some Invenio functionality. We recommend you to install it first and to rerun the configure script. pdftoppm is available from <http://poppler.freedesktop.org/>.]) fi ## Check for pdfimages: AC_PATH_PROG(PAMFILE, pdftoppm) if test -z "$PAMFILE"; then AC_MSG_WARN([ pamfile was not found in your PATH. It is used in the WebSubmit module to retrieve the size of images extracted from PDFs for OCR. You can continue without it but you will miss some Invenio functionality. We recommend you to install it first and to rerun the configure script. pamfile is available as part of the netpbm utilities from: <http://netpbm.sourceforge.net/>.]) fi ## Check for ocroscript: AC_PATH_PROG(OCROSCRIPT, ocroscript) if test -z "$OCROSCRIPT"; then AC_MSG_WARN([ If you plan to run OCR on your PDFs, then please install ocroscript now. Otherwise you can safely continue. You have also an option to install ocroscript later and edit invenio-local.conf to let Invenio know the path to ocroscript. ocroscript is available as part of OCROpus from <http://code.google.com/p/ocropus/>. NOTE: Since OCROpus is being actively developed and its api is continuosly changing, please install relase 0.3.1]) fi ## Check for pstotext: AC_PATH_PROG(PSTOTEXT, pstotext) if test -z "$PSTOTEXT"; then AC_MSG_WARN([ pstotext was not found in your PATH. It is used for the fulltext indexation of PDF and PostScript files. Please install pstotext. Otherwise you can safely continue. You have also an option to install pstotext later and edit invenio-local.conf to let Invenio know the path to pstotext. pstotext is available from <http://www.cs.wisc.edu/~ghost/doc/AFPL/>. ]) fi ## Check for ps2ascii: AC_PATH_PROG(PSTOASCII, ps2ascii) if test -z "$PSTOASCII"; then AC_MSG_WARN([ ps2ascii was not found in your PATH. It is used for the fulltext indexation of PostScript files. Please install ps2ascii. Otherwise you can safely continue. You have also an option to install ps2ascii later and edit invenio-local.conf to let Invenio know the path to ps2ascii. ps2ascii is available from <http://www.cs.wisc.edu/~ghost/doc/AFPL/>. ]) fi ## Check for any2djvu: AC_PATH_PROG(ANY2DJVU, any2djvu) if test -z "$ANY2DJVU"; then AC_MSG_WARN([ any2djvu was not found in your PATH. It is used in the WebSubmit module to convert documents to DJVU. Please install any2djvu. Otherwise you can safely continue. You have also an option to install any2djvu later and edit invenio-local.conf to let Invenio know the path to any2djvu. any2djvu is available from <http://djvu.sourceforge.net/>.]) fi ## Check for DJVUPS: AC_PATH_PROG(DJVUPS, djvups) if test -z "$DJVUPS"; then AC_MSG_WARN([ djvups was not found in your PATH. It is used in the WebSubmit module to convert documents from DJVU. Please install djvups. Otherwise you can safely continue. You have also an option to install djvups later and edit invenio-local.conf to let Invenio know the path to djvups. djvups is available from <http://djvu.sourceforge.net/>.]) fi ## Check for DJVUTXT: AC_PATH_PROG(DJVUTXT, djvutxt) if test -z "$DJVUTXT"; then AC_MSG_WARN([ djvutxt was not found in your PATH. It is used in the WebSubmit module to extract text from DJVU documents. You can continue without it but you will miss some Invenio functionality. We recommend you to install it first and to rerun the configure script. djvutxt is available from <http://djvu.sourceforge.net/>.]) fi ## Check for file: AC_PATH_PROG(FILE, file) if test -z "$FILE"; then AC_MSG_WARN([ File was not found in your PATH. It is used in the WebSubmit module to check the validity of the submitted files. You can continue without it but you will miss some Invenio functionality. We recommend you to install it first and to rerun the configure script. File is available from <ftp://ftp.astron.com/pub/file/>.]) fi ## Check for convert: AC_PATH_PROG(CONVERT, convert) if test -z "$CONVERT"; then AC_MSG_WARN([ Convert was not found in your PATH. It is used in the WebSubmit module to create an icon from a submitted picture. You can continue without it but you will miss some Invenio functionality. We recommend you to install it first and to rerun the configure script. Convert is available from <http://www.imagemagick.org/>.]) fi ## Check for CLISP: AC_MSG_CHECKING(for clisp) AC_ARG_WITH(clisp, AS_HELP_STRING([--with-clisp],[path to a specific CLISP binary (optional)]), CLISP=${withval}) if test -n "$CLISP"; then AC_MSG_RESULT($CLISP) else AC_PATH_PROG(CLISP, clisp) if test -z "$CLISP"; then AC_MSG_WARN([ GNU CLISP was not found in your PATH. It is used by the WebStat module to produce statistics about Invenio usage. (Alternatively, SBCL or CMUCL can be used instead of CLISP.) You can continue without it but you will miss this feature. We recommend you to install it first (if you don't have neither CMUCL nor SBCL) and to rerun the configure script. GNU CLISP is available from <http://clisp.cons.org/>.]) fi fi ## Check for CMUCL: AC_MSG_CHECKING(for cmucl) AC_ARG_WITH(cmucl, AS_HELP_STRING([--with-cmucl],[path to a specific CMUCL binary (optional)]), CMUCL=${withval}) if test -n "$CMUCL"; then AC_MSG_RESULT($CMUCL) else AC_PATH_PROG(CMUCL, cmucl) if test -z "$CMUCL"; then AC_MSG_CHECKING(for lisp) # CMUCL can also be installed under `lisp' exec name AC_PATH_PROG(CMUCL, lisp) fi if test -z "$CMUCL"; then AC_MSG_WARN([ CMUCL was not found in your PATH. It is used by the WebStat module to produce statistics about Invenio usage. (Alternatively, CLISP or SBCL can be used instead of CMUCL.) You can continue without it but you will miss this feature. We recommend you to install it first (if you don't have neither CLISP nor SBCL) and to rerun the configure script. CMUCL is available from <http://www.cons.org/cmucl/>.]) fi fi ## Check for SBCL: AC_MSG_CHECKING(for sbcl) AC_ARG_WITH(sbcl, AS_HELP_STRING([--with-sbcl],[path to a specific SBCL binary (optional)]), SBCL=${withval}) if test -n "$SBCL"; then AC_MSG_RESULT($SBCL) else AC_PATH_PROG(SBCL, sbcl) if test -z "$SBCL"; then AC_MSG_WARN([ SBCL was not found in your PATH. It is used by the WebStat module to produce statistics about Invenio usage. (Alternatively, CLISP or CMUCL can be used instead of SBCL.) You can continue without it but you will miss this feature. We recommend you to install it first (if you don't have neither CLISP nor CMUCL) and to rerun the configure script. SBCL is available from <http://sbcl.sourceforge.net/>.]) fi fi ## Check for gnuplot: AC_PATH_PROG(GNUPLOT, gnuplot) if test -z "$GNUPLOT"; then AC_MSG_WARN([ Gnuplot was not found in your PATH. It is used by the BibRank module to produce graphs about download and citation history. You can continue without it but you will miss these graphs. We recommend you to install it first and to rerun the configure script. Gnuplot is available from <http://www.gnuplot.info/>.]) fi ## Check for ffmpeg: AC_PATH_PROG(FFMPEG, ffmpeg) AC_PATH_PROG(FFPROBE, ffprobe) if test -z "$FFMPEG"; then AC_MSG_WARN([ FFmpeg was not found in your PATH. It is used by the BibEncode module to for video encoding. You can continue without but you will not be able to use BibEncode and no video submission workflows are thereby possible. We recommend you to install it first if you would like to support video submissions and to rerun the configure script. FFmpeg is available from <http://www.ffmpeg.org/>.]) fi ## Check for mediainfo: AC_PATH_PROG(MEDIAINFO, mediainfo) if test -z "$MEDIAINFO"; then AC_MSG_WARN([ Mediainfo was not found in your PATH. It is used by the BibEncode module to for video encoding and media metadata handling. You can continue without but you will not be able to use BibEncode and no video submission workflows are thereby possible. We recommend you to install it first if you would like to support video submissions and to rerun the configure script. Mediainfo is available from <http://mediainfo.sourceforge.net/>.]) fi ## Check for ffmpeg ## Substitute variables: AC_SUBST(VERSION) AC_SUBST(OPENOFFICE_PYTHON) AC_SUBST(MYSQL) AC_SUBST(PYTHON) AC_SUBST(GZIP) AC_SUBST(GUNZIP) AC_SUBST(TAR) AC_SUBST(WGET) AC_SUBST(MD5SUM) AC_SUBST(PS2PDF) AC_SUBST(GS) AC_SUBST(PDFTOTEXT) AC_SUBST(PDFTK) AC_SUBST(PDF2PS) AC_SUBST(PDFTOPS) AC_SUBST(PDFOPT) AC_SUBST(PDFTOPPM) AC_SUBST(OCROSCRIPT) AC_SUBST(PSTOTEXT) AC_SUBST(PSTOASCII) AC_SUBST(ANY2DJVU) AC_SUBST(DJVUPS) AC_SUBST(DJVUTXT) AC_SUBST(FILE) AC_SUBST(CONVERT) AC_SUBST(GNUPLOT) AC_SUBST(CLISP) AC_SUBST(CMUCL) AC_SUBST(SBCL) AC_SUBST(CACHEDIR) AC_SUBST(FFMPEG) AC_SUBST(MEDIAINFO) AC_SUBST(FFPROBE) AC_SUBST(localstatedir, `eval echo "${localstatedir}"`) ## Define output files: AC_CONFIG_FILES([config.nice \ Makefile \ po/Makefile.in \ config/Makefile \ config/invenio-autotools.conf \ modules/Makefile \ modules/webauthorprofile/Makefile \ modules/webauthorprofile/lib/Makefile \ modules/webauthorprofile/bin/Makefile \ modules/webauthorprofile/bin/webauthorprofile \ modules/bibauthorid/Makefile \ modules/bibauthorid/bin/Makefile \ modules/bibauthorid/bin/bibauthorid \ modules/bibauthorid/doc/Makefile \ modules/bibauthorid/doc/admin/Makefile \ modules/bibauthorid/doc/hacking/Makefile \ modules/bibauthorid/lib/Makefile \ modules/bibauthorid/etc/Makefile \ modules/bibauthorid/etc/name_authority_files/Makefile \ modules/bibauthorid/web/Makefile \ modules/bibcatalog/Makefile \ modules/bibcatalog/doc/Makefile \ modules/bibcatalog/doc/admin/Makefile \ modules/bibcatalog/doc/hacking/Makefile modules/bibcatalog/lib/Makefile \ modules/bibcheck/Makefile \ modules/bibcheck/doc/Makefile \ modules/bibcheck/doc/admin/Makefile \ modules/bibcheck/doc/hacking/Makefile \ modules/bibcheck/etc/Makefile \ modules/bibcheck/web/Makefile \ modules/bibcheck/web/admin/Makefile \ modules/bibcirculation/Makefile \ modules/bibcirculation/bin/Makefile \ modules/bibcirculation/bin/bibcircd \ modules/bibcirculation/doc/Makefile \ modules/bibcirculation/doc/admin/Makefile \ modules/bibcirculation/doc/hacking/Makefile modules/bibcirculation/lib/Makefile \ modules/bibcirculation/web/Makefile \ modules/bibcirculation/web/admin/Makefile \ modules/bibclassify/Makefile \ modules/bibclassify/bin/Makefile \ modules/bibclassify/bin/bibclassify \ modules/bibclassify/doc/Makefile \ modules/bibclassify/doc/admin/Makefile \ modules/bibclassify/doc/hacking/Makefile \ modules/bibclassify/etc/Makefile \ modules/bibclassify/lib/Makefile \ modules/bibconvert/Makefile \ modules/bibconvert/bin/Makefile \ modules/bibconvert/bin/bibconvert \ modules/bibconvert/doc/Makefile \ modules/bibconvert/doc/admin/Makefile \ modules/bibconvert/doc/hacking/Makefile \ modules/bibconvert/etc/Makefile \ modules/bibconvert/lib/Makefile \ modules/bibdocfile/Makefile \ modules/bibdocfile/bin/bibdocfile \ modules/bibdocfile/bin/Makefile \ modules/bibdocfile/doc/Makefile \ modules/bibdocfile/doc/hacking/Makefile \ modules/bibdocfile/lib/Makefile \ modules/bibrecord/Makefile \ modules/bibrecord/bin/Makefile \ modules/bibrecord/bin/xmlmarc2textmarc \ modules/bibrecord/bin/textmarc2xmlmarc \ modules/bibrecord/bin/xmlmarclint \ modules/bibrecord/doc/Makefile \ modules/bibrecord/doc/admin/Makefile \ modules/bibrecord/doc/hacking/Makefile \ modules/bibrecord/etc/Makefile \ modules/bibrecord/lib/Makefile \ modules/bibedit/Makefile \ modules/bibedit/bin/Makefile \ modules/bibedit/bin/bibedit \ modules/bibedit/doc/Makefile \ modules/bibedit/doc/admin/Makefile \ modules/bibedit/doc/hacking/Makefile \ modules/bibedit/etc/Makefile \ modules/bibedit/lib/Makefile \ modules/bibedit/web/Makefile \ modules/bibencode/Makefile \ modules/bibencode/bin/Makefile \ modules/bibencode/bin/bibencode \ modules/bibencode/lib/Makefile \ modules/bibencode/etc/Makefile \ modules/bibencode/www/Makefile \ modules/bibexport/Makefile \ modules/bibexport/bin/Makefile \ modules/bibexport/bin/bibexport \ modules/bibexport/doc/Makefile \ modules/bibexport/doc/admin/Makefile \ modules/bibexport/doc/hacking/Makefile modules/bibexport/etc/Makefile \ modules/bibexport/lib/Makefile \ modules/bibexport/web/Makefile \ modules/bibexport/web/admin/Makefile \ modules/bibfield/Makefile \ modules/bibfield/lib/Makefile \ modules/bibfield/lib/functions/Makefile \ modules/bibfield/etc/Makefile \ modules/bibformat/Makefile \ modules/bibformat/bin/Makefile \ modules/bibformat/bin/bibreformat \ modules/bibformat/doc/Makefile \ modules/bibformat/doc/admin/Makefile \ modules/bibformat/doc/hacking/Makefile \ modules/bibformat/etc/Makefile \ modules/bibformat/etc/templates/Makefile \ modules/bibformat/etc/format_templates/Makefile \ modules/bibformat/etc/output_formats/Makefile \ modules/bibformat/lib/Makefile \ modules/bibformat/lib/elements/Makefile \ modules/bibformat/web/Makefile \ modules/bibformat/web/admin/Makefile \ modules/oaiharvest/Makefile \ modules/oaiharvest/bin/Makefile \ modules/oaiharvest/bin/oaiharvest \ modules/oaiharvest/doc/Makefile \ modules/oaiharvest/doc/admin/Makefile \ modules/oaiharvest/doc/hacking/Makefile \ modules/oaiharvest/lib/Makefile \ modules/oaiharvest/web/Makefile \ modules/oaiharvest/web/admin/Makefile \ modules/oairepository/Makefile \ modules/oairepository/bin/Makefile \ modules/oairepository/bin/oairepositoryupdater \ modules/oairepository/doc/Makefile \ modules/oairepository/doc/admin/Makefile \ modules/oairepository/doc/hacking/Makefile \ modules/oairepository/etc/Makefile \ modules/oairepository/lib/Makefile \ modules/oairepository/web/Makefile \ modules/oairepository/web/admin/Makefile \ modules/bibindex/Makefile \ modules/bibindex/bin/Makefile \ modules/bibindex/bin/bibindex \ modules/bibindex/bin/bibstat \ modules/bibindex/doc/Makefile \ modules/bibindex/doc/admin/Makefile \ modules/bibindex/doc/hacking/Makefile \ modules/bibindex/lib/Makefile \ modules/bibindex/web/Makefile \ modules/bibindex/web/admin/Makefile \ modules/bibknowledge/Makefile \ modules/bibknowledge/lib/Makefile \ modules/bibknowledge/doc/Makefile \ modules/bibknowledge/doc/admin/Makefile \ modules/bibknowledge/doc/hacking/Makefile \ modules/bibmatch/Makefile \ modules/bibmatch/bin/Makefile \ modules/bibmatch/bin/bibmatch \ modules/bibmatch/doc/Makefile \ modules/bibmatch/doc/admin/Makefile \ modules/bibmatch/doc/hacking/Makefile \ modules/bibmatch/etc/Makefile \ modules/bibmatch/lib/Makefile \ modules/bibmerge/Makefile \ modules/bibmerge/bin/Makefile \ modules/bibmerge/doc/Makefile \ modules/bibmerge/doc/admin/Makefile \ modules/bibmerge/doc/hacking/Makefile \ modules/bibmerge/lib/Makefile \ modules/bibmerge/web/Makefile \ modules/bibmerge/web/admin/Makefile \ modules/bibrank/Makefile \ modules/bibrank/bin/Makefile \ modules/bibrank/bin/bibrank \ modules/bibrank/bin/bibrankgkb \ modules/bibrank/doc/Makefile \ modules/bibrank/doc/admin/Makefile \ modules/bibrank/doc/hacking/Makefile \ modules/bibrank/etc/Makefile \ modules/bibrank/etc/bibrankgkb.cfg \ modules/bibrank/etc/demo_jif.cfg \ modules/bibrank/etc/template_single_tag_rank_method.cfg \ modules/bibrank/lib/Makefile \ modules/bibrank/web/Makefile \ modules/bibrank/web/admin/Makefile \ modules/bibsched/Makefile \ modules/bibsched/bin/Makefile \ modules/bibsched/bin/bibsched \ modules/bibsched/bin/bibtaskex \ modules/bibsched/bin/bibtasklet \ modules/bibsched/doc/Makefile \ modules/bibsched/doc/admin/Makefile \ modules/bibsched/doc/hacking/Makefile \ modules/bibsched/lib/Makefile \ modules/bibsched/lib/tasklets/Makefile \ modules/bibupload/Makefile \ modules/bibsort/Makefile \ modules/bibsort/bin/Makefile \ modules/bibsort/bin/bibsort \ modules/bibsort/lib/Makefile \ modules/bibsort/etc/Makefile \ modules/bibsort/doc/Makefile \ modules/bibsort/doc/admin/Makefile \ modules/bibsort/doc/hacking/Makefile \ modules/bibsort/web/Makefile \ modules/bibsort/web/admin/Makefile \ modules/bibsword/Makefile \ modules/bibsword/bin/Makefile \ modules/bibsword/bin/bibsword \ modules/bibsword/doc/Makefile \ modules/bibsword/doc/admin/Makefile \ modules/bibsword/doc/hacking/Makefile \ modules/bibsword/lib/Makefile \ modules/bibsword/etc/Makefile \ modules/bibupload/bin/Makefile \ modules/bibupload/bin/bibupload \ modules/bibupload/bin/batchuploader \ modules/bibupload/doc/Makefile \ modules/bibupload/doc/admin/Makefile \ modules/bibupload/doc/hacking/Makefile \ modules/bibupload/lib/Makefile \ modules/elmsubmit/Makefile \ modules/elmsubmit/bin/Makefile \ modules/elmsubmit/bin/elmsubmit \ modules/elmsubmit/doc/Makefile \ modules/elmsubmit/doc/admin/Makefile \ modules/elmsubmit/doc/hacking/Makefile \ modules/elmsubmit/etc/Makefile \ modules/elmsubmit/etc/elmsubmit.cfg \ modules/elmsubmit/lib/Makefile \ modules/miscutil/Makefile \ modules/miscutil/bin/Makefile \ modules/miscutil/bin/dbdump \ modules/miscutil/bin/dbexec \ modules/miscutil/bin/inveniocfg \ modules/miscutil/bin/inveniomanage \ modules/miscutil/bin/plotextractor \ modules/miscutil/demo/Makefile \ modules/miscutil/doc/Makefile \ modules/miscutil/doc/hacking/Makefile \ modules/miscutil/etc/Makefile \ modules/miscutil/etc/bash_completion.d/Makefile \ modules/miscutil/etc/bash_completion.d/inveniocfg \ modules/miscutil/etc/ckeditor_scientificchar/Makefile \ modules/miscutil/etc/ckeditor_scientificchar/dialogs/Makefile \ modules/miscutil/etc/ckeditor_scientificchar/lang/Makefile \ modules/miscutil/etc/templates/Makefile \ modules/miscutil/lib/Makefile \ modules/miscutil/lib/upgrades/Makefile \ modules/miscutil/sql/Makefile \ modules/miscutil/web/Makefile \ modules/webaccess/Makefile \ modules/webaccess/bin/Makefile \ modules/webaccess/bin/authaction \ modules/webaccess/bin/webaccessadmin \ modules/webaccess/etc/Makefile \ modules/webaccess/etc/templates/Makefile \ modules/webaccess/doc/Makefile \ modules/webaccess/doc/admin/Makefile \ modules/webaccess/doc/hacking/Makefile \ modules/webaccess/lib/Makefile \ modules/webaccess/web/Makefile \ modules/webaccess/web/admin/Makefile \ modules/webalert/Makefile \ modules/webalert/bin/Makefile \ modules/webalert/bin/alertengine \ modules/webalert/doc/Makefile \ modules/webalert/doc/admin/Makefile \ modules/webalert/doc/hacking/Makefile \ modules/webalert/lib/Makefile \ modules/webalert/web/Makefile \ modules/webbasket/Makefile \ modules/webbasket/doc/Makefile \ modules/webbasket/doc/admin/Makefile \ modules/webbasket/doc/hacking/Makefile \ modules/webbasket/lib/Makefile \ modules/webbasket/web/Makefile \ modules/webcomment/Makefile \ modules/webcomment/doc/Makefile \ modules/webcomment/doc/admin/Makefile \ modules/webcomment/doc/hacking/Makefile \ modules/webcomment/etc/Makefile \ modules/webcomment/etc/templates/Makefile \ modules/webcomment/lib/Makefile \ modules/webcomment/web/Makefile \ modules/webcomment/web/admin/Makefile \ modules/webhelp/Makefile \ modules/webhelp/web/Makefile \ modules/webhelp/web/admin/Makefile \ modules/webhelp/web/admin/howto/Makefile \ modules/webhelp/web/hacking/Makefile \ modules/webjournal/Makefile \ modules/webjournal/etc/Makefile \ modules/webjournal/doc/Makefile \ modules/webjournal/doc/admin/Makefile \ modules/webjournal/doc/hacking/Makefile \ modules/webjournal/lib/Makefile \ modules/webjournal/lib/elements/Makefile \ modules/webjournal/lib/widgets/Makefile \ modules/webjournal/web/Makefile \ modules/webjournal/web/admin/Makefile \ modules/weblinkback/Makefile \ modules/weblinkback/etc/Makefile \ modules/weblinkback/etc/templates/Makefile \ modules/weblinkback/lib/Makefile \ modules/weblinkback/web/Makefile \ modules/weblinkback/web/admin/Makefile \ modules/webmessage/Makefile \ modules/webmessage/bin/Makefile \ modules/webmessage/bin/webmessageadmin \ modules/webmessage/doc/Makefile \ modules/webmessage/doc/admin/Makefile \ modules/webmessage/doc/hacking/Makefile \ modules/webmessage/etc/Makefile \ modules/webmessage/etc/templates/Makefile \ modules/webmessage/lib/Makefile \ modules/webmessage/web/Makefile \ modules/websearch/Makefile \ modules/websearch/bin/Makefile \ modules/websearch/bin/webcoll \ modules/websearch/doc/Makefile \ modules/websearch/doc/admin/Makefile \ modules/websearch/doc/hacking/Makefile \ modules/websearch/etc/Makefile \ modules/websearch/etc/templates/Makefile \ modules/websearch/lib/Makefile \ modules/websearch/lib/facets/Makefile \ modules/websearch/web/Makefile \ modules/websearch/web/admin/Makefile \ modules/websession/Makefile \ modules/websession/bin/Makefile \ modules/websession/bin/inveniogc \ modules/websession/etc/Makefile \ modules/websession/etc/templates/Makefile \ modules/websession/doc/Makefile \ modules/websession/doc/admin/Makefile \ modules/websession/doc/hacking/Makefile \ modules/websession/lib/Makefile \ modules/websession/web/Makefile \ modules/webstat/Makefile \ modules/webstat/bin/Makefile \ modules/webstat/bin/webstat \ modules/webstat/bin/webstatadmin \ modules/webstat/doc/Makefile \ modules/webstat/doc/admin/Makefile \ modules/webstat/doc/hacking/Makefile \ modules/webstat/etc/Makefile \ modules/webstat/lib/Makefile \ modules/webstyle/Makefile \ modules/webstyle/bin/Makefile \ modules/webstyle/bin/gotoadmin \ modules/webstyle/bin/webdoc \ modules/webstyle/css/Makefile \ modules/webstyle/doc/Makefile \ modules/webstyle/doc/admin/Makefile \ modules/webstyle/doc/hacking/Makefile \ modules/webstyle/etc/Makefile \ modules/webstyle/etc/templates/Makefile \ modules/webstyle/img/Makefile \ modules/webstyle/lib/Makefile \ modules/webstyle/lib/goto_plugins/Makefile \ modules/websubmit/Makefile \ modules/websubmit/bin/Makefile \ modules/websubmit/bin/inveniounoconv \ modules/websubmit/doc/Makefile \ modules/websubmit/doc/admin/Makefile \ modules/websubmit/doc/hacking/Makefile \ modules/websubmit/etc/Makefile \ modules/websubmit/lib/Makefile \ modules/websubmit/lib/functions/Makefile \ modules/websubmit/web/Makefile \ modules/websubmit/web/admin/Makefile \ modules/docextract/Makefile \ modules/docextract/bin/Makefile \ modules/docextract/bin/docextract \ modules/docextract/bin/refextract \ modules/docextract/doc/Makefile \ modules/docextract/lib/Makefile \ modules/docextract/etc/Makefile \ modules/docextract/doc/admin/Makefile \ modules/docextract/doc/hacking/Makefile \ modules/webdeposit/Makefile \ modules/webdeposit/etc/Makefile \ - modules/webdeposit/etc/static/Makefile \ modules/webdeposit/etc/templates/Makefile \ modules/webdeposit/lib/Makefile \ modules/webdeposit/lib/deposition_fields/Makefile \ modules/webdeposit/lib/deposition_forms/Makefile \ modules/webdeposit/lib/deposition_types/Makefile \ modules/bibworkflow/Makefile \ modules/bibworkflow/bin/Makefile \ modules/bibworkflow/doc/Makefile \ modules/bibworkflow/etc/Makefile \ modules/bibworkflow/etc/workflows/Makefile \ modules/bibworkflow/etc/templates/Makefile \ modules/bibworkflow/etc/tasks/Makefile \ modules/bibworkflow/lib/Makefile \ modules/bibworkflow/lib/workers/Makefile \ modules/bibworkflow/web/Makefile \ ]) ## Finally, write output files: AC_OUTPUT ## Write help: AC_MSG_RESULT([****************************************************************************]) AC_MSG_RESULT([** Your Invenio installation is now ready for building. **]) AC_MSG_RESULT([** You have entered the following parameters: **]) AC_MSG_RESULT([** - Invenio main install directory: ${prefix}]) AC_MSG_RESULT([** - Python executable: $PYTHON]) AC_MSG_RESULT([** - MySQL client executable: $MYSQL]) AC_MSG_RESULT([** - CLISP executable: $CLISP]) AC_MSG_RESULT([** - CMUCL executable: $CMUCL]) AC_MSG_RESULT([** - SBCL executable: $SBCL]) AC_MSG_RESULT([** Here are the steps to continue the building process: **]) AC_MSG_RESULT([** 1) Type 'make' to build your Invenio system. **]) AC_MSG_RESULT([** 2) Type 'make install' to install your Invenio system. **]) AC_MSG_RESULT([** After that you can start customizing your installation as documented **]) AC_MSG_RESULT([** in the INSTALL file (i.e. edit invenio.conf, run inveniocfg, etc). **]) AC_MSG_RESULT([** Good luck, and thanks for choosing Invenio. **]) AC_MSG_RESULT([** -- Invenio Development Team <info@invenio-software.org> **]) AC_MSG_RESULT([****************************************************************************]) ## end of file diff --git a/modules/webdeposit/etc/Makefile.am b/modules/webdeposit/etc/Makefile.am index d396d20ad..510e67bc4 100644 --- a/modules/webdeposit/etc/Makefile.am +++ b/modules/webdeposit/etc/Makefile.am @@ -1,20 +1,20 @@ ## This file is part of Invenio. ## Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2011 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. -SUBDIRS = static templates +SUBDIRS = templates CLEANFILES = *~ diff --git a/modules/webdeposit/etc/static/Makefile.am b/modules/webdeposit/etc/static/Makefile.am deleted file mode 100644 index d1793c26e..000000000 --- a/modules/webdeposit/etc/static/Makefile.am +++ /dev/null @@ -1,23 +0,0 @@ -## This file is part of Invenio. -## Copyright (C) 2003, 2005, 2006, 2007, 2008, 2009, 2010, 2011 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. - -static_DATA = websubmit_add.css - -staticdir = $(sysconfdir)/static - -CLEANFILES = *~ *.tmp - diff --git a/modules/webdeposit/etc/static/websubmit_add.css b/modules/webdeposit/etc/static/websubmit_add.css deleted file mode 100644 index 9e40348c1..000000000 --- a/modules/webdeposit/etc/static/websubmit_add.css +++ /dev/null @@ -1,45 +0,0 @@ -#link{ - float: left; - position:absolute; - font-size: 15px; - /*color:#272727;*/ - color:rgb(59, 89, 152); - font-weight:bold; -} - -#link:hover { - text-decoration:underline; -} - -.l{ - size: 10px; -} - -div#editable{ - border: none; - z-index:-1; - display:none -} - -div#conditions{ - border: none; - z-index:-1; - display:none -} - -#container { - width:550px; -/* height: 690px; - padding-left: 30px;*/ - margin-left: auto ; - margin-right: auto ; - background-color: white; - - border-top:2px solid #333232; - border-bottom:2px solid #333232; - border-right:2px solid #333232; - border-left:2px solid #333232; - border-radius: 10px; - border-bottom-right-radius: 10px; - padding: 20px; -} diff --git a/modules/webdeposit/etc/templates/webdeposit_add.html b/modules/webdeposit/etc/templates/webdeposit_add.html index 493df9266..8a160e360 100644 --- a/modules/webdeposit/etc/templates/webdeposit_add.html +++ b/modules/webdeposit/etc/templates/webdeposit_add.html @@ -1,313 +1,289 @@ {# ## This file is part of Invenio. ## Copyright (C) 2013 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. #} {% extends "page.html" %} {% block header %} {{ super() }} {% js 'js/jquery-ui.min.js', '20-jquery-ui' %} {% js 'js/plupload/plupload.full.js', '50-webdeposit' %} {% js 'js/webdeposit_form.js', '50-webdeposit' %} {% js 'ckeditor/ckeditor.js', '50-ckeditor' %} {% js 'ckeditor/invenio-ckeditor-config.js', '50-ckeditor' %} {% css 'img/jquery-ui/themes/base/jquery.ui.theme.css', '20-jquery-ui' %} {% css 'img/jquery-ui/themes/base/jquery.ui.datepicker.css', '20-jquery-ui' %} {% endblock %} {% block body %} <style> .ui-autocomplete-loading { background: white url('{{ url_for('static', filename='img/loading.gif') }}') right center no-repeat; } .typeahead { max-height: 250px; overflow-y: auto; /* prevent horizontal scrollbar */ overflow-x: hidden; } -#link{ - float: left; - position:absolute; - font-size: 15px; - /*color:#272727;*/ - color:rgb(59, 89, 152); - font-weight:bold; -} - -#link:hover { - text-decoration:underline; -} - .l{ size: 10px; } -div#editable{ - border: none; - z-index:-1; - display:none; -} - -div#conditions{ - border: none; - z-index:-1; - display:none; -} - .required:after { color: red; content:" *"; } .rmlink { cursor: pointer; display: block; margin-left: auto; margin-right: auto } </style> <div class="page-header"> <h2>{{ form._title }} {% if form._drafting %} <small class="pull-right"> <a class="btn btn-info" href="{{ url_for('webdeposit.create_new', deposition_type=deposition_type) }}"> <i class="icon-edit icon-white"></i> {{ _('New Deposition') }} </a> <a class="btn btn-danger" href="{{ url_for('webdeposit.delete', deposition_type=deposition_type, uuid=uuid) }}"> <i class="icon-remove icon-white"></i> {{ _('Delete Deposition') }} </a> <div class="btn-group"> <a class="btn dropdown-toggle" data-toggle="dropdown" href="#"> <i class="icon-list"></i> {{ _('Ongoing Depositions') }} <span class="caret"></span> </a> <ul class="dropdown-menu"> {% for draft in drafts %} <li> <a href="{{ url_for('webdeposit.add', deposition_type=draft.deposition_type, uuid=draft.uuid) }}"> {{ '<strong>'|safe if uuid == draft.uuid }} {{ draft.workflow.name }}: {% if draft.form_values and draft.form_values.title %} {{ draft.form_values.title }} {% else %} {{ _('Untitled') }} {% endif %} {{ '</strong>'|safe if uuid == draft.uuid }} <span style="font-size: 80%;" class="muted">{{ draft.timestamp|invenio_pretty_date }}</span> </a> </li> {% endfor %} </ul> </div> </small> <div class="clearfix"></div> {% endif %} </h2> </div> <form enctype="multipart/form-data" name="submitForm" id="submitForm" class="form-horizontal" method="post" action="{{ url_for('webdeposit.add', deposition_type=deposition_type, uuid=uuid) }}"> <fieldset> {% for field in form %} {% if field.form %} <hr> {% endif %} <div class="control-group {{ "error" if field.errors }}" id="error-group-{{ field.name }}"> <div class="control-label {{ "error" if field.errors }}"> {% if "submit" not in field.__html__() and "pluploader" not in field.__html__() %} {% set label_class = (' required' if field.required else '') %} {% if field.form %} <h5> {{ field.label.text }} </h5> {% else %} {{ field.label(class_=label_class) }} {% endif %} {% endif %} </div> {% if field.form %} </div> {% for subfield in field.form %} <div class="control-group {{ "error" if subfield.errors }}" id="error-group-{{ subfield.name }}"> <div class="control-label {{ "error" if subfield.errors }}"> {% if "submit" not in subfield.__html__() and "pluploader" not in subfield.__html__() %} {% set label_class = (' required' if subfield.required else '') %} {{ subfield.label(class_=label_class) }} {% endif %} </div> <div class="controls" id="field-{{ subfield.name }}"> {% if subfield._icon_html and "pluploader" not in subfield.__html__() and not field.ckeditor %} <div class="input-prepend"> <span class="add-on"> {{ subfield._icon_html|safe }} </span> {% elif "pluploader" not in subfield.__html__() and not field.ckeditor %} <div style="margin-left: 27px;"> {% else %} <div> {% endif %} {{ subfield(class_=field.short_name) }} </div> {% if subfield.errors %} {% for error in subfield.errors %} <div class="alert alert-error help-inline error-list-{{ subfield.name }}">{{ error }}</div> {% endfor %} {% endif %} <div class="alert alert-error help-inline" id="error-{{ subfield.name }}" style="display:none;">error message</div> <div class="alert alert-info help-inline" id="info-{{ subfield.name }}" style="display:none;">info message</div> <div class="alert alert-success help-inline" id="success-{{ subfield.name }}" style="display:none;">success message</div> </div> </div> {% if ("keywords" in field.__html__()) %} <div class="control-group" style="display: none;"> <input name="keywords-{{ field.short_name}}" type="text" value=""> </div> {% endif %} {% endfor %} <hr> {% else %} <div class="controls" id="field-{{ field.name }}"> {% if field._icon_html and "pluploader" not in field.__html__() and not field.ckeditor %} <div class="input-prepend"> <span class="add-on"> {{ field._icon_html|safe }} </span> {% elif "pluploader" not in field.__html__() and not field.ckeditor %} <div style="margin-left: 27px;"> {% else %} <div> {% endif %} {{ field(class_=field.short_name) }} </div> {% if field.errors %} {% for error in field.errors %} <div class="alert alert-error help-inline error-list-{{ field.name }}">{{ error }}</div> {% endfor %} {% endif %} <div class="alert alert-error help-inline" id="error-{{ field.name }}" style="display:none;">error message</div> <div class="alert alert-info help-inline" id="info-{{ field.name }}" style="display:none;">info message</div> <div class="alert alert-success help-inline" id="success-{{ field.name }}" style="display:none;">success message</div> </div> </div> {% if ("keywords" in field.__html__()) %} <div class="control-group" style="display: none;"> <input name="keywords-{{ field.short_name}}" type="text" value=""> </div> {% endif %} {% endif %} {% endfor %} </fieldset> </form> <div class="alert alert-error" id="empty-fields-error" style="font-size:12px; display:none;"></div> {% endblock %} {% block javascript %} {{ super() }} +<!-- yahooapis is imported for pluploader --> <script type="text/javascript" src="http://bp.yahooapis.com/2.4.21/browserplus-min.js"></script> <script type="text/javascript"> $(document).ready(function() { var required_fields = {{ form.required_field_names|tojson|safe }}; webdeposit_init_plupload('.pluploader', '{{ url_for('webdeposit.plupload', deposition_type=deposition_type, uuid=uuid) }}', '{{ url_for('webdeposit.plupload_delete', deposition_type=deposition_type, uuid=uuid) }}', '{{ url_for('webdeposit.plupload_get_file', deposition_type=deposition_type, uuid=uuid) }}', {{ form.files|safe }}); webdeposit_input_error_check('#submitForm input, #submitForm textarea, #submitForm select', '{{ url_for("webdeposit.error_check", deposition_type=deposition_type, uuid=uuid) }}', required_fields); webdeposit_check_status('{{ url_for('webdeposit.check_status', deposition_type=deposition_type, uuid=uuid) }}'); {% for field in form %} {% if field.autocomplete %} webdeposit_field_autocomplete('input[name="{{ field.name }}"]', '{{ url_for("webdeposit.autocomplete", deposition_type=deposition_type, uuid=uuid, type=field.name) }}'); {% endif %} {% if field.ckeditor %} webdeposit_ckeditor_init( '{{ field.id }}', '{{ url_for("webdeposit.error_check", deposition_type=deposition_type, uuid=uuid) }}', required_fields ); {% endif %} {% endfor %} $(".datepicker").datepicker(); $("input#submitButton").click(function(e ) { e.preventDefault(); emptyForm = checkEmptyFields(true, '', required_fields); if (emptyForm[0] == 0){ $('#empty-fields-error').hide('slow'); $('#submitForm').submit(); } else { $('#empty-fields-error').html("These fields are required!</br>" + "<a class='close' data-dismiss='alert' href='#'>×</a>" + emptyForm[1]); $('#empty-fields-error').show('slow'); } }); }); </script> {% endblock %} diff --git a/modules/webdeposit/lib/webdeposit_blueprint.py b/modules/webdeposit/lib/webdeposit_blueprint.py index fb61b824e..1cb60f4ad 100644 --- a/modules/webdeposit/lib/webdeposit_blueprint.py +++ b/modules/webdeposit/lib/webdeposit_blueprint.py @@ -1,396 +1,387 @@ # -*- coding: utf-8 -*- ## ## This file is part of Invenio. ## Copyright (C) 2012, 2013 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. """WebDeposit Flask Blueprint""" import os import shutil import json from glob import iglob from flask import current_app, \ render_template, \ request, \ jsonify, \ redirect, \ url_for, \ flash, \ send_file from werkzeug.utils import secure_filename from uuid import uuid1 as new_uuid from invenio.sqlalchemyutils import db from invenio.webdeposit_model import WebDepositDraft from invenio.webdeposit_load_deposition_types import deposition_types, \ deposition_metadata from invenio.webinterface_handler_flask_utils import _, InvenioBlueprint from invenio.config import CFG_WEBDEPOSIT_UPLOAD_FOLDER from invenio.sherpa_romeo import SherpaRomeoSearch from invenio.webdeposit_utils import get_current_form, \ get_form, \ draft_field_set, \ draft_field_list_add, \ delete_workflow, \ create_workflow, \ get_latest_or_new_workflow, \ get_workflow, \ draft_field_get_all, \ draft_field_error_check, \ draft_field_get, \ set_form_status, \ get_form_status, \ + create_user_file_system, \ CFG_DRAFT_STATUS from invenio.webuser_flask import current_user from invenio.bibworkflow_engine import CFG_WORKFLOW_STATUS from invenio.bibworkflow_model import Workflow blueprint = InvenioBlueprint('webdeposit', __name__, url_prefix='/deposit', config='invenio.websubmit_config', menubuilder=[('main.webdeposit', _('Deposit'), 'webdeposit.index_deposition_types', 2)], breadcrumbs=[(_('Deposit'), 'webdeposit.index_deposition_types')]) @blueprint.route('/upload/<deposition_type>/<uuid>', methods=['POST']) @blueprint.invenio_authenticated def plupload(deposition_type, uuid): """ The file is splitted in chunks on the client-side and it is merged again on the server-side """ if request.method == 'POST': try: chunks = request.form['chunks'] chunk = request.form['chunk'] except KeyError: chunks = None pass name = request.form['name'] current_chunk = request.files['file'] try: - filename = name + "_" + chunk + filename = secure_filename(name) + "_" + chunk except UnboundLocalError: - filename = name - - # Check if webdeposit folder exists - if not os.path.exists(CFG_WEBDEPOSIT_UPLOAD_FOLDER): - os.makedirs(CFG_WEBDEPOSIT_UPLOAD_FOLDER) - - # Create user filesystem - # user/deposition_type/uuid/files - CFG_USER_WEBDEPOSIT_FOLDER = os.path.join(CFG_WEBDEPOSIT_UPLOAD_FOLDER, - "user_" + - str(current_user.get_id())) - if not os.path.exists(CFG_USER_WEBDEPOSIT_FOLDER): - os.makedirs(CFG_USER_WEBDEPOSIT_FOLDER) - - CFG_USER_WEBDEPOSIT_FOLDER = os.path.join(CFG_USER_WEBDEPOSIT_FOLDER, - deposition_type) - if not os.path.exists(CFG_USER_WEBDEPOSIT_FOLDER): - os.makedirs(CFG_USER_WEBDEPOSIT_FOLDER) - - CFG_USER_WEBDEPOSIT_FOLDER = os.path.join(CFG_USER_WEBDEPOSIT_FOLDER, - uuid) - if not os.path.exists(CFG_USER_WEBDEPOSIT_FOLDER): - os.makedirs(CFG_USER_WEBDEPOSIT_FOLDER) + filename = secure_filename(name) + + CFG_USER_WEBDEPOSIT_FOLDER = create_user_file_system(current_user.get_id(), + deposition_type, + uuid) # Save the chunk current_chunk.save(os.path.join(CFG_USER_WEBDEPOSIT_FOLDER, filename)) unique_filename = "" if chunks is None: # file is a single chunk - unique_filename = str(new_uuid()) + name + unique_filename = str(new_uuid()) + filename old_path = os.path.join(CFG_USER_WEBDEPOSIT_FOLDER, filename) - file_path = os.path.join(CFG_USER_WEBDEPOSIT_FOLDER, unique_filename) + file_path = os.path.join(CFG_USER_WEBDEPOSIT_FOLDER, + unique_filename) os.rename(old_path, file_path) # Rename the chunk size = os.path.getsize(file_path) file_metadata = dict(name=name, file=file_path, size=size) draft_field_list_add(current_user.get_id(), uuid, "files", file_metadata) elif int(chunk) == int(chunks) - 1: '''All chunks have been uploaded! start merging the chunks''' - + filename = secure_filename(name) chunk_files = [] - for filename in iglob(os.path.join(CFG_USER_WEBDEPOSIT_FOLDER, name + '_*')): - chunk_files.append(filename) + for chunk_file in iglob(os.path.join(CFG_USER_WEBDEPOSIT_FOLDER, + filename + '_*')): + chunk_files.append(chunk_file) # Sort files in numerical order chunk_files.sort(key=lambda x: int(x.split("_")[-1])) - unique_filename = str(new_uuid()) + name + unique_filename = str(new_uuid()) + filename file_path = os.path.join(CFG_USER_WEBDEPOSIT_FOLDER, unique_filename) destination = open(file_path, 'wb') for chunk in chunk_files: shutil.copyfileobj(open(chunk, 'rb'), destination) os.remove(chunk) destination.close() + current_app.logger.info(file_path) size = os.path.getsize(file_path) + current_app.logger.info(size) file_metadata = dict(name=name, file=file_path, size=size) - draft_field_list_add(current_user.get_id(), uuid, - "files", json.dumps(file_metadata)) + "files", file_metadata) return unique_filename @blueprint.route('/plupload_delete/<deposition_type>/<uuid>', methods=['GET', 'POST']) @blueprint.invenio_authenticated def plupload_delete(deposition_type, uuid): if request.method == 'POST': files = draft_field_get(current_user.get_id(), uuid, "files") result = "File Not Found" filename = request.form['filename'] files = draft_field_get(current_user.get_id(), uuid, "files") for index, f in enumerate(files): if filename == f['file'].split('/')[-1]: # get the unique name from the path os.remove(f['file']) del files[index] result = str(files) + " " draft_field_set(current_user.get_id(), uuid, "files", files) result = "File " + f['name'] + " Deleted" break return result @blueprint.route('/plupload_get_file/<deposition_type>/<uuid>', methods=['GET']) @blueprint.invenio_authenticated def plupload_get_file(deposition_type, uuid): filename = request.args.get('filename') tmp = "" files = draft_field_get(current_user.get_id(), uuid, "files") for f in files: tmp += f['file'].split('/')[-1] + '<br><br>' if filename == f['file'].split('/')[-1]: return send_file(f['file'], attachment_filename=f['name'], as_attachment=True) return "filename: " + filename + '<br>' + tmp @blueprint.route('/check_status/<deposition_type>/<uuid>/', methods=['GET', 'POST']) @blueprint.invenio_authenticated def check_status(deposition_type, uuid): form_status = get_form_status(current_user.get_id(), uuid) return jsonify({"status": form_status}) @blueprint.route('/<deposition_type>/_autocomplete/<uuid>', methods=['GET', 'POST']) @blueprint.invenio_authenticated def autocomplete(deposition_type, uuid): """ Returns a list with of suggestions for the field based on the current value """ query = request.args.get('term') # value field_type = request.args.get('type') # field limit = request.args.get('limit', 50, type=int) form = get_current_form(current_user.get_id(), uuid=uuid)[1] form.__dict__["_fields"][field_type].process_data(query) #Check if field has an autocomplete function if hasattr(form.__dict__["_fields"][field_type], "autocomplete"): return jsonify(results=form.__dict__["_fields"][field_type].autocomplete()[:limit]) else: return jsonify(results=[]) @blueprint.route('/<deposition_type>/_ISSN/<uuid>', methods=['GET', 'POST']) # @cache.cached(timeout=50, key_prefix='issn') def autocomplete_ISSN_Conditions(deposition_type, uuid): query = request.args.get('title') s = SherpaRomeoSearch() s.search_journal(query) response = dict() response['issn'] = s.parser.get_issn() response['conditions'] = s.parser.get_conditions() draft_id, form = get_current_form(current_user.get_id(), uuid=uuid) draft_field_set(current_user.get_id(), \ draft_id, \ "issn", \ response['issn']) draft_field_set(current_user.get_id(), \ draft_id, \ "conditions", \ response['conditions']) return json.dumps(response) @blueprint.route('/<deposition_type>/_errorCheck/<uuid>') @blueprint.invenio_authenticated def error_check(deposition_type, uuid): """ Used for field error checking """ value = request.args.get('attribute') field_name = request.args.get('name') if field_name == "": return "{}" draft_field_set(current_user.get_id(), uuid, field_name, value) check_result = draft_field_error_check(current_user.get_id(), \ uuid, field_name, value) try: return jsonify(check_result) except TypeError: return jsonify({"error_message": "", "error": 0}) @blueprint.route('/<deposition_type>/delete/<uuid>') @blueprint.invenio_authenticated def delete(deposition_type, uuid): """ Deletes the whole deposition with uuid=uuid (including form drafts) redirects to load another workflow """ delete_workflow(current_user.get_id(), deposition_type, uuid) flash(_('Deposition %s deleted!') % (uuid,), 'error') return redirect(url_for("webdeposit.index", \ deposition_type=deposition_type)) @blueprint.route('/<deposition_type>/new/') @blueprint.invenio_authenticated def create_new(deposition_type): """ Creates new deposition """ workflow = create_workflow(current_user.get_id(), deposition_type) uuid = workflow.get_uuid() flash(_('Deposition %s created!') % (uuid,), 'info') return redirect(url_for("webdeposit.add", deposition_type=deposition_type, uuid=uuid)) @blueprint.route('/') def index_deposition_types(): """ Renders the deposition types (workflows) list """ current_app.config['breadcrumbs_map'][request.endpoint] = [ - (_('Home'), '')] + blueprint.breadcrumbs - drafts = dict(db.session.query(Workflow.name, - db.func.count(db.func.distinct(WebDepositDraft.uuid))).\ - join(WebDepositDraft.workflow).\ - filter(db.and_( - Workflow.user_id == current_user.get_id(), - Workflow.status == CFG_WORKFLOW_STATUS['running'] - )).\ - group_by(Workflow.name).all()) - - return render_template('webdeposit_index_deposition_types.html', \ + (_('Home'), '')] + blueprint.breadcrumbs + drafts = dict( + db.session.query(Workflow.name, + db.func.count( + db.func.distinct(WebDepositDraft.uuid))). + join(WebDepositDraft.workflow). + filter(db.and_(Workflow.user_id == current_user.get_id(), + Workflow.status != CFG_WORKFLOW_STATUS.FINISHED)). + group_by(Workflow.name).all()) + + return render_template('webdeposit_index_deposition_types.html', deposition_types=deposition_types, drafts=drafts) @blueprint.route('/<deposition_type>/') @blueprint.invenio_authenticated def index(deposition_type): current_app.config['breadcrumbs_map'][request.endpoint] = [ (_('Home'), '')] + blueprint.breadcrumbs + [(deposition_type, None)] user_id = current_user.get_id() drafts = draft_field_get_all(user_id, deposition_type) # drafts = WebDepositDraft.query.filter(db.and_( # WebDepositDraft.user_id == current_user.get_id(), # WebDepositDraft.deposition_type == deposition_type, # WebDepositWorkflow.status == CFG_WEBDEPOSIT_WORKFLOW_STATUS['running'] # )).group_by(WebDepositDraft.uuid).all() return render_template('webdeposit_index.html', drafts=drafts, deposition_type=deposition_type, deposition_types=deposition_types) @blueprint.route('/<deposition_type>/<uuid>', methods=['GET', 'POST']) @blueprint.invenio_authenticated def add(deposition_type, uuid=None): """ FIXME: add documentation """ status = 0 if deposition_type not in deposition_metadata: flash(_('Invalid deposition type.'), 'error') return redirect(url_for('.index_deposition_types')) elif uuid is None: # get the latest one. if there is no workflow created # lets create a new workflow with given deposition type workflow = get_latest_or_new_workflow(deposition_type) uuid = workflow.get_uuid() #flash(_('Deposition %s') % (uuid,), 'info') return redirect(url_for('.add', deposition_type=deposition_type, uuid=uuid)) else: # get workflow with specific uuid workflow = get_workflow(deposition_type, uuid) current_app.config['breadcrumbs_map'][request.endpoint] = [ (_('Home'), '')] + blueprint.breadcrumbs + \ [(deposition_type, 'webdeposit.index', {'deposition_type': deposition_type}), (uuid, 'webdeposit.add', {'deposition_type': deposition_type, 'uuid': uuid})] if request.method == 'POST': # Save the files for (field, uploaded_file) in request.files.items(): filename = secure_filename(uploaded_file.filename) if filename == "": continue - file_path = os.path.join(CFG_WEBDEPOSIT_UPLOAD_FOLDER, filename) + + CFG_USER_WEBDEPOSIT_FOLDER = create_user_file_system(current_user.get_id(), + deposition_type, + uuid) + unique_filename = str(new_uuid()) + filename + file_path = os.path.join(CFG_USER_WEBDEPOSIT_FOLDER, unique_filename) uploaded_file.save(file_path) - draft_field_list_add(current_user.get_id(), - uuid, - "files", - file_path) + size = os.path.getsize(file_path) + file_metadata = dict(name=filename, file=file_path, size=size) + draft_field_list_add(current_user.get_id(), uuid, + "files", file_metadata) # Save form values for (field_name, value) in request.form.items(): if "submit" in field_name.lower(): continue draft_field_set(current_user.get_id(), uuid, field_name, value) form = get_form(current_user.get_id(), uuid) # Validate form if not form.validate(): # render the form with error messages return render_template('webdeposit_add.html', - **workflow.get_output(form_validation=True)) + **workflow.get_output(form_validation=True)) #Set the latest form status to finished set_form_status(current_user.get_id(), uuid, CFG_DRAFT_STATUS['finished']) workflow.run() status = workflow.get_status() if status == 0: # render current step of the workflow return render_template('webdeposit_add.html', **workflow.get_output()) elif status == CFG_WORKFLOW_STATUS['finished']: flash(_('Deposition %s has been successfully finished.') % (uuid, ), 'success') return redirect(url_for('.index_deposition_types')) else: flash(_('Deposition %s has return error code %d.') % (uuid, status), 'error') current_app.logger.error('Deposition: %s has return error code: %d' % (uuid, status)) return redirect(url_for('.index_deposition_types')) diff --git a/modules/webdeposit/lib/webdeposit_form.js b/modules/webdeposit/lib/webdeposit_form.js index edca6b045..0d3e9c76c 100644 --- a/modules/webdeposit/lib/webdeposit_form.js +++ b/modules/webdeposit/lib/webdeposit_form.js @@ -1,386 +1,389 @@ /* * This file is part of Invenio. * Copyright (C) 2013 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. */ /* * Plupload */ function unique_ID(){ return Math.round(new Date().getTime() + (Math.random() * 100)); } function webdeposit_init_plupload(selector, url, delete_url, get_file_url, db_files) { uploader = new plupload.Uploader({ // General settings runtimes : 'html5', url : url, max_file_size : '460mb', chunk_size : '1mb', //unique_names : true, browse_button : 'pickfiles', - drop_element : 'filebox', + drop_element : 'filebox' // Specify what files to browse for - filters : [ - {title : "Image files", extensions : "jpg,gif,png,tif"}, - {title : "Compressed files", extensions : "rar,zip,tar,gz"}, - {title : "PDF files", extensions : "pdf"} - ] + //filters : [ + // {title : "Image files", extensions : "jpg,gif,png,tif"}, + // {title : "Compressed files", extensions : "rar,zip,tar,gz"}, + // {title : "PDF files", extensions : "pdf"} + //] }); uploader.init(); $(function() { if (!jQuery.isEmptyObject(db_files)){ $('#file-table').show('slow'); $.each(db_files, function(i, file) { // Simulate a plupload file object id = unique_ID(); var plfile = new plupload.File({ id: id, name: file.name, size: file.size }); // Dont touch it! // For some reason the constructor doesn't initialize // the data members plfile.id = id, plfile.name = file.name; plfile.size = file.size; plfile.loaded = file.size; plfile.status = 5; plfile.percent = 100; plfile.unique_filename = file.unique_filename; /////// uploader.files.push(plfile); $('#filelist').append( '<tr id="' + plfile.id + '" style="display:none;">' + - '<td><a href="' + get_file_url + "?filename=" + plfile.unique_filename + '">' + plfile.name + '</a></td>' - + '<td>' + plupload.formatSize(plfile.size) + '</td>' - + '<td width="30%"><div class="progress active"><div class="bar" style="width: 100%;"></div></div></td>' - + '<td><a id="' + plfile.id + '_rm" class="rmlink"><i class="icon-trash"></i></a></td>' - + '</tr>'); + '<td><a href="' + get_file_url + "?filename=" + plfile.unique_filename + '">' + plfile.name + '</a></td>' + + '<td>' + plupload.formatSize(plfile.size) + '</td>' + + '<td width="30%"><div class="progress active"><div class="bar" style="width: 100%;"></div></div></td>' + + '<td><a id="' + plfile.id + '_rm" class="rmlink"><i class="icon-trash"></i></a></td>' + + '</tr>'); $('#filelist #' + plfile.id).show('fast'); $("#" + plfile.id + "_rm").on("click", function(event){ uploader.removeFile(plfile); }); }); } }); $('#uploadfiles').click(function(e) { uploader.start(); $('#uploadfiles').hide(); $('#stopupload').show(); e.preventDefault(); }); $('#stopupload').click(function(d){ uploader.stop(); $('#stopupload').hide(); $('#uploadfiles').show(); $.each(uploader.files, function(i, file) { if (file.loaded < file.size){ $("#" + file.id + "_rm").show(); $('#' + file.id + " .bar").css('width', "0%"); } }); }); uploader.bind('FilesRemoved', function(up, files) { $.each(files, function(i, file) { $('#filelist #' + file.id).hide('fast'); if (file.loaded == file.size) { $.ajax({ type: "POST", url: delete_url, data: $.param({ filename: file.unique_filename }) }); } }); - if(uploader.files.length == 0){ + if(uploader.files.length === 0){ $('#uploadfiles').addClass("disabled"); $('#file-table').hide('slow'); } }); uploader.bind('UploadProgress', function(up, file) { $('#' + file.id + " .bar").css('width', file.percent + "%"); console.log("Progress " + file.name + " - " + file.percent); }); uploader.bind('UploadFile', function(up, file) { $('#' + file.id + "_rm").hide(); }); uploader.bind('FilesAdded', function(up, files) { $('#uploadfiles').removeClass("disabled"); $('#file-table').show('slow'); $.each(files, function(i, file) { $('#filelist').append( - '<tr id="' + file.id + '" style="display:none;z-index:-100;">' - + '<td id="' + file.id + '_link">' + file.name + '</td>' - + '<td>' + plupload.formatSize(file.size) + '</td>' - + '<td width="30%"><div class="progress progress-striped active"><div class="bar" style="width: 0%;"></div></div></td>' - + '<td><a id="' + file.id + '_rm" class="rmlink"><i class="icon-trash"></i></a></td>' - + '</tr>'); + '<tr id="' + file.id + '" style="display:none;z-index:-100;">' + + '<td id="' + file.id + '_link">' + file.name + '</td>' + + '<td>' + plupload.formatSize(file.size) + '</td>' + + '<td width="30%"><div class="progress progress-stri´ped active"><div class="bar" style="width: 0%;"></div></div></td>' + + '<td><a id="' + file.id + '_rm" class="rmlink"><i class="icon-trash"></i></a></td>' + + '</tr>'); $('#filelist #' + file.id).show('fast'); $('#' + file.id + '_rm').on("click", function(event){ uploader.removeFile(file); }); }); }); uploader.bind('FileUploaded', function(up, file, responseObj) { console.log("Done " + file.name); $('#' + file.id + " .progress").removeClass("progress-striped"); $('#' + file.id + " .bar").css('width', "100%"); $('#' + file.id + '_rm').show(); $('#' + file.id + '_link').html('<a href="' + get_file_url + "?filename=" + responseObj.response + '">' + file.name + '</a>'); file.unique_filename = responseObj.response; - if (uploader.total.queued == 0) + if (uploader.total.queued === 0) $('#stopupload').hide(); $('#uploadfiles').addClass('disabled'); $('#uploadfiles').show(); }); } /* Error checking */ var errors = 0; var oldJournal; function webdeposit_handle_field_data(name, value, data, url, required_fields) { // handles a response from the server for the field if (data.error == 1) { errorMsg = data.error_message; $('#error-' + name).html(errorMsg); $('.error-list-' + name).hide('slow'); $('#error-' + name).show('slow'); $("#error-group-" + name).addClass('error'); errors++; } else { $('#error-' + name).hide('slow'); $('.error-list-' + name).hide('slow'); $("#error-group-" + name).removeClass('error'); if (errors > 0) errors--; emptyForm = checkEmptyFields(false, name, required_fields); - if (emptyForm[0] == 0) { + if (emptyForm[0] === 0) { $('#empty-fields-error').hide('slow'); } else { $('#empty-fields-error').html("These fields are required!</br>" + emptyForm[1]); $('#empty-fields-error').show(); } } dismiss = '<button type="button" class="close" data-dismiss="alert">×</button>'; if (data.success == 1) { - success = '<div class="alert alert-success help-inline" id="success-' + name + '" style="display:none;">' - + dismiss + data.success_message + + success = '<div class="alert alert-success help-inline" id="success-' + name + '" style="display:none;">' + + dismiss + data.success_message + '</div>'; $('#success-' + name).remove(); $('#field-' + name).append(success); $('#success-' + name).show('slow'); } else { $('#success-' + name).remove(); } if (data.info == 1) { - info = '<div class="alert alert-info help-inline" id="info-' + name + '" style="display:none;">' - + dismiss + data.info_message + + info = '<div class="alert alert-info help-inline" id="info-' + name + '" style="display:none;">' + + dismiss + data.info_message + '</div>'; $('#info-' + name).remove(); $('#field-' + name).append(info); $('#info-' + name).css('margin-top', '10px'); $('#info-' + name).css('clear', 'both'); $('#info-' + name).css('float', 'left'); $('#info-' + name).show('slow'); } else { $('#info-' + name).remove(); } if (data.fields) { $.each(data.fields, function(name, value) { $('#error-' + name).hide('slow'); errors--; old_value = $('[name=' + name + ']').val(); if (old_value != value) { - $('[name=' + name + ']').val(value); + if (ckeditor.name == name) + ckeditor.setData(value); + else + $('[name=' + name + ']').val(value); webdeposit_handle_new_value(name, value, url, required_fields); } }); } - } function webdeposit_handle_new_value(name, value, url, required_fields) { // sends an ajax request with the data $.getJSON(url, { name: name, attribute: value }, function(data){ webdeposit_handle_field_data(name, value, data, url, required_fields); }); } function webdeposit_input_error_check(selector, url, required_fields) { $(selector).change( function() { - name = this.name; - value = this.value; - $.getJSON(url, { - name: name, - attribute: value - }, function(data){ - webdeposit_handle_field_data(name, value, data, url, required_fields) - }); + name = this.name; + value = this.value; + $.getJSON(url, { + name: name, + attribute: value + }, function(data){ + webdeposit_handle_field_data(name, value, data, url, required_fields); + }); return false; }); } /* * CKEditor */ function webdeposit_ckeditor_init(selector, url, required_fields) { CKEDITOR.replace(selector); - var ckeditor = CKEDITOR.instances[selector]; + ckeditor = CKEDITOR.instances[selector]; ckeditor.on('blur',function(event){ - webdeposit_handle_new_value(selector, ckeditor.getData(), url, required_fields) + webdeposit_handle_new_value(selector, ckeditor.getData(), url, required_fields); }); } /********************************************************/ function checkEmptyFields(all_fields, field, required_fields) { var emptyFields = ""; var empty = 0; $(":text, :file, :checkbox, select, textarea").each(function() { // Run the checks only for fields that are required if ($.inArray(this.name, required_fields) > -1) { if(($(this).val() === "") || ($(this).val() === null)) { emptyFields += "- " + $("label[for='"+this.name+"']").html() + "</br>"; if ( (all_fields === true) || (field == this.name)) { $('#error-'+this.name).html($("label[for='"+this.name+"']").html() + " field is required!"); $('#error-'+this.name).show('slow'); } empty = 1; } else { $('#error-'+this.name).hide('slow'); } } }); // Return the text only if all fields where requested if ( (empty == 1) && all_fields) return [1, emptyFields]; else return [0, emptyFields]; } /* Sherpa Romeo auto completion "_autocomplete?type=journal" */ function type(o){ return !!o && Object.prototype.toString.call(o).match(/(\w+)\]/)[1]; } var autocomplete_request = $.ajax(); function webdeposit_field_autocomplete(selector, url) { var source = function(query) { $(selector).addClass('ui-autocomplete-loading'); var typeahead = this; autocomplete_request.abort(); autocomplete_request = $.ajax({ type: 'GET', url: url, data: $.param({ term: query }) }).done(function(data) { typeahead.process(data.results); $(selector).removeClass('ui-autocomplete-loading'); }).fail(function(data) { typeahead.process([query]); $(selector).removeClass('ui-autocomplete-loading'); }); }; + $(selector).typeahead({ source: source, minLength: 5, items: 50 }); } function webdeposit_check_status(url){ setInterval(function() { $.ajax({ type: 'GET', url: url }).done(function(data) { if (data.status == 1) location.reload(); - }) - }, 7000); + }); + }, 10000); } /* $(function() { $('#keywords').keyup( function() { keywords = $('#keywords').val(); if (keywords.indexOf(" ") == -1) return; keywordsArr = keywords.split(" "); txt = ""; $.each(keywordsArr, function(index, value) { if (value != "") txt += "<div class='label label-info' id='"+value+"' style='margin-right:5px;margin-bottom:5px; display:inline-block;padding-right:2px;'><i class='icon-tag icon-white'></i><span style='margin-left:1px;margin-right:1px;'>"+ value +"</span><span id='delete_tag'><i class='icon-remove-sign icon-white' style='margin-left:5px;cursor:pointer;'></i></span></div>" }); newtags = $('#editable').html() + txt; $('#editable').html(newtags); $('#keywords').val(''); $('#editable').show(); tempkeywords = $('#keywords2').val(); $('#keywords2').val(tempkeywords+" "+keywords); }); }); $('#editable').on("click", "#delete_tag", function(event) { alert(this); alert("click!!!!"); }); */ diff --git a/modules/webdeposit/lib/webdeposit_utils.py b/modules/webdeposit/lib/webdeposit_utils.py index 7de3ff084..7ed04cb89 100644 --- a/modules/webdeposit/lib/webdeposit_utils.py +++ b/modules/webdeposit/lib/webdeposit_utils.py @@ -1,532 +1,578 @@ # -*- coding: utf-8 -*- ## ## This file is part of Invenio. ## Copyright (C) 2012, 2013 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. +import os from datetime import datetime from sqlalchemy import desc from wtforms import FormField from sqlalchemy.orm.exc import NoResultFound from invenio.sqlalchemyutils import db from invenio.webdeposit_model import WebDepositDraft from invenio.bibworkflow_model import Workflow from invenio.bibworkflow_engine import CFG_WORKFLOW_STATUS from invenio.webdeposit_load_forms import forms from invenio.webuser_flask import current_user from invenio.webdeposit_load_deposition_types import deposition_metadata from invenio.webdeposit_workflow import DepositionWorkflow +from invenio.config import CFG_WEBDEPOSIT_UPLOAD_FOLDER """ Deposition Type Functions """ CFG_DRAFT_STATUS = { 'unfinished': 0, 'finished': 1 } def get_latest_or_new_workflow(deposition_type): """ Creates new workflow or returns a new one """ user_id = current_user.get_id() wf = deposition_metadata[deposition_type]["workflow"] # get latest draft in order to get workflow's uuid webdeposit_draft = db.session.query(WebDepositDraft).\ join(WebDepositDraft.workflow).\ filter( Workflow.user_id == user_id, Workflow.name == deposition_type, Workflow.module_name == 'webdeposit', - Workflow.status == CFG_WORKFLOW_STATUS['running']).\ + Workflow.status != CFG_WORKFLOW_STATUS.FINISHED).\ order_by(db.desc(WebDepositDraft.timestamp)).\ first() if webdeposit_draft is None: # We didn't find other workflows # Let's create a new one return DepositionWorkflow(deposition_type=deposition_type, workflow=wf) # Create a new workflow # based on the latest draft's uuid uuid = webdeposit_draft.uuid return DepositionWorkflow(deposition_type=deposition_type, workflow=wf, uuid=uuid) def get_workflow(deposition_type, uuid): """ Returns a workflow instance with uuid=uuid or None """ try: wf = deposition_metadata[deposition_type]["workflow"] except KeyError: # deposition type not found return None return DepositionWorkflow(uuid=uuid, deposition_type=deposition_type, workflow=wf) def create_workflow(user_id, deposition_type): """ Creates a new workflow and returns it """ try: wf = deposition_metadata[deposition_type]["workflow"] except KeyError: # deposition type not found return None return DepositionWorkflow(deposition_type=deposition_type, workflow=wf) def delete_workflow(user_id, deposition_type, uuid): """ Deletes all workflow related data (workflow and drafts) """ db.session.query(Workflow).filter_by(\ uuid=uuid, user_id=user_id).\ delete() db.session.query(WebDepositDraft).filter_by(\ uuid=uuid).\ delete() db.session.commit() def create_deposition_type(user_id, deposition_type): """Creates a deposition object (initiates workflow) and returns the uuid and the form to be rendered TODO: check if dep type exists (deprecated, use create_workflow instead) """ try: wf = deposition_metadata[deposition_type]["workflow"] except KeyError: # deposition_type not found return None, None webdep_workflow = DepositionWorkflow(workflow=wf, deposition_type=deposition_type,\ user_id=user_id) webdep_workflow.run() uuid = webdep_workflow.get_uuid() return get_current_form(user_id, uuid=uuid) def get_current_form(user_id, deposition_type=None, uuid=None): """Returns the latest draft(wtform object) of the deposition_type or the form with the specific uuid. if it doesn't exist, creates a new one """ if user_id is None: return None try: if uuid is not None: webdeposit_draft_query = db.session.query(WebDepositDraft).\ join(Workflow).\ filter( Workflow.user_id == user_id, WebDepositDraft.uuid == uuid) # get the draft with the max step, the latest webdeposit_draft = max(webdeposit_draft_query.all(), key=lambda w: w.step) elif deposition_type is not None: webdeposit_draft = db.session.query(WebDepositDraft).\ join(Workflow).\ filter( Workflow.user_id == user_id, Workflow.name == deposition_type, WebDepositDraft.timestamp == db.func.max( WebDepositDraft.timestamp).select())[0] else: webdeposit_draft = db.session.query(WebDepositDraft).\ join(Workflow).\ filter( Workflow.user_id == user_id, WebDepositDraft.timestamp == db.func.max( WebDepositDraft.timestamp).select())[0] except NoResultFound: # No Form draft was found return None, None form = forms[webdeposit_draft.form_type]() draft_data = webdeposit_draft.form_values for field_name, field_data in form.data.iteritems(): if isinstance(form.__dict__['_fields'][field_name], FormField) \ and field_name in draft_data: subfield_names = form.__dict__['_fields'][field_name].form.__dict__['_fields'].keys() #upperfield_name, subfield_name = field_name.split('-') for subfield_name in subfield_names: if subfield_name in draft_data[field_name]: form.__dict__["_fields"][field_name].\ form.__dict__["_fields"][subfield_name].\ process_data(draft_data[field_name][subfield_name]) elif field_name in draft_data: form[field_name].process_data(draft_data[field_name]) return webdeposit_draft.uuid, form def get_form(user_id, uuid, step=None): """ Returns the current state of the workflow in a form or a previous state (step) """ if step is None: webdeposit_draft_query = db.session.query(WebDepositDraft).\ join(Workflow).\ filter( Workflow.user_id == user_id, WebDepositDraft.uuid == uuid) try: # get the draft with the max step webdeposit_draft = max(webdeposit_draft_query.all(), key=lambda w: w.step) except ValueError: return None else: webdeposit_draft = db.session.query(WebDepositDraft).\ join(Workflow).\ filter( Workflow.user_id == user_id, WebDepositDraft.uuid == uuid, WebDepositDraft.step == step).one() form = forms[webdeposit_draft.form_type]() draft_data = webdeposit_draft.form_values for field_name, field_data in form.data.iteritems(): if isinstance(form.__dict__['_fields'][field_name], FormField) \ and field_name in draft_data: subfield_names = form.__dict__['_fields'][field_name].\ form.__dict__['_fields'].keys() #upperfield_name, subfield_name = field_name.split('-') for subfield_name in subfield_names: if subfield_name in draft_data[field_name]: form.__dict__["_fields"][field_name].\ form.__dict__["_fields"][subfield_name].\ process_data(draft_data[field_name][subfield_name]) elif field_name in draft_data: form[field_name].process_data(draft_data[field_name]) - import json if 'files' in draft_data: + # FIXME: sql alchemy(0.8.0) returns the value from the + # column form_values with keys and values in unicode. + # This creates problem when the dict is rendered + # in the page to be used by javascript functions. There must + # be a more elegant way than decoding the dict from unicode. + + draft_data['files'] = decode_dict_from_unicode(draft_data['files']) for file_metadata in draft_data['files']: # Replace the path with the unique filename + if isinstance(file_metadata, basestring): + import json + file_metadata = json.loads(file_metadata) filepath = file_metadata['file'].split('/') unique_filename = filepath[-1] file_metadata['unique_filename'] = unique_filename del file_metadata['file'] form.__setattr__('files', draft_data['files']) else: form.__setattr__('files', {}) return form def get_form_status(user_id, uuid, step=None): if step is None: webdeposit_draft_query = db.session.query(WebDepositDraft).\ join(Workflow).\ filter( Workflow.user_id == user_id, WebDepositDraft.uuid == uuid) try: # get the draft with the max step webdeposit_draft = max(webdeposit_draft_query.all(), key=lambda w: w.step) except ValueError: return None else: webdeposit_draft = db.session.query(WebDepositDraft).\ join(Workflow).\ filter( Workflow.user_id == user_id, WebDepositDraft.uuid == uuid, WebDepositDraft.step == step).one() return webdeposit_draft.status def set_form_status(user_id, uuid, status, step=None): if step is None: webdeposit_draft_query = db.session.query(WebDepositDraft).\ join(Workflow).\ filter( Workflow.user_id == user_id, WebDepositDraft.uuid == uuid) try: # get the draft with the max step webdeposit_draft = max(webdeposit_draft_query.all(), key=lambda w: w.step) except ValueError: return None else: webdeposit_draft = db.session.query(WebDepositDraft).\ join(Workflow).\ filter( Workflow.user_id == user_id, WebDepositDraft.uuid == uuid, WebDepositDraft.step == step).one() webdeposit_draft.status = status db.session.commit() def get_last_step(steps): if type(steps[-1]) is list: return get_last_step[-1] else: return steps[-1] def get_current_step(user_id, uuid): webdep_workflow = db.session.query(Workflow).filter(\ Workflow.uuid == uuid).one() steps = webdep_workflow.task_counter return get_last_step(steps) """ Draft Functions (or instances of forms) old implementation with redis cache of the functions is provided in comments (works only in the article form, needs to be generic) """ def draft_field_get(user_id, uuid, field_name, subfield_name=None): """ Returns the value of a field or, in case of error, None """ webdeposit_draft_query = db.session.query(WebDepositDraft).\ join(Workflow).\ filter( Workflow.user_id == user_id, WebDepositDraft.uuid == uuid) # get the draft with the max step draft = max(webdeposit_draft_query.all(), key=lambda w: w.step) values = draft.form_values try: if subfield_name is not None: return values[field_name][subfield_name] return values[field_name] except KeyError: return None def draft_field_error_check(user_id, uuid, field_name, value): """ Retrieves the form based on the uuid and returns a json string evaluating the field's value """ form = get_form(user_id, uuid=uuid) subfield_name = None subfield_name = None if '-' in field_name: # check if its subfield field_name, subfield_name = field_name.split('-') form = form.__dict__["_fields"][field_name].form field_name = subfield_name form.__dict__["_fields"][field_name].process_data(value) return form.__dict__["_fields"][field_name].pre_validate(form) def draft_field_set(user_id, uuid, field_name, value): """ Alters the value of a field """ webdeposit_draft_query = db.session.query(WebDepositDraft).\ join(Workflow).\ filter( Workflow.user_id == user_id, WebDepositDraft.uuid == uuid) # get the draft with the max step draft = max(webdeposit_draft_query.all(), key=lambda w: w.step) values = draft.form_values subfield_name = None if '-' in field_name: # check if its subfield field_name, subfield_name = field_name.split('-') if subfield_name is not None: try: values[field_name][subfield_name] = value except (KeyError, TypeError): values[field_name] = dict() values[field_name][subfield_name] = value else: values[field_name] = value # change value #draft.form_values = values #draft.timestamp = datetime.now() # update draft's timestamp webdeposit_draft_query = db.session.query(WebDepositDraft).\ filter(WebDepositDraft.uuid == uuid, WebDepositDraft.step == draft.step).\ update({"form_values": values, "timestamp": datetime.now()}) def draft_field_list_add(user_id, uuid, field_name, value, key=None, subfield=None): """Adds value to field Used for fields that contain multiple values e.g.1: { field_name : value1 } OR { field_name : [value1] } --> { field_name : [value1, value2] } e.g.2 { } --> { field_name : [value] } e.g.3 { } --> { field_name : {key : value} } """ webdeposit_draft_query = db.session.query(WebDepositDraft).filter( WebDepositDraft.uuid == uuid) # get the draft with the max step draft = max(webdeposit_draft_query.all(), key=lambda w: w.step) values = draft.form_values try: if isinstance(values[field_name], list): values[field_name].append(value) elif subfield is not None: if not isinstance(values[field_name], dict): values[field_name] = dict() values[field_name][subfield] = value else: new_values_list = [values[field_name]] new_values_list.append(value) values[field_name] = new_values_list except KeyError: values[field_name] = [value] - webdeposit_draft_query.update({"form_values": values, "timestamp": datetime.now()}) def new_draft(user_id, deposition_type, form_type): """ Creates new draft gets new uuid (deprecated inside workflow context) """ webdeposit_draft = WebDepositDraft(user_id=user_id, \ form_type=form_type, \ form_values={}) db.session.add(webdeposit_draft) db.session.commit() return webdeposit_draft.uuid def get_draft(user_id, uuid, field_name=None): """ Returns draft values in a field_name => field_value dictionary or if field_name is defined, returns the associated value """ webdeposit_draft_query = db.session.query(WebDepositDraft).\ join(Workflow).\ filter( Workflow.user_id == user_id, WebDepositDraft.uuid == uuid) # get the draft with the max step draft = max(webdeposit_draft_query.all(), key=lambda w: w.step) form_values = draft.form_values if field_name is None: return form_values else: try: return form_values[field_name] except KeyError: # field_name doesn't exist return form_values # return whole row def delete_draft(user_id, deposition_type, uuid): """ Deletes the draft with uuid=uuid and returns the most recently used draft if there is no draft left, returns None (usage not recommended inside workflow context) """ db.session.query(WebDepositDraft).filter_by(\ uuid=uuid, \ user_id=user_id).delete() db.session.commit() latest_draft = db.session.query(WebDepositDraft).filter_by(\ user_id=user_id, \ deposition_type=deposition_type).\ order_by(\ desc(WebDepositDraft.timestamp)).\ first() if latest_draft is None: # There is no draft left return None else: return latest_draft.uuid def draft_field_get_all(user_id, deposition_type): """ Returns a list with values of the field_names specified containing all the latest drafts of deposition of type=deposition_type """ ## Select drafts with max step from each uuid. - subquery = db.session.query(WebDepositDraft.uuid, - db.func.max(WebDepositDraft.step)).\ - join(WebDepositDraft.workflow).\ - filter(db.and_( - Workflow.status == CFG_WORKFLOW_STATUS['running'], - Workflow.user_id == user_id, - Workflow.name == deposition_type, - Workflow.module_name == 'webdeposit' - )).\ - group_by(WebDepositDraft.uuid) - - drafts = WebDepositDraft.query.filter(db.tuple_(WebDepositDraft.uuid, - WebDepositDraft.step).\ - in_(subquery)).\ - order_by(db.desc(WebDepositDraft.timestamp)).\ - all() + subquery = \ + db.session.query(WebDepositDraft.uuid, + db.func.max(WebDepositDraft.step)). \ + join(WebDepositDraft.workflow).\ + filter(db.and_(Workflow.status != CFG_WORKFLOW_STATUS.FINISHED, + Workflow.user_id == user_id, + Workflow.name == deposition_type, + Workflow.module_name == 'webdeposit')). \ + group_by(WebDepositDraft.uuid) + + drafts = \ + WebDepositDraft.query. \ + filter(db.tuple_(WebDepositDraft.uuid, WebDepositDraft.step). + in_(subquery)). \ + order_by(db.desc(WebDepositDraft.timestamp)). \ + all() return drafts def set_current_draft(user_id, uuid): webdeposit_draft_query = db.session.query(WebDepositDraft).\ join(Workflow).\ filter( Workflow.user_id == user_id, WebDepositDraft.uuid == uuid) # get the draft with the max step draft = max(webdeposit_draft_query.all(), key=lambda w: w.step) draft.timestamp = datetime.now() db.session.commit() def get_current_draft(user_id, deposition_type): webdeposit_draft = db.session.query(WebDepositDraft).\ join(Workflow).\ filter( Workflow.user_id == user_id, Workflow.name == deposition_type).\ order_by(desc(WebDepositDraft.timestamp)). \ first() return webdeposit_draft + + +def create_user_file_system(user_id, deposition_type, uuid): + # Check if webdeposit folder exists + if not os.path.exists(CFG_WEBDEPOSIT_UPLOAD_FOLDER): + os.makedirs(CFG_WEBDEPOSIT_UPLOAD_FOLDER) + + # Create user filesystem + # user/deposition_type/uuid/files + CFG_USER_WEBDEPOSIT_FOLDER = os.path.join(CFG_WEBDEPOSIT_UPLOAD_FOLDER, + "user_" + str(user_id)) + if not os.path.exists(CFG_USER_WEBDEPOSIT_FOLDER): + os.makedirs(CFG_USER_WEBDEPOSIT_FOLDER) + + CFG_USER_WEBDEPOSIT_FOLDER = os.path.join(CFG_USER_WEBDEPOSIT_FOLDER, + deposition_type) + if not os.path.exists(CFG_USER_WEBDEPOSIT_FOLDER): + os.makedirs(CFG_USER_WEBDEPOSIT_FOLDER) + + CFG_USER_WEBDEPOSIT_FOLDER = os.path.join(CFG_USER_WEBDEPOSIT_FOLDER, + uuid) + if not os.path.exists(CFG_USER_WEBDEPOSIT_FOLDER): + os.makedirs(CFG_USER_WEBDEPOSIT_FOLDER) + + return CFG_USER_WEBDEPOSIT_FOLDER + + +def decode_dict_from_unicode(input): + if isinstance(input, dict): + return {decode_dict_from_unicode(key): decode_dict_from_unicode(value) for key, value in input.iteritems()} + elif isinstance(input, list): + return [decode_dict_from_unicode(element) for element in input] + elif isinstance(input, unicode): + return input.encode('utf-8') + else: + return input diff --git a/modules/webdeposit/lib/webdeposit_validation_utils.py b/modules/webdeposit/lib/webdeposit_validation_utils.py index 1177d5669..cadb6d6e4 100644 --- a/modules/webdeposit/lib/webdeposit_validation_utils.py +++ b/modules/webdeposit/lib/webdeposit_validation_utils.py @@ -1,178 +1,178 @@ # -*- coding: utf-8 -*- ## ## This file is part of Invenio. ## Copyright (C) 2013 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 invenio.dataciteutils import DataciteMetadata from invenio.sherpa_romeo import SherpaRomeoSearch def datacite_doi_validate(field): value = field.data if value == "" or value.isspace(): return dict() datacite = DataciteMetadata(value) if datacite.error: return dict(info=1, info_message="Couldn't retrieve doi metadata") return dict(fields=dict(publisher=datacite.get_publisher(), title=datacite.get_titles(), date=datacite.get_dates(), abstract=datacite.get_description()), success=1, success_message='Datacite.org metadata imported successfully') def sherpa_romeo_issn_validate(field): value = field.data if value == "" or value.isspace(): return dict(error=0, error_message='') s = SherpaRomeoSearch() s.search_issn(value) if s.error: return dict(error=1, error_message=s.error_message) if s.get_num_hits() == 1: journal = s.parser.get_journals(attribute='jtitle') journal = journal[0] publisher = s.parser.get_publishers(journal=journal) if publisher is not None and publisher != []: return dict(error=0, error_message='', fields=dict(journal=journal, publisher=publisher['name'])) else: return dict(error=0, error_message='', fields=dict(journal=journal)) return dict(info=1, info_message="Couldn't find Journal") def sherpa_romeo_publisher_validate(field): value = field.data if value == "" or value.isspace(): return dict(error=0, error_message='') s = SherpaRomeoSearch() s.search_publisher(value) if s.error: return dict(info=1, info_message=s.error_message) conditions = s.parser.get_publishers(attribute='conditions') - if conditions is not None: + if conditions is not None and s.get_num_hits() == 1: conditions = conditions[0] else: conditions = [] if conditions != []: conditions_html = "<u>Conditions</u><br><ol>" if isinstance(conditions['condition'], str): conditions_html += "<li>" + conditions['condition'] + "</li>" else: for condition in conditions['condition']: conditions_html += "<li>" + condition + "</li>" copyright_links = s.parser.get_publishers(attribute='copyrightlinks') if copyright_links is not None and copyright_links != []: copyright_links = copyright_links[0] else: copyright_links = None if isinstance(copyright_links, list): copyright_links_html = "" for copyright in copyright_links['copyrightlink']: copyright_links_html += '<a href="' + copyright['copyrightlinkurl'] + \ '">' + copyright['copyrightlinktext'] + "</a><br>" elif isinstance(copyright_links, dict): if isinstance(copyright_links['copyrightlink'], list): for copyright in copyright_links['copyrightlink']: copyright_links_html = '<a href="' + copyright['copyrightlinkurl'] + \ '">' + copyright['copyrightlinktext'] + "</a><br>" else: copyright = copyright_links['copyrightlink'] copyright_links_html = '<a href="' + copyright['copyrightlinkurl'] + \ '">' + copyright['copyrightlinktext'] + "</a><br>" home_url = s.parser.get_publishers(attribute='homeurl') if home_url is not None and home_url != []: home_url = home_url[0] home_url = '<a href="' + home_url + '">' + home_url + "</a>" else: home_url = None info_html = "" if home_url is not None: info_html += "<p>" + home_url + "</p>" if conditions is not None: info_html += "<p>" + conditions_html + "</p>" if copyright_links is not None: info_html += "<p>" + copyright_links_html + "</p>" if info_html != "": return dict(error=0, error_message='', info=1, info_message=info_html) return dict(error=0, error_message='') def sherpa_romeo_journal_validate(field): value = field.data if value == "" or value.isspace(): return dict(error=0, error_message='') s = SherpaRomeoSearch() s.search_journal(value, 'exact') if s.error: return dict(info=1, info_message=s.error_message) if s.get_num_hits() == 1: issn = s.parser.get_journals(attribute='issn') if issn != [] and issn is not None: issn = issn[0] publisher = s.parser.get_publishers(journal=value) if publisher is not None and publisher != []: return dict(error=0, error_message='', fields=dict(issn=issn, publisher=publisher['name'])) return dict(error=0, error_message='', info=1, info_message="Journal's Publisher not found", fields=dict(publisher="", issn=issn)) else: return dict(info=1, info_message="Couldn't find ISSN") return dict(error=0, error_message='') def number_validate(field, error_message='It must be a number!'): value = field.data if value == "" or value.isspace(): return dict(error=0, error_message='') def is_number(s): try: float(s) return True except ValueError: return False if not is_number(value): try: field.errors.append(error_message) except AttributeError: field.errors = list(field.process_errors) field.errors.append(error_message) return dict(error=1, error_message=error_message) else: return dict(error=0, error_message='')