diff options
| -rw-r--r-- | locale/en_GB.json | 4 | ||||
| -rw-r--r-- | routes/lookup.php | 5 | ||||
| -rw-r--r-- | static/icons.css | 3 | ||||
| -rw-r--r-- | static/misc.css | 5 | ||||
| -rw-r--r-- | templates/note/note.php | 11 | ||||
| -rw-r--r-- | templates/preferences_page.php | 18 |
6 files changed, 44 insertions, 2 deletions
diff --git a/locale/en_GB.json b/locale/en_GB.json index 0f36b5b..59e6599 100644 --- a/locale/en_GB.json +++ b/locale/en_GB.json @@ -3,6 +3,7 @@ "digitigrade": "Digitigrade", "version": "Digitigrade @ %s", "action.share": "Share", + "action.share.web+pawpub": "Share (web+pawpub)", "user.profile.createdAt": "Joined %s", "user.profile.openRemote": "Open remote profile page", "user.profile.forceRefetch": "Reload from remote instance", @@ -163,6 +164,9 @@ "preferences.pokeable.description": "Also includes other verbs such as bite, wave at, hug, etc.", "preferences.notesIndexable.name": "Allow search engines to index your notes", "preferences.notesIndexable.description": "Doesn't apply to existing notes, only new ones", + "preferences.schemeHandler.heading": "Scheme handler", + "preferences.schemeHandler.description": "Allows web+pawpub links to open in Digitigrade when you click on them. Only supported in certain browsers.", + "preferences.schemeHandler.action": "Register scheme handler", "changePassword.heading": "Change password", "changePassword.currentPassword": "Current password", "changePassword.newPassword": "New password", diff --git a/routes/lookup.php b/routes/lookup.php index 62d9e48..903c1b9 100644 --- a/routes/lookup.php +++ b/routes/lookup.php @@ -12,9 +12,12 @@ Router::getInstance()->mount('/lookup', function (array $args) { throw new BadRequest('please provide a `uri` query parameter'); } $uri = $_GET['uri']; - if (!str_starts_with($uri, 'https://')) { + if (!(str_starts_with($uri, 'https://') || str_starts_with($uri, 'web+pawpub://'))) { throw new BadRequest('dodgy looking uri'); } + if (str_starts_with($uri, 'web+pawpub://')) { + $uri = substr_replace($uri, 'https', 0, 10); + } // try looking it up as a note try { diff --git a/static/icons.css b/static/icons.css index 3cd60be..6799f54 100644 --- a/static/icons.css +++ b/static/icons.css @@ -135,4 +135,7 @@ &.sync { --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='M4 20v-2h2.75l-.4-.35q-1.225-1.225-1.787-2.662T4 12.05q0-2.775 1.663-4.937T10 4.25v2.1Q8.2 7 7.1 8.563T6 12.05q0 1.125.425 2.188T7.75 16.2l.25.25V14h2v6zm10-.25v-2.1q1.8-.65 2.9-2.212T18 11.95q0-1.125-.425-2.187T16.25 7.8L16 7.55V10h-2V4h6v2h-2.75l.4.35q1.225 1.225 1.788 2.663T20 11.95q0 2.775-1.662 4.938T14 19.75'/%3E%3C/svg%3E"); } + &.share-windows { + --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='M7 15V9q0-.825.588-1.412T9 7h8.15l-2.575-2.575L16 3l5 5l-5 5l-1.425-1.4L17.15 9H9v6zm-2 6q-.825 0-1.412-.587T3 19V4h2v15h12v-4h2v4q0 .825-.587 1.413T17 21z'/%3E%3C/svg%3E"); + } } diff --git a/static/misc.css b/static/misc.css index f2cc70d..f2d0555 100644 --- a/static/misc.css +++ b/static/misc.css @@ -182,6 +182,11 @@ details[open] > summary::before { --svg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1em' height='1em' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M9 19v-2h6.6L4 5.4L5.4 4L17 15.6V9h2v10z'/%3E%3C/svg%3E"); } +.indentedContainer { + display: block; + margin: 0 var(--spacing-double); +} + [hidden] { display: none !important; } diff --git a/templates/note/note.php b/templates/note/note.php index ddc2bac..fe28416 100644 --- a/templates/note/note.php +++ b/templates/note/note.php @@ -126,6 +126,17 @@ if ($user != null) { <span><?= __('action.share') ?></span> </button> </li> + <li> + <button data-share-url="<?= htmlspecialchars(substr_replace($note->uri, 'web+pawpub', 0, 5)) ?>" _=" + on click + set url to my @data-share-url + js(url) + navigator.share({ url: url }) + end" type="button"> + <span class="material-symbols share-windows"></span> + <span><?= __('action.share.web+pawpub') ?></span> + </button> + </li> <?php if ($note->author->isLocal && ($note->author == $user?->actor || $user?->isAdmin) && !$note->hasPage()): ?> <li> <button hx-get="/fragment/note/<?= $note->id ?>/edit" hx-target="closest .note" hx-swap="outerHTML"> diff --git a/templates/preferences_page.php b/templates/preferences_page.php index 2744747..46ba1ff 100644 --- a/templates/preferences_page.php +++ b/templates/preferences_page.php @@ -1,7 +1,23 @@ -<?php call_template('skeleton', ['pageTitle' => __('preferences.pageTitle')], function () { +<?php + +use Digitigrade\GlobalSettings; + +call_template('skeleton', ['pageTitle' => __('preferences.pageTitle')], function () { global $user, $saved; + + $siteName = GlobalSettings::getInstance()->get('instance.name'); + call_template('preferences_form', ['user' => $user, 'saved' => $saved ?? false]); ?> + + <h2><?= __('preferences.schemeHandler.heading') ?></h2> + <div class="indentedContainer"> + <p><?= __('preferences.schemeHandler.description') ?></p> + <button class="primary" type="button" onclick="navigator.registerProtocolHandler('web+pawpub', '/lookup?uri=%s')"> + <?= __('preferences.schemeHandler.action') ?> + </button> + </div> + <h2><?= __('changePassword.heading') ?></h2> <?php call_template('change_password_form'); });
\ No newline at end of file |
