auto_html 1.3.4 → 1.3.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -71,8 +71,6 @@ As from version 1.2.0 auto_html uses Rails' engine for discovering links. There
71
71
  for Rails <= 2.3.1 use auto_html 1.1.2<br/>
72
72
  for Rails >= 2.3.2 use the latest auto_html
73
73
 
74
- As of version 1.3.0, auto_html has been tested to work with Rails 3 and Ruby 1.9.
75
-
76
74
  ### As a gem
77
75
 
78
76
  To enable the library in your Rails 2.1-2.3 project, use the gem configuration method in "config/environment.rb"
@@ -93,4 +91,4 @@ In Rails 3.0 specify the gem in your Gemfile
93
91
  ## Credits
94
92
 
95
93
  Author: [Dejan Simic](http://github.com/dejan)<br/>
96
- 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)
94
+ 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)
@@ -1,5 +1,5 @@
1
1
  AutoHtml.add_filter(:image) do |text|
2
- text.gsub(/http:\/\/.+\.(jpg|jpeg|bmp|gif|png)(\?\S+)?/i) do |match|
2
+ text.gsub(/https?:\/\/.+\.(jpg|jpeg|bmp|gif|png)(\?\S+)?/i) do |match|
3
3
  %|<img src="#{match}" alt=""/>|
4
4
  end
5
5
  end
@@ -0,0 +1,9 @@
1
+ require 'redcloth'
2
+
3
+ AutoHtml.add_filter(:redcloth).with({}) do |text, options|
4
+ result = RedCloth.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
data/lib/auto_html.rb CHANGED
@@ -1,8 +1,7 @@
1
1
  %w(base filter builder auto_html_for).each do |f|
2
- require File.dirname(__FILE__) + "/auto_html/#{f}"
2
+ require File.expand_path("../auto_html/#{f}", __FILE__)
3
3
  end
4
4
 
5
- # Register built-in filters
6
5
  Dir["#{File.dirname(__FILE__) + '/auto_html/filters'}/**/*"].each do |filter|
7
6
  require "#{filter}"
8
7
  end
@@ -1,5 +1,5 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
2
- require File.dirname(__FILE__) + '/../fixture_setup'
1
+ require File.expand_path('../../test_helper', __FILE__)
2
+ require File.expand_path('../../fixture_setup', __FILE__)
3
3
 
4
4
  # store default so we can revert so that other tests use default option
5
5
  default_suffix = AutoHtmlFor.auto_html_for_options[:htmlized_attribute_suffix]
@@ -11,7 +11,7 @@ class Article < ActiveRecord::Base
11
11
  end
12
12
  end
13
13
 
14
- class AutoHtmlForTest < Test::Unit::TestCase
14
+ class AutoHtmlForOptionsTest < Test::Unit::TestCase
15
15
  include FixtureSetup
16
16
 
17
17
  def test_transform_after_save
@@ -1,5 +1,5 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
2
- require File.dirname(__FILE__) + '/../fixture_setup'
1
+ require File.expand_path('../../test_helper', __FILE__)
2
+ require File.expand_path('../../fixture_setup', __FILE__)
3
3
 
4
4
  class Article < ActiveRecord::Base
5
5
  auto_html_for :body do
@@ -1,5 +1,5 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
2
- require File.dirname(__FILE__) + '/../fixture_setup'
1
+ require File.expand_path('../../test_helper', __FILE__)
2
+ require File.expand_path('../../fixture_setup', __FILE__)
3
3
 
4
4
  AutoHtml.add_filter(:foo) do |text|
5
5
  nil
@@ -17,7 +17,7 @@ class User < ActiveRecord::Base
17
17
  end
18
18
  end
19
19
 
20
- class AutoHtmlForTest < Test::Unit::TestCase
20
+ class FilterTest < Test::Unit::TestCase
21
21
  include FixtureSetup
22
22
 
23
23
  def test_transform_after_save
@@ -1,4 +1,5 @@
1
- require File.dirname(__FILE__) + '/unit_test_helper'
1
+ require File.expand_path('../unit_test_helper', __FILE__)
2
+
2
3
 
3
4
  class AutoHtmlTest < Test::Unit::TestCase
4
5
 
@@ -22,6 +23,11 @@ class AutoHtmlTest < Test::Unit::TestCase
22
23
  assert_equal '<p>Check the logo: <img src="http://rors.org/images/rails.png" alt=""/>. Visit: <a href="http://rubyonrails.org">http://rubyonrails.org</a></p>', result
23
24
  end
24
25
 
26
+ def test_should_apply_simple_format_image_and_redcloth_and_link_filter
27
+ result = auto_html('Check the logo: http://rors.org/images/rails.png. Visit: http://rubyonrails.org and "Read the Guides":http://guides.rubyonrails.org/') { simple_format; image; redcloth; link }
28
+ assert_equal '<p>Check the logo: <img src="http://rors.org/images/rails.png" alt=""/>. Visit: <a href="http://rubyonrails.org">http://rubyonrails.org</a> and <a href="http://guides.rubyonrails.org/">Read the Guides</a></p>', result
29
+ end
30
+
25
31
  def test_should_return_blank_if_input_is_blank
26
32
  result = auto_html("") { simple_format; image; link }
27
33
  assert_equal "", result
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../unit_test_helper'
1
+ require File.expand_path('../../unit_test_helper', __FILE__)
2
2
 
