How these web pages are maintained

A folder on my laptop contains a shadow copy of the web site (along with some maintenance infrastructure). All the files for the web site itself are stored under the Web Page Data subfolder.

The application to launch ".html" is set to TextEdit, whose global preferences are set to ignore rich text. With these settings, double clicking an HTML file calls TextEdit to allow direct editing of the raw HTML, and the formatted version can be previewed by dragging the file on top of Safari in the system dock. After editing is completed, the Publish Web Pages icon is double-clicked, causing the changed files only to be copied to the actual web server.

How it works

Publish Web Pages is this Unix shell script

#! /bin/sh

# Upload web page using sitecopy
# See
# New version directly callable by double-click

OuterDir="`dirname \"$0\"`"

InnerDir="$OuterDir/Web Page Data"

# --update     normal mode
# --initialize used on first call
# --list       used for debugging

rm -rf "$TempDir"
mkdir -m 0700 "$TempDir"
cat <<@EOF >"$TempDir/control"
site "$SiteName"
protocol ftp
local "$InnerDir"
remote ~/
ftp usecwd
exclude .DS_Store
exclude FINDER.DAT
exclude ._*
chmod 0600 "$TempDir/control"

cp "$OuterDir/$SiteName.status" "$TempDir/$SiteName"
"$SiteCopyBinary" --rcfile="$TempDir/control" --storepath="$TempDir" "$Command" "$SiteName"
cp "$TempDir/$SiteName" "$OuterDir/$SiteName.status"

rm -rf "$TempDir"

The sitecopy program does not examine the directory tree on the actual web server (the remote directory tree), instead it maintains (in a local status file) a cached representation of the local directory tree at the time of the last sitecopy call. From this it deduces what has changed locally, and issues the set of transfers necessary to modify the remote directory tree to match.

Sitecopy has a somewhat convoluted set of requirements, so this script performs a similarly convoluted process to satisfy it. It creates a /tmp directory, builds a control file de-novo, copies in the status file, calls sitecopy itself, then copies the modified status file back. The sitecopy documentation might be somewhat useful in acquiring a deeper understanding of this code.

The upshot of all of this hoohah is that only the changed pages are copied to the web server, currently which provides the domain name registration, the server, and five megabytes of web space, for a very nominal price ($15 USD per year at the time of this writing).

Note: any of the control file, upload script, andor the sitecopy binary itself could be placed inside the local directory, with exclude directives added to the control file to prevent transfer to the server.

Return to Developer’s Corner