aboutsummaryrefslogtreecommitdiff
path: root/views
diff options
context:
space:
mode:
authorSyndamia <kamen@syndamia.com>2025-02-02 15:04:59 +0200
committerSyndamia <kamen@syndamia.com>2025-02-02 15:05:05 +0200
commitd7c2e638a5ea39caeadd40406f840e9b90f893d5 (patch)
tree3568f96aa508e01b9c7ee34cba261f4e16d186a2 /views
parentd6dcab722a4e4f3472d3e4128bd6f4a6d5661a31 (diff)
downloadnowayforward_human-d7c2e638a5ea39caeadd40406f840e9b90f893d5.tar
nowayforward_human-d7c2e638a5ea39caeadd40406f840e9b90f893d5.tar.gz
nowayforward_human-d7c2e638a5ea39caeadd40406f840e9b90f893d5.zip
feat(views/archive): Implement archive deletion
Diffstat (limited to 'views')
-rw-r--r--views/archive/delete/index.php34
-rw-r--r--views/archive/delete/meta.php4
-rw-r--r--views/archive/index.php3
-rw-r--r--views/archive/item.php14
-rw-r--r--views/global/router.php1
-rw-r--r--views/list/index.php2
-rw-r--r--views/styles.css3
7 files changed, 59 insertions, 2 deletions
diff --git a/views/archive/delete/index.php b/views/archive/delete/index.php
new file mode 100644
index 0000000..daad152
--- /dev/null
+++ b/views/archive/delete/index.php
@@ -0,0 +1,34 @@
+<?php
+ $user = require_login();
+ $webpage = null;
+
+ try {
+ $webpage = Database\Webpage::fromDBwid($_GET['wid']);
+ }
+ catch (Exception $e) {}
+?>
+
+<?php if ($webpage !== null && $user->Role === 'Admin'): ?>
+ <h1>Are you sure you want to delete <?= $webpage->URL ?> from <?= $webpage->Date ?>?</h1>
+
+ <form action="#" method="POST" class="font-115 flex-col-centered max-width-20 center-margin">
+ <input type="hidden" name="method" value="DELETE">
+ <?php if (isset($page_status)): ?>
+ <?php if ($page_status !== ""): ?>
+ <p class="item error"><span>
+ <strong>Error:</strong> <?= $page_status ?>
+ </span></p>
+ <?php endif; ?>
+ <?php endif; ?>
+
+ <input type="hidden" name="wid" value="<?= $_GET['wid'] ?>">
+ <input type="submit" value="Delete forever!">
+ </form>
+
+<?php elseif ($webpage === null): ?>
+ <h2>No page with identifier <?= $_GET['wid'] ?> exists!</h2>
+
+<?php else: ?>
+ <h2>You have no permission to delete archives!</h2>
+
+<?php endif; ?>
diff --git a/views/archive/delete/meta.php b/views/archive/delete/meta.php
new file mode 100644
index 0000000..b9dc330
--- /dev/null
+++ b/views/archive/delete/meta.php
@@ -0,0 +1,4 @@
+<?php
+
+$title = 'Delete an archive';
+$controller = 'archive';
diff --git a/views/archive/index.php b/views/archive/index.php
index 73e1017..7e5c818 100644
--- a/views/archive/index.php
+++ b/views/archive/index.php
@@ -1,6 +1,7 @@
<?php
$exists = null;
$page = null;
+ $user = null;
try {
list($exists, $url) = doesWebsiteExist($url);
@@ -8,6 +9,8 @@
$page = Database\Webpage::fromDB($url);
$page->incrementVisits();
+
+ $user = Database\Cookie::fromDB($TOKEN);
}
catch(Exception $e) {
}
diff --git a/views/archive/item.php b/views/archive/item.php
index e6b9cf0..467fb2c 100644
--- a/views/archive/item.php
+++ b/views/archive/item.php
@@ -15,9 +15,19 @@
<input type="hidden" name="wid" value="<?= $page->WID ?>">
<button>
<!-- Tabler icons https://tabler.io/icons -->
- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="list-icon"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M12 17l-6 4v-14a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v5" /><path d="M16 19h6" /><path d="M19 16v6" /></svg>
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="list-icon"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M12 17l-6 4v-14a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v5" /><path d="M16 19h6" /><path d="M19 16v6" /></svg>
</button>
</form>
- <span><!-- Delete (when admin) button --></span>
+ <?php if ($user !== null && $user->Role === 'Admin'): ?>
+ <form action="/archive/delete" method="GET">
+ <input type="hidden" name="wid" value="<?= $page->WID ?>">
+ <button>
+ <!-- Tabler icons https://tabler.io/icons -->
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="list-icon"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M4 7l16 0" /><path d="M10 11l0 6" /><path d="M14 11l0 6" /><path d="M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12" /><path d="M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3" /></svg>
+ </button>
+ </form>
+ <?php else: ?>
+ <span></span>
+ <?php endif; ?>
</section>
</section>
diff --git a/views/global/router.php b/views/global/router.php
index c6718a7..5b0bd01 100644
--- a/views/global/router.php
+++ b/views/global/router.php
@@ -33,6 +33,7 @@ function route_view() {
case '/list/delete': return '/list/delete';
case '/archive/create': return '/archive/create';
+ case '/archive/delete': return '/archive/delete';
case '/user/delete': return '/user/delete';
case '/user/settings': return '/user/update';
diff --git a/views/list/index.php b/views/list/index.php
index d422630..759ab04 100644
--- a/views/list/index.php
+++ b/views/list/index.php
@@ -1,10 +1,12 @@
<?php
$list = null;
$author = null;
+ $user = null;
try {
$list = Database\ArchiveList::fromDB($lid ?? -1);
$author = Database\User::fromDBuid($list->AuthorUID);
+ $user = Database\Cookie::fromDB($TOKEN);
}
catch(Exception $e) {}
?>
diff --git a/views/styles.css b/views/styles.css
index 132d280..260f7ff 100644
--- a/views/styles.css
+++ b/views/styles.css
@@ -334,10 +334,12 @@ hr.new-section {
padding: 0.5em 0 0.5em 0.5em;
display: flex;
flex-direction: column;
+ gap: 0.3em;
}
.item [name=itemButton] > * {
display: flex;
+ align-items: end;
flex: 1;
}
@@ -349,6 +351,7 @@ hr.new-section {
.list-icon {
color: var(--cherry);
+ height: 1.3em;
}
/* List item */