use a clean Makefile system to build/deploy site

This way, we get dependency/smart update for free. We don't need to
rebuild all the pages everytime a new one is added. The author, date of
creation and date of revision are extracted from git information. The
index is generated automatically, so adding a recipe is literally just
adding a markdown file in src/.

The deployment system uses rsync to push only newer data to the server.

There is a tag system that you can add at the end of each recipe file.
Tag pages are generated statically that contain all recipes with a given
tag.

It introduces more HTML template files, though.

To build website, type
make build

To deploy it,
make deploy

To clean everything,
make clean
pull/78/head
Sylvain Gauthier 3 years ago
parent feb5d6ca8e
commit 9e99745276

3
.gitignore vendored

@ -1 +1,2 @@
dest
rss.xml
atom.xml

@ -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 '<!DOCTYPE html><html><head><title>$$TITLE</title></head><body>' > templates/header.html
printf '</body></html>' > templates/footer.html
printf '' > templates/index_header.html
printf '<p>Tags:' > templates/tag_list_header.html
printf '<a href="$$URL">$$NAME</a>' > templates/tag_entry.html
printf ', ' > templates/tag_separator.html
printf '</p>' > templates/tag_list_footer.html
printf '<h2>Articles</h2><ul>' > templates/article_list_header.html
printf '<li><a href="$$URL">$$DATE $$TITLE</a></li>' > templates/article_entry.html
printf '' > templates/article_separator.html
printf '</ul>' > 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 '<?xml version="1.0" encoding="UTF-8"?>\n<rss version="2.0">\n<channel>\n<title>%s</title>\n<link>%s</link>\n<description>%s</description>\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 '<item>\n<title>%s</title>\n<link>%s</link>\n<guid>%s</guid>\n<pubDate>%s</pubDate>\n<description>%s</description>\n</item>\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 '</channel>\n</rss>\n' >> $@
blog/atom.xml: $(ARTICLES)
printf '<?xml version="1.0" encoding="UTF-8"?>\n<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">\n<title type="text">%s</title>\n<subtitle type="text">%s</subtitle>\n<updated>%s</updated>\n<link rel="alternate" type="text/html" href="%s"/>\n<id>%s</id>\n<link rel="self" type="application/atom+xml" href="%s"/>\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 '<entry>\n<title type="text">%s</title>\n<link rel="alternate" type="text/html" href="%s"/>\n<id>%s</id>\n<published>%s</published>\n<updated>%s</updated>\n<author><name>%s</name></author>\n<summary type="text">%s</summary>\n</entry>\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 '</feed>\n' >> $@

@ -0,0 +1,5 @@
BLOG_TITLE:=based.cooking
BLOG_REMOTE:=
BLOG_DATE_FORMAT_INDEX:=%F
BLOG_DATE_FORMAT:=%F %H:%M
BLOG_SRC:=src

Before

Width:  |  Height:  |  Size: 158 KiB

After

Width:  |  Height:  |  Size: 158 KiB

Before

Width:  |  Height:  |  Size: 64 KiB

After

Width:  |  Height:  |  Size: 64 KiB

Before

Width:  |  Height:  |  Size: 259 KiB

After

Width:  |  Height:  |  Size: 259 KiB

Before

Width:  |  Height:  |  Size: 79 KiB

After

Width:  |  Height:  |  Size: 79 KiB

Before

Width:  |  Height:  |  Size: 118 KiB

After

Width:  |  Height:  |  Size: 118 KiB

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 47 KiB

Before

Width:  |  Height:  |  Size: 91 KiB

After

Width:  |  Height:  |  Size: 91 KiB

Before

Width:  |  Height:  |  Size: 133 KiB

After

Width:  |  Height:  |  Size: 133 KiB

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 66 KiB

Before

Width:  |  Height:  |  Size: 103 KiB

After

Width:  |  Height:  |  Size: 103 KiB

Before

Width:  |  Height:  |  Size: 142 KiB

After

Width:  |  Height:  |  Size: 142 KiB

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Before

Width:  |  Height:  |  Size: 132 KiB

After

