-
Notifications
You must be signed in to change notification settings - Fork 2
/
winners.html
63 lines (53 loc) · 2.02 KB
/
winners.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
---
layout: default
---
<div class="home">
<h1 class="page-heading">Prize Crossword Winners</h1>
<h2>listed by date</h2>
<ul class="post-list">
{% for post in site.posts %}
{% if post.winners %}
<li>
<span class="post-meta" style="font-family: monospace;">{{ post.date | date: "%a, %d %b %Y" }}</span> <a class="post-link" href="{{ post.url | prepend: site.github.url }}">{{ post.title | escape }}</a>
<br> - won by {{ post.winners | join: '; ' }}.
</li>
{% endif %}
{% endfor %}
</ul>
<h2>listed by winner</h2>
<!--
Nicely inefficient way to create list of crosswords won by each winner.
Because not much ability to create and manipulate hashes in Liquid,
have to do multiple scans of the posts:
- loop over all posts to construct a list of all winners
- calc the list of uniq winners (sorted by first initial)
- for each winner, loop over all posts, looking for the one(s) they won: o(n^2) FTW !
-->
{% assign winners_list = "" | split:"," %}
{% for post in site.posts %}
{% if post.winners %}
{% for winner in post.winners %}
{% assign winners_list = winners_list | push: winner %}
{% endfor %}
{% endif %}
{% endfor %}
{% assign winners_uniq = winners_list | sort | uniq %}
{% for winner in winners_uniq %}
<h3>{{ winner }}</h3>
<ul>
{% for post in site.posts %}
{% if post.winners %}
{% for post_winner in post.winners %}
{% assign post_winner_with_semicolon = post_winner | append: ';' %}
{% assign winner_with_semicolon = winner | append: ';' %}
{% if post_winner_with_semicolon contains winner_with_semicolon %}
<li>
<span class="post-meta" style="font-family: monospace;">{{ post.date | date: "%a, %d %b %Y" }}</span> <a class="post-link" href="{{ post.url | prepend: site.github.url }}">{{ post.title | escape }}</a>
</li>
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
</ul>
{% endfor %}
</div>