Commit a0133ba0 authored by Jurgen Gaeremyn's avatar Jurgen Gaeremyn
Browse files

Show the next three dates of each regular series in the Agenda

Code written with LLM support.
parent ea2caa3f
Loading
Loading
Loading
Loading
Loading
+1 −1
Changes for README.md: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@ This site is built using the [Hugo static site generator](https://gohugo.io/).

### Regular series in the Agenda

The Agenda in the sidebar, and on phones in the home page itself, shows each regular series on one line, with its rhythm and its next date, and lists the other events separately, so one-off events stay visible. A series is regular when the `_index.md` of its folder has a `recurrence:` line, for example `recurrence: "open evening for everyone, every Tuesday, 19:00"` in `content/events/techtuesday/_index.md`. That text appears next to the series name. To cancel one date of a series, add `cancelled: true` to that event: it then appears with the other events, and the series line points to the next date that still takes place. The events page and the calendar file always list every date.
The Agenda in the sidebar, and on phones in the home page itself, shows each regular series with its rhythm and at most its next three dates, and lists the other events separately, so one-off events stay visible. A series is regular when the `_index.md` of its folder has a `recurrence:` line, for example `recurrence: "open evening for everyone, every Tuesday, 19:00"` in `content/events/techtuesday/_index.md`. That text appears next to the series name. To cancel one date of a series, add `cancelled: true` to that event: it then appears with the other events, and the series shows the next three dates that still take place. The events page and the calendar file always list every date.

### Adding a Project

+13 −4
Changes for e2e/structure.spec.ts: 13 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -165,7 +165,7 @@ for (const { path, headings } of [
  { path: "/", headings: ".home-agenda h3" },
  { path: "/contact/", headings: "#last-events h4" },
]) {
  test(`lists each regular series once in the Agenda on ${path}, apart from one-off events`, async ({
  test(`lists at most the next three dates of each regular series in the Agenda on ${path}, apart from one-off events`, async ({
    page,
  }) => {
    await page.goto(path);
@@ -176,15 +176,24 @@ for (const { path, headings } of [
        );
        const items = title?.nextElementSibling?.querySelectorAll("a") ?? [];
        return [...items].map((link) => ({
          series: new URL(link.href).pathname.split("/")[2],
          path: new URL(link.href).pathname,
          series: new URL(link.href).pathname.split("/")[2] ?? "",
          text: link.textContent?.replace(/\s+/g, " ").trim() ?? "",
        }));
      };
      return { regular: list("Regular"), upcoming: list("Upcoming events") };
    }, headings);
    const regularSeries = agenda.regular.map((item) => item.series);
    const datesPerSeries = new Map<string, Set<string>>();
    for (const item of agenda.regular) {
      const dates = datesPerSeries.get(item.series) ?? new Set();
      datesPerSeries.set(item.series, dates.add(item.path));
    }
    const regularSeries = [...datesPerSeries.keys()];
    expect(regularSeries.length).toBeGreaterThan(0);
    expect(new Set(regularSeries).size).toBe(regularSeries.length);
    for (const dates of datesPerSeries.values()) {
      expect(dates.size).toBeLessThanOrEqual(3);
    }
    expect(datesPerSeries.get("techtuesday")?.size).toBe(3);
    expect(agenda.upcoming.length).toBeLessThanOrEqual(8);
    expect(
      agenda.upcoming.filter(
+7 −5
Changes for layouts/partials/agenda-data.html: 7 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -5,15 +5,17 @@
  {{- range .Sections -}}
    {{- $recurrence := .Params.recurrence -}}
    {{- if $recurrence -}}
      {{- $label := printf "%s, %s" (.Params.series | default .Title) $recurrence -}}
      {{- $next := false -}}
      {{- $name := .Params.series | default .Title -}}
      {{- $label := printf "%s, %s" $name $recurrence -}}
      {{- $next := slice -}}
      {{- range .RegularPages.ByParam "startdate" -}}
        {{- if and (not $next) (not .Params.cancelled) (isset .Params "startdate") (ge .Params.startdate $today) -}}
          {{- $next = . -}}
        {{- if and (lt (len $next) 3) (not .Params.cancelled) (isset .Params "startdate") (ge .Params.startdate $today) -}}
          {{- $next = $next | append . -}}
        {{- end -}}
      {{- end -}}
      {{- with $next -}}
        {{- $regular = $regular | append (dict "date" .Params.startdate "page" . "label" $label) -}}
        {{- $first := index . 0 -}}
        {{- $regular = $regular | append (dict "date" $first.Params.startdate "page" $first "pages" . "name" $name "label" $label) -}}
      {{- end -}}
    {{- end -}}
  {{- end -}}
+3 −3
Changes for layouts/partials/agenda.html: 3 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -2,9 +2,9 @@
{{- with $agenda.regular }}
<h4>Regular</h4>
<ul>
  {{- range . }}
  {{ partial "agenda-row.html" . }}
  {{- end }}
  {{- range . }} {{- $series := . }} {{- range $i, $page := .pages }}
  {{ partial "agenda-row.html" (dict "page" $page "label" (cond (eq $i 0) $series.label $series.name)) }}
  {{- end }} {{- end }}
</ul>
{{- end }}
{{- with $agenda.upcoming }}
+4 −2
Changes for layouts/partials/home-agenda.html: 4 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -6,8 +6,10 @@
  <ul>
    {{- range . }}
    <li>
      <a href="{{ .page.RelPermalink }}">{{ .label }}</a>, next on {{
      .page.Params.startdate | dateFormat "Mon 2 Jan" }}
      <a href="{{ .page.RelPermalink }}">{{ .label }}</a>, next on {{ range $i,
      $page := .pages }}{{ if $i }}, {{ end }}<a href="{{ $page.RelPermalink }}"
        >{{ $page.Params.startdate | dateFormat "Mon 2 Jan" }}</a
      >{{ end }}
    </li>
    {{- end }}
  </ul>