jekyll-qr 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/jekyll-qr.rb +36 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: cac316d2525db5fa7ea752f19f79836d667f40f674d6f5dd39bf6ee848be30f8
4
+ data.tar.gz: c448c3021ea9225d93470afd33f94a42331e66895351f42d081e0b4e58408ab1
5
+ SHA512:
6
+ metadata.gz: cf9144171a1874b912937406ca0b260851ec15a7a63a57321164ee342816f9bab8aad7b119fce43978d95295247105249a87aee87ed43820c135309f9f8ae8ce
7
+ data.tar.gz: eae23154e518379508cd9a70da614d46c68fd65c1421e4982ef0b24c8d836bc6d3b187c894957529d6b8f790aa87941aed51c879cbbe6392f1f38316a8de327d
data/lib/jekyll-qr.rb ADDED
@@ -0,0 +1,36 @@
1
+ # SPDX-License-Identifier: GPL-3.0-only
2
+ # SPDX-FileCopyrightText: 2024 Sebastian Crane <seabass-labrax@gmx.com>
3
+
4
+ # frozen_string_literal: true
5
+
6
+ require 'erb'
7
+ require 'jekyll'
8
+ require 'rqrcode'
9
+
10
+ # Main tag definition for Jekyll Liquid
11
+ class QR < Liquid::Tag
12
+ RQRCODE_OPTIONS = {
13
+ level: :l
14
+ }.freeze
15
+
16
+ RQRCODE_SVG_OPTIONS = {
17
+ viewbox: true,
18
+ # offset is rqrcode's default module size of 11px multiplied by
19
+ # the recommended 'quiet area' for a QR code of four modules
20
+ offset: 44,
21
+ use_path: true
22
+ }.freeze
23
+
24
+ def initialize(tag_name, text, tokens)
25
+ super
26
+ @text = text
27
+ end
28
+
29
+ def render(_)
30
+ qr = RQRCode::QRCode.new(@text.strip, **RQRCODE_OPTIONS)
31
+ qr_svg = ERB::Util.url_encode(qr.as_svg(**RQRCODE_SVG_OPTIONS).to_s)
32
+ "<img class=\"qr-code\" src=\"data:image/svg+xml;utf8,#{qr_svg}\">"
33
+ end
34
+
35
+ Liquid::Template.register_tag 'qr', self
36
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-qr
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Sebastian Crane
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 1980-01-01 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/jekyll-qr.rb
20
+ homepage:
21
+ licenses:
22
+ - GPL-3.0-only
23
+ metadata:
24
+ rubygems_mfa_required: 'true'
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 2.7.0
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubygems_version: 3.5.5
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Embed QR codes with Liquid tags
44
+ test_files: []