aboutsummaryrefslogtreecommitdiffhomepage
path: root/templates
diff options
context:
space:
mode:
Diffstat (limited to 'templates')
-rw-r--r--templates/note.php13
-rw-r--r--templates/notification.php2
-rw-r--r--templates/reply_form.php14
-rw-r--r--templates/user_mention_pill.php31
-rw-r--r--templates/write_note_form.php4
5 files changed, 62 insertions, 2 deletions
diff --git a/templates/note.php b/templates/note.php
index d892656..e5c2942 100644
--- a/templates/note.php
+++ b/templates/note.php
@@ -1,4 +1,5 @@
<?php
+use Digitigrade\Model\Actor;
use Digitigrade\Model\InteractionKind;
use Digitigrade\Model\NotePrivacyScope;
use Digitigrade\Model\UserAccount;
@@ -47,12 +48,22 @@ if ($user != null) {
<?php if (isset($note->inReplyTo)): ?>
<div class="replyInfo">
+ <span class="material-symbols reply inlineIcon"></span>
<a href="/@/<?= $note->inReplyTo->author->getFullHandle() ?>/note/<?= $note->inReplyTo->id ?>">
- <span class="material-symbols reply inlineIcon"></span>
<?= sprintf(__('note.info.replyTo'),
'<b>' . htmlspecialchars($note->inReplyTo->author->displayName)) . '</b>' ?>
</a>
</div>
+ <?php elseif (count($note->mentions) > 0): ?>
+ <div class="replyInfo">
+ <span class="material-symbols alternate-email inlineIcon"></span>
+ <span>
+ <?= sprintf(__('note.info.mentions'), implode(', ', array_map(
+ fn(Actor $m) => '<b><a href="/@/' . $m->getFullHandle() . '">' . $m->displayName . '</a></b>',
+ $note->mentions
+ ))) ?>
+ </span>
+ </div>
<?php endif; ?>
<div class="content">
diff --git a/templates/notification.php b/templates/notification.php
index a23a3a6..d787f5e 100644
--- a/templates/notification.php
+++ b/templates/notification.php
@@ -20,7 +20,7 @@
<?php endif; ?>
<span class="body"><?= htmlspecialchars($body) ?></span>
</div>
- <div hidden class="notifier" <?php if ($unread): ?> _="
+ <div hidden class="notifier" <?php if ($unread ?? false): ?> _="
on load
set title to innerText of previous .title
set body to innerText of previous .body
diff --git a/templates/reply_form.php b/templates/reply_form.php
index 3434472..57a0dd0 100644
--- a/templates/reply_form.php
+++ b/templates/reply_form.php
@@ -1,3 +1,8 @@
+<?php
+use Digitigrade\Model\UserAccount;
+
+$user = UserAccount::findByCurrentSession();
+?>
<form class="noteReplyForm" id="replyForm-<?= $note->id ?>"
_="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">
@@ -11,6 +16,15 @@
value="<?= $note->summary ? "re: $note->summary" : '' ?>">
</div>
<div class="row">
+ <label class="standalone"><?= __('writeNote.mentions.label') ?></label>
+ <?php foreach (array_merge($note->mentions, [$note->author]) as $m) {
+ if ($m != $user?->actor) {
+ call_template('user_mention_pill', ['type' => 'user', 'actor' => $m]);
+ }
+ } ?>
+ <?php call_template('user_mention_pill'); ?>
+ </div>
+ <div class="row">
<button class="primary"><?= __('writeReply.action') ?></button>
</div>
</form> \ No newline at end of file
diff --git a/templates/user_mention_pill.php b/templates/user_mention_pill.php
new file mode 100644
index 0000000..3b9a018
--- /dev/null
+++ b/templates/user_mention_pill.php
@@ -0,0 +1,31 @@
+<?php
+$type ??= 'add';
+?>
+
+<?php if ($type == 'add'): ?>
+
+ <button class="inlinePill" type="button" hx-get="/fragment/note/mentionPill" hx-disabled-elt="this" hx-swap="outerHTML">
+ <span class="pillIcon material-symbols add"></span>
+ <span class="pillText"><?= __('writeNote.mentions.add.action') ?></span>
+ </button>
+
+<?php elseif ($type == 'edit'): ?>
+
+ <form class="inlinePill nopanel <?= ($invalid ?? false) ? 'invalid' : '' ?>" hx-get="/fragment/note/mentionPill"
+ hx-disabled-elt="this" hx-swap="outerHTML">
+ <span class="pillIcon material-symbols alternate-email"></span>
+ <input type="text" name="handle" class="pillInput" value="<?= $value ?? '' ?>"
+ placeholder="<?= __('writeNote.mentions.placeholder') ?>" required autofocus>
+ <button type="submit" class="material-symbols add"></button>
+ </form>
+
+<?php elseif ($type == 'user'): ?>
+
+ <button class="inlinePill" type="button" _="on click remove me">
+ <img class="pillIcon" src="<?= $actor->avatar ?? '/static/default-avatar.png' ?>">
+ <span class="pillText"><?= $actor->displayName ?></span>
+ <input type="hidden" name="mentions[]" value="<?= $actor->id ?>">
+ <span class="pillIcon material-symbols close-small"></span>
+ </button>
+
+<?php endif; ?> \ No newline at end of file
diff --git a/templates/write_note_form.php b/templates/write_note_form.php
index 55ed77e..d2dae61 100644
--- a/templates/write_note_form.php
+++ b/templates/write_note_form.php
@@ -18,6 +18,10 @@
<input type="text" id="noteSummary" name="summary" autocomplete="off">
</div>
<div class="row">
+ <label class="standalone"><?= __('writeNote.mentions.label') ?></label>
+ <?php call_template('user_mention_pill'); ?>
+ </div>
+ <div class="row">
<label for="noteScope"><?= __('writeNote.scope.label') ?></label>
<select name="scope" id="noteScope" required autocomplete="off">
<option value="none"><?= __('note.privacy.scope.none') ?></option>