You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2006/11/13 19:33:06 UTC

svn commit: r474427 - in /lenya/trunk/src: modules-core/linking/ modules-core/linking/config/cocoon-xconf/ modules-core/linking/java/src/org/apache/lenya/cms/cocoon/components/ modules-core/linking/java/src/org/apache/lenya/cms/cocoon/components/module...

Author: andreas
Date: Mon Nov 13 10:33:05 2006
New Revision: 474427

URL: http://svn.apache.org/viewvc?view=rev&rev=474427
Log:
Introducing linking module to simplify revision control request parameter handling

Added:
    lenya/trunk/src/modules-core/linking/config/cocoon-xconf/linkingmodule.xconf
    lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/components/
    lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/components/modules/
    lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/components/modules/input/
    lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/components/modules/input/LinkingModule.java
Removed:
    lenya/trunk/src/modules-core/linking/sitemap.xmap
Modified:
    lenya/trunk/src/modules/cforms/sitemap.xmap
    lenya/trunk/src/modules/links/sitemap.xmap
    lenya/trunk/src/modules/opendocument/sitemap.xmap
    lenya/trunk/src/modules/xhtml/sitemap.xmap

Added: lenya/trunk/src/modules-core/linking/config/cocoon-xconf/linkingmodule.xconf
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/linking/config/cocoon-xconf/linkingmodule.xconf?view=auto&rev=474427
==============================================================================
--- lenya/trunk/src/modules-core/linking/config/cocoon-xconf/linkingmodule.xconf (added)
+++ lenya/trunk/src/modules-core/linking/config/cocoon-xconf/linkingmodule.xconf Mon Nov 13 10:33:05 2006
@@ -0,0 +1,26 @@
+<?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.
+-->
+
+<!-- $Id: doctypes.xconf 164635 2005-04-25 20:01:43Z tschlabach $ -->
+
+<xconf xpath="/cocoon/input-modules" unless="/cocoon/input-modules/component-instance[@name = 'link']">
+
+  <component-instance logger="core.modules.input.link" name="link"
+    class="org.apache.lenya.cms.cocoon.components.modules.input.LinkingModule"/>
+  
+</xconf>

Added: lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/components/modules/input/LinkingModule.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/components/modules/input/LinkingModule.java?view=auto&rev=474427
==============================================================================
--- lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/components/modules/input/LinkingModule.java (added)
+++ lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/components/modules/input/LinkingModule.java Mon Nov 13 10:33:05 2006
@@ -0,0 +1,59 @@
+/*
+ * 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.
+ *
+ */
+package org.apache.lenya.cms.cocoon.components.modules.input;
+
+import java.util.Map;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.cocoon.components.modules.input.AbstractInputModule;
+import org.apache.cocoon.environment.ObjectModelHelper;
+import org.apache.cocoon.environment.Request;
+
+/**
+ * <p>The linking module is a utility to add parameters to link URLs,
+ * depending on request parameters. Supported attributes:</p>
+ * <ul>
+ * <li><code>rev</code> - inserts the parameter <code>,rev=...</code>
+ * if a request parameter <code>lenya.revision</code> is present.</li>
+ * </ul>
+ */
+public class LinkingModule extends AbstractInputModule {
+    
+    protected static final String ATTRIBUTE_REVISION = "rev";
+    protected static final String REQUEST_PARAM_REVISION = "lenya.revision";
+
+    public Object getAttribute(String name, Configuration modeConf, Map objectModel) throws ConfigurationException {
+        
+        if (name.equals(ATTRIBUTE_REVISION)) {
+            Request request = ObjectModelHelper.getRequest(objectModel);
+            String revision = request.getParameter(REQUEST_PARAM_REVISION);
+            if (revision != null) {
+                return ",rev=" + revision;
+            }
+            else {
+                return "";
+            }
+        }
+        else {
+            throw new ConfigurationException("The attribute [" + name + "] is not supported.");
+        }
+    }
+
+
+}

Modified: lenya/trunk/src/modules/cforms/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/cforms/sitemap.xmap?view=diff&rev=474427&r1=474426&r2=474427
==============================================================================
--- lenya/trunk/src/modules/cforms/sitemap.xmap (original)
+++ lenya/trunk/src/modules/cforms/sitemap.xmap Mon Nov 13 10:33:05 2006
@@ -23,25 +23,11 @@
   <map:pipelines>
 
     <map:pipeline>
-      <!-- View Revision? -->
-      <map:match pattern="*.xml">
-        <map:match type="step" pattern="view-revision">
-          <map:generate type="serverpages" src="fallback://lenya/content/rc/view.xsp">
-          </map:generate>
-          <map:transform src="fallback://lenya/xslt/rc/toDoc.xsl"/>
-          <map:transform src="fallback://lenya/modules/cforms/xslt/cforms2xhtml.xsl">
-            <map:parameter name="rendertype" value="{1}"/>
-            <map:parameter name="nodeid" value="{page-envelope:document-name}"/>
-            <map:parameter name="language" value="{page-envelope:document-language}"/>
-          </map:transform>
-          <map:serialize type="xml"/>
-        </map:match>
-      </map:match>
 
       <!-- parametrized doctype matcher -->
       <!-- pattern="{rendertype}" -->
       <map:match pattern="*.xml">
