From 1790977744da8834a16300402926a1d5e291684e Mon Sep 17 00:00:00 2001 From: Andy Burke Date: Thu, 24 Jul 2025 20:46:35 -0700 Subject: [PATCH] feature: spotify embeds working feature: rounded embed containers --- public/tabs/talk/talk.css | 18 ++++++++++++ public/tabs/talk/talk.js | 61 ++++++++++++++++++++++++++++++++++----- 2 files changed, 71 insertions(+), 8 deletions(-) diff --git a/public/tabs/talk/talk.css b/public/tabs/talk/talk.css index e4cda0a..e758753 100644 --- a/public/tabs/talk/talk.css +++ b/public/tabs/talk/talk.css @@ -186,9 +186,27 @@ width: 100%; max-width: 640px; height: 0; + overflow: hidden; + overflow-y: auto; padding-bottom: 20%; } +#talk .embed-container .embed-actions-container { + position: absolute; + z-index: 100; + top: 0.25rem; + right: 0.25rem; + height: 2rem; + + display: none; + visibility: hidden; + opacity: 0; +} + +#talk .embed-container.rounded { + border-radius: 6px; +} + #talk .embed-container.short { padding-bottom: 7.5%; } diff --git a/public/tabs/talk/talk.js b/public/tabs/talk/talk.js index 9196053..66bd251 100644 --- a/public/tabs/talk/talk.js +++ b/public/tabs/talk/talk.js @@ -2,6 +2,7 @@ const URL_MATCHING_REGEX = /(?:(?[a-zA-Z]+):\/\/)?(?:(?(?\S.+)\:(?.+))\@)?(?(?:(?[-a-zA-Z0-9\.]+)\.)?(?[-a-zA-Z0-9]+?\.(?[-a-zA-Z0-9]{2,64}))(?:\:(?[0-9]{1,6}))?)\b(?[-a-zA-Z0-9@:%_{}\[\]<>\(\)\+.~&\/="]*)(?:\?(?[a-zA-Z0-9!$%&<>()*+,-\.\/\:\;\=\?\@_~"]+))?(?:#(?[a-zA-Z0-9!$&'()*+,-\.\/\:\;\=\?\@_~"]*?))?/gm; const URL_MATCH_HANDLERS = [ + // Tidal (match) => { const original_url = match[0]; const { @@ -16,17 +17,57 @@ const URL_MATCH_HANDLERS = [ } return ` -
+
+
+
`; }, + // Spotify + (match) => { + const original_url = match[0]; + const { + groups: { host, subdomain, item_type, item_id }, + } = + /^(?:spotify:track:|(?:https?:\/\/(?(?:(?.+)\.)?spotify\.com)\/(?.+)\/))(?[a-zA-Z0-9]{22})/gi.exec( + original_url, + ) ?? { groups: {} }; + + console.dir({ + original_url, + host, + subdomain, + item_type, + item_id, + }); + if (!item_id) { + return; + } + + return ` +
+
+
+ +
`; + }, + + // YouTube (match) => { const original_url = match[0]; const { @@ -41,19 +82,23 @@ const URL_MATCH_HANDLERS = [ } return ` -
+
+
+
`; }, - // url + // linkify generic url (match) => { // TODO: punycoding if something has unicode? // const punycode = get_punycode();