Add barcode reader widget to qrcode plugin (#7746)

* Add barcode reader widget to qrcode plugin

* Don't use a fixed ID
This commit is contained in:
Jeremy Ruston
2023-10-14 09:42:34 +01:00
committed by GitHub
parent b7562f0c7b
commit 96b0543351
24 changed files with 813 additions and 30 deletions

View File

@@ -0,0 +1,44 @@
title: $:/plugins/tiddlywiki/qrcode/docs/barcodereader
tags: $:/tags/QRCodeDocs
caption: barcodereader Widget
The `<$barcodereader>` widget allows barcodes to be read from the device camera or from an image file. In the case of the camera, a live preview feed is shown to allow the barcode to be framed.
Note that for security reasons browsers restrict the operation of the camera to only work with web pages that have been loaded via HTTPS, or via localhost. Safari and Firefox allow usage from a file URI, but Chrome crashes when attempting to use the barcode reader from a file URI.
The `<$barcodereader>` widget has the following attributes:
|!Name |!Description |
|actionsSuccess |Action string to be executed when a code is successfully decoded |
|actionsFailure |Action string to be executed in the event of an error |
The following variables are passed to the ''actionsSuccess'' handler:
|!Name |!Description |
|format |Barcode format (see below) |
|text |Decoded text |
The following barcode formats are supported:
* 0: "QR_CODE"
* 1: "AZTEC"
* 2: "CODABAR"
* 3: "CODE_39"
* 4: "CODE_93"
* 5: "CODE_128"
* 6: "DATA_MATRIX"
* 7: "MAXICODE"
* 8: "ITF"
* 9: "EAN_13"
* 10: "EAN_8"
* 11: "PDF_417"
* 12: "RSS_14"
* 13: "RSS_EXPANDED"
* 14: "UPC_A"
* 15: "UPC_E"
* 16: "UPC_EAN_EXTENSION"
The following variables are passed to the ''actionsFailure'' handler:
|!Name |!Description |
|error |Error message |

View File

@@ -0,0 +1,44 @@
title: $:/plugins/tiddlywiki/qrcode/docs/qrcode
tags: $:/tags/QRCodeDocs
caption: makeqr Macro
The ''makeqr'' [[macro|Macros]] converts text data into an image of the corresponding QR code. The image is returned as [[base64-encoded data URI|https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs]].
!! Parameters
;text
: The text to encode
;size
: The size of the image in pixels (defaults to 500)
;errorCorrectLevel
: Determines the amount of error correction applied to the image; see below (defaults to "M").
;fallback
: The fallback image to be returned in case of an error (see below)
The conversion will fail if the text is too long and/or complex and the macro will return the provided fallback image. If no fallback image is provided then an error image is generated.
The error correction level is a [[QR code feature|http://www.qrcode.com/en/about/error_correction.html]]:
<<<
QR Code has error correction capability to restore data if the code is dirty or damaged. ... Level Q or H may be selected for factory environment where QR Code get dirty, whereas Level L may be selected for clean environment with the large amount of data. Typically, Level M (15%) is most frequently selected.
<<<
!! Examples
Making a QR code for a simple string of text:
```
<<makeqr "Hello there!">>
```
Making a QR code for the URL field of the current tiddler:
```
<$macrocall $name="makeqr" text={{!!url}}/>
```
Making a QR code for the URL of the current wiki:
```
<$macrocall $name="makeqr" text={{$:/info/url/full}}/>
```