diff --git a/.gitignore b/.gitignore index 89ea643..1df25ee 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -dest +rss.xml +atom.xml diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8aa41a3 --- /dev/null +++ b/Makefile @@ -0,0 +1,180 @@ +#!/usr/bin/make -f + +BLOG := $(MAKE) -f $(lastword $(MAKEFILE_LIST)) --no-print-directory +ifneq ($(filter-out help,$(MAKECMDGOALS)),) +include config +endif + +# The following can be configured in config +BLOG_DATE_FORMAT_INDEX ?= %x +BLOG_DATE_FORMAT ?= %x %X +BLOG_TITLE ?= blog +BLOG_DESCRIPTION ?= blog +BLOG_URL_ROOT ?= http://localhost/blog +BLOG_FEED_MAX ?= 20 +BLOG_FEEDS ?= rss atom +BLOG_SRC ?= articles + + +.PHONY: help init build deploy clean + +ARTICLES = $(shell git ls-tree HEAD --name-only -- $(BLOG_SRC)/ 2>/dev/null) +TAGFILES = $(patsubst $(BLOG_SRC)/%.md,tags/%,$(ARTICLES)) + +help: + $(info blogit init|build|deploy|clean) + +init: + mkdir -p $(BLOG_SRC) data templates + printf '$$TITLE' > templates/header.html + printf '' > templates/footer.html + printf '' > templates/index_header.html + printf '

Tags:' > templates/tag_list_header.html + printf '$$NAME' > templates/tag_entry.html + printf ', ' > templates/tag_separator.html + printf '

' > templates/tag_list_footer.html + printf '

Articles

