简体   繁体   English

单个RSS供稿可获取多种资源

[英]Single RSS feed for multiple resources

My rails app has couple of content generating resources like Article, Blog Posts, etc.. 我的rails应用程序具有几个内容生成资源,例如文章,博客文章等。

I can generate the RSS for each individual resource but I'm not getting how to synchronize into one RSS feed for these multiple feeds. 我可以为每个单独的资源生成RSS,但是我没有获得如何同步到这些多个提要的一个RSS提要。

Currently I've setup the Articles feed via FeedBurner and even FeedBurner doesn't have this facility to merge different RSS of the same app into one so that I users can subscribe to individual RSS (Which I've done already) or to just a single main feed to get all the updates. 目前,我已经通过FeedBurner设置了文章供稿,甚至FeedBurner都不具备将同一应用程序的不同RSS合并为一个的功能,因此我的用户可以订阅单个RSS(我已经做过)或仅订阅单个主供稿即可获取所有更新。

I can't find any plugins nor found any code googling around for my Rails app?? 我找不到任何插件,也找不到关于Rails应用程序的任何代码?

FeedStitch allows you to "stitch" multiple feeds together. FeedStitch允许您将多个Feed一起“缝合”。 It doesn't solve it from the Rails point of view, but it gets the job done. 从Rails的角度来看,它不能解决问题,但是可以完成工作。

I recommend putting your feeds into feedstitch, and then use feedburner with the feedstitch feed. 我建议将您的饲料放入feedstitch中,然后将feedburner与feedstitch饲料一起使用。

If you want to solve the problem from the Rails side, it's not so complicated. 如果您想从Rails的角度解决问题,它并不那么复杂。 Create a new action and fetch the records you want to format as a feed and create the feed. 创建一个新操作,并获取要格式化为提要的记录并创建提要。

# the action
def feed
  @articles = Article.all(:limit => 10)
  @posts = Post.all(:limit => 10)
  @items = @article + @posts

  respond_to do |format|
    format.html
    format.atom
  end
end

# the view
atom_feed do |feed|
  feed.title("Latest items")
  feed.updated(@items.first.try(:created_at))

  for item in @items
    feed.entry(item) do |entry|
      entry.title(item.title)
      entry.content(item.body, :type => 'html')
    end
  end
end

Off course, the resources must share the same API at least for the methods you want to call in the controller. 当然,资源至少必须为要在控制器中调用的方法共享相同的API。 http://api.rubyonrails.org/classes/ActionView/Helpers/AtomFeedHelper.html#M001900 http://api.rubyonrails.org/classes/ActionView/Helpers/AtomFeedHelper.html#M001900

In case you accept to rely on an external service for that, you can use RSS Mix or Yahoo! 万一您接受依赖外部服务的情况,可以使用RSS Mix或Yahoo!。 Pipes: 管道:

www.rssmix.com/ www.rssmix.com/

pipes.yahoo.com/pipes/ pipe.yahoo.com/pipes/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM