跳转到主要内容

TurboGears 控制器和用于处理订阅源的小部件。

项目描述

Turbofeeds 是一个 TurboGears 1 扩展,提供生成 RSS 和 Atom 订阅源以及匹配显示小部件的支持。

TurboFeeds 曾是 TurboGears 主分发中的 feed 子包。它被从 TG 核心中提取出来,以简化对两个项目的更新、增强和维护。

TurboFeeds 主要与 turbogears.feed 包向后兼容,但有很多修复和一些新特性,最重要的是对 Genshi 模板的支持。它适用于 TurboGears 1.0 和 1.1 分支。

安装

要从 Cheeseshop 安装 TurboFeeds,请使用 easy_install。

[sudo] easy_install TurboFeeds

这需要安装 setuptools 包。如果您还没有安装,请下载 ez_setup.py 脚本并运行它以安装 setuptools。

如果您想获取最新开发版本,可以使用以下命令从 Subversion 存储库检出主干:

svn co http://svn.turbogears.org/projects/TurboFeeds/trunk TurboFeeds

对于错误报告和功能请求,请访问 TurboGears trac 在 http://trac.turbogears.org/。

要提交工单,您需要一个 trac 账户。请选择“TurboFeeds”作为工单组件。

使用方法

控制器

from turbogears import controllers, expose
from turbofeeds import FeedController, FeedHeadLinks, FeedLinks

class MyFeedController(FeedController):
    def get_feed_data(self, **kwargs):
        entries = []
        # Fill ``entries`` with dicts containing at least items for:
        #
        #   title, link, summary and published
        #
        # For example, supposing ``entry`` is a database object
        # representing a blog article:
        entries.append(dict(
            title = entry.title,
            author = dict(name = entry.author.display_name,
                email = entry.author.email_address),
            summary = entry.post[:30],
            published = entry.published,
            updated = entry.updated or entry.published,
            link = 'http://blog.foo.org/article/%s' % entry.id
        ))
        return dict(entries=entries)

class Root(controllers.RootController):
    feed = MyFeedController(
        base_url = '/feed',
        title = "my fine blog",
        link = "http://blog.foo.org",
        author = dict(name="John Doe", email="john@foo.org"),
        id = "http://blog.foo.org",
        subtitle = "a blog about turbogears"
    )
    feedlheadinks = FeedHeadLinks(controller=feed)
    feedlinks = FeedLinks(controller=feed,
        title = "Click link to access the feed in %(type)s format")

    @expose('.templates.mypage')
    def mypage(self):
        return dict(
            feedheadlinks=self.feedheadlinks,
            feedlinks=self.feedlinks)

模板

<head>
  ${feadheadlinks()}
  ...
</head>
<body>
  <h2>Feed links</h2>
  ${feedlinks('%(type)s feed', url_params=dict(format='full'))}
  ...
</body>

文档

TurboFeeds 源代码经过详细的文档说明,包括 doc strings。源代码分发包含 epydoc 生成的 API 文档

您还可以参考 TurboGears 文档维基上原始 turbogears.feed 包的文档

http://docs.turbogears.org/1.0/FeedController

此页面上所有信息也适用于 TurboFeeds,只需将

from turbogears.feed import FeedController

替换为

from turbofeeds import FeedController

致谢

  • turbogears.feed 包首次在 TurboGears 版本 0.9a1 中引入,由 Elvelind Grandin 添加。

  • Christopher Arndt 将其发展成为 TurboGears 扩展 TurboFeeds。

  • 其他贡献者包括

    Florent Aide, Simon Belak, Kevin Dangoor, Charles Duffy, Alberto Valverde, Jorge Vargas

    如果您认为您的名字也应该出现在这里,请通知维护者。

  • 用于 FeedLinks 小部件的 CSS 中的图标是从 http://www.feedicons.com/ 拿取的。

项目详情


下载文件

下载适合您平台的应用程序。如果您不确定选择哪个,请了解更多关于 安装包 的信息。

源代码分发

TurboFeeds-0.2b.zip (140.4 kB 查看哈希值)

上传时间 源代码

TurboFeeds-0.2b.tar.bz2 (52.2 kB 查看哈希值)

上传时间 源代码

构建分发

TurboFeeds-0.2b-py2.5.egg (34.6 kB 查看哈希值)

上传时间 源代码

支持者:

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面