Tutorial: Simple ``Hello World'' Site
![]() |
![]() The Document Assembly Tool |
|
Tutorial: Simple ``Hello World'' SiteLet us create a really simple little site consisting of two pages. The first page will be our index page. We'll load its contents from a file; the second, merely one to say ``hello world'' and we'll provide its content directly from a string constant. The index page will also inherit global settings for the HTML meta settings (author, description, etc.), while the ``hello world'' page will override some of these with its own values. Let's jump right in! The SITE objectA site object's name is not important; required is a list of 'pages' and an 'output' filename, which is, in this case, based on the actual page object that is being processed. Note: the 'body' and 'inputfile' properties are our own creation, not something that Weblord relies upon per sé: #requires-version "2.0" #include "html-page.wl" SITE main { pages = index helloworld; output = page.objectname ".html"; inputfile = page.objectname ".text"; body = FILE(name=inputfile); author = "Udo Schuermann"; description = "Just a test page"; keywords = "weblord, test, demo, udo schuermann"; } The FILE object helps us load a fileThis is a convenient object to help us load a file with a particular 'name'; wherever you say something like FILE(name='foobar') the file 'foobar' will be loaded, and all sequences in that file to something like ${test} will be resolved by evaluating the object (or property) named 'test' (which isn't defined in this example, wherefore it is equivalent to a zero-length string). It's the "varfile" constant value of the property 'value-type' that alters the usual interpretation of the TEXT object's 'value' to be loaded from a file rather than for the 'value' to be evaluated as a combination of object/property references and string constants (in this case only a reference, i.e. 'name'). See value-type for more information. TEXT FILE { value = name; value-type = "varfile"; } The pagesThe index page gets its body (value) by inheriting a page-template, which in turn inherits the page's input from a file with a .text extension PAGE index { value = page-template; } The helloworld page gets its body (value) also by inheriting a page-template, but the body that the index page inherits is explicitly defined here, as a string constant in this case, though it could be something like FILE(name='HTML:some/file.text') or whatever you like. PAGE helloworld { value = page-template; body = "Hello world!"; keywords = main.keywords ", hello world"; } The templateThe 'page-template' is referenced by each of our pages. By defining different such templates we could drastically change the look of an entire site or give just a certain set of pages a look that differs from other pages. We reference convenient header and footer objects that are defined in the #include'd 'html-page.wl' (see top). These are horribly messy but accomplish a nice, standard HTML page; by defining for a page the properties 'keywords', 'author', and 'description' (as a minimum, the header object will even build all the cool meta-data tags for you that helps your pages to be indexed by search engines. TEXT page-template { value = header body footer; } We could easily create some neat effect, such as a left and right margin, by wrapping the 'body' in a table: TEXT page-template { value = header '
|
||
This material is Copyright © 1997,1998,1999,2000,2001 RingLord Technologies and Udo Schuermann. All rights reserved. The latest versions of the WebLord software and (this) documentation can be obtained from the WebLord Home Page (the link will only function if you are connected to the internet.) |