Hello, I''m having a great time building some rss/atom feeds and I''ve been quite successful until I hit the html formatting line of the Atom feed. Here''s an example: xml.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8" xml.feed "xml:lang" => "en-US", "xmlns" => ''http://www.w3.org/2005/Atom '' do xml.title("flavor: #{@flavor} *title1: " + @feed.title) xml.id( "tag:#{request.host},#{Time.now.utc.year}:#{@feed.title}/#{@feed.title.downcase}" ) xml.link(''url: '' + @ feed.guid) if @feed.guid xml.author { xml.name "Author Name" } @entities.each do |entity| xml.entry do xml.title(''title: '' + entity.title ) xml.link("rel" => "alternate", "href" => url_for(url_for :only_path => false, :controller => @this_controller, :action => @this_action, :id => entity.id)) xml.id(url_for(:only_path => false, :controller => @this_controller, :action => @this_action, :id => entity.id)) xml.updated("#{Time.now.utc.year}") xml.content "type" => "html" do xml.name entity.body #-->>tried this - doesn''t work xml.text! render(:partial => "shared/feed/entity", :entity => entity)-->>Tried this - doesn''t work end end end end If I could just get the xml.content "type" => "html" do end section to work I would be home free. Help! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> xml.content "type" => "html" do > end > > section to work I would be home free.1) You should be using xhtml for the content type. HTML assumes html escaped text. XHTML wants well formed HTML starting with a div tag: http://tools.ietf.org/html/rfc4287#section-4.1.3 2) You can use the #<< method to add raw xml to the xml object. Here''s how I do it in Mephisto: http://svn.techno-weenie.net/projects/mephisto/trunk/app/views/feed/_article.rxml (sanitize_feed_content is in here) http://svn.techno-weenie.net/projects/mephisto/trunk/app/helpers/application_helper.rb -- Rick Olson http://weblog.techno-weenie.net http://mephistoblog.com --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> 1) You should be using xhtml for the content type. HTML assumes html > escaped text. XHTML wants well formed HTML starting with a div tag: > > http://tools.ietf.org/html/rfc4287#section-4.1.3Okay, just to be clear... I assumed from your code you want strongly typed HTML, which is why I suggested the XHTML content type. In Mephisto, I don''t run the content through tidy or anything and can''t guarantee xhtml compliance, so I just use HTML for now. Use what you like. I just wanted to highlight the difference between the two. -- Rick Olson http://weblog.techno-weenie.net http://mephistoblog.com --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Rick - thanks for all your help. I''m not quite sure I fully understand this. The closest I''m coming to getting this displayed correctly is w/ this: xml.content "type" => "xhtml" do xml.content( "<div xmlns=\"http://www.w3.org/1999/xhtml\">#{entity.body}</div>") end This displays the info but does not render the html properly. what am I missing? Also, When I try this atom method in windows IE, it completely fails and spits the output w/out any rendering at all. lordy. Rick Olson wrote:>> 1) You should be using xhtml for the content type. HTML assumes html >> escaped text. XHTML wants well formed HTML starting with a div tag: >> >> http://tools.ietf.org/html/rfc4287#section-4.1.3 > > Okay, just to be clear... I assumed from your code you want strongly > typed HTML, which is why I suggested the XHTML content type. In > Mephisto, I don''t run the content through tidy or anything and can''t > guarantee xhtml compliance, so I just use HTML for now. Use what you > like. I just wanted to highlight the difference between the two. > > -- > Rick Olson > http://weblog.techno-weenie.net > http://mephistoblog.com-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Also when I try rendering this feed as rss in windows IE it doesn''t even respond. Double Lordy. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Also - does anyone know if there are good functional tests to test the validation of the rss and atom feed structures? Thanks, desperate -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 1/26/07, Clem Rock <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Also - does anyone know if there are good functional tests to test the > validation of the rss and atom feed structures?Look at how typo does it. I believe it calls the feed validator, or checks for and uses the local feed validator lib if it exists. -- Rick Olson http://weblog.techno-weenie.net http://mephistoblog.com --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 1/26/07, clem_c_rock <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Rick - thanks for all your help. > > I''m not quite sure I fully understand this. The closest I''m coming to > getting this displayed correctly is w/ this: > > xml.content "type" => "xhtml" do > xml.content( "<div > xmlns=\"http://www.w3.org/1999/xhtml\">#{entity.body}</div>") > end > > This displays the info but does not render the html properly. > > what am I missing? > > Also, When I try this atom method in windows IE, it completely fails and > spits the output w/out any rendering at all. > > lordy.Impossible to solve, this is, without an example of the result xml. Well, on first glance, you didnt use << at all. sooo..... -- Rick Olson http://weblog.techno-weenie.net http://mephistoblog.com --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Rick - I did try this: xml.content "type" => "xhtml" do xml << %{"<div>" + entity.body + "</div>" } end and it does render the html code properly but, for only one entry. In other words, if I have 2 records in a database, only the first one is getting displayed. Weird. I''m close but missing something basic. Thanks so much for your help. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I also tried to render the xml.content section w/ a partial like this: xml.content "type" => "html" do xml.text! render(partial => "shared/feed/entity", :entity => entity, :xm => xml) end and the partial code would contain: xm.entry ''xml:base'' => home_url do xm.title(''title: '' + entity.title ) xm.link("rel" => "alternate", "href" => url_for(url_for :only_path => false, :controller => @this_controller, :action => @this_action, :id => entity.id)) xm.id(url_for(:only_path => false, :controller => @this_controller, :action => @this_action, :id => entity.id)) xm.updated("#{Time.now.utc.year}") xm.author { xm.name "Author Name" } xm << %{<content type="xhtml">****#{entity.body}</content>} end This still only prints out the first line. Clem Rock wrote:> Rick - I did try this: > > xml.content "type" => "xhtml" do > xml << %{"<div>" + entity.body + "</div>" } > end > > and it does render the html code properly but, for only one entry. In > other words, if I have 2 records in a database, only the first one is > getting displayed. > > Weird. I''m close but missing something basic. > > Thanks so much for your help.-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---