cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r331752 - in /cocoon/blocks: portal-sample/trunk/samples/ portal-sample/trunk/samples/conf/ portal/trunk/java/org/apache/cocoon/portal/components/modules/input/ portal/trunk/java/org/apache/cocoon/portal/transformation/
Date Tue, 08 Nov 2005 09:28:21 GMT
Author: cziegeler
Date: Tue Nov  8 01:28:08 2005
New Revision: 331752

URL: http://svn.apache.org/viewcvs?rev=331752&view=rev
Log:
Provide new div based skin and enable ajax support

Modified:
    cocoon/blocks/portal-sample/trunk/samples/conf/cocoon-portal-sample.xconf
    cocoon/blocks/portal-sample/trunk/samples/sitemap.xmap
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/components/modules/input/AbstractModule.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/components/modules/input/CopletModule.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/components/modules/input/LayoutModule.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/components/modules/input/SkinModule.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/CopletTransformer.java

Modified: cocoon/blocks/portal-sample/trunk/samples/conf/cocoon-portal-sample.xconf
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal-sample/trunk/samples/conf/cocoon-portal-sample.xconf?rev=331752&r1=331751&r2=331752&view=diff
==============================================================================
--- cocoon/blocks/portal-sample/trunk/samples/conf/cocoon-portal-sample.xconf (original)
+++ cocoon/blocks/portal-sample/trunk/samples/conf/cocoon-portal-sample.xconf Tue Nov  8 01:28:08
2005
@@ -54,6 +54,9 @@
     <portal name="portal">
       <!-- These are the skins the user can choose from: -->
       <skins>
+        <skin name="modern" base-path="skins/modern">
+          <thumbnail-path>images/thumb.jpg</thumbnail-path>
+        </skin>
         <skin name="basic" base-path="skins/basic">
           <thumbnail-path>images/thumb.jpg</thumbnail-path>
         </skin>
@@ -62,6 +65,10 @@
         </skin>
       </skins>
     </portal>
+    <!-- Configuration: -->
+    <configuration>
+      <use-ajax>true</use-ajax>
+    </configuration>
   </portal-service>
 
   <!--  This is the profile manager using pipelines to load the various parts. -->

Modified: cocoon/blocks/portal-sample/trunk/samples/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal-sample/trunk/samples/sitemap.xmap?rev=331752&r1=331751&r2=331752&view=diff
==============================================================================
--- cocoon/blocks/portal-sample/trunk/samples/sitemap.xmap (original)
+++ cocoon/blocks/portal-sample/trunk/samples/sitemap.xmap Tue Nov  8 01:28:08 2005
@@ -84,7 +84,7 @@
     <map:component-configurations>
       <!-- select skin to use -->
       <map:global-variables>
-		<skin>common</skin>
+		<skin>modern</skin>
     	<mainTitle>Cocoon Portal</mainTitle>
 	    <toolsTitle>Cocoon Portal Tools</toolsTitle>
       </map:global-variables>
@@ -127,6 +127,34 @@
       </map:match>
     </map:pipeline>
 
+    <!-- The pipelines for the skin resources, like images, css etc. 
+         No caching and no output buffering for these resources as these are static files.
+      -->
+    <map:pipeline type="noncaching">
+      <map:parameter name="outputBufferSize" value="0"/>
+
+      <map:match pattern="skin/*/**.gif">
+        <map:read mime-type="image/gif" src="{portal-skin:{1}:skin.basepath}/{2}.gif"/>
+      </map:match>
+      <map:match pattern="skin/*/**.jpg">
+        <map:read mime-type="image/jpg" src="{portal-skin:{1}:skin.basepath}/{2}.jpg"/>
+      </map:match>
+      <map:match pattern="skin/*/**.css">
+        <map:read mime-type="text/css" src="{portal-skin:{1}:skin.basepath}/{2}.css"/>
+      </map:match>
+      <map:match pattern="skin/*/**.js">
+        <map:read src="{portal-skin:{1}:skin.basepath}/{2}.js"/>
+      </map:match>
+
+      <map:match pattern="resources/ajax/js/cocoon-ajax.js">
+        <map:read src="resource://org/apache/cocoon/ajax/resources/js/cocoon-ajax.js"/>
+      </map:match>
+      <map:match pattern="resources/portal/js/cocoon-portal.js">
+        <map:read src="resource://org/apache/cocoon/portal/resources/js/cocoon-portal.js"/>
+      </map:match>
+
+    </map:pipeline>
+
     <!-- Now the accessible pipelines -->
     <map:pipeline>
 
