Updated forms. Added scrapers. Updated edit page for scrapers. Made new wishlist look better and added warning to save uuids somewhere safe. Updated nix flake.
This commit is contained in:
parent
1f269afce5
commit
13d63245ed
14 changed files with 367 additions and 109 deletions
5
app/templates/components.html
Normal file
5
app/templates/components.html
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{% macro mainCenter() %}
|
||||
<main class="w-full h-screen flex justify-center items-center">
|
||||
{{ caller() }}
|
||||
</main>
|
||||
{% endmacro %}
|
||||
|
|
@ -1,98 +1,121 @@
|
|||
{% set cpath = url_for("edit", id=wishlist.editId) %}
|
||||
<main>
|
||||
<h1>Edit '{{wishlist.title}}'</h1>
|
||||
<sub>Manage your wishlist details and items</sub>
|
||||
<br>
|
||||
<form action="{{ cpath }}" method="POST">
|
||||
{{ form_wl_editinfo.hidden_tag() }}
|
||||
{{ form_wl_editinfo.title.label }}
|
||||
{{ form_wl_editinfo.title(placeholder=wishlist.title) }}
|
||||
<!-- <br> -->
|
||||
{{ form_wl_editinfo.description.label }}
|
||||
{{ form_wl_editinfo.description(placeholder=wishlist.description) }}
|
||||
<!-- <br> -->
|
||||
{{ form_wl_editinfo.wl_edit_submit() }}
|
||||
</form>
|
||||
<br>
|
||||
<h1>Urls</h1>
|
||||
<ul>
|
||||
<li>
|
||||
View: <a href={{ url_for("view", id=wishlist.viewId) }}>{{ wishlist.viewId }}</a>
|
||||
</li>
|
||||
<li>
|
||||
Edit: <a href={{ url_for("edit", id=wishlist.editId) }}>{{ wishlist.editId }}</a>
|
||||
</li>
|
||||
</ul>
|
||||
<form action="{{ cpath }}" method="POST">
|
||||
{{ form_wl_reseturls.hidden_tag() }}
|
||||
{{ form_wl_reseturls.wl_reset_submit() }}
|
||||
</form>
|
||||
<br>
|
||||
<h1>New item</h1>
|
||||
<form action="{{ cpath }}" method="POST">
|
||||
{{ form_it_new.hidden_tag() }}
|
||||
<!-- <br> -->
|
||||
{{ form_it_new.it_new_title.label }}
|
||||
{{ form_it_new.it_new_title() }}
|
||||
<!-- <br> -->
|
||||
{{ form_it_new.description.label }}
|
||||
{{ form_it_new.description() }}
|
||||
<!-- <br> -->
|
||||
{{ form_it_new.price.label }}
|
||||
{{ form_it_new.price() }}
|
||||
<!-- <br> -->
|
||||
{{ form_it_new.url.label }}
|
||||
{{ form_it_new.url() }}
|
||||
<!-- <br> -->
|
||||
{{ form_it_new.image.label }}
|
||||
{{ form_it_new.image() }}
|
||||
<!-- <br> -->
|
||||
{{ form_it_new.it_new_submit() }}
|
||||
<button id="scrape">Scrape</button>
|
||||
</form>
|
||||
<br>
|
||||
<h1>Delete items</h1>
|
||||
{% if wishlist.items|length == 0 %}<p>No items yet</p>{% endif %}
|
||||
<ul>
|
||||
{% for value in wishlist.items %}
|
||||
<li>
|
||||
<form action="{{ cpath }}" method="POST">
|
||||
{{ form_it_delete.csrf_token }}
|
||||
{{ form_it_delete.index(value=loop.index) }}
|
||||
{{ form_it_delete.it_del_submit() }}
|
||||
</form>
|
||||
{{ value.title }}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<br>
|
||||
<h1>Delete wishlist</h1>
|
||||
<form action="{{ cpath }}" method="POST">
|
||||
{{ form_wl_delete.hidden_tag() }}
|
||||
{{ form_wl_delete.wl_del_submit() }}
|
||||
</form>
|
||||
<style>
|
||||
form {
|
||||
display:grid;
|
||||
grid-template-columns: max-content max-content;
|
||||
grid-gap:5px;
|
||||
}
|
||||
form label { text-align:right; }
|
||||
form label:after { content: ":"; }
|
||||
</style>
|
||||
</main>
|
||||
|
||||
<h1>Metadata</h1>
|
||||
<form action="{{ cpath }}" method="POST">
|
||||
{{ form_wl_editinfo.hidden_tag() }}
|
||||
<script>
|
||||
const $q = (...i) => document.querySelector(...i);
|
||||
const title = $q("#it_new_title")
|
||||
const price = $q("#price")
|
||||
const url = $q("#url")
|
||||
const image = $q("#image")
|
||||
// const description = $q("#description")
|
||||
|
||||
{{ form_wl_editinfo.title.label }}
|
||||
{{ form_wl_editinfo.title(placeholder=wishlist.title) }}
|
||||
$q("#scrape").addEventListener("click", async e => {
|
||||
e.preventDefault()
|
||||
const tUrl = url.value.trim();
|
||||
|
||||
<!-- <br> -->
|
||||
{{ form_wl_editinfo.description.label }}
|
||||
{{ form_wl_editinfo.description(placeholder=wishlist.description) }}
|
||||
if (!tUrl) {
|
||||
alert("Please provide a valid url.") //TODO: Replace with daisyui modal
|
||||
return
|
||||
}
|
||||
|
||||
<!-- <br> -->
|
||||
{{ form_wl_editinfo.wl_edit_submit() }}
|
||||
</form>
|
||||
const res = await fetch(
|
||||
"/scrape?" + new URLSearchParams({
|
||||
url: tUrl
|
||||
}).toString(),
|
||||
{
|
||||
method: "get",
|
||||
}
|
||||
)
|
||||
|
||||
<br>
|
||||
<h1>Urls</h1>
|
||||
<ul>
|
||||
<li>
|
||||
View: <a href={{ url_for("view", id=wishlist.viewId) }}>{{ wishlist.viewId }}</a>
|
||||
</li>
|
||||
<li>
|
||||
Edit: <a href={{ url_for("edit", id=wishlist.editId) }}>{{ wishlist.editId }}</a>
|
||||
</li>
|
||||
</ul>
|
||||
if (res.status !== 200) {
|
||||
alert("Failed to scrape site.")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
<form action="{{ cpath }}" method="POST">
|
||||
{{ form_wl_reseturls.hidden_tag() }}
|
||||
{{ form_wl_reseturls.wl_reset_submit() }}
|
||||
</form>
|
||||
|
||||
<br>
|
||||
<h1>New item</h1>
|
||||
<form action="{{ cpath }}" method="POST">
|
||||
{{ form_it_new.hidden_tag() }}
|
||||
|
||||
<!-- <br> -->
|
||||
{{ form_it_new.title.label }}
|
||||
{{ form_it_new.title() }}
|
||||
|
||||
<!-- <br> -->
|
||||
{{ form_it_new.description.label }}
|
||||
{{ form_it_new.description() }}
|
||||
|
||||
<!-- <br> -->
|
||||
{{ form_it_new.price.label }}
|
||||
{{ form_it_new.price() }}
|
||||
|
||||
<!-- <br> -->
|
||||
{{ form_it_new.url.label }}
|
||||
{{ form_it_new.url() }}
|
||||
|
||||
<!-- <br> -->
|
||||
{{ form_it_new.image.label }}
|
||||
{{ form_it_new.image() }}
|
||||
|
||||
<!-- <br> -->
|
||||
{{ form_it_new.it_new_submit() }}
|
||||
</form>
|
||||
|
||||
<br>
|
||||
<h1>Delete items</h1>
|
||||
|
||||
{% if wishlist.items|length == 0 %}
|
||||
<p>No items yet</p>
|
||||
{% endif %}
|
||||
<ul>
|
||||
{% for value in wishlist.items %}
|
||||
<li>
|
||||
<form action="{{ cpath }}" method="POST">
|
||||
{{ form_it_delete.csrf_token }}
|
||||
{{ form_it_delete.index(value=loop.index) }}
|
||||
{{ form_it_delete.it_del_submit() }}
|
||||
</form>
|
||||
{{ value.title }}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<br>
|
||||
<h1>Delete wishlist</h1>
|
||||
<form action="{{ cpath }}" method="POST">
|
||||
{{ form_wl_delete.hidden_tag() }}
|
||||
{{ form_wl_delete.wl_del_submit() }}
|
||||
</form>
|
||||
|
||||
<style>
|
||||
form {
|
||||
display:grid;
|
||||
grid-template-columns: max-content max-content;
|
||||
grid-gap:5px;
|
||||
}
|
||||
form label { text-align:right; }
|
||||
form label:after { content: ":"; }
|
||||
</style>
|
||||
const json = await res.json()
|
||||
title.value = json.name;
|
||||
image.value = json.image;
|
||||
price.value = json.price;
|
||||
})
|
||||
</script>
|
||||
|
|
|
|||
2
app/templates/footer.html
Normal file
2
app/templates/footer.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
</body>
|
||||
</html>
|
||||
11
app/templates/header.html
Normal file
11
app/templates/header.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Wishthat</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/daisyui@5" rel="stylesheet" type="text/css" />
|
||||
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
|
||||
</head>
|
||||
<body class="m-0 p-0 w-full h-screen bg-base-200">
|
||||
|
||||
0
app/templates/index.html
Normal file
0
app/templates/index.html
Normal file
|
|
@ -1,11 +1,20 @@
|
|||
<form action="{{ url_for("new") }}" method="POST">
|
||||
{{ form.hidden_tag() }}
|
||||
{% include 'header.html' %}
|
||||
|
||||
{{ form.title.label }}
|
||||
{{ form.title() }}
|
||||
<main class="w-full h-screen flex justify-center items-end md:items-center">
|
||||
<form action="{{ url_for("new") }}" method="POST" class="border-2 border-base-300 w-full md:w-md p-6 m-4 rounded-lg shadow-lg bg-base-100">
|
||||
{{ form.hidden_tag() }}
|
||||
|
||||
{{ form.description.label }}
|
||||
{{ form.description() }}
|
||||
<h1 class="text-3xl font-semibold text-center text-info-content mb-4">New wishlist</h1>
|
||||
|
||||
{{ form.submit() }}
|
||||
</form>
|
||||
<legend class="fieldset-legend">{{ form.title.label.text }}</legend>
|
||||
{{ form.title(class="w-full input validator mt-1 mb-4", placeholder="Wishlist Title") }}
|
||||
|
||||
<legend class="fieldset-legend">{{ form.description.label.text }}</legend>
|
||||
{{ form.description(class="w-full textarea validator mt-1 mb-2", placeholder="Wishlist Description") }}
|
||||
<div class="validator-hint">Please make sure that both inputs are filled.</div>
|
||||
|
||||
{{ form.submit(class="btn btn-soft w-full") }}
|
||||
</form>
|
||||
</main>
|
||||
|
||||
{% include 'footer.html' %}
|
||||
|
|
|
|||
14
app/templates/post_new.html
Normal file
14
app/templates/post_new.html
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
{% include 'header.html' %}
|
||||
|
||||
<dialog class="modal modal-bottom md:modal-middle" open>
|
||||
<div class="modal-box">
|
||||
<h3 class="text-lg font-bold">Before you continue</h3>
|
||||
<p class="py-4">Wishthat operates using two distinct passcodes: one for viewing the wishlist and another for editing it. Think of it as a combination of a username and password. Please navigate to the edit page and <b>bookmark the URL</b>, as you will <b>not be able to edit your wishlist if you lose this passcode</b>. You can also find the passcode for viewing the wishlist on the edit page.</p>
|
||||
<div class="modal-action">
|
||||
<a class="btn" href="/view/{{viewId}}">View</a>
|
||||
<a class="btn btn-primary" href="/edit/{{editId}}">Edit</a>
|
||||
</div>
|
||||
</div>
|
||||
</dialog>
|
||||
|
||||
{% include 'footer.html' %}
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
{% include 'header.html' %}
|
||||
|
||||
<h1>{{wishlist.title}}</h1>
|
||||
<sub>{{wishlist.description}}</sub>
|
||||
|
||||
|
|
@ -54,3 +56,5 @@
|
|||
}
|
||||
|
||||
</script>
|
||||
|
||||
{% include 'footer.html' %}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue