In PHP I've got a few functions that will turn data into links based on
if it recognizes "http://", "www." etc etc.
How can I do this with Ruby?
For instance, in a forums setting if a user posted a link to something
like http://example.com
It'd basically turn it into a clickable link:
<a
href="http://example.com ">http://example.com </a>
···
--
Posted via http://www.ruby-forum.com/ .
Ted_Han
(Ted Han)
8 October 2008 22:20
2
I think everything you'd need to do to validate and produce links should
be in the core URI class: http://www.ruby-doc.org/core/classes/URI.html
Josh Pigford wrote:
···
In PHP I've got a few functions that will turn data into links based on
if it recognizes "http://", "www." etc etc.
How can I do this with Ruby?
For instance, in a forums setting if a user posted a link to something
like http://example.com
It'd basically turn it into a clickable link:
<a
href="http://example.com ">http://example.com </a>
--
Posted via http://www.ruby-forum.com/\ .
Henrik
(Henrik)
8 October 2008 23:09
3
I think everything you'd need to do to validate and produce links should
be in the core URI class: http://www.ruby-doc.org/core/classes/URI.html
Interesting, did not know that. Seems bad though:
URI.extract("Visit http://google.com/\."\ ) # => ["http://google.com/\."\ ]
You could borrow code from Rails' auto_link() which handles that kind
of stuff better:
http://api.rubyonrails.com/classes/ActionView/Helpers/TextHelper.html#M001737
···
On Thu, Oct 9, 2008 at 12:20 AM, Ted Han <notheory@gmail.com> wrote:
Josh Pigford wrote:
In PHP I've got a few functions that will turn data into links based on
if it recognizes "http://", "www." etc etc.
How can I do this with Ruby?
For instance, in a forums setting if a user posted a link to something
like http://example.com
It'd basically turn it into a clickable link:
<a
href="http://example.com ">http://example.com </a>
--
Posted via http://www.ruby-forum.com/\ .
lrlebron
(lrlebron@gmail.com)
10 October 2008 20:57
4
Have you looked at hpricot
···
On Oct 8, 6:09 pm, Henrik Nyh <hen...@nyh.se> wrote:
On Thu, Oct 9, 2008 at 12:20 AM, Ted Han <nothe...@gmail.com> wrote:
> I think everything you'd need to do to validate and produce links should
> be in the core URI class:http://www.ruby-doc.org/core/classes/URI.html
Interesting, did not know that. Seems bad though:
URI.extract("Visithttp://google.com/.") # => ["http://google.com/\."\ ]
You could borrow code from Rails' auto_link() which handles that kind
of stuff better:http://api.rubyonrails.com/classes/ActionView/Helpers/TextHelper.html\.\.\ .
> Josh Pigford wrote:
>> In PHP I've got a few functions that will turn data into links based on
>> if it recognizes "http://", "www." etc etc.
>> How can I do this with Ruby?
>> For instance, in a forums setting if a user posted a link to something
>> likehttp://example.com
>> It'd basically turn it into a clickable link:
>> <a
>> href="http://example.com ">http://example.com </a>
> --
> Posted viahttp://www.ruby-forum.com/.- Hide quoted text -
- Show quoted text -