octopress-filters 1.2.6 → 1.3.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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +31 -11
- data/lib/octopress-filters.rb +6 -7
- data/lib/octopress-filters/hooks.rb +14 -6
- data/lib/octopress-filters/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5013a2c3ecc4308d7fe3569ce0f3271c14369ef1
|
4
|
+
data.tar.gz: f4778d34eb74007d3082aadd3b98a054209be6d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cd7c03398afabd9d7dc4d81037faac1062b7c70c04e3b79dff43db7b1341e220fac2558dd911f241dd9e7e3474c04cdc0f51715783738fbdbb180ea7ae66814
|
7
|
+
data.tar.gz: 8896792ee6c7adc720d908fa2ffb07f00afaa772ff4b3c7c757e197395f2b455acb6d12c9d782d68f3f148790e308a07b73b71bed76f936b4c5fa9e908fd96b6
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
A set of handy liquid filters used by Octopress.
|
4
4
|
|
5
|
-
- full_urls - Replace relative
|
6
|
-
- full_url - Replace a relative
|
7
|
-
- canonical_url - Convert a
|
5
|
+
- full_urls - Replace relative URLs with absolute URLs (searches for `href` and `src` properties).
|
6
|
+
- full_url - Replace a relative URL with an absolute URL.
|
7
|
+
- canonical_url - Convert a URL to the proper canonical version.
|
8
8
|
- titlecase - Properly capitalize titles with John Gruber’s [Title Case](http://daringfireball.net/2008/05/title_case).
|
9
9
|
- smartquotes - Smartly curl your quotation marks with John Gruber’s [Smarty Pants](http://daringfireball.net/projects/smartypants/).
|
10
10
|
- unorphan - Insert a non-breaking space between the last two words in a title.
|
@@ -12,7 +12,9 @@ A set of handy liquid filters used by Octopress.
|
|
12
12
|
- classify - An alias for sluggify (seems appropriate when working with CSS class names).
|
13
13
|
- compact_newlines - Compact groups of empty lines into one, because Liquid templates have lots of whitespace.
|
14
14
|
- join_lines - Remove all new lines, joining each line with a separator. (defaults to a space).
|
15
|
-
- strip_url_protocol - Remove the protocol before a
|
15
|
+
- strip_url_protocol - Remove the protocol before a URL, e.g. `http://` or `https://`.
|
16
|
+
|
17
|
+
Also, not a filter, but this adds `excerpted` (true/false) to post's data. Meaning you can use `{% if post.excerpted %}` in a post loop.
|
16
18
|
|
17
19
|
[](https://travis-ci.org/octopress/filters)
|
18
20
|
[](https://rubygems.org/gems/octopress-filters)
|
@@ -41,18 +43,18 @@ Then add the gem to your Jekyll configuration.
|
|
41
43
|
|
42
44
|
## Examples
|
43
45
|
|
44
|
-
### Full
|
46
|
+
### Full URLs
|
45
47
|
|
46
|
-
Any relative links in your site will be expanded with the `url` configuration in Jekyll's `_config.yml`. This filter only affects
|
48
|
+
Any relative links in your site will be expanded with the `url` configuration in Jekyll's `_config.yml`. This filter only affects URLs
|
47
49
|
beginning with `/` inside of `href` or `src` attributes.
|
48
50
|
|
49
51
|
```
|
50
52
|
{{ post.content | full_urls }}
|
51
53
|
```
|
52
54
|
|
53
|
-
You might use this if you're working on an RSS feed, you'll need to be sure all relative
|
55
|
+
You might use this if you're working on an RSS feed, you'll need to be sure all relative URLs in your content are expanded to full URLs.
|
54
56
|
|
55
|
-
### Full
|
57
|
+
### Full URL
|
56
58
|
|
57
59
|
This filter prepends input with the `url` configuration in Jekyll's `_config.yml`.
|
58
60
|
|
@@ -60,9 +62,9 @@ This filter prepends input with the `url` configuration in Jekyll's `_config.yml
|
|
60
62
|
{{ post.url | full_url }}
|
61
63
|
```
|
62
64
|
|
63
|
-
### Canonical
|
65
|
+
### Canonical URL
|
64
66
|
|
65
|
-
This filter expands the
|
67
|
+
This filter expands the URL to be a full URL, then removes "index.html" if it is present. Here are some examples.
|
66
68
|
|
67
69
|
```
|
68
70
|
{{ "about/index.html" | canonical_url }} //=> http://example.com/about/
|
@@ -114,13 +116,31 @@ This filter expands the url to be a full url, then removes "index.html" if it is
|
|
114
116
|
…
|
115
117
|
```
|
116
118
|
|
117
|
-
### Strip
|
119
|
+
### Strip URL protocol
|
118
120
|
|
119
121
|
```
|
120
122
|
{{ site.url }} # https://some-site.com/
|
121
123
|
{{ site.url | strip_url_protocol }} # some-site.com/
|
122
124
|
```
|
123
125
|
|
126
|
+
### Excerpted posts
|
127
|
+
|
128
|
+
In your templates, you may want to show different content if a post is excerpted. This plugin automatically searches each post for the
|
129
|
+
excerpt separator and adds the `excerpted` state to the post data. So you can do something like this.
|
130
|
+
|
131
|
+
```
|
132
|
+
{% if post.excerpted %}
|
133
|
+
{{ post.excerpt }}
|
134
|
+
<a href="{{ post.url }}"Continue reading →</a>
|
135
|
+
{% else %}
|
136
|
+
{{ post.content }}
|
137
|
+
{% endif %}
|
138
|
+
```
|
139
|
+
|
140
|
+
Jekyll has an `excerpt_separator` configuration which lets you define how Jekyll selects your post excerpts. By default this config is
|
141
|
+
set to `"\n\n"`, but redefining the config to something like `excerpt_separator: <!--more-->` makes it easy to decide
|
142
|
+
which content is excerpted, or even whether posts have excerpts at all.
|
143
|
+
|
124
144
|
## Contributing
|
125
145
|
|
126
146
|
1. Fork it ( https://github.com/octopress/filters/fork )
|
data/lib/octopress-filters.rb
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
require "octopress-filters/version"
|
2
|
-
|
3
|
-
unless defined? Octopress.site
|
4
|
-
require "octopress-filters/hooks"
|
5
|
-
end
|
6
|
-
|
2
|
+
require "octopress-filters/hooks"
|
7
3
|
require "rubypants-unicode"
|
8
4
|
require "titlecase"
|
9
5
|
|
10
6
|
module Octopress
|
11
7
|
module Filters
|
8
|
+
attr_accessor :site
|
9
|
+
@site = {}
|
12
10
|
|
13
11
|
# Returns the site's baseurl or '/' if the config isn't set
|
14
12
|
#
|
@@ -17,12 +15,12 @@ module Octopress
|
|
17
15
|
end
|
18
16
|
|
19
17
|
def baseurl
|
20
|
-
Octopress.site.config['baseurl'] || Octopress.site.config['root']
|
18
|
+
Octopress::Filters.site.config['baseurl'] || Octopress::Filters.site.config['root']
|
21
19
|
end
|
22
20
|
|
23
21
|
def site_url
|
24
22
|
@url ||= begin
|
25
|
-
File.join(Octopress.site.config['url'], root)
|
23
|
+
File.join(Octopress::Filters.site.config['url'], root)
|
26
24
|
rescue
|
27
25
|
raise IOError.new "Please add your site's published url to your _config.yml, eg url: http://example.com"
|
28
26
|
end
|
@@ -156,6 +154,7 @@ module Octopress
|
|
156
154
|
module_function *instance_methods
|
157
155
|
public *private_instance_methods.reject!{ |m| [:root].include?(m) }
|
158
156
|
|
157
|
+
|
159
158
|
end
|
160
159
|
end
|
161
160
|
|
@@ -1,11 +1,19 @@
|
|
1
|
+
require 'octopress-hooks'
|
2
|
+
|
1
3
|
module Octopress
|
2
|
-
|
3
|
-
|
4
|
-
|
4
|
+
module Filters
|
5
|
+
|
6
|
+
class SiteGrabber < Hooks::Site
|
7
|
+
def post_read(site)
|
8
|
+
Octopress::Filters.site = site
|
9
|
+
end
|
10
|
+
end
|
5
11
|
|
6
|
-
|
7
|
-
|
8
|
-
|
12
|
+
class PostHooks < Hooks::Post
|
13
|
+
def pre_render(post)
|
14
|
+
excerpted = post.content.match(post.site.config['excerpt_separator'])
|
15
|
+
post.data.merge!({'excerpted' => !!excerpted})
|
16
|
+
end
|
9
17
|
end
|
10
18
|
end
|
11
19
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: octopress-filters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Mathis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: pry-byebug
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
125
139
|
description:
|
126
140
|
email:
|
127
141
|
- brandon@imathis.com
|