[RESUELTO] Cómo cargar varios ficheros Javascript desde uno único

¿Cómo cargar varios archivos JS desde un JS único y ejecutar funciones de dentro?

Se puede hacer usando la llamada jQuery getScript, asi:

$.when(
    $.getScript( "/mypath/myscript1.js" ),
    $.getScript( "/mypath/myscript2.js" ),
    $.getScript( "/mypath/myscript3.js" ),
    $.Deferred(function( deferred ){    // esperar a que el DOM esté listo
        $( deferred.resolve );
    })
    ).done(function(){
          //poner aqui tu código. todos los scripts anteriores estarán cargados y listos para usarse
    });

Si no te funciona, asegúrate de que no hay errores de parsing en tus ficheros JS (prueba primero que se carguen bien metiéndolos en un tag <script>

jQuery.getScript() considerará errores de parsing un load fallido y se llamará fail() en vez de done()

(SOLVED) How to center div horizontally and vertically using jQuery

How to center a div horizontally and vertically, no matter if the browser screen is resized?

It is very easy with jQuery…

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="es" xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 	<meta http-equiv="Content-Language" content="es" />
 	<title>Center div horizontally and vertically</title>
 	<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
	<script type="text/javascript">
		jQuery.fn.center = function () {
    		  this.css("position","absolute");
    		  this.css("top", Math.max(0, (($(window).height() - $(this).outerHeight()) / 2) + $(window).scrollTop()) + "px");
    		  this.css("left", Math.max(0, (($(window).width() - $(this).outerWidth()) / 2) + $(window).scrollLeft()) + "px");
    		return this;
		}
		$(window).load(function(){  
			$("#container").center();
		});
		$(window).resize(function(){
			$("#container").center();
		});
	</script>
</head>
<body>	
<div id="container">
	<span>Some content here</span>
</div>
</body>
</html>

Pasar de .mo a .pot y viceversa [RESUELTO]

Algo común cuando instalas un theme de WordPress es que en el path donde se encuentren las traducciones sólo tengas el archivo .mo correspondiente a tu idioma (y no el .po).

Los archivos .mo son binarios y no se pueden editar directamente. Asi que, ¿cómo modificar un archivo de traducción si no tienes el archivo .po correspondiente?

Fácil. En la página http://tools.konstruktors.com/ te ofrecen una herramienta online gratuita para realizar conversiones de .po a .mo y conversiones de .mo a .po

Si lo prefieres, también puedes instalar en tu equipo las gettext-tools y usar la herramienta msgunfmt.

RESUELTO – Conectar a VMware VCenter desde OSX (Mac)

¿Cuál es la forma más sencilla de conectarte a VCenter desde tu Mac? Sigue los pasos del post para instalar VirtualBox y una máquina virtual Windows, después inicia la máquina virtual recién instalada, abre un navegador web, conéctate a tu VCenter y descarga e instala el cliente VMware.

Conectar a Vcenter en Mac (OSX)

Una vez lo hayas hecho, toma un snapshot (instantánea) de tu máquina en VirtualBox. Asi siempre tendrás una instantánea con el cliente vmware instalado, lista para funcionar.

Fácil y ¡gratis!

RESUELTO – Internet Explorer (IE7, IE8, IE9, IE10, IE11) en MAC (OS X)

Muchas veces nos vemos en la obligación de probar cómo se ve una web en Internet Explorer. Inexplicablemente, todavía hay muchos usuarios que emplean Internet Explorer en sus versiones más antiguas (IE6, IE7, IE8, IE9), pese a las obvias desventajas de elegir este navegador.

Internet Explorer en MAC OSX

Desde Windows resulta más sencillo. Pero, ¿cómo ejecutar Internet Explorer desde tu OS X (Mac)?

La solución es sencilla:

1. Instala VirtualBox (descargar el instalador de VirtualBox para OSX)

2. Decide qué versiones de IE quieres instalar, abre Terminal y escribe el comando adecuado en función a la versión que desees *
— Todas las versiones de IE (crearás tantas máquinas virtuales como versiones de IE se instalen)

curl -s https://raw.githubusercontent.com/xdissent/ievms/master/ievms.sh | bash

— Internet Explorer 7 (IE7):

curl -s https://raw.github.com/xdissent/ievms/master/ievms.sh | IEVMS_VERSIONS="7" bash

— Internet Explorer (IE8):

curl -s https://raw.github.com/xdissent/ievms/master/ievms.sh | IEVMS_VERSIONS="8" bash

— Internet Explorer (IE9):

curl -s https://raw.githubusercontent.com/xdissent/ievms/master/ievms.sh | IEVMS_VERSIONS="9" bash

— Internet Explorer (IE10):

curl -s https://raw.githubusercontent.com/xdissent/ievms/master/ievms.sh | IEVMS_VERSIONS="10" bash

— Internet Explorer (IE11):

curl -s https://raw.githubusercontent.com/xdissent/ievms/master/ievms.sh | IEVMS_VERSIONS="11" bash

3. Abre VirtualBox (lo tendrás instalado en “Aplicaciones” > “Virtual Box”) e inicia la máquina virtual adecuada. Se iniciará Windows y tendrás la versión de Internet Explorer que elegiste disponible. Recuerda que la contraseña por defecto de Windows es “Password1”.
Además, puedes realizar un snapshot de las máquinas para “solventar” el problema de la licencia de evaluación de 30 días que Microsoft aplica a su SO. Crea un snapshot nada más instalar las máquinas virtuales y arráncalo. Asi siempre tendrás tus 30 días de evaluación restantes.

Internet Explorer en Mac (resuelto)

* Los comandos del paso 2 son parte del ievsms script de xdissent y se encargan del proceso completo de descarga, conversión e instalación. Más fácil no puede ser 🙂

Nota: Si las URL’s de arriba no funcionan correctamente, puede ser que github haya cambiado la estructura de URL’s de raw.github.com a raw.githubusercontent.com. Corrige las URL’s superiores según este patrón.

Z39.50 command line client: YAZ CLIENT

YAZ-CLIENT is a useful command line Z39.50 client. You can install it with apt-get in your Debian box.

Connecting to Z39.50 server

You can connect to your server prividing IP Address/Port Number/Database name.
For instance I am going to connect to host=roble.unizar.es, port=210, database name=INNOPAC:

root@invenio1:~# yaz-client 
Z> open tcp:roble.unizar.es:210/INNOPAC
Connecting...OK.
Sent initrequest.
Connection accepted by v2 target.
ID     : Z39.50-III
Name   : z39-innopac
Version: 1
UserInformationfield:
{
    OCTETSTRING(len=52) Innovative Interfaces Inc. Z39.50 SERVER version 1.1
}
Guessing visiblestring:
'Innovative Interfaces Inc. Z39.50 SERVER version 1.1'
Options: search present scan namedResultSets
Elapsed: 0.178681

Getting server information

Z> list_all
Connected to         : tcp:roble.unizar.es:210/INNOPAC
auto_reconnect       : off
auto_wait            : on
Authentication       : none
Bases                : INNOPAC 
CCL file             : default.bib
CQL file             : /usr/local/share/yaz/etc/pqf.properties
Query type           : prefix (RPN sent to server)
Named Result Sets    : on
ssub/lslb/mspn       : 0/1/0
Format               : usmarc
Schema               : not set
Elements             : 
APDU log             : off
Record log           : off
Other Info:

Making a query

I am going to search records with title='”Aiche Journal” (more details on how to search by typing: man yaz-client)

Z> f @attr 1=4 "Aiche journal"
Sent searchRequest.
Received SearchResponse.
Search was a success.
Number of hits: 3, setno 1
records returned: 0
Elapsed: 0.056104

And listing results:

 

Z> show 1
Sent presentRequest (1+1).
Records: 1
[INNOPAC]Record type: USmarc
00976nas 2200253 i 4500
001 ocm00000001-1541
008 750720c19559999us mr p i 0 a0eng d
022 $a 0001-1541
022 $a 1547-5905 $b (Online)
040 $a UZ.PPE
080 $a (051)66
210 1 $a AICHE J.
222 0 $a AICHE journal $b (Print)
222 0 $a AICHE journal $b (Online)
245 00 $a AICHE journal : $b American Institute of Chemical Engineers journal / $c American Institute of Chemical Engineers.
246 13 $a American Institute of Chemical Engineers journal.
260 $a New York : $b American Institute of Chemical Engineers, $c 1955-
300 $a v. : $b il. ; $c 29 cm.
310 $a Mensual.
321 $a Trimestral $b (Mar. 1955-June 1957)
321 $a Bimestral $b (Jan. 1975-1995)
500 $a Indices de autor, t?itulo y materias de cada volumen en el ?ultimo n?umero del volumen.
650 04 $a Ingenier?ia qu?imica $v Publicaciones peri?odicas.
710 2 $a American Institute of Chemical Engineers.

nextResultSetPosition = 2
Elapsed: 0.201121

Next result…

Z> show 2
Sent presentRequest (2+1).
Records: 1
[INNOPAC]Record type: USmarc
00976nas  2200253 i 4500
001 ocm00000001-1541
008 750720c19559999us mr p  i    0   a0eng d
022    $a 0001-1541
022    $a 1547-5905 $b (Online)  
040    $a UZ.PPE
080    $a (051)66
210 1  $a AICHE J.
222  0 $a AICHE journal $b (Print)
222  0 $a AICHE journal $b (Online)
245 00 $a AICHE journal : $b American Institute of Chemical Engineers journal  / $c American Institute of Chemical Engineers.
246 13 $a American Institute of Chemical Engineers journal.
260    $a New York : $b American Institute of Chemical Engineers, $c 1955-
300    $a v. : $b il. ; $c 29 cm.
310    $a Mensual.
321    $a Trimestral $b (Mar. 1955-June 1957)
321    $a Bimestral $b (Jan. 1975-1995)
500    $a Indices de autor, t?itulo y materias de cada volumen en el ?ultimo n?umero del volumen.
650 04 $a Ingenier?ia qu?imica $v Publicaciones peri?odicas.
710 2  $a American Institute of Chemical Engineers.
 
nextResultSetPosition = 3
Elapsed: 0.013234

Using your III WebOPAC to show holding information

This will be useful if you have Innovative Millenium WebPAC.
You can show record’s holding data using b number.

For instance for record with .b1000203
HOLDINGS (english): http://roble.unizar.es/search?/.b1000203/.b1000203/1%2C1%2C1%2CB/holdings~b1000203
HOLDINGS (español): http://roble.unizar.es/search*spi?/.b1000203/.b1000203/1%2C1%2C1%2CB/holdings~b1000203
LOANS: AVAILABILTY INFORMATION: http://roble.unizar.es/search?/.b1000203/.b1000203/1%2C1%2C1%2CB/request~b1000203

Duplicate VIEWS in MySQL [SOLVED]

MySQL views are stored in information_schema.views table. You can list your views:

mysql> USE information_schema;
mysql> DESCRIBE views;
+-----------------+--------------+------+-----+---------+-------+
| FIELD           | TYPE         | NULL | KEY | DEFAULT | Extra |
+-----------------+--------------+------+-----+---------+-------+
| TABLE_CATALOG   | VARCHAR(512) | YES  |     | NULL    |       | 
| TABLE_SCHEMA    | VARCHAR(64)  | NO   |     |         |       | 
| TABLE_NAME      | VARCHAR(64)  | NO   |     |         |       | 
| VIEW_DEFINITION | longtext     | NO   |     | NULL    |       | 
| CHECK_OPTION    | VARCHAR(8)   | NO   |     |         |       | 
| IS_UPDATABLE    | VARCHAR(3)   | NO   |     |         |       | 
| DEFINER         | VARCHAR(77)  | NO   |     |         |       | 
| SECURITY_TYPE   | VARCHAR(7)   | NO   |     |         |       | 
+-----------------+--------------+------+-----+---------+-------+
8 ROWS IN SET (0.00 sec)
 
mysql> SELECT TABLE_NAME FROM views;
+---------------------------+
| TABLE_NAME                |
+---------------------------+
| uz_DOWNLOADS_TESIS        | 
| uz_DOWNLOADS_TESIS_TITLES | 
| uz_REGISTROS_BORRADOS     | 
+---------------------------+
3 ROWS IN SET, 5 warnings (0.11 sec)

You can also view who defined each view (DEFINER):

mysql> SELECT TABLE_NAME, definer FROM views;
+---------------------------+--------------------+
| TABLE_NAME                | definer            |
+---------------------------+--------------------+
| uz_DOWNLOADS_TESIS        | root@155.210.85.31 | 
| uz_DOWNLOADS_TESIS_TITLES | root@155.210.85.31 | 
| uz_REGISTROS_BORRADOS     | root@155.210.85.31 | 
+---------------------------+--------------------+
3 ROWS IN SET, 5 warnings (0.11 sec)

And you can also get the query for a view:

mysql> SELECT TABLE_NAME, view_definition FROM views;
| uz_DOWNLOADS_TESIS        | /* ALGORITHM=UNDEFINED */ (SELECT `cdsinvenio`.`rnkDOWNLOADS`.`id_bibrec` AS `id_bibrec`,`cdsinvenio`.`rnkDOWNLOADS`.`download_time` AS `download_time`,`cdsinvenio`.`rnkDOWNLOADS`.`client_host` AS `client_host`,`cdsinvenio`.`rnkDOWNLOADS`.`id_user` AS `id_user`,`cdsinvenio`.`rnkDOWNLOADS`.`id_bibdoc` AS `id_bibdoc`,`cdsinvenio`.`rnkDOWNLOADS`.`file_version` AS `file_version`,`cdsinvenio`.`rnkDOWNLOADS`.`file_format` AS `file_format`,COUNT(`cdsinvenio`.`rnkDOWNLOADS`.`id_bibrec`) AS `total` FROM `cdsinvenio`.`rnkDOWNLOADS` WHERE (`cdsinvenio`.`rnkDOWNLOADS`.`id_bibrec` IN (SELECT DISTINCT `cdsinvenio`.`bibrec_bib98x`.`id_bibrec` AS `id_bibrec` FROM `cdsinvenio`.`bibrec_bib98x` WHERE (`cdsinvenio`.`bibrec_bib98x`.`id_bibxxx` = 7)) AND (NOT(`cdsinvenio`.`rnkDOWNLOADS`.`id_bibrec` IN (SELECT DISTINCT `cdsinvenio`.`bibrec_bib98x`.`id_bibrec` AS `id_bibrec` FROM `cdsinvenio`.`bibrec_bib98x` WHERE (`cdsinvenio`.`bibrec_bib98x`.`id_bibxxx` = 3))))) GROUP BY `cdsinvenio`.`rnkDOWNLOADS`.`id_bibrec`) | 
| uz_DOWNLOADS_TESIS_TITLES | /* ALGORITHM=UNDEFINED */ (SELECT `cdsinvenio`.`bibrec_bib24x`.`id_bibrec` AS `id_bibrec`,`cdsinvenio`.`bib24x`.`value` AS `value`,`uz_DOWNLOADS_TESIS`.`total` AS `total` FROM `cdsinvenio`.`bib24x` JOIN `cdsinvenio`.`bibrec_bib24x` JOIN `cdsinvenio`.`uz_DOWNLOADS_TESIS` WHERE ((`cdsinvenio`.`bib24x`.`id` = `cdsinvenio`.`bibrec_bib24x`.`id_bibxxx`) AND (`cdsinvenio`.`bibrec_bib24x`.`id_bibrec` = `uz_DOWNLOADS_TESIS`.`id_bibrec`) AND (`cdsinvenio`.`bib24x`.`tag` = _utf8'24500a')) ORDER BY `cdsinvenio`.`bibrec_bib24x`.`id_bibrec`)
| uz_REGISTROS_BORRADOS     | /* ALGORITHM=UNDEFINED */ (SELECT DISTINCT `cdsinvenio`.`bibrec_bib98x`.`id_bibrec` AS `id_bibrec` FROM `cdsinvenio`.`bibrec_bib98x` WHERE (`cdsinvenio`.`bibrec_bib98x`.`id_bibxxx` = 3))

Knowing the query you can re-create the view with another name in another database. Original datbase was cdsinvenio, cloned database is invenio2014

mysql> USE invenio2014;
mysql> CREATE VIEW UZ_DESCARGAS_TESIS AS (SELECT `invenio2014`.`rnkDOWNLOADS`.`id_bibrec` AS `id_bibrec`,`invenio2014`.`rnkDOWNLOADS`.`download_time` AS `download_time`,`invenio2014`.`rnkDOWNLOADS`.`client_host` AS `client_host`,`invenio2014`.`rnkDOWNLOADS`.`id_user` AS `id_user`,`invenio2014`.`rnkDOWNLOADS`.`id_bibdoc` AS `id_bibdoc`,`invenio2014`.`rnkDOWNLOADS`.`file_version` AS `file_version`,`invenio2014`.`rnkDOWNLOADS`.`file_format` AS `file_format`,COUNT(`invenio2014`.`rnkDOWNLOADS`.`id_bibrec`) AS `total` FROM `invenio2014`.`rnkDOWNLOADS` WHERE (`invenio2014`.`rnkDOWNLOADS`.`id_bibrec` IN (SELECT DISTINCT `invenio2014`.`bibrec_bib98x`.`id_bibrec` AS `id_bibrec` FROM `invenio2014`.`bibrec_bib98x` WHERE (`invenio2014`.`bibrec_bib98x`.`id_bibxxx` = 7)) AND (NOT(`invenio2014`.`rnkDOWNLOADS`.`id_bibrec` IN (SELECT DISTINCT `invenio2014`.`bibrec_bib98x`.`id_bibrec` AS `id_bibrec` FROM `invenio2014`.`bibrec_bib98x` WHERE (`invenio2014`.`bibrec_bib98x`.`id_bibxxx` = 3))))) GROUP BY `invenio2014`.`rnkDOWNLOADS`.`id_bibrec`)

And to delete a view, you can do it like:

mysql> DROP VIEW uz_DOWNLOADS_TESIS;
Query OK, 0 ROWS affected (0.05 sec)

Install DISTCACHE on RHEL6 [SOLVED]

Installing distcache on RHEL6 can be tricky. Let’s see how to do it…

cd /home/miguelm/invenio113/prerequisites/distcache
wget http://sourceforge.net/projects/distcache/files/latest/download?source=files
tar -xzvf distcache-1.5.1.tar.gz
cd distcache-1.5.1

If you try to compile as is, you will get errors:

proto_fd.c: In function 'addr_parse':
proto_fd.c:177: error: 'LONG_MIN' undeclared (first use in this function)
proto_fd.c:177: error: (Each undeclared identifier is reported only once
proto_fd.c:177: error: for each function it appears in.)
proto_fd.c:177: error: 'LONG_MAX' undeclared (first use in this function)

To get rid of them, you just have to include in distcache-1.5.1/libnal/proto_fd.c as in:

#define SYS_GENERATING_LIB
 
#include <libsys/pre.h>
#include <libnal/nal.h>
#include "nal_internal.h" 
#include "ctrl_fd.h" 
#include <libsys/post.h>
#include <limits.h>
 
/**************************/
/* predeclare our vtables */
/**************************/
...

Now you can compile with no errors…

./configure --prefix=/usr
make
make install

CDS Invenio 1: The new file uploader explained

Those who have used Invenio since 0.9x version will notice a new useful websubmit element in Invenio 1.

This new useful element is Upload_Files. Older versions just had a file input element (for instance, DEMOTHE_FILE) which allowed just one file to be uploaded.

This is the code of the Upload_Files element:

"""
This is an example of element that creates a file upload interface.
Clone it, customize it and integrate it into your submission. Then add function 
'Move_Uploaded_Files_to_Storage' to your submission functions list, in order for files 
uploaded with this interface to be attached to the record. More information in 
the WebSubmit admin guide.
"""
import os
from invenio.websubmit_managedocfiles import create_file_upload_interface
from invenio.websubmit_functions.Shared_Functions import ParamFromFile
 
indir = ParamFromFile(os.path.join(curdir, 'indir'))
doctype = ParamFromFile(os.path.join(curdir, 'doctype'))
access = ParamFromFile(os.path.join(curdir, 'access'))
try:
    sysno = int(ParamFromFile(os.path.join(curdir, 'SN')).strip())
except:
    sysno = -1
ln = ParamFromFile(os.path.join(curdir, 'ln'))
 
"""
Run the following to get the list of parameters of function 'create_file_upload_interface':
echo -e 'from invenio.websubmit_managedocfiles import create_file_upload_interface as f\nprint f.__doc__' | python
"""
text = create_file_upload_interface(recid=sysno,
                                 print_outside_form_tag=False,
                                 include_headers=True,
                                 ln=ln,
                                 doctypes_and_desc=[('main','Normativa/Modificacion'),
                                                    ('additional','Texto integrado')],
                                 can_revise_doctypes=['*'],
                                 can_describe_doctypes=['main'],
                                 can_delete_doctypes=['additional'],
                                 can_rename_doctypes=['main'],
                                 sbm_indir=indir, sbm_doctype=doctype, sbm_access=access)[1]

Using this new file uploader you can upload several files at a time.

This is how the element is rendered by default:
Captura de pantalla 2014-05-22 a la(s) 13.30.43

When you add this element to your forms, you will also have to add the Move_Uploaded_Files_to_Storage function in the submission. As in:
Invenio websubmit functions

By default the file path will be stored in a 8654_u MARCXML tag, subfield code a.
The information supplied in “Description” field will be mapped to a 8564_u MARCXML tag, subfield code y.
The data entered in “Name” field will be used to rename the fulltext file.

Here is an example of how Invenio builds a 8564_u tag using this new file uploader:
Invenio websubmit functions

I wanted to add a “comment” input field to this File Uploader form. I took a look at the code and… well, Invenio guys have already thought about this!! Notice the “commentBox” div in the code:

<div id="reviseControl">
    <table class="reviseControlBrowser"></table><input type="button" onclick="display_revise_panel(this, 'add', '', true, false, true, true, true, '', '', '', true, '', '<select id=&quot;fileDoctype&quot; name=&quot;fileDoctype&quot; onchange=&quot;var idx=this.selectedIndex;var doctype=this.options[idx].value;updateForm(doctype,{\'main\': \'\'},{},{});&quot;><option value=&quot;main&quot;>Main document</option>\n<option value=&quot;additional&quot;>Figure, schema, etc.</option></select>');updateForm('main', {'main': ''}, {}, {});return false;" value="Añadir otro fichero"/></div></div>
<div id="balloon" style="display:none;">
<input type="hidden" name="fileAction" value="" />
<input type="hidden" name="fileTarget" value="" />
  <table>
    <tr>
      <td class="topleft">&nbsp;</td>
      <td class="top">&nbsp;</td>
      <td class="topright">&nbsp;</td>
    </tr>
    <tr>
      <td class="left" vertical-align="center" width="24"><img alt=" " src="../img/balloon_arrow_left_shadow.png" /></td>
      <td class="center">
        <table id="balloonReviseFile">
          <tr>
            <td><label for="balloonReviseFileInput">Escoja el fichero:</label><br/>
              <div style="display:none" id="fileDoctypesRow"></div>
              <div id="balloonReviseFileInputBlock"><input type="file" name="myfile" id="balloonReviseFileInput" size="20" /></div>
                          <!--  <input type="file" name="myfile" id="balloonReviseFileInput" size="20" onchange="var name=getElementById('rename');var filename=this.value.split('/').pop().split('.')[0];name.value=filename;"/> -->
              <div id="renameBox" style=""><label for="rename">Nombre:</label><br/><input type="text" name="rename" id="rename" size="20" autocomplete="off"/></div>
              <div id="descriptionBox" style=""><label for="description">Descripción:</label><br/><input type="text" name="description" id="description" size="20" autocomplete="off"/></div>
              <div id="commentBox" style=""><label for="comment">Comentario:</label><br/><textarea name="comment" id="comment" rows="3"/></textarea></div>
              <div id="restrictionBox" style="display:none"><select style="display:none" id="fileRestriction" name="fileRestriction"></select></div>
              <div id="keepPreviousVersions" style="display:none"><input type="checkbox" id="balloonReviseFileKeep" name="keepPreviousFiles" checked="checked" /><label for="balloonReviseFileKeep">Guardar las versiones anteriores</label>&nbsp;<small>[<a href="" onclick="alert('Puede decidir esconder o no versiones anteriores de este archivo.');return false;">?</a>]</small></div>
              <p id="warningFormats" style="display:none"><img src="http://155.210.11.63/img/warning.png" alt="Warning"/> Los formatos alternativos para la versión actual de este archivo serán borrados&nbsp;[<a href="" onclick="alert('Cuando revise un archivo, los formatos adicionales que haya subido previamente serán borrados, ya que no estarían sincronizados con el nuevo archivo.');return false;">?</a>]</p>
              <div style="text-align:right;margin-top:5px"><input type="button" value="Cancelar" onclick="javascript:hide_revise_panel();"/> <input type="submit" value="Subir"/></div>
            </td>
          </tr>
        </table>
      </td>
      <td class="right">&nbsp;</td>
    </tr>
    <tr>
      <td class="bottomleft">&nbsp;</td>
      <td class="bottom">&nbsp;</td>
      <td class="bottomright">&nbsp;</td>
    </tr>
  </table>
</div>

However this box has a display:none attribute. So, how can we make the box visible?

Easy.

If you look at the Upload_Files element code, you will notice that the function producing that output is create_file_upload_interface. That function has a lot of parameters that can be listed using:

echo -e 'from invenio.websubmit_managedocfiles import create_file_upload_interface as f\nprint f.__doc__' | python

If you want the “Comment” box to be displayed, just add the parameter can_comment_doctypes=['*'] to the code, as in:

"""
This is an example of element that creates a file upload interface.
Clone it, customize it and integrate it into your submission. Then add function 
'Move_Uploaded_Files_to_Storage' to your submission functions list, in order for files 
uploaded with this interface to be attached to the record. More information in 
the WebSubmit admin guide.
"""
import os
from invenio.websubmit_managedocfiles import create_file_upload_interface
from invenio.websubmit_functions.Shared_Functions import ParamFromFile
 
indir = ParamFromFile(os.path.join(curdir, 'indir'))
doctype = ParamFromFile(os.path.join(curdir, 'doctype'))
access = ParamFromFile(os.path.join(curdir, 'access'))
try:
    sysno = int(ParamFromFile(os.path.join(curdir, 'SN')).strip())
except:
    sysno = -1
ln = ParamFromFile(os.path.join(curdir, 'ln'))
 
"""
Run the following to get the list of parameters of function 'create_file_upload_interface':
echo -e 'from invenio.websubmit_managedocfiles import create_file_upload_interface as f\nprint f.__doc__' | python
"""
text = create_file_upload_interface(recid=sysno,
                                 print_outside_form_tag=False,
                                 include_headers=True,
                                 ln=ln,
                                 doctypes_and_desc=[('main','Normativa/Modificacion'),
                                                    ('additional','Texto integrado')],
                                 can_revise_doctypes=['*'],
                                 can_comment_doctypes=['*'],
                                 can_describe_doctypes=['main'],
                                 can_delete_doctypes=['additional'],
                                 can_rename_doctypes=['main'],
                                 sbm_indir=indir, sbm_doctype=doctype, sbm_access=access)[1]

And now the commentBox is visible 🙂

invenio submit fulltext websubmit element file uploader

This new “comment” field is mapped to 8564_u subfield z. Example:

invenio several files upload, file uploader

invenio file uploader resulting marcxml

There are several other parameters of function create_file_upload_interface still to be explored…

root@invenio1:/opt/invenio/lib/python/invenio/websubmit_functions# echo -e 'from invenio.websubmit_managedocfiles import create_file_upload_interface as f\nprint f.__doc__' | python
/usr/local/lib/python2.6/dist-packages/pkg_resources.py:2535: DeprecationWarning: functions overriding warnings.showwarning() must support the 'line' argument
  warn(stacklevel = level+1, *args, **kw)
/usr/lib/python2.6/dist-packages/Ft/Lib/ImportUtil.py:362: UserWarning: Module _hashlib was already imported from None, but /usr/local/lib/python2.6/dist-packages is being added to sys.path
  from pkg_resources import get_provider, resource_filename
 
    Returns the HTML for the file upload interface.
 
    @param recid: the id of the record to edit files
    @type recid: int or None
 
    @param form: the form sent by the user's browser in response to a
                 user action. This is used to read and record user's
                 actions.
    @param form: as returned by the interface handler.
 
    @param print_outside_form_tag: display encapsulating <form> tag or
                                   not
    @type print_outside_form_tag: boolean
 
    @param print_envelope: (internal parameter) if True, return the
                           encapsulating initial markup, otherwise
                           skip it.
    @type print_envelope: boolean
 
    @param include_headers: include javascript and css headers in the
                            body of the page. If you set this to
                            False, you must take care of including
                            these headers in your page header. Setting
                            this parameter to True is useful if you
                            cannot change the page header.
    @type include_headers: boolean
 
    @param ln: language
    @type ln: string
 
    @param minsize: the minimum size (in bytes) allowed for the
                    uploaded files. Files not big enough are
                    discarded.
    @type minsize: int
 
    @param maxsize: the maximum size (in bytes) allowed for the
                    uploaded files. Files too big are discarded.
    @type maxsize: int
 
    @param doctypes_and_desc: the list of doctypes (like 'Main' or
                              'Additional') and their description that users
                              can choose from when adding new files.
                                - When no value is provided, users cannot add new
                                  file (they can only revise/delete/add format)
                                - When a single value is given, it is used as
                                  default doctype for all new documents
 
                              Order is relevant
                              Eg:
                              [('main', 'Main document'), ('additional', 'Figure, schema. etc')]
    @type doctypes_and_desc: list(tuple(string, string))
 
    @param restrictions_and_desc: the list of restrictions (like 'Restricted' or
                         'No Restriction') and their description that
                         users can choose from when adding or revising
                         files. Restrictions can then be configured at
                         the level of WebAccess.
                           - When no value is provided, no restriction is
                             applied
                           - When a single value is given, it is used as
                             default resctriction for all documents.
                           - The first value of the list is used as default
                             restriction if the user if not given the
                             choice of the restriction. Order is relevant
 
                         Eg:
                         [('', 'No restriction'), ('restr', 'Restricted')]
    @type restrictions_and_desc: list(tuple(string, string))
 
    @param can_delete_doctypes: the list of doctypes that users are
                                allowed to delete.
                                Eg: ['main', 'additional']
                                Use ['*'] for "all doctypes"
    @type can_delete_doctypes: list(string)
 
    @param can_revise_doctypes: the list of doctypes that users are
                                allowed to revise
                                Eg: ['main', 'additional']
                                Use ['*'] for "all doctypes"
    @type can_revise_doctypes: list(string)
 
    @param can_describe_doctypes: the list of doctypes that users are
                                  allowed to describe
                                  Eg: ['main', 'additional']
                                  Use ['*'] for "all doctypes"
    @type can_describe_doctypes: list(string)
 
    @param can_comment_doctypes: the list of doctypes that users are
                                 allowed to comment
                                 Eg: ['main', 'additional']
                                 Use ['*'] for "all doctypes"
    @type can_comment_doctypes: list(string)
 
    @param can_keep_doctypes: the list of doctypes for which users can
                         choose to keep previous versions visible when
                         revising a file (i.e. 'Keep previous version'
                         checkbox). See also parameter 'keepDefault'.
                         Note that this parameter is ~ignored when
                         revising the attributes of a file (comment,
                         description) without uploading a new
                         file. See also parameter
                         Move_Uploaded_Files_to_Storage.force_file_revision
                         Eg: ['main', 'additional']
                         Use ['*'] for "all doctypes"
    @type can_keep_doctypes: list(string)
 
 
    @param can_add_format_to_doctypes: the list of doctypes for which users can
                              add new formats. If there is no value,
                              then no 'add format' link nor warning
                              about losing old formats are displayed.
                              Eg: ['main', 'additional']
                              Use ['*'] for "all doctypes"
    @type can_add_format_to_doctypes: list(string)
 
    @param can_restrict_doctypes: the list of doctypes for which users can
                             choose the access restrictions when adding or
                             revising a file. If no value is given:
                               - no restriction is applied if none is defined
                                 in the 'restrictions' parameter.
                               - else the *first* value of the 'restrictions'
                                 parameter is used as default restriction.
 
                             Eg: ['main', 'additional']
                             Use ['*'] for "all doctypes"
    @type can_restrict_doctypes : list(string)
 
    @param can_rename_doctypes: the list of doctypes that users are allowed
                           to rename (when revising)
                           Eg: ['main', 'additional']
                           Use ['*'] for "all doctypes"
    @type can_rename_doctypes: list(string)
 
    @param can_name_new_files: if user can choose the name of the files they
                         upload or not
    @type can_name_new_files: boolean
 
    @param doctypes_to_default_filename: Rename uploaded files to admin-chosen
                                 values. List here the the files in
                                 current submission directory that
                                 contain the names to use for each doctype.
                                 Eg:
                                 {'main': RN', 'additional': 'additional_filename'}
 
                                 If the same doctype is submitted
                                 several times, a"-%i" suffix is added
                                 to the name defined in the file.
 
                                 The default filenames are overriden
                                 by user-chosen names if you allow
                                 'can_name_new_files' or
                                 'can_rename_doctypes'.
    @type doctypes_to_default_filename: dict
 
    @param max_files_for_doctype: the maximum number of files that users can
                          upload for each doctype.
                          Eg: {'main': 1, 'additional': 2}
 
                          Do not specify the doctype here to have an
                          unlimited number of files for a given
                          doctype.
    @type max_files_for_doctype: dict
 
    @param create_related_formats: if uploaded files get converted to
                                     whatever format we can or not
    @type create_related_formats: boolean
 
    @param keep_default: the default behaviour for keeping or not previous
                     version of files when users cannot choose (no
                     value in can_keep_doctypes).
                     Note that this parameter is ignored when revising
                     the attributes of a file (comment, description)
                     without uploading a new file. See also parameter
                     Move_Uploaded_Files_to_Storage.force_file_revision
    @type keep_default: boolean
 
    @param show_links: if we display links to files when possible or
                         not
    @type show_links: boolean
 
    @param file_label: the label for the file field
    @type file_label: string
 
    @param filename_label: the label for the file name field
    @type filename_label: string
 
    @param description_label: the label for the description field
    @type description_label: string
 
    @param comment_label: the label for the comments field
    @type comment_label: string
 
    @param restriction_label: the label in front of the restrictions list
    @type restriction_label: string
 
    @param sbm_indir: the submission indir parameter, in case the
                      function is used in a WebSubmit submission
                      context.
                      This value will be used to retrieve where to
                      read the current state of the interface and
                      store uploaded files
    @type sbm_indir : string
 
    @param sbm_doctype: the submission doctype parameter, in case the
                        function is used in a WebSubmit submission
                        context.
                        This value will be used to retrieve where to
                        read the current state of the interface and
                        store uploaded files
    @type sbm_doctype: string
 
    @param sbm_access: the submission access parameter. Must be
                       specified in the context of WebSubmit
                       submission, as well when used in the
                       WebSubmit Admin file management interface.
 
                       This value will be used to retrieve where to
                       read the current state of the interface and
                       store uploaded files
    @type sbm_access: string
 
    @param sbm_curdir: the submission curdir parameter. Must be
                       specified in the context of WebSubmit
                       function Create_Upload_File_Interface.
 
                       This value will be used to retrieve where to
                       read the current state of the interface and
                       store uploaded files.
    @type sbm_curdir: string
 
    @param uid: the user id
    @type uid: int
 
    @return Tuple (errorcode, html)

Adding jQuery UI tabs to Drupal 7 [SOLVED]

I recently wanted to add some jQuery UI tabs to nodes. Drupal 7 has jQuery 1.4 included in core, so we’ll take advantage of that.

This is how you do it:

First, edit template.php and create / make some changes to hook _preprocess_html.

function THEMENAME_preprocess_html(&$variables){
   // This function looks for node 1 and only adds the javascript for this.
   // However it can be extended in different ways if required
    drupal_add_library('system', 'ui.tabs');
    drupal_add_js('jQuery(document).ready(function(){
                jQuery("#tabs").tabs({event: "mouseover"});
                jQuery("#tabs").tabs().addClass("ui-tabs-vertical ui-helper-clearfix");
                jQuery("#tabs li").removeClass("ui-corner-top").addClass("ui-corner-left");
            });',
        'inline');
}

