File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -390,6 +390,28 @@ func (t *Templ) FuncClosures(db *sql.DB) *template.FuncMap { //nolint:funlen
390390 dir .Directory (t .Environment .AbsPreview ),
391391 dir .Directory (t .Environment .AbsThumbnail ))
392392 },
393+ "yearRange" : func (start , end int ) []int {
394+ const epoch = 1980
395+ if start < epoch {
396+ start = epoch
397+ }
398+ now := time .Now ().Year ()
399+ if end > now {
400+ end = now
401+ }
402+
403+ // we don't want to include start or end range years in the results
404+ start ++
405+ years := make ([]int , end - start )
406+
407+ for i := range years {
408+ years [i ] = start + i
409+ }
410+ return years
411+ },
412+ "sub" : func (start , end int ) int {
413+ return end - start
414+ },
393415 }
394416}
395417
Original file line number Diff line number Diff line change 11{{- define " timeline" }}
22{{- $year := . }}
33{{- $eraClass := " text-start text-secondary mx-5 mb-4" }}
4- <h3 class= " text-end display-6 mt-3 p-3" >{{$year }}</h3>
5- {{- if eq $year 1981 }}
4+ {{- $skipped := or (eq $year 1999) (gt $year 2004) }}
5+ {{- if $skipped }}
6+ <!-- display nothing --->
7+ {{- else if eq $year 1981 }}
68 <div class= " {{$eraClass}}" >
79 <small><em class= " text-primary" >Pre Scene</em>.
810 The first IBM PC was released on 12 August 1981.
Original file line number Diff line number Diff line change 2222 {{- $initialism := initialisms $rel .Unique.URI }}
2323 {{- $year := $rel .Unique.Year.Int }}
2424 {{- $displayYear := or (eq $prevYear 0) (gt $year $prevYear )}}
25- {{- /* conditionals must always begin after these vars */ -}}
25+ {{- $difference := sub $prevYear $year }}
26+ {{- /* conditionals must always begin after these vars */ -}}
2627 {{- if $displayYear }}
2728 <!-- this case will only match years that exist in the fetched records -->
2829 {{- if ne $index 0}}</div><!-- this is the closing element -->{{ end }}
29- {{ template " timeline" $year }}
30+ {{- if gt $difference 1 }}
31+ <!-- we iterate through any missing years -->
32+ {{- range yearRange $prevYear $year }}
33+ <h3 class= " text-end fw-light fs-4 mt-3 me-3" >{{. }}</h3>
34+ {{- template " timeline" . }}
35+ {{- end }}
36+ {{- end }}
37+ <!-- but also display timelines of the years with artifact records -->
38+ <h3 class= " text-end display-6 mt-3 p-3" >{{$year }}</h3>
39+ {{- template " timeline" $year }}
3040 <div class= " {{$class}}" ><!-- this is the opening element -->
3141 {{- end }}
3242 <div class= " col" >
You can’t perform that action at this time.
0 commit comments