summaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
authorDavid T. Sadler <davidtsadler@googlemail.com>2021-10-06 21:23:25 +0100
committerDavid T. Sadler <davidtsadler@googlemail.com>2021-10-06 21:23:25 +0100
commit34ba17ceeecd3ac6be9e31be45ee76757da2dec0 (patch)
tree65511f92bdef592056942effba763957e933bf6b /public
parent245e2234eea0596b2f6aabcbf694e7fd6f458486 (diff)
Implement basic index page
Diffstat (limited to 'public')
-rw-r--r--public/index.php13
1 files changed, 9 insertions, 4 deletions
diff --git a/public/index.php b/public/index.php
index df80ef3..9b4ac6e 100644
--- a/public/index.php
+++ b/public/index.php
@@ -3,16 +3,21 @@
declare(strict_types=1);
use DTS\BookmarkRepository;
+use DTS\Template;
+use function DTS\Functions\respondAndExit;
require_once(__DIR__.'/../autoload.php');
$config = require_once(__DIR__.'/../config.php');
+$bookmarks = new BookmarkRepository($config['path_to_repository']);
+
+$template = new Template($config['path_to_templates']);
+
$sort = $_GET['sort'] ?? null;
$tag = $_GET['tag'] ?? null;
-$bookmarks = new BookmarkRepository($config['path_to_repository']);
$bookmarks->load();
@@ -22,6 +27,6 @@ if ($tag !== null) {
$bookmarks->sort($sort === 'asc');
-foreach ($bookmarks as $bookmark) {
- echo $bookmark->url.' '.$bookmark->addedAt."<br/>";
-}
+$html = $template->render('index', compact('bookmarks'));
+
+respondAndExit(200, 'OK', $html);