|
|
@ -6,7 +6,7 @@ import sys |
|
|
|
import tempfile |
|
|
|
import io |
|
|
|
import requests |
|
|
|
# from svg_to_hpgl import svgToHPGL |
|
|
|
from svg_to_hpgl import svgToHPGL |
|
|
|
|
|
|
|
app = Flask(__name__) |
|
|
|
|
|
|
@ -157,7 +157,7 @@ def drawing(id): |
|
|
|
ascii_input = pad_export.text |
|
|
|
|
|
|
|
# to SVG |
|
|
|
svg = ascii2svg(ascii_input, params['weight']); |
|
|
|
svg = ascii2svg(ascii_input, params['weight']) |
|
|
|
|
|
|
|
return render_template( |
|
|
|
'drawing.html', |
|
|
@ -226,10 +226,22 @@ def catalogue(): |
|
|
|
def make_svg (): |
|
|
|
return '' |
|
|
|
|
|
|
|
@app.route('/hpgl/') |
|
|
|
def hpgl (): |
|
|
|
# generate svg |
|
|
|
svg = make_svg() |
|
|
|
@app.route('/hpgl/<id>') |
|
|
|
def hpgl (id): |
|
|
|
params = { |
|
|
|
'pad': id or 'default', |
|
|
|
'weight': request.args.get('w') or '3', |
|
|
|
} |
|
|
|
params['pad-full'] = etherpad + prefix + params['pad'] |
|
|
|
|
|
|
|
# get pad content |
|
|
|
print(' getting ' + params['pad-full']) |
|
|
|
pad_export = requests.get(params['pad-full'] + '/export/txt') |
|
|
|
ascii_input = pad_export.text |
|
|
|
|
|
|
|
# to SVG |
|
|
|
svg = ascii2svg(ascii_input, params['weight']) |
|
|
|
|
|
|
|
# store as a temporary file |
|
|
|
(svg_file, svg_path) = tempfile.mkstemp() |
|
|
|
svg_file.write(svg) |
|
|
@ -241,11 +253,9 @@ def hpgl (): |
|
|
|
os.remove(svg_path) |
|
|
|
|
|
|
|
r = Response(hpgl, mimetype='application/hpgl') |
|
|
|
|
|
|
|
r.headers.extend({ |
|
|
|
'Content-Disposition': 'attachment; filename="cobbled-paths.hpgl"' |
|
|
|
}) |
|
|
|
|
|
|
|
return r |
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|