跳转到主要内容

项目 collective.portlet.localcumulus 是 Makina Corpus 的 cumulus 产品

项目描述

简介

此软件包提供了基于标签云的 2 个新组件

具有

  • 缓存(刷新)

  • 本地路径搜索增强

以及对于“自定义组件”

  • 标签浏览的 URL 自定义

用法

  • 使用 QuickInstaller 安装“本地标签云(cumulus)组件”。

  • 从“添加组件”下拉菜单中选择“本地标签云(cumulus)组件”。

  • 如有必要,提供组件配置的自定义值。

  • 保存更改。

支持的 Plone 版本

  • 3.x

仓库

svn

致谢

makinacom

collective.portlet.cumulus 安装

要安装 collective.portlet.cumulus 到全局 Python 环境(或 workingenv),使用传统的 Zope 2 实例,您可以这样做

  • 当您阅读此内容时,您可能已经运行了

    ``easy_install collective.portlet.cumulus``.

    有关如何安装 setuptools(和 EasyInstall)的信息,请在此处查看: http://peak.telecommunity.com/DevCenter/EasyInstall

  • 如果您使用的是 Zope 2.9(不是 2.10),请获取 pythonproducts 并通过以下方式安装它

    python setup.py install --home /path/to/instance

    到您的 Zope 实例中。

  • /path/to/instance/etc/package-includes 目录中创建一个名为 collective.portlet.cumulus-configure.zcml 的文件。该文件应只包含以下内容

    <include package="collective.portlet.cumulus" />

或者,如果您使用 zc.buildout 和 plone.recipe.zope2instance 脚本管理项目,您可以这样做

  • collective.portlet.cumulus添加到要安装的egg列表中,例如:

    [buildout]
    ...
    eggs =
        ...
        collective.portlet.cumulus
  • 告诉plone.recipe.zope2instance配方安装ZCML别名

    [instance]
    recipe = plone.recipe.zope2instance
    ...
    zcml =
        collective.portlet.cumulus
  • 重新运行buildout,例如使用

    $ ./bin/buildout

如果您打算从另一个包的configure.zcml文件中显式包含包,则可以跳过ZCML别名

详细文档

本地渲染器和组件对象

添加一些内容以进行测试搜索

>>> self.setRoles(('Manager', ))
>>> self.portal['front-page'].edit(subject=['global', 'tags'])
>>> if1 = self.folder.invokeFactory('Folder', id='f1')
>>> if2 = self.folder.invokeFactory('Folder', id='f2')
>>> f1 = self.folder[if1]
>>> f2 = self.folder[if2]
>>> d1 = f1.invokeFactory('Document', id='blog-entry1')
>>> d2 = f1.invokeFactory('Document', id='blog-entry2')
>>> d3 = f2.invokeFactory('Document', id='blog-entry3')
>>> d4 = f2.invokeFactory('Document', id='blog-entry4')
>>> f1[d1].edit(subject=['blog', 'tags'])
>>> f1[d2].edit(subject=['foo', 'bar'])
>>> f2[d3].edit(subject=['toto', 'titi'])
>>> f2[d4].edit(subject=['toto', 'tutu'])

寻找我们的适配器已经到位

>>> from collective.portlet.localcumulus.interfaces import ILocalTagsRetriever
>>> from collective.portlet.localcumulus import catalog
>>> data = catalog.DummyData()
>>> data.refreshInterval = 1

此适配器将上下文和一个Assignment作为'data'属性

>>> retriever = ILocalTagsRetriever(f1)
>>> retriever
<collective.portlet.localcumulus.catalog.LocalTags object at ...>

尝试获取f1文件夹的本地标签

>>> data.path = '/'.join(f1.getPhysicalPath())
>>> retriever.data = data
>>> print '\n'.join(['%s %s %s'% i for i in retriever.getTags()])
blog 1 http://nohost/plone/search?path=/plone/Members/test_user_1_/f1&Subject:list=blog
foo 1 http://nohost/plone/search?path=/plone/Members/test_user_1_/f1&Subject:list=foo
bar 1 http://nohost/plone/search?path=/plone/Members/test_user_1_/f1&Subject:list=bar
tags 1 http://nohost/plone/search?path=/plone/Members/test_user_1_/f1&Subject:list=tags

尝试获取f2文件夹的本地标签

>>> data.path = '/'.join(f2.getPhysicalPath())
>>> print '\n'.join(['%s %s %s'% i for i in retriever.getTags()])
tutu 1 http://nohost/plone/search?path=/plone/Members/test_user_1_/f2&Subject:list=tutu
titi 1 http://nohost/plone/search?path=/plone/Members/test_user_1_/f2&Subject:list=titi
toto 2 http://nohost/plone/search?path=/plone/Members/test_user_1_/f2&Subject:list=toto

如果没有路径,则端口令牌全局有效

>>> data.path = ''
>>> print '\n'.join(['%s %s %s'% i for i in retriever.getTags(data=data)])
bar 1 http://nohost/plone/search?Subject:list=bar
blog 1 http://nohost/plone/search?Subject:list=blog
foo 1 http://nohost/plone/search?Subject:list=foo
global 1 http://nohost/plone/search?Subject:list=global
tags 2 http://nohost/plone/search?Subject:list=tags
titi 1 http://nohost/plone/search?Subject:list=titi
toto 2 http://nohost/plone/search?Subject:list=toto
tutu 1 http://nohost/plone/search?Subject:list=tutu

测试缓存

