jekyll-wns 3.2.0 β†’ 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce4a530aaa64925e4fe89a2318439175152879194a2a6d2b84d607937ddd0e29
4
- data.tar.gz: 3fea0f81407034716ae7b995907f270a36b372b22b7bd6b9530148a2b8decc4f
3
+ metadata.gz: 88c6a307f9dcfa02534630dd00aaa8934a9d53793d3eaee4b44a5e7e349374be
4
+ data.tar.gz: 70fd68ab8f8cc9c6e387b7067d06680ea01ecd3ac26e55e525c9335e77df2e3e
5
5
  SHA512:
6
- metadata.gz: 5024b3b8ad0bdcfd5bf6d67e04bf3911b33e328d92cb12c3777c7aad6fc0d7cea0e05ef2e1f85325dcb444b7a1eb7dd4f5e4b718e53837e1eb9bca9f27e872f3
7
- data.tar.gz: 4907863579a24fbd276ec75efe74fe06e24edc518255eb397bff24dc3de712d12dc2db313fa93a5dd2542c14ce80c53cfaca61e9f37233e424db3e414cf192cc
6
+ metadata.gz: 9dfa46f956900df775184338cd195b7fa8c7f1e91dfd0d729024d196d9bf71fe70e5a6dd11d5a1fd917641478ab7d2e804184875319764ec1d21830c3a297d26
7
+ data.tar.gz: 7a7389c4347905765cf9edcd32848ba86f65c786f6c12a085165f8e416d5c48a280b30fdc64ba91ef8236b773f6cd68629326b5b85ac39c6eb8594ebba95f5ba
@@ -2,7 +2,7 @@ name: Ruby Gem
2
2
 
3
3
  on:
4
4
  push:
5
- tags: "*"
5
+ tags: "v*"
6
6
 
7
7
  jobs:
8
8
  build:
data/README.md CHANGED
@@ -4,11 +4,11 @@ A collection of filters, tags and hooks that I use on my pages.
4
4
 
5
5
  ## Installation
6
6
 
7
- 1. Add `gem "jekyll-wns", git: "https://github.com/0xReki/jekyll-wns.git, branch: "main"` to your site's Gemfile and run `bundle`
7
+ 1. Run Μ€ bundle add jekyll-wns` and
8
8
  2. Add the following to your site's `_config.yml`:
9
9
 
10
10
  ```yml
11
- gems:
11
+ plugins:
12
12
  - jekyll-wns
13
13
  ```
14
14
 
@@ -76,6 +76,62 @@ gems:
76
76
  <p style="text-align:center" data-mce-style="text-align:center">πŸ™ΏπŸ™ΎπŸ™ΏπŸ™ΎπŸ™ΏπŸ™ΎπŸ™ΏπŸ™Ύ
77
77
  ```
78
78
 
