jekyll_reading_time 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9c3d51ca61a18c6d445c4d9c58ea87be14022726
4
+ data.tar.gz: 7c7927e5369ca372b4e6175ffbe4fe4f9594d72d
5
+ SHA512:
6
+ metadata.gz: ae53a5bdb7c53ebced5506c46aea9531f78604d916b381b7b5e4793b1185a38ac01cbb0de8e0dddae81b3517e60172394a180899fa8ac02456cf849df975be36
7
+ data.tar.gz: 658f773fc681f16180a8ef7b54f461f3ee9034d009bc41e7bdefa01d511f488484b10ea4a32b53b4d45686defb9be4b3e04c45a6b896e5197e6badd317fdfa95
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jekyll-reading-time.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Routemap Application Ltd
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # jekyll_reading_time
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/jekyll_reading_time.svg)](http://badge.fury.io/rb/jekyll_reading_time)
4
+
5
+ Display in your Jekyll posts and pages how long it'll take to read their content.
6
+
7
+ ## Installation
8
+
9
+ Add this gem to your Jekyll installation's `Gemfile`:
10
+
11
+ ```ruby
12
+ gem 'jekyll_reading_time', '~> 0.1.0'
13
+ ```
14
+
15
+ Next, add the plugin to the `plugins` key in Jekyll's `_config.yml`:
16
+
17
+ ```yml
18
+ gems: [jekyll_reading_time]
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ Add to your layout, piping your page or post's content into the `reading_time` filter, and it'll return roughly how long it'll take to read your content, assuming a pace of 180 words per minute.
24
+
25
+ We'll return "about 1 minute" if it'll take a minute or less, or otherwise "about *n* minutes", where *n* is how long we think it'll take.
26
+
27
+ ```html
28
+ <p>{{ page.content | reading_time }}</p>
29
+ ```
30
+
31
+ ## Configuration
32
+
33
+ We'll assume that people read at a pace of 180 words per minute, but this is customisable. You can also customise the words we translate English as "about", "minute" and "minutes".
34
+
35
+ To set your own options, add a section like this to your Jekyll `_config.yml`:
36
+
37
+ ```yml
38
+ reading_time:
39
+ words_per_minute: 150
40
+ translations:
41
+ about: etwa
42
+ minute: minute
43
+ minutes: minuten
44
+ ```
45
+
46
+ ## Contributing
47
+
48
+ Bug reports and pull requests are welcome on GitHub at https://github.com/routemap/jekyll-reading-time. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
49
+
50
+ ## License
51
+
52
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "jekyll_reading_time"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jekyll_reading_time/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "jekyll_reading_time"
8
+ spec.version = JekyllReadingTime::VERSION
9
+ spec.authors = ["Tim Rogers"]
10
+ spec.email = ["tim@theroutemap.com"]
11
+
12
+ spec.summary = %q{Calculate how long it'll take to read a Jekyll post or page}
13
+ spec.homepage = "https://github.com/routemap/jekyll-reading-time"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_runtime_dependency "jekyll"
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.10"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ end
@@ -0,0 +1,48 @@
1
+ require 'liquid'
2
+
3
+ module JekyllReadingTime
4
+ module ReadingTime
5
+ def reading_time(input)
6
+ minutes = reading_time_as_integer(input)
7
+
8
+ if minutes == 1
9
+ "#{about_translation} #{minutes} #{minute_translation}"
10
+ else
11
+ "#{about_translation} #{minutes} #{minutes_translation}"
12
+ end
13
+ end
14
+
15
+ private
16
+
17
+ def reading_time_as_integer(input)
18
+ words = input.split(" ").count
19
+ (words / words_per_minute).floor
20
+ end
21
+
22
+ def about_translation
23
+ translations.fetch("about", "about")
24
+ end
25
+
26
+ def minute_translation
27
+ translations.fetch("minute", "minute")
28
+ end
29
+
30
+ def minutes_translation
31
+ translations.fetch("minutes", "minutes")
32
+ end
33
+
34
+ def words_per_minute
35
+ reading_time_config.fetch("words_per_minute", 180)
36
+ end
37
+
38
+ def translations
39
+ reading_time_config.fetch("translations", {})
40
+ end
41
+
42
+ def reading_time_config
43
+ Jekyll.configuration({}).fetch("reading_time", {})
44
+ end
45
+ end
46
+ end
47
+
48
+ Liquid::Template.register_filter(JekyllReadingTime::ReadingTime)
@@ -0,0 +1,3 @@
1
+ module JekyllReadingTime
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,3 @@
1
+ require "jekyll_reading_time/version"
2
+ require "jekyll_reading_time/reading_time"
3
+ require "jekyll"
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll_reading_time
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Tim Rogers
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-06-23 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: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description:
56
+ email:
57
+ - tim@theroutemap.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - CODE_OF_CONDUCT.md
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - bin/console
69
+ - bin/setup
70
+ - jekyll_reading_time.gemspec
71
+ - lib/jekyll_reading_time.rb
72
+ - lib/jekyll_reading_time/reading_time.rb
73
+ - lib/jekyll_reading_time/version.rb
74
+ homepage: https://github.com/routemap/jekyll-reading-time
75
+ licenses:
76
+ - MIT
77
+ metadata: {}
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 2.4.7
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: Calculate how long it'll take to read a Jekyll post or page
98
+ test_files: []