2014-09-05 84 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

相關問題