cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r292992 - in /cocoon/whiteboard/example-apps/bricks-cms/src: cocoon/webapp/bricks-cms/admin/document-editor/ cocoon/webapp/bricks-cms/admin/document-editor/flow/ cocoon/webapp/bricks-cms/admin/document-editor/forms/ cocoon/webapp/bricks-cms...
Date Sat, 01 Oct 2005 16:06:10 GMT
Author: bdelacretaz
Date: Sat Oct  1 09:05:52 2005
New Revision: 292992

URL: http://svn.apache.org/viewcvs?rev=292992&view=rev
Log:
Search function implemented, improved navigation when editing documents

Added:
    cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/document-editor/flow/search.js
    cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/document-editor/view/search-results.jx.xml
    cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/xslt/search-results-to-page.xsl
Modified:
    cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/document-editor/document-editor-homepage.xml
    cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/document-editor/forms/document-template.xml
    cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/document-editor/sitemap.xmap
    cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/document-editor/view/document.jx.xml
    cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/static-content/pages/admin-homepage.xml
    cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/static-content/resources/css/bricks-cms.css
    cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/objectstore/ObjectStore.java
    cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/objectstore/impl/OjbObjectStore.java

Modified: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/document-editor/document-editor-homepage.xml
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/document-editor/document-editor-homepage.xml?rev=292992&r1=292991&r2=292992&view=diff
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/document-editor/document-editor-homepage.xml
(original)
+++ cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/document-editor/document-editor-homepage.xml
Sat Oct  1 09:05:52 2005
@@ -28,28 +28,9 @@
 
   <content>
     <p>
-      To create a document use
-      the <a href="create">create</a> link.
-    </p>
-    <p class="note">
-      Document 1 is not created automatically, for now you have to create a document
-      using the above link, and use the ID of the created document instead
-      of 1.
-    </p>
-
-    <p>
-      To edit an existing document use
-      the <a href="edit/1">edit/1</a>, where 1 is
-      the document ID.
-    </p>
-    <p>
-      To view an existing document use
-      the <a href="view/1">view/1</a>, where 1 is
-      the document ID.
-    </p>
-    <p>
-      In real life we'd add a search page to select the
-      document to edit...maybe later;-)
+      Here you can 
+      <a href="search">search</a> for existing documents, or 
+      <a href="create">create</a> new ones.
     </p>
   </content>
 </page>

Added: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/document-editor/flow/search.js
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/document-editor/flow/search.js?rev=292992&view=auto
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/document-editor/flow/search.js
(added)
+++ cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/document-editor/flow/search.js
Sat Oct  1 09:05:52 2005
@@ -0,0 +1,34 @@
+/*
+    Copyright 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.
+*/
+
+// document search flowscript
+
+cocoon.load("context://bricks-cms/common/component-manager.js");
+
+// search documents
+function searchDocuments() {
+    var displayURI = cocoon.parameters.displayURI;
+    
+    var objectStore = get_objectStore();
+	var queryParameters = objectStore.createParameters();
+	// TODO here we would set query parameters from our request
+	var resultSet = objectStore.runQuery(queryParameters);
+    
+    cocoon.sendPage(
+    		displayURI,
+    		{ "data" : resultSet }
+    );
+}
\ No newline at end of file

Modified: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/document-editor/forms/document-template.xml
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/document-editor/forms/document-template.xml?rev=292992&r1=292991&r2=292992&view=diff
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/document-editor/forms/document-template.xml
(original)
+++ cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/document-editor/forms/document-template.xml
Sat Oct  1 09:05:52 2005
@@ -36,7 +36,7 @@
     </title>
     <menu>
       <item>
-        <a href="../">cancel</a>
+        <a href="search">cancel</a>
       </item>
     </menu>
   </metadata>

Modified: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/document-editor/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/document-editor/sitemap.xmap?rev=292992&r1=292991&r2=292992&view=diff
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/document-editor/sitemap.xmap
(original)
+++ cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/document-editor/sitemap.xmap
Sat Oct  1 09:05:52 2005
@@ -25,8 +25,15 @@
   xmlns:map="http://apache.org/cocoon/sitemap/1.0"
   >
 
+  <map:views>
+	  <map:view name="data" from-label="data">
+		<map:serialize type="xml"/>	  
+	  </map:view>
+  </map:views>
+  
   <map:flow language="javascript">
     <map:script src="flow/document-editor.js"/>
+    <map:script src="flow/search.js"/>
   </map:flow>
 
   <map:resources>
@@ -86,6 +93,12 @@
           <map:parameter name="displayURI" value="document-display"/>
         </map:call>
       </map:match>
+      
+      <map:match pattern="search">
+        <map:call function="searchDocuments">
+          <map:parameter name="displayURI" value="search-results-display"/>
+        </map:call>
+      </map:match>
     </map:pipeline>
 
     <map:pipeline internal-only="true">
