commit 6b3808305210877384d649de219fa404b8ec8b06 Author: Marco Date: Sat Mar 13 16:21:17 2021 +0100 Primo Commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..9468bab --- /dev/null +++ b/README.md @@ -0,0 +1,78 @@ +# Based Cooking Website + +[Ricette Basate](https://octosrv.me/ricette-basate) + +## To-do + +- get many recipes +- make and take pictures of recipes +- decide on CSS/styling, something good-looking and readable, but nothing too complicated +- search function? See below +- keep it simple + +## Rules for submission + +Add reciples as `.md` files to the `src/` directory. +Look at already existing `.md` files for examples +or see [example](example.md). + +Recipe must be based, i.e. good traditional and substantial food. Nothing +ironic, meme-tier hyper-sugary, meat-substitute, etc. + +### Minor rules + +- Don't include salt and pepper and other uniquitous things in the ingredients list. +- If measurements are used, include metric and American measurements. Do not use decimals in American; round or use fractions. + +## Images + +Each recipe can have a title image at the top and perhaps +several instructional images as absolutely necessary. + +Do not add stock images you found on the internet. +Take a good picture yourself of the actual dish created. +If you see a bad or substandard image, you may submit a better one. + +Images should be in `.webp` format. +If you submit an image for say, `chicken-parmesan.md`, it should be added as `pix/chicken-parmesan.webp`. +I will create smaller images from that which is seen on the page, +and upon being clicked, the user will see the full-size image. + +If you would like to add additional directional images, +they should be numbered with two digits like: `pix/chicken-parmesan-01.webp`, etc. + +## About the site + +The front page, for now, will just be a list of recipes +and when adding a `.md` page, please manually add a link to it in the list. +As more articles are added, the site will be reorganized, categorized +or will implement server-side scripting or searches. +This is not necessary yet though. + +I don't really want images of recipes on the mainpage yet. +I'll think about how best to do it to minimize bandwidth if possible. + +This site is generated with [Roman Zolotarev](https://www.romanzolotarev.com/)'s +[ssg5](https://www.romanzolotarev.com/ssg.html) which is also included in this +repo for replicability. + +## curl/Search function in the future + +I eventually want a command-line/curl interface to this site. +Part of this would be an implicit search function. + +So suppose someone wants a recipe with chicken, I'd like +`curl based.cooking/chicken` to return articles with that title. +If there is only one result, that page is opened. + +Just something to think about. +Then people could make a simple two or three character alias to get a simple text recipe. + +## License + +This website and all its content is in the public domain. +By submitting text or images or anything else to this repository, +you waive any pretense of ownership to it, +although you are welcome and recommended to give yourself credit +at the bottom of a submitted page for you adding it +(including personal or donation links). diff --git a/src/.ssgignore b/src/.ssgignore new file mode 100644 index 0000000..febf952 --- /dev/null +++ b/src/.ssgignore @@ -0,0 +1 @@ +template.md diff --git a/src/_footer.html b/src/_footer.html new file mode 100644 index 0000000..b446637 --- /dev/null +++ b/src/_footer.html @@ -0,0 +1,8 @@ + + + + + diff --git a/src/_header.html b/src/_header.html new file mode 100644 index 0000000..3651175 --- /dev/null +++ b/src/_header.html @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/index.md b/src/index.md new file mode 100644 index 0000000..8d73c96 --- /dev/null +++ b/src/index.md @@ -0,0 +1,21 @@ +# 🍳 Basatissimo 🍲 + +Solo ricette basate, divieto di bloat + +## Ricette + +- [Pasta al forno](pasta-al-forno.html) +- [Pane con la macchina del pane](pane-in-macchina.html) + +## Più informazioni + + +## In verità vi dico + +Forza Inter + +### Manca la vostra ricetta preferita? +È facile aggiungere la vostra! + +- Proponete le vostre ricette sul nostro [Git](https://git.octosrv.me/marco/ricette-basate) +- Per informazioni scrivete a [Marco](mailto:marco@octosrv.me) diff --git a/src/pane-in-macchina.md b/src/pane-in-macchina.md new file mode 100644 index 0000000..a874637 --- /dev/null +++ b/src/pane-in-macchina.md @@ -0,0 +1,22 @@ +# Pane in macchina del pane + +Pane in macchina - Clatronic + +## Ingredients + +- Acqua - 300ml +- Olio - 1,5 cucchiai +- Sale - 1 cucchiaino +- Zucchero - 1 cucchiaio +- Farina tipo0 e/o integrale - 540g +- Lievito secco - un pacchetto / 7g + +## Directions + +1. Butta tutto in macchina del pane +2. Fai partire con programma 1 (completo) oppure 8 (solo impasto per infornare a parte) + + +## Contribution + +- Mr. Clatronic diff --git a/src/pasta-al-forno.md b/src/pasta-al-forno.md new file mode 100644 index 0000000..814748f --- /dev/null +++ b/src/pasta-al-forno.md @@ -0,0 +1,24 @@ +# Pasta Al Forno + +È della pasta, è al forno + +## Ingredients + +- Pasta +- Mozzarella +- Ragù +- Ma in realtà tutte le cose che stanno bene in forno + +## Directions + +1. Cuoci pasta +2. Metti mozzarella cubetti in teglia +3. Metti sugo +4. Inforna finchè mozzarella sciolta +5. ??? +6. Profit + + +## Contribution + +- Tipo chiunque diff --git a/src/style.css b/src/style.css new file mode 100644 index 0000000..a6961f3 --- /dev/null +++ b/src/style.css @@ -0,0 +1,43 @@ +body { + max-width: 800px ; + margin: auto ; + padding: 0 16px ; + margin-bottom: 500px ; +} + +h1 { + text-align: center ; +} + +footer { + text-align: center ; +} + +img { + max-width: 600px ; + margin: auto ; + display: block ; +} + +@media (prefers-color-scheme: dark) { + body { + background: #151515 ; + color: white ; + } + a { + color: lightblue ; + } + a:visited { + color: gray ; + } + h2 { + color: tomato ; + } +} + +@media print { + a[href] { + text-decoration: none ; + color: black ; + } +} diff --git a/src/template.md b/src/template.md new file mode 100644 index 0000000..a82314d --- /dev/null +++ b/src/template.md @@ -0,0 +1,24 @@ +# Nome ricetta + +Aggiungete una breve descrizione + + +## Ingredienti + +- Basta +- Una semplice +- lista +- in markdown + +## Procedura + +1. Qua +2. Un bell'elenco +3. Numerato +4. Perchè ci piacciono le cose belle + +## Crediti + +- **Vostro Nome** -- [Vostro sito](https://se-volete.com) + +P.S. non dimenticate di aggiungere il link ne file index.md! diff --git a/ssg5 b/ssg5 new file mode 100755 index 0000000..9aa58fe --- /dev/null +++ b/ssg5 @@ -0,0 +1,263 @@ +#!/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/update b/update new file mode 100755 index 0000000..a30114e --- /dev/null +++ b/update @@ -0,0 +1,5 @@ +#!/bin/sh +git pull gitocto master + +./ssg5 ./src/ /var/www/iindice/ricette-basate/ "OctoCooking" "https://octosrv.me/ricette-basate" +