Commit 1f8fe830 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Merge branch 'master' into 'production'

Release 0.9.4

* Require plugin_dbui 0.8.0 and libreoffice
* Application compliant with the chrome browser
* List can be extract in the OpenDocument format odt.

See merge request !53
parents 96ea84b9 78dc947b
......@@ -2,6 +2,7 @@
""" Controllers for building graphs using pandas library
"""
import base64
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
......@@ -87,5 +88,12 @@ def index():
do_title(ax, db, selector)
# delegate the rendering to the view
fmt = "svg" if selector.format == "html" else selector.format
return dict(data=savefig(ax.get_figure(), fmt))
extension = request.extension
fmt = "svg" if extension == "html" else extension
# base64 string encoding
data = savefig(ax.get_figure(), fmt)
if fmt in ("pdf", "png"):
data = base64.b64encode(data)
return dict(data=data)
......@@ -2,7 +2,7 @@
""" list_selector (virtaul table)
"""
FORMATS = ['bib', 'csv', 'html', 'pdf', 'tex']
FORMATS = ['bib', 'html', 'odt', 'pdf', 'tex']
#-------------------------------------------------------------------------------
#
......
......@@ -2,6 +2,11 @@
HEAD
0.9.4 (Dec 2015)
- Require plugin_dbui 0.8.0 and libreoffice.
- Few modifications to be compliant with the navigator Chrome.
- List can be extract in OpenDocument format odt.
0.9.3 (Dec 2015)
- Require plugin_dbui 0.7.3
- Add the wizard to create an harvester.
......
{{include 'lists/index.html'}}
{{
import base64
import cStringIO
import os
from subprocess import call
from tempfile import TemporaryFile
from uuid import uuid4
#
# go to the build directory
#
cwd = os.getcwd()
wd = os.path.join(request.folder, 'tmp_build')
if not os.path.exists(wd):
os.chdir(request.folder)
os.mkdir('tmp_build')
os.chdir('tmp_build')
else:
os.chdir(wd)
pass
#
# create the HTML file
#
shtml = '<head></head><body>%s</body>' % response.body.getvalue()
froot = str(uuid4())
fhtml = '%s.html' % froot
fi = open(fhtml, 'wb')
fi.write(shtml)
fi.close()
#
# convert the HTML in ODT file
#
cmd = ["libreoffice", "--headless", "--convert-to", "odt", fhtml]
call(cmd, stdout=TemporaryFile())
fodt = '%s.odt' % froot
fi = open(fodt, 'rb')
sodt = fi.read()
fi.close()
s64 = base64.b64encode(sodt)
#
# clean
#
for ext in ('html', 'odt'):
f = '%s.%s' % (froot, ext)
if os.path.exists(f):
os.remove(f)
pass
pass
os.chdir(cwd)
#
# build the response
#
response.body = cStringIO.StringIO()
response.headers['Content-Type']='application/vnd.oasis.opendocument.text'
response.headers['Content-Disposition'] = 'attachment;filename="list.odt"'
response.write(s64, escape=False)
}}
\ No newline at end of file
......@@ -101,8 +101,11 @@
// instantiate the grid with a summary row.
// data can be extracted via the plugin pGridExport
//
var grid = Ext.create('Ext.grid.Panel', {
plugins: ['pGridExport'],
var grid = Ext.create('App.grid.Panel', {
plugins: [{
fileRoot: 'metrics',
ptype:'pGridExport'
}],
store: Ext.create('Ext.data.ArrayStore', cfgStore),
columns: columns,
features: [{ftype:'summary'}],
......
......@@ -4,6 +4,7 @@
# Converte to transform a tex file generate by a view as a pdf file
#
#--------------------------------------------------------------------------
import base64
import cStringIO
import os
......@@ -22,11 +23,11 @@
# go to the private directory and create a latex file
#
cwd = os.getcwd()
wd = os.path.join(request.folder, 'latex')
wd = os.path.join(request.folder, 'tmp_build')
if not os.path.exists(wd):
os.chdir(request.folder)
os.mkdir('latex')
os.chdir('latex')
os.mkdir('tmp_build')
os.chdir('tmp_build')
else:
os.chdir(wd)
pass
......@@ -43,21 +44,23 @@
call(cmd, stdout=TemporaryFile())
#
# copy the pdf in the new response
# copy the pdf into a base64 string
#
response.headers['Content-Type']='application/pdf'
fn_pdf = '%s.pdf' % fn
if os.path.exists(fn_pdf):
fi = open(fn_pdf, 'rb')
response.write(fi.read(), escape=False)
data = fi.read()
fi.close()
else:
response.write("\nThe generation of the PDF file failed.", escape=False)
response.write("\nPlease, check the LaTeX file.", escape=False)
data = "\nThe generation of the PDF file failed."
data += "\nPlease, check the LaTeX file."
pass
s64 = base64.b64encode(data)
#
# clean files
# cleaning
#
for ext in ('aux', 'log', 'out', 'pdf', 'tex'):
f = '%s.%s' % (fn, ext)
......@@ -66,8 +69,11 @@
pass
pass
os.chdir(cwd)
#
# go back to the web2py main directory
# Prepare the response
#
os.chdir(cwd)
response.headers['Content-Type']='application/pdf'
response.write(s64, escape=False)
}}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment