jekyll-uj-powertools 1.6.13 → 1.6.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/jekyll-uj-powertools.gemspec +1 -1
- data/lib/tags/readtime.rb +12 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18477ab3973e5e57e8219050d534de95931357c22447f6ee3ad189c78af1303f
|
4
|
+
data.tar.gz: ee42cd7804794b12971d8480ca7f4571d7ca1229587d0d6c11e90685eb143a1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d898ebfb5c473390ddeb41fc125a4cb2e11dfbc8880d48c7b24313538c30311dd62ac917b2bf6d5b87c1c19461cfa10ff205ab308fe72f74490d0aa39295145
|
7
|
+
data.tar.gz: 14126d4f4e0fbdb967a3792a3949ed18a4d02160b57c146d24ad58993a9a62dad1f87dfe9f72fbb8046d9d060dab54b4477cd6dc90b349dc806f4e60bffb270c
|
data/lib/tags/readtime.rb
CHANGED
@@ -5,7 +5,7 @@ require_relative '../helpers/variable_resolver'
|
|
5
5
|
module Jekyll
|
6
6
|
class UJReadtimeTag < Liquid::Tag
|
7
7
|
include UJPowertools::VariableResolver
|
8
|
-
|
8
|
+
|
9
9
|
def initialize(tag_name, markup, tokens)
|
10
10
|
super
|
11
11
|
@markup = markup.strip
|
@@ -15,22 +15,22 @@ module Jekyll
|
|
15
15
|
# Get the content to analyze
|
16
16
|
content = resolve_content(context)
|
17
17
|
return '1' unless content
|
18
|
-
|
18
|
+
|
19
19
|
# Strip HTML tags
|
20
20
|
stripped_content = strip_html(content)
|
21
|
-
|
21
|
+
|
22
22
|
# Count words
|
23
23
|
words = count_words(stripped_content)
|
24
|
-
|
25
|
-
# Calculate readtime (
|
26
|
-
readtime = (words /
|
24
|
+
|
25
|
+
# Calculate readtime (269 words per minute, minimum 1 minute)
|
26
|
+
readtime = (words / 269.0).ceil
|
27
27
|
readtime = 1 if readtime < 1
|
28
|
-
|
28
|
+
|
29
29
|
readtime.to_s
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
private
|
33
|
-
|
33
|
+
|
34
34
|
def resolve_content(context)
|
35
35
|
if @markup.empty?
|
36
36
|
# No argument, use page content
|
@@ -42,7 +42,7 @@ module Jekyll
|
|
42
42
|
resolve_input(context, @markup)
|
43
43
|
end
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
def strip_html(content)
|
47
47
|
# Remove HTML tags
|
48
48
|
content = content.to_s.gsub(/<script.*?<\/script>/m, '')
|
@@ -51,7 +51,7 @@ module Jekyll
|
|
51
51
|
content = content.gsub(/\s+/, ' ')
|
52
52
|
content.strip
|
53
53
|
end
|
54
|
-
|
54
|
+
|
55
55
|
def count_words(text)
|
56
56
|
# Count words (split by whitespace)
|
57
57
|
text.split(/\s+/).length
|
@@ -59,4 +59,4 @@ module Jekyll
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
-
Liquid::Template.register_tag('uj_readtime', Jekyll::UJReadtimeTag)
|
62
|
+
Liquid::Template.register_tag('uj_readtime', Jekyll::UJReadtimeTag)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-uj-powertools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ITW Creative Works
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-10-
|
11
|
+
date: 2025-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|