octopress-filters 1.1.2 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3c65382a30429a404d49a1cb99e50bfb23703fd1
4
- data.tar.gz: d666f7a9bdc1881762edfbecec3cc4fb72381e98
3
+ metadata.gz: 47d40082d204354809525e9551ddbd6eab622278
4
+ data.tar.gz: f67ec62b70dfad459b14250060562daedfaf762c
5
5
  SHA512:
6
- metadata.gz: 29708b749f9ea64d3375e2fefebbfbc8b7c7e45faecd9ecfa81c39561d0c86ee1cb2d409f0e77c79d6f3e2f84179fede3682c1f5ce5b47edfc44dfe812d277d0
7
- data.tar.gz: f26aa1793c01c10ae7491cd9e160bd0263ba973bc9c90c20a0b4690be386fd1150102e2523fb19beb5d5692bed5c46069c2a423de96ddf9902aa44e32467b1ea
6
+ metadata.gz: 423d42bc07b4525ffb331d9665b721eae432b8fe88d090c5c19b9d12406c17705e550fbddc5fce5f1807f046ad3d7ee1d9162b01e0338a3eaf00bedf0afe2f91
7
+ data.tar.gz: 010ce83f7446fa3d690e3e20ed85088f708e110d07fbfd56ebf254be3b0367ebb32ebb5bbd9e41062ba8271ba3980dc2d81ef09cdc83a9b97901008e727c6ac5
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ### 1.2.0 - 2014-08-31
4
+
5
+ - Added `strip_url_protocol` which converts `http://bog.com` to `blog.com`.
6
+
3
7
  ### 1.1.2 - 2014-07-26
4
8
 
5
9
  - Replaced octopress-hooks with something simpler
data/README.md CHANGED
@@ -12,6 +12,7 @@ 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
16
 
16
17
  [![Build Status](https://travis-ci.org/octopress/filters.svg)](https://travis-ci.org/octopress/filters)
17
18
  [![Gem Version](http://img.shields.io/gem/v/octopress-filters.svg)](https://rubygems.org/gems/octopress-filters)
@@ -92,6 +93,11 @@ This filter expands the url to be a full url, then removes "index.html" if it is
92
93
  <title>{{ page_title | join_lines: " - " }}</title>
93
94
 
94
95
 
96
+ ### Strip url protocol
97
+
98
+ {{ site.url }} # https://some-site.com/
99
+ {{ site.url | strip_url_protocol }} # some-site.com/
100
+
95
101
  ## Contributing
96
102
 
97
103
  1. Fork it ( https://github.com/octopress/filters/fork )
@@ -17,6 +17,14 @@ module Octopress
17
17
  root_url.nil? ? '/' : File.join('/', root_url)
18
18
  end
19
19
 
20
+ def site_url
21
+ @url ||= begin
22
+ Octopress.site.config['url']
23
+ rescue
24
+ raise IOError.new "Please add your site's published url to your _config.yml, eg url: http://example.com/"
25
+ end
26
+ end
27
+
20
28
  # Escapes HTML content for XML
21
29
  def cdata_escape(input)
22
30
  input.gsub(/<!\[CDATA\[/, '&lt;![CDATA[').gsub(/\]\]>/, ']]&gt;')
@@ -68,12 +76,7 @@ module Octopress
68
76
  # e.g. /images/awesome.gif => http://example.com/images/awesome.gif
69
77
  #
70
78
  def full_urls(input)
71
- url = Octopress.site.config['url']
72
- if url.nil?
73
- raise IOError.new "Could not expand urls: Please add your published url to your _config.yml, eg url: http://example.com/"
74
- else
75
- expand_urls(input, url)
76
- end
79
+ expand_urls(input, site_url)
77
80
  end
78
81
 
79
82
  # Prepend a url with the full site url
@@ -84,12 +87,7 @@ module Octopress
84
87
  # e.g. /images/awesome.gif => http://example.com/images/awesome.gif
85
88
  #
86
89
  def full_url(input)
87
- url = Octopress.site.config['url']
88
- if url.nil?
89
- raise IOError.new "Could not expand url in #{input}: Please add your site's published url to your _config.yml, eg url: http://example.com/"
90
- else
91
- expand_url(input, url)
92
- end
90
+ expand_url(input, site_url)
93
91
  end
94
92
 
95
93
  # Prepends input with a url fragment
@@ -122,6 +120,10 @@ module Octopress
122
120
  end
123
121
  end
124
122
 
123
+ def strip_url_protocol(input)
124
+ input.sub(/\w+?:\/\//,'')
125
+ end
126
+
125
127
  module_function *instance_methods
126
128
  public *private_instance_methods.reject!{ |m| [:root].include?(m) }
127
129
 
@@ -1,7 +1,7 @@
1
1
  module Octopress
2
2
  module Tags
3
3
  module Filters
4
- VERSION = "1.1.2"
4
+ VERSION = "1.2.0"
5
5
  end
6
6
  end
7
7
  end
@@ -0,0 +1,2 @@
1
+ yourdomain.com
2
+ foo.bar.com/goggles
@@ -0,0 +1,6 @@
1
+ ---
2
+ ---
3
+ {{ site.url | strip_url_protocol }}
4
+ {% filter strip_url_protocol %}
5
+ https://foo.bar.com/goggles
6
+ {% endfilter %}
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.1.2
4
+ version: 1.2.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: 2014-07-26 00:00:00.000000000 Z
11
+ date: 2014-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -149,6 +149,7 @@ files:
149
149
  - test/_expected/full_urls.html
150
150
  - test/_expected/join_lines.html
151
151
  - test/_expected/smartquotes.html
152
+ - test/_expected/strip_url_protocol.html
152
153
  - test/_expected/titlecase.html
153
154
  - test/_expected/unorphan.html
154
155
  - test/canonical.html
@@ -157,6 +158,7 @@ files:
157
158
  - test/full_urls.html
158
159
  - test/join_lines.html
159
160
  - test/smartquotes.html
161
+ - test/strip_url_protocol.html
160
162
  - test/titlecase.html
161
163
  - test/unorphan.html
162
164
  homepage: https://github.com/octopress/filters
@@ -193,6 +195,7 @@ test_files:
193
195
  - test/_expected/full_urls.html
194
196
  - test/_expected/join_lines.html
195
197
  - test/_expected/smartquotes.html
198
+ - test/_expected/strip_url_protocol.html
196
199
  - test/_expected/titlecase.html
197
200
  - test/_expected/unorphan.html
198
201
  - test/canonical.html
@@ -201,5 +204,6 @@ test_files:
201
204
  - test/full_urls.html
202
205
  - test/join_lines.html
203
206
  - test/smartquotes.html
207
+ - test/strip_url_protocol.html
204
208
  - test/titlecase.html
205
209
  - test/unorphan.html