Share links come from the worker now, not from a published file

Publishing wrote an HTML file into this repository and triggered a full site
deploy on every share. The page is now rendered per request on its own
hostname, so there is nothing to publish: share_link just marks the video
shared and hands back the address.
This commit is contained in:
gator 2026-09-09 02:21:33 +00:00
parent 7407a945ac
commit 6b7ef08fcc

View file

@ -76,9 +76,10 @@ function card(p) {
// Through our own domain, so an open is a page load we can count. A link // Through our own domain, so an open is a page load we can count. A link
// straight to the file is invisible to us. 33 characters against 74. // straight to the file is invisible to us. 33 characters against 74.
// A placeholder only; share_link returns the real address, which lives on
// its own hostname rather than on this site.
window.__shareUrl = window.__shareUrl || function (p) { window.__shareUrl = window.__shareUrl || function (p) {
if (!(p.cut_url || p.video_url)) return ""; return (p.cut_url || p.video_url) ? "pending" : "";
return location.origin + "/v/" + String(p.id || "").slice(0, 8);
}; };
return '<div class="item">' return '<div class="item">'
@ -113,24 +114,12 @@ async function load() {
if (!p) return; if (!p) return;
var link = window.__shareUrl(p); var link = window.__shareUrl(p);
if (!link) { showMsg("msg", "That one has no video yet."); return; } if (!link) { showMsg("msg", "That one has no video yet."); return; }
// Publish the static page first: it is what carries the preview tags, // Nothing to publish: the page is rendered per request. This only marks
// and crawlers never run the JavaScript route. // the video shared and returns its address.
b.disabled = true; b.textContent = "Preparing…"; b.disabled = true; b.textContent = "Preparing…";
var s = await api("publish_share_page", { email: email, project_id: p.id }); var s = await api("share_link", { email: email, project_id: p.id });
if (s.ok && s.pending) {
var waited = 0;
s = await new Promise(function (done) {
var t = setInterval(async function () {
waited += 4;
var g = await api("publish_share_page", { email: email, project_id: p.id });
if (g.ok && !g.pending) { clearInterval(t); done(g); return; }
if (waited > 180) { clearInterval(t); done({ ok: false, error: "That is taking unusually long." }); }
}, 4000);
});
}
b.disabled = false; b.textContent = "Share"; b.disabled = false; b.textContent = "Share";
if (!s.ok) { showMsg("msg", s.error || "Could not prepare that link."); return; } if (!s.ok) { showMsg("msg", s.error || "Could not prepare that link."); return; }
if (s.note) { showMsg("msg", s.note); return; }
link = s.url || link; link = s.url || link;
var title = p.title || ((p.pet_name || "Your pet") + " has something to say"); var title = p.title || ((p.pet_name || "Your pet") + " has something to say");
// The native sheet is the shortest path into a text message on a phone. // The native sheet is the shortest path into a text message on a phone.