diff options
author | xengineering <me@xengineering.eu> | 2023-12-27 13:33:59 +0100 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2023-12-27 13:33:59 +0100 |
commit | c6d2e9dadcd08cdf82aab507d9d4d8d58574df20 (patch) | |
tree | 65495b3fd84060638c5dc396417b6aab926bca79 /view/html | |
parent | 1978c5257e2cf4720716b59c3d69dc21cf457c18 (diff) | |
download | ceres-c6d2e9dadcd08cdf82aab507d9d4d8d58574df20.tar ceres-c6d2e9dadcd08cdf82aab507d9d4d8d58574df20.tar.zst ceres-c6d2e9dadcd08cdf82aab507d9d4d8d58574df20.zip |
Implement index page with recipe overview
Diffstat (limited to 'view/html')
-rw-r--r-- | view/html/footer.html | 5 | ||||
-rw-r--r-- | view/html/head.html | 8 | ||||
-rw-r--r-- | view/html/index.html | 40 |
3 files changed, 53 insertions, 0 deletions
diff --git a/view/html/footer.html b/view/html/footer.html new file mode 100644 index 0000000..5128b7f --- /dev/null +++ b/view/html/footer.html @@ -0,0 +1,5 @@ +{{define "footer"}} +<footer> + <p>The <a href="https://xengineering.eu/git/ceres">Ceres</a> recipe server is licensed under <a href="https://www.gnu.org/licenses/agpl-3.0.en.html">AGPL v3</a> and developed with <a href="https://simplecss.org/">simple.css</a>.</p> +</footer> +{{end}} diff --git a/view/html/head.html b/view/html/head.html new file mode 100644 index 0000000..91ae004 --- /dev/null +++ b/view/html/head.html @@ -0,0 +1,8 @@ +{{define "head"}} +<head> + <title>Recipes</title> + <meta charset="utf-8"/> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <link rel="stylesheet" href="/static/view/static/simple.css/simple.css" type="text/css"> +</head> +{{end}} diff --git a/view/html/index.html b/view/html/index.html new file mode 100644 index 0000000..45f600f --- /dev/null +++ b/view/html/index.html @@ -0,0 +1,40 @@ +{{define "index"}} +<html> + {{ template "head" }} + <header> + <nav> + <a href="/">HOME</a> + </nav> + <h1>Recipe overview</h1> + </header> + <body> + <main> + <p>Here are the available recipes 😋🍳🍔🍕🥘</p> + <input id="search" onkeyup="filter()" type="text" placeholder="Search for a recipe ..."></input> + <ul id="recipes">{{range .}} + <li><a href="./recipes/{{.Id}}">{{.Title}}</a></li>{{end}} + </ul> + </main> + {{ template "footer" }} + <script> + function filter() { + var input, query, ul, li, a, i, txtValue; + input = document.getElementById('search'); + query = input.value.toUpperCase(); + ul = document.getElementById("recipes"); + li = ul.getElementsByTagName('li'); + + for (i = 0; i < li.length; i++) { + a = li[i].getElementsByTagName("a")[0]; + txtValue = a.textContent || a.innerText; + if (txtValue.toUpperCase().indexOf(query) > -1) { + li[i].style.display = ""; + } else { + li[i].style.display = "none"; + } + } + } + </script> + </body> +</html> +{{end}} |