|
@@ -112,7 +112,6 @@ def clip():
|
|
|
else:
|
|
|
content = None
|
|
|
link = f'{LOCATION}/clip/{_hash}' if content else f'{LOCATION}/clip'
|
|
|
- svg = get_qr_code(content, fallback=link)
|
|
|
|
|
|
response.content_type = 'text/html; charset=utf-8'
|
|
|
form = template(
|
|
@@ -125,7 +124,7 @@ def clip():
|
|
|
return template(
|
|
|
'paste',
|
|
|
form=form,
|
|
|
- svg=svg,
|
|
|
+ qr=f'{LOCATION}/clip/{_hash}.qr' if content else f'{LOCATION}/grocery/static/clip-qr.svg',
|
|
|
link=link,
|
|
|
disabled=True if content else False,
|
|
|
download=f'/clip/{_hash}' if content else None
|
|
@@ -134,7 +133,7 @@ def clip():
|
|
|
if request.method == 'POST':
|
|
|
content = validate_parameter(request, 'paste')
|
|
|
if request.params.copy != 'true':
|
|
|
- _b32 = save(content)
|
|
|
+ _b32 = save(content, LOCATION)
|
|
|
return redirect(f'/clip?hash={_b32}')
|
|
|
|
|
|
response.content_type = 'text/html; charset=utf-8'
|
|
@@ -146,11 +145,10 @@ def clip():
|
|
|
disabled=False
|
|
|
)
|
|
|
link = f'{LOCATION}/clip'
|
|
|
- svg = get_qr_code(content, fallback=link)
|
|
|
return template(
|
|
|
'paste',
|
|
|
form=form,
|
|
|
- svg=svg,
|
|
|
+ qr=f'{LOCATION}/grocery/static/clip-qr.svg',
|
|
|
link=link,
|
|
|
disabled=False,
|
|
|
download=None
|
|
@@ -159,6 +157,17 @@ def clip():
|
|
|
|
|
|
@route('/clip/<filename:path>', method='GET')
|
|
|
def get_clip(filename):
|
|
|
+ ext = 'file'
|
|
|
+ if filename and filename.endswith('.qr'):
|
|
|
+ filename, ext = filename.split('.', 1)
|
|
|
+
|
|
|
+ filename = filename and normalize_base32(filename)
|
|
|
+ path = f'{filename}/{filename}.{ext}'
|
|
|
+
|
|
|
+ if ext == 'qr':
|
|
|
+ mimetype = 'image/svg+xml'
|
|
|
+ return static_file(path, root='app/rest/static', mimetype=mimetype)
|
|
|
+
|
|
|
filename = filename and normalize_base32(filename)
|
|
|
if not request.params.raw.lower() == 'true':
|
|
|
|
|
@@ -168,7 +177,7 @@ def get_clip(filename):
|
|
|
if isinstance(ret, HTTPError):
|
|
|
return ret
|
|
|
|
|
|
- return static_file('/'.join([filename,]*2) + '.file', root='app/rest/static')
|
|
|
+ return static_file(path, root='app/rest/static')
|
|
|
|
|
|
|
|
|
@route('/upload', method=['GET', 'POST'])
|