aboutsummaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
Diffstat (limited to 'public')
-rw-r--r--public/index.php12
-rw-r--r--public/kontakt.php10
-rw-r--r--public/omdömen.php32
-rw-r--r--public/omdömen/edit.php33
-rw-r--r--public/omdömen/index.php60
-rw-r--r--public/style.css6
6 files changed, 98 insertions, 55 deletions
diff --git a/public/index.php b/public/index.php
index 8e6f565..0dd4d48 100644
--- a/public/index.php
+++ b/public/index.php
@@ -1,16 +1,6 @@
<?php require "../include/layout.php"; layout($_); ?>
-<header>
- <section>
- <p>Trädgårdstomten ✂️</p>
- </section>
- <nav>
- <a href="/">Tjänster</a>
- <a href="/omdömen">Omdömen</a>
- <a href="/kontakt">Kontakt</a>
- </nav>
-</header>
<main>
- <article>
+ <article id="about-text">
<p style="grid-area: p1">
Jag heter Lucas Magnusson, är 26 år gammal och har flera års yrkeserfarenhet och
är även utbildad inom trädgård. Jag har alltid varit intresserad av allt som
diff --git a/public/kontakt.php b/public/kontakt.php
index a23e0c6..ed60c0d 100644
--- a/public/kontakt.php
+++ b/public/kontakt.php
@@ -1,14 +1,4 @@
<?php require "../include/layout.php"; layout($_); ?>
-<header>
- <section>
- <p>Trädgårdstomten ✂️</p>
- </section>
- <nav>
- <a href="/">Tjänster</a>
- <a href="/omdömen">Omdömen</a>
- <a href="/kontakt">Kontakt</a>
- </nav>
-</header>
<main>
<p>Kontakta mig gärna så hör jag av mig så fort jag kan!</p>
<br>
diff --git a/public/omdömen.php b/public/omdömen.php
deleted file mode 100644
index c4a912a..0000000
--- a/public/omdömen.php
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php require "../include/layout.php"; layout($_); ?>
-<header>
- <section>
- <p>Trädgårdstomten ✂️</p>
- </section>
- <nav>
- <a href="/">Tjänster</a>
- <a href="/omdömen">Omdömen</a>
- <a href="/kontakt">Kontakt</a>
- </nav>
-</header>
-<main>
- <div class="height-transition-wrapper">
- <form>
- <label for="name">Namn:</label>
- <input type="text" name="name" id="name">
- <br>
- <label for="review">Omdöme:</label>
- <textarea name="review" id="review"></textarea>
- <br>
- <button>Skicka!</button>
- </form>
- </div>
- <button _="
- on click
- toggle .open on previous <div/>
- if (previous <div/>) match .open then
- set my.innerText to 'Stäng formulär'
- else
- set my.innerText to 'Lämna ett omdöme'
- ">Lämna ett omdöme</button>
-</main>
diff --git a/public/omdömen/edit.php b/public/omdömen/edit.php
new file mode 100644
index 0000000..00b2d3b
--- /dev/null
+++ b/public/omdömen/edit.php
@@ -0,0 +1,33 @@
+<?php
+require "../../include/sqlite.php";
+
+session_start();
+
+if (!isset($_SESSION["editable review"])) die("Kan ej redigera något omdöme.");
+
+$rowid = $_SESSION["editable review"];
+$res = query('select name, content from reviews where rowid = ?', $rowid);
+$review = (object) $res->fetchArray();
+
+if ($_SERVER["REQUEST_METHOD"] === "POST") {
+ $name = $_POST["name"];
+ $content = $_POST["content"];
+
+ query("update reviews set name = ?, content = ? where rowid = ?", $name, $content, $rowid);
+
+ header("HX-Redirect: /omd%c3%b6men/");
+ exit;
+}
+
+require "../../include/layout.php"; layout($_);
+?>
+
+<form hx-post="/omdömen/edit/">
+ <label for="name">Namn:</label>
+ <input type="text" name="name" id="name" value="<?= htmlspecialchars($review->name) ?>">
+ <br>
+ <label for="content" style="vertical-align: top">Omdöme:</label>
+ <textarea name="content" id="content" style="height: 10em; width: 20em"><?= htmlspecialchars($review->content) ?></textarea>
+ <br>
+ <button>Skicka!</button>
+</form>
diff --git a/public/omdömen/index.php b/public/omdömen/index.php
new file mode 100644
index 0000000..53a9123
--- /dev/null
+++ b/public/omdömen/index.php
@@ -0,0 +1,60 @@
+<?php
+require "../../include/sqlite.php";
+
+session_start();
+
+if ($_SERVER["REQUEST_METHOD"] === "POST") {
+ $name = $_POST["name"];
+ $content = $_POST["content"];
+
+ query("insert into reviews (name, content) values (?, ?)", $name, $content);
+
+ $_SESSION["editable review"] = lastRowId();
+
+ header("HX-Refresh: true");
+ exit;
+}
+
+$res = query('select rowid, name, content from reviews');
+$reviews = [];
+while ($row = $res->fetchArray()) {
+ $row["editable"] = isset($_SESSION["editable review"]) && $_SESSION["editable review"] === $row["rowid"];
+ $row = (object) $row;
+ $reviews[] = $row;
+}
+
+require "../../include/layout.php"; layout($_);
+?>
+<main>
+ <div class="height-transition-wrapper">
+ <form hx-post="/omdömen/">
+ <label for="name">Namn:</label>
+ <input type="text" name="name" id="name">
+ <br>
+ <br>
+ <label for="content" style="vertical-align: top">Omdöme:</label>
+ <textarea name="content" id="content" style="height: 10em; width: 20em"></textarea>
+ <br>
+ <button>Skicka!</button>
+ <p style="margin-bottom: 1em; font-size: 0.8em"><i>Du kommer kunna redigera ditt omdöme tills du stänger fliken</i></p>
+ </form>
+ </div>
+ <button _="
+ on click
+ toggle .open on previous <div/>
+ if (previous <div/>) match .open then
+ set my.innerText to 'Stäng formulär'
+ else
+ set my.innerText to 'Lämna ett omdöme'
+ ">Lämna ett omdöme</button>
+
+ <? foreach ($reviews as $review) { ?>
+ <article style="padding: 0.25em;">
+ <p><i style="color: #333"><?= htmlspecialchars($review->name) ?>:</i></p>
+ <p style="white-space: pre-line"><?= htmlspecialchars($review->content) ?></p>
+ <? if ($review->editable) { ?>
+ <a class="nf nf-fa-edit" href="/omdömen/edit/"></a>
+ <? } ?>
+ </article>
+ <? } ?>
+</main>
diff --git a/public/style.css b/public/style.css
index 6f145db..c157f7d 100644
--- a/public/style.css
+++ b/public/style.css
@@ -1,3 +1,5 @@
+@import "https://www.nerdfonts.com/assets/css/webfont.css";
+
* {
margin: 0;
box-sizing: border-box;
@@ -62,7 +64,7 @@ main {
margin-inline: auto;
}
-main article {
+#about-text {
padding-bottom: 4em;
display: grid;
gap: 2em;
@@ -71,7 +73,7 @@ main article {
}
@media (min-width: 500px) {
- main article {
+ #about-text {
grid-template-columns: auto auto;
grid-template-areas: "p1 img" "p2 p2" "p3 p3";
}