Forum: Ruby Auto-recognize links?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
9d4eaaf6c763c9fc01a9356ef58dbe72?d=identicon&s=25 Josh Pigford (shpigford)
on 2008-10-08 23:55
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<...
E9419fd4df1cfd3b64d64d65c38bcfa2?d=identicon&s=25 Ted Han (knowtheory)
on 2008-10-09 00:21
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<...
4a551074ddba4460f95d011c47190d0e?d=identicon&s=25 Henrik --- (malesca)
on 2008-10-09 01:12
(Received via mailing list)
On Thu, Oct 9, 2008 at 12:20 AM, Ted Han <notheory@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("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/Help...
C5b0a0cf40eb23497068889c8fb20a18?d=identicon&s=25 lrlebron@gmail.com (Guest)
on 2008-10-10 23:03
(Received via mailing list)
On Oct 8, 6:09 pm, Henrik Nyh <hen...@nyh.se> wrote:
>
> >> It'd basically turn it into a clickable link:
> >> &lt;a
> >> href=&quot;http://example.com">http://example.com</a>
>
> > --
> > Posted viahttp://www.ruby-forum.com/.- Hide quoted text -
>
> - Show quoted text -

Have you looked at hpricot
This topic is locked and can not be replied to.