jekyll-read-time 0.1.0
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 +7 -0
- data/.editorconfig +11 -0
- data/.gitignore +25 -0
- data/LICENSE +21 -0
- data/Makefile +19 -0
- data/README.md +29 -0
- data/jekyll-read-time.gemspec +19 -0
- data/lib/jekyll-read-time/filter.rb +39 -0
- data/lib/jekyll-read-time/version.rb +3 -0
- data/lib/jekyll-read-time.rb +5 -0
- metadata +109 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ca10ee65b08015c2678206e588cc6d25c576ff3b
|
4
|
+
data.tar.gz: c1c58edec33675bc5efeb4085c654779ccd27324
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 60378d4778ce9f6a386b5f4df1f35bc0dbfa5ebeb847942f20e436bf70f1282c2e43e68191e2f4b7a518c9dae7a6a9105ee0c5682283f5c59674436cb66840d0
|
7
|
+
data.tar.gz: afe1e5d528aa6cc732df6179cea92118a296b3435eec5bc453edfcd642927b6054428158b2fbe7f34d27f303adeb78802407c2b4f183a39a53f167fce1bd7c10
|
data/.editorconfig
ADDED
data/.gitignore
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
.dat*
|
13
|
+
.repl_history
|
14
|
+
build/
|
15
|
+
*.bridgesupport
|
16
|
+
build-iPhoneOS/
|
17
|
+
build-iPhoneSimulator/
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
/.bundle/
|
23
|
+
/vendor/bundle
|
24
|
+
/lib/bundler/man/
|
25
|
+
.rvmrc
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Jam Risser <jam@jamrizzi.com> (https://jam.jamrizzi.com)
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/Makefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
CWD := $(shell pwd)
|
2
|
+
|
3
|
+
.PHONY: all
|
4
|
+
all: build
|
5
|
+
|
6
|
+
.PHONY: build
|
7
|
+
build: clean
|
8
|
+
@gem build *.gemspec
|
9
|
+
@echo ::: BUILD :::
|
10
|
+
|
11
|
+
.PHONY: push
|
12
|
+
push: build
|
13
|
+
@gem push *.gem
|
14
|
+
@echo ::: PUSH :::
|
15
|
+
|
16
|
+
.PHONY: clean
|
17
|
+
clean:
|
18
|
+
-@rm -rf *.gem &>/dev/null || true
|
19
|
+
@echo ::: CLEAN :::
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Jekyll Read Time
|
2
|
+
|
3
|
+
Jekyll liquid tag to indicating the read time of the content
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
Add the following to your `Gemfile`'
|
8
|
+
```rb
|
9
|
+
group :jekyll_plugins do
|
10
|
+
gem "jekyll-read-time", "~> 0.1.0"
|
11
|
+
end
|
12
|
+
```
|
13
|
+
|
14
|
+
Add the following to your `_config.yml`
|
15
|
+
|
16
|
+
```yml
|
17
|
+
plugins:
|
18
|
+
- jekyll-read-time
|
19
|
+
```
|
20
|
+
|
21
|
+
Place one of the following tags in your layout
|
22
|
+
|
23
|
+
`{{ content | read_time_short }}`
|
24
|
+
|
25
|
+
This generates the reading time as a number, like "4 minute read" or "less than 1 minute read"
|
26
|
+
|
27
|
+
`{{ content | read_time }}`
|
28
|
+
|
29
|
+
This generates the reading time as like "4 min read"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "jekyll-read-time/version"
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = "jekyll-read-time"
|
6
|
+
spec.summary = "Jekyll liquid tag to indicating the read time of the content"
|
7
|
+
spec.description = "Jekyll liquid tag to indicating the read time of the content"
|
8
|
+
spec.version = JekyllReadTime::VERSION
|
9
|
+
spec.authors = ["Jam Risser"]
|
10
|
+
spec.email = ["jam@jamrizzi.com"]
|
11
|
+
spec.homepage = "https://github.com/jamrizzi/jekyll-read-time"
|
12
|
+
spec.licenses = ["MIT"]
|
13
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|spec|features)/!) }
|
14
|
+
spec.require_paths = ["lib"]
|
15
|
+
spec.add_dependency "jekyll", "~> 3.0"
|
16
|
+
spec.add_development_dependency "rake", "~> 11.0"
|
17
|
+
spec.add_development_dependency "rspec", "~> 3.5"
|
18
|
+
spec.add_development_dependency "rubocop", "~> 0.52"
|
19
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "jekyll-read-time"
|
2
|
+
|
3
|
+
module JekyllReadTime
|
4
|
+
|
5
|
+
WORD_PER_MINUTE = 180
|
6
|
+
|
7
|
+
def calculate_time( input )
|
8
|
+
words = input.split.size;
|
9
|
+
minutes = ( words / WORD_PER_MINUTE ).floor
|
10
|
+
return minutes
|
11
|
+
end
|
12
|
+
|
13
|
+
module ReadingTimeFilter
|
14
|
+
def read_time( input )
|
15
|
+
minutes = calculate_time(input)
|
16
|
+
case minutes
|
17
|
+
when 2 then minutes_s = 'two'
|
18
|
+
when 3 then minutes_s = 'three'
|
19
|
+
when 4 then minutes_s = 'four'
|
20
|
+
when 5 then minutes_s = 'five'
|
21
|
+
when 6 then minutes_s = 'six'
|
22
|
+
when 7 then minutes_s = 'seven'
|
23
|
+
when 8 then minutes_s = 'eight'
|
24
|
+
when 9 then minutes_s = 'nine'
|
25
|
+
else minutes_s = minutes
|
26
|
+
end
|
27
|
+
minutes > 0 ? "#{minutes_s} minute read" : "less than one minute read"
|
28
|
+
end
|
29
|
+
Liquid::Template.register_filter(ReadingTimeFilter)
|
30
|
+
end
|
31
|
+
|
32
|
+
module ReadingTimeFilterShort
|
33
|
+
def read_time_short( input )
|
34
|
+
minutes = calculate_time(input)
|
35
|
+
minutes > 0 ? "#{minutes} min read" : "1 min read"
|
36
|
+
end
|
37
|
+
Liquid::Template.register_filter(ReadingTimeFilterShort)
|
38
|
+
end
|
39
|
+
end
|
metadata
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-read-time
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jam Risser
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-01-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jekyll
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '11.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '11.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.52'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.52'
|
69
|
+
description: Jekyll liquid tag to indicating the read time of the content
|
70
|
+
email:
|
71
|
+
- jam@jamrizzi.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".editorconfig"
|
77
|
+
- ".gitignore"
|
78
|
+
- LICENSE
|
79
|
+
- Makefile
|
80
|
+
- README.md
|
81
|
+
- jekyll-read-time.gemspec
|
82
|
+
- lib/jekyll-read-time.rb
|
83
|
+
- lib/jekyll-read-time/filter.rb
|
84
|
+
- lib/jekyll-read-time/version.rb
|
85
|
+
homepage: https://github.com/jamrizzi/jekyll-read-time
|
86
|
+
licenses:
|
87
|
+
- MIT
|
88
|
+
metadata: {}
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options: []
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
requirements: []
|
104
|
+
rubyforge_project:
|
105
|
+
rubygems_version: 2.6.14
|
106
|
+
signing_key:
|
107
|
+
specification_version: 4
|
108
|
+
summary: Jekyll liquid tag to indicating the read time of the content
|
109
|
+
test_files: []
|