Subject Librarians
{% comment %} This is a strange document, all because jekyll doesn’t support associative arrays. Here’s what’s happening:
- for each staff member with liaison responsibilities, get a list of their departments
- for each department, generate a line with the department and their name/link
- but sometimes a department has more than one liaison, so:
- if the department has already been used, create a new entry adding a second liaison to the first string
- and then, make a note to suppress the lines with just one entry for that department
- finally, loop through the list of lines generated; only print the line if it’s not in the list of suppressed lines {% endcomment %}
Librarians by Subject Area
{% assign staff-list = site.data.staff-members | sort: ‘last-name’ %} {% assign all_subjects = ” | split: ’,’ %} {% assign all_liaisons = ” | split: ’,’ %} {% assign suppress = ” | split: ’,’ %} {% assign today = “now” | date: “%Y-%m-%d” %} {% for staff in staff-list %} {% if staff.liaison %} {% if staff.start-date <= today or staff.start-date == nil %} {% if staff.last-date >= today or staff.last-date == nil %} {% assign liaisons = staff.liaison | split: ’; ’ %} {% for subject in liaisons %} {% if staff.libguides-id %} {% capture link %}https://libguides.lib.miamioh.edu/prf.php?account_id={{ staff.libguides-id }}{% endcapture %} {% else %} {% capture link %}/about/organization/staff/?subject={{ subject | slugify }}{% endcapture %} {% endif %} {% capture liaison_link %}{{ staff.first-name }} {{ staff.last-name }}{% endcapture %} {% capture liaison_string %}{{subject}}: {{liaison_link}}{% endcapture %}
{% comment %}
Loop through subjects and see if there's already an entry for this subject in the liaisons array
If so, append instead of creating it new
The XXX is a hack to make sure we're not just matching substrings like "American Studies" and "Latin American Studies"
{% endcomment %}
{% for known_subject in all_liaisons %}
{% capture strcmp %}XXX{{subject}}:{% endcapture %}
{% capture subjcmp %}XXX{{known_subject}}{% endcapture %}
{% if subjcmp contains strcmp %}
{% unless known_subject contains liaison_link %}
{% capture update %}{{ all_liaisons[forloop.index0] }}, {{liaison_link}}{% endcapture %}
{% assign all_liaisons = all_liaisons | push: update %}
{% assign suppress = suppress | push: all_liaisons[forloop.index0] %}
{% assign suppress = suppress | push: liaison_string %}
{% break %}
{% endunless %}
{% endif %}
{% endfor %}
{% assign all_subjects = all_subjects | push: subject %}
{% assign all_liaisons = all_liaisons | push: liaison_string %}
{% endfor %}
{% endif %}
{% endif %}
{% endif %} {% endfor %}
{% assign all_liaisons = all_liaisons | sort %}
-
{% for lia in all_liaisons %}
{% assign suppressed = false %}
{% for hidden in suppress %}
{% if hidden == lia %}
{% assign suppressed = true %}
{% endif %}
{% endfor %}
{% if suppressed == false %}
- {{lia}} {% endif %} {% endfor %}
