Skip to content

Commit

Permalink
Refactor past and future to use date fields (devopsdays#885)
Browse files Browse the repository at this point in the history
* Refactor past and future to use date fields

Do not merge this yet - the /events page is displaying oddly,and it’s somehow due to the two New Yorks. If you change the startdate of New York (Winter) to be in 2012, everything lays out properly.

* Make tiny comment change to trigger deploy preview

* Change to three columns from four

For some dumb reason, this works, and it’s Probably Fine.
  • Loading branch information
mattstratton authored Aug 20, 2016
1 parent 1fcd2bb commit 7d37b73
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
3 changes: 2 additions & 1 deletion data/events/2012-newyork.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: "2012-newyork" # The name of the event. Four digit year with the city name in lower-case, with no spaces.
year: 2012 # The year of the event. Make sure it is in quotes.
year: 2013 # The year of the event. Make sure it is in quotes.
city: "New York" # The city name of the event. Capitalize it.
displayname: "New York (Winter)"
friendly: "2012-newyork" # Four digit year and the city name in lower-case. Don't forget the dash!
status: "past" # Options are "past" or "current". Use "current" for upcoming.

Expand Down
4 changes: 2 additions & 2 deletions data/events/2013-newyork.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: "2013-newyork" # The name of the event. Four digit year with the city name in lower-case, with no spaces.
year: 2013 # The year of the event. Make sure it is in quotes.
city: "New York" # The city name of the event. Capitalize it.
displayname: "New York (Fall)"
friendly: "2013-newyork" # Four digit year and the city name in lower-case. Don't forget the dash!
status: "past" # Options are "past" or "current". Use "current" for upcoming.
status: "past" # Options are "past" or "current". Use "current" for upcoming

# All dates are in unquoted 2013-MM-DD, like this: variable: 2016-01-05
startdate: 2013-10-17
Expand All @@ -27,4 +28,3 @@ nav_elements: # List of pages you want to show up in the navigation of your page
- name: sponsor
- name: contact
- name: conduct

6 changes: 3 additions & 3 deletions themes/devopsdays-responsive/layouts/partials/future.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ <h1>Future</h1>
<div style="margin:1px;">
<strong>2016 - 2017</strong><br/>
{{ range sort $.Site.Data.events "startdate" }}
{{ if and ( eq .status "current") ( .startdate ) }}
{{ if and ( .startdate ) ( ge (dateFormat "2006-01-02" .startdate) (dateFormat "2006-01-02" ($.Now.Format "2006-01-02")) ) }}
<a href = "/events/{{ .name }}/welcome">
{{ if .displayname }}
{{ .displayname }}
{{ else }}
{{ .city }}
{{ end }}
{{ dateFormat "Jan 2" .startdate }}
{{ dateFormat "Jan 2, 2006" .startdate }}
-
{{ dateFormat "Jan 2" .enddate }}
{{ dateFormat "Jan 2, 2006" .enddate }}
</a><br />
{{ end }}
{{ end }}
Expand Down
11 changes: 6 additions & 5 deletions themes/devopsdays-responsive/layouts/partials/past.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- The following blocks of comments explains how this list is generated with Hugo.
<!-- 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.
Expand All @@ -9,9 +9,10 @@
{{ range seq 2009 2020 }}
{{ $r_year := . }}
{{ range $.Site.Data.events }}
{{ if and (eq .year $r_year) (eq .status "past") }}
{{ $.Scratch.SetInMap "active_years" (print (chomp .year)) (print (chomp .year)) }}
{{ $.Scratch.SetInMap (print (chomp .year)) .startdate (.name) }}
{{ $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 }}
Expand All @@ -24,7 +25,7 @@ <h2>Past</h2>
<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-3">
<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
Expand Down

0 comments on commit 7d37b73

Please sign in to comment.