I''m using simple_format to format and display posted content from users. This content sometimes has urls in it. The problem I''m having is that if the urls are long enough to wrap, they do, but the url gets split with a <br> tag. Then, if the user clicks on the link, only the first, non-wrapped part of the link gets posted to the browser... and that''s an invalid link. Is there a better way to handle this so that the link wraps, but keeps its integrity? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Have you tried to use auto_link with simple_format? This, I would think, would keep your link integrity, even if there was a line break. Let me know if that works. ~Dustin Tigner On Jul 25, 6:48 pm, lunaclaire <szager...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m using simple_format to format and display posted content from > users. This content sometimes has urls in it. > > The problem I''m having is that if the urls are long enough to wrap, > they do, but the url gets split with a <br> tag. Then, if the user > clicks on the link, only the first, non-wrapped part of the link gets > posted to the browser... and that''s an invalid link. > > Is there a better way to handle this so that the link wraps, but keeps > its integrity?--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Yeah, that''s exactly what I do, as follows: simple_format(sanitize(auto_link(content, :all, :target => ''_blank''))) And that''s what ends up with the break. On Jul 26, 9:16 am, Achithyn <dtig...-wxkBo02D2AnYtjvyW6yDsg@public.gmane.org> wrote:> Have you tried to use auto_link with simple_format? This, I would > think, would keep your link integrity, even if there was a line break. > Let me know if that works. > > ~Dustin Tigner > > On Jul 25, 6:48 pm, lunaclaire <szager...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I''m using simple_format to format and display posted content from > > users. This content sometimes has urls in it. > > > The problem I''m having is that if the urls are long enough to wrap, > > they do, but the url gets split with a <br> tag. Then, if the user > > clicks on the link, only the first, non-wrapped part of the link gets > > posted to the browser... and that''s an invalid link. > > > Is there a better way to handle this so that the link wraps, but keeps > > its integrity?--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
touching this again ''cause I never found a solution and it just came back and bit me this must be a common problem and perhaps I''ve missed something obvious...? any more thoughts/help out there? On Jul 26, 5:24 pm, lunaclaire <szager...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Yeah, that''s exactly what I do, as follows: > > simple_format(sanitize(auto_link(content, :all, :target => ''_blank''))) > > And that''s what ends up with the break. > > On Jul 26, 9:16 am, Achithyn <dtig...-wxkBo02D2AnYtjvyW6yDsg@public.gmane.org> wrote: > > > Have you tried to use auto_link with simple_format? This, I would > > think, would keep your link integrity, even if there was a line break. > > Let me know if that works. > > > ~Dustin Tigner > > > On Jul 25, 6:48 pm, lunaclaire <szager...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I''m using simple_format to format and display posted content from > > > users. This content sometimes has urls in it. > > > > The problem I''m having is that if the urls are long enough to wrap, > > > they do, but the url gets split with a <br> tag. Then, if the user > > > clicks on the link, only the first, non-wrapped part of the link gets > > > posted to the browser... and that''s an invalid link. > > > > Is there a better way to handle this so that the link wraps, but keeps > > > its integrity?--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
OK... sorry for the thrash, but I''ve found a solution of sorts and thought I''d share... --- Turns out my problem was not with simple_format. Instead it was with the TextHelper word_wrap call I''d been using. When it wraps long bits of unbroken text (like a long url), it inserts <br/> tags. That was screwing things up. So, I went in search of a solution that might wrap text using CSS. Problem is that the solutions dont work cross-browser. But I found something that works that doesnt use CSS (or Ruby code), it''s JS. Check it out: http://www.hedgerwow.com/360/dhtml/css-word-break.html I put the breakWord function in my application.js file, added another function that looks for my DOM elements by class name (I name the relevant ones ''content''), and then call that function from the onLoad event in my application layout. Works well, though others may have a more elegant way to do this. Hope that helps. On Sep 8, 10:07 am, lunaclaire <szager...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> touching this again ''cause I never found a solution and it just came > back and bit me > > this must be a common problem and perhaps I''ve missed something > obvious...? > > any more thoughts/help out there? > > On Jul 26, 5:24 pm, lunaclaire <szager...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Yeah, that''s exactly what I do, as follows: > > >simple_format(sanitize(auto_link(content, :all, :target => ''_blank''))) > > > And that''s what ends up with the break. > > > On Jul 26, 9:16 am, Achithyn <dtig...-wxkBo02D2AnYtjvyW6yDsg@public.gmane.org> wrote: > > > > Have you tried to use auto_link withsimple_format? This, I would > > > think, would keep your link integrity, even if there was a line break. > > > Let me know if that works. > > > > ~Dustin Tigner > > > > On Jul 25, 6:48 pm, lunaclaire <szager...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > I''m usingsimple_formatto format and display posted content from > > > > users. This content sometimes has urls in it. > > > > > The problem I''m having is that if the urls are long enough to wrap, > > > > they do, but the url gets split with a <br> tag. Then, if the user > > > > clicks on the link, only the first, non-wrapped part of the link gets > > > > posted to the browser... and that''s an invalid link. > > > > > Is there a better way to handle this so that the link wraps, but keeps > > > > its integrity?--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Reasonably Related Threads
- rails 2.2.3 dirty.rb field_changed? method throwing arg error on creating an obj
- bad move? - complex form with *many* observe_field's
- How do I format text before saving it?
- New line char in a text area field on DISPLAY
- simple_format and in_place_editor_field