From c2c1b67122d1f345bf875420ef69e0fad4c79a56 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 17 Nov 2020 23:20:55 -0600 Subject: [PATCH] Add cookbook.org Yeah, I'm literate programming. Deal with it. --- cookbook.org | 144 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 cookbook.org diff --git a/cookbook.org b/cookbook.org new file mode 100644 index 0000000..0537fe3 --- /dev/null +++ b/cookbook.org @@ -0,0 +1,144 @@ +#+TITLE: Bake-Bread, a bread baker +#+AUTHOR: Case Duckworth + +This is a literate org file that'll generate https://breadpunk.club. It's got features like [[https://pandoc.org][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 [[*Variables]]), but of course earlier in the resulting Makefile. /Tangling!/ + +#+NAME index_recipe +#+BEGIN_SRC makefile +$(O)/index.html: index.md $(T_CRUST) + $(PANDOC) $< --template=$(T_CRUST) -o $@ +#+END_SRC + +* 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 +#+BEGIN_SRC makefile +$(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 $@ +#+END_SRC + +* 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: + +#+begin_example + white bread bread.html + cookies cookies.html + pumpernickel pumpernickel.md +#+end_example + +*** ~/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 =
= tags, and dump it in a template page. If it's =.html= we'll just ... wrap it in =
= 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 +#+BEGIN_SRC makefile +.PHONY: publish +publish: O/* + $(RSYNC) $(P)/ /bread/site_backups/$$(date %FT%T)/ + $(RSYNC) --delete $(O)/ $(P) +#+END_SRC + +* 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][publish]] rule. +#+NAME var_build +#+BEGIN_SRC makefile +O = build +P = /var/www +#+END_SRC + +*** 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 +#+BEGIN_SRC makefile +T_CRUST = crust.templ.html +T_CRUMB = crumb.templ.html +#+END_SRC + +*** 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 +#+BEGIN_SRC makefile +PANDOC_BIN = /usr/bin/pandoc +PANDOC_OPT = --from=markdown --to=html +PANDOC = $(PANDOC_BIN) $(PANDOC_OPT) +#+END_SRC + +*** Rsync invocation +Since I call =rsync= more than once, I'm popping its invocation in a variable. +#+NAME var_rsync +#+BEGIN_SRC makefile +RSYNC_BIN = /usr/bin/rsync +RSYNC_OPT = --archive --verbose --compress --progress +RSYNC = $(RSYNC_BIN) $(RSYNC_OPT) +#+END_SRC + +* 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 +#+begin_src html + + + + + + + + + + + + + + + + +
+
+
+ +
+ + + + +#+end_src +** =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.