diff --git a/app/static/roles.js b/app/static/roles.js index 7814ac4..8c597a5 100644 --- a/app/static/roles.js +++ b/app/static/roles.js @@ -903,16 +903,23 @@ return n > 1 ? `×${n}` : ""; } + /* Where a role's posting is: the ad's own page once it is known + (`posting_url`, found for a Jobindex role when its text is fetched), else + the link the board listed. Either way only an http(s) link. */ + function linkOf(x) { + return safeUrl(x?.posting_url) || safeUrl(x?.original_url); + } + /* The other postings of this role, each a link to where it is posted, labelled by host and place, as newsdesk's "Also covered by". */ function alsoPosted(r) { const copies = (Array.isArray(r.copies) ? r.copies : []) - .filter((c) => safeUrl(c.original_url)); + .filter((c) => linkOf(c)); if (!copies.length) return ""; return `

Also posted

${copies.map((c) => { - const url = safeUrl(c.original_url); + const url = linkOf(c); const when = c.posted_at ? ago(c.posted_at) : ""; return ` ${esc(c.host || host(url))} @@ -925,7 +932,7 @@ link opens: the copies' own links, and the role's link for its own. */ function placeEntries(r) { const seen = new Set(); - const own = safeUrl(r.original_url); + const own = linkOf(r); const out = []; for (const p of Array.isArray(r.places) ? r.places : []) { const url = p.url ? safeUrl(p.url) : own; @@ -1312,7 +1319,7 @@ el.dataset.uid = state.readingUid; if (r.title) document.title = `${r.title} — roledesk`; - const out = safeUrl(r.original_url); + const out = linkOf(r); const text = (r.article_text || r.description || "").trim(); const body = error ? `

This role could not be loaded: ${esc(error)}

` @@ -1502,7 +1509,7 @@ const uid = state.readingUid || state.items[state.selected]?.uid; const role = state.reading?.uid === uid ? state.reading : state.items.find((r) => r.uid === uid); - const url = safeUrl(role?.original_url); + const url = linkOf(role); if (!url) return; window.open(url, "_blank", "noopener"); markRead(uid);