html-pipeline 1.7.0 → 1.8.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: 6e3b868abc13fac903776f091b0e0e5111c3f2fb
4
- data.tar.gz: 52048ee1cf9300f16e37c1a4b11c009a8dabf441
3
+ metadata.gz: c80ec3a729612072c5bf7e4042b86062f189a490
4
+ data.tar.gz: 1af2da4c0dfb19235124be8ca3caafc940b4ab5a
5
5
  SHA512:
6
- metadata.gz: b51c354c77f8e6f25f7e25a512e1b4d93274b447597929d9562dedc3537b4b94c02f5b5adbfa48e75a592b200fd5bb542c412100f61df569b8faf6054dd9ce39
7
- data.tar.gz: 308a373470a7f7f935df533e99a045d1b47c02805d70a2f14983a7844cb8a71760c33420287d3b012e2aeb891563f7b4e41606c94d5edb8a81b73c20daa7882a
6
+ metadata.gz: 5ebe5a48f81aa9f84c65ff11404f3239a65d385faac96518cc9b0a11989012e93c988bcf2a7a0577bca82b4dc7a88b17c5bdcfdecb9c67bd07c23239419deafd
7
+ data.tar.gz: e901ad26193941fafc158e6041a40d6049b4edc850167740b809581fcc62270d3a82014b8a40be1e30b323fa6ea0b3e573307c009fe7f14d2bf3374dcb930e10
@@ -1,5 +1,10 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.8.0
4
+
5
+ * Add custom path support for EmojiFilter #122 bradly
6
+ * Reorganize README and add table of contents #118 simeonwillbanks
7
+
3
8
  ## 1.7.0
4
9
 
5
10
  * SanitizationFilter whitelists <s> and <strike> elements #120 charliesome
data/README.md CHANGED
@@ -5,6 +5,19 @@ framework for defining DOM based content filters and applying them to user
5
5
  provided content. Read an introduction about this project in
