summaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
Diffstat (limited to 'public')
-rw-r--r--public/css/site.css9
-rw-r--r--public/store/index.php1
-rw-r--r--public/update/index.php1
-rw-r--r--public/view/index.php37
4 files changed, 47 insertions, 1 deletions
diff --git a/public/css/site.css b/public/css/site.css
index c1010a2..d34f380 100644
--- a/public/css/site.css
+++ b/public/css/site.css
@@ -18,6 +18,7 @@ body {
h1,
h2,
+h3,
label {
font-weight: bold;
font-size: 1.125rem;
@@ -37,6 +38,10 @@ h2:before {
content: "## ";
}
+h3 {
+ color: #86EFAC;
+}
+
section {
padding: 1rem;
}
@@ -71,13 +76,15 @@ label {
}
input,
+textarea,
button {
border-radius: .25rem;
display: block;
width: 100%;
}
-input {
+input,
+textarea {
border: 2px solid #FFFFFF;
padding: .375rem .75rem;
}
diff --git a/public/store/index.php b/public/store/index.php
index c4d24fa..0f472d8 100644
--- a/public/store/index.php
+++ b/public/store/index.php
@@ -40,6 +40,7 @@ $todos = new TodoRepository($config['path_to_repository']);
$todo = new Todo();
$todo->task = $validated->task;
+$todo->description = $validated->description;
$todo->tag = $validated->tag;
$todo->addedAt = date('Y-m-d H:i:s');
diff --git a/public/update/index.php b/public/update/index.php
index 82b3c3f..749f429 100644
--- a/public/update/index.php
+++ b/public/update/index.php
@@ -45,6 +45,7 @@ if ($validator->errors->count()) {
$validated = $validator->validated;
$todo->task = $validated->task;
+$todo->description = $validated->description;
$todo->tag = $validated->tag;
if (!$todos->update($todo)) {
diff --git a/public/view/index.php b/public/view/index.php
new file mode 100644
index 0000000..798cefd
--- /dev/null
+++ b/public/view/index.php
@@ -0,0 +1,37 @@
+<?php
+
+declare(strict_types=1);
+
+use DTS\TodoRepository;
+use DTS\Session;
+use DTS\Template;
+
+use function DTS\Functions\respondAndExit;
+
+require_once(__DIR__.'/../../autoload.php');
+
+$config = require_once(__DIR__.'/../../config.php');
+
+$session = Session::getInstance();
+
+if (filter_input(INPUT_SERVER, 'REQUEST_METHOD') !== 'GET') {
+ respondAndExit(405, 'Method Not Allowed');
+}
+
+$id = filter_input(INPUT_GET, 'id');
+
+$todos = new TodoRepository($config['path_to_repository']);
+
+$template = new Template($config['path_to_templates']);
+
+$todo = $todos->find($id);
+
+if ($todo === null) {
+ respondAndExit(404, 'Not Found');
+}
+
+$html = $template->render('view', compact(
+ 'todo'
+));
+
+respondAndExit(200, 'OK', $html);