jekyll-read-more 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/LICENSE +10 -0
- data/README.md +57 -0
- data/jekyll-read-more-0.1.0.gem +0 -0
- data/jekyll-read-more.gemspec +23 -0
- data/lib/jekyll-read-more.rb +2 -0
- data/lib/jekyll-read-more/filter.rb +43 -0
- data/lib/jekyll-read-more/version.rb +5 -0
- metadata +80 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fc80ff58409b3d21e9b76f69c2576cddc764b332
|
4
|
+
data.tar.gz: 27729aa24c85b99f1a0af90d2ebc25c347e4917c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 37958bb19efc461b87b0abe8b9a840a09d81f49d8d3ea996c51c19b3c691a313ac39add9eec4c4e8ce7a3bb9435bcc195b339a09afc7dbf6e2942db1b56049da
|
7
|
+
data.tar.gz: 2372001c6856748df7c2ca42e73a096444faa19295e62adacd2765a3cd6bc28bf9371d9751e8cf38f0becbf61eea7424b4114724f0d3536f07df28e39284e113
|
data/LICENSE
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright © 2015, Rob Shaw.
|
4
|
+
|
5
|
+
This software is released under the following version of the MIT license:
|
6
|
+
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following condition: the above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
+
|
9
|
+
The software is provided “as is”, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.
|
10
|
+
|
data/README.md
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# Read More Plugin for Jekyll
|
2
|
+
|
3
|
+
A [Liquid Filter](http://liquidmarkup.org/) to determine if a [Jekyll](http://jekyllrb.com/) Post has an excerpt to display and retrieve the excerpt to use on a list page for read more capability.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
The easiest way to install this plugin is with RubyGems: `gem install jekyll-read-more`.
|
8
|
+
|
9
|
+
You can see the gem on Ruby Gems: [jekyll-read-more](https://rubygems.org/gems/jekyll-read-more).
|
10
|
+
|
11
|
+
This Liquid Filter is designed specifically for Jekyll. This plugin can be installed directly to the `_plugins/` directory by dropping the contents of the `lib` directory into the `_plugins` folder.
|
12
|
+
|
13
|
+
See [documentation on installing Jekyll plugins](http://jekyllrb.com/docs/plugins/#installing-a-plugin) for more detailed instructions.
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
In any post where an excerpt should be used to display elsewhere, include the following tag `<!---excerpt-break-->` after the content that should be displayed as the excerpt.
|
18
|
+
|
19
|
+
_Please note that the tag has three dashes (-) after the bang (!). This is to support HTML comments in markdown._
|
20
|
+
|
21
|
+
Two methods are provided via Liquid Filters:
|
22
|
+
|
23
|
+
* post\_contains\_excerpt\_tag?
|
24
|
+
* get\_post\_excerpt
|
25
|
+
|
26
|
+
### post\_contains\_excerpt\_tag?
|
27
|
+
|
28
|
+
Determines if the excerpt tag exists in the post. The return value is a boolean.
|
29
|
+
|
30
|
+
Example Usage:
|
31
|
+
|
32
|
+
{% if post.content | post_should_be_truncated? %}
|
33
|
+
<a href="{{ post.url }}">Read more →</a>
|
34
|
+
{% endif %}
|
35
|
+
|
36
|
+
### get\_post\_excerpt
|
37
|
+
|
38
|
+
Will remove all content from the excerpt tag and after. The return value will be a string.
|
39
|
+
|
40
|
+
If the excerpt tag cannot be found, it will perform no action.
|
41
|
+
|
42
|
+
Example Usage:
|
43
|
+
|
44
|
+
<p class="excerpt">
|
45
|
+
{{ post.content | get_post_excerpt }}
|
46
|
+
</p>
|
47
|
+
|
48
|
+
## Versioning
|
49
|
+
|
50
|
+
The version numbers of this project conform to [Semantic Versioning 2.0](http://semver.org/).
|
51
|
+
|
52
|
+
* __0.1.0__ (2015-03-09): Initial release of gem.
|
53
|
+
|
54
|
+
## License
|
55
|
+
|
56
|
+
This is released under the MIT license. Please see LICENSE file for more details.
|
57
|
+
|
Binary file
|
@@ -0,0 +1,23 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
|
2
|
+
|
3
|
+
require 'jekyll-read-more/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem_spec|
|
6
|
+
gem_spec.name = 'jekyll-read-more'
|
7
|
+
gem_spec.version = Jekyll::ReadMore::VERSION
|
8
|
+
gem_spec.date = '2015-03-09'
|
9
|
+
|
10
|
+
gem_spec.summary = 'A Liquid Filter to get an excerpt from a Jekyll Post.'
|
11
|
+
gem_spec.description = 'A Liquid Filter to determine if a Jekyll Post has an excerpt to display and get the excerpt.'
|
12
|
+
|
13
|
+
gem_spec.authors = ['Rob Shaw']
|
14
|
+
gem_spec.email = ['rob@borwahs.com']
|
15
|
+
gem_spec.homepage = 'https://github.com/borwahs/jekyll-read-more/'
|
16
|
+
gem_spec.license = 'MIT'
|
17
|
+
|
18
|
+
gem_spec.files = Dir["./**/*"].reject{|file| file =~ /\.\/(doc|pkg|spec|test)/}
|
19
|
+
gem_spec.require_path = 'lib'
|
20
|
+
|
21
|
+
gem_spec.add_runtime_dependency 'liquid'
|
22
|
+
gem_spec.add_development_dependency 'jekyll'
|
23
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# jekyll-read-more
|
2
|
+
#
|
3
|
+
# A Liquid Filter for Jekyll to check and retrieve
|
4
|
+
# an excerpt from a post.
|
5
|
+
#
|
6
|
+
# https://github.com/borwahs/jekyll-post-excerpt
|
7
|
+
#
|
8
|
+
# Copyright (c) Rob Shaw, 2015
|
9
|
+
# See readme.md for LICENSE information.
|
10
|
+
|
11
|
+
module Jekyll
|
12
|
+
module ReadMore
|
13
|
+
module Filter
|
14
|
+
extend self
|
15
|
+
|
16
|
+
# uses the markdown format <!--- (three dashes)
|
17
|
+
EXCERPT_BREAK_TAG = "<!---excerpt-break-->"
|
18
|
+
|
19
|
+
def post_contains_excerpt_tag?(post)
|
20
|
+
post.include?(EXCERPT_BREAK_TAG)
|
21
|
+
end
|
22
|
+
|
23
|
+
def get_post_excerpt(post)
|
24
|
+
if !post_contains_excerpt_tag?(post)
|
25
|
+
return post
|
26
|
+
end
|
27
|
+
|
28
|
+
post_split = post.split(EXCERPT_BREAK_TAG)
|
29
|
+
|
30
|
+
strip_footnotes(post_split[0])
|
31
|
+
end
|
32
|
+
|
33
|
+
def strip_footnotes(content)
|
34
|
+
# Example: <sup>...</sup>
|
35
|
+
# Regex: <sup>.*?<\/sup>/mi
|
36
|
+
|
37
|
+
content.gsub(/<sup>.*?<\/sup>/mi, '')
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
Liquid::Template.register_filter(Jekyll::ReadMore::Filter) if defined?(Liquid)
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-read-more
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rob Shaw
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: liquid
|
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: jekyll
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: A Liquid Filter to determine if a Jekyll Post has an excerpt to display
|
42
|
+
and get the excerpt.
|
43
|
+
email:
|
44
|
+
- rob@borwahs.com
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ./LICENSE
|
50
|
+
- ./README.md
|
51
|
+
- ./jekyll-read-more-0.1.0.gem
|
52
|
+
- ./jekyll-read-more.gemspec
|
53
|
+
- ./lib/jekyll-read-more.rb
|
54
|
+
- ./lib/jekyll-read-more/filter.rb
|
55
|
+
- ./lib/jekyll-read-more/version.rb
|
56
|
+
homepage: https://github.com/borwahs/jekyll-read-more/
|
57
|
+
licenses:
|
58
|
+
- MIT
|
59
|
+
metadata: {}
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
requirements: []
|
75
|
+
rubyforge_project:
|
76
|
+
rubygems_version: 2.4.5
|
77
|
+
signing_key:
|
78
|
+
specification_version: 4
|
79
|
+
summary: A Liquid Filter to get an excerpt from a Jekyll Post.
|
80
|
+
test_files: []
|