Skip to content

Commit

Permalink
Add new variable 'url' to forge the QRCode url
Browse files Browse the repository at this point in the history
  • Loading branch information
anxuae committed Apr 12, 2022
1 parent 09a00a2 commit 3bec760
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
7 changes: 5 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Here below the new configuration options available in the `pibooth`_ configurati
background = (0, 0, 0)
# Optional text displayed close to the QR code
side_text =
side_text =
# Offset (x, y) from location
offset = (20, 40)
Expand All @@ -55,7 +55,10 @@ The URL linked to the QR code can be define dynamically using some state variabl
options. Available variables to forge the URL are:

- **picture** : current picture filename
- **count** : current counters. You can access to values using ``{count.xxx}`` (see counters in configuration menu)
- **count** : current counters. You can access to values using ``{count.xxx}`` (see counters
in configuration menu)
- **url** : URL defined in the ``app.previous_picture_url`` attribute. This attribute can be
defined by another plugin.

For instance, ``https://photos.google.com/share/AxFF4t56kiJiu89m/{picture}`` will generate::

Expand Down
7 changes: 4 additions & 3 deletions pibooth_qrcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import pibooth
from pibooth.view.background import multiline_text_to_surfaces

__version__ = "1.0.1"
__version__ = "1.0.2"


SECTION = 'QRCODE'
Expand Down Expand Up @@ -130,7 +130,7 @@ def state_wait_do(app, win):
win.surface.blit(text, rect)


@pibooth.hookimpl
@pibooth.hookimpl(trylast=True)
def state_processing_exit(cfg, app):
"""
Generate the QR Code and store it in the application.
Expand All @@ -143,7 +143,8 @@ def state_processing_exit(cfg, app):
border=1)

url_vars = {'picture': app.picture_filename,
'count': app.count}
'count': app.count,
'url': getattr(app, 'previous_picture_url', None) or ''}

qr.add_data(cfg.get(SECTION, 'prefix_url').format(**url_vars))
qr.make(fit=True)
Expand Down

0 comments on commit 3bec760

Please sign in to comment.