diff options
| author | winter | 2025-03-15 21:26:02 +0000 |
|---|---|---|
| committer | winter | 2025-03-15 21:26:02 +0000 |
| commit | 8843a8cb197e71b1ca42f1ea56be5f806ad0f5b4 (patch) | |
| tree | 20ca690e9bd3e4996421eb4d43c0b4fbdaf0ff95 /templates/note/note.php | |
| parent | d8e440b1998e5c3e33445f2ec020d261fc7fa714 (diff) | |
implement note editing
and improve display of edited note timestamps
Diffstat (limited to 'templates/note/note.php')
| -rw-r--r-- | templates/note/note.php | 47 |
1 files changed, 16 insertions, 31 deletions
diff --git a/templates/note/note.php b/templates/note/note.php index 7cef342..0d48272 100644 --- a/templates/note/note.php +++ b/templates/note/note.php @@ -3,7 +3,6 @@ use Digitigrade\Model\Actor; use Digitigrade\Model\InteractionKind; -use Digitigrade\Model\NotePrivacyScope; use Digitigrade\Model\UserAccount; use Digitigrade\UserSettings; @@ -17,7 +16,6 @@ if ($user != null) { $interactions = $note->getInteractionsWithAuthor($user->actor); $interKinds = array_map(fn($inter) => $inter->kind, $interactions); } -$pathToSelf = $note->getLocalUiHref(); ?> <article class="note <?= ($selected ?? false) ? 'selected' : '' ?>"> @@ -27,40 +25,14 @@ $pathToSelf = $note->getLocalUiHref(); <div> - <div class="infoLine"> - <a class="authorName" - href="/@/<?= htmlspecialchars($note->author->getFullHandle()) ?>"><?= htmlspecialchars($note->author->displayName) ?></a> - <span class="authorPronouns"> - <?php if (isset($note->author->pronouns) && trim($note->author->pronouns) != '') { - echo htmlspecialchars($note->author->pronouns); - } ?> - </span> - <a class="timestamp" href="<?= htmlspecialchars($pathToSelf) ?>"> - <?= format_datetime($note->created) - . (isset($note->modified) && $note->modified != $note->created - ? ' (' . format_datetime($note->modified) . ')' - : '' - ) ?> - </a> - <span class="privacyScope inlineIcon material-symbols <?= match ($note->privacy->scope) { - NotePrivacyScope::NONE => 'lock', - NotePrivacyScope::MUTUALS => 'group', - NotePrivacyScope::FOLLOWERS => 'groups', - NotePrivacyScope::PUBLIC => 'public' - } ?>" title="<?= match ($note->privacy->scope) { - NotePrivacyScope::NONE => __('note.privacy.scope.none'), - NotePrivacyScope::MUTUALS => __('note.privacy.scope.mutuals'), - NotePrivacyScope::FOLLOWERS => __('note.privacy.scope.followers'), - NotePrivacyScope::PUBLIC => __('note.privacy.scope.public') - } ?>"></span> - </div> + <?php call_template('note/info_line', ['note' => $note]); ?> <?php if (isset($note->inReplyTo)): ?> <div class="replyInfo"> <span class="material-symbols reply inlineIcon"></span> <a href="/@/<?= htmlspecialchars($note->inReplyTo->author->getFullHandle()) ?>/note/<?= $note->inReplyTo->id ?>"> - <?= sprintf(__('note.info.replyTo'), + <?= __f('note.info.replyTo', '<b>' . htmlspecialchars($note->inReplyTo->author->displayName)) . '</b>' ?> </a> </div> @@ -68,7 +40,7 @@ $pathToSelf = $note->getLocalUiHref(); <div class="replyInfo"> <span class="material-symbols alternate-email inlineIcon"></span> <span> - <?= sprintf(__('note.info.mentions'), implode(', ', array_map( + <?= __f('note.info.mentions', implode(', ', array_map( fn(Actor $m) => '<b><a href="/@/' . htmlspecialchars($m->getFullHandle()) . '">' . htmlspecialchars($m->displayName) . '</a></b>', $note->mentions ))) ?> @@ -76,6 +48,13 @@ $pathToSelf = $note->getLocalUiHref(); </div> <?php endif; ?> + <?php if (isset($note->modified) && $note->modified != $note->created): ?> + <div class="modifiedInfo"> + <span class="material-symbols edit-outline inlineIcon"></span> + <span><?= __f('note.info.modified', format_datetime($note->modified)) ?></span> + </div> + <?php endif; ?> + <?php if (isset($note->summary)): ?> <details> <summary><?= htmlspecialchars($note->summary) ?></summary> @@ -151,6 +130,12 @@ $pathToSelf = $note->getLocalUiHref(); </li> <?php if ($note->author->isLocal && ($note->author == $user?->actor || $user?->isAdmin)): ?> <li> + <button hx-get="/fragment/note/<?= $note->id ?>/edit" hx-target="closest .note" hx-swap="outerHTML"> + <span class="material-symbols edit-outline"></span> + <span><?= __('note.action.edit') ?></span> + </button> + </li> + <li> <button hx-delete="/fragment/note/<?= $note->id ?>" hx-confirm="<?= __('note.action.delete.confirmation') ?>" hx-target="closest .note" hx-swap="delete"> |
