|
||
---|---|---|
sample/in | ||
.gitignore | ||
README.md | ||
dirmake.sh |
README.md
dirmake
Name suggestions welcome.
I needed flexible static site generation, and I've been reading about daemontools
and software architecture ideas on the Oil shell blog. Enter dirmake
. It serves well as a static site generator, but let its flexibility inspire you.
- daemontools: https://cr.yp.to/daemontools.html
- Celebrating Daemontools: https://journal.infinitenegativeutility.com/celebrating-daemontools
- The Oil Shell Blog: https://journal.infinitenegativeutility.com/celebrating-daemontools
Dependencies
POSIX shell and utilities. Everything should be standard and widely portable. If not, call it a bug.
One caveat: My use cases don't involve many symlinks. There's a good chance I've missed a few flags on things like find
that mean symlinks won't work the way people want them to. This is not intended; patches and ideas are welcome.
Usage
It's a shell script. Put it where those go. Structure your site directory like in the tree below, then run dirmake.sh
in the top-level directory. Here, that's sample
: the directory containing in
. dirmake
creates out
if it's missing.
Big Idea
A static site is a collection of resources that mirrors a filesystem. dirmake
leverages that structure. We'll work with this example directory structure (trailing slashes added to directories for clarity):
sample/
├── in/
│ ├── index.html/
│ │ ├── index.md
│ │ └── run
│ └── posts/
│ └── hello-world.html/
│ └── raw
└── out/
├── index.html
└── posts/
└── hello-world.html
sample
is our top-level directory for the site. in
contains all the input for the site. A subdirectory of in
(or sub-subdirectory, etc.) is either hidden, contains a non-initial period, or does not contain a period.
Hidden files and directories are completely ignored by dirmake
.
An input subdirectory without a period represents a directory in the output in the same location. The output directory will have the same name as the input directory. See posts/
in the tree above.
An input subdirectory with a non-initial period represents a file in the output in the same location. The output file will have the same name as the input directory.
dirmake
will first look for a file called raw
inside the input directory. If it's found, raw
will be copied directly to the output location, under the name of the input directory. See hello-world.html
in the tree above.
If raw
is missing, dirmake
looks for run
. If it's found, dirmake
temporarily enters the input directory, executes run
, and redirects its standard output to the output location under the name of the input directory. See index.html
in the tree above. Any other files in the input directory are ignored. For example, index.md
is solely input to run
and isn't noticed by dirmake
.
So maybe most of your run
scripts will simply be pandoc
one-liners. But any executable can be there, so do all the generation-time computing you want!