@@ -203,6 +231,7 @@
                 <map:parameter name="user" value="{ID}"/>
                 <map:parameter name="title" value="{global:mainTitle}"/>
                 <map:parameter name="base" value="{portalpath:relative}"/>
+                <map:parameter name="skin" value="{portal-skin:skin}"/>
               </map:transform>
               <map:transform type="cinclude"/>
               <map:transform type="portal-coplet"/>

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/components/modules/input/AbstractModule.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/components/modules/input/AbstractModule.java?rev=331752&r1=331751&r2=331752&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/components/modules/input/AbstractModule.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/components/modules/input/AbstractModule.java
Tue Nov  8 01:28:08 2005
@@ -19,6 +19,7 @@
 import java.util.Iterator;
 import java.util.Map;
 
+import org.apache.avalon.framework.activity.Disposable;
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.avalon.framework.service.ServiceException;
@@ -26,33 +27,47 @@
 import org.apache.avalon.framework.service.Serviceable;
 import org.apache.avalon.framework.thread.ThreadSafe;
 import org.apache.cocoon.components.modules.input.InputModule;
+import org.apache.cocoon.portal.PortalService;
 
 /**
  * @version $Id$
  */
 public abstract class AbstractModule 
-implements InputModule, Serviceable, ThreadSafe {
-    
-    /**
-     * The service manager.
-     */
+    implements InputModule, Serviceable, ThreadSafe, Disposable {
+
+    /** The service manager. */
     protected ServiceManager manager;
-    
-    /* (non-Javadoc)
+
+    /** The portal service. */
+    protected PortalService portalService;
+
+    /**
      * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
      */
     public void service(ServiceManager manager) throws ServiceException {
         this.manager = manager;
+        this.portalService = (PortalService)this.manager.lookup(PortalService.ROLE);
     }
 
-	/* (non-Javadoc)
+	/**
+	 * @see org.apache.avalon.framework.activity.Disposable#dispose()
+	 */
+	public void dispose() {
+		if ( this.manager != null ) {
+			this.manager.release(this.portalService);
+			this.portalService = null;
+			this.manager = null;
+		}
+	}
+
+	/**
 	 * @see org.apache.cocoon.components.modules.input.InputModule#getAttributeNames(org.apache.avalon.framework.configuration.Configuration,
java.util.Map)
 	 */
 	public Iterator getAttributeNames(Configuration modeConf, Map objectModel) {
         return Collections.EMPTY_LIST.iterator();
 	}
 
-	/* (non-Javadoc)
+	/**
 	 * @see org.apache.cocoon.components.modules.input.InputModule#getAttributeValues(java.lang.String,
org.apache.avalon.framework.configuration.Configuration, java.util.Map)
 	 */
 	public Object[] getAttributeValues(String name, Configuration modeConf, Map objectModel)

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/components/modules/input/CopletModule.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/components/modules/input/CopletModule.java?rev=331752&r1=331751&r2=331752&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/components/modules/input/CopletModule.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/components/modules/input/CopletModule.java
Tue Nov  8 01:28:08 2005
@@ -19,21 +19,19 @@
 
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.service.ServiceException;
 import org.apache.cocoon.environment.ObjectModelHelper;
 import org.apache.cocoon.portal.Constants;
-import org.apache.cocoon.portal.PortalService;
 import org.apache.commons.jxpath.JXPathContext;
 
 /**
  * Makes accessible coplet instance data by using JXPath expressions.<br><br>
  *
  * Example:<br><br>
- * 
+ *
  * <pre>&lt;map:action type="foo"&gt;
  * 	&lt;map:parameter name="maxpageable" value="{coplet:copletData/maxpageable}"/&gt;
  * &lt;/map:action&gt;<br></pre>
- * 
+ *
  * The module will insert the boolean value specifying whether the coplet is 
  * maxpageable or not as value of attribute "value" in &lt;map:parameter&gt;. 
  * There are two possibilities how the module obtains the information required for 
@@ -52,46 +50,35 @@
  * &lt;/map:action&gt;</pre>
  *
  * Using the path '#' you get the current copletId: {coplet:#}
- * 
+ *
  * @version $Id$
  */
 public class CopletModule 
-extends AbstractModule {
-    
-    /* (non-Javadoc)
+    extends AbstractModule {
+
+    /**
      * @see org.apache.cocoon.components.modules.input.InputModule#getAttribute(java.lang.String,
org.apache.avalon.framework.configuration.Configuration, java.util.Map)
      */
     public Object getAttribute(String name, Configuration modeConf, Map objectModel) 
     throws ConfigurationException {
-        PortalService portalService = null;
-        try {
-
-            portalService = (PortalService)this.manager.lookup(PortalService.ROLE);
-
-            // determine coplet id
-            String copletId = null;            
-            Map context = (Map)objectModel.get(ObjectModelHelper.PARENT_CONTEXT);
-            if (context != null) {
-                copletId = (String)context.get(Constants.COPLET_ID_KEY);
-            } else {
-                copletId = (String)objectModel.get(Constants.COPLET_ID_KEY);
-            }
-            
-            if (copletId == null) {
-                return null;
-            }
-            
-            // return the coplet id
-            if ( name.equals("#") ) {
-                return copletId;
-            }
-            JXPathContext jxpathContext = JXPathContext.newContext(portalService.getComponentManager().getProfileManager().getCopletInstanceData(copletId));
-            return jxpathContext.getValue(name);
-        } catch (ServiceException e) {
-            throw new ConfigurationException("Unable to lookup portal service.", e);
-        } finally {
-            this.manager.release(portalService);
+        // determine coplet id
+        String copletId = null;            
+        Map context = (Map)objectModel.get(ObjectModelHelper.PARENT_CONTEXT);
+        if (context != null) {
+            copletId = (String)context.get(Constants.COPLET_ID_KEY);
+        } else {
+            copletId = (String)objectModel.get(Constants.COPLET_ID_KEY);
+        }
+        
+        if (copletId == null) {
+            return null;
         }
+        
+        // return the coplet id
+        if ( name.equals("#") ) {
+            return copletId;
+        }
+        JXPathContext jxpathContext = JXPathContext.newContext(portalService.getComponentManager().getProfileManager().getCopletInstanceData(copletId));
+        return jxpathContext.getValue(name);
     }
-
 }

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/components/modules/input/LayoutModule.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/components/modules/input/LayoutModule.java?rev=331752&r1=331751&r2=331752&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/components/modules/input/LayoutModule.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/components/modules/input/LayoutModule.java
Tue Nov  8 01:28:08 2005
@@ -19,8 +19,6 @@
 
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.cocoon.portal.PortalService;
 import org.apache.commons.jxpath.JXPathContext;
 
 /**
@@ -31,48 +29,37 @@
  * @version $Id$
  */
 public class LayoutModule 
-extends AbstractModule {
-    
-    /* (non-Javadoc)
+    extends AbstractModule {
+
+    /**
      * @see org.apache.cocoon.components.modules.input.InputModule#getAttribute(java.lang.String,
org.apache.avalon.framework.configuration.Configuration, java.util.Map)
      */
     public Object getAttribute(String name, Configuration modeConf, Map objectModel) 
     throws ConfigurationException {
-        PortalService portalService = null;
-        try {
-
-            portalService = (PortalService)this.manager.lookup(PortalService.ROLE);
-
-            int pos = name.indexOf('/');
-            String path;
-            if ( pos == -1 ) {
-                path = null;
-            } else {
-                path = name.substring(pos + 1);
-                name = name.substring(0, pos);
-            }
-            // is the layout key specified?
-            pos = name.indexOf(':');
-            String layoutKey = null;
-            String layoutId = name;
-            if ( pos != -1 ) {
-                layoutKey = name.substring(0, pos);
-                layoutId = name.substring(pos + 1);
-            }
+        int pos = name.indexOf('/');
+        String path;
+        if ( pos == -1 ) {
+            path = null;
+        } else {
+            path = name.substring(pos + 1);
+            name = name.substring(0, pos);
+        }
+        // is the layout key specified?
+        pos = name.indexOf(':');
+        String layoutKey = null;
+        String layoutId = name;
+        if ( pos != -1 ) {
+            layoutKey = name.substring(0, pos);
+            layoutId = name.substring(pos + 1);
+        }
 
-            // get the layout
-            final Object layout = portalService.getComponentManager().getProfileManager().getPortalLayout(layoutKey,
layoutId);
-            Object value = layout;
-            if ( layout != null && path != null ) {
-                final JXPathContext jxpathContext = JXPathContext.newContext(layout);
-                value = jxpathContext.getValue(path);
-            }
-            return value;            
-        } catch (ServiceException e) {
-            throw new ConfigurationException("Unable to lookup portal service.", e);
-        } finally {
-            this.manager.release(portalService);
+        // get the layout
+        final Object layout = portalService.getComponentManager().getProfileManager().getPortalLayout(layoutKey,
layoutId);
+        Object value = layout;
+        if ( layout != null && path != null ) {
+            final JXPathContext jxpathContext = JXPathContext.newContext(layout);
+            value = jxpathContext.getValue(path);
         }
+        return value;            
     }
-
 }

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/components/modules/input/SkinModule.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/components/modules/input/SkinModule.java?rev=331752&r1=331751&r2=331752&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/components/modules/input/SkinModule.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/components/modules/input/SkinModule.java
Tue Nov  8 01:28:08 2005
@@ -18,72 +18,65 @@
 import java.util.Iterator;
 import java.util.Map;
 
-import org.apache.avalon.framework.activity.Disposable;
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceSelector;
 import org.apache.cocoon.components.modules.input.InputModule;
-import org.apache.cocoon.portal.PortalService;
 import org.apache.cocoon.portal.layout.Layout;
 import org.apache.cocoon.portal.layout.SkinDescription;
 
 /**
  * This input module provides information about the current selected skin
- * 
+ *
  * @version $Id$
  */
 public class SkinModule 
-extends AbstractModule
-implements Disposable {
-    
+    extends AbstractModule {
+
+    /** The global input module. */
     protected InputModule globalModule;
-    protected ServiceSelector moduleSelector;
-    
-    /* (non-Javadoc)
+
+    /**
      * @see org.apache.avalon.framework.activity.Disposable#dispose()
      */
     public void dispose() {
         if ( this.manager != null ) {
-            if ( this.moduleSelector != null ) {
-                this.moduleSelector.release(this.globalModule);
-                this.manager.release(this.moduleSelector);
-                this.moduleSelector = null;
-                this.globalModule = null;
-            }
+            this.manager.release(this.globalModule);
+            this.globalModule = null;
         }
+        super.dispose();
     }
-    
-    /* (non-Javadoc)
+
+    /**
 	 * @see org.apache.cocoon.components.modules.input.InputModule#getAttribute(java.lang.String,
org.apache.avalon.framework.configuration.Configuration, java.util.Map)
 	 */
 	public Object getAttribute(String name, Configuration modeConf, Map objectModel) 
     throws ConfigurationException {
         // lazy init
-        if ( this.moduleSelector == null ) {
+        if ( this.globalModule == null ) {
             synchronized ( this ) {
                 try {
-                    if ( this.moduleSelector == null ) {
-                        this.moduleSelector = (ServiceSelector)this.manager.lookup(InputModule.ROLE+"Selector");
-                        this.globalModule = (InputModule)this.moduleSelector.select("global");
+                    if ( this.globalModule == null ) {
+                        this.globalModule = (InputModule)this.manager.lookup(InputModule.ROLE+"/global");
                     }
                 } catch (ServiceException e) {
-                    throw new ConfigurationException("Unable to lookup input module.", e);
+                    throw new ConfigurationException("Unable to lookup global input module.",
e);
                 }
             }
         }
-            
-        PortalService portalService = null;
-        try {
-
-            portalService = (PortalService)this.manager.lookup(PortalService.ROLE);
 
-            String skinName = null;
+        String skinName = null;
+        // if the attribute already contains a ':', the name is prefixed with the skin name
+        int pos = name.indexOf(':');
+        if ( pos != -1 ) {
+            skinName = name.substring(0, pos);
+            name = name.substring(pos+1);
+        } else {
             // get the current skin
             // the skin is stored as a parameter on the root layout
             // if not, the global module is used
             // fallback is: common
-            final Layout rootLayout = portalService.getComponentManager().getProfileManager().getPortalLayout(null,
null);
+            final Layout rootLayout = this.portalService.getComponentManager().getProfileManager().getPortalLayout(null,
null);
             if ( rootLayout != null ) {
                 skinName = rootLayout.getParameter("skin");
             }
@@ -94,39 +87,34 @@
                     skinName = "common";
                 }
             }
-            
-            // find the correct skin
-            SkinDescription desc = null;
-            final Iterator i = portalService.getSkinDescriptions().iterator();
-            while ( i.hasNext() && desc == null ) {
-                final SkinDescription current = (SkinDescription)i.next();
-                if ( current.getName().equals(skinName) ) {
-                    desc = current;
-                }
+        }
+
+        // find the correct skin
+        SkinDescription desc = null;
+        final Iterator i = this.portalService.getSkinDescriptions().iterator();
+        while ( i.hasNext() && desc == null ) {
+            final SkinDescription current = (SkinDescription)i.next();
+            if ( current.getName().equals(skinName) ) {
+                desc = current;
             }
-            if ( desc != null ) {
-                if ( "skin".equals(name) ) {
-                    return skinName;
-                } else if ( "skin.basepath".equals(name) ) {
-                    return desc.getBasePath();
-                } else if ( "skin.thumbnailpath".equals(name) ) {
-                    return desc.getThumbnailPath();
-                } else if ( name.startsWith("skin.thumbnailuri.") ) {
-                    String selectedSkinName = name.substring(name.lastIndexOf(".")+ 1, name.length());
-                    for(Iterator it = portalService.getSkinDescriptions().iterator(); it.hasNext();)
{
-                        SkinDescription selected = (SkinDescription) it.next();
-                        if(selected.getName().equals(selectedSkinName)) {
-                            return selected.getBasePath() + "/"  + selected.getThumbnailPath();

-                        }
+        }
+        if ( desc != null ) {
+            if ( "skin".equals(name) ) {
+                return skinName;
+            } else if ( "skin.basepath".equals(name) ) {
+                return desc.getBasePath();
+            } else if ( "skin.thumbnailpath".equals(name) ) {
+                return desc.getThumbnailPath();
+            } else if ( name.startsWith("skin.thumbnailuri.") ) {
+                String selectedSkinName = name.substring(name.lastIndexOf(".")+ 1, name.length());
+                for(Iterator it = portalService.getSkinDescriptions().iterator(); it.hasNext();)
{
+                    SkinDescription selected = (SkinDescription) it.next();
+                    if(selected.getName().equals(selectedSkinName)) {
+                        return selected.getBasePath() + "/"  + selected.getThumbnailPath();

                     }
                 }
             }
-            return null;
-        } catch (ServiceException e) {
-            throw new ConfigurationException("Unable to lookup portal service.", e);
-        } finally {
-            this.manager.release(portalService);
         }
+        return null;
 	}
-
 }

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/CopletTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/CopletTransformer.java?rev=331752&r1=331751&r2=331752&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/CopletTransformer.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/CopletTransformer.java
Tue Nov  8 01:28:08 2005
@@ -107,7 +107,7 @@
      */
     public void configure(Configuration configuration) throws ConfigurationException {
         super.configure(configuration);
-        this.useAjax = configuration.getChild("use-ajax").getValueAsBoolean(this.useAjax);
+        this.useAjax = this.portalService.getConfigurationAsBoolean("use-ajax", false);
     }
 
     /**



Mime
View raw message