From 46808e3932fa596b80a05bb5b24e17ed8300ac55 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 20 Jun 2020 19:37:44 +0000 Subject: [PATCH] Create a qrcode for the domain name --- README.md | 4 ++-- daemon.py | 17 +++++++++++++++-- deploy/i2p | 5 +++-- deploy/onion | 5 +++-- gemini/EN/install.gmi | 2 +- website/EN/index.html | 2 +- 6 files changed, 25 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 9071bfe4..04d5170e 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ On Arch/Parabola: sudo pacman -S tor python-pip python-pysocks python-pycryptodome \ imagemagick python-pillow python-requests \ perl-image-exiftool python-numpy python-dateutil \ - certbot flake8 + python-qrcode python-png certbot flake8 suso pip3 install pyLD ``` @@ -37,7 +37,7 @@ sudo apt install -y \ python3-idna python3-requests \ python3-pyld python3-django-timezone-field \ libimage-exiftool-perl python3-flake8 \ - certbot nginx + python3-pyqrcode python3-png certbot nginx ``` ## Installation diff --git a/daemon.py b/daemon.py index 9d9b5a82..575e6d1b 100644 --- a/daemon.py +++ b/daemon.py @@ -13,6 +13,7 @@ import time import locale import urllib.parse from functools import partial +import pyqrcode # for saving images from hashlib import sha256 from hashlib import sha1 @@ -201,6 +202,16 @@ followsPerPage = 12 sharesPerPage = 12 +def saveDomainQrcode(baseDir: str, httpPrefix: str, + domainFull: str, scale=6) -> None: + """Saves a qrcode image for the domain name + This helps to transfer onion or i2p domains to a mobile device + """ + qrcodeFilename = baseDir + '/accounts/qrcode.png' + url = pyqrcode.create(httpPrefix + '://' + domainFull) + url.png(qrcodeFilename, scale) + + def readFollowList(filename: str) -> None: """Returns a list of ActivityPub addresses to follow """ @@ -1708,12 +1719,13 @@ class PubServer(BaseHTTPRequestHandler): self._benchmarkGETtimings(GETstartTime, GETtimings, 15) - # image on login screen + # image on login screen or qrcode if self.path == '/login.png' or \ self.path == '/login.gif' or \ self.path == '/login.webp' or \ self.path == '/login.jpeg' or \ - self.path == '/login.jpg': + self.path == '/login.jpg' or \ + self.path == '/qrcode.png': mediaFilename = \ self.server.baseDir + '/accounts' + self.path if os.path.isfile(mediaFilename): @@ -7981,6 +7993,7 @@ def runDaemon(blogsInstance: bool, mediaInstance: bool, if port != 80 and port != 443: if ':' not in domain: httpd.domainFull = domain + ':' + str(port) + saveDomainQrcode(baseDir, httpPrefix, httpd.domainFull) httpd.httpPrefix = httpPrefix httpd.debug = debug httpd.federationList = fedList.copy() diff --git a/deploy/i2p b/deploy/i2p index 80b48b80..23ec38c3 100755 --- a/deploy/i2p +++ b/deploy/i2p @@ -57,7 +57,7 @@ if [ -f /usr/bin/pacman ]; then pacman -S --noconfirm python-pip python-pysocks python-pycryptodome \ imagemagick python-pillow python-requests \ perl-image-exiftool python-numpy python-dateutil \ - certbot flake8 git i2pd wget qrencode + python-qrcode certbot flake8 git i2pd wget qrencode pip3 install pyLD else apt-get update @@ -66,7 +66,8 @@ else python3-numpy python3-pil.imagetk python3-pip \ python3-setuptools python3-socks python3-idna \ libimage-exiftool-perl python3-flake8 python3-pyld \ - python3-django-timezone-field nginx git i2pd wget qrencode + python3-django-timezone-field nginx git i2pd wget \ + python3-pyqrcode qrencode python3-png fi if [ ! -d /etc/i2pd ]; then diff --git a/deploy/onion b/deploy/onion index 4b53406a..b2d076c5 100755 --- a/deploy/onion +++ b/deploy/onion @@ -38,7 +38,7 @@ if [ -f /usr/bin/pacman ]; then pacman -S --noconfirm tor python-pip python-pysocks python-pycryptodome \ imagemagick python-pillow python-requests \ perl-image-exiftool python-numpy python-dateutil \ - certbot flake8 git qrencode + python-qrcode certbot flake8 git qrencode pip3 install pyLD else apt-get update @@ -47,7 +47,8 @@ else python3-numpy python3-pil.imagetk python3-pip \ python3-setuptools python3-socks python3-idna \ libimage-exiftool-perl python3-flake8 python3-pyld \ - python3-django-timezone-field tor nginx git qrencode + python3-django-timezone-field tor nginx git qrencode \ + python3-pyqrcode python3-png fi echo 'Cloning the epicyon repo' diff --git a/gemini/EN/install.gmi b/gemini/EN/install.gmi index f78c01d5..6484b30f 100644 --- a/gemini/EN/install.gmi +++ b/gemini/EN/install.gmi @@ -4,7 +4,7 @@ You will need python version 3.7 or later. On a Debian based system: - sudo apt install -y tor python3-socks imagemagick python3-numpy python3-setuptools python3-crypto python3-pycryptodome python3-dateutil python3-pil.imagetk python3-idna python3-requests python3-flake8 python3-pyld python3-django-timezone-field libimage-exiftool-perl certbot nginx + sudo apt install -y tor python3-socks imagemagick python3-numpy python3-setuptools python3-crypto python3-pycryptodome python3-dateutil python3-pil.imagetk python3-idna python3-requests python3-flake8 python3-pyld python3-django-timezone-field python3-pyqrcode python3-png libimage-exiftool-perl certbot nginx The following instructions install Epicyon to the /opt directory. It's not essential that it be installed there, and it could be in any other preferred directory. diff --git a/website/EN/index.html b/website/EN/index.html index 34391f59..2f6c1106 100644 --- a/website/EN/index.html +++ b/website/EN/index.html @@ -1264,7 +1264,7 @@

You will need python version 3.7 or later.

On a Debian based system:

-

sudo apt install -y tor python3-socks imagemagick python3-numpy python3-setuptools python3-crypto python3-pycryptodome python3-dateutil python3-pil.imagetk python3-idna python3-requests python3-flake8 python3-pyld python3-django-timezone-field libimage-exiftool-perl certbot nginx

+

sudo apt install -y tor python3-socks imagemagick python3-numpy python3-setuptools python3-crypto python3-pycryptodome python3-dateutil python3-pil.imagetk python3-idna python3-requests python3-flake8 python3-pyld python3-django-timezone-field python3-pyqrcode python3-png libimage-exiftool-perl certbot nginx