>>> import time
>>> data.path = '/'.join(f2.getPhysicalPath())
>>> data.refreshInterval = 10
>>> [o[0] for o in retriever.getTags()]
[u'tutu', u'titi', u'toto']
>>> f2[d4].edit(subject=['toto', 'tutu', 'tata'])
>>> [o[0] for o in retriever.getTags()]
[u'tutu', u'titi', u'toto']
>>> time.sleep(2)
>>> [o[0] for o in retriever.getTags()]
[u'tutu', u'titi', u'toto']

11秒后,缓存生命周期结束

>>> time.sleep(9)
>>> [o[0] for o in retriever.getTags()]
[u'tutu', u'titi', u'toto', u'tata']

本地自定义组件

自定义端口令牌允许用户格式化用于浏览标签的URL,而不是使用plone的默认search_form

测试

添加一些内容以进行测试搜索

>>> self.setRoles(('Manager', ))
>>> self.portal['front-page'].edit(subject=['global', 'tags'])
>>> if1 = self.folder.invokeFactory('Folder', id='f1')
>>> if2 = self.folder.invokeFactory('Folder', id='f2')
>>> f1 = self.folder[if1]
>>> f2 = self.folder[if2]
>>> d1 = f1.invokeFactory('Document', id='blog-entry1')
>>> d2 = f1.invokeFactory('Document', id='blog-entry2')
>>> d3 = f2.invokeFactory('Document', id='blog-entry3')
>>> d4 = f2.invokeFactory('Document', id='blog-entry4')
>>> f1[d1].edit(subject=['blog', 'tags'])
>>> f1[d2].edit(subject=['foo', 'bar'])
>>> f2[d3].edit(subject=['toto', 'titi'])
>>> f2[d4].edit(subject=['toto', 'tutu'])

寻找我们的适配器已经到位

>>> from collective.portlet.localcumulus.interfaces import ICustomLocalTagsRetriever
>>> from collective.portlet.localcumulus import catalog
>>> data = catalog.DummyData()
>>> data.refreshInterval = 1
>>> data.path = '/'.join(f1.getPhysicalPath())

此适配器将上下文和一个Assignment作为'data'属性

>>> retriever = ICustomLocalTagsRetriever(f1)
>>> retriever
<collective.portlet.localcumulus.catalog.CustomLocalTags object at ...>

尝试获取没有URL的f1文件夹的本地标签,它将默认为localtag行为

>>> data.search_url = ''
>>> retriever.data = data
>>> print '\n'.join(['%s %s %s'% i for i in retriever.getTags()])
blog 1 http://nohost/plone/search?path=/plone/Members/test_user_1_/f1&Subject:list=blog
foo 1 http://nohost/plone/search?path=/plone/Members/test_user_1_/f1&Subject:list=foo
bar 1 http://nohost/plone/search?path=/plone/Members/test_user_1_/f1&Subject:list=bar
tags 1 http://nohost/plone/search?path=/plone/Members/test_user_1_/f1&Subject:list=tags

使用变量自定义 URL

我们可以以Python字典字符串格式化的风格玩一些变量。

如果没有参数的URL,它将在末尾附加标签

>>> [bool(catalog.NOT_SIMPLE_URL_RE.match(a)) for a in ['azerty', '()', '%(azerty)s', '%()', '%()s']]
[False, False, True, False, False]
>>> data.search_url = 'http://foo'
>>> retriever.data = data
>>> print '\n'.join(['%s' % i for i in retriever.getTags()])
[u'blog', 1, u'http://foo/blog&path=/plone/Members/test_user_1_/f1']
[u'foo', 1, u'http://foo/foo&path=/plone/Members/test_user_1_/f1']
[u'bar', 1, u'http://foo/bar&path=/plone/Members/test_user_1_/f1']
[u'tags', 1, u'http://foo/tags&path=/plone/Members/test_user_1_/f1']

请记住,您肯定需要在您的URL中至少添加%(tag)s以包含标签信息;)。

可用的变量有

  • portal_path:plone站点路径

  • portal_url:plone站点URL

  • here_url:上下文URL

  • here_path:ZODB中的上下文路径

  • tag:标签

  • tag_weight:标签权重

>>> data.search_url = '%(portal_url)s?path=%(portal_path)s&url=%(here_url)s&hpath=%(here_path)s&tag=%(tag)s&weight=%(tag_weight)s'
>>> retriever.data = data
>>> print '\n'.join(['%s' % i for i in retriever.getTags()])
[u'blog', 1, u'http://nohost/plone?path=/plone&url=http://nohost/plone/Members/test_user_1_/f1&hpath=/plone&tag=blog&weight=1']
[u'foo', 1, u'http://nohost/plone?path=/plone&url=http://nohost/plone/Members/test_user_1_/f1&hpath=/plone&tag=foo&weight=1']
[u'bar', 1, u'http://nohost/plone?path=/plone&url=http://nohost/plone/Members/test_user_1_/f1&hpath=/plone&tag=bar&weight=1']
[u'tags', 1, u'http://nohost/plone?path=/plone&url=http://nohost/plone/Members/test_user_1_/f1&hpath=/plone&tag=tags&weight=1']

变更日志

1.5 - 2010-03-16

  • 修复:自定义端口令牌中的路径[kiorky]

1.4 - 2010-03-16

  • grok修复(删除它,无用)[kiorky]

  • 修复测试。

1.3 - 未发布

  • 尊重自定义端口令牌中的路径[kiorky]

1.2 - 2010-02-08

  • 添加可自定义的端口令牌,并在选择标签时具有特殊URL进行浏览[kiorky]

1.0 - 2010-01-18

  • 初始发布[kiorky]

项目详情


下载文件

为您的平台下载文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分发

collective.portlet.localcumulus-1.8.zip (46.1 kB 查看散列)

上传时间

由以下机构支持

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