Templates

Templates are the way I'm using to build some different kinds of pages. The template is simply an html page, with some keywords that are used to set the values going to be changed. There is a hierarchy about choosing templates. If there is a definition in the file /site/templates.conf, it will be applied, else the default template will be choosen.
The way to assign a different template to a page is quite simple, following the fnmatch expressions, similar to DOS style. The file can contain rows that explains how a range or a file are associated to a template, with the match expression, a pipe and the the template name. For example, if I would to associate the template imagestyle to files /images/directory, and the template main to all index file processed, but not the main, that will have a firstpage template, when the site is on a directory called /home/me/sitedir, I would have a templates.conf made in this way:

/home/me/site/index.*|firstpage
*/images/directory/*|imagestyle
*/index.*|main

Templates can contain some predefinited values, that are substituted during site regeneration.

${appname}

It returns the name of application, without the version, due it can be used for contents: in some headers, could make all pages changing.

${author}

The name of author, if it is known by page. It will get from chunk "author_description", that can be personalized.

${autotitle}

An automatically generated title: if you need a particular title, it's better to define it via def, that allows more precision on the final file name.

${body}

This part will be replaced for first, with the contents of text file that's got the template.

${dateday}

In the current file path, the part presenting the day (two chars).

${datedir}

The date part of the current file path.

${dateautolang}

The date of the post, formatted in the language mode. Requires scripting. It tries to get the format of the date from the browser, then put it into the html text. It can be personalized modifying the chunk localized_date.

${datelang}

The date of the post, formatted in the language mode. Formatting should be set, or it could take unpredictable results.

${datemonth}

In the current file path, the part that represent the month (two chars).

${dateyear}

In the current file path, the part that show the year (four chars).

${dirdocs}

The path (relative to the site root) where documents are stored. This can be changed during action file execution.

${dirimages}

The path (relative to the site root) where image galleries are stored. This can be changed during action file execution.

${dirposts}

The path (relative to the site root) where posts (the blog) are stored. This can be changed during action file execution.

${dirtitle}

Result is the relative path of the file.

${dirupindex}

A link to the above directory index file.

${firstarchive}

Return, if present, the name of the first file listing the archives. For example, if first archived page is /2006/08/12/mypage.html, then the file return by directive is archive-2006-08-12.html. You need to add probably a first part of the link.

${gallerybox}

A way to insert a lightbox image gallery into a post or a page: first of all, you have to insert images into page directory, or, if you have more pages, into a subdirectory with the same name. For example, if you have a text file called abc.txt, that will be abc.html after processing, in the original directory you've to make an abc subdirectory. Files that haven't same base name without extension, due same name files will be added as image automatically, will be put into a list of images. First of them, will be used as the launcher, the others will appear in a lightbox square. What is written depends on what it contains the chunk gallery_box

${gallerybuttons}

Block of html, from a chunk, where are the buttons associated to gallery navigation.

${history}

Return the lists of the archive files automatically created.

${keywords}

Keywords (as in the header section of the html page). They can be automatically or def generated.

${lang(ln)}

Beginning of the part of language 'nl' (two chars indicating the language), that should be close by a ${}.

${listdirindex}

A block containing the links to index files of the underlaying directories, that is generated from the rispective chunk.

${listfiles}

A block, derived from the chunk index_dir, containing the links to files in the directory.

${listgeneric(*.ext)}

Change this value with a list of matching files. Matching files can be specified as a kind (example, file*.doc), or an array of kinds (like *.doc|.rtf|.zip). File with same name are included only if they are not html files or jpg. List is sorted by file base name. Linking with other created html files is not allowed, you should use ${listfiles}

${listthumbs}

Thumbnails and links to /thumbnails directory of the current gallery.

${navbar}

A series of links, starting from home page and down, with links to index files. The contents of the links are affected by changes in chunk file navbar_items.

${pageencodedurl}

The encoded url for current page. In this mode, the url http://www.my.org/aaa?bcd will be translated in http%3A//www.my.org/aaa%3Fbcd. It should be used to get a safe url for composing links. In my intentions, anywy, urls shouldn't have spaces inside.

${pageencodedurlplus}

The encoded url for current page, translating also the spaces. In this mode, the url http://www.my.org/aaa?b c d will be translated in http%3A%2F%2Fwww.my.org%2Faaa%3Fb+c+d

${pagename}

The base name of the page: if page file is ~site/pages/index.txt, it returns index

${pagepath}

Path of the page through the site: for example, when a page on the site will be www.mysite.com/dir/page.html, this returns dir

${pathid}

An automatically generated string, like posts-21-01-13-title, useful to have an unique id usable, for example, with Disqus. Warning: moving or renaming files, this id will change.

${postsarchives}

Get a list, as links, to the pages containing the blog archives pages divided by month. In my thoughts, it should be used in a smaller column, while links part will contain only ${body} as a marker (it will include the list of the posts for that month).
For example, putting first column in div floating on left....

${postlinks}

A <div> containing automatically generated links to indexes, previous and next blog post.

${rootdir}

The site root dir. Used to get relative position of a file. For example, it can be used to link the home page in a template, don't considering the position of all files that contains it.

${script(scriptname)}

The output of a script that is launched with current file name as parameter. For example, writing a $script(test.sh) from /home/me/data/file.txt, gstatic will get the textual result of the command "/home/me/data/site/scripts/test.sh" "/home/me/data/file.txt. Called script should be marked as executable.

${scriptlang}

The script, that generally should be at the end of the pagem before the end of body, that shows and hides languages. After the settings of the used languages, it will contain references to them, and its purpose is to hide and show appropriate parts of the page.

${sitename}

The name of the site.

${statimagelastmod}

Date of the last save of the image associated to page.

${statimagesize}

Size of the image associated to page.

${statsize}

Size of the page.

${statlastmod}

Last save date of the page. It depends from the date of the processing file (this file, as default, has md extension).

${tags}

Tags (defined via defs) of the file. They're set as links to the pages where are listed all files tagged with the same word.

${title}

A div where contents are formed by title.

Last update: 2021-05-04 13:57