Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
limbra
limbra
Commits
878df57f
Commit
878df57f
authored
Dec 14, 2015
by
LE GAC Renaud
Browse files
List can be extracted as an odt file.
parent
23f47a5a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
4 deletions
+76
-4
models/vt_list_selector.py
models/vt_list_selector.py
+1
-1
views/lists/index.odt
views/lists/index.odt
+72
-0
views/tex2pdf.html
views/tex2pdf.html
+3
-3
No files found.
models/vt_list_selector.py
View file @
878df57f
...
...
@@ -2,7 +2,7 @@
""" list_selector (virtaul table)
"""
FORMATS
=
[
'bib'
,
'csv'
,
'html'
,
'pdf'
,
'tex'
]
FORMATS
=
[
'bib'
,
'csv'
,
'html'
,
'odt'
,
'pdf'
,
'tex'
]
#-------------------------------------------------------------------------------
#
...
...
views/lists/index.odt
0 → 100644
View file @
878df57f
{{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
views/tex2pdf.html
View file @
878df57f
...
...
@@ -23,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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment