added tags to recipe page

This commit is contained in:
overflowerror 2022-03-31 21:00:39 +02:00
parent d373f387b7
commit a3e6e0c258
3 changed files with 20 additions and 1 deletions

View file

@ -33,7 +33,9 @@ recipe() {
ingredients="$(echo "$result" | getColumns 3)"
nrIngredients="$(echo "$qts" | wc -l)"
title=""
tags="$(getTagsByRecipeId "$id" | getColumns 1)"
title="$name"
content="$(template "templates/recipe.fragment.templ")"
template "templates/layout.html.templ"
}

View file

@ -35,6 +35,18 @@ getRecipeById() {
EOF
}
getTagsByRecipeId() {
local id="$(echo "$1" | sed 's/[^0-9]//g')"
query <<EOF
SELECT DISTINCT name
FROM tags
INNER JOIN recipeTags
ON recipeTags.tagFk = tags.id
WHERE recipeFk = $id
EOF
}
addRecipe() {
local name="$1"
local description="$2"

View file

@ -1,4 +1,9 @@
<h1>{{ print "$name" }}</h1>
<ul>
{{ for t in $tags; do }}
<li>{{ print "$t" }}</li>
{{ done }}
</ul>
<p>
from <a href="/profile?id={{ print "$uid" }}">{{ print "$author" }}</a>
</p>