From e0da3d1c081b3aa02e2cc75323edc2026e85c350 Mon Sep 17 00:00:00 2001 From: Marcus Jaschen Date: Sat, 7 Oct 2023 13:57:20 +0200 Subject: [PATCH 1/5] Enable sharing via Mastodon Sharing works now with newer Mastoton releases. --- js/control/ShareRoute.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/js/control/ShareRoute.js b/js/control/ShareRoute.js index 953d3279..ef4408f1 100644 --- a/js/control/ShareRoute.js +++ b/js/control/ShareRoute.js @@ -1,12 +1,7 @@ BR.ShareRoute = L.Class.extend({ - /** - * Sharing via Mastodon is currently disabled by default, because - * the share intent fails when the current route URL is longer - * than the post character limit for that instance. - */ options: { services: { - mastodon: false, + mastodon: true, }, shortcut: { share_action: 65, // char code for 'a' ("action") From c4a8858498e4facfb52485b79df7c6d3fba262c0 Mon Sep 17 00:00:00 2001 From: Marcus Jaschen Date: Thu, 21 Dec 2023 13:04:12 +0100 Subject: [PATCH 2/5] update share dialog - change order of items between mobile and desktop views: - QRCode is rendered at first when displayed on a desktop (viewport >= 992px) - links and buttons are rendered first on mobile devices (viewport < 992px) - add some spacing between buttons --- index.html | 189 +++++++++++++++++++++++++++++------------------------ 1 file changed, 102 insertions(+), 87 deletions(-) diff --git a/index.html b/index.html index 6acafda5..2500eba8 100644 --- a/index.html +++ b/index.html @@ -796,96 +796,111 @@ the route on your smartphone browser for viewing, changing or exporting.

-

- - - - - -

- -

+
+
+

-

- Cannot create QR Code: Route definition is too long. Removing some waypoints may help fit - all data into the QR Code. -

-

- Cannot create QR Code: An unknown error occurred. See the browser console for details. Maybe - the route definition is too long. Removing some waypoints may help fit all data into the QR - Code. -

-
-
QR Code Size:
-
- - - + Cannot create QR Code: An unknown error occurred. See the browser console for + details. Maybe the route definition is too long. Removing some waypoints may help + fit all data into the QR Code. +

+
+
QR Code Size:
+
+ + + +
+
+
+
+
+ +
+
+ + + + +
From fdbb8d5faf77720dc24e37195a500d8f1b45f441 Mon Sep 17 00:00:00 2001 From: Marcus Jaschen Date: Thu, 21 Dec 2023 13:19:25 +0100 Subject: [PATCH 3/5] store/retrieve last used Mastodon instance to/from local storage --- js/control/ShareRoute.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/js/control/ShareRoute.js b/js/control/ShareRoute.js index ef4408f1..ad017b14 100644 --- a/js/control/ShareRoute.js +++ b/js/control/ShareRoute.js @@ -31,16 +31,26 @@ BR.ShareRoute = L.Class.extend({ }); if (this.options.services.mastodon === true) { + let storedMastodonInstance; + if (BR.Util.localStorageAvailable()) { + storedMastodonInstance = localStorage.getItem('share/mastodonInstance'); + } $('.share-service-mastodon') .removeAttr('hidden') .on('click', function () { let mastodonServer = window.prompt( i18next.t('share.mastodon-enter-server-name'), - 'mastodon.social' + storedMastodonInstance ?? 'mastodon.social' ); + if (mastodonServer.indexOf('http') !== 0) { mastodonServer = 'https://' + mastodonServer; } + + if (BR.Util.localStorageAvailable()) { + localStorage.setItem('share/mastodonInstance', new URL(mastodonServer).hostname); + } + window.open(mastodonServer + '/share?text=' + encodeURIComponent(self.getShareUrl()), '_blank'); }); } From 782c50b3ea426127d882de4629b3a54c46e0ea47 Mon Sep 17 00:00:00 2001 From: Marcus Jaschen Date: Thu, 21 Dec 2023 13:21:15 +0100 Subject: [PATCH 4/5] add error handling for invalid URLs --- js/control/ShareRoute.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/js/control/ShareRoute.js b/js/control/ShareRoute.js index ad017b14..dca79fce 100644 --- a/js/control/ShareRoute.js +++ b/js/control/ShareRoute.js @@ -48,7 +48,11 @@ BR.ShareRoute = L.Class.extend({ } if (BR.Util.localStorageAvailable()) { - localStorage.setItem('share/mastodonInstance', new URL(mastodonServer).hostname); + try { + localStorage.setItem('share/mastodonInstance', new URL(mastodonServer).hostname); + } catch (exception) { + console.error('Cannot store Mastodon instance', exception); + } } window.open(mastodonServer + '/share?text=' + encodeURIComponent(self.getShareUrl()), '_blank'); From 6eff1a1e7cd6461a82921bccc08b8bb2b12d9f66 Mon Sep 17 00:00:00 2001 From: Marcus Jaschen Date: Thu, 21 Dec 2023 13:27:07 +0100 Subject: [PATCH 5/5] replace style attribute with proper class --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 2500eba8..696968df 100644 --- a/index.html +++ b/index.html @@ -798,7 +798,7 @@
-

+