如何使用plone.app.theming交付静态html

如何使用plone.app.theming交付静态html,plone,diazo,Plone,Diazo,我使用Diazo在某个url上部署静态html文件'ticker.html'。该页面完全没有使用内容中的任何内容 这是rules.xml: <rules xmlns="http://namespaces.plone.org/diazo" xmlns:css="http://namespaces.plone.org/diazo/css" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <rule

我使用Diazo在某个url上部署静态html文件'ticker.html'。该页面完全没有使用内容中的任何内容

这是rules.xml:

<rules xmlns="http://namespaces.plone.org/diazo"
       xmlns:css="http://namespaces.plone.org/diazo/css"
       xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <rules if-path="/Plone/ticker/ /ticker/">
    <theme href="ticker.html" />
  </rules>

  <rules css:if-content="#visual-portal-wrapper" if-not-path="/Plone/ticker/ /ticker/">
    <theme href="index.html" />    
    The rest of the theme...
  </rules>
</rules>
我怎么能告诉Diazo完全忽略内容并返回一个200,即使没有虚拟内容


如果你想知道:我使用Diazo是因为plone.app.themeing允许通过web修改静态页面

plone.app.theming转换是交付流程中的最后一步。内容已经从Plone中调用,以便与主题相结合。所以,这不是一个合适的地方


相反,请使用反向代理的重写规则执行此操作。让代理在收到目标URL的请求时获取您的ticker。在这个过程中,您还可以节省大量的CPU周期,因为这样可以避免通过Zope/Plone的机器进行整个过程。

我有一个类似的用例,我想通过Zope将一些js部分服务器发送到AngularJS。它们是
text/html
,因此它们通过
plone.app.theming
进行了转换。深入查看
plone.app.theming
后,我在一个新文件
transforms.py
中使用子类适配器重载了
ThemeTranform
适配器,如下所示:

# -*- coding: utf-8 -*-
from plone.app.theming import transform
from your.theme.interfaces import IYourThemeLayer
from zope.component import adapter
from zope.interface import Interface


@adapter(Interface, IYourThemeLayer
class ThemeTransform(transform.ThemeTransform):

    def parseTree(self, result):

        # Prevent diazo from adding doctype and html head to every
        # html file. Exclude all partial resources from theme transforms
        if '/++resource++your.theme.js-partials/' in self.request.getURL():
            return None

        return super(ThemeTransform, self).parseTree(result)
。。。并在
zcml
中注册到与默认
metransform
适配器相同的名称,使用:

<configure
    xmlns="http://namespaces.zope.org/zope"
    xmlns:zcml="http://namespaces.zope.org/zcml"
    i18n_domain="your.theme">

    <!-- Override plone.app.theming adapter -->
    <adapter
        name="plone.app.theming.transform"
        factory=".transform.ThemeTransform"
        zcml:condition="installed plone.app.theming"
        />

</configure>


真遗憾。我想用一个单独的重氮或解救,情况就不会是这样了?但这也意味着我会失去主题编辑器。我将重写从plone.app.theming移动到apache,并通过仍然部署主题中的静态文件来保留主题编辑器:
RewriteRule^/tickerhttp://localhost:8080/VirtualHostBase/http/www.mysite.com:80/Plone/VirtualHostRoot/++theme++myproject.theme/ticker.html/[L,P]
<configure
    xmlns="http://namespaces.zope.org/zope"
    xmlns:zcml="http://namespaces.zope.org/zcml"
    i18n_domain="your.theme">

    <!-- Override plone.app.theming adapter -->
    <adapter
        name="plone.app.theming.transform"
        factory=".transform.ThemeTransform"
        zcml:condition="installed plone.app.theming"
        />

</configure>