summaryrefslogtreecommitdiff
path: root/public/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'public/index.php')
-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);