mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 10:07:19 +00:00
Added first version of QR code generator plugin
This commit is contained in:
parent
7a6d7e2a15
commit
22c1b04ee7
@ -10,7 +10,8 @@
|
|||||||
"tiddlywiki/powered-by-tiddlywiki",
|
"tiddlywiki/powered-by-tiddlywiki",
|
||||||
"tiddlywiki/internals",
|
"tiddlywiki/internals",
|
||||||
"tiddlywiki/highlight",
|
"tiddlywiki/highlight",
|
||||||
"tiddlywiki/markdown"
|
"tiddlywiki/markdown",
|
||||||
|
"tiddlywiki/qrcode"
|
||||||
],
|
],
|
||||||
"themes": [
|
"themes": [
|
||||||
"tiddlywiki/vanilla",
|
"tiddlywiki/vanilla",
|
||||||
|
27
plugins/tiddlywiki/qrcode/MakeContactQR.tid
Normal file
27
plugins/tiddlywiki/qrcode/MakeContactQR.tid
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
title: $:/plugins/tiddlywiki/qrcode/MakeContactQR
|
||||||
|
tags: $:/tags/MakeQR
|
||||||
|
caption: Contact
|
||||||
|
|
||||||
|
\define wifi-url()
|
||||||
|
WIFI:wifi name;T:WPA;S:SSID;P:password;
|
||||||
|
\end
|
||||||
|
|
||||||
|
\define image(firstname,lastname,address,tel,email)
|
||||||
|
<img src=<<makeqr text:"""MECARD:N:$lastname$,$firstname$;ADR:$address$;TEL:$tel$;EMAIL:$email$;;""" size:"350">>/>
|
||||||
|
\end
|
||||||
|
|
||||||
|
! Enter the contact details
|
||||||
|
|
||||||
|
First name: <$edit-text tiddler="$:/config/plugins/tiddlywiki/qrcode/contact/firstname" tag="input" default=""/>
|
||||||
|
|
||||||
|
Last name: <$edit-text tiddler="$:/config/plugins/tiddlywiki/qrcode/contact/lastname" tag="input" default=""/>
|
||||||
|
|
||||||
|
Address: <$edit-text tiddler="$:/config/plugins/tiddlywiki/qrcode/contact/address" tag="input" default=""/>
|
||||||
|
|
||||||
|
Telephone: <$edit-text tiddler="$:/config/plugins/tiddlywiki/qrcode/contact/tel" tag="input" default=""/>
|
||||||
|
|
||||||
|
Email: <$edit-text tiddler="$:/config/plugins/tiddlywiki/qrcode/contact/email" tag="input" default=""/>
|
||||||
|
|
||||||
|
! Here is your QR code
|
||||||
|
|
||||||
|
<$macrocall $name="image" firstname={{$:/config/plugins/tiddlywiki/qrcode/contact/firstname}} lastname={{$:/config/plugins/tiddlywiki/qrcode/contact/lastname}} address={{$:/config/plugins/tiddlywiki/qrcode/contact/address}} tel={{$:/config/plugins/tiddlywiki/qrcode/contact/tel}} email={{$:/config/plugins/tiddlywiki/qrcode/contact/email}}/>
|
15
plugins/tiddlywiki/qrcode/MakeGenericQR.tid
Normal file
15
plugins/tiddlywiki/qrcode/MakeGenericQR.tid
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
title: $:/plugins/tiddlywiki/qrcode/MakeGenericQR
|
||||||
|
tags: $:/tags/MakeQR
|
||||||
|
caption: Generic
|
||||||
|
|
||||||
|
\define image(content)
|
||||||
|
<img src=<<makeqr text:"""$content$""" size:"350">>/>
|
||||||
|
\end
|
||||||
|
|
||||||
|
! Enter the details
|
||||||
|
|
||||||
|
<$edit-text tiddler="$:/config/plugins/tiddlywiki/qrcode/generic" default="" class="tc-edit-texteditor"/>
|
||||||
|
|
||||||
|
! Here is your QR code
|
||||||
|
|
||||||
|
<$macrocall $name="image" content={{$:/config/plugins/tiddlywiki/qrcode/generic}}/>
|
30
plugins/tiddlywiki/qrcode/MakeWifiQR.tid
Normal file
30
plugins/tiddlywiki/qrcode/MakeWifiQR.tid
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
title: $:/plugins/tiddlywiki/qrcode/MakeWifiQR
|
||||||
|
tags: $:/tags/MakeQR
|
||||||
|
caption: Wifi
|
||||||
|
|
||||||
|
\define wifi-url()
|
||||||
|
WIFI:wifi name;T:WPA;S:SSID;P:password;
|
||||||
|
\end
|
||||||
|
|
||||||
|
\define image(network,encryption,ssid,password)
|
||||||
|
<img src=<<makeqr text:"""WIFI:$network$;T:$encryption$;S:$ssid$;P:$password$;""" size:"350">>/>
|
||||||
|
\end
|
||||||
|
|
||||||
|
! Enter the details of your wifi network
|
||||||
|
|
||||||
|
Name of wifi network: <$edit-text tiddler="$:/config/plugins/tiddlywiki/qrcode/wifi/network" tag="input" default=""/>
|
||||||
|
|
||||||
|
Encryption: <$select tiddler="$:/config/plugins/tiddlywiki/qrcode/wifi/encryption" default="none">
|
||||||
|
<option value="none">None</option>
|
||||||
|
<option value="WEP">WEP</option>
|
||||||
|
<option value="WPA">WPA</option>
|
||||||
|
<option value="WPA2">WPA2</option>
|
||||||
|
</$select>
|
||||||
|
|
||||||
|
SSID: <$edit-text tiddler="$:/config/plugins/tiddlywiki/qrcode/wifi/ssid" tag="input" default=""/>
|
||||||
|
|
||||||
|
Password: <$edit-text tiddler="$:/config/plugins/tiddlywiki/qrcode/wifi/password" tag="input" default=""/>
|
||||||
|
|
||||||
|
! Here is your QR code
|
||||||
|
|
||||||
|
<$macrocall $name="image" network={{$:/config/plugins/tiddlywiki/qrcode/wifi/network}} encryption={{$:/config/plugins/tiddlywiki/qrcode/wifi/encryption}} ssid={{$:/config/plugins/tiddlywiki/qrcode/wifi/ssid}} password={{$:/config/plugins/tiddlywiki/qrcode/wifi/password}}/>
|
53
plugins/tiddlywiki/qrcode/ViewToolbarButton/Button.tid
Normal file
53
plugins/tiddlywiki/qrcode/ViewToolbarButton/Button.tid
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
title: $:/plugins/tiddlywiki/qrcode/ViewToolbarButton
|
||||||
|
tags: $:/tags/ViewToolbar
|
||||||
|
caption: {{$:/plugins/tiddlywiki/qrcode/icon}}
|
||||||
|
short-caption: QR code
|
||||||
|
description: Generate QR code for this tiddler
|
||||||
|
|
||||||
|
<span class="tc-popup-keep">
|
||||||
|
<$button popup=<<qualify "$:/state/popup/qrcode">> tooltip={{$:/plugins/tiddlywiki/qrcode/ViewToolbarButton!!description}} aria-label={{$:/plugins/tiddlywiki/qrcode/ViewToolbarButton!!short-caption}} class=<<tv-config-toolbar-class>> class=<<tv-config-toolbar-class>> selectedClass="tc-selected">
|
||||||
|
<$list filter="[<tv-config-toolbar-icons>prefix[yes]]">
|
||||||
|
{{$:/plugins/tiddlywiki/qrcode/icon}}
|
||||||
|
</$list>
|
||||||
|
<$list filter="[<tv-config-toolbar-text>prefix[yes]]">
|
||||||
|
<span class="tc-btn-text"><$text text={{$:/plugins/tiddlywiki/qrcode/ViewToolbarButton!!short-caption}}/></span>
|
||||||
|
</$list>
|
||||||
|
</$button>
|
||||||
|
</span>
|
||||||
|
<$reveal state=<<qualify "$:/state/popup/qrcode">> type="popup" position="below" animate="yes">
|
||||||
|
|
||||||
|
<div class="tc-drop-down">
|
||||||
|
|
||||||
|
{{$:/plugins/tiddlywiki/qrcode/ViewToolbarButton||description}}
|
||||||
|
|
||||||
|
<$set name="tv-config-toolbar-icons" value="yes">
|
||||||
|
|
||||||
|
<$set name="tv-config-toolbar-text" value="yes">
|
||||||
|
|
||||||
|
<$set name="tv-config-toolbar-class" value="tc-btn-invisible">
|
||||||
|
|
||||||
|
<$set name="targetTiddler" value=<<currentTiddler>>>
|
||||||
|
|
||||||
|
<$list filter="[all[shadows+tiddlers]tag[$:/tags/ViewToolbarButton/QRcode]!has[draft.of]]">
|
||||||
|
|
||||||
|
<$button popup=<<qualify "$:/state/popup/qrcode/type">> class="tc-btn-invisible" selectedClass="tc-selected">
|
||||||
|
|
||||||
|
<$action-sendmessage $message="tm-modal" $param=<<currentTiddler>> currentTiddler=<<targetTiddler>>/>
|
||||||
|
|
||||||
|
<$transclude field="caption" mode="inline"/>
|
||||||
|
|
||||||
|
</$button>
|
||||||
|
|
||||||
|
</$list>
|
||||||
|
|
||||||
|
</$set>
|
||||||
|
|
||||||
|
</$set>
|
||||||
|
|
||||||
|
</$set>
|
||||||
|
|
||||||
|
</$set>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</$reveal>
|
12
plugins/tiddlywiki/qrcode/ViewToolbarButton/Raw.tid
Normal file
12
plugins/tiddlywiki/qrcode/ViewToolbarButton/Raw.tid
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
title: $:/plugins/tiddlywiki/qrcode/ViewToolbarButton/Raw
|
||||||
|
tags: $:/tags/ViewToolbarButton/QRcode
|
||||||
|
caption: Raw content of this tiddler
|
||||||
|
subtitle: QR code of raw tiddler content
|
||||||
|
|
||||||
|
\define image()
|
||||||
|
<img src=<<makeqr text:"""$(content)$""" size:"350">>/>
|
||||||
|
\end
|
||||||
|
|
||||||
|
<$set name="content" value={{!!text}}>
|
||||||
|
<<image>>
|
||||||
|
</$set>
|
12
plugins/tiddlywiki/qrcode/ViewToolbarButton/Rendered.tid
Normal file
12
plugins/tiddlywiki/qrcode/ViewToolbarButton/Rendered.tid
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
title: $:/plugins/tiddlywiki/qrcode/ViewToolbarButton/Rendered
|
||||||
|
tags: $:/tags/ViewToolbarButton/QRcode
|
||||||
|
caption: Rendered content of this tiddler
|
||||||
|
subtitle: QR code of rendered tiddler content
|
||||||
|
|
||||||
|
\define image()
|
||||||
|
<img src=<<makeqr text:"""$(content)$""" size:"350">>/>
|
||||||
|
\end
|
||||||
|
|
||||||
|
<$wikify name="content" text={{!!text}} type="text" mode="block" output="formattedtext">
|
||||||
|
<<image>>
|
||||||
|
</$wikify>
|
14
plugins/tiddlywiki/qrcode/ViewToolbarButton/URL.tid
Normal file
14
plugins/tiddlywiki/qrcode/ViewToolbarButton/URL.tid
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
title: $:/plugins/tiddlywiki/qrcode/ViewToolbarButton/URL
|
||||||
|
tags: $:/tags/ViewToolbarButton/QRcode
|
||||||
|
caption: URL of this tiddler
|
||||||
|
subtitle: QR code of URL of this tiddler
|
||||||
|
|
||||||
|
\define image()
|
||||||
|
<img src=<<makeqr text:"""$(url)$#$(hash)$""" size:"350">>/>
|
||||||
|
\end
|
||||||
|
|
||||||
|
<$set name="url" value={{$:/info/url/full}}>
|
||||||
|
<$set name="hash" filter="[<currentTiddler>encodeuricomponent[]]" select="0">
|
||||||
|
<<image>>
|
||||||
|
</$set>
|
||||||
|
</$set>
|
9
plugins/tiddlywiki/qrcode/ViewToolbarButton/styles.tid
Normal file
9
plugins/tiddlywiki/qrcode/ViewToolbarButton/styles.tid
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
title: $:/plugins/tiddlywiki/qrcode/styles
|
||||||
|
tags: [[$:/tags/Stylesheet]]
|
||||||
|
|
||||||
|
\rules only filteredtranscludeinline transcludeinline macrodef macrocallinline
|
||||||
|
|
||||||
|
.tc-drop-down .tc-qrcode-drop-down img {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
3
plugins/tiddlywiki/qrcode/doc/examples.tid
Normal file
3
plugins/tiddlywiki/qrcode/doc/examples.tid
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
title: $:/plugins/tiddlywiki/qrcode/examples
|
||||||
|
|
||||||
|
<<tabs "[all[shadows+tiddlers]tag[$:/tags/MakeQR]!has[draft.of]]" "$:/plugins/tiddlywiki/qrcode/MakeGenericQR">>
|
13
plugins/tiddlywiki/qrcode/doc/readme.tid
Normal file
13
plugins/tiddlywiki/qrcode/doc/readme.tid
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
title: $:/plugins/tiddlywiki/qrcode/readme
|
||||||
|
|
||||||
|
The QR code plugin provides a macro that enables any text to be rendered as a [[QR code|https://en.wikipedia.org/wiki/QR_code]]. QR codes are a type of 2-dimensional bar code that encodes arbitrary data: text, numbers, links. QR code readers are available or built-in for smartphones, making them a convenient means to transfer information between devices
|
||||||
|
|
||||||
|
The QR code plugin adds the following features to TiddlyWiki:
|
||||||
|
|
||||||
|
* A new [[makeqr Macro]] that renders specified text as a QR code image that can be displayed or printed
|
||||||
|
* A new toolbar button that can display several QR code renderings of the content of a tiddler:
|
||||||
|
** Raw content
|
||||||
|
** Rendered, formatted content
|
||||||
|
** URL of tiddler
|
||||||
|
|
||||||
|
The QR code plugin is based on the [[library qrcode.js by Zeno Zeng|https://github.com/zenozeng/node-yaqrcode]].
|
24
plugins/tiddlywiki/qrcode/doc/usage.tid
Normal file
24
plugins/tiddlywiki/qrcode/doc/usage.tid
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
title: $:/plugins/tiddlywiki/qrcode/usage
|
||||||
|
|
||||||
|
! `makeqr` Macro
|
||||||
|
|
||||||
|
The <<.def 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.
|
||||||
|
<<<
|
20
plugins/tiddlywiki/qrcode/files/LICENSE
Executable file
20
plugins/tiddlywiki/qrcode/files/LICENSE
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2013 Zeno Zeng
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
72
plugins/tiddlywiki/qrcode/files/README.md
Executable file
72
plugins/tiddlywiki/qrcode/files/README.md
Executable file
@ -0,0 +1,72 @@
|
|||||||
|
# node-yaqrcode
|
||||||
|
|
||||||
|
Yet another node-qrcode Generator!
|
||||||
|
|
||||||
|
This is a simple and pure javascript wrapper for the QR Code Generator from the d-project.
|
||||||
|
|
||||||
|
No Canvas or Binary needed!
|
||||||
|
|
||||||
|
Note:
|
||||||
|
|
||||||
|
```
|
||||||
|
The word 'QR Code' is registered trademark of
|
||||||
|
DENSO WAVE INCORPORATED
|
||||||
|
http://www.denso-wave.com/qrcode/faqpatent-e.html
|
||||||
|
```
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
- Pure Javascript and could work without any requiments
|
||||||
|
|
||||||
|
- Use `RS_BLOCK_TABLE` from http://davidshimjs.github.io/qrcodejs/ to support typeNumber 40
|
||||||
|
|
||||||
|
- Use the code from http://davidshimjs.github.io/qrcodejs/ to support UTF-8
|
||||||
|
|
||||||
|
- Return a Base64 Data URI like this
|
||||||
|
|
||||||
|
```
|
||||||
|
data:image/gif;base64,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
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```
|
||||||
|
npm install yaqrcode
|
||||||
|
```
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
qrcode = require('yaqrcode');
|
||||||
|
base64 = qrcode('hello world');
|
||||||
|
```
|
||||||
|
|
||||||
|
### custom size
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
qrcode = require('yaqrcode');
|
||||||
|
base64 = qrcode('hello world', {
|
||||||
|
size: 500
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2013,2015 Zeno Zeng
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1587
plugins/tiddlywiki/qrcode/files/qrcode.js
Executable file
1587
plugins/tiddlywiki/qrcode/files/qrcode.js
Executable file
File diff suppressed because it is too large
Load Diff
20
plugins/tiddlywiki/qrcode/files/tiddlywiki.files
Normal file
20
plugins/tiddlywiki/qrcode/files/tiddlywiki.files
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"tiddlers": [
|
||||||
|
{
|
||||||
|
"file": "qrcode.js",
|
||||||
|
"fields": {
|
||||||
|
"type": "application/javascript",
|
||||||
|
"title": "$:/plugins/tiddlywiki/qrcode/qrcode.js",
|
||||||
|
"module-type": "library"
|
||||||
|
},
|
||||||
|
"prefix": "",
|
||||||
|
"suffix": ""
|
||||||
|
},{
|
||||||
|
"file": "LICENSE",
|
||||||
|
"fields": {
|
||||||
|
"type": "text/plain",
|
||||||
|
"title": "$:/plugins/tiddlywiki/qrcode/license"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
24
plugins/tiddlywiki/qrcode/icon.tid
Normal file
24
plugins/tiddlywiki/qrcode/icon.tid
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
title: $:/plugins/tiddlywiki/qrcode/icon
|
||||||
|
tags: $:/tags/Image
|
||||||
|
|
||||||
|
<svg class="tc-image-qrcode tc-image-button" viewBox="0 0 128 128" width="22pt" height="22pt">
|
||||||
|
<g fill-rule="evenodd">
|
||||||
|
<path d="M0,15.9969199 C0,7.16206498 7.16987059,0 15.9969199,0 L64.0030801,0 C72.837935,0 80,7.16987059 80,15.9969199 L80,64.0030801 C80,72.837935 72.8301294,80 64.0030801,80 L15.9969199,80 C7.16206498,80 0,72.8301294 0,64.0030801 L0,15.9969199 Z M16,22.0063866 C16,18.6891509 18.6835413,16 22.0063866,16 L57.9936134,16 C61.3108491,16 64,18.6835413 64,22.0063866 L64,57.9936134 C64,61.3108491 61.3164587,64 57.9936134,64 L22.0063866,64 C18.6891509,64 16,61.3164587 16,57.9936134 L16,22.0063866 Z M28,31.990053 C28,29.7864076 29.7842933,28 31.990053,28 L48.009947,28 C50.2135924,28 52,29.7842933 52,31.990053 L52,48.009947 C52,50.2135924 50.2157067,52 48.009947,52 L31.990053,52 C29.7864076,52 28,50.2157067 28,48.009947 L28,31.990053 Z"></path>
|
||||||
|
<rect x="96" y="16" width="16" height="16" rx="6"></rect>
|
||||||
|
<rect x="96" y="48" width="16" height="16" rx="6"></rect>
|
||||||
|
<rect x="16" y="112" width="16" height="16" rx="6"></rect>
|
||||||
|
<rect x="96" y="64" width="16" height="16" rx="6"></rect>
|
||||||
|
<rect x="96" y="96" width="16" height="16" rx="6"></rect>
|
||||||
|
<rect x="48" y="96" width="16" height="16" rx="6"></rect>
|
||||||
|
<rect x="112" y="0" width="16" height="16" rx="6"></rect>
|
||||||
|
<rect x="32" y="96" width="16" height="16" rx="6"></rect>
|
||||||
|
<rect x="112" y="16" width="16" height="16" rx="6"></rect>
|
||||||
|
<rect x="112" y="80" width="16" height="16" rx="6"></rect>
|
||||||
|
<rect x="112" y="48" width="16" height="16" rx="6"></rect>
|
||||||
|
<rect x="112" y="112" width="16" height="16" rx="6"></rect>
|
||||||
|
<rect x="32" y="112" width="16" height="16" rx="6"></rect>
|
||||||
|
<rect x="80" y="112" width="16" height="16" rx="6"></rect>
|
||||||
|
<rect x="0" y="112" width="16" height="16" rx="6"></rect>
|
||||||
|
<rect x="0" y="96" width="16" height="16" rx="6"></rect>
|
||||||
|
</g>
|
||||||
|
</svg>
|
74
plugins/tiddlywiki/qrcode/makeqr.js
Normal file
74
plugins/tiddlywiki/qrcode/makeqr.js
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
/*\
|
||||||
|
title: $:/plugins/tiddlywiki/qrcode/makeqr.js
|
||||||
|
type: application/javascript
|
||||||
|
module-type: macro
|
||||||
|
|
||||||
|
Macro to convert a string into a QR Code
|
||||||
|
|
||||||
|
\*/
|
||||||
|
(function(){
|
||||||
|
|
||||||
|
/*jslint node: true, browser: true */
|
||||||
|
/*global $tw: false */
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
/*
|
||||||
|
Information about this macro
|
||||||
|
*/
|
||||||
|
|
||||||
|
var qrcode = require("$:/plugins/tiddlywiki/qrcode/qrcode.js");
|
||||||
|
|
||||||
|
var QRCODE_GENERATION_ERROR_PREFIX = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300"><text x="0" y="30" fill="red" font-family="Helvetica, sans-serif" font-size="18">',
|
||||||
|
QRCODE_GENERATION_ERROR_SUFFIX = '</text></svg>';
|
||||||
|
|
||||||
|
exports.name = "makeqr";
|
||||||
|
|
||||||
|
exports.params = [
|
||||||
|
{name: "text"},
|
||||||
|
{name: "size"},
|
||||||
|
{name: "errorCorrectLevel"},
|
||||||
|
{name: "fallback"}
|
||||||
|
];
|
||||||
|
|
||||||
|
/*
|
||||||
|
Run the macro
|
||||||
|
*/
|
||||||
|
exports.run = function(text,size,errorCorrectLevel,fallback) {
|
||||||
|
var result;
|
||||||
|
try {
|
||||||
|
result = generateQrCode(text,{size: size, errorCorrectLevel: errorCorrectLevel});
|
||||||
|
} catch (ex) {
|
||||||
|
console.log("makeqr error: " + ex);
|
||||||
|
result = fallback || ("data:image/svg+xml," + encodeURI(QRCODE_GENERATION_ERROR_PREFIX + ex + QRCODE_GENERATION_ERROR_SUFFIX));
|
||||||
|
}
|
||||||
|
return result || "";
|
||||||
|
};
|
||||||
|
|
||||||
|
function generateQrCode(text,options) {
|
||||||
|
options = options || {};
|
||||||
|
var typeNumber = options.typeNumber || 4,
|
||||||
|
errorCorrectLevel = options.errorCorrectLevel || "M",
|
||||||
|
size = options.size || 500,
|
||||||
|
qr;
|
||||||
|
try {
|
||||||
|
qr = qrcode(typeNumber,errorCorrectLevel);
|
||||||
|
qr.addData(text);
|
||||||
|
qr.make();
|
||||||
|
} catch (e) {
|
||||||
|
if(typeNumber >= 40) {
|
||||||
|
throw new Error("Text too long to encode");
|
||||||
|
} else {
|
||||||
|
return generateQrCode(text, {
|
||||||
|
size: size,
|
||||||
|
errorCorrectLevel: errorCorrectLevel,
|
||||||
|
typeNumber: typeNumber + 1
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var cellsize = parseInt(size / qr.getModuleCount()),
|
||||||
|
margin = parseInt((size - qr.getModuleCount() * cellsize) / 2);
|
||||||
|
return qr.createImgTag(cellsize, margin, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
})();
|
7
plugins/tiddlywiki/qrcode/plugin.info
Normal file
7
plugins/tiddlywiki/qrcode/plugin.info
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"title": "$:/plugins/tiddlywiki/qrcode",
|
||||||
|
"description": "QR Code generator",
|
||||||
|
"author": "Zeno Zeng, adapted by Jeremy Ruston",
|
||||||
|
"plugin-type": "plugin",
|
||||||
|
"list": "readme usage examples license"
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user