You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by th...@apache.org on 2007/06/08 08:35:59 UTC

svn commit: r545437 - in /lenya/trunk/src: impl/java/org/apache/lenya/cms/publication/ modules-core/linking/java/src/org/apache/lenya/cms/cocoon/transformation/ pubs/default/ pubs/default/config/ resources/build/ webapp/ webapp/lenya/ webapp/lenya/chap...

Author: thorsten
Date: Thu Jun  7 23:35:57 2007
New Revision: 545437

URL: http://svn.apache.org/viewvc?view=rev&rev=545437
Log:
Bug 42050 - proxying does not work. 
Adding proxyTransformer that is doing the proxy rewritte as last step of the transformation for html documents.
Adding chaperon pattern resolver and using it for css proxing. Can scan any file for pattern and transform them to links, see the way I implemented in css to extend it to e.g. js.
Extending PublicationConfiguration.java and publication.rng to read and allow the new attributes in the proxies element.

Added:
    lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/transformation/ProxyTransformer.java
    lenya/trunk/src/webapp/lenya/chaperon/
    lenya/trunk/src/webapp/lenya/chaperon/grammars/
    lenya/trunk/src/webapp/lenya/chaperon/grammars/link.xlex
    lenya/trunk/src/webapp/lenya/chaperon/stylesheets/
    lenya/trunk/src/webapp/lenya/chaperon/stylesheets/a-to-txt.xsl
    lenya/trunk/src/webapp/lenya/chaperon/stylesheets/pattern-to-link.xsl
Modified:
    lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/PublicationConfiguration.java
    lenya/trunk/src/pubs/default/config/publication.xml
    lenya/trunk/src/pubs/default/sitemap.xmap
    lenya/trunk/src/resources/build/publication.rng
    lenya/trunk/src/webapp/global-sitemap.xmap
    lenya/trunk/src/webapp/lenya/config/sitemap/transformers.xmap
    lenya/trunk/src/webapp/lenya/lenya.xmap
    lenya/trunk/src/webapp/lenya/module-resources.xmap
    lenya/trunk/src/webapp/lenya/resources-shared.xmap
    lenya/trunk/src/webapp/lenya/resources.xmap

Modified: lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/PublicationConfiguration.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/PublicationConfiguration.java?view=diff&rev=545437&r1=545436&r2=545437
==============================================================================
--- lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/PublicationConfiguration.java (original)
+++ lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/PublicationConfiguration.java Thu Jun  7 23:35:57 2007
@@ -83,6 +83,7 @@
     private static final String ELEMENT_CONTENT_DIR = "content-dir";
     private static final String ATTRIBUTE_SRC = "src";
     private static final String ELEMENT_PROXIES = "proxies";
+    private static final String ATTRIBUTE_ROOT = "root";
     private static final String ELEMENT_PROXY = "proxy";
     private static final String ATTRIBUTE_AREA = "area";
     private static final String ATTRIBUTE_URL = "url";