@@ -98,8 +111,18 @@
         <map:serialize type="html"/>
       </map:match>
 
-      <map:match pattern="document-display">
-        <map:generate type="jx" src="view/document.jx.xml"/>
+	  <!-- generic data display using JXTemplates, with optional XSLT filter -->
+      <map:match pattern="*-display">
+        <!-- dump data using JXTemplates -->
+        <map:generate label="data" type="jx" src="view/{1}.jx.xml"/>
+        
+        <!-- if we have an XSLT filter having the appropriate name, apply it -->
+        <map:act type="resource-exists">
+          <map:parameter name="url" value="../xslt/{1}-to-page.xsl"/>
+          <map:transform src="../xslt/{../1}-to-page.xsl"/>
+        </map:act>
+        
+        <!-- and use our standard layout -->
         <map:call resource="layout"/>
       </map:match>
 

Modified: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/document-editor/view/document.jx.xml
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/document-editor/view/document.jx.xml?rev=292992&r1=292991&r2=292992&view=diff
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/document-editor/view/document.jx.xml
(original)
+++ cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/document-editor/view/document.jx.xml
Sat Oct  1 09:05:52 2005
@@ -29,18 +29,13 @@
         <a href="../edit/#{document/id}">edit</a>
       </item>
       <item>
-        <a href="../">cancel</a>
+        <a href="../search">search</a>
       </item>
     </menu>
   </metadata>
 
   <content>
     <page>
-      <p class="note">
-        This is document
-        <b>#{document/id}</b>,
-        you might want to note this ID for further testing.
-      </p>
       <div class="content">
 	      #{wikiText}
       </div>

Added: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/document-editor/view/search-results.jx.xml
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/document-editor/view/search-results.jx.xml?rev=292992&view=auto
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/document-editor/view/search-results.jx.xml
(added)
+++ cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/document-editor/view/search-results.jx.xml
Sat Oct  1 09:05:52 2005
@@ -0,0 +1,32 @@
+<?xml version="1.0"?>
+
+<!--
+  Copyright 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.
+-->
+
+<!--
+  JXTemplate used to dump the results of a query on BricksDocuments
+  $Id: document.jx.xml 292989 2005-10-01 16:39:33 +0200 (sam., 01 oct. 2005) bdelacretaz
$
+-->
+
+<search-results xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
+	<jx:forEach select="#{data}">
+		<document id="#{id}">
+			<title>#{title}</title>
+			<created>#{created}</created>
+			<last-modified>#{lastModified}</last-modified>
+		</document>
+	</jx:forEach>
+</search-results>
\ No newline at end of file

Modified: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/static-content/pages/admin-homepage.xml
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/static-content/pages/admin-homepage.xml?rev=292992&r1=292991&r2=292992&view=diff
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/static-content/pages/admin-homepage.xml
(original)
+++ cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/static-content/pages/admin-homepage.xml
Sat Oct  1 09:05:52 2005
@@ -22,7 +22,7 @@
 -->       
 <page>
   <metadata>
-    <title>bricks-cms admin homepage</title>
+    <title>bricks-cms V0.5 admin homepage</title>
   </metadata>
 
   <content>

Modified: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/static-content/resources/css/bricks-cms.css
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/static-content/resources/css/bricks-cms.css?rev=292992&r1=292991&r2=292992&view=diff
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/static-content/resources/css/bricks-cms.css
(original)
+++ cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/static-content/resources/css/bricks-cms.css
Sat Oct  1 09:05:52 2005
@@ -64,4 +64,17 @@
 
 td {
 	vertical-align: top;
-}	
\ No newline at end of file
+}	
+
+thead tr
+{
+    font-size: 80%;
+    color: #FFCC00;
+    background-color:#333333;
+    padding: 2px;
+}
+
+.evenRow
+{
+    background-color: #FFFFCC;
+}
\ No newline at end of file

