Skip to content

Commit 2978680

Browse files
committed
Integrate QR code on sharelink invite form for easy direct visual sharing.
1 parent c494b40 commit 2978680

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

mig/shared/functionality/sharelink.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
from mig.shared.sharelinks import build_sharelinkitem_object, load_share_links, \
4747
create_share_link, update_share_link, delete_share_link, \
4848
create_share_link_form, invite_share_link_form, \
49-
invite_share_link_message, generate_sharelink_id
49+
invite_share_link_message, show_share_link_qr, generate_sharelink_id
5050
from mig.shared.validstring import valid_user_path
5151
from mig.shared.vgrid import in_vgrid_share, vgrid_is_owner, vgrid_settings, \
5252
vgrid_add_sharelinks, vgrid_remove_sharelinks
@@ -111,8 +111,13 @@ def main(client_id, user_arguments_dict):
111111
[table_spec],
112112
{'width': 600})
113113
title_entry['script']['advanced'] += add_import
114+
title_entry['script']['advanced'] += '''
115+
<script type="text/javascript" src="/images/js/qrious.js"></script>
116+
'''
114117
title_entry['script']['init'] += add_init
115118
title_entry['script']['ready'] += add_ready
119+
title_entry['script']['ready'] += show_share_link_qr(configuration,
120+
share_id)
116121
output_objects.append({'object_type': 'html_form',
117122
'text': man_base_html(configuration)})
118123

mig/shared/sharelinks.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,15 @@ def invite_share_link_form(configuration, client_id, share_dict, output_format,
347347
<h4>Send Share Link Invitations</h4>
348348
<p>
349349
After creating a share link you can manually give the link to anyone
350-
you want to share the data with and/or use this form to send
351-
invitations on email. Please note that abuse of this service to send
352-
out spam mail is strictly prohibited and will be sanctioned.
350+
you want to share the data with. Either by handing them the URL<br/>
351+
%(share_url)s<br/>
352+
or by letting them scan this QR code:
353+
</p>
354+
<canvas id="sharelink_qr"><!-- filled by script --></canvas>
355+
<p>
356+
Alternatively you can use this form to send invitations on email.
357+
Please note that abuse of this service to send out spam mail is
358+
strictly prohibited and will be sanctioned.
353359
</p>
354360
<table>
355361
<tr><td colspan=2>
@@ -389,6 +395,19 @@ def invite_share_link_form(configuration, client_id, share_dict, output_format,
389395
''' % fill_helpers
390396
return html
391397

398+
def show_share_link_qr(configuration, share_id):
399+
"""Generate QR code for sharelinks"""
400+
fill_helpers = {}
401+
fill_helpers['share_url'] = "%s/sharelink/%s" % \
402+
(configuration.migserver_https_sid_url,
403+
share_id)
404+
return '''
405+
var qr = new QRious({
406+
element: document.getElementById("sharelink_qr"),
407+
value: "%(share_url)s",
408+
size: 200
409+
});
410+
''' % fill_helpers
392411

393412
def load_share_links(configuration, client_id):
394413
"""Find all share links owned by user"""

0 commit comments

Comments
 (0)