|
1 | 1 | <!--Get all the publications on the page--> |
2 | 2 | {% assign publications = site.publications | sort: 'date' | reverse %} |
3 | 3 |
|
| 4 | +{%- comment -%} |
| 5 | +Build filter option lists (venue, year, topic) from the publications collection. |
| 6 | +{%- endcomment -%} |
| 7 | + |
| 8 | +{%- assign venues = site.publications | map: 'venue' | uniq | sort -%} |
| 9 | + |
| 10 | +{%- assign years_string = '' -%} |
| 11 | +{%- assign topics_string = '' -%} |
| 12 | +{%- for publication in site.publications -%} |
| 13 | + {%- assign pub_year = publication.date | date: '%Y' -%} |
| 14 | + {%- unless years_string contains pub_year -%} |
| 15 | + {%- assign years_string = years_string | append: pub_year | append: '|' -%} |
| 16 | + {%- endunless -%} |
| 17 | + |
| 18 | + {%- if publication.topics -%} |
| 19 | + {%- for topic in publication.topics -%} |
| 20 | + {%- unless topics_string contains topic -%} |
| 21 | + {%- assign topics_string = topics_string | append: topic | append: '|' -%} |
| 22 | + {%- endunless -%} |
| 23 | + {%- endfor -%} |
| 24 | + {%- endif -%} |
| 25 | +{%- endfor -%} |
| 26 | + |
| 27 | +{%- assign years = years_string | split: '|' | sort | reverse -%} |
| 28 | +{%- assign topics = topics_string | split: '|' | sort -%} |
| 29 | + |
| 30 | +<!--Filters--> |
| 31 | +<div class="publications__filters"> |
| 32 | + <div class="publications__filters-group"> |
| 33 | + <label for="pub-filter-topic">Topic</label> |
| 34 | + <select id="pub-filter-topic" class="publications__filter-select"> |
| 35 | + <option value="">All topics</option> |
| 36 | + {%- for topic in topics -%} |
| 37 | + {%- if topic and topic != '' -%} |
| 38 | + <option value="{{ topic }}">{{ topic }}</option> |
| 39 | + {%- endif -%} |
| 40 | + {%- endfor -%} |
| 41 | + </select> |
| 42 | + </div> |
| 43 | + |
| 44 | + <div class="publications__filters-group"> |
| 45 | + <label for="pub-filter-year">Year</label> |
| 46 | + <select id="pub-filter-year" class="publications__filter-select"> |
| 47 | + <option value="">All years</option> |
| 48 | + {%- for year in years -%} |
| 49 | + {%- if year and year != '' -%} |
| 50 | + <option value="{{ year }}">{{ year }}</option> |
| 51 | + {%- endif -%} |
| 52 | + {%- endfor -%} |
| 53 | + </select> |
| 54 | + </div> |
| 55 | + |
| 56 | + <div class="publications__filters-group"> |
| 57 | + <label for="pub-filter-venue">Venue</label> |
| 58 | + <select id="pub-filter-venue" class="publications__filter-select"> |
| 59 | + <option value="">All venues</option> |
| 60 | + {%- for venue_key in venues -%} |
| 61 | + {%- if venue_key and venue_key != '' -%} |
| 62 | + <option value="{{ venue_key }}">{{ venue_key }}</option> |
| 63 | + {%- endif -%} |
| 64 | + {%- endfor -%} |
| 65 | + </select> |
| 66 | + </div> |
| 67 | +</div> |
| 68 | + |
4 | 69 | <!--List all publications--> |
5 | | -<ul class="publications__list"> |
| 70 | +<ul class="publications__list" id="publications-list"> |
6 | 71 | {% for publication in publications %} |
7 | | - <li> |
| 72 | + <li |
| 73 | + class="publications__item" |
| 74 | + data-venue="{{ publication.venue }}" |
| 75 | + data-year="{{ publication.date | date: '%Y' }}" |
| 76 | + data-topics="{% if publication.topics %}{{ publication.topics | join: ',' }}{% endif %}" |
| 77 | + > |
8 | 78 | <a class="pub-title" href="{{ publication.url | relative_url }}">{{ publication.title }}</a> |
9 | 79 | <br> |
10 | 80 | <span class="pub-authors"> |
|
25 | 95 | {% endif %} |
26 | 96 | {% endfor %} |
27 | 97 | </span> |
| 98 | + {% if publication.topics %} |
| 99 | + <br> |
| 100 | + <span class="pub-topics"> |
| 101 | + {{ publication.topics | join: ', ' }} |
| 102 | + </span> |
| 103 | + {% endif %} |
28 | 104 | <br> |
29 | 105 | <span class="pub-venue"> |
30 | 106 | {% assign venue = site.data.venues[publication.venue] %} |
31 | | - {{ venue.name }} |
| 107 | + {% if venue %} |
| 108 | + {{ venue.name }} |
| 109 | + {% else %} |
| 110 | + {{ publication.venue }} |
| 111 | + {% endif %} |
32 | 112 | </span> |
33 | 113 | </li> |
34 | 114 | {% endfor %} |
|
0 commit comments