jekyll-kw-shorten 0.0.4 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jekyll-kw-shorten.rb +33 -6
- data/lib/jekyll/KargWare/Shorten/parser.rb +3 -1
- data/lib/jekyll/KargWare/Shorten/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97496aede7c98b125cb9e846af73359d5fbc9bf7a1d2bf64209cd1b029e2a8c8
|
4
|
+
data.tar.gz: f10ea06d240481bbf7dc057ea48bd30a915d23a1df0c20a4faedd276d9879475
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbe3c662114d8a867b4e1ed5718215a62826eb35e3e08934fdf460a967757ec00f2b35283a2411e551796b69c2aae0b093cd38e5aa081e8235fbd284acda348a
|
7
|
+
data.tar.gz: 0112cb09a60e5dc1bf4d7a9f9de3a035ed178dcbac030fe2d8f5e5924fc79205d8284907ace1a0175f954acad24e56a2a7e42651a3b3bc3aa53a71983085eba9
|
data/lib/jekyll-kw-shorten.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'jekyll/KargWare/Shorten/parser'
|
4
|
+
require 'jekyll/KargWare/Shorten/version'
|
4
5
|
|
5
6
|
module Jekyll
|
6
7
|
module KargWare
|
@@ -10,28 +11,54 @@ module Jekyll
|
|
10
11
|
|
11
12
|
# shorten tag {% shorten input %} for Jekyll
|
12
13
|
class ShortenTag < Liquid::Tag
|
14
|
+
|
15
|
+
class << self
|
16
|
+
def tag_name
|
17
|
+
name.split("::").last.downcase
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
13
21
|
def initialize(tag_name, input, tokens)
|
14
22
|
super
|
15
23
|
@input = input
|
24
|
+
|
25
|
+
# raise ArgumentError, <<~MSG
|
26
|
+
# Could not use '#{input}' in tag '#{self.class.tag_name}'.
|
27
|
+
# Make sure it is a string or a number.
|
28
|
+
# MSG
|
16
29
|
end
|
17
30
|
|
18
31
|
def render(context)
|
19
|
-
|
20
|
-
|
32
|
+
parser = Jekyll::KargWare::Shorten::Parser.new(get_plugin_config(context))
|
33
|
+
parser.parse(@input)
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def get_plugin_config(context)
|
39
|
+
if defined? context.registers[:site].config
|
40
|
+
context.registers[:site].config[Jekyll::KargWare::Shorten::RUBYGEM_NAME] || {}
|
41
|
+
else
|
42
|
+
{}
|
43
|
+
end
|
21
44
|
end
|
22
45
|
end
|
23
46
|
|
24
47
|
# shorten filter {{ number | shorten }} for Jekyll
|
25
48
|
module ShortenFilter
|
26
49
|
def shorten(number)
|
27
|
-
parser = Jekyll::KargWare::Shorten::Parser.new(
|
28
|
-
parser.
|
50
|
+
parser = Jekyll::KargWare::Shorten::Parser.new(get_plugin_config)
|
51
|
+
parser.parse(number)
|
29
52
|
end
|
30
53
|
|
31
54
|
private
|
32
55
|
|
33
|
-
def
|
34
|
-
@context.registers[:site].config
|
56
|
+
def get_plugin_config
|
57
|
+
if defined? @context.registers[:site].config
|
58
|
+
@context.registers[:site].config[Jekyll::KargWare::Shorten::RUBYGEM_NAME] || {}
|
59
|
+
else
|
60
|
+
{}
|
61
|
+
end
|
35
62
|
end
|
36
63
|
end
|
37
64
|
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'jekyll/KargWare/Shorten/configuration'
|
4
|
+
|
3
5
|
module Jekyll
|
4
6
|
module KargWare
|
5
7
|
module Shorten
|
@@ -11,7 +13,7 @@ module Jekyll
|
|
11
13
|
@configuration = Jekyll::KargWare::Shorten::Configuration.new(options)
|
12
14
|
end
|
13
15
|
|
14
|
-
def
|
16
|
+
def parse(text)
|
15
17
|
if text.is_a? String then
|
16
18
|
return text
|
17
19
|
else
|