*Note that you can remove ui-tabs-vertical if you want horizontal tabs. You can also change the mouseover event to the event you prefer.

This would be the markup:

<!-- TITULOS PESTAÑAS -->
<div id="tabs">
<div id="tab-list">
  <ul>
  <li><a href="#tabs-1">Titulo 1</a></li>
  <li><a href="#tabs-2">Titulo 2</a></li>
  <li><a href="#tabs-3">Titulo 3</a></li>
  <li><a href="#tabs-4">Titulo 4</a></li>
  <li><a href="#tabs-5">Titulo 5</a></li>
  <li><a href="#tabs-6">Titulo 6</a></li>
  <li><a href="#tabs-7">Titulo 7</a></li>
  <li><a href="#tabs-8">Titulo 8</a></li>
  <li><a href="#tabs-9">Titulo 9</a></li>
  <li><a href="#tabs-10">Titulo 10</a></li>
  </ul>
</div>
 
 
<!-- CONTENIDO PESTAÑAS -->
<div id="tab-content">    
  <div id="tabs-1">
    <p>Texto de la TABS-1</p>
  </div>
  <div id="tabs-2">
    <p>Texto de la TABS-2</p>
  </div>
  <div id="tabs-3">
    <p>Texto de la TABS-3</p>
  </div>
  <div id="tabs-4">
    <p>Texto de la TABS-4</p>
  </div>
  <div id="tabs-5">
    <p>Texto de la TABS-5</p>
  </div>
  <div id="tabs-6">
   <p>Texto de la TABS-6</p>
  </div>
  <div id="tabs-7">
    <p>Texto de la TABS-7</p>
  </div>
  <div id="tabs-8">
    <p>Texto de la TABS-8</p>
  </div>
  <div id="tabs-9">
    <p>Texto de la TABS-9</p>
  </div>
  <div id="tabs-10">
    <p>Texto de la TABS-10</p>
  </div>
</div>
</div>

And a sample output:
UI-Tabs-Drupal