mirror of
https://gitlab.constantvzw.org/osp/tools.cobbled-paths.git
synced 2024-12-23 13:01:25 +01:00
Added button for HPGL export.
This commit is contained in:
parent
8b8a1cf80f
commit
e972ffb387
2
app.py
2
app.py
@ -378,7 +378,7 @@ def hpgl (id):
|
||||
with open(hpgl_file, 'r') as hpgl_handle:
|
||||
r = Response(hpgl_handle.read(), mimetype='application/hpgl')
|
||||
r.headers.extend({
|
||||
'Content-Disposition': 'attachment; filename="cobbled-paths.hpgl"'
|
||||
'Content-Disposition': f'attachment; filename="cobbled-paths-{id}.hpgl"'
|
||||
})
|
||||
|
||||
# remove tmp file
|
||||
|
@ -5,7 +5,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<script src="/static/js/FileSaver.js"></script>
|
||||
<style>
|
||||
#save-svg{
|
||||
#save-buttons{
|
||||
position: fixed;
|
||||
top: 0.5em;
|
||||
right: 0.5em;
|
||||
@ -28,7 +28,10 @@
|
||||
|
||||
{{ svg|safe }}
|
||||
|
||||
<button id="save-svg">> SVG</button>
|
||||
<div id="save-buttons">
|
||||
<button id="save-svg">> SVG</button>
|
||||
<button id="save-hpgl">> HPGL</button>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function get2bodyclass(){
|
||||
@ -58,6 +61,25 @@
|
||||
let blob = new Blob([source], {type: "text/plain;charset=utf-8"});
|
||||
saveAs(blob, 'cobbled-paths.svg');
|
||||
});
|
||||
|
||||
let save_button_hpgl = document.getElementById('save-hpgl');
|
||||
save_button_hpgl.addEventListener('click', function () {
|
||||
let url = document.URL,
|
||||
parts = url.split('/'),
|
||||
name = parts[parts.length-1],
|
||||
hpgl_url = '/hpgl/' + name,
|
||||
a = document.createElement('a');
|
||||
a.href = hpgl_url;
|
||||
a.setAttribute('download', 'download');
|
||||
if (document.createEvent) {
|
||||
const event = document.createEvent('MouseEvents');
|
||||
event.initEvent('click', true, true);
|
||||
a.dispatchEvent(event);
|
||||
}
|
||||
else {
|
||||
a.click();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
Loading…
Reference in New Issue
Block a user