简体   繁体   English

如何创建自己的XML / RSS Feed?

[英]How do I create my own XML/RSS feed?

I am in the process of creating my own product that acts like a Content Management System, in a way. 我正在以某种方式创建自己的产品,该产品的行为类似于内容管理系统。 I would like to include an RSS feed, although I'm not exactly sure how I would go about doing it. 我想包括一个RSS feed,尽管我不确定我将如何去做。

I think it would be possible if I iterate through each post as its being built by my Build script and append it as an item into the XML file . 我认为,如果我遍历每条由构建脚本构建的帖子并将其作为一项附加到XML文件中,那将是可能的。 Is there a more efficient or less costly way to achieve this? 有没有更有效或更便宜的方法来实现这一目标?

I'm mainly using Ruby/Php/Haml, but I will also accept other languages (I'm willing to learn) 我主要使用Ruby / Php / Haml,但我也会接受其他语言(我愿意学习)

I suggest to use a stack of x items. 我建议使用一堆x件物品。 Every time a new post is added, you'll push it to the stack. 每次添加新帖子时,您都将其推送到堆栈中。 At any given moment, you can view the stack. 在任何给定的时刻,您都可以查看堆栈。 That's your feed. 那是你的饲料。

Rails has an after_create mechanism to identify when a new item has been added. Rails具有after_create机制,用于识别何时添加了新项目。

For the stack, I would recommend using Redis, which is very fast. 对于堆栈,我建议使用Redis,这是非常快的。

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

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