79
+ #### Ruby Annotations
80
+
81
+ ```liquid
82
+ {% ruby b|t %}
83
+
84
+ {% ruby a#b|t#s %}
85
+
86
+ {% ruby a#b#c|x#y#z %}
87
+ ```
88
+
89
+ ```html
90
+ <p><ruby><span class="rb first last" aria-hidden="true">b</span><rp>(</rp><rt first="" last="">t</rt><rp>)</rp></ruby></p>
91
+
92
+ <p><ruby><span class="rb first" aria-hidden="true">a</span><rp>(</rp><rt first="">t</rt><rp>)</rp><span class="rb last" aria-hidden="true">b</span><rp>(</rp><rt last="">s</rt><rp>)</rp></ruby></p>
93
+
94
+ <p><ruby><span class="rb first" aria-hidden="true">a</span><rp>(</rp><rt first="">x</rt><rp>)</rp><span class="rb" aria-hidden="true">b</span><rp>(</rp><rt>y</rt><rp>)</rp><span class="rb last" aria-hidden="true">c</span><rp>(</rp><rt last="">z</rt><rp>)</rp></ruby></p>
95
+ ```
96
+
97
+ #### YouTube Embed
98
+
99
+ The following snippet should be integrated into your site for the tag to properly work:
100
+
101
+ ```javascript
102
+ function loadYouTube() {
103
+ var videos = d.getElementsByClassName('youtube');
104
+ for (var i = 0; i < videos.length; i++) {
105
+ videos[i].innerHTML = d.getElementById(videos[i].getAttribute('data-videoid')).innerHTML;
106
+ }
107
+ }
108
+ ```
109
+
110
+ ```liquid
111
+ {% youtube U6xJfP7-HCc|Base 12 β€” Numberphile %}
112
+ ```
113
+
114
+ ```html
115
+ <div class="youtube" data-videoid="youtube-U6xJfP7-HCc">
116
+ <a class="btn btn-lg btn-block btn-primary" href="https://youtu.be/U6xJfP7-HCc" target="_blank" rel="noopener">
117
+ Watch β€œBase 12 β€” Numberphile” on YouTube
118
+ </a>
119
+ <a class="btn btn-lg btn-block btn-primary" href="javascript:loadYouTube();">
120
+ Load YouTube Video (3rd party script)
121
+ </a>
122
+ </div>
123
+ <script id="youtube-U6xJfP7-HCc" type="text/html">
124
+ <div style='position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; overflow: hidden;'>
125
+ <iframe
126
+ style='position: absolute; top: 0; left: 0; width: 100%; height: 100%;'
127
+ src='https://www.youtube-nocookie.com/embed/U6xJfP7-HCc?rel=0'
128
+ frameborder='0'
129
+ allow='accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture'
130
+ allowfullscreen></iframe>
131
+ </div>
132
+ </script>
133
+ ```
134
+
79
135
  ### Hooks
80
136
 
81
137
  #### Automatic replacement of spaces to en quads after each sentence
@@ -108,3 +164,22 @@ With `abbreviations: true`:
108
164
  ```html
109
165
  … tools,&nbsp;e.&#8239;\g.,&nbsp;hammer,…
110
166
  ```
167
+
168
+ ### Automatic labelling of Unicode Characters
169
+
170
+ Some assistive technologies don't play nice with Unicode character, this should improve thing by adding aria-labels spans to wherever necessary.
171
+
172
+ To enable this, add this to your `_config.yml`:
173
+
174
+ ```yml
175
+ wns:
176
+ label_unicode: true
177
+ ```
178
+
179
+ ```markdown
180
+ Hyda-β…£
181
+ ```
182
+
183
+ ```html
184
+ Hyda-<span aria-label="4">β…£</span>
185
+ ```
data/jekyll-wns.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "jekyll-wns"
5
- spec.version = "3.2.0"
5
+ spec.version = "4.0.1"
6
6
  spec.authors = ["Thai Chung"]
7
7
  spec.email = ["mail@0xReki.de"]
8
8
  spec.summary = "Collection of Filters, Tags and Hooks I use."
data/js/youtube.js ADDED
@@ -0,0 +1,6 @@
1
+ function loadYouTube() {
2
+ var videos = d.getElementsByClassName('youtube');
3
+ for (var i = 0; i < videos.length; i++) {
4
+ videos[i].innerHTML = d.getElementById(videos[i].getAttribute('data-videoid')).innerHTML;
5
+ }
6
+ }
data/lib/jekyll-wns.rb CHANGED
@@ -2,12 +2,16 @@ require 'liquid'
2
2
  require 'jekyll'
3
3
 
4
4
  require_relative 'jekyll-wns/assets/abbreviations'
5
+ require_relative 'jekyll-wns/assets/label_unicode'
5
6
  require_relative 'jekyll-wns/assets/quads'
6
7
 
7
8
  require_relative 'jekyll-wns/assets/digest_filters'
