Skip to content
This repository has been archived by the owner on Jul 21, 2019. It is now read-only.

Commit

Permalink
Merge pull request #166 from devopsdays/event-page
Browse files Browse the repository at this point in the history
Event page
  • Loading branch information
bridgetkromhout authored Feb 2, 2017
2 parents 87db522 + 424413c commit 1544e9c
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 2 deletions.
2 changes: 1 addition & 1 deletion exampleSite/content/page/events.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
+++
date = "2015-11-29T00:00:00-06:00"
title = "devopsdays events"
type = "events-list"
type = "events"
aliases = ["/calendar", "/events/calendar", "/devops-calendar", "/presentations"]

+++
Expand Down
2 changes: 1 addition & 1 deletion layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
{{- block "main" . }} {{- end -}}
</div>
<div class="col-md-2 pull-md-8">
<a href = "/past" class="left-nav-navs">PAST EVENTS</a><br />
<a href = "/events" class="left-nav-navs">PAST EVENTS</a><br />
{{- partial "future.html" . -}}
</div>
{{ end }}
Expand Down
16 changes: 16 additions & 0 deletions layouts/events/single.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{ define "main" }}

{{/* site data query copypasta */}}
{{ $path := split $.Source.File.Path .Site.Params.pathseperator }}
{{ $event_slug := index $path 1 }}
{{ $e := (index $.Site.Data.events $event_slug) }}
{{/* end site data query */}}

<div>
{{ .Content }}
</div>

{{ partial "future.html" . }}
{{ partial "past.html" . }}

{{ end }}
1 change: 1 addition & 0 deletions layouts/partials/future.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
{{- if ne ($.Scratch.Get "month") (dateFormat "January" .startdate ) -}}
{{- $.Scratch.Set "month" (dateFormat "January" .startdate ) -}}
{{- $.Scratch.Set "month-displayed" "false" -}}
<br />
{{- end -}}
{{- if ne ($.Scratch.Get "year-displayed") "true" -}}
<h3 class="left-nav-year">{{ dateFormat "2006" .startdate }}</h3>
Expand Down
43 changes: 43 additions & 0 deletions layouts/partials/past.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!-- The following blocks of comments explains how this list is generated with Hugo.
If you read this post generation, it will make no sense. see pre generated sources -->

<!-- Scan through a range of years and look in data/events for events during these years.
If found, store year in "active_years" scratch in order to get back to that year later.
Also save the event name under scratch with the ID of the scratch equal to the year number.
Chomping .year has the nice effect of turning an int into string. -->
{{ range seq 2009 2020 }}
{{ $r_year := . }}
{{ range $.Site.Data.events }}
{{ if .startdate }}
{{ $my_year := string ((dateFormat "2006" .startdate ))}}
{{ if and (eq $my_year (string $r_year)) ( lt (dateFormat "2006-01-02" .startdate) (dateFormat "2006-01-02" ($.Now.Format "2006-01-02"))) }}
{{ $.Scratch.SetInMap "active_years" (print (chomp $my_year)) (print (chomp $my_year)) }}
{{ $.Scratch.SetInMap (print (chomp $my_year)) .startdate (.name) }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}

<div class = "row">
<div class = "col-md-12">
<h2>Past</h2>
</div>
</div>
<div class = "row">
<!-- Now scan through all the years that were marked as active in order to print the headline -->
{{ range ($.Scratch.GetSortedMapValues "active_years") }}
<div class = "col-md-4">
<strong>{{ . }}</strong>
<br/>
<!-- Finally, scan throug the scratch with the ID of that year and print all the events sorted by startdate
Chomping here in order to convert int to string -->
{{ range ($.Scratch.GetSortedMapValues (print (chomp .))) }}
{{ $.Scratch.Set "citydisplay" (index $.Site.Data.events . "city") }}
{{ $friendly := (index $.Site.Data.events . "name") }}
<a href="/events/{{ $friendly }}/">{{ $.Scratch.Get "citydisplay" }}</a>
<br/>
{{ end }}
</div>
{{ end }}
</div>

0 comments on commit 1544e9c

Please sign in to comment.