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 2005/05/24 16:44:51 UTC

svn commit: r178174 - in /lenya/trunk/src/webapp/lenya/usecases/edit/bxe: ./ addSourceTags.xsl bxe.js bxe.jx removeSourceTags.xsl

Author: andreas
Date: Tue May 24 07:44:50 2005
New Revision: 178174

URL: http://svn.apache.org/viewcvs?rev=178174&view=rev
Log:
added BXE JX template and stylesheets

Added:
    lenya/trunk/src/webapp/lenya/usecases/edit/bxe/
    lenya/trunk/src/webapp/lenya/usecases/edit/bxe/addSourceTags.xsl
    lenya/trunk/src/webapp/lenya/usecases/edit/bxe/bxe.js
    lenya/trunk/src/webapp/lenya/usecases/edit/bxe/bxe.jx
    lenya/trunk/src/webapp/lenya/usecases/edit/bxe/removeSourceTags.xsl

Added: lenya/trunk/src/webapp/lenya/usecases/edit/bxe/addSourceTags.xsl
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/usecases/edit/bxe/addSourceTags.xsl?rev=178174&view=auto
==============================================================================
--- lenya/trunk/src/webapp/lenya/usecases/edit/bxe/addSourceTags.xsl (added)
+++ lenya/trunk/src/webapp/lenya/usecases/edit/bxe/addSourceTags.xsl Tue May 24 07:44:50 2005
@@ -0,0 +1,38 @@
+<?xml version="1.0"?>
+<!--
+  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: addSourceTags.xsl 42703 2004-03-13 12:57:53Z gregor $ -->
+
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+
+<xsl:param name="source"/>
+
+<xsl:template match="/">
+  <open>
+  <source:write xmlns:source="http://apache.org/cocoon/source/1.0">
+    <source:source><xsl:value-of select="$source"/></source:source>
+    <source:fragment>
+      <xsl:copy-of select="."/>
+    </source:fragment>
+  </source:write>
+    <content>
+      <xsl:copy-of select="."/>
+    </content>
+  </open>
+</xsl:template>
+
+</xsl:stylesheet>

Added: lenya/trunk/src/webapp/lenya/usecases/edit/bxe/bxe.js
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/usecases/edit/bxe/bxe.js?rev=178174&view=auto
==============================================================================
--- lenya/trunk/src/webapp/lenya/usecases/edit/bxe/bxe.js (added)
+++ lenya/trunk/src/webapp/lenya/usecases/edit/bxe/bxe.js Tue May 24 07:44:50 2005
@@ -0,0 +1,160 @@
+/*
+ * Copyright  1999-2005 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: usecases.js 161122 2005-04-12 21:16:09Z andreas $ */
+ 
+
+/* Helper method to add all request parameters to a usecase */
+function passRequestParameters(flowHelper, usecase) {
+    var names = cocoon.request.getParameterNames();
+    while (names.hasMoreElements()) {
+        var name = names.nextElement();
+        if (!name.equals("lenya.usecase")
+            && !name.equals("lenya.continuation")
+            && !name.equals("submit")) {
+            
+            var value = flowHelper.getRequest(cocoon).get(name);
+            
+            var string = new Packages.java.lang.String();
+            if (string.getClass().isInstance(value)) {
+                usecase.setParameter(name, value);
+            }
+            else {
+                usecase.setPart(name, value);
+            }
+            
+        }
+    }
+}
+
+
+/* Returns the query string to attach to the target URL. This is used in the site area. */
+function getTargetQueryString(usecaseName) {
+    var isTabUsecase = new Packages.java.lang.String(usecaseName).startsWith('tab');
+    var queryString = "";
+    if (isTabUsecase) {
+        queryString = "?lenya.usecase=" + usecaseName;
+    }
+    return queryString;
+}
+
+
+/*
+ * Start the editing process.
+ */
+function startEditing() {
+    var usecaseName = cocoon.request.getParameter("lenya.usecase");
+    var view;
+    var proxy;
+    
+    var usecaseResolver;
+    var usecase;
+    
+    if (cocoon.log.isDebugEnabled())
+       cocoon.log.debug("usecases.js::executeUsecase() called, parameter lenya.usecase = [" + usecaseName + "]");
+    
+    try {
+        usecaseResolver = cocoon.getComponent("org.apache.lenya.cms.usecase.UsecaseResolver");
+        usecase = usecaseResolver.resolve(usecaseName);
+
+        var flowHelper = cocoon.getComponent("org.apache.lenya.cms.cocoon.flow.FlowHelper");
+        var request = flowHelper.getRequest(cocoon);
+        var sourceUrl = Packages.org.apache.lenya.util.ServletHelper.getWebappURI(request);
+        usecase.setSourceURL(sourceUrl);
+        usecase.setName(usecaseName);
+        view = usecase.getView();
+
+        passRequestParameters(flowHelper, usecase);
+        
+        if (request.getRequestMethod().equalsIgnoreCase("GET")) {
+        }
+        else {
+        }
+        
+        usecase.checkPreconditions();
+        usecase.lockInvolvedObjects();
+        proxy = new Packages.org.apache.lenya.cms.usecase.UsecaseProxy(usecase);
+    }
+    finally {
+        /* done with usecase component, tell usecaseResolver to release it */
+        if (usecaseResolver != null) {
+            if (usecase != null) {
+                usecaseResolver.release(usecase);
+                usecase = undefined;
+            }
+            cocoon.releaseComponent(usecaseResolver);
+        }
+    }
+    
+    try {
+        var viewUri = "view/nomenu/" + view.getTemplateURI();
+        cocoon.sendPage(viewUri, { "usecase" : proxy });
+    }
+    catch (exception) {
+        /* if an exception was thrown by the view, allow the usecase to rollback the transition */
+        try {
+            usecaseResolver = cocoon.getComponent("org.apache.lenya.cms.usecase.UsecaseResolver");
+            usecase = usecaseResolver.resolve(usecaseName);
+            proxy.setup(usecase);
+            usecase.cancel();
+            throw exception;
+        }
+        finally {
+            usecaseResolver.release(usecase);
+            usecase = undefined;
+            cocoon.releaseComponent(usecaseResolver);
+        }
+    }
+}
+
+
+function save() {
+
+    var usecaseName = cocoon.request.getParameter("lenya.usecase");
+    var view;
+    
+    var usecaseResolver;
+    var usecase;
+
+    try {
+        usecaseResolver = cocoon.getComponent("org.apache.lenya.cms.usecase.UsecaseResolver");
+        usecase = usecaseResolver.resolve(usecaseName);
+        proxy.setup(usecase);
+    
+        passRequestParameters(flowHelper, usecase);
+        usecase.advance();
+    
+        var view = usecase.getView();
+        var viewUri = "view/nomenu/" + view.getTemplateURI();
+        cocoon.sendPage(viewUri, { "usecase" : proxy });
+    }
+    catch (exception) {
+        /* if an exception was thrown by the view, allow the usecase to rollback the transition */
+        try {
+            usecaseResolver = cocoon.getComponent("org.apache.lenya.cms.usecase.UsecaseResolver");
+            usecase = usecaseResolver.resolve(usecaseName);
+            proxy.setup(usecase);
+            usecase.cancel();
+            throw exception;
+        }
+        finally {
+            usecaseResolver.release(usecase);
+            usecase = undefined;
+            cocoon.releaseComponent(usecaseResolver);
+        }
+    }
+    
+}