-        <map:generate src="lenyadoc:/{page-envelope:document-language}/{page-envelope:document-id}"/>
+        <map:generate src="cocoon://modules/linking/current-document.xml"/>
         <map:transform src="fallback://lenya/modules/cforms/xslt/cforms2xhtml.xsl">
           <map:parameter name="rendertype" value="{request-param:rendertype}"/>
           <map:parameter name="nodeid" value="{page-envelope:document-name}"/>

Modified: lenya/trunk/src/modules/links/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/links/sitemap.xmap?view=diff&rev=474427&r1=474426&r2=474427
==============================================================================
--- lenya/trunk/src/modules/links/sitemap.xmap (original)
+++ lenya/trunk/src/modules/links/sitemap.xmap Mon Nov 13 10:33:05 2006
@@ -23,25 +23,11 @@
   <map:pipelines>
 
     <map:pipeline>
-      <!-- View Revision? -->
-      <map:match pattern="*.xml">
-        <map:match type="step" pattern="view-revision">
-          <map:generate type="serverpages" src="fallback://lenya/content/rc/view.xsp">
-          </map:generate>
-          <map:transform src="fallback://lenya/xslt/rc/toDoc.xsl"/>
-          <map:transform src="fallback://lenya/modules/links/xslt/links2xhtml.xsl">
-            <map:parameter name="rendertype" value="{1}"/>
-            <map:parameter name="nodeid" value="{page-envelope:document-name}"/>
-            <map:parameter name="language" value="{page-envelope:document-language}"/>
-          </map:transform>
-          <map:serialize type="xml"/>
-        </map:match>
-      </map:match>
 
       <!-- parametrized doctype matcher -->
       <!-- pattern="{rendertype}" -->
       <map:match pattern="*.xml">
-        <map:generate src="lenyadoc:/{page-envelope:document-language}/{page-envelope:document-id}"/>
+        <map:generate src="cocoon://modules/linking/current-document.xml"/>
         <map:transform src="fallback://lenya/modules/links/xslt/links2xhtml.xsl">
           <map:parameter name="rendertype" value="{request-param:rendertype}"/>
           <map:parameter name="nodeid" value="{page-envelope:document-name}"/>

Modified: lenya/trunk/src/modules/opendocument/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/opendocument/sitemap.xmap?view=diff&rev=474427&r1=474426&r2=474427
==============================================================================
--- lenya/trunk/src/modules/opendocument/sitemap.xmap (original)
+++ lenya/trunk/src/modules/opendocument/sitemap.xmap Mon Nov 13 10:33:05 2006
@@ -21,20 +21,6 @@
   <map:pipelines>
 
     <map:pipeline>
-      <!-- View Revision? -->
-      <map:match pattern="*.xml">
-        <map:match type="step" pattern="view-revision">
-          <map:generate type="serverpages" src="fallback://lenya/content/rc/view.xsp">
-          </map:generate>
-          <map:transform src="fallback://lenya/xslt/rc/toDoc.xsl"/>
-          <map:transform src="fallback://lenya/modules/links/xslt/links2xhtml.xsl">
-            <map:parameter name="rendertype" value="{1}"/>
-            <map:parameter name="nodeid" value="{page-envelope:document-name}"/>
-            <map:parameter name="language" value="{page-envelope:document-language}"/>
-          </map:transform>
-          <map:serialize type="xml"/>
-        </map:match>
-      </map:match>
 
       <!-- webdav GET matcher -->
       <map:match pattern="davget.xml">

Modified: lenya/trunk/src/modules/xhtml/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/xhtml/sitemap.xmap?view=diff&rev=474427&r1=474426&r2=474427
==============================================================================
--- lenya/trunk/src/modules/xhtml/sitemap.xmap (original)
+++ lenya/trunk/src/modules/xhtml/sitemap.xmap Mon Nov 13 10:33:05 2006
@@ -79,7 +79,7 @@
       <!-- parametrized doctype matcher -->
       <!-- pattern="{rendertype}" -->
       <map:match pattern="*.xml">
-        <map:generate src="cocoon://modules/linking/current-document.xml"/>
+        <map:generate src="lenya-document:{page-envelope:document-uuid},lang={page-envelope:document-language}{link:rev}"/>
         <map:transform src="fallback://lenya/modules/xhtml/xslt/xhtml2xhtml.xsl">
           <map:parameter name="rendertype" value="{request-param:rendertype}"/>
           <map:parameter name="nodeid" value="{page-envelope:document-name}"/>



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