|
|
@ -413,18 +413,31 @@ def resizeSVG (m): |
|
|
|
|
|
|
|
return f'<svg xmlns="http://www.w3.org/2000/svg" viewbox="{viewbox}" width="{newWidth}mm" height="{newHeight}mm" class="svgbob">' |
|
|
|
|
|
|
|
# @app.route('/svg/<id>') |
|
|
|
# def svg (id): |
|
|
|
# params = { |
|
|
|
# 'pad': id or 'default', |
|
|
|
# 'weight': request.args.get('w') or '2', |
|
|
|
# } |
|
|
|
# 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 = pad_export.text |
|
|
|
@app.route('/svg/<id>') |
|
|
|
def svg (id): |
|
|
|
params = { |
|
|
|
'pad': id or 'default', |
|
|
|
'weight': request.args.get('w') or '2', |
|
|
|
} |
|
|
|
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 = pad_export.text |
|
|
|
|
|
|
|
# to SVG |
|
|
|
svg = simplifySVG(ascii2svg(ascii, params['weight'])) |
|
|
|
# Remove background rect inserted by SVG Bob |
|
|
|
svg = re.sub(r'\<rect class="backdrop" x="\d+" y="\d+" width="\d+" height="\d+">\<\/rect\>', '', svg, flags=re.M) |
|
|
|
svg = re.sub(r'<svg xmlns="http://www.w3.org/2000/svg" width="(\d+)" height="(\d+)" class="svgbob">', resizeSVG,svg) |
|
|
|
|
|
|
|
r = Response(svg, mimetype='application/svg') |
|
|
|
r.headers.extend({ |
|
|
|
'Content-Disposition': f'attachment; filename="cobbled-paths-{id}.svg"' |
|
|
|
}) |
|
|
|
|
|
|
|
return r |
|
|
|
|
|
|
|
|
|
|
|
@app.route('/hpgl/<id>') |
|
|
|