Width:  |  Height:  |  Size: 132 KiB

Before

Width:  |  Height:  |  Size: 127 KiB

After

Width:  |  Height:  |  Size: 127 KiB

Before

Width:  |  Height:  |  Size: 92 KiB

After

Width:  |  Height:  |  Size: 92 KiB

Before

Width:  |  Height:  |  Size: 219 KiB

After

Width:  |  Height:  |  Size: 219 KiB

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 62 KiB

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 56 KiB

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 51 KiB

Before

Width:  |  Height:  |  Size: 204 KiB

After

Width:  |  Height:  |  Size: 204 KiB

@ -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)

@ -1 +0,0 @@
template.md

@ -1,8 +0,0 @@
<footer>
<a href="index.html">🏡 Based Cooking Homepage</a> </br>
All site content is in the Public Domain.
</footer>
</body>
</html>

@ -1,12 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta charset=UTF-8>
<link rel=stylesheet href=style.css>
<link rel="shortcut icon" type="image/x-icon" href="favicon.png">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>

@ -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).

Binary file not shown.

Before

Width:  |  Height:  |  Size: 558 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 53 KiB

@ -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.

@ -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.

@ -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
<!--
Put your name or identifier here if you want.
Limit yourself to a single line with links like this:
-->
- **Luke Smith** -- [website](https://lukesmith.xyz), [donate](https://lukesmith.xyz/donate)
- Billy Smith -- [website](https://lukesmith.xyz) (improved kneading technique added)
<!--
If someone add a *substantial* improvement, they can add their name to the
bottom of the list (at least for the time being). In that case, the original
author's line should still be at the top and bold.
-->
<!--
Other Rules:
- Images should be as small as possible in size, preferably .webp files.
- Minor edits (spell checkings) do not warrant credit at the bottom.
- Everything you add here should be public domain. Getting credit at the bottom for adding the article is not a claim to ownership.
-->

263
ssg5

@ -1,263 +0,0 @@
#!/bin/sh -e
#
# https://rgz.ee/bin/ssg5
# Copyright 2018-2019 Roman Zolotarev <hi@romanzolotarev.com>
#
# 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 " &mdash; " title
}
n = split(ENVIRON["HEADER"], header, /\n/)
for (i = 1; i <= n; i++) {
if (match(tolower(header[i]), "<title></title>")) {
head = substr(header[i], 1, RSTART - 1)
tail = substr(header[i], RSTART + RLENGTH)
print head "<title>" title "</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 '<?xml version="1.0" encoding="UTF-8"?>'
echo '<urlset'
echo 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
echo 'xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9'
echo 'http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"'
echo 'xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'
echo "$urls" |
sed -E 's#^(.*)$#<url><loc>'"$base_url"'/\1</loc><lastmod>'\
"$date"'</lastmod><priority>1.0</priority></url>#'
echo '</urlset>'
}
main "$@"

@ -0,0 +1 @@
<li><a href="$URL">$TITLE</a></li>

@ -0,0 +1,2 @@
<p><a href=".">index</a></p>
<p><i>Recipe posted on: $DATE_POSTED, last edited on: $DATE_EDITED, written by: $AUTHOR</i></p>

@ -0,0 +1,2 @@
<h2>Recipes</h2>
<ul>

@ -0,0 +1,7 @@
<p>This website is a fork from <a href="https://based.cooking">Luke Smith's Based Cooking</a></p>
<div class="footer">
<hr/>
<a href="./rss.xml">RSS</a>
<a href="./atom.xml">atom</a>
</div>
</body></html>

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="./style.css">
<title>$TITLE</title>
</head>
<body>
<div class="banner">
<h1>🍳 Based Cooking 🍲</h1>
<hr/>
</div>

@ -0,0 +1 @@
<p>Only Based cooking. No ads, no tracking, nothing but based cooking.</p>

@ -0,0 +1 @@
<a href="$URL">$NAME</a>

@ -0,0 +1,2 @@
<p><a href=".">index</a></p>
<p><i>Filtering recipes tagged:</i> <b>$TAGS</b></p>
Loading…
Cancel
Save