jekyll-wns 3.4.0 → 4.1.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: 38306cb9f707488c12823384ec74b7930cf88213f85c44dc175127e811c481fd
4
- data.tar.gz: 327780f0d819168bc54b9b71869b4b18a4df0b07316403155d2ec0b445bb5015
3
+ metadata.gz: 39db2c4912ad62b82e3f5f8f35a2a1d8885e03ffc8a3f52ca993889e86985cbc
4
+ data.tar.gz: 2d7cdf9fcbf3b0c7dc99d3d264268a8b11a9d55b05219653c4b6bc92eb4acc35
5
5
  SHA512:
6
- metadata.gz: 3aaba0a6bf99ac328b04d46083dcc3205feb010f60fa07eafdac95d7e2ad7d731eff4061ded3e82955f955019f59787f1e615b7b37c02d4f3914f753b225ed76
7
- data.tar.gz: 2869712897b1038a276af2d06e3d19e45f0ba2e606dc5d735b4834f1abc4b321b23bd3226d7ceda4da978fd17e28dd562a005e7f82f0241ef0bd7ac4ab8423c3
6
+ metadata.gz: 9e3c6c0297e48963461abc3884daec9f7cbf6ce0e98ae97e157396975cda4fc93d2c8ceecfda5a0b7408ae886a4da5e2ed83ce5f6874dd2fe57d39b5daee1eba
7
+ data.tar.gz: c834e2ed3707525e08cb4f517aeabaf8b7102972bd6f0e4138207cc86edbaf420c38f7d61e75bf3dec30362a37fd48fde78a1d2a678a50d321c97013db7e36ab
@@ -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/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
1
  source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
