admin page
All checks were successful
/ deploy (push) Successful in 1m8s

This commit is contained in:
Loyyd 2026-07-10 10:38:08 +02:00
parent aa10a4e22b
commit e2354234ae
2 changed files with 891 additions and 190 deletions

View file

@ -23,20 +23,103 @@ body.custom-background { background-color: #ffffff; }
/* Homepage slider/frontpage settings from the original export. */ /* Homepage slider/frontpage settings from the original export. */
#colophon {display: none;} .slider-wrapper { max-width: 1200px; } #slider{ max-width: 1200px; max-height: 350px; border:0px solid #ffffff; } #front-text1, #front-text2 { color: #212121; } #front-columns > div { width: 32%; } #front-columns > div.ppcolumn:nth-child(3n) { margin-right: 0; } #front-columns > div.ppcolumn:nth-child(3n+1) { clear: left; } .column-image { padding: 0px; } .column-image h3 {margin-bottom: 0px; } .column-image img { max-height:201px;} .nivo-caption { background-color: rgb(252,250,250); background-color: rgba(252,250,250,0.7); } .nivo-caption, .nivo-caption a { color: #0e2012; } .theme-default .nivoSlider { background-color: #ffffff; } .theme-default .nivo-controlNav:before, .theme-default .nivo-controlNav:after { border-top-color:#ffffff; } .theme-default .nivo-controlNav { background-color:#ffffff; } .slider-bullets .nivo-controlNav a { background-color: #fdf7f7; } .slider-bullets .nivo-controlNav a:hover { background-color: #fdfcfc; } .slider-bullets .nivo-controlNav a.active {background-color: #ffffff; } .slider-numbers .nivo-controlNav a { color:#fdf7f7; background-color:#F7F7F2;} .slider-numbers .nivo-controlNav a:hover { color: #fdfcfc; background-color:#FFFFFF } .slider-numbers .nivo-controlNav a.active { color:#ffffff;} .column-image h3{ color: #333333; background-color: rgb(255,255,255); } .columnmore { background-color: #F7F7F2; } .columnmore:before { border-bottom-color: #F7F7F2; } #front-columns h3.column-header-noimage { background: #FFFFFF; } #colophon {display: none;} .slider-wrapper { max-width: 1200px; } #slider{ max-width: 1200px; max-height: 350px; border:0px solid #ffffff; } #front-text1, #front-text2 { color: #212121; } #front-columns > div { width: 32%; } #front-columns > div.ppcolumn:nth-child(3n) { margin-right: 0; } #front-columns > div.ppcolumn:nth-child(3n+1) { clear: left; } .column-image { padding: 0px; } .column-image h3 {margin-bottom: 0px; } .column-image img { max-height:201px;} .nivo-caption { background-color: rgb(252,250,250); background-color: rgba(252,250,250,0.7); } .nivo-caption, .nivo-caption a { color: #0e2012; } .theme-default .nivoSlider { background-color: #ffffff; } .theme-default .nivo-controlNav:before, .theme-default .nivo-controlNav:after { border-top-color:#ffffff; } .theme-default .nivo-controlNav { background-color:#ffffff; } .slider-bullets .nivo-controlNav a { background-color: #fdf7f7; } .slider-bullets .nivo-controlNav a:hover { background-color: #fdfcfc; } .slider-bullets .nivo-controlNav a.active {background-color: #ffffff; } .slider-numbers .nivo-controlNav a { color:#fdf7f7; background-color:#F7F7F2;} .slider-numbers .nivo-controlNav a:hover { color: #fdfcfc; background-color:#FFFFFF } .slider-numbers .nivo-controlNav a.active { color:#ffffff;} .column-image h3{ color: #333333; background-color: rgb(255,255,255); } .columnmore { background-color: #F7F7F2; } .columnmore:before { border-bottom-color: #F7F7F2; } #front-columns h3.column-header-noimage { background: #FFFFFF; }
/* Searchable speeches archive. */ /* Interactive speeches archive explorer. */
.speeches-archive .post {
padding: 0;
}
.speeches-archive .entry-content { .speeches-archive .entry-content {
max-width: 100%; max-width: 100%;
} }
.speech-explorer {
--speech-orange: #bf4d28;
--speech-orange-soft: #fff4ef;
--speech-green: #618348;
--speech-green-soft: #edf4e3;
--speech-ink: #2f312d;
--speech-muted: #666a62;
--speech-line: #dedfd9;
--speech-wash: #f7f7f2;
color: var(--speech-ink);
}
.speech-explorer-intro {
max-width: 720px;
padding: 34px 36px 10px;
}
.speech-explorer-intro .entry-title {
margin: 2px 0 10px;
color: var(--speech-ink);
font-family: "Bebas Neue";
font-size: 44px;
line-height: 1;
}
.speech-explorer-intro > p:last-child {
max-width: 640px;
margin: 0;
color: var(--speech-muted);
font-size: 16px;
}
.speech-explorer-kicker,
.speech-section-kicker {
margin: 0;
color: var(--speech-orange);
font-size: 11px;
font-weight: 700;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.speech-archive-overview {
display: grid;
grid-template-columns: repeat(3, 1fr);
margin: 22px 36px 30px;
border-top: 1px solid var(--speech-line);
border-bottom: 1px solid var(--speech-line);
}
.speech-archive-overview div {
padding: 16px 18px;
border-right: 1px solid var(--speech-line);
}
.speech-archive-overview div:first-child {
padding-left: 0;
}
.speech-archive-overview div:last-child {
border-right: 0;
}
.speech-archive-overview dt {
color: var(--speech-muted);
font-size: 11px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.speech-archive-overview dd {
margin: 4px 0 0;
color: var(--speech-ink);
font-family: "Yanone Kaffeesatz Regular";
font-size: 27px;
line-height: 1.1;
}
.speech-filters { .speech-filters {
display: grid; display: grid;
grid-template-columns: minmax(240px, 2fr) repeat(2, minmax(150px, 1fr)) auto; grid-template-columns: minmax(230px, 2fr) repeat(3, minmax(120px, 1fr)) auto;
gap: 12px; gap: 12px;
align-items: end; align-items: end;
margin: 0 0 18px; margin: 0 36px 28px;
padding: 16px; padding: 18px;
border: 1px solid #eeeeee; border: 1px solid var(--speech-line);
background: #fbfbf8; background: var(--speech-wash);
} }
.speech-filter { .speech-filter {
@ -46,9 +129,10 @@ body.custom-background { background-color: #ffffff; }
.speech-filter label { .speech-filter label {
display: block; display: block;
margin-bottom: 5px; margin-bottom: 5px;
color: #444444; color: var(--speech-muted);
font-size: 12px; font-size: 11px;
font-weight: 700; font-weight: 700;
letter-spacing: 0.06em;
text-transform: uppercase; text-transform: uppercase;
} }
@ -56,103 +140,427 @@ body.custom-background { background-color: #ffffff; }
.speech-filter select { .speech-filter select {
box-sizing: border-box; box-sizing: border-box;
width: 100%; width: 100%;
min-height: 38px; min-height: 42px;
margin: 0; margin: 0;
border: 1px solid #cfd0ca;
border-radius: 3px;
color: var(--speech-ink);
background: #ffffff;
} }
.speech-reset { .speech-filter input:focus,
min-height: 38px; .speech-filter select:focus,
padding: 8px 12px; .speech-reset:focus,
border: 1px solid #d8d8d0; .speech-load-more:focus,
border-radius: 4px; .speech-detail-nav button:focus,
color: #333333; .speech-year-button:focus {
outline: 2px solid var(--speech-orange);
outline-offset: 2px;
}
.speech-reset,
.speech-load-more,
.speech-detail-nav button {
min-height: 42px;
padding: 8px 13px;
border: 1px solid #cfd0ca;
border-radius: 3px;
color: var(--speech-ink);
background: #ffffff; background: #ffffff;
cursor: pointer; cursor: pointer;
} }
.speech-reset:hover, .speech-reset:hover,
.speech-reset:focus { .speech-load-more:hover,
border-color: #bf4d28; .speech-detail-nav button:hover:not(:disabled) {
color: #bf4d28; border-color: var(--speech-orange);
color: var(--speech-orange);
} }
.speech-archive-status { .speech-chart-section {
margin: 0 0 14px; margin: 0 36px 34px;
color: #666666; }
.speech-section-heading {
display: flex;
flex-wrap: wrap;
gap: 10px 24px;
align-items: end;
justify-content: space-between;
margin-bottom: 12px;
}
.speech-section-heading h2 {
margin: 1px 0 0;
color: var(--speech-ink);
font-size: 25px;
line-height: 1.1;
}
.speech-chart-summary,
.speech-results-status,
.speech-detail-position {
margin: 0;
color: var(--speech-muted);
font-size: 12px;
}
.speech-year-chart {
--speech-year-columns: 38;
display: grid;
grid-template-columns: repeat(var(--speech-year-columns), minmax(0, 1fr));
gap: 3px;
align-items: end;
min-height: 122px;
padding: 38px 0 26px;
border-top: 1px solid var(--speech-line);
border-bottom: 1px solid var(--speech-line);
background-image: linear-gradient(to top, transparent 24%, #eeeeea 25%, transparent 26%, transparent 49%, #eeeeea 50%, transparent 51%, transparent 74%, #eeeeea 75%, transparent 76%);
}
.speech-year-button {
position: relative;
display: flex;
align-items: end;
height: 120px;
min-width: 0;
padding: 0;
border: 0;
color: var(--speech-muted);
background: transparent;
cursor: pointer;
}
.speech-year-button:disabled {
cursor: default;
}
.speech-year-button::after {
position: absolute;
z-index: 3;
top: -32px;
left: 50%;
display: none;
width: max-content;
max-width: 140px;
padding: 4px 7px;
transform: translateX(-50%);
border-radius: 3px;
color: #ffffff;
background: var(--speech-ink);
content: attr(data-chart-label);
font-size: 11px;
line-height: 1.25;
pointer-events: none;
}
.speech-year-button:hover::after,
.speech-year-button:focus::after {
display: block;
}
.speech-year-bar {
display: block;
width: 100%;
height: var(--speech-bar-height);
min-height: 2px;
border-radius: 2px 2px 0 0;
background: #b9cc9f;
transition: height 180ms ease, background-color 180ms ease;
}
.speech-year-button:hover .speech-year-bar,
.speech-year-button:focus .speech-year-bar {
background: #e6ac27;
}
.speech-year-button[aria-pressed="true"] .speech-year-bar {
background: var(--speech-orange);
}
.speech-year-button:disabled .speech-year-bar {
min-height: 1px;
background: #d9dad4;
}
.speech-year-tick {
position: absolute;
bottom: -23px;
left: 50%;
transform: translateX(-50%);
font-size: 10px;
white-space: nowrap;
}
.speech-explorer-layout {
display: grid;
grid-template-columns: minmax(0, 1fr) minmax(280px, 34%);
gap: 26px;
align-items: start;
padding: 0 36px 38px;
}
.speech-results-heading {
min-height: 43px;
} }
.speech-results { .speech-results {
display: grid; border-top: 1px solid var(--speech-line);
gap: 12px;
} }
.speech-result { a.speech-result {
padding: 16px; display: block;
border: 1px solid #eeeeee; padding: 17px 16px 17px 0;
border-radius: 6px; border-bottom: 1px solid var(--speech-line);
background: #ffffff; color: var(--speech-ink);
text-decoration: none;
}
a.speech-result:hover,
a.speech-result:focus,
a.speech-result.is-selected {
color: var(--speech-ink);
background: var(--speech-wash);
}
a.speech-result.is-selected {
padding-left: 13px;
border-left: 3px solid var(--speech-orange);
}
.speech-result-topline {
display: flex;
flex-wrap: wrap;
gap: 6px 10px;
align-items: center;
margin-bottom: 5px;
color: var(--speech-muted);
font-size: 11px;
font-weight: 700;
letter-spacing: 0.04em;
text-transform: uppercase;
}
.speech-result-year {
color: var(--speech-green);
} }
.speech-result-title { .speech-result-title {
margin: 4px 0 8px; display: block;
font-size: 24px; margin-bottom: 5px;
line-height: 1.2; color: var(--speech-ink);
font-family: "Yanone Kaffeesatz Regular";
font-size: 21px;
font-weight: 400;
line-height: 1.15;
} }
.speech-result p { .speech-result-excerpt {
margin: 0; display: -webkit-box;
} overflow: hidden;
color: var(--speech-muted);
.speech-result-meta {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
.speech-result-meta span {
display: inline-flex;
align-items: center;
min-height: 22px;
padding: 2px 8px;
border: 1px solid #eeeeee;
border-radius: 4px;
color: #5c5c56;
background: #f7f7f2;
font-size: 12px; font-size: 12px;
line-height: 1.2; line-height: 1.55;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
} }
.speech-result-meta span:first-child { .speech-load-more {
border-color: #d5e6b3; width: 100%;
color: #365d26; margin-top: 14px;
background: #f2f7e8; }
.speech-load-more[hidden] {
display: none;
} }
.speech-empty-state { .speech-empty-state {
margin: 0;
padding: 26px 0;
border-bottom: 1px solid var(--speech-line);
color: var(--speech-muted);
}
.speech-detail {
position: sticky;
top: 20px;
padding: 22px; padding: 22px;
border: 1px solid #eeeeee; border: 1px solid var(--speech-line);
border-radius: 6px; border-top: 4px solid var(--speech-green);
background: #ffffff; background: #ffffff;
} }
.speech-detail h2 {
margin: 8px 0 8px;
color: var(--speech-ink);
font-size: 27px;
line-height: 1.1;
}
.speech-detail > p {
color: var(--speech-muted);
}
.speech-detail .speech-section-kicker {
color: var(--speech-green);
}
.speech-detail-position {
float: right;
}
.speech-detail-meta {
margin: 0 0 16px;
padding-bottom: 13px;
border-bottom: 1px solid var(--speech-line);
color: var(--speech-muted);
font-size: 11px;
font-weight: 700;
letter-spacing: 0.04em;
text-transform: uppercase;
}
.speech-detail-link {
display: inline-block;
margin-top: 5px;
font-weight: 700;
}
.speech-detail-nav {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
margin-top: 20px;
padding-top: 16px;
border-top: 1px solid var(--speech-line);
}
.speech-detail-nav button {
min-height: 36px;
padding: 6px 9px;
}
.speech-detail-nav button:disabled {
color: #9a9c96;
background: var(--speech-wash);
cursor: default;
}
.speech-explorer-message {
margin: -28px 36px 32px;
color: var(--speech-muted);
font-size: 11px;
}
.speech-explorer.is-ready .speech-explorer-message {
display: none;
}
.speech-explorer-message.is-error {
color: var(--speech-orange);
}
@media (prefers-reduced-motion: reduce) {
.speech-year-bar {
transition: none;
}
}
@media (max-width: 900px) { @media (max-width: 900px) {
.speech-filters { .speech-filters {
grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-columns: repeat(3, minmax(0, 1fr));
}
.speech-filter-search {
grid-column: 1 / -1;
} }
.speech-filter-search,
.speech-reset { .speech-reset {
grid-column: 1 / -1; grid-column: 1 / -1;
} }
.speech-explorer-layout {
grid-template-columns: minmax(0, 1.15fr) minmax(250px, 0.85fr);
}
}
@media (max-width: 720px) {
.speech-explorer-intro {
padding: 28px 22px 8px;
}
.speech-archive-overview,
.speech-filters,
.speech-chart-section {
margin-right: 22px;
margin-left: 22px;
}
.speech-explorer-layout {
grid-template-columns: 1fr;
padding-right: 22px;
padding-left: 22px;
}
.speech-detail {
position: static;
grid-row: 1;
}
.speech-results-panel {
grid-row: 2;
}
.speech-explorer-message {
margin-right: 22px;
margin-left: 22px;
}
} }
@media (max-width: 560px) { @media (max-width: 560px) {
.speech-explorer-intro .entry-title {
font-size: 38px;
}
.speech-archive-overview {
grid-template-columns: 1fr;
}
.speech-archive-overview div,
.speech-archive-overview div:first-child {
padding: 11px 0;
border-right: 0;
border-bottom: 1px solid var(--speech-line);
}
.speech-archive-overview div:last-child {
border-bottom: 0;
}
.speech-filters { .speech-filters {
grid-template-columns: 1fr; grid-template-columns: 1fr;
} }
.speech-result-title { .speech-filter-search,
font-size: 21px; .speech-reset {
grid-column: auto;
}
.speech-year-chart {
gap: 2px;
}
.speech-year-tick {
font-size: 9px;
}
.speech-section-heading {
align-items: start;
flex-direction: column;
}
.speech-detail h2 {
font-size: 24px;
} }
} }

View file

@ -3,13 +3,25 @@ import SiteLayout from "../../components/SiteLayout.astro";
import { getSpeechArchive, uniqueSorted } from "../../lib/speeches"; import { getSpeechArchive, uniqueSorted } from "../../lib/speeches";
const speeches = getSpeechArchive(); const speeches = getSpeechArchive();
const years = uniqueSorted(speeches.map((speech) => speech.year), "desc"); const years = uniqueSorted(speeches.map((speech) => speech.year));
const speakers = uniqueSorted(speeches.map((speech) => speech.speaker)); const speakers = uniqueSorted(speeches.map((speech) => speech.speaker));
const decades = uniqueSorted(
years.map((year) => `${Math.floor(Number.parseInt(year, 10) / 10) * 10}`),
);
const yearCounts = new Map(
years.map((year) => [year, speeches.filter((speech) => speech.year === year).length]),
);
const maxYearCount = Math.max(...yearCounts.values());
const initialResults = speeches.slice(0, 18);
const initialSpeech = initialResults[0];
const initialSpeechId = initialSpeech?.id ?? "";
const firstYear = years[0] ?? "";
const lastYear = years.at(-1) ?? "";
--- ---
<SiteLayout <SiteLayout
title="Speeches Archive &#8211; FFWPU Ireland" title="Speeches Explorer &#8211; FFWPU Ireland"
description="Search the FFWPU Ireland archive of speeches by Rev. Sun Myung Moon and Dr. Hak Ja Han Moon by year, speaker, and text." description={`Explore ${speeches.length} speeches in the FFWPU Ireland archive by year, decade, speaker, and full text.`}
bodyClass="page-template page-template-templates page-template-template-onecolumn page-template-templatestemplate-onecolumn-php page custom-background tribe-no-js metaslider-plugin parabola-image-three caption-light meta-light parabola_triagles parabola-menu-left" bodyClass="page-template page-template-templates page-template-template-onecolumn page-template-templatestemplate-onecolumn-php page custom-background tribe-no-js metaslider-plugin parabola-image-three caption-light meta-light parabola_triagles parabola-menu-left"
pathname="/speeches/" pathname="/speeches/"
canonical="/speeches/" canonical="/speeches/"
@ -21,21 +33,32 @@ const speakers = uniqueSorted(speeches.map((speech) => speech.speaker));
<section id="container" class="one-column speeches-archive"> <section id="container" class="one-column speeches-archive">
<div id="content" role="main"> <div id="content" role="main">
<div class="post page type-page status-publish hentry"> <div class="post page type-page status-publish hentry">
<h1 class="entry-title">Speeches Archive</h1> <div class="entry-content speech-explorer" data-speech-explorer>
<header class="speech-explorer-intro">
<p class="speech-explorer-kicker">FFWPU Ireland digital collection</p>
<h1 class="entry-title">Speeches Explorer</h1>
<p>Search the full archive, compare activity across the years, and select any result for a closer look.</p>
</header>
<dl class="speech-archive-overview" aria-label="Archive overview">
<div>
<dt>Speeches</dt>
<dd>{speeches.length.toLocaleString("en-IE")}</dd>
</div>
<div>
<dt>Years represented</dt>
<dd>{years.length}</dd>
</div>
<div>
<dt>Collection span</dt>
<dd>{firstYear}&ndash;{lastYear}</dd>
</div>
</dl>
<div class="entry-content">
<form class="speech-filters" id="speech-filters" role="search"> <form class="speech-filters" id="speech-filters" role="search">
<div class="speech-filter speech-filter-search"> <div class="speech-filter speech-filter-search">
<label for="speech-search">Search text</label> <label for="speech-search">Search the full text</label>
<input id="speech-search" name="q" type="search" autocomplete="off" placeholder="Search titles and full speech text" /> <input id="speech-search" name="q" type="search" autocomplete="off" placeholder="Try peace, family, Ireland&hellip;" />
</div>
<div class="speech-filter">
<label for="speech-year">Year</label>
<select id="speech-year" name="year">
<option value="">All years</option>
{years.map((year) => <option value={year}>{year}</option>)}
</select>
</div> </div>
<div class="speech-filter"> <div class="speech-filter">
@ -46,29 +69,121 @@ const speakers = uniqueSorted(speeches.map((speech) => speech.speaker));
</select> </select>
</div> </div>
<button class="speech-reset" type="reset">Reset filters</button> <div class="speech-filter">
<label for="speech-decade">Decade</label>
<select id="speech-decade" name="decade">
<option value="">All decades</option>
{decades.map((decade) => <option value={decade}>{decade}s</option>)}
</select>
</div>
<div class="speech-filter">
<label for="speech-year">Year</label>
<select id="speech-year" name="year">
<option value="">All years</option>
{years.map((year) => <option value={year}>{year}</option>)}
</select>
</div>
<button class="speech-reset" type="reset">Clear filters</button>
</form> </form>
<div class="speech-archive-status" aria-live="polite"> <section class="speech-chart-section" aria-labelledby="speech-chart-title">
<strong id="speech-result-count">{speeches.length}</strong> speeches <div class="speech-section-heading">
<div>
<p class="speech-section-kicker">Distribution</p>
<h2 id="speech-chart-title">Speeches by year</h2>
</div>
<p class="speech-chart-summary" data-chart-summary>{speeches.length} speeches across {years.length} years</p>
</div>
<div
class="speech-year-chart"
data-year-chart
style={`--speech-year-columns: ${years.length}`}
role="group"
aria-label="Number of speeches in each year. Select a bar to filter the archive."
>
{
years.map((year, index) => {
const count = yearCounts.get(year) ?? 0;
const height = Math.max(3, Math.round((count / maxYearCount) * 100));
const showTick = index === 0 || index === years.length - 1 || Number.parseInt(year, 10) % 5 === 0;
return (
<button
class="speech-year-button"
type="button"
data-year={year}
data-chart-label={`${year}: ${count} ${count === 1 ? "speech" : "speeches"}`}
style={`--speech-bar-height: ${height}%`}
aria-label={`${year}: ${count} ${count === 1 ? "speech" : "speeches"}`}
aria-pressed="false"
>
<span class="speech-year-bar" aria-hidden="true"></span>
{showTick && <span class="speech-year-tick" aria-hidden="true">{year}</span>}
</button>
);
})
}
</div>
</section>
<div class="speech-explorer-layout">
<section class="speech-results-panel" aria-labelledby="speech-results-title">
<div class="speech-section-heading speech-results-heading">
<div>
<p class="speech-section-kicker">Browse</p>
<h2 id="speech-results-title">Archive results</h2>
</div>
<p class="speech-results-status" aria-live="polite" data-results-status>
Showing {initialResults.length} of {speeches.length}
</p>
</div> </div>
<div class="speech-results" id="speech-results"> <div class="speech-results" id="speech-results">
{ {
speeches.map((speech) => ( initialResults.map((speech, index) => (
<article class="speech-result"> <a
<div class="speech-result-meta"> class:list={["speech-result", { "is-selected": index === 0 }]}
<span>{speech.year}</span> href={speech.url}
data-speech-id={speech.id}
aria-current={index === 0 ? "true" : undefined}
>
<span class="speech-result-topline">
<span class="speech-result-year">{speech.year}</span>
<span>{speech.speaker}</span> <span>{speech.speaker}</span>
</div> </span>
<h2 class="speech-result-title"> <strong class="speech-result-title">{speech.title}</strong>
<a href={speech.url}>{speech.title}</a> <span class="speech-result-excerpt">{speech.excerpt}</span>
</h2> </a>
<p>{speech.excerpt}</p>
</article>
)) ))
} }
</div> </div>
<button class="speech-load-more" type="button" data-load-more>Show more speeches</button>
</section>
<aside class="speech-detail" aria-labelledby="speech-detail-label" data-speech-detail>
<p class="speech-section-kicker" id="speech-detail-label">Selected speech</p>
{
initialSpeech && (
<>
<p class="speech-detail-position" data-detail-position>1 of {speeches.length}</p>
<h2 data-detail-title>{initialSpeech.title}</h2>
<p class="speech-detail-meta" data-detail-meta>{initialSpeech.year} <span aria-hidden="true">&middot;</span> {initialSpeech.speaker}</p>
<p data-detail-excerpt>{initialSpeech.excerpt}</p>
<a class="speech-detail-link" href={initialSpeech.url} data-detail-link>Read the full speech <span aria-hidden="true">&rarr;</span></a>
<div class="speech-detail-nav" aria-label="Move through filtered speeches">
<button type="button" data-detail-previous disabled>Previous</button>
<button type="button" data-detail-next>Next</button>
</div>
</>
)
}
</aside>
</div>
<p class="speech-explorer-message" data-explorer-message aria-live="polite">Loading full-text search&hellip;</p>
</div> </div>
</div> </div>
</div> </div>
@ -78,69 +193,99 @@ const speakers = uniqueSorted(speeches.map((speech) => speech.speaker));
</div> </div>
</div> </div>
<script is:inline slot="scripts"> <script is:inline slot="scripts" define:vars={{ initialSpeechId }}>
(() => { (() => {
const explorer = document.querySelector("[data-speech-explorer]");
const form = document.getElementById("speech-filters"); const form = document.getElementById("speech-filters");
const results = document.getElementById("speech-results"); const results = document.getElementById("speech-results");
const count = document.getElementById("speech-result-count"); const resultsStatus = explorer?.querySelector("[data-results-status]");
const searchInput = document.getElementById("speech-search"); const searchInput = document.getElementById("speech-search");
const yearSelect = document.getElementById("speech-year"); const yearSelect = document.getElementById("speech-year");
const decadeSelect = document.getElementById("speech-decade");
const speakerSelect = document.getElementById("speech-speaker"); const speakerSelect = document.getElementById("speech-speaker");
const chart = explorer?.querySelector("[data-year-chart]");
const chartSummary = explorer?.querySelector("[data-chart-summary]");
const detail = explorer?.querySelector("[data-speech-detail]");
const detailPosition = detail?.querySelector("[data-detail-position]");
const detailTitle = detail?.querySelector("[data-detail-title]");
const detailMeta = detail?.querySelector("[data-detail-meta]");
const detailExcerpt = detail?.querySelector("[data-detail-excerpt]");
const detailLink = detail?.querySelector("[data-detail-link]");
const previousButton = detail?.querySelector("[data-detail-previous]");
const nextButton = detail?.querySelector("[data-detail-next]");
const loadMoreButton = explorer?.querySelector("[data-load-more]");
const message = explorer?.querySelector("[data-explorer-message]");
if (!form || !results || !count || !searchInput || !yearSelect || !speakerSelect) { if (
!explorer || !form || !results || !resultsStatus || !searchInput || !yearSelect ||
!decadeSelect || !speakerSelect || !chart || !chartSummary || !detail ||
!detailPosition || !detailTitle || !detailMeta || !detailExcerpt || !detailLink ||
!previousButton || !nextButton || !loadMoreButton || !message
) {
return; return;
} }
let speeches = []; let speeches = [];
let searchIndex = {}; let searchIndex = {};
let searchTerms = []; let searchTerms = [];
const termCache = new Map(); let filteredSpeeches = [];
let selectedId = initialSpeechId;
let visibleLimit = 18;
let renderTimer = 0; let renderTimer = 0;
const termCache = new Map();
function normalize(value) { function normalize(value) {
return value return String(value || "")
.normalize("NFKD") .normalize("NFKD")
.replace(/[\u0300-\u036f]/g, "") .replace(/[\u0300-\u036f]/g, "")
.toLowerCase() .toLowerCase()
.trim(); .trim();
} }
function speechDecade(speech) {
return `${Math.floor(Number.parseInt(speech.year, 10) / 10) * 10}`;
}
function selectedFilters() { function selectedFilters() {
return { return {
q: searchInput.value.trim(), q: searchInput.value.trim(),
year: yearSelect.value,
speaker: speakerSelect.value, speaker: speakerSelect.value,
decade: decadeSelect.value,
year: yearSelect.value,
}; };
} }
function syncUrl(filters) {
const params = new URLSearchParams();
Object.entries(filters).forEach(([key, value]) => {
if (value) {
params.set(key, value);
}
});
const nextUrl = params.toString() ? `${window.location.pathname}?${params}` : window.location.pathname;
window.history.replaceState(null, "", nextUrl);
}
function hydrateFromUrl() { function hydrateFromUrl() {
const params = new URLSearchParams(window.location.search); const params = new URLSearchParams(window.location.search);
searchInput.value = params.get("q") || ""; searchInput.value = params.get("q") || "";
yearSelect.value = params.get("year") || "";
speakerSelect.value = params.get("speaker") || ""; speakerSelect.value = params.get("speaker") || "";
decadeSelect.value = params.get("decade") || "";
yearSelect.value = params.get("year") || "";
selectedId = params.get("speech") || selectedId;
}
function syncUrl(filters) {
const params = new URLSearchParams();
Object.entries(filters).forEach(([key, value]) => {
if (value) params.set(key, value);
});
if (selectedId) params.set("speech", selectedId);
const nextUrl = params.toString() ? `${window.location.pathname}?${params}` : window.location.pathname;
window.history.replaceState(null, "", nextUrl);
} }
function decodeDocumentIds(value) { function decodeDocumentIds(value) {
return new Set(String(value || "").split(",").filter(Boolean).map((documentId) => Number.parseInt(documentId, 36))); return new Set(
String(value || "")
.split(",")
.filter(Boolean)
.map((documentId) => Number.parseInt(documentId, 36)),
);
} }
function unionSets(sets) { function unionSets(sets) {
const union = new Set(); const union = new Set();
sets.forEach((set) => { sets.forEach((set) => set.forEach((value) => union.add(value)));
set.forEach((value) => union.add(value));
});
return union; return union;
} }
@ -148,26 +293,17 @@ const speakers = uniqueSorted(speeches.map((speech) => speech.speaker));
const smaller = left.size <= right.size ? left : right; const smaller = left.size <= right.size ? left : right;
const larger = left.size <= right.size ? right : left; const larger = left.size <= right.size ? right : left;
const intersection = new Set(); const intersection = new Set();
smaller.forEach((value) => { smaller.forEach((value) => {
if (larger.has(value)) { if (larger.has(value)) intersection.add(value);
intersection.add(value);
}
}); });
return intersection; return intersection;
} }
function documentsForTerm(term) { function documentsForTerm(term) {
if (termCache.has(term)) { if (termCache.has(term)) return termCache.get(term);
return termCache.get(term);
}
const matches = []; const matches = [];
if (searchIndex[term]) matches.push(decodeDocumentIds(searchIndex[term]));
if (searchIndex[term]) {
matches.push(decodeDocumentIds(searchIndex[term]));
}
if (term.length >= 3) { if (term.length >= 3) {
searchTerms.forEach((indexedTerm) => { searchTerms.forEach((indexedTerm) => {
@ -184,75 +320,56 @@ const speakers = uniqueSorted(speeches.map((speech) => speech.speaker));
function searchCandidates(query) { function searchCandidates(query) {
const terms = normalize(query).match(/[a-z0-9]+/g)?.filter((term) => term.length >= 2) ?? []; const terms = normalize(query).match(/[a-z0-9]+/g)?.filter((term) => term.length >= 2) ?? [];
if (!terms.length) return null;
if (!terms.length) {
return null;
}
return terms.reduce((candidateIds, term) => { return terms.reduce((candidateIds, term) => {
const termIds = documentsForTerm(term); const termIds = documentsForTerm(term);
return candidateIds ? intersectSets(candidateIds, termIds) : termIds;
if (!candidateIds) {
return termIds;
}
return intersectSets(candidateIds, termIds);
}, null); }, null);
} }
function matchesSpeechMetadata(speech, filters) { function matchesMetadata(speech, filters) {
if (filters.year && speech.year !== filters.year) { if (filters.speaker && speech.speaker !== filters.speaker) return false;
return false; if (filters.decade && speechDecade(speech) !== filters.decade) return false;
}
if (filters.speaker && speech.speaker !== filters.speaker) {
return false;
}
return true; return true;
} }
function appendMeta(parent, values) { function buildResult(speech) {
values.filter(Boolean).forEach((value) => {
const span = document.createElement("span");
span.textContent = value;
parent.append(span);
});
}
function renderSpeech(speech) {
const article = document.createElement("article");
article.className = "speech-result";
const meta = document.createElement("div");
meta.className = "speech-result-meta";
appendMeta(meta, [speech.year, speech.speaker]);
const title = document.createElement("h2");
title.className = "speech-result-title";
const link = document.createElement("a"); const link = document.createElement("a");
link.className = "speech-result";
link.href = speech.url; link.href = speech.url;
link.textContent = speech.title; link.dataset.speechId = speech.id;
title.append(link); if (speech.id === selectedId) {
link.classList.add("is-selected");
link.setAttribute("aria-current", "true");
}
const excerpt = document.createElement("p"); const topline = document.createElement("span");
topline.className = "speech-result-topline";
const year = document.createElement("span");
year.className = "speech-result-year";
year.textContent = speech.year;
const speaker = document.createElement("span");
speaker.textContent = speech.speaker;
topline.append(year, speaker);
const title = document.createElement("strong");
title.className = "speech-result-title";
title.textContent = speech.title;
const excerpt = document.createElement("span");
excerpt.className = "speech-result-excerpt";
excerpt.textContent = speech.excerpt; excerpt.textContent = speech.excerpt;
link.append(topline, title, excerpt);
article.append(meta, title, excerpt); return link;
return article;
} }
function render() { function renderResults() {
const filters = selectedFilters(); const shown = filteredSpeeches.slice(0, visibleLimit);
const candidateIds = searchCandidates(filters.q);
const matched = speeches.filter((speech, index) => {
if (candidateIds && !candidateIds.has(index)) {
return false;
}
return matchesSpeechMetadata(speech, filters);
});
const fragment = document.createDocumentFragment(); const fragment = document.createDocumentFragment();
if (matched.length) { if (shown.length) {
matched.forEach((speech) => fragment.append(renderSpeech(speech))); shown.forEach((speech) => fragment.append(buildResult(speech)));
} else { } else {
const empty = document.createElement("p"); const empty = document.createElement("p");
empty.className = "speech-empty-state"; empty.className = "speech-empty-state";
@ -261,22 +378,144 @@ const speakers = uniqueSorted(speeches.map((speech) => speech.speaker));
} }
results.replaceChildren(fragment); results.replaceChildren(fragment);
count.textContent = matched.length.toString(); resultsStatus.textContent = filteredSpeeches.length
? `Showing ${shown.length} of ${filteredSpeeches.length}`
: "No results";
loadMoreButton.hidden = shown.length >= filteredSpeeches.length;
if (!loadMoreButton.hidden) {
const remaining = filteredSpeeches.length - shown.length;
loadMoreButton.textContent = `Show ${Math.min(18, remaining)} more`;
}
}
function renderDetail() {
const selectedIndex = filteredSpeeches.findIndex((speech) => speech.id === selectedId);
const speech = filteredSpeeches[selectedIndex];
if (!speech) {
detail.classList.add("is-empty");
detailPosition.textContent = "No selection";
detailTitle.textContent = "Choose a speech";
detailMeta.textContent = "";
detailExcerpt.textContent = "Select a result to see its details here.";
detailLink.hidden = true;
previousButton.disabled = true;
nextButton.disabled = true;
return;
}
detail.classList.remove("is-empty");
detailPosition.textContent = `${selectedIndex + 1} of ${filteredSpeeches.length}`;
detailTitle.textContent = speech.title;
detailMeta.textContent = `${speech.year} · ${speech.speaker}`;
detailExcerpt.textContent = speech.excerpt;
detailLink.href = speech.url;
detailLink.hidden = false;
previousButton.disabled = selectedIndex <= 0;
nextButton.disabled = selectedIndex >= filteredSpeeches.length - 1;
}
function renderChart(contextSpeeches, filters) {
const counts = new Map();
contextSpeeches.forEach((speech) => counts.set(speech.year, (counts.get(speech.year) || 0) + 1));
const chartYears = Array.from(new Set(speeches.map((speech) => speech.year)))
.filter((year) => !filters.decade || `${Math.floor(Number.parseInt(year, 10) / 10) * 10}` === filters.decade)
.sort();
const maxCount = Math.max(1, ...chartYears.map((year) => counts.get(year) || 0));
const fragment = document.createDocumentFragment();
chart.style.setProperty("--speech-year-columns", chartYears.length.toString());
chartYears.forEach((year, index) => {
const count = counts.get(year) || 0;
const height = count ? Math.max(3, Math.round((count / maxCount) * 100)) : 0;
const button = document.createElement("button");
button.type = "button";
button.className = "speech-year-button";
button.dataset.year = year;
button.dataset.chartLabel = `${year}: ${count} ${count === 1 ? "speech" : "speeches"}`;
button.style.setProperty("--speech-bar-height", `${height}%`);
button.setAttribute("aria-label", button.dataset.chartLabel);
button.setAttribute("aria-pressed", String(filters.year === year));
button.disabled = count === 0;
const bar = document.createElement("span");
bar.className = "speech-year-bar";
bar.setAttribute("aria-hidden", "true");
button.append(bar);
const showTick = index === 0 || index === chartYears.length - 1 || Number.parseInt(year, 10) % 5 === 0;
if (showTick) {
const tick = document.createElement("span");
tick.className = "speech-year-tick";
tick.setAttribute("aria-hidden", "true");
tick.textContent = year;
button.append(tick);
}
fragment.append(button);
});
chart.replaceChildren(fragment);
if (filters.year) {
const count = counts.get(filters.year) || 0;
chartSummary.textContent = `${count} ${count === 1 ? "speech" : "speeches"} in ${filters.year}`;
} else {
chartSummary.textContent = `${contextSpeeches.length} ${contextSpeeches.length === 1 ? "speech" : "speeches"} across ${chartYears.length} years`;
}
}
function render(options = {}) {
const filters = selectedFilters();
const normalizedQuery = normalize(filters.q);
const candidateIds = filters.q ? searchCandidates(filters.q) : null;
const contextSpeeches = speeches.filter((speech, index) => {
if (candidateIds && !candidateIds.has(index)) return false;
if (filters.q && !candidateIds && !normalize(`${speech.title} ${speech.excerpt}`).includes(normalizedQuery)) return false;
return matchesMetadata(speech, filters);
});
filteredSpeeches = filters.year
? contextSpeeches.filter((speech) => speech.year === filters.year)
: contextSpeeches;
if (!filteredSpeeches.some((speech) => speech.id === selectedId)) {
selectedId = filteredSpeeches[0]?.id || "";
}
renderChart(contextSpeeches, filters);
renderResults();
renderDetail();
syncUrl(filters); syncUrl(filters);
if (options.focusSelected) {
results.querySelector(`[data-speech-id="${CSS.escape(selectedId)}"]`)?.focus();
}
} }
function queueRender() { function queueRender() {
window.clearTimeout(renderTimer); window.clearTimeout(renderTimer);
visibleLimit = 18;
selectedId = "";
renderTimer = window.setTimeout(render, 120); renderTimer = window.setTimeout(render, 120);
} }
function selectByOffset(offset) {
const currentIndex = filteredSpeeches.findIndex((speech) => speech.id === selectedId);
const nextIndex = Math.max(0, Math.min(filteredSpeeches.length - 1, currentIndex + offset));
const nextSpeech = filteredSpeeches[nextIndex];
if (!nextSpeech) return;
selectedId = nextSpeech.id;
if (nextIndex >= visibleLimit) visibleLimit = nextIndex + 1;
renderResults();
renderDetail();
syncUrl(selectedFilters());
}
hydrateFromUrl(); hydrateFromUrl();
fetch("/speeches/search-index.json") fetch("/speeches/search-index.json")
.then((response) => { .then((response) => {
if (!response.ok) { if (!response.ok) throw new Error(`Speech index request failed: ${response.status}`);
throw new Error(`Speech index request failed: ${response.status}`);
}
return response.json(); return response.json();
}) })
.then((data) => { .then((data) => {
@ -284,15 +523,69 @@ const speakers = uniqueSorted(speeches.map((speech) => speech.speaker));
searchIndex = Array.isArray(data) ? {} : data.index ?? {}; searchIndex = Array.isArray(data) ? {} : data.index ?? {};
searchTerms = Object.keys(searchIndex); searchTerms = Object.keys(searchIndex);
termCache.clear(); termCache.clear();
explorer.classList.add("is-ready");
message.textContent = "Full-text search ready.";
render(); render();
form.addEventListener("input", queueRender); form.addEventListener("input", queueRender);
form.addEventListener("change", render); form.addEventListener("change", (event) => {
form.addEventListener("reset", () => { if (event.target === yearSelect && yearSelect.value) {
window.setTimeout(render, 0); decadeSelect.value = speechDecade({ year: yearSelect.value });
}
if (event.target === decadeSelect && yearSelect.value && speechDecade({ year: yearSelect.value }) !== decadeSelect.value) {
yearSelect.value = "";
}
visibleLimit = 18;
selectedId = "";
render();
}); });
form.addEventListener("submit", (event) => {
event.preventDefault();
visibleLimit = 18;
selectedId = "";
render();
});
form.addEventListener("reset", () => {
window.setTimeout(() => {
visibleLimit = 18;
selectedId = "";
render();
searchInput.focus();
}, 0);
});
chart.addEventListener("click", (event) => {
const button = event.target.closest("[data-year]");
if (!button || button.disabled) return;
const year = button.dataset.year;
yearSelect.value = yearSelect.value === year ? "" : year;
if (yearSelect.value) decadeSelect.value = speechDecade({ year });
visibleLimit = 18;
selectedId = "";
render();
});
results.addEventListener("click", (event) => {
const link = event.target.closest("[data-speech-id]");
if (!link || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;
event.preventDefault();
selectedId = link.dataset.speechId;
renderResults();
renderDetail();
syncUrl(selectedFilters());
});
loadMoreButton.addEventListener("click", () => {
visibleLimit += 18;
renderResults();
});
previousButton.addEventListener("click", () => selectByOffset(-1));
nextButton.addEventListener("click", () => selectByOffset(1));
}) })
.catch(() => { .catch(() => {
count.textContent = results.querySelectorAll(".speech-result").length.toString(); message.textContent = "Full-text search is unavailable. The latest archive links are still available below.";
message.classList.add("is-error");
loadMoreButton.hidden = true;
}); });
})(); })();
</script> </script>