File: genhtml/__docs__/genhtml.html.txt

$DOCTYPE$

<HTML>

<HEAD>

<!-- META=Unicode type, STYLE=css link, SCRIPT=analytics  -->
<!-- feb18: STYLE now includes a viewport meta for mobile -->

$META$

$ICON$

$STYLE$

$SCRIPT$

<STYLE>
/* local styles not in _main.css */

.notebox {
    margin-left: 40px; 
    margin-right: 40px; 
    margin-top: 30px;
    margin-bottom: 30px;
    border-style: solid; 
    border-width: 1; 
    padding: 5px;
    background-color: cornsilk;
}


LI {                       /* feb18 mobile: redesign by-date lists for mobile */
    margin-bottom: 5px;    /* all double-space, else hard to read or tap */
}
</STYLE>

<TITLE>genhtml - Webpage Macros Utility</TITLE> 

</HEAD>


<BODY>


<H1><I>genhtml</I> &mdash; Static HTML Inserts for Website Files</H1>


<P class=notebox>
<I><B>New</B></I>: as of June 2017, genhtml now  
handles ".*" Mac/Unix cruft files in inserts and templates folders.
This includes both ".DS_Store" Finder files, and any "._*" AppleDouble 
resource-fork files on non-Mac drives.  Both are skipped in inserts 
to avoid errors, but are simply copied like other non-HTML in templates 
because more may pop up before publication&mdash;filter later with your 
zip or upload tools (e.g., <A HREF="ziptools.html">ziptools</A>).

<BR><BR>
See the new <A HREF="genhtml/genhtml.py">script's</A> 
docstring for details.  For a quick example of genhtml at work, 
see also the template file for the page you are
<A HREF="genhtml/__docs__/genhtml.html.txt">viewing</A>, and its expansion 
via your browser's "view source."  There are also new example site-publisher 
master scripts
<A HREF="genhtml/__docs__/PUBLISH.py">here</A> and
<A HREF="genhtml/__docs__/publish-halves.py">here</A> that use genhtml 
as a nested tool, and are used to publish the website you are 
<A HREF="genhtml/__docs__/publish.png">viewing</A>.


<P>
This Python 3.X program provides basic HTML macro functionality.
It replaces keys in a folder's HTML-template files with the content 
of correspondingly-named insert files.  The net effect automatically 
updates static web pages when any common content they share is changed.
Among its features, this program has:

<UL>
<LI>Automatic dependency tracking&mdash;HTML files are regenerated whenever their 
templates or any inserts they use have changed

<LI>Configurable Unicode support&mdash;encodings in a sequence are tried in turn for
each HTML file

<LI>One-level nested inserts&mdash;insert files can insert other insert files
for added flexibility

<LI>Automatic generation-date insertion&mdash;built-in keys support multiple formats
</UL>

<P>
This script addresses only static content: common text that can change over time,
but need not be generated on each new page request.  For such content, though,
this program is a simple alternative to:

<UL>
<LI>Mass cut-and-paste edits, which are prohibitively tedious
<LI>JavaScript hacks on the client, which users may disable
<LI>PHP or Apache inserts on the server, which make your pages 
    unviewable offline
<LI>Unix cpp + make, which may not be present on every platform,
    and requires manual makefiles
</UL>

<P>
This program uses and requires Python 3.X, and serves to illustrate a typical
utility role for Python code.
See the main script's docstring and other items below for usage details.


<P>
<B><I>Code and docs</I></B>:
<UL>
<LI><A HREF="genhtml/genhtml.py">genhtml.py</A> &mdash; the main script's source (425 lines, 1/3 docstring)
</UL>


<P>
<B><I>Example</I></B>:
<UL>
<LI><A HREF="genhtml/Html-inserts/FOOTERMAIN.txt">Inserts file</A> &mdash; filename gives key 
                                                  (plus the <A HREF="genhtml/Html-inserts/FOOTER-COMMON.txt">nested insert</A>)

<LI><A HREF="genhtml/Html-templates/test1.html">Template page</A> &mdash; with insert targets (inspect with "view source")

<LI><A HREF="genhtml/Complete/test1.html">Generated page</A> &mdash; with inserts applied (inspect with "view source")
</UL>


<P>
<B><I>Usage</I></B>:
<UL>
<LI><A HREF="genhtml/__docs__/PUBLISH.py">Site publishing script</A> &mdash; runs genhtml automatically

<LI><A HREF="genhtml/__docs__/run-log.txt">Run log examples</A> &mdash; basic script interaction

<LI><A HREF="genhtml/__docs__/console.png">Console screen shot</A> &mdash; session console capture

<LI><A HREF="genhtml/__docs__">Docs folder</A> &mdash; assorted documentation augmenting the script's docstring
</UL>


<P>
<B><I>Download/view all</I></B>:
<UL>
<LI><A HREF="genhtml/genhtml.zip">genhtml.zip</A> &mdash; with all tests, docs, and examples</A>

<LI><A HREF="genhtml/">Unzipped content online</A> &mdash; script, docs, more examples and test pages
</UL>
</P>


<P>
This program was last changed February 28, 2018     <!-- or pagegen date: $_DATELONG2$ -->

<P>
For more code examples, see the
<A HREF="programs.html">programs</A> page.  
</P>



$FOOTERTAN$

</BODY>
</HTML>



[Home] Books Programs Blog Python Author Training Search Email ©M.Lutz