summaryrefslogtreecommitdiff
path: root/public/index.php
blob: df80ef30a04552c334a536f345e5c13f691e1b9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php

declare(strict_types=1);

use DTS\BookmarkRepository;

require_once(__DIR__.'/../autoload.php');

$config = require_once(__DIR__.'/../config.php');

$sort = $_GET['sort'] ?? null;

$tag = $_GET['tag'] ?? null;

$bookmarks = new BookmarkRepository($config['path_to_repository']);

$bookmarks->load();

if ($tag !== null) {
    $bookmarks->filter($tag);
}

$bookmarks->sort($sort === 'asc');

foreach ($bookmarks as $bookmark) {
    echo $bookmark->url.'  '.$bookmark->addedAt."<br/>";
}