diff --git a/app/static/app.css b/app/static/app.css index e5e5e10..1f5455f 100644 --- a/app/static/app.css +++ b/app/static/app.css @@ -761,6 +761,18 @@ body[data-reader="open"] .row[data-open="true"] { padding: 0 .45rem; font-size: .76rem; line-height: 1.5; } .meta .badge.closed, .reader-meta .badge.closed { color: var(--error); border-color: var(--error); } +/* A deadline within four days (roles.js `closesIn`), in the warning's colour + as closed is in the error's. */ +.meta .badge.closing, .reader-meta .badge.closing, .reader-facts .closing { + color: var(--warn); border-color: var(--warn); +} +/* The language flag (roles.js `langMark`): newsdesk's mark, one glyph and no + border, its reason the title. */ +.meta .badge.mark, .reader-meta .badge.mark, .reader-facts .badge.mark { + background: none; border: 0; padding: 0 .15rem; font-size: .9em; cursor: help; +} +.badge.mark.warn { color: var(--warn); } +.badge.mark.plus { color: var(--accent); } .meta .gated { color: var(--error); } /* How many postings a row stands for (roles.js `dupes`), newsdesk's "+N more outlets": beside the company and in the accent, not a badge. */ @@ -911,6 +923,22 @@ body[data-reader="open"] .company-strip { display: none; } border-left: 3px solid var(--accent); border-radius: .3rem; } .reader-summary p { margin: 0; font-family: var(--read); line-height: 1.6; } +/* The CV match (roles.js `cvMatch`), in the summary's box: the total, its + three numbers, and the strengths and gaps side by side, stacked on a phone. */ +.reader-cv .cv-total { margin: 0 0 .45rem; font-variant-numeric: tabular-nums; } +.reader-cv .cv-total b { font-size: 1.25rem; } +.reader-cv .cv-total span { display: inline-block; margin-left: .4rem; color: var(--dim); font-size: .88rem; } +.cv-lists { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem 1.2rem; } +.cv-lists ul { margin: 0; padding-left: 1.1rem; font-size: .92rem; line-height: 1.45; } +.cv-lists li + li { margin-top: .2rem; } +/* The deadline and the languages (roles.js `roleFacts`), newsdesk's settings `dl`. */ +.reader-facts { + display: grid; grid-template-columns: 6rem minmax(0, 1fr); + gap: .3rem .8rem; margin-top: 1rem; +} +.reader-facts dt { font-size: .82rem; color: var(--faint); } +.reader-facts dd { margin: 0; font-size: .88rem; } +.reader-facts .fact-note { display: block; margin-top: .15rem; color: var(--dim); font-size: .82rem; } /* A label over a block rather than the posting's own heading. */ .reader-label { margin: 0 0 .3rem; font-size: .72rem; font-weight: 600; @@ -1047,6 +1075,8 @@ table.applications td[data-label="Saved"] { white-space: nowrap; color: var(--di .top:has(#search) .brand { display: none; } #rail-toggle:not([aria-label*="filter"]) .rail-toggle-label { display: none; } #reader h1 { font-size: 1.3rem; } + .cv-lists { grid-template-columns: minmax(0, 1fr); } + .reader-summary { padding: .6rem .7rem; } } @media (max-width: 640px) { diff --git a/app/static/roles.js b/app/static/roles.js index aa77dc8..326ace7 100644 --- a/app/static/roles.js +++ b/app/static/roles.js @@ -9,7 +9,8 @@ * from app.js, so a failure is one toast carrying the server's own sentence. * * A row is newsdesk's `.row`: the score gutter and number (hidden under - * Newest first, since the score is not what put the row there), the title, + * Newest first, since the score is not what put the row there, and the CV + * match under Best CV match, a dash for a role not judged yet), the title, * company · place · badges · age · tags, the summary or the description's * opening, and ▼ ● ▲ ★ from judge.js. A passed role and a hidden company's * are dimmed, never dropped, so a stray tap stays visible to be undone. @@ -31,9 +32,12 @@ * Picking another reloads the feed and the counts under the reader, which * stays open and is fetched again for that agent's vote. * - * Order is Best first (`order=score`, the agent's score moved by its votes) - * or Newest first (`order=newest`), the same two whichever agent is viewed, - * and both carry the agent's votes and hidden companies. + * Order is Best first (`order=score`, the agent's score moved by its votes), + * Newest first (`order=newest`) or Best CV match (`order=cv`, the roles the + * agent's `judge` read against its CV first, by that total), the same three + * whichever agent is viewed, and all carry the agent's votes and hidden + * companies. Best CV match needs a CV: an agent without one is shown Best + * first, as an agentless page is shown Newest first. * * The filters are in the query string, so a reload or a link keeps them, and * each one set is a history entry, so back takes it off again: a tag, the @@ -116,8 +120,14 @@ const TRACKS = { "": "Both", ic: "Individual", people: "People" }; // What the list is in the order of. Best first is the viewing agent's - // score, moved by its votes; Newest first is first seen. - const SORTS = { score: "Best first", time: "Newest first" }; + // score, moved by its votes; Newest first is first seen; Best CV match is + // the agent's `judge` total, the roles not judged after by score. + const SORTS = { score: "Best first", time: "Newest first", cv: "Best CV match" }; + // The route's `order` for each. + const ORDERS = { score: "score", time: "newest", cv: "cv" }; + // How many days ahead a deadline earns a badge: today to today + 4, the + // window of `closing=1` (Closing soon). + const CLOSING_DAYS = 4; // The named windows over `days`, which counts back from now. const PERIODS = { @@ -145,6 +155,7 @@ company: "", place: "", function: "", remote: "", judged: "", pay: "", showMuted: false, gated: false, companyKeys: [], places: [], levelFrom: "", levelTo: "", track: "", seniorityUnknown: true, payUnknown: false, + closing: false, }; } @@ -154,7 +165,7 @@ counted. */ function filtersOn(f = state.filter, { more = false } = {}) { const folded = [f.company.trim(), f.place.trim(), f.function, f.remote, f.pay, f.judged, - f.showMuted, sortShown() === "score" && f.gated].filter(Boolean).length + f.showMuted, f.closing, ranked() && f.gated].filter(Boolean).length + f.companyKeys.length + f.places.length + [f.levelFrom, f.levelTo, f.track].filter(Boolean).length; if (more) return folded; @@ -201,10 +212,24 @@ // ------------------------------------------------------------ the order + /** The viewing agent, once the agents are in. */ + const viewed = () => state.agents.find((a) => a.id === state.filter.agent) || null; + + /** Whether Best CV match has a CV to go by: the viewed agent has one, or + the agents are not in yet, when the address is taken at its word. */ + const hasCv = () => !state.agentsLoaded || Boolean(viewed()?.cv_text?.trim()); + /** The order the list is in. Best first needs an agent to score by: with - none enabled the server answers newest first, and so does this. */ - const sortShown = () => - (state.filter.sort === "score" && state.filter.agent !== null ? "score" : "time"); + none enabled the server answers newest first, and so does this. Best + CV match needs that agent's CV too, and without one is Best first. */ + function sortShown() { + const { sort, agent } = state.filter; + if (sort === "time" || agent === null) return "time"; + return sort === "cv" && hasCv() ? "cv" : "score"; + } + + /** Whether the list is in a score order, where a gated role can be shown. */ + const ranked = () => sortShown() !== "time"; /** Whether a bound or a track is set, which is what "no level" asks about. */ const seniorityOn = (f = state.filter) => Boolean(f.levelFrom || f.levelTo || f.track); @@ -228,10 +253,11 @@ // Each box is sent only off its default, and only while its filter is on. if (seniorityOn(f) && !f.seniorityUnknown) p.set("seniority_unknown", "false"); if (f.pay && f.payUnknown) p.set("pay_unknown", "true"); + if (f.closing) p.set("closing", "1"); if (f.agent !== null) { p.set("agent", String(f.agent)); - p.set("order", sortShown() === "score" ? "score" : "newest"); - if (f.gated && sortShown() === "score") p.set("gated", "true"); + p.set("order", ORDERS[sortShown()]); + if (f.gated && ranked()) p.set("gated", "true"); } return p; } @@ -264,8 +290,9 @@ f.track = q.get("track") in TRACKS ? q.get("track") : ""; f.seniorityUnknown = q.get("seniority_unknown") !== "false"; f.payUnknown = q.get("pay_unknown") === "true"; + f.closing = q.get("closing") === "1" || q.get("closing") === "true"; if (!view) return; - if (q.get("sort") === "time") f.sort = "time"; + if (q.get("sort") === "time" || q.get("sort") === "cv") f.sort = q.get("sort"); // Checked against the enabled agents once they are in (`chooseAgent`). if (q.get("agent")) f.agent = Number(q.get("agent")); // Open where the rail is a column of its own, which scrolls; shut where @@ -310,7 +337,7 @@ function addressFor(path, f = state.filter, q = state.q) { const p = feedParams(f, q); p.delete("order"); - if (f.sort === "time") p.set("sort", "time"); + if (f.sort !== "score") p.set("sort", f.sort); const query = p.toString(); return path + (query ? `?${query}` : ""); } @@ -625,18 +652,24 @@ renderAgent(); - // The order, the same two whatever is viewed. Best first needs an agent - // to score by, so with none it is greyed and says why. + // The order, the same three whatever is viewed. Best first needs an + // agent to score by, and Best CV match that agent's CV, so without one + // each is greyed and says why. const none = state.agentsLoaded && !state.agents.length; + const why = { + score: none ? "No search agent is enabled, so nothing is scored." : "", + cv: none ? "No search agent is enabled, so nothing is judged." + : !hasCv() ? "This agent has no CV, so nothing is judged against one. Search agents sets it." + : "", + }; $("#sort").querySelectorAll("[data-sort]").forEach((b) => { b.setAttribute("aria-pressed", String(sortShown() === b.dataset.sort)); - const off = b.dataset.sort === "score" && none; + const off = Boolean(why[b.dataset.sort]); if (off) b.setAttribute("aria-disabled", "true"); else b.removeAttribute("aria-disabled"); - b.title = off ? "No search agent is enabled, so nothing is scored." : ""; + b.title = why[b.dataset.sort] || ""; }); - const ranked = sortShown() === "score"; - $("#show-gated").hidden = !ranked; + $("#show-gated").hidden = !ranked(); $("#period").value = f.period; @@ -665,6 +698,7 @@ setValue("f-pay", f.pay); setValue("f-judged", f.judged); setValue("f-show-muted", f.showMuted); + setValue("f-closing", f.closing); setValue("f-gated", f.gated); renderFacets(); const more = filtersOn(f, { more: true }); @@ -893,12 +927,47 @@ return ""; } - /** Closed, pay, remote, function and seniority, as the row and the reader - both show them. */ + /** Days from today (UTC, as `closing=1` counts) to a `YYYY-MM-DD` + deadline: 0 is today, negative is past; null with no date. */ + function daysLeft(deadline) { + const at = Date.parse(`${deadline || ""}T00:00:00Z`); + if (!Number.isFinite(at)) return null; + const today = Date.parse(`${new Date().toISOString().slice(0, 10)}T00:00:00Z`); + return Math.round((at - today) / 86400000); + } + + /** "closes today" or "closes in N d" within the Closing soon window, else "". */ + function closesIn(deadline) { + const n = daysLeft(deadline); + if (n === null || n < 0 || n > CLOSING_DAYS) return ""; + return n === 0 ? "closes today" : `closes in ${n} d`; + } + + /* The posting's languages against the agent's (`lang_flag`): ⚠ when it + requires one the agent lacks or a level above the agent's, ★ when it + names one of the agent's as a plus. A glyph with the reason as its title, + newsdesk's mark; the reader spells the reason out for a phone. */ + const LANG_MARKS = { + missing: ["⚠", "warn"], below: ["⚠", "warn"], plus: ["★", "plus"], + }; + + function langMark(role) { + const mark = LANG_MARKS[role.lang_flag]; + if (!mark) return ""; + const note = role.lang_note || ""; + return `${mark[0]}`; + } + + /** Closed, closing soon, the language flag, pay, remote, function and + seniority, as the row and the reader both show them. */ function badges(role) { const words = [remoteHelpers.remoteBadge(role), role.function, role.seniority].filter(Boolean); const pay = payBadge(role); + const closing = role.closed_at ? "" : closesIn(role.deadline); return (role.closed_at ? `closed` : "") + + (closing ? `${closing}` : "") + + langMark(role) + (pay ? `${esc(pay)}` : "") + words.map((w) => `${esc(w)}`).join(""); } @@ -971,13 +1040,29 @@ `; } - function drawRow(el, role) { + /* The gutter's number, of 100, and what it says: the agent's score, or + under Best CV match the CV match, where a role `judge` has not read yet + shows a dash and an empty bar. */ + function gutterOf(role) { + if (sortShown() === "cv") { + const judged = role.cv_score !== null && role.cv_score !== undefined; + return { + pct: judged ? Math.round(Math.min(100, Math.max(0, role.cv_score))) : 0, + shown: judged ? String(Math.round(role.cv_score)) : "–", + title: judged ? "How well it matches the CV, of 100" : "Not judged against the CV yet", + }; + } const scored = role.score !== null && role.score !== undefined; const pct = scored ? Math.round(Math.min(1, Math.max(0, role.score)) * 100) : 0; + return { pct, shown: scored ? String(pct) : "", title: "How well it matches, of 100" }; + } + + function drawRow(el, role) { + const { pct, shown, title } = gutterOf(role); const text = excerpt(role); el.innerHTML = `