Quick Start Guide |
Download the latest version of Yggdrasil: http://www.psyke.org/yggdrasil/
Yggdrasil uses the following modules which are not included in the standard Perl distribution:
You can download the modules from CPAN or Activestate’s package repository.
Create directories to store your site’s source files. These directories will contain your stripped HTML files, template files and all other files that are needed for your site (e.g. images and pdf files). For best results, create subdirectories for each content area, e.g.:
mysite_source/ about/ essays/ planes/ trains/ automobiles/ contact/
Your HTML files should only contain a minimum of markup, though you are free to use any markup that is allowed inside <body>
tags. All HTML files must contain at least one set of <h1>
tags.
The text in the first set of <h1>
found in a file is used to create the site navigation.
The contact page for the site above would be named index.html, be placed in the contact/ directory and could look like:
<h1>Contact Me</h1> <p> You can reach me at this address: me@mysite </p>
By default, files named index.html or index.shtml are used to create the site navigation. This can be changed by editing the configuration file.
You can use HTML files which are not named index.html or index.shtml, but you must manually create links to them. To add a map page called map.html to the example above, we would create the file map.html in contact/ and edit index.html:
<h1>Contact Me</h1> <p> You can reach me at this address: me@mysite <a href="map.html">Here is a map</a>. </p>
If you don’t want to handle the link to your map manually, you can create the directory contact/map/ and move map.html to contact/map/index.html. This will make the map show up in the autogenerated navigation.
Templates are parsed with the Text::Template module. A basic template contains the HTML header and content that should be included on all pages of your site. The basic template for your site is called base.tmpl (the line numbers are not part of the template):
1: <html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en"> 2: <head><title>My Site - {$title}</title></head> 3: <body> 4: <p> 5: You are here: 6: { 7: foreach my $item (@trail) { 8: if ($item->{href}) { 9: $OUT .= qq( 10: <a href="$item->{href}">$item->{name}</a> > 11: ); 12: } 13: else { 14: $OUT .= $item->{name}; 15: } 16: } 17: } 18: </p> 19: { 20: if (@navigation) { 21: $OUT .= '<ul>'; 22: 23: foreach my $item (@navigation) { 1: 24: $OUT .= qq( 25: <li><a href="$item->{href}">$item->{name}</a></li> 26: ); 27: } 28: 29: $OUT .= '</ul>'; 30: } 31: else { 32: $OUT .= ''; 33: } 34: } 35: {include_text($template{'__file__'})} 36: </body> 37: </html>
{$title}
inserts the title of the current source HTML file.Home > Essays > Trains.
It is possible to include templates in other templates. If you use the same footer in all you templates, you can place it in the file footer.tmpl and include it when you need it:
{include($template{'footer.tmpl'})}
Yggdrasil searches the path to the current source file for templates. If you put footer.tmpl in mysite_source/ and an edited version of footer.tmpl in mysite_source/essays/, all the essay files will use the edited footer while the rest of the site will use the footer in the site root. Use this feature to create different looks for different parts of your site.
The following variables are available in the templates:
<h1>
tags in the file). If no title can be found in the document, a default title is used.The following functions are available in the templates:
You can either modify the included default.cfg or create your own. You only need to configure three parameters:
input_dir = /home/me/mysite_source output_dir = /home/me/wwwroot base_url = http://www.mysite.com
This configuration file tells Yggdrasil to process the source files in /home/me/mysite_source and write the output files to /home/me/wwwroot. http://www.mysite.com is passed to the template variable $base_url
.
Run y.pl:
perl y.pl
or
./y.pl
depending on your OS and system setup.
Run
perl y.pl --help
for a list of commandline options.
See the User Guide for a comprehensive description of configuration options and advanced features.
Morten Wulff, <wulff@psyke.org>
Copyright 2003, Morten Wulff
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the file “FDL”.
Quick Start Guide |