diff options
author | xengineering <me@xengineering.eu> | 2022-11-05 21:25:31 +0100 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2022-11-07 21:17:44 +0100 |
commit | 1d6b45bebea66391a2a535a3bb328a5732aaa75d (patch) | |
tree | 12faa62d8d8574ad8c94f4a7c9ff206c34456430 /data | |
download | ceres-1d6b45bebea66391a2a535a3bb328a5732aaa75d.tar ceres-1d6b45bebea66391a2a535a3bb328a5732aaa75d.tar.zst ceres-1d6b45bebea66391a2a535a3bb328a5732aaa75d.zip |
Add existing work
Diffstat (limited to 'data')
-rw-r--r-- | data/.gitignore | 1 | ||||
-rw-r--r-- | data/static/add.html | 33 | ||||
l--------- | data/static/libweb.css | 1 | ||||
-rw-r--r-- | data/templates/index.html | 31 | ||||
-rw-r--r-- | data/templates/recipe.html | 64 |
5 files changed, 130 insertions, 0 deletions
diff --git a/data/.gitignore b/data/.gitignore new file mode 100644 index 0000000..fa780e2 --- /dev/null +++ b/data/.gitignore @@ -0,0 +1 @@ +storage diff --git a/data/static/add.html b/data/static/add.html new file mode 100644 index 0000000..ed02811 --- /dev/null +++ b/data/static/add.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> + +<html> + + <head> + + <title>Recipes</title> + + <meta charset="utf-8"/> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <link rel="stylesheet" href="./static/libweb.css" type="text/css"> + + </head> + + <body> + + <main> + + <h1>Add a recipe</h1> + + <form action="/add_recipes" method="post"> + <label for="custom_title">Title:</label><br> + <input style="border: 1px solid;" type="text" id="custom_title" name="title"><br> + <label for="custom_link">Link (optional):</label><br> + <input style="border: 1px solid;" type="text" id="custom_link" name="url"><br> + <button class="card-last-item" type="submit">add</button> + </form> + + </main> + + </body> + +</html> diff --git a/data/static/libweb.css b/data/static/libweb.css new file mode 120000 index 0000000..efe201e --- /dev/null +++ b/data/static/libweb.css @@ -0,0 +1 @@ +../../libweb/libweb.css
\ No newline at end of file diff --git a/data/templates/index.html b/data/templates/index.html new file mode 100644 index 0000000..f216ed4 --- /dev/null +++ b/data/templates/index.html @@ -0,0 +1,31 @@ +<!DOCTYPE html> + +<html> + + <head> + + <title>Recipes</title> + + <meta charset="utf-8"/> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <link rel="stylesheet" href="./static/libweb.css" type="text/css"> + + </head> + + <body> + + <main> + <h1>Recipes</h1> + <button><a href="./add_recipes">add recipe</a></button> + <p>Here are the available recipes 😋🍳🍔🍕🥘</p> + {{range .}} + <a href="./recipe?id={{.Id}}"> + <div class="card"> + <h5 class="card-first-item" class="card-last-item">{{.Title}}</h5> + </div> + </a>{{end}} + </main> + + </body> + +</html> diff --git a/data/templates/recipe.html b/data/templates/recipe.html new file mode 100644 index 0000000..fcfdf67 --- /dev/null +++ b/data/templates/recipe.html @@ -0,0 +1,64 @@ +<!DOCTYPE html> + +<html> + + <head> + + <title>Recipes</title> + + <meta charset="utf-8"/> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <link rel="stylesheet" href="../../../static/libweb.css" type="text/css"> + + </head> + + <body> + + <main> + <h1>{{.Title}}</h1> + <img src="./recipe/image?id={{.Id}}" alt="Recipe image">{{if ne .UpstreamUrl ""}} + <p><a href="{{.UpstreamUrl}}">Link to recipe</a></p>{{end}} + <h2>Recipe description</h2> + <button id="editbtn" style="margin-top:20px;margin-bottom:20px;display:block" onclick=startEditMode()>edit</button> + <button id="cancelbtn" style="margin-top:20px;margin-bottom:20px;display:none" onclick=cancelEditMode()>abort</button> + <button id="savebtn" style="margin-top:20px;margin-bottom:20px;display:none" onclick=saveDescriptionMarkdown()>save</button> + <pre id="description_md" style="display:none;" contenteditable="true">{{.DescriptionMarkdown}}</pre> + <div id="rendered_description_md" style="display:block;"> + {{.RenderedDescriptionMarkdown}} + </div> + </main> + + <script> + var editbtn = document.getElementById("editbtn"); + var cancelbtn = document.getElementById("cancelbtn"); + var savebtn = document.getElementById("savebtn"); + var description_md = document.getElementById("description_md"); + var rendered_description_md = document.getElementById("rendered_description_md"); + + function startEditMode() { + editbtn.style.display = "none"; + rendered_description_md.style.display = "none"; + cancelbtn.style.display = "block"; + savebtn.style.display = "block"; + description_md.style.display = "block"; + } + + function cancelEditMode() { + window.location.reload(true); + } + + function saveDescriptionMarkdown() { + var xhttp = new XMLHttpRequest(); + xhttp.onreadystatechange = function() { + if (this.readyState == 4) { + window.location.reload(true); + } + } + xhttp.open("POST", window.location.href, true); + xhttp.send(description_md.innerHTML.replaceAll("<br>", "\n")); + } + </script> + + </body> + +</html> |