CssColumnSite

Articles

More

Links

CssColumnSite Application

This document describes as Cocoon setup for a simple static publishing site.

Requirements

A simple but flexible site should be built using Cocoon. Following requirements triggered the design:

Page Layout

Solution

Layouting was taking from a description at alistapart ; it describes a column oriented layout by using css only.

The current implementation uses a flat URI. The base name of requested page is used inside the Cocoon sitemap for peeking xml documents from each of the section directories.

The response html page is aggregated by one xml-document from each of the section directories top-col-1, mid-col-1, mid-col-2, mid-col-3, mid-col-4, and bottom-col-1.

The directory layout:

Directory Hierarchy

Each section top-col-1, mid-col-1, mid-col-2, mid-col-3, mid-col-4, and bottom-col-1 holds documents of each section. A requested page is aggregated from the xml files having the same basename from each section directory. The sitemap resource show-page provides the aggregation.

If a section directory does not hold the requested xml document, the xml document index is used. The sitemap resource load-page provides this logical behaviour.

The directory stylsheets holds the xslt stylsheet.

The directory resources and its subdirectories styles, and images holds additional site resources.

Defaulting to default section document was implemented by an Action, and a Selector evaluating the Action result.

More specific the already existing ResourceExistAction is enhanced to a ExtendedResourceExistsAction. This action sets the sitemap parameter resource-exists to true, or false, depending if the requested source can be resolved, or not.

The act method of ExtendedResourceExistAction:


public Map act(Redirector redirector, 
  SourceResolver resolver, Map objectModel, 
  String source, Parameters parameters) 
  throws Exception {
    String urlstring = 
      parameters.getParameter("url", source);
    Source src = null;
    
    Map result = new HashMap();
    
    try {
        // try to resolve the source
        src = resolver.resolveURI(urlstring);
        src.getInputStream();
        
        // as no exception has been thrown assume that
        // the source exists, and is accessible
        result.put( RESOURCE_EXISTS_PARAM_NAME, "true" );

    } catch (Exception e) {
        
        // as an exception is thrown assume 
        // that the source
        // can not be resolved, and does not exists
        getLogger().warn( "Resource " + 
          String.valueOf(urlstring) + 
          " does not exist, " +
          "set parameter " + 
          RESOURCE_EXISTS_PARAM_NAME + " to false" );

        result.put( RESOURCE_EXISTS_PARAM_NAME, "false" );
    } finally {
        // do houskeeping release the resolved src
        resolver.release(src);
    }
    return result;
}
      

The selector ParameterSelector is used for evaluating the parameter resource-exists.


  [Next]

PDF
csscolumnsite

Hints

» Use Search to search all documents.
» Use Recreate Index to create the inital index. This may be neccessary once at startup.

» Search and Recreate Index are available at HTML Cocoon online deployment, only.
» Search and Recreate Index are not available on WML online, WML offline, and HTML offline deployments.