@@ -179,6 +180,16 @@
 
             Configuration proxyConfig = config.getChild(ELEMENT_PROXIES);
             if (proxyConfig != null) {
+              // root/global proxy 
+              String urlRoot=proxyConfig.getAttribute(ATTRIBUTE_ROOT,null);
+              String sslRoot = proxyConfig.getAttribute(ATTRIBUTE_SSL,null);
+              if (urlRoot!=null & sslRoot!=null){
+                Proxy rootProxy = new Proxy();
+                rootProxy.setUrl(urlRoot);
+                Object rootKey = getProxyKey(ATTRIBUTE_ROOT, Boolean.valueOf(sslRoot).booleanValue());
+                this.areaSsl2proxy.put(rootKey, rootProxy);
+              }
+              // Area proxies
                 Configuration[] proxyConfigs = proxyConfig.getChildren(ELEMENT_PROXY);
                 for (int i = 0; i < proxyConfigs.length; i++) {
                     String url = proxyConfigs[i].getAttribute(ATTRIBUTE_URL);

Added: lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/transformation/ProxyTransformer.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/transformation/ProxyTransformer.java?view=auto&rev=545437
==============================================================================
--- lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/transformation/ProxyTransformer.java (added)
+++ lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/transformation/ProxyTransformer.java Thu Jun  7 23:35:57 2007
@@ -0,0 +1,215 @@
+package org.apache.lenya.cms.cocoon.transformation;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Map;
+
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.avalon.framework.service.ServiceSelector;
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.environment.ObjectModelHelper;
+import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.environment.SourceResolver;
+import org.apache.cocoon.transformation.AbstractSAXTransformer;
+import org.apache.lenya.ac.AccessControlException;
+import org.apache.lenya.ac.AccessController;
+import org.apache.lenya.ac.AccessControllerResolver;
+import org.apache.lenya.ac.AccreditableManager;
+import org.apache.lenya.ac.Policy;
+import org.apache.lenya.ac.PolicyManager;
+import org.apache.lenya.cms.publication.DocumentBuildException;
+import org.apache.lenya.cms.publication.DocumentFactory;
+import org.apache.lenya.cms.publication.DocumentUtil;
+import org.apache.lenya.cms.publication.Proxy;
+import org.apache.lenya.cms.publication.Publication;
+import org.apache.lenya.cms.publication.PublicationUtil;
+import org.apache.lenya.cms.repository.RepositoryUtil;
+import org.apache.lenya.cms.repository.Session;
+import org.apache.lenya.util.ServletHelper;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+
+public class ProxyTransformer extends AbstractSAXTransformer {
+  protected static final String[] elementNames = { "a", "object", "img",
+      "link", "form" , "script" };
+
+  protected static final String[] attributeNames = { "href", "src", "data",
+      "action" };
+
+  private boolean ignoreLinkElement = false;
+
+  private String indent = "";
+
+  private DocumentFactory factory;
+
+  private Publication publication;
+
+  private String url;
+
+  private ServiceSelector serviceSelector;
+
+  private AccessControllerResolver acResolver;
+
+  private AccreditableManager accreditableManager;
+
+  private PolicyManager policyManager;
+
+  protected static final String PARAMETER_FACTORY = "private.factory";
+
+  private static final String ATTRIBUTE_ROOT = "root";
+
+  public void setup(SourceResolver _resolver, Map _objectModel, String _source,
+      Parameters _parameters) throws ProcessingException, SAXException,
+      IOException {
+    super.setup(_resolver, _objectModel, _source, _parameters);
+    Request _request = ObjectModelHelper.getRequest(_objectModel);
+
+    try {
+      Session session = RepositoryUtil.getSession(this.manager, _request);
+      this.factory = DocumentUtil.createDocumentFactory(this.manager, session);
+      this.url = ServletHelper.getWebappURI(_request);
+      this.publication = PublicationUtil.getPublicationFromUrl(this.manager,
+          factory, url);
+    } catch (final Exception e) {
+      throw new RuntimeException(e);
+    }
+    this.serviceSelector = null;
+    try {
+      this.serviceSelector = (ServiceSelector) this.manager
+          .lookup(AccessControllerResolver.ROLE + "Selector");
+      this.acResolver = (AccessControllerResolver) this.serviceSelector
+          .select(AccessControllerResolver.DEFAULT_RESOLVER);
+      AccessController accessController = this.acResolver
+          .resolveAccessController(url);
+      if (accessController!=null){
+        this.accreditableManager = accessController.getAccreditableManager();
+        this.policyManager = accessController.getPolicyManager();
+      }
+    } catch (final Exception e) {
+      throw new RuntimeException(e);
+    }
+
+  }
+
+  public void startElement(String uri, String name, String qname,
+      Attributes attrs) throws SAXException {
+    if (getLogger().isDebugEnabled()) {
+      getLogger().debug(
+          this.indent + "<" + qname + "> (ignoreAElement = "
+              + this.ignoreLinkElement + ")");
+      this.indent += "  ";
+    }
+    AttributesImpl newAttrs = null;
+    if (lookingAtLinkElement(name)) {
+
+      for (int i = 0; i < attributeNames.length; i++) {
+        String linkUrl = attrs.getValue(attributeNames[i]);
+        if (linkUrl != null) {
+          if (linkUrl.startsWith("/")) {
+            try {
+              newAttrs = new AttributesImpl(attrs);
+              rewriteLink(newAttrs, attributeNames[i], linkUrl);
+              if (getLogger().isDebugEnabled()) {
+                getLogger().debug(this.indent + "link URL: [" + linkUrl + "]");
+              }
+            } catch (final Exception e) {
+              getLogger().error("startElement failed: ", e);
+              throw new SAXException(e);
+            }
+          }
+        }
+      }
+      if (newAttrs == null)
+        super.startElement(uri, name, qname, attrs);
+      else
+        super.startElement(uri, name, qname, newAttrs);
+    } else
+      super.startElement(uri, name, qname, attrs);
+
+  }
+
+  public void endElement(String uri, String name, String qname)
+      throws SAXException {
+    if (getLogger().isDebugEnabled()) {
+      this.indent = this.indent.substring(2);
+      getLogger().debug(this.indent + "</" + qname + ">");
+    }
+    if (getLogger().isDebugEnabled()) {
+      getLogger().debug(this.indent + "</" + qname + "> sent");
+    }
+    super.endElement(uri, name, qname);
+  }
+
+  private void rewriteLink(AttributesImpl newAttrs, String attributeName,
+      String linkUrl) throws AccessControlException, DocumentBuildException {
+    String rewrittenURL = "";
+    Policy policy=null;
+    if(policyManager!=null)
+    policy = this.policyManager.getPolicy(this.accreditableManager, linkUrl);
+    String area = "";
+    if(factory.isDocument(linkUrl)){
+      area = factory.getFromURL(linkUrl).getArea();
+    }
+    if (PublicationUtil.isValidArea(area)) {
+      Proxy proxy = this.publication.getProxy(area, policy.isSSLProtected());
+      if (proxy == null) {
+        rewrittenURL = this.request.getContextPath() + linkUrl;
+      } else {
+        String prefix = "/" + publication.getId() + "/" + area;
+        if (linkUrl.startsWith(prefix))
+          rewrittenURL = proxy.getUrl() + linkUrl.substring(prefix.length());
+        else
+          rewrittenURL = proxy.getUrl() + linkUrl;
+      }
+      if (getLogger().isDebugEnabled()) {
+        getLogger().debug(
+            this.indent + "SSL protection: [" + policy.isSSLProtected() + "]");
+        getLogger().debug(this.indent + "Resolved proxy: [" + proxy + "]");
+      }
+
+      if (getLogger().isDebugEnabled()) {
+        getLogger().debug(
+            this.indent + "Rewriting URL to: [" + rewrittenURL + "]");
+      }
+    } else {
+      // Since we came here the link is not covered by the area proxies.
+      // Now we try the global proxy for the pub of our initial request.
+      Proxy proxy = this.publication.getProxy(ATTRIBUTE_ROOT, (policy==null)?false:policy.isSSLProtected());
+      if (proxy == null) {
+        rewrittenURL = this.request.getContextPath() + linkUrl;
+      } else {
+        rewrittenURL = proxy.getUrl() + linkUrl.substring(1);
+      }
+      if (getLogger().isDebugEnabled()) {
+        getLogger().debug(
+            this.indent + "Rewriting URL to: [" + rewrittenURL + "]");
+      }
+    }
+    setAttribute(newAttrs, attributeName, rewrittenURL);
+  }
+
+  private boolean lookingAtLinkElement(String name) {
+    return Arrays.asList(elementNames).contains(name);
+  }
+
+  /**
+   * Sets the value of the href attribute.
+   * 
+   * @param attr
+   *          The attributes.
+   * @param name
+   *          The attribute name.
+   * @param value
+   *          The value.
+   * @throws IllegalArgumentException
+   *           if the href attribute is not contained in this attributes.
+   */
+  protected void setAttribute(AttributesImpl attr, String name, String value) {
+    int position = attr.getIndex(name);
+    if (position == -1) {
+      throw new IllegalArgumentException("The href attribute is not available!");
+    }
+    attr.setValue(position, value);
+  }
+}

Modified: lenya/trunk/src/pubs/default/config/publication.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/default/config/publication.xml?view=diff&rev=545437&r1=545436&r2=545437
==============================================================================
--- lenya/trunk/src/pubs/default/config/publication.xml (original)
+++ lenya/trunk/src/pubs/default/config/publication.xml Thu Jun  7 23:35:57 2007
@@ -101,8 +101,8 @@
   
   <!-- Lenya can rewrite the links to cater to special proxy setups.
        For information about these settings, read http://lenya.apache.org/1_2_x/components/deployment/proxying.html
-       (yes, this needs some updating... sorry.)
-  <proxies>
+       (yes, this needs some updating... sorry.)--><!--
+  <proxies ssl="false" root="http://www.host.com/non-ssl/">
     <proxy area="live" ssl="true" url="https://www.host.com/ssl/default"/>
     <proxy area="live" ssl="false" url="http://www.host.com/default"/>
     <proxy area="authoring" ssl="true" url="https://www.host.com/lenya/default/authoring"/>

Modified: lenya/trunk/src/pubs/default/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/default/sitemap.xmap?view=diff&rev=545437&r1=545436&r2=545437
==============================================================================
--- lenya/trunk/src/pubs/default/sitemap.xmap (original)
+++ lenya/trunk/src/pubs/default/sitemap.xmap Thu Jun  7 23:35:57 2007
@@ -85,7 +85,7 @@
     </map:pipeline>
 
     <map:pipeline>
-    
+
       <map:match pattern="**">
         <map:match pattern="webdav**">
           <map:mount uri-prefix="" src="{fallback:lenya/modules/webdav/sitemap.xmap}" check-reload="true" reload-method="synchron"/>    
@@ -306,6 +306,7 @@
                     </map:select>
                     <!-- pretty-print output for easier debugging and for the benefit of new users -->
                     <map:transform src="fallback://lenya/modules/prettyprinting/xslt/xml2nicexml.xsl"/>
+                    <map:transform type="proxy"/>
                     <map:serialize type="xhtml"/>
                   </map:otherwise>
                 </map:select>

Modified: lenya/trunk/src/resources/build/publication.rng
URL: http://svn.apache.org/viewvc/lenya/trunk/src/resources/build/publication.rng?view=diff&rev=545437&r1=545436&r2=545437
==============================================================================
--- lenya/trunk/src/resources/build/publication.rng (original)
+++ lenya/trunk/src/resources/build/publication.rng Thu Jun  7 23:35:57 2007
@@ -189,6 +189,10 @@
         </optional>
         <optional>
           <element name="proxies">
+            <optional>
+              <attribute name="root"><data type="anyURI"/></attribute>
+              <attribute name="ssl"><ref name="booleanString"/></attribute>
+            </optional>
             <oneOrMore>
               <element name="proxy">
                 <attribute name="area"><ref name="lenyaAreaName"/></attribute>

Modified: lenya/trunk/src/webapp/global-sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/webapp/global-sitemap.xmap?view=diff&rev=545437&r1=545436&r2=545437
==============================================================================
--- lenya/trunk/src/webapp/global-sitemap.xmap (original)
+++ lenya/trunk/src/webapp/global-sitemap.xmap Thu Jun  7 23:35:57 2007
@@ -45,6 +45,30 @@
         <map:parameter name="locale" value="{request:locale}"/>
       </map:transform>
     </map:resource>
+    <map:resource name="proxy-css">
+      <map:act type="resource-exists"
+        src="{url}.xml">
+        <map:generate src="{../url}.xml"/>
+        <map:transform src="fallback://lenya/resources/css/css.xsl">
+          <map:parameter name="contextprefix" value="{request:contextPath}"/>
+          <map:parameter name="root"
+            value="{base-url:{page-envelope:publication-id}:{page-envelope:area}:false}"/>
+        </map:transform>
+        <map:call resource="prepare-proxy-css"/>
+      </map:act>
+      <map:generate type="text" src="{url}.css"/>
+      <map:call resource="prepare-proxy-css"/>
+    </map:resource>
+    <map:resource name="prepare-proxy-css">
+      <map:transform type="pattern"
+        src="fallback://lenya/chaperon/grammars/link.xlex"/>
+      <map:transform
+        src="fallback://lenya/chaperon/stylesheets/pattern-to-link.xsl"/>
+      <map:transform type="proxy"/>
+      <map:transform
+        src="fallback://lenya/chaperon/stylesheets/a-to-txt.xsl"/>
+      <map:serialize type="text" mime-type="text/css"/>
+    </map:resource>
  </map:resources>
 
 <!-- =========================== Pipelines ================================= -->
@@ -122,7 +146,7 @@
     <map:pipeline>
       <!-- Lenya GUI -->
       <map:match pattern="lenya/**">
-        <map:mount uri-prefix="lenya" src="lenya/lenya.xmap" check-reload="true" reload-method="synchron"/>
+        <map:mount uri-prefix="lenya" src="lenya/lenya.xmap" check-reload="true" reload-method="synchron" pass-through="true"/>
       </map:match>
       
 
@@ -231,7 +255,7 @@
       <map:match pattern="menu-xml/module/*/*.xml">
         <map:select type="resource-exists">
           <map:when test="fallback://lenya/modules/{2}/menus.xmap">
-            <map:mount uri-prefix="menu-xml/module/{1}/" src="fallback://lenya/modules/{2}/menus.xmap" check-reload="true" reload-method="synchron"/>
+            <map:mount uri-prefix="menu-xml/module/{1}/" src="fallback://lenya/modules/{2}/menus.xmap" check-reload="true" reload-method="synchron" pass-through="true"/>
           </map:when>
           <map:otherwise>
             <map:generate type="serverpages" src="lenya/content/menus/live.xsp"/>
@@ -248,12 +272,12 @@
       
       <!-- menu-xml/{publication-id}/... -->
       <map:match pattern="menu-xml/*/**" internal-only="true">
-        <map:mount uri-prefix="menu-xml/{1}/" src="{fallback:menus.xmap}" check-reload="true" reload-method="synchron"/>
+        <map:mount uri-prefix="menu-xml/{1}/" src="{fallback:menus.xmap}" check-reload="true" reload-method="synchron" pass-through="true"/>
       </map:match>
       
       <!-- Access Control Policies -->
       <map:match pattern="*/policies/**">
-        <map:mount uri-prefix="{1}/policies" src="lenya/pubs/{1}/policies-sitemap.xmap" check-reload="true" reload-method="synchron"/>
+        <map:mount uri-prefix="{1}/policies" src="lenya/pubs/{1}/policies-sitemap.xmap" check-reload="true" reload-method="synchron" pass-through="true"/>
       </map:match>
       
     </map:pipeline>

Added: lenya/trunk/src/webapp/lenya/chaperon/grammars/link.xlex
URL: http://svn.apache.org/viewvc/lenya/trunk/src/webapp/lenya/chaperon/grammars/link.xlex?view=auto&rev=545437
==============================================================================
--- lenya/trunk/src/webapp/lenya/chaperon/grammars/link.xlex (added)
+++ lenya/trunk/src/webapp/lenya/chaperon/grammars/link.xlex Thu Jun  7 23:35:57 2007
@@ -0,0 +1,183 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<lexicon xmlns="http://chaperon.sourceforge.net/schema/lexicon/1.0">
+ <!-- (([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))? -->
+ <lexeme symbol="link">
+  <concat>
+   <concat minOccurs="0" maxOccurs="1">
+     <cstring content="\"/>
+   </concat>
+   <group>
+   <concat>
+    <cclass maxOccurs="*">
+     <cinterval min="A" max="Z"/>
+     <cinterval min="a" max="z"/>
+    </cclass>
+    <cstring content=":"/>
+    <cstring content="/"/>
+   </concat>
+ 
+   <concat minOccurs="0">
+    <cstring content="/"/>
+    <cclass minOccurs="0" maxOccurs="*">
+     <cinterval min="A" max="Z"/>
+     <cinterval min="a" max="z"/>
+     <cinterval min="0" max="9"/>
+     <cset content="._-:"/>
+    </cclass>
+   </concat>
+ 
+   <cclass minOccurs="0" maxOccurs="*">
+    <cinterval min="A" max="Z"/>
+    <cinterval min="a" max="z"/>
+    <cinterval min="0" max="9"/>
+    <cset content="._-:/"/>
+   </cclass>
+
+   <concat minOccurs="0">
+    <cstring content="?"/>
+    <cclass minOccurs="0" maxOccurs="*">
+     <cinterval min="A" max="Z"/>
+     <cinterval min="a" max="z"/>
+     <cinterval min="0" max="9"/>
+     <cset content="._-:/?"/>
+    </cclass>
+   </concat>
+
+   <concat minOccurs="0">
+    <cstring content="#"/>
+    <cclass minOccurs="0" maxOccurs="*">
+     <cinterval min="A" max="Z"/>
+     <cinterval min="a" max="z"/>
+     <cinterval min="0" max="9"/>
+     <cset content="._-:/?#"/>
+    </cclass>
+   </concat>
+   </group>
+  </concat>
+ </lexeme>
+
+ <lexeme symbol="cssurl">
+  <concat>
+      <group>
+       <concat>
+        <cstring content="u"/>
+        <cstring content="r"/>
+        <cstring content="l"/>
+       </concat>
+     
+       <concat minOccurs="0" maxOccurs="*">
+        <cstring content=" "/>
+       </concat>
+    
+       <concat>
+        <cstring content="("/>
+       </concat>
+       
+       <concat minOccurs="0" maxOccurs="*">
+        <cstring content=" "/>
+       </concat>
+       
+       <concat minOccurs="0" maxOccurs="1">
+        <cstring content="'"/>
+       </concat>
+      </group>
+      
+      <group>
+       <concat minOccurs="0">
+        <cstring content="/"/>
+        <cclass minOccurs="0" maxOccurs="*">
+         <cinterval min="A" max="Z"/>
+         <cinterval min="a" max="z"/>
+         <cinterval min="0" max="9"/>
+         <cset content="._-:"/>
+        </cclass>
+       </concat>
+     
+       <cclass minOccurs="0" maxOccurs="*">
+        <cinterval min="A" max="Z"/>
+        <cinterval min="a" max="z"/>
+        <cinterval min="0" max="9"/>
+        <cset content="._-:/"/>
+       </cclass>
+    
+       <concat minOccurs="0">
+        <cstring content="?"/>
+        <cclass minOccurs="0" maxOccurs="*">
+         <cinterval min="A" max="Z"/>
+         <cinterval min="a" max="z"/>
+         <cinterval min="0" max="9"/>
+         <cset content="._-:/?"/>
+        </cclass>
+       </concat>
+    
+       <concat minOccurs="0">
+        <cstring content="#"/>
+        <cclass minOccurs="0" maxOccurs="*">
+         <cinterval min="A" max="Z"/>
+         <cinterval min="a" max="z"/>
+         <cinterval min="0" max="9"/>
+         <cset content="._-:/?#"/>
+        </cclass>
+       </concat>
+      </group>
+      
+      <group>
+       <concat minOccurs="0" maxOccurs="1">
+        <cstring content="'"/>
+       </concat>   
+    
+       <concat minOccurs="0" maxOccurs="*">
+        <cstring content=" "/>
+       </concat>
+    
+       <concat>
+        <cstring content=")"/>
+       </concat>   
+      </group>
+      
+  </concat>
+ </lexeme>
+ 
+ <lexeme symbol="email">
+  <concat>
+   <concat>
+    <concat minOccurs="0" maxOccurs="1">
+     <cstring content="\"/>
+    </concat>
+    <group>
+     <cclass maxOccurs="*">
+      <cinterval min="A" max="Z"/>
+      <cinterval min="a" max="z"/>
+      <cinterval min="0" max="9"/>
+      <cset content="._-:"/>
+     </cclass>
+    </group>
+    <cstring content="@"/>
+    <group>
+     <cclass maxOccurs="*">
+      <cinterval min="A" max="Z"/>
+      <cinterval min="a" max="z"/>
+      <cinterval min="0" max="9"/>
+      <cset content="._-:"/>
+     </cclass>
+    </group>
+   </concat>
+  </concat>
+ </lexeme>
+</lexicon>
\ No newline at end of file

Added: lenya/trunk/src/webapp/lenya/chaperon/stylesheets/a-to-txt.xsl
URL: http://svn.apache.org/viewvc/lenya/trunk/src/webapp/lenya/chaperon/stylesheets/a-to-txt.xsl?view=auto&rev=545437
==============================================================================
--- lenya/trunk/src/webapp/lenya/chaperon/stylesheets/a-to-txt.xsl (added)
+++ lenya/trunk/src/webapp/lenya/chaperon/stylesheets/a-to-txt.xsl Thu Jun  7 23:35:57 2007
@@ -0,0 +1,28 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<xsl:stylesheet version="1.0" 
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+  <xsl:template match="a">
+    <xsl:value-of select="@href"/>
+  </xsl:template>
+  <xsl:template match="@*|*|text()|processing-instruction()" priority="-1">
+    <xsl:copy>
+      <xsl:apply-templates select="@*|*|text()|processing-instruction()"/>
+    </xsl:copy>
+  </xsl:template>
+</xsl:stylesheet>

Added: lenya/trunk/src/webapp/lenya/chaperon/stylesheets/pattern-to-link.xsl
URL: http://svn.apache.org/viewvc/lenya/trunk/src/webapp/lenya/chaperon/stylesheets/pattern-to-link.xsl?view=auto&rev=545437
==============================================================================
--- lenya/trunk/src/webapp/lenya/chaperon/stylesheets/pattern-to-link.xsl (added)
+++ lenya/trunk/src/webapp/lenya/chaperon/stylesheets/pattern-to-link.xsl Thu Jun  7 23:35:57 2007
@@ -0,0 +1,50 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<xsl:stylesheet version="1.0" 
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    xmlns:lex="http://chaperon.sourceforge.net/schema/lexemes/2.0">
+  <xsl:template match="lex:lexeme[@symbol='link']">
+    <xsl:choose>
+<!-- it is possible to disable link writing by prefixing by '\' -->
+      <xsl:when test="not( starts-with( @text, '\') )"><a href="{@text}">
+        <xsl:value-of select="@text"/></a>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="lex:group[2]"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+  <xsl:template match="lex:lexeme[@symbol='email']">
+    <xsl:choose>
+<!-- it is possible to disable link writing by prefixing by '\' -->
+      <xsl:when test="not( starts-with( @text, '\') )"><a href="mailto:{@text}">
+        <xsl:value-of select="lex:group[2]"/> at <xsl:value-of select="lex:group[3]"/></a>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="lex:group[2]"/>@<xsl:value-of select="lex:group[3]"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+  <xsl:template match="lex:lexeme[@symbol='cssurl']"><xsl:value-of select="lex:group[2]"/><a href="{lex:group[3]}"/><xsl:value-of select="lex:group[4]"/>
+  </xsl:template>
+  <xsl:template match="@*|*|text()|processing-instruction()" priority="-1">
+    <xsl:copy>
+      <xsl:apply-templates select="@*|*|text()|processing-instruction()"/>
+    </xsl:copy>
+  </xsl:template>
+</xsl:stylesheet>

Modified: lenya/trunk/src/webapp/lenya/config/sitemap/transformers.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/webapp/lenya/config/sitemap/transformers.xmap?view=diff&rev=545437&r1=545436&r2=545437
==============================================================================
--- lenya/trunk/src/webapp/lenya/config/sitemap/transformers.xmap (original)
+++ lenya/trunk/src/webapp/lenya/config/sitemap/transformers.xmap Thu Jun  7 23:35:57 2007
@@ -28,4 +28,10 @@
        <untranslated-text>untranslated</untranslated-text>
        <cache-at-startup>true</cache-at-startup>
     </map:transformer>
+    <map:transformer name="pattern" 
+       src="org.apache.cocoon.transformation.PatternTransformer" 
+       logger="sitemap.transformer.pattern">
+       <parameter name="groups" value="true"/>
+    </map:transformer>
+    <map:transformer name="proxy" logger="lenya.sitemap.transformer.proxy" src="org.apache.lenya.cms.cocoon.transformation.ProxyTransformer"/>
 </xmap>

Modified: lenya/trunk/src/webapp/lenya/lenya.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/webapp/lenya/lenya.xmap?view=diff&rev=545437&r1=545436&r2=545437
==============================================================================
--- lenya/trunk/src/webapp/lenya/lenya.xmap (original)
+++ lenya/trunk/src/webapp/lenya/lenya.xmap Thu Jun  7 23:35:57 2007
@@ -19,7 +19,30 @@
 <!-- $Id$ -->
 
 <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
-
+  <map:resources>
+    <map:resource name="proxy-css">
+      <map:act type="resource-exists" src="{url}.xml">
+        <map:generate src="{../url}.xml"/>
+        <map:transform src="fallback://lenya/resources/css/css.xsl">
+          <map:parameter name="contextprefix" value="{request:contextPath}"/>
+          <map:parameter name="root"
+            value="{base-url:{page-envelope:publication-id}:{page-envelope:area}:false}"/>
+        </map:transform>
+        <map:call resource="prepare-proxy-css"/>
+      </map:act>
+      <map:generate type="text" src="{url}.css"/>
+      <map:call resource="prepare-proxy-css"/>
+    </map:resource>
+    <map:resource name="prepare-proxy-css">
+      <map:transform type="pattern"
+        src="fallback://lenya/chaperon/grammars/link.xlex"/>
+      <map:transform
+        src="fallback://lenya/chaperon/stylesheets/pattern-to-link.xsl"/>
+      <map:transform type="proxy"/>
+      <map:transform src="fallback://lenya/chaperon/stylesheets/a-to-txt.xsl"/>
+      <map:serialize type="text" mime-type="text/css"/>
+    </map:resource>
+  </map:resources>
   <map:pipelines>
 
     <map:pipeline>
@@ -49,18 +72,9 @@
       </map:match>
 
       <map:match pattern="css/**.css">
-        <map:select type="resource-exists">
-          <map:when test="resources/css/{1}.xml">
-            <map:generate src="resources/css/{1}.xml"/>
-            <map:transform src="resources/css/css.xsl">
-              <map:parameter name="contextprefix" value="{request:contextPath}"/>
-            </map:transform>
-            <map:serialize type="text" mime-type="text/css"/>
-          </map:when>
-          <map:otherwise>
-            <map:read src="resources/css/{1}.css" mime-type="text/css"/> 
-          </map:otherwise>
-        </map:select>
+        <map:call resource="proxy-css">
+           <map:parameter name="url" value="resources/css/{1}"/>
+         </map:call>
       </map:match>
     </map:pipeline>
 

Modified: lenya/trunk/src/webapp/lenya/module-resources.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/webapp/lenya/module-resources.xmap?view=diff&rev=545437&r1=545436&r2=545437
==============================================================================
--- lenya/trunk/src/webapp/lenya/module-resources.xmap (original)
+++ lenya/trunk/src/webapp/lenya/module-resources.xmap Thu Jun  7 23:35:57 2007
@@ -19,7 +19,30 @@
 <!-- $Id: resources-shared.xmap 349588 2005-11-29 02:07:44Z chestnut $ -->
 
 <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
-
+<map:resources>
+    <map:resource name="proxy-css">
+      <map:act type="resource-exists" src="{url}.xml">
+        <map:generate src="{../url}.xml"/>
+        <map:transform src="fallback://lenya/resources/css/css.xsl">
+          <map:parameter name="contextprefix" value="{request:contextPath}"/>
+          <map:parameter name="root"
+            value="{base-url:{page-envelope:publication-id}:{page-envelope:area}:false}"/>
+        </map:transform>
+        <map:call resource="prepare-proxy-css"/>
+      </map:act>
+      <map:generate type="text" src="{url}.css"/>
+      <map:call resource="prepare-proxy-css"/>
+    </map:resource>
+    <map:resource name="prepare-proxy-css">
+      <map:transform type="pattern"
+        src="fallback://lenya/chaperon/grammars/link.xlex"/>
+      <map:transform
+        src="fallback://lenya/chaperon/stylesheets/pattern-to-link.xsl"/>
+      <map:transform type="proxy"/>
+      <map:transform src="fallback://lenya/chaperon/stylesheets/a-to-txt.xsl"/>
+      <map:serialize type="text" mime-type="text/css"/>
+    </map:resource>
+  </map:resources>
   <map:pipelines>
     <map:pipeline internal-only="true">
       <map:match pattern="*/**.*">
@@ -33,14 +56,9 @@
       <!-- matches modules/*/**.css -->
       <map:match pattern="*/**.css">
         <!-- Only called if a {3}.css exists because of resource-exists-enhanced before -->
-        <map:act type="resource-exists" src="fallback://lenya/modules/{1}/resources/{2}.xml">
-          <map:generate src="fallback://lenya/modules/{../1}/resources/{../2}.xml"/>
-          <map:transform src="fallback://lenya/resources/css/css.xsl">
-            <map:parameter name="contextprefix" value="{request:contextPath}"/>
-          </map:transform>
-          <map:serialize type="text" mime-type="text/css"/>
-        </map:act>
-        <map:read src="fallback://lenya/modules/{1}/resources/{2}.css" mime-type="text/css" />
+        <map:call resource="proxy-css">
+           <map:parameter name="url" value="fallback://lenya/modules/{1}/resources/{2}"/>
+         </map:call>
       </map:match>
 
       <!-- matches modules/*/**.js -->

Modified: lenya/trunk/src/webapp/lenya/resources-shared.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/webapp/lenya/resources-shared.xmap?view=diff&rev=545437&r1=545436&r2=545437
==============================================================================
--- lenya/trunk/src/webapp/lenya/resources-shared.xmap (original)
+++ lenya/trunk/src/webapp/lenya/resources-shared.xmap Thu Jun  7 23:35:57 2007
@@ -19,7 +19,33 @@
 <!-- $Id$ -->
 
 <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
-
+  <!--<map:resources>
+    
+  </map:resources>-->
+  <map:resources>
+    <map:resource name="proxy-css">
+      <map:act type="resource-exists" src="{url}.xml">
+        <map:generate src="{../url}.xml"/>
+        <map:transform src="fallback://lenya/resources/css/css.xsl">
+          <map:parameter name="contextprefix" value="{request:contextPath}"/>
+          <map:parameter name="root"
+            value="{base-url:{page-envelope:publication-id}:{page-envelope:area}:false}"/>
+        </map:transform>
+        <map:call resource="prepare-proxy-css"/>
+      </map:act>
+      <map:generate type="text" src="{url}.css"/>
+      <map:call resource="prepare-proxy-css"/>
+    </map:resource>
+    <map:resource name="prepare-proxy-css">
+      <map:transform type="pattern"
+        src="fallback://lenya/chaperon/grammars/link.xlex"/>
+      <map:transform
+        src="fallback://lenya/chaperon/stylesheets/pattern-to-link.xsl"/>
+      <map:transform type="proxy"/>
+      <map:transform src="fallback://lenya/chaperon/stylesheets/a-to-txt.xsl"/>
+      <map:serialize type="text" mime-type="text/css"/>
+    </map:resource>
+  </map:resources>
   <map:pipelines>
     <map:pipeline>
       
@@ -28,29 +54,16 @@
       <!-- only look for inherited css ex: default.css -> @import url(default.inherited.css); -->
       <!-- matches pub-id/area/css/*.inherited.css -->
       <map:match pattern="*/*/css/*.inherited.css">
-        <map:act type="resource-exists" src="template-fallback://resources/shared/css/{3}.xml">
-          <map:generate src="template-fallback://resources/shared/css/{../3}.xml"/>
-          <map:transform src="template-fallback://lenya/resources/css/css.xsl">
-            <map:parameter name="contextprefix" value="{request:contextPath}"/>
-            <map:parameter name="root" value="{base-url:{page-envelope:publication-id}:{page-envelope:area}:false}"/>
-          </map:transform>
-          <map:serialize type="text" mime-type="text/css"/>
-        </map:act>
-        <map:read src="template-fallback://resources/shared/css/{3}.css" mime-type="text/css" />      
+         <map:call resource="proxy-css">
+           <map:parameter name="url" value="template-fallback://resources/shared/css/{3}"/>
+         </map:call>
       </map:match>
       
       <!-- matches pub-id/area/css/*.css -->
       <map:match pattern="*/*/css/*.css">
-        <!-- Only called if a {3}.css exists because of resource-exists-enhanced before -->
-        <map:act type="resource-exists" src="fallback://resources/shared/css/{3}.xml">
-          <map:generate src="fallback://resources/shared/css/{../3}.xml"/>
-          <map:transform src="fallback://lenya/resources/css/css.xsl">
-            <map:parameter name="contextprefix" value="{request:contextPath}"/>
-            <map:parameter name="root" value="{base-url:{page-envelope:publication-id}:{page-envelope:area}:false}"/>
-          </map:transform>
-          <map:serialize type="text" mime-type="text/css"/>
-        </map:act>
-        <map:read src="fallback://resources/shared/css/{3}.css" mime-type="text/css" />
+        <map:call resource="proxy-css">
+           <map:parameter name="url" value="fallback://resources/shared/css/{3}"/>
+         </map:call>
       </map:match>
 
       <!-- matches pub-id/area/javascript/**.inherited.js -->

Modified: lenya/trunk/src/webapp/lenya/resources.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/webapp/lenya/resources.xmap?view=diff&rev=545437&r1=545436&r2=545437
==============================================================================
--- lenya/trunk/src/webapp/lenya/resources.xmap (original)
+++ lenya/trunk/src/webapp/lenya/resources.xmap Thu Jun  7 23:35:57 2007
@@ -19,14 +19,40 @@
 <!-- $Id$ -->
 
 <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
-
+<map:resources>
+    <map:resource name="proxy-css">
+      <map:act type="resource-exists" src="{url}.xml">
+        <map:generate src="{../url}.xml"/>
+        <map:transform src="fallback://lenya/resources/css/css.xsl">
+          <map:parameter name="contextprefix" value="{request:contextPath}"/>
+          <map:parameter name="root"
+            value="{base-url:{page-envelope:publication-id}:{page-envelope:area}:false}"/>
+        </map:transform>
+        <map:call resource="prepare-proxy-css"/>
+      </map:act>
+      <map:generate type="text" src="{url}.css"/>
+      <map:call resource="prepare-proxy-css"/>
+    </map:resource>
+    <map:resource name="prepare-proxy-css">
+      <map:transform type="pattern"
+        src="fallback://lenya/chaperon/grammars/link.xlex"/>
+      <map:transform
+        src="fallback://lenya/chaperon/stylesheets/pattern-to-link.xsl"/>
+      <map:transform type="proxy"/>
+      <map:transform src="fallback://lenya/chaperon/stylesheets/a-to-txt.xsl"/>
+      <map:serialize type="text" mime-type="text/css"/>
+    </map:resource>
+  </map:resources>
   <map:pipelines>
     <map:pipeline>
       
       <!-- Lenya Publications -->      
           <!-- matches pub-id/area/css/*.css -->
           <map:match pattern="*/*/css/*.css">
-            <map:read src="fallback://resources/css/{3}.css" mime-type="text/css" />
+            <map:call resource="proxy-css">
+              <map:parameter name="url"
+                value="fallback://resources/css/{3}"/>
+            </map:call>
           </map:match>
 
           <!-- matches pub-id/area/javascript/**.js -->



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org