' > templates/article_list_footer.html + printf '' > templates/index_footer.html + printf '' > templates/tag_index_header.html + printf '' > templates/tag_index_footer.html + printf '' > templates/article_header.html + printf '' > templates/article_footer.html + printf 'blog\n' > .git/info/exclude + +build: blog/index.html tagpages $(patsubst $(BLOG_SRC)/%.md,blog/%.html,$(ARTICLES)) $(patsubst %,blog/%.xml,$(BLOG_FEEDS)) + +deploy: build + rsync -rLtvz $(BLOG_RSYNC_OPTS) blog/ data/ $(BLOG_REMOTE) + +clean: + rm -rf blog tags + +config: + printf 'BLOG_REMOTE:=%s\n' \ + '$(shell printf "Blog remote (eg: host:/var/www/html): ">/dev/tty; head -n1)' \ + > $@ + +tags/%: $(BLOG_SRC)/%.md + mkdir -p tags + grep -i '^; *tags:' "$<" | cut -d: -f2- | sed 's/ */\n/g' | sed '/^$$/d' | sort -u > $@ + +blog/index.html: $(ARTICLES) $(TAGFILES) $(addprefix templates/,$(addsuffix .html,header index_header tag_list_header tag_entry tag_separator tag_list_footer article_list_header article_entry article_separator article_list_footer index_footer footer)) + mkdir -p blog + TITLE="$(BLOG_TITLE)"; \ + export TITLE; \ + envsubst < templates/header.html > $@; \ + envsubst < templates/index_header.html >> $@; \ + envsubst < templates/tag_list_header.html >> $@; \ + first=true; \ + for t in $(shell cat $(TAGFILES) | sort -u); do \ + "$$first" || envsubst < templates/tag_separator.html; \ + NAME="$$t" \ + URL="@$$t.html" \ + envsubst < templates/tag_entry.html; \ + first=false; \ + done >> $@; \ + envsubst < templates/tag_list_footer.html >> $@; \ + envsubst < templates/article_list_header.html >> $@; \ + first=true; \ + for f in $(ARTICLES); do \ + printf '%s ' "$$f"; \ + git log --diff-filter=A --date="format:%s $(BLOG_DATE_FORMAT_INDEX)" --pretty=format:'%ad%n' -- "$$f"; \ + done | sort -k2nr | cut -d" " -f1,3- | while IFS=" " read -r FILE DATE; do \ + "$$first" || envsubst < templates/article_separator.html; \ + URL="`printf '%s' "\$$FILE" | sed 's,^$(BLOG_SRC)/\(.*\).md,\1,'`.html" \ + DATE="$$DATE" \ + TITLE="`head -n1 "\$$FILE" | sed -e 's/^# //g'`" \ + envsubst < templates/article_entry.html; \ + first=false; \ + done >> $@; \ + envsubst < templates/article_list_footer.html >> $@; \ + envsubst < templates/index_footer.html >> $@; \ + envsubst < templates/footer.html >> $@; \ + + +blog/tag/%.html: $(ARTICLES) $(addprefix templates/,$(addsuffix .html,header tag_header index_entry tag_footer footer)) + +.PHONY: tagpages +tagpages: $(TAGFILES) + +$(BLOG) $(patsubst %,blog/@%.html,$(shell cat $(TAGFILES) | sort -u)) + +blog/@%.html: $(TAGFILES) $(addprefix templates/,$(addsuffix .html,header tag_index_header tag_list_header tag_entry tag_separator tag_list_footer article_list_header article_entry article_separator article_list_footer tag_index_footer footer)) + mkdir -p blog + TITLE="Articles tagged $*"; \ + TAGS="$*"; \ + export TITLE; \ + export TAGS; \ + envsubst < templates/header.html > $@; \ + envsubst < templates/tag_index_header.html >> $@; \ + envsubst < templates/article_list_header.html >> $@; \ + first=true; \ + for f in $(shell grep -FH '$*' $(TAGFILES) | sed 's,^tags/\([^:]*\):.*,$(BLOG_SRC)/\1.md,'); do \ + printf '%s ' "$$f"; \ + git log --diff-filter=A --date="format:%s $(BLOG_DATE_FORMAT_INDEX)" --pretty=format:'%ad%n' -- "$$f"; \ + done | sort -k2nr | cut -d" " -f1,3- | while IFS=" " read -r FILE DATE; do \ + "$$first" || envsubst < templates/article_separator.html; \ + URL="`printf '%s' "\$$FILE" | sed 's,^$(BLOG_SRC)/\(.*\).md,\1,'`.html" \ + DATE="$$DATE" \ + TITLE="`head -n1 "\$$FILE" | sed -e 's/^# //g'`" \ + envsubst < templates/article_entry.html; \ + first=false; \ + done >> $@; \ + envsubst < templates/article_list_footer.html >> $@; \ + envsubst < templates/tag_index_footer.html >> $@; \ + envsubst < templates/footer.html >> $@; \ + + +blog/%.html: $(BLOG_SRC)/%.md $(addprefix templates/,$(addsuffix .html,header article_header article_footer footer)) + mkdir -p blog + TITLE="$(shell head -n1 $<)"; \ + export TITLE; \ + AUTHOR="$(shell git log --format="%an" -- "$<" | tail -n 1)"; \ + export AUTHOR; \ + DATE_POSTED="$(shell git log --diff-filter=A --date="format:$(BLOG_DATE_FORMAT)" --pretty=format:'%ad' -- "$<")"; \ + export DATE_POSTED; \ + DATE_EDITED="$(shell git log -n 1 --date="format:$(BLOG_DATE_FORMAT)" --pretty=format:'%ad' -- "$<")"; \ + export DATE_EDITED; \ + TAGS="$(shell grep -i '^; *tags:' "$<" | cut -d: -f2- | paste -sd ',')"; \ + export TAGS; \ + envsubst < templates/header.html > $@; \ + envsubst < templates/article_header.html >> $@; \ + sed -e '/^;/d' < $< | markdown -f fencedcode >> $@; \ + envsubst < templates/article_footer.html >> $@; \ + envsubst < templates/footer.html >> $@; \ + +blog/rss.xml: $(ARTICLES) + printf '\n\n\n%s\n%s\n%s\n' \ + "$(BLOG_TITLE)" "$(BLOG_URL_ROOT)" "$(BLOG_DESCRIPTION)" > $@ + for f in $(ARTICLES); do \ + printf '%s ' "$$f"; \ + git log --diff-filter=A --date="format:%s %a, %d %b %Y %H:%M:%S %z" --pretty=format:'%ad%n' -- "$$f"; \ + done | sort -k2nr | head -n $(BLOG_FEED_MAX) | cut -d" " -f1,3- | while IFS=" " read -r FILE DATE; do \ + printf '\n%s\n%s\n%s\n%s\n%s\n\n' \ + "`head -n 1 $$FILE`" \ + "$(BLOG_URL_ROOT)/`basename $$FILE`.html" \ + "$(BLOG_URL_ROOT)/`basename $$FILE`.html" \ + "$$DATE" \ + "`sed -n '1d;/^$$/{2{d;b};q};p' < $$FILE`"; \ + done >> $@ + printf '\n\n' >> $@ + +blog/atom.xml: $(ARTICLES) + printf '\n\n%s\n%s\n%s\n\n%s\n\n' \ + "$(BLOG_TITLE)" "$(BLOG_DESCRIPTION)" "$(shell date +%Y-%m-%dT%H:%M:%SZ)" "$(BLOG_URL_ROOT)" "$(BLOG_URL_ROOT)/atom.xml" "$(BLOG_URL_ROOT)/atom.xml" > $@ + for f in $(ARTICLES); do \ + printf '%s ' "$$f"; \ + git log --diff-filter=A --date="format:%s %Y-%m-%dT%H:%M:%SZ" --pretty=format:'%ad %aN%n' -- "$$f"; \ + done | sort -k2nr | head -n $(BLOG_FEED_MAX) | cut -d" " -f1,3- | while IFS=" " read -r FILE DATE AUTHOR; do \ + printf '\n%s\n\n%s\n%s\n%s\n%s\n%s\n\n' \ + "`head -n 1 $$FILE`" \ + "$(BLOG_URL_ROOT)/`basename $$FILE`.html" \ + "$(BLOG_URL_ROOT)/`basename $$FILE`.html" \ + "$$DATE" \ + "`git log -n 1 --date="format:%Y-%m-%dT%H:%M:%SZ" --pretty=format:'%ad' -- "$$FILE"`" \ + "$$AUTHOR" \ + "`sed -n '1d;/^$$/{2{d;b};q};p' < $$FILE`"; \ + done >> $@ + printf '\n' >> $@ diff --git a/config b/config new file mode 100644 index 0000000..651a0e3 --- /dev/null +++ b/config @@ -0,0 +1,5 @@ +BLOG_TITLE:=based.cooking +BLOG_REMOTE:= +BLOG_DATE_FORMAT_INDEX:=%F +BLOG_DATE_FORMAT:=%F %H:%M +BLOG_SRC:=src diff --git a/src/pix/beef-goulash.webp b/data/pix/beef-goulash.webp similarity index 100% rename from src/pix/beef-goulash.webp rename to data/pix/beef-goulash.webp diff --git a/src/pix/cacio-e-pepe.webp b/data/pix/cacio-e-pepe.webp similarity index 100% rename from src/pix/cacio-e-pepe.webp rename to data/pix/cacio-e-pepe.webp diff --git a/src/pix/carbonara.webp b/data/pix/carbonara.webp similarity index 100% rename from src/pix/carbonara.webp rename to data/pix/carbonara.webp diff --git a/src/pix/cheesy-meatballs.webp b/data/pix/cheesy-meatballs.webp similarity index 100% rename from src/pix/cheesy-meatballs.webp rename to data/pix/cheesy-meatballs.webp diff --git a/src/pix/country-skillet.webp b/data/pix/country-skillet.webp similarity index 100% rename from src/pix/country-skillet.webp rename to data/pix/country-skillet.webp diff --git a/src/pix/creamy-mashed-potatoes.webp b/data/pix/creamy-mashed-potatoes.webp similarity index 100% rename from src/pix/creamy-mashed-potatoes.webp rename to data/pix/creamy-mashed-potatoes.webp diff --git a/src/pix/croutons.webp b/data/pix/croutons.webp similarity index 100% rename from src/pix/croutons.webp rename to data/pix/croutons.webp diff --git a/src/pix/csalad.webp b/data/pix/csalad.webp similarity index 100% rename from src/pix/csalad.webp rename to data/pix/csalad.webp diff --git a/src/pix/fried-anglerfish-fillet-00.webp b/data/pix/fried-anglerfish-fillet-00.webp similarity index 100% rename from src/pix/fried-anglerfish-fillet-00.webp rename to data/pix/fried-anglerfish-fillet-00.webp diff --git a/src/pix/fried-anglerfish-fillet-01.webp b/data/pix/fried-anglerfish-fillet-01.webp similarity index 100% rename from src/pix/fried-anglerfish-fillet-01.webp rename to data/pix/fried-anglerfish-fillet-01.webp diff --git a/src/pix/guacamole.webp b/data/pix/guacamole.webp similarity index 100% rename from src/pix/guacamole.webp rename to data/pix/guacamole.webp diff --git a/src/pix/japanese-noodle-soup.webp b/data/pix/japanese-noodle-soup.webp similarity index 100% rename from src/pix/japanese-noodle-soup.webp rename to data/pix/japanese-noodle-soup.webp diff --git a/src/pix/merchants-buckwheat.webp b/data/pix/merchants-buckwheat.webp similarity index 100% rename from src/pix/merchants-buckwheat.webp rename to data/pix/merchants-buckwheat.webp diff --git a/src/pix/pan-seared-chicken.webp b/data/pix/pan-seared-chicken.webp similarity index 100% rename from src/pix/pan-seared-chicken.webp rename to data/pix/pan-seared-chicken.webp diff --git a/src/pix/parmesan-potatoes.webp b/data/pix/parmesan-potatoes.webp similarity index 100% rename from src/pix/parmesan-potatoes.webp rename to data/pix/parmesan-potatoes.webp diff --git a/src/pix/pasta-navy-style.webp b/data/pix/pasta-navy-style.webp similarity index 100% rename from src/pix/pasta-navy-style.webp rename to data/pix/pasta-navy-style.webp diff --git a/src/pix/refried-beans.webp b/data/pix/refried-beans.webp similarity index 100% rename from src/pix/refried-beans.webp rename to data/pix/refried-beans.webp diff --git a/src/pix/sunday-milkshake.webp b/data/pix/sunday-milkshake.webp similarity index 100% rename from src/pix/sunday-milkshake.webp rename to data/pix/sunday-milkshake.webp diff --git a/src/pix/sweet-potato-fries.webp b/data/pix/sweet-potato-fries.webp similarity index 100% rename from src/pix/sweet-potato-fries.webp rename to data/pix/sweet-potato-fries.webp diff --git a/src/pix/tuscan-style-pork-roast.webp b/data/pix/tuscan-style-pork-roast.webp similarity index 100% rename from src/pix/tuscan-style-pork-roast.webp rename to data/pix/tuscan-style-pork-roast.webp diff --git a/src/style.css b/data/style.css similarity index 100% rename from src/style.css rename to data/style.css diff --git a/example.md b/example.md deleted file mode 100644 index dfb3d05..0000000 --- a/example.md +++ /dev/null @@ -1,36 +0,0 @@ -# This is the dish title - -If necessary, provide a very brief description of the dish in one or two sentences. -For most dishes, this will be unnecessary. -If there is a title image of this dish, it should be above this paragraph. -You may also include prep/cook time and the number of servings as below: - -- ⏲️ Prep time: 10 min -- 🍳Cook time: 30 min -- 🍽️ Servings: 4 - -## Ingredients - -- List the ingredients -- in an unordered list -- similar to this. -- List amounts if necessary. -- Put (optional) at the end of optional ingredients - -## Directions - -1. Now using an ordered list, -2. give the directions to prepare the dish. -3. Do **not** add unnecessary blank lines between items. -4. If necessary, -5. an image can be included between some directions if needed to explain something particular. -6. But that should be kept to a minimum to reduce bandwidth and aid in simplicity. - -## Contribution - -Here, just put your name and links to yourself (maybe a website or donation link) if you want. -You may say "Anonymous" or a screenname if desired. -If you add something substantial to an already existing recipe (including and image) you may add your name below with the contribution in parens. - -- Luke Smith - [website](https://lukesmith.xyz), [donate](https://lukesmith.xyz/donate) -- Luke Smith (photo credit) - [website](https://lukesmith.xyz), [donate](https://lukesmith.xyz/donate) diff --git a/src/index.md b/index.md similarity index 100% rename from src/index.md rename to index.md diff --git a/src/.ssgignore b/src/.ssgignore deleted file mode 100644 index febf952..0000000 --- a/src/.ssgignore +++ /dev/null @@ -1 +0,0 @@ -template.md diff --git a/src/_footer.html b/src/_footer.html deleted file mode 100644 index 452246e..0000000 --- a/src/_footer.html +++ /dev/null @@ -1,8 +0,0 @@ - - - - - diff --git a/src/_header.html b/src/_header.html deleted file mode 100644 index 3110681..0000000 --- a/src/_header.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/src/mortar-and-pestle.md b/src/mortar-and-pestle.md deleted file mode 100644 index 6abf387..0000000 --- a/src/mortar-and-pestle.md +++ /dev/null @@ -1,17 +0,0 @@ -# Get a Mortar and Pestle - -![mortar-and-pestle](pix/mortar-and-pestle.webp) - -Mortars and pestles are tools which have unfortunately been nearly forgotten in modern American kitchens, but they -have been around since the stone age for a reason. -They are one of the most useful appliances and require no electricity. - -They easily smash garlic, nuts and other things (also automatically removes skins). -This is much better than simple slicing because it squeezes out the juices and tastes of things. - -You can also easily make paste (like pesto) and out of herbs and other simple ingredients. -Many people use a hard-to-clean and expensive electric food processor to do things like this, -but a larger mortar and pestle could get the job done just as easily. - -Do not get porcelain mortar and pestles; they are non-functional and loud. -I have two granite ones which work very well (see pic above). diff --git a/src/pix/bitcoin-based-cooking.webp b/src/pix/bitcoin-based-cooking.webp deleted file mode 100644 index 1c5c8af..0000000 Binary files a/src/pix/bitcoin-based-cooking.webp and /dev/null differ diff --git a/src/pix/mortar-and-pestle.webp b/src/pix/mortar-and-pestle.webp deleted file mode 100644 index dd94795..0000000 Binary files a/src/pix/mortar-and-pestle.webp and /dev/null differ diff --git a/src/salt.md b/src/salt.md deleted file mode 100644 index e35af4f..0000000 --- a/src/salt.md +++ /dev/null @@ -1,41 +0,0 @@ -# Table Salt vs. Kosher Salt - -Table salt is the salt on your table: teeny-tiny grains in a little shaker. - -Kosher salt is the salt that should be in your kitchen: large, thick grains. - -Some people new to cooking get confused on the difference and when to use one or the other. - -The long story short is you should always use kosher salt for cooking. -Table salt is much more intense and is only for brisk post-cooking flavoring at the table. -Kosher salt is more subtle, dissolves slower and thus releases its flavor slower. - -Note also that you should add a larger mass of kosher salt where you might only -add a pinch of table salt, since table salt is much stronger partially because -it dissolves so quickly. - -## Table salt is not lindy. - -Table salt has iodine and other additives. - -Its history is somewhat analogous to the addition of fluoride to municipal -water supplies. Nearly a hundred years ago, the U.S. government began working -with corporations to add iodine to salt ostensibly because they were concerned -about people having iodine deficiencies. - -A healthy diet including eggs, dairy and some seafood should get enough iodine -elsewhere to not need it in the form of table salt supplements, so don't feel -like to you need to use it. - -## Why is kosher salt called "kosher" salt? - -Hebrews and then Jews revile eating meat with any blood in it. Larger grain -salt was better for the process called "koshering" whereby meat is covered in -salt and the salt draws out the liquid blood. Note that table salt is not -non-kosher in Mosaic law either, it is simply not suited for this "koshering" -process because it simply dissolves into the meat. - -For one reason or another, this association caught on and we now call coarse -grain salt "kosher." Note that kosher salt is more or less the natural form of -salt, it is not, as one might imagine, some new innovation to comply with -Jewish dietary practice. diff --git a/src/slow-cooking-tips.md b/src/slow-cooking-tips.md deleted file mode 100644 index e635445..0000000 --- a/src/slow-cooking-tips.md +++ /dev/null @@ -1,17 +0,0 @@ -# Slow Cooking Benefits and Tips - -You can buy a Slow Cooker for cheap, but it is still one of the most precious tools you can have in a kitchen. - -## Benefits - -- It's cheap: slow-cooking turns the toughest and cheapest cuts of meat into that "fall off the bone" goodness. Chuck steak and pork shoulder/Boston butts are some of the cheapest meats and are sure hard to eat, but put them in a slow-cooker and it's gourmet stuff. -- It is easy and low-effort: ingredients take very little time to prep and the cooking happens overnight or while you're at work. -- It's an objective science: a lot of people have a hard time developing the best techniques for kneading or pan-frying or other culinary skills, but slow-cooking just requires you put the ingredients in. No magic, just follow directions. -- It's relaxing: by the time your food is done, you've had plenty of time to clean up, so you can serve and eat your meal without having to worry about cleaning up afterwards. -- It's portable: you can cook for an event or your friends because you load up your slow-cooker and go. - -## Tips - -- Things that need more cooking should always go at the bottom. For example, potatoes take forever to cook, so put them under your meat. They'll get the extra cooking they need while getting marinated in juices. -- Only slow-cook dry herbs, not freshly-picked herbs, although you can add freshly-picked herbs in the last 10 or 20 minutes for some extra flavor. -- Only take off the top to check how things are doing in absolute emergencies. It loses a lot more heat than you might expect when you open that. diff --git a/src/template.md b/src/template.md deleted file mode 100644 index eca38fd..0000000 --- a/src/template.md +++ /dev/null @@ -1,49 +0,0 @@ -# Recipe name - -This is a brief, one or two sentence description of the dish. - -Optionally include a picture of the dish here, stored in `pix/` with the same base name as this file. -Please take your own picture after having followed exactly this recipe. - -## Ingredients - -- Just do -- a very simple -- markdown list for this -- with amounts. - -## Directions - -1. Now include the directions. -2. I suppose this list should be numbered -3. just for convenience's sake. -4. If necessary, include directional images between these items. - -![like this](lol.webp) - -5. Looks good. -6. Obvious, - -## Contributors - - - -- **Luke Smith** -- [website](https://lukesmith.xyz), [donate](https://lukesmith.xyz/donate) -- Billy Smith -- [website](https://lukesmith.xyz) (improved kneading technique added) - - - - diff --git a/ssg5 b/ssg5 deleted file mode 100755 index 9aa58fe..0000000 --- a/ssg5 +++ /dev/null @@ -1,263 +0,0 @@ -#!/bin/sh -e -# -# https://rgz.ee/bin/ssg5 -# Copyright 2018-2019 Roman Zolotarev -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -# - -main() { - test -n "$1" || usage - test -n "$2" || usage - test -n "$3" || usage - test -n "$4" || usage - test -d "$1" || no_dir "$1" - test -d "$2" || no_dir "$2" - - src=$(readlink_f "$1") - dst=$(readlink_f "$2") - - IGNORE=$( - if ! test -f "$src/.ssgignore" - then - printf ' ! -path "*/.*"' - return - fi - while read -r x - do - test -n "$x" || continue - printf ' ! -path "*/%s*"' "$x" - done < "$src/.ssgignore" - ) - - # files - - title="$3" - - h_file="$src/_header.html" - f_file="$src/_footer.html" - test -f "$f_file" && FOOTER=$(cat "$f_file") && export FOOTER - test -f "$h_file" && HEADER=$(cat "$h_file") && export HEADER - - list_dirs "$src" | - (cd "$src" && cpio -pdu "$dst") - - fs=$( - if test -f "$dst/.files" - then list_affected_files "$src" "$dst/.files" - else list_files "$1" - fi - ) - - if test -n "$fs" - then - echo "$fs" | tee "$dst/.files" - - if echo "$fs" | grep -q '\.md$' - then - if test -x "$(which lowdown 2> /dev/null)" - then - echo "$fs" | grep '\.md$' | - render_md_files_lowdown "$src" "$dst" "$title" - else - if test -x "$(which Markdown.pl 2> /dev/null)" - then - echo "$fs" | grep '\.md$' | - render_md_files_Markdown_pl "$src" "$dst" "$title" - else - echo "couldn't find lowdown nor Markdown.pl" - exit 3 - fi - fi - fi - - echo "$fs" | grep '\.html$' | - render_html_files "$src" "$dst" "$title" - - echo "$fs" | grep -Ev '\.md$|\.html$' | - (cd "$src" && cpio -pu "$dst") - fi - - printf '[ssg] ' >&2 - print_status 'file, ' 'files, ' "$fs" >&2 - - - # sitemap - - base_url="$4" - date=$(date +%Y-%m-%d) - urls=$(list_pages "$src") - - test -n "$urls" && - render_sitemap "$urls" "$base_url" "$date" > "$dst/sitemap.xml" - - print_status 'url' 'urls' "$urls" >&2 - echo >&2 -} - - -readlink_f() { - file="$1" - cd "$(dirname "$file")" - file=$(basename "$file") - while test -L "$file" - do - file=$(readlink "$file") - cd "$(dirname "$file")" - file=$(basename "$file") - done - dir=$(pwd -P) - echo "$dir/$file" -} - - -print_status() { - test -z "$3" && printf 'no %s' "$2" && return - - echo "$3" | awk -v singular="$1" -v plural="$2" ' - END { - if (NR==1) printf NR " " singular - if (NR>1) printf NR " " plural - }' -} - - -usage() { - echo "usage: ${0##*/} src dst title base_url" >&2 - exit 1 -} - - -no_dir() { - echo "${0##*/}: $1: No such directory" >&2 - exit 2 -} - -list_dirs() { - cd "$1" && eval "find . -type d ! -name '.' ! -path '*/_*' $IGNORE" -} - - -list_files() { - cd "$1" && eval "find . -type f ! -name '.' ! -path '*/_*' $IGNORE" -} - - -list_dependant_files () { - e="\\( -name '*.html' -o -name '*.md' -o -name '*.css' -o -name '*.js' \\)" - cd "$1" && eval "find . -type f ! -name '.' ! -path '*/_*' $IGNORE $e" -} - -list_newer_files() { - cd "$1" && eval "find . -type f ! -name '.' $IGNORE -newer $2" -} - - -has_partials() { - grep -qE '^./_.*\.html$|^./_.*\.js$|^./_.*\.css$' -} - - -list_affected_files() { - fs=$(list_newer_files "$1" "$2") - - if echo "$fs" | has_partials - then list_dependant_files "$1" - else echo "$fs" - fi -} - - -render_html_files() { - while read -r f - do render_html_file "$3" < "$1/$f" > "$2/$f" - done -} - - -render_md_files_lowdown() { - while read -r f - do - lowdown \ - < "$1/$f" | - render_html_file "$3" \ - > "$2/${f%\.md}.html" - done -} - - -render_md_files_Markdown_pl() { - while read -r f - do - Markdown.pl < "$1/$f" | - render_html_file "$3" \ - > "$2/${f%\.md}.html" - done -} - - -render_html_file() { - # h/t Devin Teske - awk -v title="$1" ' - { body = body "\n" $0 } - END { - body = substr(body, 2) - if (body ~ /<[Hh][Tt][Mm][Ll]/) { - print body - exit - } - if (match(body, /<[[:space:]]*[Hh]1(>|[[:space:]][^>]*>)/)) { - t = substr(body, RSTART + RLENGTH) - sub("<[[:space:]]*/[[:space:]]*[Hh]1.*", "", t) - gsub(/^[[:space:]]*|[[:space:]]$/, "", t) - if (t) title = t " — " title - } - n = split(ENVIRON["HEADER"], header, /\n/) - for (i = 1; i <= n; i++) { - if (match(tolower(header[i]), "")) { - head = substr(header[i], 1, RSTART - 1) - tail = substr(header[i], RSTART + RLENGTH) - print head "" title "" tail - } else print header[i] - } - print body - print ENVIRON["FOOTER"] - }' -} - - -list_pages() { - e="\\( -name '*.html' -o -name '*.md' \\)" - cd "$1" && eval "find . -type f ! -path '*/.*' ! -path '*/_*' $IGNORE $e" | - sed 's#^./##;s#.md$#.html#;s#/index.html$#/#' -} - - -render_sitemap() { - urls="$1" - base_url="$2" - date="$3" - - echo '' - echo '' - echo "$urls" | - sed -E 's#^(.*)$#'"$base_url"'/\1'\ -"$date"'1.0#' - echo '' -} - -main "$@" diff --git a/templates/article_entry.html b/templates/article_entry.html new file mode 100644 index 0000000..4c149eb --- /dev/null +++ b/templates/article_entry.html @@ -0,0 +1 @@ +
  • $TITLE
  • diff --git a/templates/article_footer.html b/templates/article_footer.html new file mode 100644 index 0000000..e69de29 diff --git a/templates/article_header.html b/templates/article_header.html new file mode 100644 index 0000000..e66f98c --- /dev/null +++ b/templates/article_header.html @@ -0,0 +1,2 @@ +

    index

    +

    Recipe posted on: $DATE_POSTED, last edited on: $DATE_EDITED, written by: $AUTHOR

    diff --git a/templates/article_list_footer.html b/templates/article_list_footer.html new file mode 100644 index 0000000..3d3a44c --- /dev/null +++ b/templates/article_list_footer.html @@ -0,0 +1 @@ + diff --git a/templates/article_list_header.html b/templates/article_list_header.html new file mode 100644 index 0000000..54ba16f --- /dev/null +++ b/templates/article_list_header.html @@ -0,0 +1,2 @@ +

    Recipes

    +