8
9
  require_relative 'jekyll-wns/assets/file_properties_filter'
9
10
  require_relative 'jekyll-wns/assets/quads_filter'
11
+
12
+ require_relative 'jekyll-wns/assets/ruby_tag'
10
13
  require_relative 'jekyll-wns/assets/scene_break_tag'
14
+ require_relative 'jekyll-wns/assets/youtube_tag'
11
15
 
12
16
  require_relative 'jekyll-wns/register_filters'
13
17
  require_relative 'jekyll-wns/register_hooks'
@@ -1,9 +1,16 @@
1
1
  module WNS
2
2
  module Abbreviations
3
- MAIN_EXPRESSION = /([a-zA-Z])\.([a-zA-Z])\.(,|) /
4
- MAIN_REPLACEMENT = "\\1.&#8239;\\2.\\3&nbsp;"
5
- CLEANUP_EXPRESSION = /, ([a-zA-Z]\.&)/
6
- CLEANUP_REPLACEMENT = ",&nbsp;\\1"
3
+ INNER_DOTS_EXPRESSION = /([a-zA-Z]\.)([a-zA-Z]\.)([a-zA-Z]\.|)([a-zA-Z]\.|)([a-zA-Z]\.|)(,|) /
4
+ INNER_DOTS_REPLACEMENT = "\\1&#8239;\\2&#8239;\\3&#8239;\\4&#8239;\\5&#8239;\\6&nbsp;"
5
+
6
+ TITLE_EXPRESSION = /(Mr|Ms|Mrs|Messrs|Mmes|Msgr|Prof|Rev|Dr|Sr|St|[A-Z][a-z]|[A-Z][a-z][a-z])(\.|\.,|,) /
7
+ TITLE_REPLACEMENT = "\\1\\2&nbsp;"
8
+
9
+ PREFIX_EXPRESSION = /, ([a-zA-Z]\.&)/
10
+ PREFIX_REPLACEMENT = ",&nbsp;\\1"
11
+
12
+ COLLAPSE_SPACES_EXPRESSION = /(&#8239;)*(&nbsp;|,)/
13
+ COLLAPSE_SPACES_REPLACEMENT = "\\2"
7
14
 
8
15
  def self.enabled?(doc)
9
16
  wns = doc.site.config["wns"] || {}
@@ -12,8 +19,10 @@ module WNS
12
19
 
13
20
  def self.replace_abbreviations!(doc)
14
21
  if Abbreviations::enabled?(doc)
15
- doc.content = doc.content.gsub(Abbreviations::MAIN_EXPRESSION, Abbreviations::MAIN_REPLACEMENT)
16
- doc.content = doc.content.gsub(Abbreviations::CLEANUP_EXPRESSION, Abbreviations::CLEANUP_REPLACEMENT)
22
+ doc.content = doc.content.gsub(Abbreviations::INNER_DOTS_EXPRESSION, Abbreviations::INNER_DOTS_REPLACEMENT)
23
+ doc.content = doc.content.gsub(Abbreviations::TITLE_EXPRESSION, Abbreviations::TITLE_REPLACEMENT)
24
+ doc.content = doc.content.gsub(Abbreviations::PREFIX_EXPRESSION, Abbreviations::PREFIX_REPLACEMENT)
25
+ doc.content = doc.content.gsub(Abbreviations::COLLAPSE_SPACES_EXPRESSION, Abbreviations::COLLAPSE_SPACES_REPLACEMENT)
17
26
  end
18
27
  end
19
28
  end
@@ -0,0 +1,19 @@
1
+ module WNS
2
+ module LabelUnicode
3
+ SYMBOLS = [/(β… )/, /(β…‘)/, /(β…’)/, /(β…£)/, /(β…€)/, /(β…₯)/, /(β…¦)/, /(β…§)/, /(β…¨)/, /(β…©)/]
4
+ READINGS = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
5
+
6
+ def self.enabled?(doc)
7
+ wns = doc.site.config["wns"] || {}
8
+ wns["label_unicode"] || false
9
+ end
10
+
11
+ def self.label_unicode!(doc)
12
+ if LabelUnicode::enabled?(doc)
13
+ for i in (0..(LabelUnicode::SYMBOLS.length()) - 1) do
14
+ doc.content = doc.content.gsub(Regexp.new("([\\-A-Za-z0-9]*|)#{LabelUnicode::SYMBOLS[i].source}([\\-A-Za-z0-9]*|)"), "<span aria-label='\\1#{LabelUnicode::READINGS[i]}\\3'>\\1\\2\\3</span>")
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -16,7 +16,9 @@ module WNS
16
16
  end
17
17
 
18
18
  def self.insert_quads_into_document!(doc)
19
- doc.content = insert_quads doc.content
19
+ if Quads::enabled?(doc)
20
+ doc.content = insert_quads doc.content
21
+ end
20
22
  end
21
23
  end
22
24
  end
@@ -0,0 +1,21 @@
1
+ module WNS
2
+ class RubyTag < Liquid::Tag
3
+ def initialize(tag_name, text, tokens)
4
+ super
5
+
6
+ @text = text.strip!.split("|")
7
+ end
8
+
9
+ def render(context)
10
+ base = @text[0].split("#")
11
+ text = @text[1].split("#")
12
+ output = "<ruby>"
13
+ i = 0
14
+ while i < base.length()
15
+ output += "<span class='rb" + (i == 0 ? " first" : "") + (i == base.length() - 1 ? " last" : "") + "' aria-hidden='true'>#{base[i]}</span><rp>(</rp><rt" + (i == 0 ? " first" : "") + (i == base.length() - 1 ? " last" : "") + ">#{text[i]}</rt><rp>)</rp>"
16
+ i += 1
17
+ end
18
+ output += "</ruby>"
19
+ end
20
+ end
21
+ end
@@ -13,7 +13,7 @@ module WNS
13
13
  when "wave"
14
14
  '<p style="text-align:center;letter-spacing:-.13em" data-mce-style="text-align:center;letter-spacing:-.13em">◠◑◠◑◠◑◠◑◠◑◠◑◠◑◠◑◠◑◠◑◠‏</p>'
15
15
  when "wall"
16
- '<p style="text-align:center;letter-spacing:-.2em" data-mce-style="text-align:center;letter-spacing:-.2em">β€ŽβšŽβ€βšβ€ŽβšŽβšβ€ŽβšŽβšβ€ŽβšŽβšβ€ŽβšŽβšβ€ŽβšŽβšβ€ŽβšŽβšβ€ŽβšŽβšβ€ŽβšŽβšβ€ŽβšŽβšβ€ŽβšŽ</p>'
16
+ '<p style="text-align:center;letter-spacing:-.2em" data-mce-style="text-align:center;letter-spacing:-.2em">⚎⚍⚎⚍⚎⚍⚎⚍⚎⚍⚎⚍⚎⚍⚎⚍⚎⚍⚎⚍</p>'
17
17
  else
18
18
  '<p style="text-align:center" data-mce-style="text-align:center">πŸ™ΏπŸ™ΎπŸ™ΏπŸ™ΎπŸ™ΏπŸ™ΎπŸ™ΏπŸ™ΎπŸ™ΏπŸ™ΎπŸ™ΏπŸ™ΎπŸ™ΏπŸ™ΎπŸ™Ώ</p>'
19
19
  end
@@ -0,0 +1,30 @@
1
+ module WNS
2
+ class YoutubeTag < Liquid::Tag
3
+ def initialize(tag_name, text, tokens)
4
+ super
5
+ @text = text.strip!.split("|")
6
+ end
7
+
8
+ def render(context)
9
+ "<div class='youtube' data-videoid='youtube-" + @text[0] + "'>
10
+ <a class='btn btn-lg btn-block btn-primary' href='https://youtu.be/" + @text[0] + "' target='_blank' rel='noopener'>
11
+ Watch β€œ" + @text[1] + "” on YouTube
12
+ </a>
13
+ <a class='btn btn-lg btn-block btn-primary'
14
+ href='javascript:loadYouTube();'>
15
+ Load YouTube Video (3rd party script)
16
+ </a>
17
+ </div>
18
+ <script id='youtube-" + @text[0] + "' type='text/html'>
19
+ <div style='position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; overflow: hidden;'>
20
+ <iframe
21
+ style='position: absolute; top: 0; left: 0; width: 100%; height: 100%;'
22
+ src='https://www.youtube-nocookie.com/embed/" + @text[0] + "?rel=0'
23
+ frameborder='0'
24
+ allow='accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture'
25
+ allowfullscreen></iframe>
26
+ </div>
27
+ </script>"
28
+ end
29
+ end
30
+ end
@@ -1,14 +1,23 @@
1
- Jekyll::Hooks.register :documents, :pre_render do |document|
2
- WNS::Abbreviations::replace_abbreviations! document
3
- WNS::Quads::insert_quads_into_document! document
1
+ Jekyll::Hooks.register :pages, :pre_render do |document|
2
+ if document.path =~ /(.md|.html)/
3
+ WNS::Abbreviations::replace_abbreviations! document
4
+ WNS::LabelUnicode::label_unicode! document
5
+ WNS::Quads::insert_quads_into_document! document
6
+ end
4
7
  end
5
8
 
6
- Jekyll::Hooks.register :pages, :pre_render do |document|
7
- WNS::Abbreviations::replace_abbreviations! document
8
- WNS::Quads::insert_quads_into_document! document
9
+ Jekyll::Hooks.register :pages, :post_render do |document|
10
+ if document.path =~ /(.md|.html)/
11
+ true
12
+ end
9
13
  end
10
14
 
11
15
  Jekyll::Hooks.register :posts, :pre_render do |document|
12
16
  WNS::Abbreviations::replace_abbreviations! document
17
+ WNS::LabelUnicode::label_unicode! document
13
18
  WNS::Quads::insert_quads_into_document! document
14
19
  end
20
+
21
+ Jekyll::Hooks.register :posts, :post_render do |document|
22
+ true
23
+ end
@@ -1 +1,3 @@
1
1
  Liquid::Template.register_tag('scene_break', WNS::SceneBreakTag)
2
+ Liquid::Template.register_tag('youtube', WNS::YoutubeTag)
3
+ Liquid::Template.register_tag('ruby', WNS::RubyTag)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-wns
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 4.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thai Chung
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-08 00:00:00.000000000 Z
11
+ date: 2021-06-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -23,14 +23,17 @@ files:
23
23
  - LICENSE
24
24
  - README.md
25
25
  - jekyll-wns.gemspec
26
- - lib/.ruby-version
26
+ - js/youtube.js
27
27
  - lib/jekyll-wns.rb
28
28
  - lib/jekyll-wns/assets/abbreviations.rb
29
29
  - lib/jekyll-wns/assets/digest_filters.rb
30
30
  - lib/jekyll-wns/assets/file_properties_filter.rb
31
+ - lib/jekyll-wns/assets/label_unicode.rb
31
32
  - lib/jekyll-wns/assets/quads.rb
32
33
  - lib/jekyll-wns/assets/quads_filter.rb
34
+ - lib/jekyll-wns/assets/ruby_tag.rb
33
35
  - lib/jekyll-wns/assets/scene_break_tag.rb
36
+ - lib/jekyll-wns/assets/youtube_tag.rb
34
37
  - lib/jekyll-wns/register_filters.rb
35
38
  - lib/jekyll-wns/register_hooks.rb
36
39
  - lib/jekyll-wns/register_tags.rb
data/lib/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 3.0.1