Added: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/xslt/search-results-to-page.xsl
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/xslt/search-results-to-page.xsl?rev=292992&view=auto
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/xslt/search-results-to-page.xsl
(added)
+++ cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/xslt/search-results-to-page.xsl
Sat Oct  1 09:05:52 2005
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  Copyright 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.
+-->
+
+<!--
+    Convert search results (output by a JXTemplate) to one of our <page>
+    $Id: page-to-html.xsl,v 1.2 2005/09/26 19:33:15 bdelacretaz Exp $
+-->
+
+<xsl:stylesheet version="1.0"
+	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+	xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
+>
+
+  <xsl:param name="docUrlPrefix" select="'view/'"/>
+  
+  <xsl:template match="/">
+	<page xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
+	  <metadata>
+	    <title><i18n:text>search-results-page-title</i18n:text></title>
+	    <menu>
+	      <item>
+	        <a href="create">create document</a>
+	      </item>
+	      <item>
+	        <a href="../">menu</a>
+	      </item>
+	    </menu>
+	  </metadata>
+	  
+	  <content>
+	    <table width="100%">
+	      <thead>
+	        <tr>
+		    	  <td>Id</td>	
+		    	  <td>Title</td>	
+		    	  <td>Created</td>	
+		    	  <td>Last Modified</td>	
+	        </tr>
+	      </thead>
+	      <tbody>
+		    <xsl:apply-templates/>
+	      </tbody>
+	    </table>
+	  </content>
+	</page>
+  </xsl:template>
+  
+  <xsl:template match="document">
+    <tr>
+      <xsl:if test="position() mod 2 = 0">
+        <xsl:attribute name="class">evenRow</xsl:attribute>
+      </xsl:if>
+      
+    	  <td>
+    	    <a href="{concat($docUrlPrefix,@id)}">
+      	  <xsl:value-of select="@id"/>
+    	    </a>
+    	  </td>	
+    	  <td><xsl:value-of select="title"/></td>	
+    	  <td><xsl:value-of select="created"/></td>	
+    	  <td><xsl:value-of select="last-modified"/></td>	
+    </tr>
+  </xsl:template>
+  
+</xsl:stylesheet>

Modified: cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/objectstore/ObjectStore.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/objectstore/ObjectStore.java?rev=292992&r1=292991&r2=292992&view=diff
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/objectstore/ObjectStore.java
(original)
+++ cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/objectstore/ObjectStore.java
Sat Oct  1 09:05:52 2005
@@ -16,6 +16,11 @@
 
 package org.apache.cocoon.apps.bricks.cms.objectstore;
 
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+
+/** Store and retrieve java objects */
 public interface ObjectStore {
 
     /** data objects implement this to provide a key object for retrieval */
@@ -34,4 +39,16 @@
 
     /** create an empty object of the given class */
     Object createNew(Class clazz) throws Exception;
+
+    /** query parameters */
+	public static interface QueryParameters extends Map {
+	}
+	
+	/** Build a QueryParameters which is appropriate for this ObjectStore */
+	QueryParameters createParameters();
+	
+	/** Run a query and return results
+	 * 	TODO should implement result set paging
+	 */
+	Collection runQuery(QueryParameters params) throws Exception;
 }

Modified: cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/objectstore/impl/OjbObjectStore.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/objectstore/impl/OjbObjectStore.java?rev=292992&r1=292991&r2=292992&view=diff
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/objectstore/impl/OjbObjectStore.java
(original)
+++ cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/objectstore/impl/OjbObjectStore.java
Sat Oct  1 09:05:52 2005
@@ -16,16 +16,26 @@
 
 package org.apache.cocoon.apps.bricks.cms.objectstore.impl;
 
+import java.util.Collection;
+import java.util.HashMap;
+
 import org.apache.commons.logging.Log;
 import org.apache.ojb.broker.PersistenceBroker;
+import org.apache.ojb.broker.query.Criteria;
+import org.apache.ojb.broker.query.QueryByCriteria;
 import org.apache.ojb.broker.query.QueryByIdentity;
 import org.apache.ojb.broker.query.Query;
+import org.apache.cocoon.apps.bricks.cms.data.BricksDocument;
 import org.apache.cocoon.apps.bricks.cms.ojb.OjbTransactionHelper;
 import org.apache.cocoon.apps.bricks.cms.objectstore.ObjectStore;
 
 public class OjbObjectStore implements ObjectStore {
     private Log log;
 
+    /** we don't use these parameters yet, so this is simplistic */
+    static class QueryParametersImpl extends HashMap implements QueryParameters {
+    }
+    
     public void setLog(Log log) {
         this.log = log;
     }
@@ -96,4 +106,34 @@
         }
         return result;
     }
+
+	/** Build a QueryParameters which is appropriate for this ObjectStore */
+	public QueryParameters createParameters() {
+		return new QueryParametersImpl();
+	}
+
+	/** Run a query and return results
+	 * 	TODO should use parameters, for now queries return all objects!
+	 * 	TODO should implement result set paging
+	 */
+	public Collection runQuery(QueryParameters params) throws Exception {
+		final Criteria c = new Criteria();
+		final QueryByCriteria q = new QueryByCriteria(BricksDocument.class,c);
+		
+		final OjbTransactionHelper t = new OjbTransactionHelper() {
+			protected void runTransaction(PersistenceBroker broker) throws Exception {
+				setResult(broker.getCollectionByQuery(q));
+			}
+		};
+		t.execute();
+		
+		final Collection result = (Collection)t.getResult();
+		
+		if(log.isDebugEnabled()) {
+			final int size = (result == null ? 0 : result.size());
+			log.debug("runQuery (" + params + ") returns " + size +" results");
+		}
+		
+		return result;
+	}
 }



Mime
View raw message