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:
parent
7407a945ac
commit
6b7ef08fcc
1 changed files with 6 additions and 17 deletions
23
videos.html
23
videos.html
|
|
@ -76,9 +76,10 @@ function card(p) {
|
|||
|
||||
// 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.
|
||||
// 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) {
|
||||
if (!(p.cut_url || p.video_url)) return "";
|
||||
return location.origin + "/v/" + String(p.id || "").slice(0, 8);
|
||||
return (p.cut_url || p.video_url) ? "pending" : "";
|
||||
};
|
||||
|
||||
return '<div class="item">'
|
||||
|
|
@ -113,24 +114,12 @@ async function load() {
|
|||
if (!p) return;
|
||||
var link = window.__shareUrl(p);
|
||||
if (!link) { showMsg("msg", "That one has no video yet."); return; }
|
||||
// Publish the static page first: it is what carries the preview tags,
|
||||
// and crawlers never run the JavaScript route.
|
||||
// Nothing to publish: the page is rendered per request. This only marks
|
||||
// the video shared and returns its address.
|
||||
b.disabled = true; b.textContent = "Preparing…";
|
||||
var s = await api("publish_share_page", { 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);
|
||||
});
|
||||
}
|
||||
var s = await api("share_link", { email: email, project_id: p.id });
|
||||
b.disabled = false; b.textContent = "Share";
|
||||
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;
|
||||
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.
|
||||
|
|
|
|||
Loading…
Reference in a new issue