diff --git a/cal/src/EventDetails.vue b/cal/src/EventDetails.vue index f0123d1f..ce99c638 100644 --- a/cal/src/EventDetails.vue +++ b/cal/src/EventDetails.vue @@ -62,9 +62,10 @@ export default { } // done loading. const page = buildPage(evt, vm.calStart, to.fullPath); - vm.evt = evt; + vm.evt = evt; // override the server's shareable with the spa's current page. evt.shareable = window.location; + vm.loadUnfurl(); vm.$emit("pageLoaded", page); }); } @@ -81,7 +82,8 @@ export default { const { caldaily_id, slug } = to.params; return dataPool.getDaily(caldaily_id).then((evt) => { const page = buildPage(evt, this.calStart, to.fullPath); - this.evt = evt; + this.evt = evt; + this.loadUnfurl(); this.$emit("pageLoaded", page); }).catch((error) => { console.warn("event loading error:", error); @@ -100,9 +102,36 @@ export default { }, // the week we came from calStart: null, + // oEmbed card html for a ridewithgps link in the details (if any) + unfurlHtml: null, }; }, + methods: { + // fetch an oEmbed card for the first ridewithgps link in the details, if + // any. mirrors the legacy calendar's loadUnfurls; fails silently on error + // or CORS. unlike the legacy list (collapsed events), this is a dedicated + // page so the link is always visible — no need to lazy-load. + loadUnfurl() { + this.unfurlHtml = null; + const url = helpers.getUnfurlUrl(this.evt.details); + // oEmbed endpoint is ridewithgps-specific; only it is allow-listed today. + if (!url || !/(^|\.)ridewithgps\.com$/i.test(new URL(url).hostname)) { + return; + } + fetch(`https://ridewithgps.com/oembed?format=json&url=${encodeURIComponent(url)}`) + .then((resp) => (resp.ok ? resp.json() : null)) + .then((data) => { + if (data && data.html) { + this.unfurlHtml = data.html; + } + }) + .catch(() => { /* fails silently, matches legacy */ }); + }, + }, computed: { + linkedDetails() { + return helpers.getLinkedDetails(this.evt.details); + }, tags() { return calTags.buildEventTags(this.evt) }, @@ -187,9 +216,8 @@ export default { -

- {{evt.details}} -

+

+