diff options
| author | David T. Sadler <davidtsadler@googlemail.com> | 2021-10-06 21:23:25 +0100 |
|---|---|---|
| committer | David T. Sadler <davidtsadler@googlemail.com> | 2021-10-06 21:23:25 +0100 |
| commit | 34ba17ceeecd3ac6be9e31be45ee76757da2dec0 (patch) | |
| tree | 65511f92bdef592056942effba763957e933bf6b /public | |
| parent | 245e2234eea0596b2f6aabcbf694e7fd6f458486 (diff) | |
Implement basic index page
Diffstat (limited to 'public')
| -rw-r--r-- | public/index.php | 13 |
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); |
