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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +6 -0
- data/lib/octopress-filters.rb +14 -12
- data/lib/octopress-filters/version.rb +1 -1
- data/test/_expected/strip_url_protocol.html +2 -0
- data/test/strip_url_protocol.html +6 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47d40082d204354809525e9551ddbd6eab622278
|
4
|
+
data.tar.gz: f67ec62b70dfad459b14250060562daedfaf762c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 423d42bc07b4525ffb331d9665b721eae432b8fe88d090c5c19b9d12406c17705e550fbddc5fce5f1807f046ad3d7ee1d9162b01e0338a3eaf00bedf0afe2f91
|
7
|
+
data.tar.gz: 010ce83f7446fa3d690e3e20ed85088f708e110d07fbfd56ebf254be3b0367ebb32ebb5bbd9e41062ba8271ba3980dc2d81ef09cdc83a9b97901008e727c6ac5
|
data/CHANGELOG.md
CHANGED
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
|
[](https://travis-ci.org/octopress/filters)
|
17
18
|
[](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 )
|
data/lib/octopress-filters.rb
CHANGED
@@ -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\[/, '<![CDATA[').gsub(/\]\]>/, ']]>')
|
@@ -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
|
-
|
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
|
-
|
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
|
|
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.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-
|
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
|