Statin

Statin version 1.1

What is Statin?

Statin is a python command line utility to generate static html websites. It implements SSI (Server Side Includes) directives to generate the static files for deployment.

The name statin is a portmanteau of the words static includes.

Installation

Statin is available on PyPI. You can install it with pip by simply running the command pip install statin. You may need superuser permission depending on your system.

Alternatively you can download the package and extract it on your computer. Then you can install the package by running python setup.py install from inside the extracted package directory. You may require superuser persmission. You can also clone the repository to your computer and execute the script named run.

You need to have Python 3 installed in order to use the script.

Usage

Create your website in html. The files containing SSI directives should have the extension ".shtml", ".shtm", or ".sht". After creating the website change directory to the document root of the site and run the script. By default the static site will be generated in a subdirectory named statin-output.

The command line usage is follows:

statin [-h] [-q | -v] [-s] [-r] [-l LEVEL] [-p PATTERN] [-o OUTPUT] [files [files ...]]

Positional arguments:
filesList of files to be processed
Optional arguments:
-h, --helpshow this help message and exit
-q, --quietSuppress text output to console
-v, --verboseVerbose text output to console
-s, --safeDisable python eval of strings
-r, --recursiveProcess files recursively
-l LEVEL, --level LEVEL Maximum recursion level
-c COMMAND, --after COMMAND Run a command on each file after they are processed. The content of the file is supplied through the stdin and the output is read from the stdout.
-C COMMAND, --before COMMAND Run a command on each file before they are processed. The content of the file is supplied through the stdin and the output is read from the stdout.
-p PATTERN, --pattern PATTERN Filename patterns to be processed
-o OUTPUT, --output OUTPUT Specify the output directory

Supported Directives

A directive is written as <!--#directive parameter="value" -->

The supported directives and parameters are listed below:

DirectivesParametersDescription
includefile / virtualAllows embedding another file inside a document. Example — <!--#include file="navbar.html" -->
'file' specifies the path relative to the referencing file and 'virtual' specifies the path relative to the current working directory.
execcgi / cmdExecutes the specified command and embeds the result.
echovarPrints the value of a variable.
configtimefmt / sizefmt / errmsgConfigures the display format.(timefmt - time format, sizefmt - filesize format, errmsg - displayed error message)
flastmodfile / virtualDisplayes the last modification date of a file.
fsizefile / virtualDisplays the size of a file
printenv(none)Outputs the values of all variables.
ifexprUsed for writing conditional statements.
elifexpr
else(none)
endif(none)
setvar & valueSets the value of a variable

Default Variables

  • DATE_LOCAL
  • DATE_GMT
  • DOCUMENT_URI
  • DOCUMENT_NAME
  • LAST_MODIFIED

Configuration

The default configuration is stored in the file conf.py. Available configuration options are:

OUTPUT_DIR
The directory where the statin output files will be saved.
PROCESS_PAT
The filename extensions recognized by statin for processing.
TIMEFMT
The default time format.
SIZEFMT
The default size format.
ERRMSG
The default error message.

FAQ

What do I need to install Statin?
You need Python 3. You will also need pip and setuptools to help you with the installation.
Does it run on Windows?
Yes. An executable file will be automatically generated and placed in your path if you install the program with pip. There may be some issues with Windows though, see the known issues below.
Does it run on GNU/Linux?
Yes. It runs perfectly on GNU/Linux.
Do I need to know HTML to use Statin?
Yes. You need to write the source files in HTML. In addition you should be familiar with SSI directives, although they are very easy to learn if you already know HTML.
What's the difference with other static HTML generators like Pelican?
Most static HTML generators force you to maintain a certain filesystem hierarchy and document structure. It's also difficult to adapt your existing website to conform with them. Statin doesn't make any assumption about your directory structure, and it's as easy as including some simple directives anywhere in your existing website.
How do I contribute?
Thank you for your interest in the project. Please clone the repository and send a pull request via e-mail after making your changes.

Changelog

v1.1
Enabled external commands to be run before or after processing each file.
Temporary files are no longer created in the working directory.

License

Copyright © 2018 Dr. Agnibho Mondal
All rights reserved

Statin is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Contacts

Agnibho Mondal
mondal@agnibho.com
www.agnibho.com


Softwares of Agnibho
Copyright © 2013-2018 Dr. Agnibho Mondal
www.agnibho.com