Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ Styles live in `assets/css/doors/`, with colours and type defined once in `token

Every repeated device has to earn its place. In practice:

- Pills and chips are for controls: filters, toggles, language switches. A list of links, such as related glossary terms, is a plain list. One exception: an item may carry one quiet tag for a category that visitors filter by on the same page, such as a resource's purpose.
- Pills and chips are for controls: filters, toggles, language switches. A list of links is a plain list, unless each link brings a preview of where it leads: related glossary terms, which show the start of each definition, are cards like the glossary's own. One exception: an item may carry one quiet tag for a category that visitors filter by on the same page, such as a resource's purpose.
- Search and filters belong on long lists (the glossary, the resources directory, Reversals). A list of fewer than about twenty items needs neither, and a longer one may do without when another clear route through it exists, such as a contents list.
- Tags: a tag links to the tags page only when at least five pages and at most a quarter of the tagged pages share it (`layouts/partials/functions/tag_counts.html`). Rarer tags are plain keywords; tags on more pages are not shown, because they no longer tell pages apart.
- In directories of cards (§4, About pages), show descriptions in full. Cut one only when it runs past six lines: show four lines and a "more" button. Dense term lists such as the glossary keep their short previews. Never hide just a line or two behind "more". Without JavaScript the full text shows.
- In directories of cards (§4, About pages), show descriptions in full. Cut one only when it runs past six lines: show four lines and a "more" button. Dense term lists such as the glossary keep their short previews, and break into chapters under large letters on the area's pale ground, so a long run of cards has landmarks. Never hide just a line or two behind "more". Without JavaScript the full text shows.
- Cards for actions are the brick cards of `action_cards`. Lists of tools are rows: a linked title and a sentence, not boxes.
- Directories of organisations, teams and projects (Partnerships, Teams, Get involved) are pale cards or pictured entries, two or more to a row on a wide screen, so they are easy to skim. Each ends in a button for its action, such as "Visit website" or "Join the team's Slack channel".
- Framed boxes (cards, panels, toolbars) keep space inside them and between them; text never runs up against a box's edge.
Expand Down
79 changes: 79 additions & 0 deletions assets/css/doors/glossary.css
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,82 @@ main:lang(ar) .glossary-layout .article-style .term-credit{font-size:18px}
/* Chinese titles break at punctuation such as 、 rather than inside a word (工业 / 化); a title with no break
opportunity still wraps, through the page's overflow-wrap. */
main:lang(zh) .glossary-layout :is(.reading h1,.term-list a){word-break:keep-all}
/* Chapters: each letter is a large Newsreader letter on the education area's pale ground (the glossary belongs to
Education & Pedagogy, DESIGN.md §6), so a long run of terms breaks into chapters. On a wide screen the letter
stands in a column beside its terms and stays in view while they scroll by; elsewhere it heads them as a band. */
.term-group>h2{display:flex;align-items:center;margin:32px 0 12px;padding:4px 16px;min-height:56px;box-sizing:border-box;background:var(--edu-bg);border-radius:var(--r-large);color:var(--edu);font:500 40px/1 var(--display)}
.term-grid>.term-group:first-child>h2{margin-top:8px}
.term-group li{background:#fff;border:1.5px solid var(--line)}
.term-group li:hover{border-color:var(--edu)}
@media(max-width:760px){.term-group>h2{min-height:48px;margin:24px 0 10px;font-size:32px}}
/* Wide screens: the search, the view and the letters in a pale green panel beside the title, which stays in view
while the terms scroll by. Letter jumps then land at the top of the screen. */
@media(min-width:1001px){
.glossary-hub .reading{display:grid;grid-template-columns:minmax(0,1fr) 320px;column-gap:40px;align-items:start}
.glossary-hub .reading>*{grid-column:1}
.glossary-hub .reading>.glossary-tools{grid-column:2;grid-row:1/span 20;align-self:start;position:sticky;top:16px;margin:0;padding:20px;border:0;border-radius:var(--r-large);background:var(--edu-bg)}
.glossary-hub .glossary-find{margin:0;max-width:none}
.glossary-hub .glossary-find label{font-size:23px;color:var(--edu)}
.glossary-hub .glossary-search-row{flex-wrap:wrap}
.glossary-hub .glossary-search-row input{flex:1 1 100%}
.glossary-hub .glossary-view{margin-top:2px}
.glossary-hub .glossary-letters{display:grid;grid-template-columns:repeat(auto-fill,minmax(36px,1fr));gap:6px;margin:16px 0 0;padding:16px 0 0;border-top:1px solid rgba(45,87,80,.25)}
.glossary-hub .glossary-letters a{min-width:0;height:38px;background:#fff;font-size:17px}
.glossary-hub .glossary-letters a:hover{background:var(--edu);color:#fff}
.glossary-hub .glossary-letters a.is-current{background:var(--edu);color:#fff}
.glossary-hub .glossary-letters a.is-empty{background:transparent}
.glossary-hub:has(.glossary-tools) .term-group{scroll-margin-top:16px}
.glossary-hub .standfirst{max-width:32.5em}
/* Two cards a row beside the panel, so a card's lines stay under 80 characters (DESIGN.md §7). */
.term-group ul{grid-template-columns:repeat(auto-fill,minmax(min(100%,250px),1fr))}
}
@media(min-width:1240px){
.term-group{display:grid;grid-template-columns:88px minmax(0,1fr);column-gap:24px;align-items:start;margin-top:28px}
.term-group>h2{position:sticky;top:16px;justify-content:center;width:88px;height:88px;margin:0;padding:0;font-size:56px}
.term-grid>.term-group:first-child{margin-top:8px}
.term-grid>.term-group:first-child>h2{margin-top:0}
.term-group ul{grid-template-columns:repeat(auto-fill,minmax(min(100%,280px),1fr))}
}
.term-grid.is-list .term-group li{border-width:0 0 1px;border-color:var(--line)}
/* A term page: related terms as the hub's cards, with the start of their definitions; references as a plain list with a hanging indent;
the previous and next terms as two cards with the start of theirs. */
.glossary-layout .article-style .term-related{margin:28px 0 8px}
.glossary-layout .article-style :is(.term-related>h2,.term-references-heading){margin:28px 0 12px;font-size:24px;color:var(--edu)}
.glossary-layout .article-style .term-related>h2{margin-top:0}
.glossary-layout .article-style .term-cards{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,260px),1fr));gap:10px;max-width:none;margin:0 0 10px;padding:0;list-style:none}
.glossary-layout .article-style .term-cards li{max-width:none;margin:0;padding:12px 16px;background:#fff;border:1.5px solid var(--line);border-radius:var(--r-large);font-size:16px;line-height:1.45}
.glossary-layout .article-style .term-cards li:hover{border-color:var(--edu)}
.glossary-layout .article-style .term-cards a{font:600 18px/1.3 var(--text)}
.glossary-layout .article-style .term-cards p{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;margin:4px 0 0;font-size:16px;line-height:1.45}
.glossary-layout .article-style .term-unlinked-line{margin:12px 0 0;font-size:16px;line-height:1.5;color:var(--soft)}
.glossary-layout .article-style .term-unlinked-label{font-weight:600}
.glossary-layout .article-style .term-unlinked-list{display:inline;margin:0;padding:0;list-style:none}
.glossary-layout .article-style .term-unlinked-list li{display:inline;margin:0;padding:0}
.glossary-layout .article-style .term-unlinked-list li::before{content:none}
.glossary-layout .article-style .term-unlinked-list li+li::before{content:", "}
main:lang(ar) .glossary-layout .article-style .term-unlinked-list li+li::before{content:"، "}
.glossary-layout .article-style .term-unlinked-list .term-unlinked{color:inherit}
.glossary-layout .article-style .term-references{margin:0 0 8px;padding:0;list-style:none;font-size:16px;line-height:1.5}
/* As wide as the definition and the cards above it (article.css caps reference lists at 29.8em). */
.glossary-layout .article-style ul.term-references.references-list{max-width:none}
.glossary-layout .article-style .term-references li{max-width:29em;margin:0 0 10px;padding-inline-start:1.5em;text-indent:-1.5em;list-style:none}
.glossary-layout .article-style .term-references li::before{content:none}
.glossary-layout .article-style .term-references li:last-child{margin-bottom:0}
main:lang(ar) .glossary-layout .article-style .term-references{direction:ltr;padding:0}
.glossary-layout .article-foot .post-nav{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.glossary-layout .article-foot .post-nav-item{max-width:none;padding:14px 16px;background:var(--edu-bg);border-radius:var(--r-large)}
.glossary-layout .article-foot .post-nav-next:only-child{grid-column:2}
.glossary-layout .article-foot .post-nav-item>a{display:block;color:var(--ink);text-decoration:none}
.glossary-layout .article-foot .post-nav-item>a p{margin:2px 0 0;color:var(--link);font:600 18px/1.3 var(--text)}
.glossary-layout .article-foot .post-nav-item p.post-nav-def{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;margin:6px 0 0;font-size:15px;color:var(--ink)}
@media(max-width:560px){.glossary-layout .article-foot .post-nav{grid-template-columns:1fr}.glossary-layout .article-foot .post-nav-next:only-child{grid-column:1}}
/* The reference list: the hub's panel and letters, with each reference a row in a hanging indent and the terms
that cite it underneath. */
.glossary-references .term-group ul.references-list{display:block;max-width:none;margin:0;padding:0}
.glossary-references .term-group ul.references-list>li{max-width:29em;margin:0;padding:12px 0 12px 1.5em;text-indent:-1.5em;background:none;border:0;border-bottom:1px solid var(--line);border-radius:0;line-height:1.5}
.glossary-references .term-group ul.references-list>li:hover{border-color:var(--line)}
.glossary-references .reference-apa a{color:var(--link);text-decoration:underline;text-underline-offset:3px;overflow-wrap:anywhere}
.glossary-references .reference-cited{display:block;margin:6px 0 0;text-indent:0;font-size:16px;color:var(--soft)}
.glossary-references .reference-cited a{color:var(--link);font-weight:600;text-decoration:underline;text-underline-offset:3px}
.glossary-references .reference-cited .term-en{display:none}
.glossary-references .standfirst{max-width:30em}
13 changes: 9 additions & 4 deletions assets/js/doors/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -516,17 +516,22 @@ if (termFilter && termGrid) {
});
document.querySelector('.glossary-clear').hidden = !query;
const shown = terms.filter((term) => !term.hidden).length;
document.querySelector('.glossary-count').textContent = query && shown ? `${shown} of ${terms.length} terms` : '';
// "12 of 260 terms", in the glossary's language (data-format, from layouts/glossary/list.html).
const count = document.querySelector('.glossary-count');
const format = count.dataset.format || '%s of %s terms';
Comment thread
LukasWallrich marked this conversation as resolved.
Resolved
count.textContent = query && shown ? format.replace('%s', shown).replace('%s', terms.length) : '';
});
// Cards or a compact list; the choice is kept for the next visit.
// The reference list (layouts/partials/doors/glossary_references.html) has neither the views nor the about box.
const view = document.querySelector('.glossary-view');
const setView = (list) => {
if (!view) return;
termGrid.classList.toggle('is-list', list);
view.querySelectorAll('button').forEach((b) => b.setAttribute('aria-pressed', String((b.dataset.view === 'list') === list)));
try { localStorage.setItem('glossary-view', list ? 'list' : 'cards'); } catch (e) { /* storage blocked: the choice lasts this visit */ }
};
view.hidden = false;
view.querySelectorAll('button').forEach((b) => b.addEventListener('click', () => setView(b.dataset.view === 'list')));
if (view) view.hidden = false;
view?.querySelectorAll('button').forEach((b) => b.addEventListener('click', () => setView(b.dataset.view === 'list')));
// Phones start with the compact list; a stored choice wins.
let stored = null;
try { stored = localStorage.getItem('glossary-view'); } catch (e) { /* no stored choice */ }
Expand Down Expand Up @@ -557,7 +562,7 @@ if (termFilter && termGrid) {
if (asked) { termFilter.value = asked; termFilter.dispatchEvent(new Event('input')); }
// "How to cite" links to the closed disclosure under the heading; following the link opens it.
const about = document.getElementById('about-the-glossary');
const openAbout = () => { if (location.hash === '#about-the-glossary') about.open = true; };
const openAbout = () => { if (about && location.hash === '#about-the-glossary') about.open = true; };
window.addEventListener('hashchange', openAbout);
openAbout();
} else if (termFilter) {
Expand Down
52 changes: 10 additions & 42 deletions content/glossary/_build_references.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
"""Generate the glossary reference list page from apa_lookup.json.
"""Generate the glossary reference list page (/glossary/references/).

The dynamic glossary resolves per-term references from apa_lookup.json (built by
bibtex_to_apa/bibtex_to_apa.js from the "Glossary BibTex" Google Doc). This script
renders the same data as the public "List of References" page so the two stay in
sync. Run it after apa_lookup.json is regenerated:
bibtex_to_apa/bibtex_to_apa.js from the "Glossary BibTex" Google Doc). The public
"List of References" is rendered from the same file by
layouts/partials/doors/glossary_references.html, so the two stay in sync; this
script writes only the page's front matter and introduction. Run it after
apa_lookup.json is regenerated:

python3 content/glossary/_build_references.py

Expand Down Expand Up @@ -34,64 +36,30 @@

import json
import os
import re

script_dir = os.path.dirname(os.path.abspath(__file__))
apa_path = os.path.join(script_dir, "apa_lookup.json")
out_path = os.path.join(script_dir, "references", "index.md")

URL_RE = re.compile(r"(https?://[^\s<>]+[^\s<>.,;)])")

HEADER = """---
title: List of References
---

You can find the list of all references that were used to create the Glossary.

{{< alert info >}}

We are currently working on a better way to display and cross-link the references with the terms they are used for.

{{< /alert >}}

<div class="csl-bib-body" style="line-height: 2; margin-left: 2em; text-indent:-2em;">
"""


def sort_key(citation):
# Sort like a bibliography: by the leading author/title text, ignoring
# leading markup/punctuation and case.
return re.sub(r"^[^\w]+", "", citation).casefold()


def render(citation):
"""Linkify the bare DOI/URL in an apa_lookup HTML fragment.

Values are HTML fragments from citation-js (journal titles in <i>/<sub>, literal
"&", the odd &#60;/&#62; entity). They are emitted into a Markdown page rendered
with goldmark unsafe=true, which escapes bare "&" to &amp; itself — so we only
wrap the DOI/URL here (its literal "&" gets escaped in the href too).
"""
return URL_RE.sub(lambda m: f'<a href="{m.group(1)}">{m.group(1)}</a>', citation)


def main():
# The list itself is rendered by layouts/partials/doors/glossary_references.html from apa_lookup.json, with
# letters, a search and, under each reference, the terms that cite it. This page only gives it a URL and title.
with open(apa_path, encoding="utf-8") as f:
apa = json.load(f)

# Dedupe identical citation strings (distinct keys can share a reference).
citations = sorted(set(apa.values()), key=sort_key)

lines = [HEADER]
for citation in citations:
lines.append(f' <div class="csl-entry">{render(citation)}</div>')
lines.append("</div>\n")

os.makedirs(os.path.dirname(out_path), exist_ok=True)
with open(out_path, "w", encoding="utf-8") as f:
f.write("\n".join(lines))
f.write(HEADER)

print(f"Wrote {len(citations)} references to {out_path}")
print(f"Wrote the reference list page for {len(set(apa.values()))} references to {out_path}")


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion layouts/glossary/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
site.js filters the terms as the search is typed. */}}
{{ $lang := .Params.language | default "english" }}
{{ $labels := dict
"english" (dict "view" "View" "cards" "Cards" "list" "List" "language" "Language" "clear" "Clear" "lede" "Community-written definitions of open scholarship terms, described in Nature Human Behaviour (Parsons et al., 2022). [How to cite the glossary](#about-the-glossary)." "search" "Search %d terms" "placeholder" "Type a term, e.g. replication" "about" "About the glossary project, and how to cite it" "letters" "Terms by letter" "none" "No term matches.")
"english" (dict "view" "View" "cards" "Cards" "list" "List" "language" "Language" "clear" "Clear" "lede" "Community-written definitions of open scholarship terms, described in Nature Human Behaviour (Parsons et al., 2022). [How to cite the glossary](#about-the-glossary)." "search" "Search %d terms" "placeholder" "Type a term, e.g. replication" "about" "About the glossary project" "letters" "Terms by letter" "none" "No term matches.")
"german" (dict "view" "Ansicht" "cards" "Karten" "list" "Liste" "language" "Sprache" "clear" "Löschen" "search" "%d Begriffe durchsuchen" "placeholder" "Begriff eingeben, z. B. Replikation" "about" "Über das Glossar und wie man es zitiert" "letters" "Begriffe nach Buchstaben" "none" "Kein Begriff passt.")
"arabic" (dict "view" "العرض" "cards" "بطاقات" "list" "قائمة" "language" "اللغة" "clear" "مسح" "search" "ابحث في %d مصطلحًا" "placeholder" "اكتب مصطلحًا" "about" "عن المسرد وكيفية الاستشهاد به" "letters" "المصطلحات حسب الحرف" "updated" "آخر تحديث:" "none" "لا يوجد مصطلح مطابق.")
"turkish" (dict "view" "Görünüm" "cards" "Kartlar" "list" "Liste" "language" "Dil" "clear" "Temizle" "search" "%d terimde ara" "placeholder" "Bir terim yazın" "about" "Sözlük hakkında ve nasıl atıf yapılır" "letters" "Harfe göre terimler" "none" "Eşleşen terim yok.")
Expand Down
Loading
Loading