Primo Commit

This commit is contained in:
Marco 2021-03-13 16:21:17 +01:00
commit 6b38083052
11 changed files with 501 additions and 0 deletions

78
README.md Normal file
View File

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

1
src/.ssgignore Normal file
View File

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

8
src/_footer.html Normal file
View File

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

12
src/_header.html Normal file
View File

@ -0,0 +1,12 @@
<!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>

21
src/index.md Normal file
View File

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

22
src/pane-in-macchina.md Normal file
View File

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

24
src/pasta-al-forno.md Normal file
View File

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

43
src/style.css Normal file
View File

@ -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 ;
}
}

24
src/template.md Normal file
View File

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

263
ssg5 Executable file
View File

@ -0,0 +1,263 @@
#!/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 "$@"

5
update Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
git pull gitocto master
./ssg5 ./src/ /var/www/iindice/ricette-basate/ "OctoCooking" "https://octosrv.me/ricette-basate"