2014-09-05 89 views
2

我使用Diazo在特定网址上部署静态html文件'ticker.html'。该网页根本没有使用任何内容。如何使用plone.app.theming提供静态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> 

它工作正常和HTML是正确的,但的http://localhost:8080/Plone/ticker返回代码为404。只有当我建立在这个位置,我得到Plone中一些虚拟内容一个200返回的也略有改变:当有一个虚拟的内容重氮增加了一个基地,标签头:

<base href="http://localhost:8080/Plone/ticker/" /> 

我怎么能告诉重氮完全忽略的内容,当返回200即使在那里是不是虚拟内容?

如果您想知道:我使用Diazo,因为plone.app.themeing允许通过网页修改静态页面。

回答

3

plone.app.theming转换是交付管道中的最后一步。内容已经从Plone召集,以便它可以与主题相结合。所以,这不是适合的地方。

而是使用反向代理的重写规则来做到这一点。只要代理收到目标网址的请求,代理就会提取您的代码。在这个过程中,您还可以节省大量的CPU周期,因为您将避免通过Zope/Plone的机器进行整个旅程。

+1

这是一个遗憾。我想用独立的Diazo或Deliverance来解决问题并非如此?但那也意味着我会放弃主题编辑。我将重写从plone.app.theming改为apache,并通过仍然部署主题中的静态文件来保留主题编辑器:'RewriteRule ^/ticker http:// localhost:8080/VirtualHostBase/http/www.mysite.com :80/Plone/VirtualHostRoot/++主题++ myproject.theme/ticker.html/[L,P]' – pbauer 2014-09-05 18:23:20

0

我有一个类似的用例,我想通过Zope为AngularJS服务一些js-partials。他们是text/html,所以他们通过plone.app.theming转换。一个深入探讨plone.app.theming后,我超载了ThemeTranform适配器与子类的一个新文件中transforms.py,如下图所示:

# -*- 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注册相同的名字作为默认ThemeTransform适配器:

<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> 

可能与此问题:https://dev.plone.org/ticket/13139

相关问题