From 2ab5661583d74b03c86bb4f437616bb634d9c4fc Mon Sep 17 00:00:00 2001 From: "David T. Sadler" Date: Tue, 12 Oct 2021 20:41:49 +0100 Subject: Add delete --- public/delete/index.php | 27 +++++++++++++++++++++++++++ public/edit/index.php | 2 -- public/index.php | 2 -- 3 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 public/delete/index.php (limited to 'public') diff --git a/public/delete/index.php b/public/delete/index.php new file mode 100644 index 0000000..1b2484d --- /dev/null +++ b/public/delete/index.php @@ -0,0 +1,27 @@ +find($id); + +if ('POST' === filter_input(INPUT_SERVER, 'REQUEST_METHOD')) { + $bookmarks->delete($bookmark); +} + +$html = $template->render('delete', compact('bookmark')); + +respondAndExit(200, 'OK', $html); diff --git a/public/edit/index.php b/public/edit/index.php index 0cc1c27..65b3fa5 100644 --- a/public/edit/index.php +++ b/public/edit/index.php @@ -16,8 +16,6 @@ $template = new Template($config['path_to_templates']); $id = filter_input(INPUT_GET, 'id') ?? filter_input(INPUT_POST, 'id') ?? null; -$bookmarks->load(); - $bookmark = $bookmarks->find($id); if ('POST' === filter_input(INPUT_SERVER, 'REQUEST_METHOD')) { diff --git a/public/index.php b/public/index.php index 2a9ccb7..7453506 100644 --- a/public/index.php +++ b/public/index.php @@ -18,8 +18,6 @@ $sort = $_GET['sort'] ?? null; $tag = $_GET['tag'] ?? null; -$bookmarks->load(); - if ($tag !== null) { $bookmarks->filter($tag); } -- cgit v1.2.3-13-gbd6f