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 2007/01/10 15:31:41 UTC

svn commit: r494824 - in /lenya/trunk/src/modules/kupu: kupu.js sitemap.xmap

Author: andreas
Date: Wed Jan 10 06:31:40 2007
New Revision: 494824

URL: http://svn.apache.org/viewvc?view=rev&rev=494824
Log:
Added kupu.js and sitemap.xmap for Kupu. Thanks to Jonathan Addison for the patch. See bug 39890.

Added:
    lenya/trunk/src/modules/kupu/kupu.js
    lenya/trunk/src/modules/kupu/sitemap.xmap

Added: lenya/trunk/src/modules/kupu/kupu.js
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/kupu/kupu.js?view=auto&rev=494824
==============================================================================
--- lenya/trunk/src/modules/kupu/kupu.js (added)
+++ lenya/trunk/src/modules/kupu/kupu.js Wed Jan 10 06:31:40 2007
@@ -0,0 +1,94 @@
+/*
+ * Copyright  1999-2004 The Apache Software Foundation
+ *
+ *  Licensed 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.
+ *
+ */
+
+importClass(Packages.java.util.ArrayList);
+
+importClass(Packages.org.apache.lenya.cms.cocoon.flow.FlowHelper);
+importClass(Packages.org.apache.lenya.cms.publication.util.DocumentHelper);
+importClass(Packages.org.apache.lenya.cms.publication.DefaultResourcesManager);
+
+/**
+ * Kupu usecase flow.
+ * @version $Id$
+ */
+
+/**
+ * Collects all link/url information from a publication's siteree.
+ * This information is used to generate xml for the Kupu (link) library drawer.
+ */
+function sitetree_link_library() {
+    
+    var flowHelper = new FlowHelper();
+    var documentHelper = flowHelper.getDocumentHelper(cocoon);
+    var pageEnvelope = flowHelper.getPageEnvelope(cocoon);
+    var siteTree = pageEnvelope.getPublication().getSiteTree(pageEnvelope.getDocument().getArea());
+    var allNodes = siteTree.getNode("/").preOrder();
+    var resources = new ArrayList(allNodes.size()-1);
+    var addedResourcesCount = 0;
+    
+    for(var i=1; i<allNodes.size(); i++) {
+    	var languageLabel = allNodes.get(i).getLabel(pageEnvelope.getDocument().getLanguage())
+		/* If the current sitree node does not exist in the displayed document's language
+		 * Continue with next node. This is a quick fix for bug #32808.
+		 * Next step would be to offer all links to the available languages.
+		 * by roku 
+		 */
+		if (languageLabel == null) continue;
+		
+        resources.add(addedResourcesCount, {
+                "url" : documentHelper.getDocumentUrl(allNodes.get(i).getAbsoluteId(), pageEnvelope.getDocument().getArea(), null),
+                "label" : languageLabel.getLabel(),
+                "id" : allNodes.get(i).getId(),
+                "fullid" : allNodes.get(i).getAbsoluteId(),
+                "language" : pageEnvelope.getDocument().getLanguage()});
+        addedResourcesCount++;
+    }
+    
+    cocoon.sendPage("sitetree_link_library_template", {"resources" : resources});
+}
+
+/**
+ * Collects infos about all image resources in a publication.
+FIXME PublicationHelper does no longer exist
+function publication_image_library() {        
+    var pageEnvelope = new FlowHelper().getPageEnvelope(cocoon);
+    var pubHelper = new PublicationHelper(pageEnvelope.getPublication());
+    var allDocs = pubHelper.getAllDocuments(pageEnvelope.getDocument().getArea(), pageEnvelope.getDocument().getLanguage());
+    var imageInfos = new ArrayList();
+    
+    for(var i=0; i<allDocs.length; i++) {
+        if(allDocs[i].getId().equals(pageEnvelope.getDocument().getId()))
+            continue;
+        var resourcesMgr = new DefaultResourcesManager(allDocs[i]);
+        var imageResources = resourcesMgr.getImageResources();
+        
+        for(var j=0; j<imageResources.length; j++) {
+            var metaDoc = org.apache.lenya.xml.DocumentHelper.readDocument(resourcesMgr.getMetaFile(imageResources[j]));
+            var title = metaDoc.getElementsByTagNameNS("http://purl.org/dc/elements/1.1/", "title").item(0).getChildNodes().item(0).getNodeValue();
+            
+            imageInfos.add({
+                    "url" : pageEnvelope.getContext() + "/" + resourcesMgr.getResourceUrl(imageResources[j]),
+                    "name" : imageResources[j].getName(),
+                    "title" : title,
+                    "length" : imageResources[j].length(),
+                    "iconUrl" : cocoon.parameters["iconUrl"]
+            });
+        }
+    }
+    cocoon.sendPage(cocoon.parameters["template"], {"imageInfos" : imageInfos});
+}
+*/
\ No newline at end of file

