views:

85

answers:

1

Ciao a tutti, nella Rails app che sto realizzando, l'utente ha la possibilita' di inserire un post (campo memo) con all'interno una URL.

Ad esempio:

"bla bla bla bla www.blabla.com bla bla bla ..."

Nel mostrare tale post vorrei che www.blabla.com diventasse un link cliccabile (come avviene in twitter).

Ovviamente deve essere fatto un parsing della url, immagino usando le espressioni regolari.

Avete dei consigli in merito ? Esiste qualcosa di gia' fatto oppure inizio da subito a scrivere il codice :) ?

Grazie

Alessandro DS http://alex-on-rails.blogspot.com/

+2  A: 

Ecco una versione di PHP, non dovrebbe essere troppo difficile da tradurre in ruby:

In alternativa, vai direttamente a questo post:


PS. Sorry, my italian is as good as google translate;)

The MYYN
+1 for being braver than me by trusting Google translate like this. :)
Donnie
hey, here in SO may I speak my native language?
Hermet
Sì, `auto_link` ("Collegamento automatico") dal `Rails` è il corretto funzionamento. Vedi qui: http://railsapi.com/doc/rails-v2.3.8/classes/ActionView/Helpers/TextHelper.html#M002276
James A. Rosen
@Hermet, you should not. English is the prevalent language for all technical and scientific matters. Not speaking english excludes you from one of the biggest communities in the world, and also excludes them from your world, none of which I think is good.
back2dos
@The MYYN, thank you! I will use auto_link (id this case Google translation isn't so bad !)@back2dos, Yes, I agree with you (I have no problem to read english, but some to write), of course my next question or answer will be in English
@back2dos all right, I've been posting here in my poor English, I was just wondering if not doing it was seen bad. I know that in a technical field English is the prevalent language, nonetheless, remember Spanish is the second most natively spoken language, it would be great if SO had support for this language.
Hermet
@Hermet: Your english seems just fine. I personally dislike the idea of stackoverflow becoming multilingual. By your logic, SO should also support simplified chinese, that is written by far more people than spanish. I think it's great, that we now have a language as widely spread and as easy to learn (to a sufficient degree) as english, and I don't see why whe should now reverse this fortunate developement. Also, I see only advantages in learning foreign languages, so to me, the only people actually suffering from the whole world speaking english are the native speakers. :)
back2dos