Browse Source

Added pad downloading.

master
Gijs 8 months ago
parent
commit
e8c36e10d7
  1. 26
      app.py
  2. 1
      requirements.txt
  3. 1
      svg_to_hpgl.py

26
app.py

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

1
requirements.txt

@ -1,2 +1,3 @@
Flask Flask
pyinkscape pyinkscape
requests

1
svg_to_hpgl.py

@ -1,5 +1,4 @@
from hpgl_multipen_output import HpglMultipenOutput from hpgl_multipen_output import HpglMultipenOutput
from sys import argv
def svgToHPGL (path, speed=1, penCount=8, force=2): def svgToHPGL (path, speed=1, penCount=8, force=2):
e = HpglMultipenOutput() e = HpglMultipenOutput()

Loading…
Cancel
Save