diff --git a/assets/css/article.css b/assets/css/article.css index 8e3ab546b4e..b1648207a40 100644 --- a/assets/css/article.css +++ b/assets/css/article.css @@ -1272,3 +1272,43 @@ html:has(.list-filter-section){scroll-padding-top:calc(var(--list-filter-bar,0px .outcome-board.is-seen .outcome-tile .outcome-bricks i{animation-play-state:running} } @keyframes outcome-brick{from{opacity:0;transform:scale(.2)}} + +/* A paragraph of nothing but pictures in an article (reading): as wide as the text, a pair side by side + at one height, each no wider than its file. A picture wider than its share of the text links to its full size. Square corners, + so a frame drawn in the picture is not clipped. On a phone the pictures stack. */ +.article-layout .article-style p.img-row{display:flex;gap:12px;align-items:flex-start;max-width:var(--measure);margin:28px 0} +.article-layout .article-style .img-pair-item{flex:calc(var(--w) / var(--h)) 1 0;min-width:0;max-width:calc(var(--w) * 1px)} +.article-layout .article-style .img-row img{display:block;width:100%;height:auto} +.article-layout .article-style a.img-full{display:block;cursor:zoom-in} +.article-layout .article-style a.img-full:hover img{filter:brightness(.94)} +.article-layout .article-style a.img-full:focus-visible{outline:3px solid var(--ink);outline-offset:3px} +/* On a wide screen a figure runs past the text into the empty band on its right, to the page's edge. */ +@media(min-width:1241px){.article-layout:has(>.article-card):not(.article-layout-callouts,.article-layout-wide) .article-style p.img-row:not(.img-row-text){width:min(calc(50vw + 130px),818px);max-width:none;gap:16px} +} +@media(max-width:560px){.article-layout .article-style p.img-row{flex-direction:column} +.article-layout .article-style .img-pair-item{flex:none;max-width:100%} +} + +/* An editor's note after an article: its label bold and the note at body weight, a size down, under a short rule. */ +.article-layout .article-style .editors-note{max-width:calc(var(--measure) * 18 / 17);margin:0 0 16px;font-size:17px;line-height:1.55} +.article-layout .article-style hr:has(+ .editors-note,+ br + .editors-note){width:96px;margin:36px 0 18px;border:0;border-top:3px solid var(--edu)} + +/* An Educators' Corner article by one author with a photo (article_header): on a phone or tablet the byline is a band + on education's pale ground, in place of the side card at the end; on a wide screen the card has photo and name. */ +.article-layout .byline-portrait :is(.byline-photo,.network-icon,.byline-role,.byline-bio){display:none} +@media(max-width:1000px){.article-layout .byline-portrait{display:grid;grid-template-columns:96px minmax(0,1fr);gap:2px 16px;align-items:center;margin-top:20px;padding:22px 18px 16px;background:var(--edu-bg);border-radius:var(--r-large);box-shadow:inset 0 6px 0 var(--edu)} +.article-layout .byline-portrait>*{grid-column:2} +.article-layout .byline-portrait .byline-photo{display:block;grid-column:1;grid-row:1/span 3;width:96px;height:96px;border-radius:50%;object-fit:cover;box-shadow:0 0 0 3px #fff} +.article-layout .byline-portrait .byline-authors{font:500 21px/1.2 var(--display)} +.article-layout .byline-portrait .byline-role{display:block;font-size:15px;line-height:1.4} +.article-layout .byline-portrait .byline-bio{display:block;grid-column:1/-1;margin-top:10px;font-size:15px;line-height:1.45} +.article-layout .byline-portrait :is(.byline-role,.byline-bio) p{margin:0} +.article-layout .byline-portrait .network-icon{display:flex;gap:0;margin:2px 0 0 -10px;padding:0;list-style:none} +.article-layout .byline-portrait .network-icon li{margin:0} +.article-layout .byline-portrait .network-icon a{display:flex;align-items:center;justify-content:center;width:44px;height:44px;color:var(--link);font-size:17px;text-decoration:none} +.article-layout:has(.byline-portrait) .article-card{display:none} +} +.article-layout .article-card-edu .card-authors>li:has(>.card-author-portrait){grid-template-columns:minmax(0,1fr)} +.article-layout .article-card-edu .card-authors>li>img.card-author-portrait{grid-row:auto;width:100%;height:auto;aspect-ratio:184/220;margin:0 0 12px;border-radius:var(--r-small);object-fit:cover} +.article-layout .article-card-edu .card-authors>li:has(>.card-author-portrait)>div>*{grid-column:1} +.article-layout .article-card-edu .card-authors>li:has(>.card-author-portrait) .card-author-name{font-size:22px} diff --git a/content/educators-corner/001-Representation-HeatherUrry/index.md b/content/educators-corner/001-Representation-HeatherUrry/index.md index 70d7cdf5730..d2a7c1230dc 100644 --- a/content/educators-corner/001-Representation-HeatherUrry/index.md +++ b/content/educators-corner/001-Representation-HeatherUrry/index.md @@ -18,7 +18,7 @@ draft: false image: #caption: "Photo by Andrea Piacquadio from [Pexels](https://www.pexels.com/photo/happy-ethnic-woman-sitting-at-table-with-laptop-3769021/)" focal_point: "Center" - preview_only: false + preview_only: true # Projects (optional). # Associate this post with one or more of your projects. diff --git a/content/educators-corner/011-intersectionality-open-science/index.md b/content/educators-corner/011-intersectionality-open-science/index.md index 8297fbe5310..f1723736205 100644 --- a/content/educators-corner/011-intersectionality-open-science/index.md +++ b/content/educators-corner/011-intersectionality-open-science/index.md @@ -18,7 +18,7 @@ draft: false image: #caption: "Photo by Andrea Piacquadio from [Pexels](https://www.pexels.com/photo/happy-ethnic-woman-sitting-at-table-with-laptop-3769021/)" focal_point: "Center" - preview_only: false + preview_only: true # Projects (optional). # Associate this post with one or more of your projects. diff --git a/content/educators-corner/016-reviewer-zero/index.md b/content/educators-corner/016-reviewer-zero/index.md index c9d6330a56e..912baff19ee 100644 --- a/content/educators-corner/016-reviewer-zero/index.md +++ b/content/educators-corner/016-reviewer-zero/index.md @@ -20,6 +20,9 @@ image: focal_point: "Center" preview_only: false +# Pictures that stay at the width of the text on wide screens. +text_width_figures: ["tweet_rz.webp"] + # Projects (optional). # Associate this post with one or more of your projects. # Simply enter your project's folder or file name without extension. diff --git a/layouts/_default/_markup/render-link.html b/layouts/_default/_markup/render-link.html index 64bb2557952..edb55a84d19 100644 --- a/layouts/_default/_markup/render-link.html +++ b/layouts/_default/_markup/render-link.html @@ -1,2 +1,6 @@ -{{- /* A Hugo Markdown render hook to parse links, opening external links in new tabs. Trimmed so no whitespace is emitted before the link. */ -}} -{{ .Text | safeHTML }} \ No newline at end of file +{{- /* Markdown links, opening other sites in new tabs; a link to forrt.org itself (site.Params.doors.host, with or + without www.) stays in the tab, as in booklet_contents. Overrides the theme's hook, whose comment line left a + line break before every link: rendered as a space, it split "(" from a link that follows it. */ -}} +{{- $host := strings.TrimPrefix "www." (urls.Parse .Destination).Host -}} +{{- $away := and $host (ne $host site.Params.doors.host) -}} +{{ .Text | safeHTML }} \ No newline at end of file diff --git a/layouts/partials/article_header.html b/layouts/partials/article_header.html index 3c17af0c97e..ac18e600d7a 100644 --- a/layouts/partials/article_header.html +++ b/layouts/partials/article_header.html @@ -29,8 +29,22 @@ {{ $heading := .Params.heading_title | default .Title }} {{ if .Params.hide_title }}

{{ $heading }}

{{ else }}

{{ $heading }}

{{ end }} {{ with .Params.subtitle }}

{{ . | markdownify | emojify }}

{{ end }} -
+ {{/* An Educators' Corner article by one author with a photo: on a phone or tablet the byline is a band on education's pale + ground with the photo, name, links and date, and the side card, which has them on a wide screen, is left out + there (article.css). */}} + {{ $profile := false }}{{ $photo := false }} + {{ if and (eq (len (.Params.authors | default slice)) 1) (eq .Type "educators-corner") }} + {{ with partialCached "author_profile" (index .Params.authors 0) (index .Params.authors 0) }}{{ $profile = . }}{{ if ne (lower (.Params.name | default "")) "forrt" }}{{ $photo = (.Resources.ByType "image").GetMatch "*avatar*" }}{{ end }}{{ end }} + {{ end }} +
+ {{ with $photo }}{{ end }} {{ with .Params.authors }}{{ end }} + {{ if $photo }} + {{/* The card's role and bio come too, as the card is left out on these screens. */}} + {{ with $profile.Params.role }}{{ end }} + {{ if $profile.Params.social }}{{ partial "social_links" $profile }}{{ end }} + {{ with $profile.Params.bio }}{{ end }} + {{ end }} {{/* The side card carries the date on a wide screen; on a narrow one it would come after the article. */}} {{ if and (in (slice "post" "educators-corner" "pedagogies") .Type) (not .Date.IsZero) }}{{ end }} {{ if and (eq .Type "post") (ge .ReadingTime 3) }}{{ end }} diff --git a/layouts/partials/author_links.html b/layouts/partials/author_links.html index 2ad694f2936..b3667b8f828 100644 --- a/layouts/partials/author_links.html +++ b/layouts/partials/author_links.html @@ -1,7 +1,7 @@ {{/* Author names, comma-separated, each linked to its profile where one exists, as page_metadata_authors does. Input: a slice of names as written in a page's `authors`. */}} {{- range $i, $raw := . -}} - {{- $profile := site.GetPage (printf "/authors/%s" (urlize $raw)) -}} + {{- $profile := partialCached "author_profile" $raw $raw -}} {{- if gt $i 0 }}, {{ end -}} {{- $name := $raw -}}{{- with $profile -}}{{- with .Params.name -}}{{- $name = . -}}{{- end -}}{{- end -}} {{- if and $profile $profile.Params.name (site.Params.link_authors | default true) -}} diff --git a/layouts/partials/author_profile.html b/layouts/partials/author_profile.html new file mode 100644 index 00000000000..f4ea1da0a65 --- /dev/null +++ b/layouts/partials/author_profile.html @@ -0,0 +1,16 @@ +{{/* The profile page (/authors//) for a name as written in a page's `authors`, or false. The slug is usually the + name made into a URL; a title such as "Dr." in front, or a profile whose folder differs from the credited name + ("Patrick Forscher" at patrick-s-forscher), is found by the profile's own name. Call it with partialCached and + the name as the key. */}} +{{ $raw := . }} +{{ $found := site.GetPage (printf "/authors/%s" (urlize $raw)) }} +{{ if not $found }} + {{ $plain := replaceRE `(?i)^(dr|prof|professor)\.?\s+` "" (trim $raw " ") }} + {{ $found = site.GetPage (printf "/authors/%s" (urlize $plain)) }} + {{ if not $found }} + {{ with site.GetPage "/authors" }}{{ range .Sections }} + {{ if and (not $found) (eq (lower (.Params.name | default .Title)) (lower $plain)) }}{{ $found = . }}{{ end }} + {{ end }}{{ end }} + {{ end }} +{{ end }} +{{ return $found }} diff --git a/layouts/partials/page_metadata_authors.html b/layouts/partials/page_metadata_authors.html index 3d2e4618a75..e5195336b98 100644 --- a/layouts/partials/page_metadata_authors.html +++ b/layouts/partials/page_metadata_authors.html @@ -9,7 +9,7 @@ {{ with .Param "authors" }} {{ $link_authors := site.Params.link_authors | default true }} {{ range $index, $name_raw := . }} - {{- $profile_page := site.GetPage (printf "/authors/%s" (urlize $name_raw)) -}} + {{- $profile_page := partialCached "author_profile" $name_raw $name_raw -}} {{- $name := $name_raw -}} {{- if and $profile_page $profile_page.Params.name }}{{ $name = $profile_page.Params.name }}{{ end -}} {{- if gt $index 0 }}, {{ end -}} diff --git a/layouts/partials/reading.html b/layouts/partials/reading.html index 6d6370db008..e82308d2b64 100644 --- a/layouts/partials/reading.html +++ b/layouts/partials/reading.html @@ -22,6 +22,28 @@ {{ $label := cond (in (.Params.categories | default slice) "Newsletter") "Read the full issue" "$3" }} {{ $body = replaceRE $link (printf `

%s

` $tone $label) $body 1 | safeHTML }} {{ end }} +{{/* In an article, a paragraph of nothing but pictures is a figure: as wide as the text, or wider on a wide screen, + a pair side by side at one height (article.css), and each picture wider than its share of the text links to its + full size. A picture the author already linked is left alone, because it sits inside that link, not alone in the + paragraph. */}} +{{ if and .IsPage (in (slice "post" "educators-corner" "pedagogies") .Type) }} + {{ range findRE `

\s*(?:]*>\s*)+

` $body }} + {{ $figure := . }} + {{ $column := div 640 (len (findRE `]*? width="(\d+)" height="(\d+)"[^>]*>` . }} + {{ $img := index . 0 }} + {{ $link := cond (gt (int (index . 2)) $column) (printf `%s (full size)` (index . 1) $img) $img }} + {{ $figure = replace $figure $img (printf `%s` (index . 2) (index . 3) $link) }} + {{ end }} + {{/* A picture an article names in `text_width_figures`, such as a screenshot of a tweet, stays at the text's width. */}} + {{ $class := "img-row" }} + {{ range $.Params.text_width_figures }}{{ if in $figure . }}{{ $class = "img-row img-row-text" }}{{ end }}{{ end }} + {{ $body = replace $body . (replace $figure "

" (printf `

` $class)) | safeHTML }} + {{ end }} + {{/* An editor's note set wholly in emphasis read as one bold block: its label stays bold, the note itself is + body text (Educators' Corner 001, 007, 012). */}} + {{ $body = replaceRE `

\s*Editor(?:’|’|')s note(?::\s*|:\s*)([\s\S]*?)(?:)?\s*

` `

Editor’s note: $1

` $body | safeHTML }} +{{ end }} {{ $contents := cond (findRE `(?i)]*\bid="?([^"> ]+)"?[^>]*>([\s\S]*?)` $body }} {{/* A short page's real sections can sit a level down. */}} diff --git a/layouts/partials/reading_card.html b/layouts/partials/reading_card.html index 9cd23a006b6..5a097380e3c 100644 --- a/layouts/partials/reading_card.html +++ b/layouts/partials/reading_card.html @@ -10,7 +10,7 @@ {{/* Authors with a profile page, photo first; the rest by name. */}} {{ $authors := slice }} {{ if $article }}{{ range $p.Params.authors }} - {{ $profile := site.GetPage (printf "/authors/%s" (urlize .)) }} + {{ $profile := partialCached "author_profile" . . }} {{ $authors = $authors | append (dict "name" . "profile" $profile) }} {{ end }}{{ end }} {{/* A newsletter's archive, which neither the breadcrumb nor the cards at the end link. */}} @@ -54,7 +54,9 @@ {{ with .profile }} {{ $avatar := (.Resources.ByType "image").GetMatch "*avatar*" }} - {{ with $avatar }}{{ end }} + {{/* On an education article a lone author's portrait is large, as the article's opening picture (article.css); FORRT's own account is not a person, and its logo stays small. */}} + {{ $person := ne (lower (.Params.name | default "")) "forrt" }} + {{ with $avatar }}{{ if and $person (eq (len $authors) 1) (in (slice "educators-corner" "pedagogies") $p.Type) }}{{ else }}{{ end }}{{ end }}
{{ .Title }} {{ with .Params.role }}

{{ . | markdownify | emojify }}

{{ end }} diff --git a/scripts/rebrand/compare_builds.py b/scripts/rebrand/compare_builds.py index 0e408054194..03d28624c4b 100644 --- a/scripts/rebrand/compare_builds.py +++ b/scripts/rebrand/compare_builds.py @@ -111,6 +111,38 @@ def _equivalent_social_images(before, after): return before, after +# A space just inside an opening bracket or quote, as in "( https://…": Markdown links left one there until #1243. +_OPENER_SPACE = re.compile(r"""([(\[“«]|(?:^|(?<=\s))")\s+""") + + +def _same_description(old, new): + """True when two descriptions differ only by spaces just inside an opening bracket or quote. Losing such a space + can move the cut of a long description ("…") on by a word, so the cut text may then end one or two words later.""" + removed = len(_OPENER_SPACE.findall(old)) + len(_OPENER_SPACE.findall(new)) + old, new = _OPENER_SPACE.sub(r"\1", old), _OPENER_SPACE.sub(r"\1", new) + if old == new: + return True + # A later cut is only explained by a removed space; without one, any difference is a real edit. + if not removed: + return False + stems = [text[:-1].rstrip() if text.endswith("…") else text for text in (old, new)] + short = 0 if len(stems[0]) < len(stems[1]) else 1 + shorter, longer = stems[short], stems[1 - short] + # Only a cut description may end earlier than the other, and only by a word or two. + return (old, new)[short].endswith("…") and longer.startswith(shorter) and len(longer[len(shorter):].split()) <= 2 + + +def _equivalent_descriptions(before, after): + """Treat a description as unchanged when it only lost a space inside a bracket or quote (_same_description). + Every other tag, and any description that changed otherwise, still compares exactly.""" + for key in ("description", "og:description", "twitter:description"): + old = [tag for tag in before if tag.partition("=")[0] == key] + new = [tag for tag in after if tag.partition("=")[0] == key] + if len(old) == 1 and len(new) == 1 and old != new and _same_description(old[0][len(key) + 1:], new[0][len(key) + 1:]): + after = [old[0] if tag == new[0] else tag for tag in after] + return before, after + + def compare_heads(reference, candidate, allowed=frozenset()): """Return {path: (only_before, only_after)} for pages whose SEO tags differ.""" changes = {} @@ -121,6 +153,7 @@ def compare_heads(reference, candidate, allowed=frozenset()): before = _without_edit_date(tags) after = _without_edit_date(candidate[path]) before, after = _equivalent_social_images(before, after) + before, after = _equivalent_descriptions(before, after) if before != after: before, after = set(before), set(after) changes[path] = (sorted(before - after), sorted(after - before)) diff --git a/scripts/tests/test_rebrand_checks.py b/scripts/tests/test_rebrand_checks.py index 2dd607e8374..aa303d24231 100644 --- a/scripts/tests/test_rebrand_checks.py +++ b/scripts/tests/test_rebrand_checks.py @@ -246,6 +246,32 @@ def test_heads_report_only_differences(self): changes = compare_heads({"a": ["x", "y"], "b": ["z"]}, {"a": ["x", "w"], "b": ["z"]}) self.assertEqual(changes, {"a": (["y"], ["w"])}) + def test_a_description_may_lose_the_space_inside_a_bracket(self): + before = ["description=Open Source Guides ( https://opensource.guide/) are a collection", + 'og:description=He said " The replication" was fine', "title=Page"] + after = ["description=Open Source Guides (https://opensource.guide/) are a collection", + 'og:description=He said "The replication" was fine', "title=Page"] + self.assertEqual(compare_heads({"a": before}, {"a": after}), {}) + + def test_a_cut_description_may_then_end_a_word_later(self): + before = ["description=Software ( https://jasp-stats.org/) and the web…"] + after = ["description=Software (https://jasp-stats.org/) and the web application…"] + self.assertEqual(compare_heads({"a": before}, {"a": after}), {}) + + def test_other_description_changes_still_count(self): + before = "description=Open Source Guides ( https://opensource.guide/) are a collection…" + for after in ("description=Open Source Guides (https://opensource.guide/) is a collection…", + "description=Open Source Guides (https://opensource.guide/) are a collection of many more resources…", + "description=Open Source Guides (https://opensource.guide/) are a", + "description=Open Source Guides(https://opensource.guide/) are a collection…"): + with self.subTest(after=after): + self.assertIn("a", compare_heads({"a": [before]}, {"a": [after]})) + # Without a removed space, even a cut description that ends a word later is a real edit. + self.assertIn("a", compare_heads({"a": ["description=Software and the web…"]}, + {"a": ["description=Software and the web application…"]})) + # Only descriptions: the same change in a title still counts. + self.assertIn("a", compare_heads({"a": ["title=A ( b)"]}, {"a": ["title=A (b)"]})) + def social_tags(self, image, image_type="image/webp", width="100", height="50"): return sorted(["og:image=" + image, "twitter:image=" + image,