octopress-filters 1.2.6 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 275742bcf0c2c8509d00c77967e676656d414359
4
- data.tar.gz: 55acae0b91e3ff40333ebb176a92eb7fa22fefa6
3
+ metadata.gz: 5013a2c3ecc4308d7fe3569ce0f3271c14369ef1
4
+ data.tar.gz: f4778d34eb74007d3082aadd3b98a054209be6d7
5
5
  SHA512:
6
- metadata.gz: 459fcd158dd11dd276c5b1ef871f2dc02ccfa638b112d28e8ad15df1a489c9f27b931d230607af9166ef234bb349462d1b84588fe69d459d295126f505e60273
7
- data.tar.gz: 60d86ad2b640030e3ee0483054f4e7fa03d799cff19742895c8f9cad8203e7da9778a47356737cd7917468e47cb1900f1d86e0f7cc9eff7ab228fb61a5f62990
6
+ metadata.gz: 7cd7c03398afabd9d7dc4d81037faac1062b7c70c04e3b79dff43db7b1341e220fac2558dd911f241dd9e7e3474c04cdc0f51715783738fbdbb180ea7ae66814
7
+ data.tar.gz: 8896792ee6c7adc720d908fa2ffb07f00afaa772ff4b3c7c757e197395f2b455acb6d12c9d782d68f3f148790e308a07b73b71bed76f936b4c5fa9e908fd96b6
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ### 1.3.0 - 2015-02-08
4
+
5
+ - New: Added excerpted state to post data, e.g. {{ post.excerpted }} # true/false
6
+
3
7
  ### 1.2.6 - 2015-01-24
4
8
 
5
9
  - Fix: Baseurl expansion no longer breaks root relative URLs.
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 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.
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 url, e.g. `http://` or `https://`.
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
  [![Build Status](https://travis-ci.org/octopress/filters.svg)](https://travis-ci.org/octopress/filters)
18
20
  [![Gem Version](http://img.shields.io/gem/v/octopress-filters.svg)](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 urls
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 urls
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 urls in your content are expanded to full urls.
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 url
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 url
65
+ ### Canonical URL
64
66
 
65
- This filter expands the url to be a full url, then removes "index.html" if it is present. Here are some examples.
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 url protocol
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 )
@@ -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
- class << self
3
- attr_accessor :site
4
- end
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
- class SiteGrabber < Jekyll::Generator
7
- def generate(site)
8
- Octopress.site = site
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
@@ -1,5 +1,5 @@
1
1
  module Octopress
2
2
  module Filters
3
- VERSION = "1.2.6"
3
+ VERSION = "1.3.0"
4
4
  end
5
5
  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.2.6
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-01-24 00:00:00.000000000 Z
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