+
5
+ gem "ruby-mp3info", "~> 0.8.10"
data/README.md CHANGED
@@ -164,3 +164,22 @@ With `abbreviations: true`:
164
164
  ```html
165
165
  … tools, e. \g., hammer,…
166
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.4.0"
5
+ spec.version = "4.1.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."
@@ -10,4 +10,6 @@ Gem::Specification.new do |spec|
10
10
  spec.licenses = "MIT"
11
11
 
12
12
  spec.files = `git ls-files -z`.split("\x0")
13
+
14
+ spec.add_dependency("ruby-mp3info", "~> 0.8.10")
13
15
  end
data/lib/jekyll-wns.rb CHANGED
@@ -2,10 +2,11 @@ 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
- require_relative 'jekyll-wns/assets/file_properties_filter'
9
+ require_relative 'jekyll-wns/assets/file_property_filters'
9
10
  require_relative 'jekyll-wns/assets/quads_filter'
10
11
 
11
12
  require_relative 'jekyll-wns/assets/ruby_tag'
@@ -1,11 +1,16 @@
1
1
  module WNS
2
2
  module Abbreviations
3
- THREE_LETTER_EXPRESSION = /([a-zA-Z])\.([a-zA-Z])\.([a-zA-Z])\.(,|) /
4
- THREE_LETTER_REPLACEMENT = "\\1.&#8239;\\2.&#8239;\\3.\\4&nbsp;"
5
- TWO_LETTER_EXPRESSION = /([a-zA-Z])\.([a-zA-Z])\.(,|) /
6
- TWO_LETTER_REPLACEMENT = "\\1.&#8239;\\2.\\3&nbsp;"
7
- CLEANUP_EXPRESSION = /, ([a-zA-Z]\.&)/
8
- 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"
9
14
 
10
15
  def self.enabled?(doc)
11
16
  wns = doc.site.config["wns"] || {}
@@ -14,9 +19,10 @@ module WNS
14
19
 
15
20
  def self.replace_abbreviations!(doc)
16
21
  if Abbreviations::enabled?(doc)
17
- doc.content = doc.content.gsub(Abbreviations::THREE_LETTER_EXPRESSION, Abbreviations::THREE_LETTER_REPLACEMENT)
18
- doc.content = doc.content.gsub(Abbreviations::TWO_LETTER_EXPRESSION, Abbreviations::TWO_LETTER_REPLACEMENT)
19
- 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)
20
26
  end
21
27
  end
22
28
  end
@@ -0,0 +1,39 @@
1
+ require 'mp3info'
2
+
3
+ module WNS
4
+ module FilePropertyFilters
5
+ def file_size(path)
6
+ source = Jekyll.configuration({})['source']
7
+
8
+ unless source.empty?
9
+ source += '/'
10
+ else
11
+ source = ''
12
+ end
13
+ full_path = source + path
14
+
15
+ unless path.nil?
16
+ File.size full_path
17
+ else
18
+ 0
19
+ end
20
+ end
21
+
22
+ def mp3_duration(path)
23
+ source = Jekyll.configuration({})['source'] || ''
24
+
25
+ unless source.empty?
26
+ source += '/'
27
+ else
28
+ source = ''
29
+ end
30
+ full_path = source + path
31
+
32
+ unless path.nil?
33
+ Mp3Info.open(full_path).length.to_i
34
+ else
35
+ 0
36
+ end
37
+ end
38
+ end
39
+ 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
@@ -6,16 +6,15 @@ module WNS
6
6
  end
7
7
 
8
8
  def render(context)
9
- "<div class='youtube' data-videoid='youtube-" + @text[0] + "'>
9
+ "<div class='youtube' id='" + @text[0] + "'>
10
10
  <a class='btn btn-lg btn-block btn-primary' href='https://youtu.be/" + @text[0] + "' target='_blank' rel='noopener'>
11
11
  Watch “" + @text[1] + "” on YouTube
12
12
  </a>
13
- <a class='btn btn-lg btn-block btn-primary'
14
- href='javascript:loadYouTube();'>
13
+ <a class='btn btn-lg btn-block btn-primary youtube-load-btn' data-videoid='" + @text[0] + "'>
15
14
  Load YouTube Video (3rd party script)
16
15
  </a>
17
16
  </div>
18
- <script id='youtube-" + @text[0] + "' type='text/html'>
17
+ <script id='yt-" + @text[0] + "' type='text/html'>
19
18
  <div style='position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; overflow: hidden;'>
20
19
  <iframe
21
20
  style='position: absolute; top: 0; left: 0; width: 100%; height: 100%;'
@@ -1,3 +1,3 @@
1
1
  Liquid::Template.register_filter(WNS::QuadsFilter)
2
2
  Liquid::Template.register_filter(WNS::DigestFilters)
3
- Liquid::Template.register_filter(WNS::FilePropertiesFilter)
3
+ Liquid::Template.register_filter(WNS::FilePropertyFilters)
@@ -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
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-wns
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.0
4
+ version: 4.1.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-11 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2021-07-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ruby-mp3info
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.8.10
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.8.10
13
27
  description:
14
28
  email:
15
29
  - mail@0xReki.de
@@ -24,11 +38,11 @@ files:
24
38
  - README.md
25
39
  - jekyll-wns.gemspec
26
40
  - js/youtube.js
27
- - lib/.ruby-version
28
41
  - lib/jekyll-wns.rb
29
42
  - lib/jekyll-wns/assets/abbreviations.rb
30
43
  - lib/jekyll-wns/assets/digest_filters.rb
31
- - lib/jekyll-wns/assets/file_properties_filter.rb
44
+ - lib/jekyll-wns/assets/file_property_filters.rb
45
+ - lib/jekyll-wns/assets/label_unicode.rb
32
46
  - lib/jekyll-wns/assets/quads.rb
33
47
  - lib/jekyll-wns/assets/quads_filter.rb
34
48
  - lib/jekyll-wns/assets/ruby_tag.rb
data/lib/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 3.0.1
@@ -1,7 +0,0 @@
1
- module WNS
2
- module FilePropertiesFilter
3
- def file_size(path)
4
- File.size path
5
- end
6
- end
7
- end