6
6
  [this blog post](https://github.com/blog/1311-html-pipeline-chainable-content-filters).
7
7
 
8
+ - [Installation](#installation)
9
+ - [Usage](#usage)
10
+ - [Examples](#examples)
11
+ - [Filters](#filters)
12
+ - [Dependencies](#dependencies)
13
+ - [Documentation](#documentation)
14
+ - [Extending](#extending)
15
+ - [3rd Party Extensions](#3rd-party-extensions)
16
+ - [Instrumenting](#instrumenting)
17
+ - [Contributing](#contributing)
18
+ - [Contributors](#contributors)
19
+ - [Releasing A New Version](#releasing-a-new-version)
20
+
8
21
  ## Installation
9
22
 
10
23
  Add this line to your application's Gemfile:
@@ -83,56 +96,7 @@ filter = HTML::Pipeline::MarkdownFilter.new("Hi **world**!", :gfm => false)
83
96
  filter.call
84
97
  ```
85
98
 
86
- ## Filters
87
-
88
- * `MentionFilter` - replace `@user` mentions with links
89
- * `AbsoluteSourceFilter` - replace relative image urls with fully qualified versions
90
- * `AutolinkFilter` - auto_linking urls in HTML
91
- * `CamoFilter` - replace http image urls with [camo-fied](https://github.com/atmos/camo) https versions
92
- * `EmailReplyFilter` - util filter for working with emails
93
- * `EmojiFilter` - everyone loves [emoji](http://www.emoji-cheat-sheet.com/)!
94
- * `HttpsFilter` - HTML Filter for replacing http github urls with https versions.
95
- * `ImageMaxWidthFilter` - link to full size image for large images
96
- * `MarkdownFilter` - convert markdown to html
97
- * `PlainTextInputFilter` - html escape text and wrap the result in a div
98
- * `SanitizationFilter` - whitelist sanitize user markup
99
- * `SyntaxHighlightFilter` - [code syntax highlighter](#syntax-highlighting)
100
- * `TextileFilter` - convert textile to html
101
- * `TableOfContentsFilter` - anchor headings with name attributes and generate Table of Contents html unordered list linking headings
102
-
103
- ## Dependencies
104
-
105
- Filter gem dependencies are not bundled; you must bundle the filter's gem
106
- dependencies. The below list details filters with dependencies. For example,
107
- `SyntaxHighlightFilter` uses [github-linguist](https://github.com/github/linguist)
108
- to detect and highlight languages. For example, to use the `SyntaxHighlightFilter`,
109
- add the following to your Gemfile:
110
-
111
- ```ruby
112
- gem 'github-linguist'
113
- ```
114
-
115
- * `AutolinkFilter` - `rinku`
116
- * `EmailReplyFilter` - `escape_utils`, `email_reply_parser`
117
- * `EmojiFilter` - `gemoji`
118
- * `MarkdownFilter` - `github-markdown`
119
- * `PlainTextInputFilter` - `escape_utils`
120
- * `SanitizationFilter` - `sanitize`
121
- * `SyntaxHighlightFilter` - `github-linguist`
122
- * `TextileFilter` - `RedCloth`
123
-
124
- _Note:_ See [Gemfile](/Gemfile) `:test` block for version requirements.
125
-
126
- ## 3rd Party Extensions
127
-
128
- If you have an idea for a filter, propose it as
129
- [an issue](https://github.com/jch/html-pipeline/issues) first. This allows us discuss
130
- whether the filter is a common enough use case to belong in this gem, or should be
131
- built as an external gem.
132
-
133
- * [html-pipeline-asciidoc_filter](https://github.com/asciidoctor/html-pipeline-asciidoc_filter) - asciidoc support
134
-
135
- ## Examples
99
+ ### Examples
136
100
 
137
101
  We define different pipelines for different parts of our app. Here are a few
138
102
  paraphrased snippets to get you started:
@@ -187,6 +151,50 @@ EmojiPipeline = Pipeline.new [
187
151
  ], context
188
152
  ```
189
153
 
154
+ ## Filters
155
+
156
+ * `MentionFilter` - replace `@user` mentions with links
157
+ * `AbsoluteSourceFilter` - replace relative image urls with fully qualified versions
158
+ * `AutolinkFilter` - auto_linking urls in HTML
159
+ * `CamoFilter` - replace http image urls with [camo-fied](https://github.com/atmos/camo) https versions
160
+ * `EmailReplyFilter` - util filter for working with emails
161
+ * `EmojiFilter` - everyone loves [emoji](http://www.emoji-cheat-sheet.com/)!
162
+ * `HttpsFilter` - HTML Filter for replacing http github urls with https versions.
163
+ * `ImageMaxWidthFilter` - link to full size image for large images
164
+ * `MarkdownFilter` - convert markdown to html
165
+ * `PlainTextInputFilter` - html escape text and wrap the result in a div
166
+ * `SanitizationFilter` - whitelist sanitize user markup
167
+ * `SyntaxHighlightFilter` - [code syntax highlighter](#syntax-highlighting)
168
+ * `TextileFilter` - convert textile to html
169
+ * `TableOfContentsFilter` - anchor headings with name attributes and generate Table of Contents html unordered list linking headings
170
+
171
+ ## Dependencies
172
+
173
+ Filter gem dependencies are not bundled; you must bundle the filter's gem
174
+ dependencies. The below list details filters with dependencies. For example,
175
+ `SyntaxHighlightFilter` uses [github-linguist](https://github.com/github/linguist)
176
+ to detect and highlight languages. For example, to use the `SyntaxHighlightFilter`,
177
+ add the following to your Gemfile:
178
+
179
+ ```ruby
180
+ gem 'github-linguist'
181
+ ```
182
+
183
+ * `AutolinkFilter` - `rinku`
184
+ * `EmailReplyFilter` - `escape_utils`, `email_reply_parser`
185
+ * `EmojiFilter` - `gemoji`
186
+ * `MarkdownFilter` - `github-markdown`
187
+ * `PlainTextInputFilter` - `escape_utils`
188
+ * `SanitizationFilter` - `sanitize`
189
+ * `SyntaxHighlightFilter` - `github-linguist`
190
+ * `TextileFilter` - `RedCloth`
191
+
192
+ _Note:_ See [Gemfile](/Gemfile) `:test` block for version requirements.
193
+
194
+ ## Documentation
195
+
196
+ Full reference documentation can be [found here](http://rubydoc.info/gems/html-pipeline/frames).
197
+
190
198
  ## Extending
191
199
  To write a custom filter, you need a class with a `call` method that inherits
192
200
  from `HTML::Pipeline::Filter`.
@@ -218,6 +226,15 @@ Now this filter can be used in a pipeline:
218
226
  Pipeline.new [ RootRelativeFilter ], { :base_url => 'http://somehost.com' }
219
227
  ```
220
228
 
229
+ ### 3rd Party Extensions
230
+
231
+ If you have an idea for a filter, propose it as
232
+ [an issue](https://github.com/jch/html-pipeline/issues) first. This allows us discuss
233
+ whether the filter is a common enough use case to belong in this gem, or should be
234
+ built as an external gem.
235
+
236
+ * [html-pipeline-asciidoc_filter](https://github.com/asciidoctor/html-pipeline-asciidoc_filter) - asciidoc support
237
+
221
238
  ## Instrumenting
222
239
 
223
240
  Filters and Pipelines can be set up to be instrumented when called. The pipeline
@@ -268,37 +285,28 @@ service.subscribe "call_pipeline.html_pipeline" do |event, start, ending, transa
268
285
  end
269
286
  ```
270
287
 
271
- ## Documentation
272
-
273
- Full reference documentation can be [found here](http://rubydoc.info/gems/html-pipeline/frames).
274
-
275
- ## Development
276
-
277
- To see what has changed in recent versions, see the [CHANGELOG](https://github.com/jch/html-pipeline/blob/master/CHANGELOG.md).
278
-
279
- ```sh
280
- bundle
281
- rake test
282
- ```
283
-
284
- ## Releasing a new version
285
-
286
- This section is for gem maintainers to cut a new version of the gem.
287
-
288
- * update lib/html/pipeline/version.rb to next version number X.X.X following [semver](http://semver.org).
289
- * update CHANGELOG.md. Get latest changes with `git log --oneline vLAST_RELEASE..HEAD | grep Merge`
290
- * on the master branch, run `script/release`
291
-
292
288
  ## Contributing
293
289
 
290
+ Please review the [Contributing Guide](https://github.com/jch/html-pipeline/blob/master/CONTRIBUTING.md).
291
+
294
292
  1. [Fork it](https://help.github.com/articles/fork-a-repo)
295
293
  2. Create your feature branch (`git checkout -b my-new-feature`)
296
294
  3. Commit your changes (`git commit -am 'Added some feature'`)
297
295
  4. Push to the branch (`git push origin my-new-feature`)
298
296
  5. Create new [Pull Request](https://help.github.com/articles/using-pull-requests)
299
297
 
300
- ## Contributors
298
+ To see what has changed in recent versions, see the [CHANGELOG](https://github.com/jch/html-pipeline/blob/master/CHANGELOG.md).
299
+
300
+ ### Contributors
301
301
 
302
302
  Thanks to all of [these contributors](https://github.com/jch/html-pipeline/graphs/contributors).
303
303
 
304
304
  Project is a member of the [OSS Manifesto](http://ossmanifesto.org/).
305
+
306
+ ### Releasing A New Version
307
+
308
+ This section is for gem maintainers to cut a new version of the gem.
309
+
310
+ * update lib/html/pipeline/version.rb to next version number X.X.X following [semver](http://semver.org).
311
+ * update CHANGELOG.md. Get latest changes with `git log --oneline vLAST_RELEASE..HEAD | grep Merge`
312
+ * on the master branch, run `script/release`
@@ -12,6 +12,7 @@ module HTML
12
12
  #
13
13
  # Context:
14
14
  # :asset_root (required) - base url to link to emoji sprite
15
+ # :asset_path (optional) - url path to link to emoji sprite. :file_name can be used as a placeholder for the sprite file name. If no asset_path is set "emoji/:file_name" is used.
15
16
  class EmojiFilter < Filter
16
17
  # Build a regexp that matches all valid :emoji: names.
17
18
  EmojiPattern = /:(#{Emoji.names.map { |name| Regexp.escape(name) }.join('|')}):/
@@ -56,10 +57,22 @@ module HTML
56
57
  context[:asset_root]
57
58
  end
58
59
 
60
+ # The url path to link emoji sprites
61
+ #
62
+ # :file_name can be used in the asset_path as a placeholder for the sprite file name. If no asset_path is set in the context "emoji/:file_name" is used.
63
+ # Returns the context's asset_path or the default path if no context asset_path is given.
64
+ def asset_path(name)
65
+ if context[:asset_path]
66
+ context[:asset_path].gsub(":file_name", "#{::CGI.escape(name)}.png")
67
+ else
68
+ File.join("emoji", "#{::CGI.escape(name)}.png")
69
+ end
70
+ end
71
+
59
72
  private
60
73
 
61
74
  def emoji_url(name)
62
- File.join(asset_root, "emoji", "#{::CGI.escape(name)}.png")
75
+ File.join(asset_root, asset_path(name))
63
76
  end
64
77
  end
65
78
  end
@@ -1,5 +1,5 @@
1
1
  module HTML
2
2
  class Pipeline
3
- VERSION = "1.7.0"
3
+ VERSION = "1.8.0"
4
4
  end
5
5
  end
@@ -21,4 +21,10 @@ class HTML::Pipeline::EmojiFilterTest < Test::Unit::TestCase
21
21
  }
22
22
  assert_match /:asset_root/, exception.message
23
23
  end
24
+
25
+ def test_custom_asset_path
26
+ filter = EmojiFilter.new("<p>:+1:</p>", {:asset_path => ':file_name', :asset_root => 'https://foo.com'})
27
+ doc = filter.call
28
+ assert_match "https://foo.com/%2B1.png", doc.search('img').attr('src').value
29
+ end
24
30
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html-pipeline
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Tomayko
@@ -9,34 +9,34 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-11 00:00:00.000000000 Z
12
+ date: 2014-04-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ~>
18
+ - - "~>"
19
19
  - !ruby/object:Gem::Version
20
20
  version: '1.4'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ~>
25
+ - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: '1.4'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: activesupport
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - '>='
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
34
  version: '2'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - '>='
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '2'
42
42
  description: GitHub HTML processing filters and utilities
@@ -47,8 +47,8 @@ executables: []
47
47
  extensions: []
48
48
  extra_rdoc_files: []
49
49
  files:
50
- - .gitignore
51
- - .travis.yml
50
+ - ".gitignore"
51
+ - ".travis.yml"
52
52
  - CHANGELOG.md
53
53
  - CONTRIBUTING.md
54
54
  - Gemfile
@@ -108,17 +108,17 @@ require_paths:
108
108
  - lib
109
109
  required_ruby_version: !ruby/object:Gem::Requirement
110
110
  requirements:
111
- - - '>='
111
+ - - ">="
112
112
  - !ruby/object:Gem::Version
113
113
  version: '0'
114
114
  required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  requirements:
116
- - - '>='
116
+ - - ">="
117
117
  - !ruby/object:Gem::Version
118
118
  version: '0'
119
119
  requirements: []
120
120
  rubyforge_project:
121
- rubygems_version: 2.0.14
121
+ rubygems_version: 2.2.2
122
122
  signing_key:
123
123
  specification_version: 4
124
124
  summary: Helpers for processing content through a chain of filters