2015-12-21 40 views
2

我试图创建一个RSS提要为每个物体图像,最终的一面旗帜的资讯提供ly和标志,但我很难做到这一点。Rails的RSS建设者的形象,旗帜,徽

这里是我所得到的预览: Feedly preview

这里是我的RSS生成器:

#encoding: UTF-8 

xml.instruct! :xml, :version => "1.0" 
xml.rss :version => '2.0', 'xmlns:atom' => 'http://www.w3.org/2005/Atom', 'xmlns:media' => 'http://search.yahoo.com/mrss/' do 
    xml.channel do 
    xml.title "My RSS feed" 
    xml.description "Super description" 
    xml.link "MY_URL" 
    xml.language "en" 
    xml.tag! 'atom:link', :rel => 'self', :type => 'application/rss+xml', :href => "MY_URL/feed" 

    for article in @articles 
     xml.item do 
     xml.title article.name 
     xml.pubDate article.created_at.to_s(:rfc822) 
     xml.link "MY_URL" 
     xml.guid "MY_URL" 

     xml.media(:content, :url => article.image.url(:medium)) 
     xml.media(:thumbnail, :url => article.image.url(:thumbnail)) 
     xml.description "<p>" + article.description + "</p>" 

     end 
    end 
    end 
end 

,这里是结果:

<?xml version="1.0" encoding="UTF-8"?> 
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/"> 
    <channel> 
    <title>My RSS feed</title> 
    <description>Super description</description> 
    <link>MY_URL</link> 
    <language>en</language> 
    <atom:link rel="self" type="application/rss+xml" href="MY_URL/feed"/> 
    <item> 
     <title>Dojo</title> 
     <pubDate>Mon, 23 Nov 2015 16:58:41 +0000</pubDate> 
     <link>MY_URL</link> 
     <guid>MY_URL</guid> 
     <media:content url="MY_URL"/> 
     <media:thumbnail url="MY_URL"/> 
     <description>&lt;p&gt;Your security &amp; privacy advisor.&lt;/p&gt;</description> 
    </item> 
</channel> 
</rss> 

感谢您的帮助那!

+0

那样做你的rss feed你确定你的图片链接了绝对链接吗?你可以打开Firebug或类似的东西,看看你的浏览器正在呈现什么? –

回答

0

我已经签出它是如何工作的blog.feedly.com这里是例子:

<item> 
    <title>POST_TITLE</title> 
    <link>URL_TO_POST</link> 
    <comments>URL_TO_COMMENTS</comments> 
    <pubDate>ISODate</pubDate> 
    <dc:creator>CDATA_AUTHOR_METATAG</dc:creator> 
    <category><![CDATA[All]]></category> 

    <guid isPermaLink="false">URL_WITHOUT_SLUG</guid> 
    <description>CDATA_DESCRIPTION</description> 
    <content:encoded>CDATA_POST_CONTENT</content:encoded> 
    <wfw:commentRss>URL_TO_COMMENTS_RSS</wfw:commentRss> 
    <slash:comments>NUMBER_OF_COMMENTS</slash:comments> 

    <media:content url="IMG_URL" medium="image"> 
     <media:title type="html">Author</media:title> 
    </media:content> 

    <media:content url="IMG_URL" medium="image"> 
     <media:title type="html">img_short_description</media:title> 
    </media:content> 
</item> 

试图实现您的饲料项目,如我上述的,如果它不能正常工作,检查出item父标签了。你需要像在blog.feedly.com