生成Atom提要的编辑器插件。

lektor-atom的Python项目详细描述


Lektor Atom插件

为基于Lektor的站点生成一个或多个AtomXML提要。

灵感来自于为Lektor官方博客撰写的atom-feed-support插件Armin Ronacher。

安装

从命令行将lektor atom添加到项目中:

lektor plugins add lektor-atom

the Lektor documentation for more instructions on installing plugins

配置

对于要发布的每个提要,向configs/atom.ini添加一个节。例如,一个包含所有最近文章的源和一个关于咖啡的源的博客:

[blog]
name = My Blog
source_path = /
url_path = /feed.xml
items = site.query('/').filter(F.type == 'post')
item_model = blog-post

[coffee]
name = My Blog: Articles About Coffee
source_path = /
url_path = /category/coffee/feed.xml
items = site.query('/blog').filter(F.categories.contains('coffee'))
item_model = blog-post

节名,比如blogcoffee,只是用作内部标识符。

选项

OptionDefaultDescription
source_path/Where in the content directory to find items' parent source
nameFeed name: default is section name
filenamefeed.xmlName of generated Atom feed file
url_pathFeed's URL on your site: default is source's URL path plus the filename
blog_author_fieldauthorName of source's author field
blog_summary_fieldsummaryName of source's summary field
itemsNoneA query expression: default is the source's children
limit50How many recent items to include
item_title_fieldtitleName of items' title field
item_body_fieldbodyName of items' content body field
item_author_fieldauthorName of items' author field
item_date_fieldpub_dateName of items' publication date field
item_modelNoneName of items' model

为您的模型定制插件

使用field选项告诉lektor atom如何读取项目。例如,如果您的站点的模型是:

[model]
name = Blog

[fields.writer]
type = string

[fields.short_description]
type = string

然后添加到atom.ini:

[main]
blog_author_field = writer
blog_summary_field = short_description

有关完整的示例,请参见tests/demo-project/configs/atom.ini

过滤项

默认情况下,lektor atom在source_path处获取源,并在提要中包含其所有子级。如果设置了item_model,lektor atom只包含具有该数据模型的子级。

items设置为任何查询表达式以覆盖默认值。如果items_model也指定了,lektor atom会将其作为过滤器应用到items

在模板中使用

您可以链接到模板中的特定源。如果您的atom.ini包含这样的提要:

[main]
source_path = /blog

在这样的模板中链接到源:

{{ 'blog@atom/main'|url }}

更改

2016-06-02:版本0.2。python 3兼容性(感谢dan bauman) 生成期间的彩色错误输出,修复标记格式的项目副标题。

2016-01-09:0.1版,首次发布。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java向嵌入式Jetty添加多个端点   java如何在JAXWS处理程序中区分请求和响应?   使用Scenebuilder for JAVAFx的登录应用程序的java MVC体系结构   java对话框将不显示   Windows 7上的Java系统变量   java删除动态添加的面板   java将Javadoc嵌入到HTML网站中   带有URL编码数据的java Spring RestTemplate POST请求   java JAXR只运行一次函数   HttpClient缺少java依赖项   java深层反射比较   基于javarmi和CORBA的分布式计算   如何使用当前数据库时间从Java更新MongoDB?   java通过光标保存数据调试时显示错误数据