aboutsummaryrefslogtreecommitdiffhomepage
path: root/templates
diff options
context:
space:
mode:
Diffstat (limited to 'templates')
-rw-r--r--templates/live_notifications_updater.php4
-rw-r--r--templates/notification.php23
-rw-r--r--templates/notifications_panel.php26
-rw-r--r--templates/skeleton.php72
-rw-r--r--templates/write_note_form.php4
5 files changed, 95 insertions, 34 deletions
diff --git a/templates/live_notifications_updater.php b/templates/live_notifications_updater.php
new file mode 100644
index 0000000..bbf31b4
--- /dev/null
+++ b/templates/live_notifications_updater.php
@@ -0,0 +1,4 @@
+<form hidden id="liveNotificationsUpdater" hx-trigger="load delay:10s, update" hx-get="/notifications/partial"
+ hx-target="next .items" hx-swap="afterbegin" <?= ($isUpdate ?? false) ? 'hx-swap-oob="true"' : '' ?>>
+ <input type="hidden" name="since" value="<?= $since->format('c') ?>">
+</form> \ No newline at end of file
diff --git a/templates/notification.php b/templates/notification.php
new file mode 100644
index 0000000..a010ff9
--- /dev/null
+++ b/templates/notification.php
@@ -0,0 +1,23 @@
+<div class="notification">
+ <div class="notifImage">
+ <?php if ($imageUrl != null): ?>
+ <?php if ($imageLink != null): ?>
+ <a href="<?= $imageLink ?>">
+ <?php endif; ?>
+ <img src="<?= $imageUrl ?>">
+ <?php if ($imageLink != null): ?>
+ </a>
+ <?php endif; ?>
+ <?php endif; ?>
+ </div>
+ <div class="notifContent">
+ <?php if ($titleLink != null): ?>
+ <a href="<?= $titleLink ?>">
+ <?php endif; ?>
+ <span class="title"><?= htmlspecialchars($title) ?></span>
+ <?php if ($titleLink != null): ?>
+ </a>
+ <?php endif; ?>
+ <span class="body"><?= htmlspecialchars($body) ?></span>
+ </div>
+</div> \ No newline at end of file
diff --git a/templates/notifications_panel.php b/templates/notifications_panel.php
new file mode 100644
index 0000000..3ca8faf
--- /dev/null
+++ b/templates/notifications_panel.php
@@ -0,0 +1,26 @@
+<?php
+use Digitigrade\Model\Notification;
+
+$notifications = Notification::findAllForUser($user, 50);
+?>
+<div id="notificationsPanel">
+ <h2><?= __('notifications.heading') ?></h2>
+ <?php call_template('live_notifications_updater', ['since' => new \DateTimeImmutable()]); ?>
+ <div class="items">
+ <?php
+ if (count($notifications) <= 0) {
+ call_template('placeholder_text');
+ }
+ foreach ($notifications as $notif) {
+ $notif = $notif->toNotifyable();
+ call_template('notification', [
+ 'title' => $notif->getNotificationTitle(),
+ 'body' => $notif->getNotificationBody(),
+ 'imageUrl' => $notif->getNotificationImageUrl(),
+ 'titleLink' => $notif->getNotificationTitleLink(),
+ 'imageLink' => $notif->getNotificationImageLink()
+ ]);
+ }
+ ?>
+ </div>
+</div> \ No newline at end of file
diff --git a/templates/skeleton.php b/templates/skeleton.php
index 9e27386..3b2a963 100644
--- a/templates/skeleton.php
+++ b/templates/skeleton.php
@@ -46,39 +46,47 @@ $settings = GlobalSettings::getInstance();
</nav>
</header>
<main>
- <section id="leftPane">
- <?php
- if ($user != null) {
- call_template('write_note_form');
- $links = [[
- 'href' => '/followrequests',
- 'icon' => 'person_add',
- 'label' => __('navigation.followRequests'),
- 'unreadCount' => FollowRelation::countWhere("object = ? AND status = 'pending'", [$user->actor->id])
- ]];
- if ($user->isAdmin) {
- $links[] = ['href' => '/admin/settings/instance', 'icon' => 'settings', 'label' => __('navigation.instanceSettings')];
+ <div>
+ <section id="leftPane">
+ <?php
+ if ($user != null) {
+ call_template('write_note_form');
+ $links = [[
+ 'href' => '/followrequests',
+ 'icon' => 'person_add',
+ 'label' => __('navigation.followRequests'),
+ 'unreadCount' => FollowRelation::countWhere("object = ? AND status = 'pending'", [$user->actor->id])
+ ]];
+ if ($user->isAdmin) {
+ $links[] = ['href' => '/admin/settings/instance', 'icon' => 'settings', 'label' => __('navigation.instanceSettings')];
+ }
+ $links[] = [
+ 'href' => '/logout',
+ 'icon' => 'logout',
+ 'label' => __('navigation.logout'),
+ 'confirmation' => __('navigation.logout.confirmation')
+ ];
+ call_template('side_navigation', ['links' => $links]);
}
- $links[] = [
- 'href' => '/logout',
- 'icon' => 'logout',
- 'label' => __('navigation.logout'),
- 'confirmation' => __('navigation.logout.confirmation')
- ];
- call_template('side_navigation', ['links' => $links]);
- }
- ?>
- <p class="versionInfo"><?= sprintf(__('version'), get_version()) ?></p>
- </section>
- <section id="centrePane">
- <?php if (!isset($renderTitleHeading) || $renderTitleHeading): ?>
- <h1><?= $pageTitle ?></h1>
- <?php endif; ?>
- <?php slot(); ?>
- </section>
- <section id="rightPane">
-
- </section>
+ ?>
+ <p class="versionInfo"><?= sprintf(__('version'), get_version()) ?></p>
+ </section>
+ </div>
+ <div>
+ <section id="centrePane">
+ <?php if (!isset($renderTitleHeading) || $renderTitleHeading): ?>
+ <h1><?= $pageTitle ?></h1>
+ <?php endif; ?>
+ <?php slot(); ?>
+ </section>
+ </div>
+ <div>
+ <section id="rightPane">
+ <?php if ($user != null) {
+ call_template('notifications_panel', ['user' => $user]);
+ } ?>
+ </section>
+ </div>
</main>
</body>
diff --git a/templates/write_note_form.php b/templates/write_note_form.php
index b74de69..2d50896 100644
--- a/templates/write_note_form.php
+++ b/templates/write_note_form.php
@@ -1,5 +1,5 @@
-<form action="/todo" method="post" hx-post="/fragment/note" hx-swap="outerHTML" hx-disabled-elt="find button"
- _="on submit wait 1s then trigger update on #liveTimelineUpdater">
+<form id="writeNoteForm" action="/todo" method="post" hx-post="/fragment/note" hx-swap="outerHTML"
+ hx-disabled-elt="find button" _="on submit wait 1s then trigger update on #liveTimelineUpdater">
<div class="row">
<label for="noteContent"><?= __('writeNote.label') ?></label>
<textarea name="content" id="noteContent" required autocomplete="off"></textarea>