cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@cocoon.apache.org
Subject [Cocoon Wiki] Updated: SimpleContentModel
Date Thu, 13 Jan 2005 23:52:24 GMT
   Date: 2005-01-13T15:52:23
   Editor: MarkLundquist
   Wiki: Cocoon Wiki
   Page: SimpleContentModel
   URL: http://wiki.apache.org/cocoon/SimpleContentModel

   more corrrect & complete!

Change Log:

------------------------------------------------------------------------------
@@ -14,21 +14,24 @@
 
 = The Content Model =
 
-OK, then... we start with two top-level directories:
-
+OK, then... we start with this directory structure within the webapp directory:
 {{{
 webapp/
     content/
     static/
+        content/
 }}}
 
 {{{content}}} is the root of a directory structure that contains the XML source documents.
+
 {{{static/}}} contains:
  * static resources common to all or most pages, such as
   * layout artwork, e.g. logos
   * site-wide CSS stylesheet
   * common external javascripts
- * symbolic links into the {{{content/}}} directory structure (see below!)
+  * etc...
+ And...
+  * An automatically-generated {{{content/}}} subdirectory containing symbolic links into
the {{{webapp/content/}}} directory structure (see below!)
 
 {{{static/}}} does '''not''' contain any page-specific resources (see below!)
 
@@ -80,21 +83,21 @@
             bowser_chasing_tail.swf
 }}}
 
-We then create the following directory structure and soft link in {{{webapp/static}}}:
+We then create a directory structure and a soft link in {{{webapp/static/content}}}.  A tool
is provided (see the implementation notes at the end of this article) that (re)builds {{{webapp/static/content}}},
so you don't have to make any of those soft links or the directory scaffolding by hand --
just run the tool.  But you should know what it does!  The following directory structure is
created:
 
 {{{
-webapp/static/
+webapp/static/content/
    path/
       to/
          dogs/
             Bowser      ----> .../content/path/to/dogs/Bowser/static
 }}}
-''[ToDo: provide an ant task that automates this]''
+
 
 A reference to a page-specific resource looks like this in the HTML, e.g.
 
 {{{
-<img src="/static/path/to/dogs/Bowser/bad_dog.jpg" />
+<img src="/static/content/path/to/dogs/Bowser/bad_dog.jpg" />
 }}}
 
 It would be quite undesirable to hard-code the site structure into our XML source document,
so we'll add a template to our stylesheet that lets us just write that as {{{<img src="static/bad_dog.jpg">}}};
the template will rewrite that to the necessary URI in the generated HTML.  See the implementation
notes at the end of this article for the XSLT template.
@@ -103,6 +106,22 @@
 
 Note the the sub-structure of {{{.../Bowser/static}}} is completely ''ad hoc''; all that
matters at this level is that references in the page match the directory structure.  The sitemap
does not know or care about this per-page "static/" directory, and it certainly doesn't care
how it's structured internally.
 
+If you have static resources that are specific to a certain area of the site, this is handled
too.  Suppose we have some imagery that appears on every page in the {{{path/to/dogs/**}}}.
 Simply create a {{{static/}}} directory at the appropriate place in the {{{content/}}} directory
structure, e.g.
+{{{
+content/path/to/dogs/
+    static/
+        some-common-image.jpg
+    Bowser.page/
+    ''etc...''
+}}}
+
+The tool will create the soft link in {{{static/content}}}, and you
+reference it in the document like this, e.g.:
+{{{
+<img src="/static/content/path/to/dogs/some-common-image.jpg">
+}}}
+
+
 == "Trailing slash" resources ==
 
 Sometimes you really need a resource to be served at a URI that ends with a slash, because
it determines whether a relative link in the page denotes a ''child''(if the current URL has
a trailing slash), or a ''sibling'' (current URL has no trailing slash) of the current page.
 If the URL of the current page doesn't end with a slash (e.g., {{{path/to/dogs}}}), then
we have an annoying situation if we want to include a link on that page to a child resource
(e.g., {{{path/to/dogs/Bowser}}}).  Our choices are:
@@ -231,9 +250,34 @@
 </xsl:template>
 }}}
 
-== Ant task to automate building directories and links in webapp/static ==
+== A script to automate building directories and links in webapp/static/content ==
 
-TBD!
+You can invoke this script from an ant task or a makefile.
+
+{{{
+#!/bin/csh -f
+#
+# Rebuild webapp/static/content.
+# (See http://wiki.apache.org/cocoon/SimpleContentModel)
+#
+cd webapp
+set content_dir = $cwd/content
+
+rm -rf static/content
+mkdir static/content
+
+foreach dir (`cd $content_dir; find * -name static -type d`)
+        set page_dir = $dir:h
+        set page_parent = $page_dir:h
+        set page_name = $page_dir:t
+        set static_dir = static/content/$page_parent
+
+        mkdir -p $static_dir
+        pushd $static_dir >& /dev/null
+        ln -s $content_dir/$page_dir/static $page_name
+        popd >& /dev/null
+end
+}}}
 
 ----
 That's all there is to it!

Mime
View raw message