Added: lenya/trunk/src/modules/kupu/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/kupu/sitemap.xmap?view=auto&rev=494824
==============================================================================
--- lenya/trunk/src/modules/kupu/sitemap.xmap (added)
+++ lenya/trunk/src/modules/kupu/sitemap.xmap Wed Jan 10 06:31:40 2007
@@ -0,0 +1,230 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed 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: sitemap.xmap 423198 2006-07-18 18:52:43Z chestnut $ -->
+
+<!--
+  Kupu usecase sitemaps. Integrates the Kupu editor (http://kupu.oscom.org/) into Lenya.
+  Most matchers serve as callbacks for Kupu running in a client's browser.
+  Make sure that Kupu is installed under lenya/resources/kupu.
+  
+  Most of (re)sources used in generators and transfomers of this sitemap
+  are located in the Kupu distribution.
+  
+  Enjoy using Kupu.
+-->
+
+<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+  <!-- =========================== Components ================================ -->
+  <map:components/>
+  <!-- =========================== Resources ================================= -->
+
+  <map:resources>
+    <map:resource name="style-cms-page">
+      <map:transform type="i18n">      
+        <map:parameter name="locale" value="{request:locale}"/>
+      </map:transform>    
+      <map:transform src="fallback://lenya/xslt/util/page2xhtml.xsl">
+        <map:parameter name="contextprefix" value="{request:contextPath}"/>
+      </map:transform>
+      <map:transform src="fallback://lenya/xslt/util/strip_namespaces.xsl"/>
+    </map:resource>
+  </map:resources>
+  
+  <!-- =========================== Flow ===================================== -->
+  <map:flow language="javascript">
+    <map:script src="kupu.js"/>
+    <map:script src="fallback://lenya/usecases/edit-document.js"/>
+  </map:flow>
+  <!-- =========================== Pipelines ================================ -->  
+  <map:pipelines>
+    
+    <map:component-configurations>
+      <global-variables>
+        <resourceIconUrl>kupu/apache-lenya/kupu/images/right_arrow.png</resourceIconUrl>
+      </global-variables>
+    </map:component-configurations>
+
+
+    <map:pipeline internal-only="true">
+      <map:match pattern="kupu-stream">
+        <map:generate type="stream"/>
+        <map:serialize type="xml"/>
+      </map:match>
+      
+      <!-- Flow callbacks -->
+      <map:match pattern="sitetree_link_library_template">
+        <map:generate src="fallback://lenya/modules/kupu/resources/kupu/apache-lenya/lenya/drawers/sitetree_link_library.xml.jx" type="jx">
+          <map:parameter name="resource-icon-url" value="{page-envelope:context-prefix}/kupu/apache-lenya/kupu/images/right_arrow.png"/>
+        </map:generate>
+        <map:serialize type="xml"/>
+      </map:match>      
+      <map:match pattern="publication_image_library_template">
+        <map:generate src="fallback://lenya/modules/kupu/resources/kupu/apache-lenya/lenya/drawers/publication_image_library.xml.jx" type="jx">
+          <map:parameter name="resource-icon-url" value="{page-envelope:context-prefix}/{global:resourceIconUrl}"/>
+        </map:generate>
+        <map:serialize type="xml"/>
+      </map:match>      
+      <map:match pattern="request2document">
+        <map:aggregate element="edit-envelope">
+          <map:part element="edited" src="cocoon:/kupu-stream"/>
+          <map:part element="original" 
+              src="lenyadoc:/{page-envelope:document-language}/{page-envelope:document-uuid}"/>
+        </map:aggregate>              
+        <map:transform src="fallback://lenya/modules/kupu/resources/kupu/apache-lenya/lenya/kupusave.xsl"/>
+        <map:serialize type="xml"/>
+      </map:match>
+    </map:pipeline>   
+    
+    <map:pipeline>           
+        <map:match pattern="open" type="step">
+          <map:match pattern="*/authoring/**.html">
+            <!-- Check if Kupu is installed -->
+            <map:act type="resource-exists" 
+              src="fallback://lenya/modules/kupu/resources/kupu/apache-lenya/kupu/kupumacros.html">
+              <map:act type="reserved-checkout">
+                <map:generate type="serverpages" 
+                  src="fallback://lenya/content/rc/{exception}.xsp">
+                  <map:parameter name="user" value="{user}"/>
+                  <map:parameter name="filename" value="{filename}"/>
+                  <map:parameter name="date" value="{date}"/>
+                  <map:parameter name="message" value="{message}"/>
+                </map:generate>
+                <map:transform src="fallback://lenya/xslt/rc/rco-exception.xsl"/>
+                <map:call resource="style-cms-page"/>
+                <map:serialize />
+              </map:act>
+              <map:generate 
+                src="fallback://lenya/modules/kupu/resources/kupu/apache-lenya/kupu/kupumacros.html"/>
+              <map:transform src="fallback://lenya/modules/kupu/resources/kupu/apache-lenya/lenya/kupumacros.xsl">
+                <map:parameter name="contentfile" 
+                  value="{request:requestURI}?lenya.module=kupu&amp;lenya.step=content"/>
+                <map:parameter name="context-prefix" value="{request:contextPath}/{page-envelope:publication-id}/modules/kupu"/>
+                <!-- Only used to display the document path of the edited doc  -->
+                <map:parameter name="document-path" value="{page-envelope:document-path}"/>
+                <map:parameter name="save-destination" 
+                  value="{request:requestURI}"/>
+                <map:parameter name="exit-destination" 
+                  value="{request:requestURI}?lenya.module=kupu&amp;lenya.step=exit"/>
+                <map:parameter name="reload-after-save" value="1"/>
+                <map:parameter name="use-css" value="1"/>
+                <map:parameter name="imagedrawer-xsl-uri" 
+                  value="{request:requestURI}?lenya.module=kupu&amp;lenya.step=imagedrawerxsl"/>
+                <map:parameter name="linkdrawer-xsl-uri" 
+                  value="{request:requestURI}?lenya.module=kupu&amp;lenya.step=linkdrawerxsl"/>
+                <map:parameter name="image-libraries-uri" 
+                  value="{request:requestURI}?lenya.module=kupu&amp;lenya.step=image_libraries"/>
+                <map:parameter name="link-libraries-uri" 
+                  value="{request:requestURI}?lenya.module=kupu&amp;lenya.step=link_libraries"/>
+              </map:transform>
+              <map:serialize type="xhtml"/>
+            </map:act>
+            <!-- If Kupu is not installed; Action failed -->
+            <map:generate src="fallback://lenya/resources/misc/kupu/download.xhtml"/>
+            <map:call resource="style-cms-page"/>
+            <map:serialize />
+          </map:match>
+        </map:match>
+        <!-- Requested by Kupu to load the document into the editor -->    
+        <map:match pattern="content" type="step">
+          <map:match pattern="*/authoring/**">
+            <map:generate src="lenyadoc:/{page-envelope:document-language}/{page-envelope:document-uuid}"/>
+            <map:transform 
+              src="fallback://lenya/modules/kupu/resources/kupu/apache-lenya/lenya/content2edit.xsl">
+              <map:parameter name="css" 
+                value="{page-envelope:context-prefix}/{1}/authoring/css/page.css"/>
+              <map:parameter name="nodeid" value="{page-envelope:document-name}"/>
+            </map:transform>
+            <map:transform src="fallback://lenya/xslt/util/strip_namespaces.xsl"/>
+              <map:serialize type="xhtml"/>
+          </map:match>            
+        </map:match>
+        
+        <!-- Kupu Image Drawer -->
+        <map:match pattern="*drawerxsl" type="step">
+          <map:generate type="jx" src="fallback://lenya/modules/kupu/resources/kupu/apache-lenya/lenya/drawers/{1}drawer.xsl">
+            <!-- We need to use the hole uri scheme i.e. http://servername:port/, since IE xslt processor  
+                 throws an access violation upon loading of xslts from the internet.
+             -->
+            <map:parameter name="import-stylesheet-url"
+              value="{request:scheme}://{request:serverName}:{request:serverPort}{page-envelope:context-prefix}/kupu/common/kupudrawers/drawer.xsl"/>
+          </map:generate>  
+          <map:serialize type="xml"/>
+        </map:match>
+        
+        <map:match pattern="image_libraries" type="step">
+          <map:generate src="fallback://lenya/modules/kupu/resources/kupu/apache-lenya/lenya/drawers/imagelibraries.xml.jx" type="jx">
+            <map:parameter name="pubLibUrl" value="{request:requestURI}?lenya.usecase=kupu&amp;lenya.step=publication_image_library"/>
+            <map:parameter name="pageLibUrl" value="{request:requestURI}?lenya.usecase=kupu&amp;lenya.step=page_image_library"/>
+            <map:parameter name="imageBaseUrl" value="{page-envelope:context-prefix}/kupu/apache-lenya/kupu/images"/>
+          </map:generate>
+          <map:serialize type="xml"/>
+        </map:match>
+        <map:match pattern="link_libraries" type="step">
+          <map:generate src="fallback://lenya/modules/kupu/resources/kupu/apache-lenya/lenya/drawers/linklibraries.xml.jx" type="jx">
+            <map:parameter name="pubLibUrl" value="{request:requestURI}?lenya.usecase=kupu&amp;lenya.step=sitetree_link_library"/>
+            <map:parameter name="pageLibUrl" value="{request:requestURI}?lenya.usecase=kupu&amp;lenya.step=other_link_library"/>
+            <map:parameter name="imageBaseUrl" value="{page-envelope:context-prefix}/kupu/apache-lenya/kupu/images"/>
+          </map:generate>
+          <map:serialize type="xml"/>
+        </map:match>
+                  
+        <map:match pattern="page_image_library" type="step">
+          <map:generate src="fallback://lenya/content/info/assets.xsp" type="serverpages"/>
+          <map:transform src="fallback://lenya/modules/kupu/resources/kupu/apache-lenya/lenya/pageassets2kupulibrary.xsl">
+            <map:parameter name="iconUrl" value="{page-envelope:context-prefix}/{global:resourceIconUrl}"/>
+            <map:parameter name="resource-path-url" value="{page-envelope:document-id}/"/>
+          </map:transform>
+          <map:serialize type="xml"/>            
+        </map:match>
+        <map:match pattern="sitetree_link_library" type="step">
+          <map:call function="sitetree_link_library"/>
+        </map:match>        
+        <map:match pattern="publication_image_library" type="step">
+          <map:call function="publication_image_library">
+            <map:parameter name="template" value="publication_image_library_template"/>
+            <map:parameter name="iconUrl" value="{page-envelope:context-prefix}/{global:resourceIconUrl}"/>
+          </map:call>
+        </map:match>
+        
+        <map:match pattern="*_library" type="step">
+          <map:generate src="fallback://lenya/modules/kupu/resources/kupu/apache-lenya/lenya/drawers/{1}_library.xml.jx" type="jx"/>
+          <map:serialize type="xml"/>
+        </map:match>
+        <!-- /Kupu Image Drawer -->  
+        
+        <!-- Checkin document on exit and trigger workflow -->
+        <map:match pattern="exit" type="step">
+          <map:act type="reserved-checkin">
+            <map:generate src="fallback://lenya/content/rc/{exception}.xsp" type="serverpages">
+              <map:parameter name="user" value="{user}"/>
+              <map:parameter name="filename" value="{filename}"/>
+              <map:parameter name="checkType" value="{checkType}"/>
+              <map:parameter name="date" value="{date}"/>
+              <map:parameter name="message" value="{message}"/>
+            </map:generate>
+            <map:transform src="fallback://lenya/xslt/rc/rco-exception.xsl"/>
+            <map:call resource="style-cms-page"/>
+            <map:serialize />
+          </map:act>
+          <map:redirect-to uri="{request:requestURI}"/>
+        </map:match>
+      
+    </map:pipeline>
+  </map:pipelines>
+
+</map:sitemap>
\ No newline at end of file



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