diff options
| author | winter | 2025-02-16 20:09:16 +0000 |
|---|---|---|
| committer | winter | 2025-02-16 20:09:16 +0000 |
| commit | 645e8bd0b2cf5f020585047d683ed0b26e892204 (patch) | |
| tree | fcf5b73eaf2041e39d439e3ead41c0ceff7da2d1 | |
| parent | 5a44137ddea7b3a6d7f68cbe71594f7633d6e9a6 (diff) | |
share button in context menus
| -rw-r--r-- | locale/en_GB.json | 2 | ||||
| -rw-r--r-- | static/icons.css | 3 | ||||
| -rw-r--r-- | templates/menu_button.php | 2 | ||||
| -rw-r--r-- | templates/note.php | 23 |
4 files changed, 27 insertions, 3 deletions
diff --git a/locale/en_GB.json b/locale/en_GB.json index d734f85..d65c890 100644 --- a/locale/en_GB.json +++ b/locale/en_GB.json @@ -1,6 +1,7 @@ { "digitigrade": "Digitigrade", "version": "Digitigrade @ %s", + "action.share": "Share", "user.profile.createdAt": "Joined on %s", "user.profile.openRemote": "Open remote profile page", "user.profile.bio.placeholder": "This user hasn't written a bio yet.", @@ -37,6 +38,7 @@ "note.action.reply": "Reply", "note.action.delete": "Delete note", "note.action.delete.confirmation": "Are you sure you want to permanently delete this note?", + "note.openRemote": "Open on original instance", "note.info.replyTo": "In reply to %s", "note.info.mentions": "Mentions %s", "note.privacy.scope.none": "Private", diff --git a/static/icons.css b/static/icons.css index e486244..a48a4f4 100644 --- a/static/icons.css +++ b/static/icons.css @@ -108,4 +108,7 @@ &.markdown-outline { --svg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='m16 15l3-3l-1.05-1.075l-1.2 1.2V9h-1.5v3.125l-1.2-1.2L13 12zM4 20q-.825 0-1.412-.587T2 18V6q0-.825.588-1.412T4 4h16q.825 0 1.413.588T22 6v12q0 .825-.587 1.413T20 20zm0-2h16V6H4zm0 0V6zm1.5-3H7v-4.5h1v3h1.5v-3h1V15H12v-5q0-.425-.288-.712T11 9H6.5q-.425 0-.712.288T5.5 10z'/%3E%3C/svg%3E"); } + &.share { + --svg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M17 22q-1.25 0-2.125-.875T14 19q0-.15.075-.7L7.05 14.2q-.4.375-.925.588T5 15q-1.25 0-2.125-.875T2 12t.875-2.125T5 9q.6 0 1.125.213t.925.587l7.025-4.1q-.05-.175-.062-.337T14 5q0-1.25.875-2.125T17 2t2.125.875T20 5t-.875 2.125T17 8q-.6 0-1.125-.213T14.95 7.2l-7.025 4.1q.05.175.063.338T8 12t-.012.363t-.063.337l7.025 4.1q.4-.375.925-.587T17 16q1.25 0 2.125.875T20 19t-.875 2.125T17 22'/%3E%3C/svg%3E"); + } } diff --git a/templates/menu_button.php b/templates/menu_button.php index da47569..4d5dc48 100644 --- a/templates/menu_button.php +++ b/templates/menu_button.php @@ -4,7 +4,7 @@ set menu to next .popupMenu toggle @hidden on menu measure me then set pos to it - set menu.style.top to `${scrollY + pos.top}px` + set menu.style.top to `${(scrollY + pos.top) - 8}px` set menu.style.right to `${(scrollX + innerWidth) - pos.right}px` on click from elsewhere set @hidden of next .popupMenu to false "></button> diff --git a/templates/note.php b/templates/note.php index 4cdcd94..19a1895 100644 --- a/templates/note.php +++ b/templates/note.php @@ -15,6 +15,7 @@ if ($user != null) { $interactions = $note->getInteractionsWithAuthor($user->actor); $interKinds = array_map(fn($inter) => $inter->kind, $interactions); } +$pathToSelf = '/@/' . $note->author->getFullHandle() . '/note/' . $note->id; ?> <article class="note <?= ($selected ?? false) ? 'selected' : '' ?>"> @@ -33,8 +34,7 @@ if ($user != null) { <?php endif; ?> @<?= htmlspecialchars($note->author->getFullHandle()) ?> </span> - <a class="timestamp" - href="/@/<?= htmlspecialchars($note->author->getFullHandle()) ?>/note/<?= $note->id ?>"> + <a class="timestamp" href="<?= htmlspecialchars($pathToSelf) ?>"> <?= format_datetime($note->created, $prefs?->get('locale.timezone')) . (isset($note->modified) && $note->modified != $note->created ? ' (' . format_datetime($note->modified, $prefs?->get('locale.timezone')) . ')' @@ -126,6 +126,17 @@ if ($user != null) { global $note; $user = UserAccount::findByCurrentSession(); ?> + <li> + <button data-share-url="<?= htmlspecialchars($note->uri) ?>" _=" + on click + set url to my @data-share-url + js(url) + navigator.share({ url: url }) + end" type="button"> + <span class="material-symbols share"></span> + <span><?= __('action.share') ?></span> + </button> + </li> <?php if ($note->author->isLocal && ($note->author == $user?->actor || $user?->isAdmin)): ?> <li> <button hx-delete="/fragment/note/<?= $note->id ?>" @@ -136,6 +147,14 @@ if ($user != null) { </button> </li> <?php endif; ?> + <?php if (!$note->author->isLocal): ?> + <li> + <a target="_blank" href="<?= htmlspecialchars($note->uri) ?>" rel="nofollow noreferrer"> + <span class="material-symbols open-in-new"></span> + <span><?= __('note.openRemote') ?></span> + </a> + </li> + <?php endif; ?> <?php }); ?> </div> </div> |
