auto_html 1.4.1 → 1.4.2

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.
data/README.md CHANGED
@@ -88,4 +88,4 @@ Specify the gem in Gemfile of the project
88
88
  ## Credits
89
89
 
90
90
  Author: [Dejan Simic](http://github.com/dejan)<br/>
91
- Contributors: [Claudio Perez Gamayo](http://github.com/crossblaim), [Matt Polito](http://github.com/mattpolito), [Ryan Heneise](http://github.com/mysmallidea), [Caleb Wright](http://github.com/fabrikagency), [Derrick Camerino](https://github.com/robustdj), [Daniel Weinmann](https://github.com/danielweinmann), [Edgars Beigarts](ebeigarts)
91
+ Contributors: [Claudio Perez Gamayo](https://github.com/crossblaim), [Matt Polito](https://github.com/mattpolito), [Ryan Heneise](https://github.com/mysmallidea), [Caleb Wright](https://github.com/fabrikagency), [Derrick Camerino](https://github.com/robustdj), [Daniel Weinmann](https://github.com/danielweinmann), [Edgars Beigarts](https://github.com/ebeigarts), [Henning Thies](https://github.com/henningthies), [rbq](https://github.com/ebeigarts)
@@ -0,0 +1,9 @@
1
+ require 'redcarpet'
2
+
3
+ AutoHtml.add_filter(:redcarpet).with({}) do |text, options|
4
+ result = Redcarpet.new(text).to_html
5
+ if options and options[:target] and options[:target].to_sym == :_blank
6
+ result.gsub!(/<a/,'<a target="_blank"')
7
+ end
8
+ result
9
+ end
@@ -1,7 +1,7 @@
1
1
  AutoHtml.add_filter(:youtube).with(:width => 390, :height => 250, :frameborder => 0) do |text, options|
2
- regex = /http:\/\/(www.)?youtube\.com\/watch\?v=([A-Za-z0-9._%-]*)(\&\S+)?/
2
+ regex = /http:\/\/(www.)?youtube\.com\/watch\?v=([A-Za-z0-9._%-]*)(\&\S+)?|http:\/\/(www.)?youtu\.be\/([A-Za-z0-9._%-]*)?/
3
3
  text.gsub(regex) do
4
- youtube_id = $2
4
+ youtube_id = $2 || $5
5
5
  width = options[:width]
6
6
  height = options[:height]
7
7
  frameborder = options[:frameborder]
@@ -0,0 +1,25 @@
1
+ require File.expand_path('../../unit_test_helper', __FILE__)
2
+
3
+ class RedcarpetTest < Test::Unit::TestCase
4
+
5
+ def test_transform_strong
6
+ result = auto_html("This is **my** text.") { redcarpet }
7
+ assert_equal '<p>This is <strong>my</strong> text.</p>'+"\n", result
8
+ end
9
+
10
+ def test_transform_title
11
+ result = auto_html("## This is a title ##") { redcarpet }
12
+ assert_equal '<h2>This is a title</h2>'+"\n", result
13
+ end
14
+
15
+ def test_transform_link
16
+ result = auto_html('[This is a link](http://example.org/)') { redcarpet }
17
+ assert_equal '<p><a href="http://example.org/">This is a link</a></p>'+"\n", result
18
+ end
19
+
20
+ def test_transform_link_target_blank
21
+ result = auto_html('[This is a link](http://example.org/)') { redcarpet :target => :_blank }
22
+ assert_equal '<p><a target="_blank" href="http://example.org/">This is a link</a></p>'+"\n", result
23
+ end
24
+
25
+ end
@@ -31,5 +31,12 @@ class YouTubeTest < Test::Unit::TestCase
31
31
  assert_equal '<iframe class="youtube-player" type="text/html" width="300" height="255" src="http://www.youtube.com/embed/BwNrmYRiX_o" frameborder="1">
32
32
  </iframe>', result
33
33
  end
34
+
35
+
36
+ def test_transform_with_short_url
37
+ result = auto_html('http://www.youtu.be/BwNrmYRiX_o') { youtube }
38
+ assert_equal '<iframe class="youtube-player" type="text/html" width="390" height="250" src="http://www.youtube.com/embed/BwNrmYRiX_o" frameborder="0">
39
+ </iframe>', result
40
+ end
34
41
 
35
42
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auto_html
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
5
- prerelease: false
4
+ hash: 3
5
+ prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 4
9
- - 1
10
- version: 1.4.1
9
+ - 2
10
+ version: 1.4.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dejan Simic
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-07-09 00:00:00 +02:00
18
+ date: 2011-08-12 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -60,6 +60,20 @@ dependencies:
60
60
  version: "0"
61
61
  type: :runtime
62
62
  version_requirements: *id003
63
+ - !ruby/object:Gem::Dependency
64
+ name: redcarpet
65
+ prerelease: false
66
+ requirement: &id004 !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ hash: 3
72
+ segments:
73
+ - 0
74
+ version: "0"
75
+ type: :runtime
76
+ version_requirements: *id004
63
77
  description: Automatically transforms URIs (via domain) and includes the destination resource (Vimeo, YouTube movie, image, ...) in your document
64
78
  email: desimic@gmail.com
65
79
  executables: []
@@ -80,6 +94,7 @@ files:
80
94
  - lib/auto_html/filters/image.rb
81
95
  - lib/auto_html/filters/link.rb
82
96
  - lib/auto_html/filters/metacafe.rb
97
+ - lib/auto_html/filters/redcarpet.rb
83
98
  - lib/auto_html/filters/redcloth.rb
84
99
  - lib/auto_html/filters/sanitize.rb
85
100
  - lib/auto_html/filters/simple_format.rb
@@ -101,6 +116,7 @@ files:
101
116
  - test/unit/filters/image_test.rb
102
117
  - test/unit/filters/link_test.rb
103
118
  - test/unit/filters/metacafe_test.rb
119
+ - test/unit/filters/redcarpet_test.rb
104
120
  - test/unit/filters/redcloth_test.rb
105
121
  - test/unit/filters/sanitize_test.rb
106
122
  - test/unit/filters/simple_format_test.rb
@@ -139,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
155
  requirements: []
140
156
 
141
157
  rubyforge_project:
142
- rubygems_version: 1.3.7
158
+ rubygems_version: 1.4.2
143
159
  signing_key:
144
160
  specification_version: 3
145
161
  summary: Transform URIs to appropriate markup