From 8c3e0e08b628fd79382201d613f27a3ddfe8ed5e Mon Sep 17 00:00:00 2001 From: s3lph <1375407-s3lph@users.noreply.gitlab.com> Date: Sat, 22 Oct 2022 16:14:19 +0200 Subject: [PATCH] v0.2.14: Present an on-screen keyboard and disable file upload in kiosk mode (localhost) --- CHANGELOG.md | 13 ++ README.md | 1 + matemat/__init__.py | 2 +- matemat/webserver/pagelets/signup.py | 7 ++ package/debian/matemat/DEBIAN/control | 6 +- package/debian/matemat/etc/matemat.conf | 7 ++ .../matemat/usr/lib/matemat/matemat.conf | 2 + setup.py | 3 +- static/css/matemat.css | 44 +++++++ templates/signup_kiosk.html | 117 ++++++++++++++++++ 10 files changed, 197 insertions(+), 5 deletions(-) create mode 100644 templates/signup_kiosk.html diff --git a/CHANGELOG.md b/CHANGELOG.md index a800353..0d1a580 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Matemat Changelog + +## Version 0.2.14 + +UX release + +### Changes + + +- Present an on-screen keyboard and disable file upload in kiosk mode (localhost) + + + + ## Version 0.2.13 diff --git a/README.md b/README.md index 2902bfa..3e48955 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ This project intends to provide a well-tested and maintainable alternative to - file-magic - jinja2 - Pillow + - netaddr ## Usage diff --git a/matemat/__init__.py b/matemat/__init__.py index 4b94a86..215eb4c 100644 --- a/matemat/__init__.py +++ b/matemat/__init__.py @@ -1,2 +1,2 @@ -__version__ = '0.2.13' +__version__ = '0.2.14' diff --git a/matemat/webserver/pagelets/signup.py b/matemat/webserver/pagelets/signup.py index bc68611..c3b31c0 100644 --- a/matemat/webserver/pagelets/signup.py +++ b/matemat/webserver/pagelets/signup.py @@ -6,6 +6,7 @@ from io import BytesIO import magic from bottle import get, post, redirect, abort, request, FormsDict from PIL import Image +import netaddr from matemat.db import MatematDatabase from matemat.db.primitives import User @@ -89,5 +90,11 @@ def signup(): redirect('/') elif request.method != 'GET': abort(405, 'Method not allowed') + + acl = netaddr.IPSet([addr.strip() for addr in config.get('SignupKioskMode', '').split(',')]) + if request.remote_addr in acl: + return template.render('signup_kiosk.html', + zip=zip, + setupname=config['InstanceName']) return template.render('signup.html', setupname=config['InstanceName']) diff --git a/package/debian/matemat/DEBIAN/control b/package/debian/matemat/DEBIAN/control index 3cce219..ecb2f61 100644 --- a/package/debian/matemat/DEBIAN/control +++ b/package/debian/matemat/DEBIAN/control @@ -1,10 +1,10 @@ Package: matemat -Version: 0.2.13 -Maintainer: s3lph +Version: 0.2.14 +Maintainer: s3lph <1375407-s3lph@users.noreply.gitlab.com> Section: web Priority: optional Architecture: all -Depends: python3 (>= 3.6), python3-bottle, python3-jinja2, python3-magic, python3-pil +Depends: python3 (>= 3.6), python3-bottle, python3-jinja2, python3-magic, python3-netaddr, python3-pil Description: Soda machine stock-keeping webservice A web service for automated stock-keeping of a soda machine written in Python. It provides a touch-input-friendly user interface (as most input happens diff --git a/package/debian/matemat/etc/matemat.conf b/package/debian/matemat/etc/matemat.conf index 1339a49..f76f673 100644 --- a/package/debian/matemat/etc/matemat.conf +++ b/package/debian/matemat/etc/matemat.conf @@ -28,5 +28,12 @@ InstanceName=Matemat # # SmtpSendReceipts=1 +# +# Permit user signup +# +#SignupEnabled=1 +#SignupKioskMode= ::1, ::ffff:127.0.0.0/8, 127.0.0.0/8 + + # Add static HTTP headers in this section # [HttpHeaders] diff --git a/package/debian/matemat/usr/lib/matemat/matemat.conf b/package/debian/matemat/usr/lib/matemat/matemat.conf index 5c34f56..364af72 100644 --- a/package/debian/matemat/usr/lib/matemat/matemat.conf +++ b/package/debian/matemat/usr/lib/matemat/matemat.conf @@ -9,3 +9,5 @@ LogTarget=stdout UploadDir=/var/lib/matemat/upload DatabaseFile=/var/lib/matemat/matemat.db + +SignupKioskMode= ::1, ::ffff:127.0.0.0/8, 127.0.0.0/8 \ No newline at end of file diff --git a/setup.py b/setup.py index c135a73..40c2079 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,8 @@ soda machine's touch screen). 'bottle', 'file-magic', 'jinja2', - 'Pillow' + 'Pillow', + 'netaddr' ], test_loader='unittest:TestLoader', entry_points={ diff --git a/static/css/matemat.css b/static/css/matemat.css index 3b38c84..0cbfc0f 100644 --- a/static/css/matemat.css +++ b/static/css/matemat.css @@ -249,4 +249,48 @@ #transfer-userlist-list > li.active { background: #60f060; +} + + +div.osk-kbd { + display: none; + font-family: sans-serif; + position: fixed; + left: 0; + bottom: 0; + right: 0; + flex-direction: column; + z-index: 100; + background: white; + font-size: 5vh; +} + +div.osk-kbd.visible { + display: flex; +} + +div.osk-kbd-row { + width: 100%; + height: 10vh; + flex-grow: 1; + display: flex; + flex-direction: row; +} + +div.osk-button { + flex: 1 0 1px; + background: #f0f0f0; + padding: 5px; + margin: 2px; + text-align: center; + line-height: calc(10vh - 10px); +} + +div.osk-button:active, div.osk-button.osk-locked { + background: #606060; +} + +div.osk-button.osk-button-space { + flex: 5 0 1px; + color: #606060; } \ No newline at end of file diff --git a/templates/signup_kiosk.html b/templates/signup_kiosk.html new file mode 100644 index 0000000..0916236 --- /dev/null +++ b/templates/signup_kiosk.html @@ -0,0 +1,117 @@ +{% extends "base.html" %} + +{% block header %} +

Signup

+ {{ super() }} +{% endblock %} + +{% block main %} + + {# Show a username/password signup form #} +
+ +
+ + +
+ + +
+ + +
+ +
+ + + +
+ +
+ {% set lower = [['1','2','3','4','5','6','7','8','9','0','-','⌫'], + ['q','w','e','r','t','y','u','i','o','p','[','⇥'], + ['a','s','d','f','g','h','j','k','l',';','\'','⇤'], + ['z','x','c','v','b','n','m',',','.','/','{','⇧'], + ['SPACE']] %} + {% set upper = [['!','@','#','$','%','^','&','*','(',')','_','⌫'], + ['Q','W','E','R','T','Y','U','I','O','P',']','⇥'], + ['A','S','D','F','G','H','J','K','L',':','"','⇤'], + ['Z','X','C','V','B','N','M','<','>','?','}','⇧'], + ['SPACE']] %} + {% for lrow, urow in zip(lower, upper) %} +
+ {% for lc, uc in zip(lrow, urow) %} +
{{ lc }}
+ {% endfor %} +
+ {% endfor %} +
+ + + + + + {{ super() }} + +{% endblock %}