Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 76 lines (52 sloc) 3.17 kb
6f12d21 Aaron Patterson initial commit
authored
1 = rails_autolink
2
3 * http://github.com/tenderlove/rails_autolink
4
5 == DESCRIPTION:
6
7 This is an extraction of the `auto_link` method from rails. The `auto_link`
8 method was removed from Rails in version Rails 3.1. This gem is meant to
9 bridge the gap for people migrating.
10
65944f1 Juanjo Bazán Readme
xuanxu authored
11 == FEATURES:
6f12d21 Aaron Patterson initial commit
authored
12
051b26c Juanjo Bazán Version up. Rails 4 ready.
xuanxu authored
13 By default auto_link returns sanitized html_safe strings.
a4d3188 Harry Llewelyn Fixed typo + added word.
Advocation authored
14 This behaviour can be overridden by setting the <tt>:sanitize</tt> option to false
65944f1 Juanjo Bazán Readme
xuanxu authored
15 (thus making it insecure if you don't have the content under control).
6f12d21 Aaron Patterson initial commit
authored
16
17 == SYNOPSIS:
18
19 require 'rails_autolink'
20
21 auto_link("Go to http://www.rubyonrails.org and say hello to david@loudthinking.com")
22 # => "Go to <a href=\"http://www.rubyonrails.org\">http://www.rubyonrails.org</a> and
23 # say hello to <a href=\"mailto:david@loudthinking.com\">david@loudthinking.com</a>"
051b26c Juanjo Bazán Version up. Rails 4 ready.
xuanxu authored
24
6f12d21 Aaron Patterson initial commit
authored
25 auto_link("Visit http://www.loudthinking.com/ or e-mail david@loudthinking.com", :link => :urls)
26 # => "Visit <a href=\"http://www.loudthinking.com/\">http://www.loudthinking.com/</a>
27 # or e-mail david@loudthinking.com"
051b26c Juanjo Bazán Version up. Rails 4 ready.
xuanxu authored
28
6f12d21 Aaron Patterson initial commit
authored
29 auto_link("Visit http://www.loudthinking.com/ or e-mail david@loudthinking.com", :link => :email_addresses)
30 # => "Visit http://www.loudthinking.com/ or e-mail <a href=\"mailto:david@loudthinking.com\">david@loudthinking.com</a>"
051b26c Juanjo Bazán Version up. Rails 4 ready.
xuanxu authored
31
65944f1 Juanjo Bazán Readme
xuanxu authored
32 auto_link("Go to http://www.rubyonrails.org <script>Malicious code!</script>")
33 # => "Go to <a href=\"http://www.rubyonrails.org\">http://www.rubyonrails.org</a> "
051b26c Juanjo Bazán Version up. Rails 4 ready.
xuanxu authored
34
65944f1 Juanjo Bazán Readme
xuanxu authored
35 auto_link("Go to http://www.rubyonrails.org <script>alert('Script!')</script>", :sanitize => false)
36 # => "Go to <a href=\"http://www.rubyonrails.org\">http://www.rubyonrails.org</a> <script>alert('Script!')</script>"
051b26c Juanjo Bazán Version up. Rails 4 ready.
xuanxu authored
37
6f12d21 Aaron Patterson initial commit
authored
38 post_body = "Welcome to my new blog at http://www.myblog.com/. Please e-mail me at me@email.com."
39 auto_link(post_body, :html => { :target => '_blank' }) do |text|
40 truncate(text, :length => 15)
41 end
42 # => "Welcome to my new blog at <a href=\"http://www.myblog.com/\" target=\"_blank\">http://www.m...</a>.
43
44 == REQUIREMENTS:
45
051b26c Juanjo Bazán Version up. Rails 4 ready.
xuanxu authored
46 * rails > 3.1
6f12d21 Aaron Patterson initial commit
authored
47
48 == INSTALL:
49
65944f1 Juanjo Bazán Readme
xuanxu authored
50 * gem install rails_autolink
6f12d21 Aaron Patterson initial commit
authored
51
52 == LICENSE:
53
54 (The MIT License)
55
56 Copyright (c) 2011 DHH
57
58 Permission is hereby granted, free of charge, to any person obtaining
59 a copy of this software and associated documentation files (the
60 'Software'), to deal in the Software without restriction, including
61 without limitation the rights to use, copy, modify, merge, publish,
62 distribute, sublicense, and/or sell copies of the Software, and to
63 permit persons to whom the Software is furnished to do so, subject to
64 the following conditions:
65
66 The above copyright notice and this permission notice shall be
67 included in all copies or substantial portions of the Software.
68
69 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
70 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
71 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
72 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
73 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
74 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
75 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Something went wrong with that request. Please try again.