Skip to content

Commit

Permalink
Improve handling of future and past on index page
Browse files Browse the repository at this point in the history
We basically split the list of posts into 3 parts:

- the next meetup
- meetups _after_ the next one
- meetups in the past

This is necessary to allow having more than one meetup planned and on
the website (cf. #14).

It also makes use of some newer Jekyll filters which make the code much
more functionally-flavored and readable.

I also change the "Help us [plan the next meetup]" link to point to
Github issues (instead of being a mailto link).
  • Loading branch information
killercup committed Nov 5, 2016
1 parent ef2c433 commit 11108c6
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 41 deletions.
24 changes: 13 additions & 11 deletions _sass/_prev-meetup.scss
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
.featured-impressions,
.prev-meetup {
.future-meetups,
.prev-meetup,
.featured-impressions {
margin-top: $spacing-large;
border-top: 1px solid $color-lo;
padding-top: $spacing-large;
padding-bottom: $spacing-large;
}

.prev-meetup-byline {
font-style: italic;
}
.future-meetups,
.prev-meetup {
.byline {
font-style: italic;
}

.prev-meetup .event-title {
margin-top: 0;
font-size: 1em;
margin-bottom: $spacing;
}
.event-title {
margin-top: 0;
font-size: 1em;
}
}
65 changes: 35 additions & 30 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,51 @@
layout: default
header-variant: start-page
---
{% assign curDate = site.time %}
{% assign next_meetups = site.posts | where_exp: "item", "item.date > curDate" | sort: "date" %}
{% assign past_meetups = site.posts | where_exp: "item", "item.date <= curDate" | sort: "date" %}
{% assign next_meetup = next_meetups | first %}
{% assign prev_meetup = past_meetups | last %}
{% assign further_down_the_line = next_meetups | shift %}

<div class="page-home" role="main">
<section class="next-meetup">
{% comment %}
Find the next meetup in the future
{% endcomment %}
{% assign curDate = site.time | date: '%s' %}
{% for post in site.posts %}
{% assign postStartDate = post.date | date: '%s' %}
{% if postStartDate >= curDate %}
{% assign current = post %}
{% break %}
{% endif %}
{% endfor %}
{% if current %}
<p class="next-meetup-byline">Next Meetup:</p>
<article class="event is-current">
{% if current.talks != false %}
{% include event.html event=current skip_date=true call_for_talks=true %}
{% if next_meetup %}
<p class="next-meetup-byline">Next meetup:</p>
<article class="event is-next-meetup">
{% if next_meetup.talks != false %}
{% include event.html event=next_meetup skip_date=true call_for_talks=true %}
{% else %}
{% include event.html event=current skip_date=true call_for_talks=false %}
{% include event.html event=next_meetup skip_date=true call_for_talks=false %}
{% endif %}
</article>
{% else %}
<h1>We are currently planning our next meetup</h1>
<p><a href="mailto:{{site.email}}?subject={{ "Next Rust Meetup" | uri_escape }}">Help us!</a></p>
{% endif %}
{% else %}
<h1>
We are currently planning our next meetup
</h1>
<p>
<a href="https://github.com/Rustaceans/rust-cologne/issues">
Help us!
</a>
</p>
{% endif %}
</section>

{% if current %}
{% assign older = site.posts | shift %}
{% else %}
{% assign older = site.posts %}
{% endif %}
{% if further_down_the_line.size > 0 %}
<section class="future-meetups">
<p class="byline">More future meetups:</p>
{% for event in further_down_the_line %}
{% include event-inline.html event=event %}
{% endfor %}
</section>
{% endif %}

{% if older.size > 0 %}
{% if prev_meetup %}
<section class="prev-meetup">
<p class="prev-meetup-byline">Previous Meetup:</p>
{% include event-inline.html event=older.first %}
<p class="byline">Previous meetup:</p>
{% include event-inline.html event=prev_meetup %}
</section>
{% endif %}
{% endif %}

<section class="featured-impressions">
<h2>Featured Impressions</h2>
Expand Down

0 comments on commit 11108c6

Please sign in to comment.