Thinairarts icon (fan-shaped) Go to Main Page
Thinairarts logo (like a Scheme program...)

oowebtools: open-source project

Mon 19 Feb 2024 18:20:59 PST

oowebtools is a software toolkit for creating websites from simple to complex as requirements demand. oowebtools is written in Tcl and like Tcl oowebtools is a "platform" to build on, making all kinds of websites possible. oowebtools is perfectly suitable for producing fully static sites, but is also capable of generating pages on the fly. Content can be added dynamically, for example via AJAX/fetch APIs or standard server response. oowebtools includes its own backend server specifically for handling dynamic content.

This site, is an example since it was developed and is maintained using oowebtools. The job of managing busy websites for thriving businesses or enthusiastic communities of interest is a good problem to have! But keeping pace with demands for revision means frequently regenerating single pages up to entire sites.

Many tools are available to automate website maintenance. oowebtools includes a make-like utility pmake which can be set up to render site pages. Writing "rules" for a Pmakefile differs from typical makefiles though it's generally simpler. Running pmake is an easy way to manage generating site updates for deployment.

Tcl's tremendous adaptability and rock-steady reliability make it an ideal language for implementing this project. Website generation is naturally an off-line, time-tolerant task. Nonetheless, oowebtools operations aren't sluggish. Generating this website's 75 pages conpletes in just over two seconds, a decent performance for this type of application.

Download oowebtools!

You can access the latest version of oowebtools using our oowebtools fossil repository

Or if you prefer, go directly to the repo download page: oowebtools Downloads

You can find the oowebtools documentation here: oowebtools documentation

One option is installing fossil and cloning the repo, or just get the archive in tar.gz or zip format—it really couldn't be simpler!

The oowebtools Tools

oowebtools is a versatile construction kit originally developed for building websites. However it's also extremely useful in many other kinds of Tcl projects.

First let's look at how oowebtools works for websites.

Installing oowebtools

Installation is pretty straightforward. Once the archive is downloaded and decompressed, you'll have a single directory. Copy the directory to the usual location for extensions. Generally that's will be something like: /path/to/Tcl/lib/oowebtools.

Note that oowebtools has a few dependencies. First it uses: features of Tcl8.7 or 9.0. oowebtools uses the sqlite3 and tcllib extensions. Currently installing these on 9.0 is possible but both sqlite3 and tcllib need modifications to run on 9.0 so using 8.7 is therefore recommended.

Once installed, use oowebtools by putting the usual declaration in Tcl source files: package require oowebtools.

What's in the oowebtools Toolkit?

The oowebtools extension directory contains 20 files that begin with "oo...". These are TclOO classes that define the working elements of HTML (and other important functionality). There are also 11 non-TclOO utility files containing namespaces with procedures useful in a variety of contexts.

Html elements

Composite elements

These are convenient prewritten but highly configurable compound elements. This list provides a general description of the element's capabilities and usage. See documentation site for more details.

A predefined page

Utilities (class-based)

Utilities (namespace-based)

Subdirectories (css/, js/, shell/)

oowebtools for websites

Using oowebtools classes

Except for Html, all html elements are represented by a subclass of the abstract class <Element>. To create a page, begin by deriving from Html:

There are a few things of note in this example. In several places nxconstructor, nxmethod is used providing named-arguments, very useful for configuring objects.

Also note the general layout of element calls. For example, the "tag" name, Body is followed by new (or :), then -->. Here --> takes a list of -elements that are contained within the body elememt. In this case there's an h2, then a div with its own list of elements to be rendered within it. It should be obvious this follows the normal flow of html markup.

An advantage of this way of creating pages is the clean separation of logic among computing values and displaying them. Data flow is then more understandable which contributes to effective site maintenance.

Using the Tag namespace

oowebtools provides the Tag namespace as an alternative way to use objects for page creation. Consider this example:

This example looks a lot like the previous one. Only here we're using an ordinary namespace and procs to implement the page. Notice that the prior "Head:" is now just "Head:". Every html tag class is present in the ::Tag namespace as class name + : (colon). Thus "Head:" is the same as "Head:". IOW "Head:" is a proc that returns an object that can be used directly. Just remember to put "namespace import ::Tag::*" at the top of the namespace where tags will be used.

Of course Tag::* elements can also be use in pages written as classes. Syntax is the same, Tag class followed by a colon:

The only issue with this is where to put the "namespace import ::Tag::*" line. It doesn't work to put it at the top of the class definition. However it usually works if put in the constructor, or in the first method.

oowebtools: for websites, and more...

This overview of oowebtools' many capabilities can only hit the highlights. But we hope the descriptions of the toolkit's basic functions are at least clear enough to pique your interest in what it really can do! Give it a try, let us know your impressions, your feedback is valuable. A prime goal is making constant improvement to oowebtools. Your input helps us get there and that is definitely appreciated!