aboutsummaryrefslogtreecommitdiffhomepage
path: root/templates
diff options
context:
space:
mode:
Diffstat (limited to 'templates')
-rw-r--r--templates/interaction_button.php3
-rw-r--r--templates/live_timeline_updater.php4
-rw-r--r--templates/reply_form.php6
-rw-r--r--templates/skeleton.php8
-rw-r--r--templates/timeline.php17
-rw-r--r--templates/write_note_form.php5
6 files changed, 31 insertions, 12 deletions
diff --git a/templates/interaction_button.php b/templates/interaction_button.php
index edd1a25..b3d072d 100644
--- a/templates/interaction_button.php
+++ b/templates/interaction_button.php
@@ -15,7 +15,8 @@ $id = "interactButton-$action-$note->id";
<div class="interactButtonContainer <?= $action . ($active ? ' active' : '') ?>">
<button title="<?= $tooltip ?>" class="icon material-symbols-outlined <?= $active ? 'active' : '' ?>"
hx-post="<?= "/fragment/note/$note->id/$action" ?>" hx-swap="outerHTML"
- hx-target="closest .interactButtonContainer" hx-disabled-elt="this" id="<?= $id ?>">
+ hx-target="closest .interactButtonContainer" hx-disabled-elt="this" id="<?= $id ?>"
+ _="on click wait 1s then trigger update on #liveTimelineUpdater">
<?= $icon ?>
</button>
<label for="<?= $id ?>" class="interactionCount"><?= $count ?? '' ?></label>
diff --git a/templates/live_timeline_updater.php b/templates/live_timeline_updater.php
new file mode 100644
index 0000000..366b417
--- /dev/null
+++ b/templates/live_timeline_updater.php
@@ -0,0 +1,4 @@
+<form hidden id="liveTimelineUpdater" hx-trigger="load delay:10s, update" hx-get="/feed/<?= $kind ?>/partial"
+ hx-target="next #timelineItems" 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/reply_form.php b/templates/reply_form.php
index f96eb5a..9a1d7e5 100644
--- a/templates/reply_form.php
+++ b/templates/reply_form.php
@@ -1,9 +1,9 @@
<form class="noteReplyForm" id="replyForm-<?= $note->id ?>"
- _="on submit send toggle to previous <button.reply/> on toggle or submit toggle @hidden" hidden
- hx-post="/fragment/note/<?= $note->id ?>/reply" hx-disabled-elt="find button" hx-swap="outerHTML">
+ _="on submit send toggle to previous <button.reply/> then wait 1s then trigger update on #liveTimelineUpdater on toggle or submit toggle @hidden"
+ hidden hx-post="/fragment/note/<?= $note->id ?>/reply" hx-disabled-elt="find button" hx-swap="outerHTML">
<div class="row">
<label for="replyContent-<?= $note->id ?>"><?= __('writeReply.label') ?></label>
- <textarea id="replyContent-<?= $note->id ?>" name="content" required></textarea>
+ <textarea id="replyContent-<?= $note->id ?>" name="content" required autocomplete="off"></textarea>
</div>
<div class="row">
<button class="primary"><?= __('writeReply.action') ?></button>
diff --git a/templates/skeleton.php b/templates/skeleton.php
index e678957..6eb6bd1 100644
--- a/templates/skeleton.php
+++ b/templates/skeleton.php
@@ -18,10 +18,14 @@ $user = Digitigrade\Model\UserAccount::findByCurrentSession();
<body hx-boost="true">
<header>
<nav>
- <?php call_template('navigation_links', ['links' => [
+ <?php
+ $links = $user == null ? [] : ['/feed/home' => __('timeline.home.shortName')];
+ $links = array_merge($links, [
'/feed/global' => __('timeline.global.shortName'),
'/feed/local' => __('timeline.local.shortName'),
- ]]); ?>
+ ]);
+ call_template('navigation_links', ['links' => $links]);
+ ?>
<span id="siteTitle"><?= __('digitigrade') ?></span>
<?php if ($user == null):
call_template('navigation_links', ['links' => [
diff --git a/templates/timeline.php b/templates/timeline.php
index 7ba2fbf..a65b4ce 100644
--- a/templates/timeline.php
+++ b/templates/timeline.php
@@ -1,11 +1,20 @@
<?php call_template('skeleton', ['pageTitle' => __("timeline.$kind")], function () {
global $items, $kind;
- call_template('alertbox', [
- 'variety' => 'info',
- 'message' => __("timeline.$kind.description")
- ]);
+ if ($kind != 'home') {
+ call_template('alertbox', [
+ 'variety' => 'info',
+ 'message' => __("timeline.$kind.description")
+ ]);
+ } else {
+ call_template('live_timeline_updater', [
+ 'kind' => 'home',
+ 'since' => new DateTimeImmutable()
+ ]);
+ }
+ echo '<div id="timelineItems">';
foreach ($items as $item) {
$item->getReason()?->renderAsHtml();
$item->getObject()->renderAsHtml();
}
+ echo '</div>';
}); \ No newline at end of file
diff --git a/templates/write_note_form.php b/templates/write_note_form.php
index 9b7c61c..c28dc12 100644
--- a/templates/write_note_form.php
+++ b/templates/write_note_form.php
@@ -1,7 +1,8 @@
-<form action="/todo" method="post" hx-post="/fragment/note" hx-swap="outerHTML" hx-disabled-elt="find button">
+<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">
<div class="row">
<label for="noteContent"><?= __('writeNote.label') ?></label>
- <textarea name="content" id="noteContent" required></textarea>
+ <textarea name="content" id="noteContent" required autocomplete="off"></textarea>
</div>
<div class="row">
<button class="primary"><?= __('writeNote.action') ?></button>