Skip to content
Snippets Groups Projects
Commit 81f3612e authored by legac's avatar legac
Browse files

Add the method ExportLatex.domToLaTeX handling hyperlink.

parent 018c48c3
No related branches found
No related tags found
No related merge requests found
...@@ -63,7 +63,8 @@ def report_4(): ...@@ -63,7 +63,8 @@ def report_4():
cfg['data'] = [] cfg['data'] = []
for row in db().select(db.harvesters.ALL): for row in db().select(db.harvesters.ALL):
cfg['data'].append([row.controller, cfg['data'].append([row.controller,
row.host, '<a href="http://www.web2py.com">%s</a>' % row.host,
# row.host,
row.collections, row.collections,
row.ratio]) row.ratio])
......
...@@ -9,6 +9,41 @@ Ext.define('App.grid.mixin.ExportLatex', { ...@@ -9,6 +9,41 @@ Ext.define('App.grid.mixin.ExportLatex', {
extend: 'App.grid.mixin.ExportBase', extend: 'App.grid.mixin.ExportBase',
//
// Convert the dom Element corresponding to a grid cell into a string.
// When the cell contains an hyper link, it is encoded as using the
// latex command href.
//
// @param {Ext.dom.Element}
//
// @return {String}
//
domToLaTeX: function(domEl) {
"use strict";
var htmlEl = domEl.dom,
href,
li,
value;
// is the cell contains an hyper link
li = htmlEl.getElementsByTagName("A");
// standard string
// shrink empty string to avoid latex processing failure
if (li.length === 0) {
value = htmlEl.textContent.trim();
// render the hyper link using latex command href
} else {
href = li.item(0).getAttribute("href");
value = htmlEl.textContent;
value = "\\href{" + href +"}{" + value +"}";
}
return value;
},
/** /**
* Convert the Ext.grid.View content into a string. * Convert the Ext.grid.View content into a string.
* The information are encoded using LaTeX standard. * The information are encoded using LaTeX standard.
...@@ -73,7 +108,7 @@ Ext.define('App.grid.mixin.ExportLatex', { ...@@ -73,7 +108,7 @@ Ext.define('App.grid.mixin.ExportLatex', {
div = trEl.down(".x-grid-group-title"); div = trEl.down(".x-grid-group-title");
if (div) { if (div) {
cmd = '\\multicolumn{' + nColumns + '}{l}{' + div.dom.textContent + '} \\\\'; cmd = '\\multicolumn{' + nColumns + '}{l}{' + me.domToLaTeX(div) + '} \\\\';
latex.push(cmd); latex.push(cmd);
latex.push('\\hline'); latex.push('\\hline');
} }
...@@ -86,10 +121,7 @@ Ext.define('App.grid.mixin.ExportLatex', { ...@@ -86,10 +121,7 @@ Ext.define('App.grid.mixin.ExportLatex', {
// process the tdEls Ext.dom.CompositeElement // process the tdEls Ext.dom.CompositeElement
for (j = 0; j < tdEls.getCount(); j += 1) { for (j = 0; j < tdEls.getCount(); j += 1) {
cells.push(me.domToLaTeX(tdEls.item(j)));
// shrink empty string to avoid latex processing failure
tdEl = tdEls.item(j).dom.textContent.trim();
cells.push(tdEl);
} }
row = cells.join(' & ') + ' \\\\'; row = cells.join(' & ') + ' \\\\';
......
...@@ -29,6 +29,7 @@ Ext.define('App.grid.plugin.Export', { ...@@ -29,6 +29,7 @@ Ext.define('App.grid.plugin.Export', {
'\\documentclass[a4paper]{article}', '\\documentclass[a4paper]{article}',
'\\usepackage[utf8]{inputenc}', '\\usepackage[utf8]{inputenc}',
'\\usepackage[T1]{fontenc}', '\\usepackage[T1]{fontenc}',
'\\usepackage{hyperref}',
'\\usepackage{longtable}' '\\usepackage{longtable}'
], ],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment