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

Event page #166

Merged
merged 3 commits into from
Feb 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -15,7 +15,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>
</div>
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 />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd sorta rather do this with CSS; we can do some padding on the element itself rather than a `
tag, but it's not the end of the world.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair. I was following the usage already present in this partial, but I don't think it's perfect. It's just less annoying than it was.

{{- 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>