3
3
  class DailyMotionTest < Test::Unit::TestCase
4
4
 
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../unit_test_helper'
1
+ require File.expand_path('../../unit_test_helper', __FILE__)
2
2
 
3
3
  class GoogleVideoTest < Test::Unit::TestCase
4
4
 
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../unit_test_helper'
1
+ require File.expand_path('../../unit_test_helper', __FILE__)
2
2
 
3
3
  class HtmlEscapeTest < Test::Unit::TestCase
4
4
 
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../unit_test_helper'
1
+ require File.expand_path('../../unit_test_helper', __FILE__)
2
2
 
3
3
  class ImageTest < Test::Unit::TestCase
4
4
 
@@ -42,4 +42,9 @@ class ImageTest < Test::Unit::TestCase
42
42
  assert_equal '<img src="http://tbn3.google.com/images?q=tbn:vS-jtEi9Xc8K6M:http://upload.wikimedia.org/wikipedia/commons/b/ba/Potturinn.jpeg" alt=""/>', result
43
43
  end
44
44
 
45
+ def test_https
46
+ result = auto_html('https://img.skitch.com/20100910-1wrbg5749xe29ya5t3s85bnaiy.png') { image }
47
+ assert_equal '<img src="https://img.skitch.com/20100910-1wrbg5749xe29ya5t3s85bnaiy.png" alt=""/>', result
48
+ end
49
+
45
50
  end
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../unit_test_helper'
1
+ require File.expand_path('../../unit_test_helper', __FILE__)
2
2
 
3
3
  class LinkTest < Test::Unit::TestCase
4
4
 
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../unit_test_helper'
1
+ require File.expand_path('../../unit_test_helper', __FILE__)
2
2
 
3
3
  class MetaCafeTest < Test::Unit::TestCase
4
4
 
@@ -0,0 +1,25 @@
1
+ require File.expand_path('../../unit_test_helper', __FILE__)
2
+
3
+ class RedClothTest < Test::Unit::TestCase
4
+
5
+ def test_transform_strong
6
+ result = auto_html("This is *my* text.") { redcloth }
7
+ assert_equal '<p>This is <strong>my</strong> text.</p>', result
8
+ end
9
+
10
+ def test_transform_title
11
+ result = auto_html("h2. This is a title") { redcloth }
12
+ assert_equal '<h2>This is a title</h2>', result
13
+ end
14
+
15
+ def test_transform_link
16
+ result = auto_html('"This is a link (This is a title)":http://www.textism.com') { redcloth }
17
+ assert_equal '<p><a href="http://www.textism.com" title="This is a title">This is a link</a></p>', result
18
+ end
19
+
20
+ def test_transform_link_target_blank
21
+ result = auto_html('"This is a link (This is a title)":http://www.textism.com') { redcloth :target => :_blank }
22
+ assert_equal '<p><a target="_blank" href="http://www.textism.com" title="This is a title">This is a link</a></p>', result
23
+ end
24
+
25
+ end
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../unit_test_helper'
1
+ require File.expand_path('../../unit_test_helper', __FILE__)
2
2
 
3
3
  class SanitizeTest < Test::Unit::TestCase
4
4
 
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../unit_test_helper'
1
+ require File.expand_path('../../unit_test_helper', __FILE__)
2
2
 
3
3
  class SimpleFormatTest < Test::Unit::TestCase
4
4
 
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../unit_test_helper'
1
+ require File.expand_path('../../unit_test_helper', __FILE__)
2
2
 
3
3
  class VimeoTest < Test::Unit::TestCase
4
4
 
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../unit_test_helper'
1
+ require File.expand_path('../../unit_test_helper', __FILE__)
2
2
 
3
3
  class YouTubeJsApiTest < Test::Unit::TestCase
4
4
 
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../unit_test_helper'
1
+ require File.expand_path('../../unit_test_helper', __FILE__)
2
2
 
3
3
  class YouTubeTest < Test::Unit::TestCase
4
4
 
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: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 3
9
- - 4
10
- version: 1.3.4
9
+ - 5
10
+ version: 1.3.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dejan Simic
@@ -15,10 +15,23 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-01 00:00:00 +01:00
18
+ date: 2011-03-30 00:00:00 +02:00
19
19
  default_executable:
20
- dependencies: []
21
-
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: redcloth
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
22
35
  description: Automatically transforms URIs (via domain) and includes the destination resource (Vimeo, YouTube movie, image, ...) in your document
23
36
  email: desimic@gmail.com
24
37
  executables: []
@@ -39,6 +52,7 @@ files:
39
52
  - lib/auto_html/filters/image.rb
40
53
  - lib/auto_html/filters/link.rb
41
54
  - lib/auto_html/filters/metacafe.rb
55
+ - lib/auto_html/filters/redcloth.rb
42
56
  - lib/auto_html/filters/sanitize.rb
43
57
  - lib/auto_html/filters/simple_format.rb
44
58
  - lib/auto_html/filters/vimeo.rb
@@ -59,6 +73,7 @@ files:
59
73
  - test/unit/filters/image_test.rb
60
74
  - test/unit/filters/link_test.rb
61
75
  - test/unit/filters/metacafe_test.rb
76
+ - test/unit/filters/redcloth_test.rb
62
77
  - test/unit/filters/sanitize_test.rb
63
78
  - test/unit/filters/simple_format_test.rb
64
79
  - test/unit/filters/vimeo_test.rb