From 34ba17ceeecd3ac6be9e31be45ee76757da2dec0 Mon Sep 17 00:00:00 2001 From: "David T. Sadler" Date: Wed, 6 Oct 2021 21:23:25 +0100 Subject: Implement basic index page --- public/index.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'public') 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."
"; -} +$html = $template->render('index', compact('bookmarks')); + +respondAndExit(200, 'OK', $html); -- cgit v1.2.3-13-gbd6f