Added: lenya/trunk/src/webapp/lenya/usecases/edit/bxe/bxe.jx
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/usecases/edit/bxe/bxe.jx?rev=178174&view=auto
==============================================================================
--- lenya/trunk/src/webapp/lenya/usecases/edit/bxe/bxe.jx (added)
+++ lenya/trunk/src/webapp/lenya/usecases/edit/bxe/bxe.jx Tue May 24 07:44:50 2005
@@ -0,0 +1,48 @@
+<page:page
+  xmlns:jx="http://apache.org/cocoon/templates/jx/1.0"
+  xmlns:page="http://apache.org/cocoon/lenya/cms-page/1.0"
+  xmlns="http://www.w3.org/1999/xhtml"
+  xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
+  xmlns:cinclude="http://apache.org/cocoon/include/1.0"
+  >
+  
+  <page:head>
+    <link rel="stylesheet" href="${request.getContextPath()}/bxe/css/editor.css" type="text/css"/>
+    <script src="${request.getContextPath()}/bxe/bxeLoader.js" type="text/javascript"/>
+    
+    <meta name="bxeNS" content="xhtml=http://www.w3.org/1999/xhtml"/>
+    <meta name="bxeNS" content="lenya=http://apache.org/cocoon/lenya/page-envelope/1.0"/>
+    <meta name="bxeNS" content="dc=http://purl.org/dc/elements/1.1/"/>
+    <meta name="bxeNS" content="dcterms=http://purl.org/dc/terms/"/>
+  </page:head>
+  
+  <page:title><i18n:text>Bitflux Editor</i18n:text></page:title>
+  
+  <jx:set var="configFile" value="${request.getRequestURI()}"/>
+
+  <jx:choose>
+    <jx:when test="${usecase.hasErrors()}">
+      <page:body>
+        <jx:import uri="templates/messages.jx"/>
+      </page:body>
+    </jx:when>
+    <jx:otherwise>
+      <page:body onload="bxe_start('${configFile}?lenya.usecase=bxe&amp;lenya.step=config&amp;lenya.continuation=${continuation.id}')">
+    
+        <!-- everything in the following div element will be replaced -->
+        <div id="bxe_area">
+        <noscript>
+        <span style='font-family: Arial; padding: 5px; background-color: #ffffff'>
+        You need JavaScript enabled. Otherwise nothing at all works here
+        :)</span></noscript>
+        </div>
+        
+        <!-- another way to do it without having to use xslt
+          <div id="foobar" bxe_xpath="/xhtml:body"></div>
+        -->
+            
+      </page:body>
+    </jx:otherwise>
+  </jx:choose>
+  
+</page:page>
\ No newline at end of file

Added: lenya/trunk/src/webapp/lenya/usecases/edit/bxe/removeSourceTags.xsl
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/usecases/edit/bxe/removeSourceTags.xsl?rev=178174&view=auto
==============================================================================
--- lenya/trunk/src/webapp/lenya/usecases/edit/bxe/removeSourceTags.xsl (added)
+++ lenya/trunk/src/webapp/lenya/usecases/edit/bxe/removeSourceTags.xsl Tue May 24 07:44:50 2005
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<!--
+  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: removeSourceTags.xsl 42703 2004-03-13 12:57:53Z gregor $ -->
+
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+
+<xsl:template match="/">
+  <xsl:copy-of select="/open/content/*"/>
+</xsl:template>
+
+</xsl:stylesheet>



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