Generate output files from input files. This is revolutionary.
Go to file
Ty Kozic fd57e770ef
enable environment variable configuration
2023-11-22 09:50:21 -06:00
sample/in initial commit 2023-07-04 16:30:40 -05:00
.gitignore initial commit 2023-07-04 16:30:40 -05:00
README.md clarify README 2023-07-04 16:49:19 -05:00
dirmake.sh enable environment variable configuration 2023-11-22 09:50:21 -06:00

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.

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!