cookbook/cookbook.org

5.6 KiB
Raw Permalink Blame History

Bake-Bread, a bread baker

This is a literate org file that'll generate https://breadpunk.club. It's got features like pandoc templating, poor-person's wiki-fying, manpage generation, and (stretch goal!) gemini and gopher output as well. I'm going to try to do this in as little "programming" as possible just make, sh, and pandoc, I hope.

Index.html

First things first, we need to generate the site index, good old /index.html. That should be easy enough from a markdown source, plus a template.

A note: There are a few Make variables we'll be defining those later on in this file (see /breadpunk/cookbook/src/branch/master/*Variables), but of course earlier in the resulting Makefile. Tangling!

#+NAME index_recipe

$(O)/index.html: index.md $(T_CRUST)
	$(PANDOC) $< --template=$(T_CRUST) -o $@

Pages

There are a couple of pages that should be easy to get to on breadpunk.club, for example, /join, /about, and /donate. They should all look pretty similar to /index.html, so their recipes do, too.

A note: I could do something fancy here, I'm sure, but my Make is rusty so I'm manually specifying each recipe. I will fix it later, or merge requests are welcome!

#+NAME pages_recipe

$(O)/join/index.html: join.md $(T_CRUST)
	$(PANDOC) $< --template=$(T_CRUST) -o $@

$(O)/about/index.html: about.md $(T_CRUST)
	$(PANDOC) $< --template=$(T_CRUST) -o $@

$(O)/donate/index.html: donate.md $(T_CRUST)
	$(PANDOC) $< --template=$(T_CRUST) -o $@

Cookbook

Here's the fun part: a "cookbook" for bakers to add their own stuff to get listed on breadpunk.club. We're also going to put docs here, like the Manifesto, etc. I might have to route /docs to /cookbook, just so we don't break links.

TODO decide between these two possibilities

~/.cookbook file

In each user's $HOME, we'll look for a file called .cookbook, with the following format:

  white bread	bread.html
  cookies	cookies.html
  pumpernickel	pumpernickel.md

~/cookbook/ directory

In each user's $HOME, we'll look for files in a directory called cookbook. If those files end in .md we'll run them through pandoc and sanitize the output HTML, wrap it in <article> tags, and dump it in a template page. If it's .html we'll just … wrap it in <article> and dump it in there. Hm.. I guess we should sanitize it as well.

Publish

After everything is built, we can publish the site to /var/www/. First, though, we'll back up the current site, just in case of data loss.

Oh, and of course, publish is a .PHONY target. Let's specify that.

#+NAME publish_recipe

.PHONY: publish
publish: O/*
	$(RSYNC) $(P)/ /bread/site_backups/$$(date %FT%T)/
	$(RSYNC) --delete $(O)/ $(P)

Variables

Makefile

There are a couple of variables we need to define for the Makefile to work.

Build and publish directories

The build directory is like a staging area, getting the sources ready for moving to the publish directory in the publish rule. #+NAME var_build

O = build
P = /var/www

Templates

These are the various templates we'll pass to pandoc to generate breadpunk.club. We've got a general, "crust" one for basic pages, as well as an "crumb" one for individual articles in a river-of-news style page (like /news). #+NAME var_templates

T_CRUST = crust.templ.html
T_CRUMB = crumb.templ.html

Pandoc invocation

So that I don't have to remember the pandoc invocation every time I invoke it, here it is in a (couple of) variables. #+NAME var_pandoc

PANDOC_BIN = /usr/bin/pandoc
PANDOC_OPT = --from=markdown --to=html
PANDOC = $(PANDOC_BIN) $(PANDOC_OPT)

Rsync invocation

Since I call rsync more than once, I'm popping its invocation in a variable. #+NAME var_rsync

RSYNC_BIN = /usr/bin/rsync
RSYNC_OPT = --archive --verbose --compress --progress
RSYNC = $(RSYNC_BIN) $(RSYNC_OPT)

Templates

crust.templ.html

The crust is the outside of the bread, and it's the outside of a breadpage. It's what makes the page displayable by a browser. #+NAME template_crust

  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  <html lang="en">
    <head>
          <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
          <meta name="viewport" content="width=device-width,initial-scale=1">
          <meta name="description" content="a collaborative bread-positive space">
          <link rel="stylesheet" media="screen" type="text/css" href="https://fontlibrary.org/face/cmu-typewriter">
          <!-- TODO ^ load font locally -->
          <link rel="stylesheet" type="text/css" href="/S/breadpunk.css">
          <link rel="icon" type="image/png" href="/S/breadpunk.png">
	
          <title></title>
    </head>
    <body>
          <div id="header">
            <div class="nav">
                  <!-- TODO -->
            </div>
            <marquee id="users">
                  <!-- TODO -->
            </marquee>
          </div>

          <div id="main">
            <div class="header">
            </div>
            <!-- CONTENT HERE -->
          </div>

          <div id="footer">
          </div>
    </body>
  </html>

crumb.templ.html

The crumb is … the inside. It's the tasty soft middle that makes the bread interesting. We'll wrap our content in the crumb before stuffing all the different ones in the crust. Maybe this should've been burritopunk. Hm.