Merge branch 'claude/relaxed-faraday-h4zd09' of https://github.com/pablovolenski/vienalatina

This commit is contained in:
admin 2026-10-12 14:30:34 +00:00
commit 6a591890f6
10 changed files with 550 additions and 21 deletions

View File

@ -388,3 +388,48 @@ def test_the_public_agenda_draws_every_day_on_a_phone_too():
assert weekday and weekday[2] != "none", ( assert weekday and weekday[2] != "none", (
"the phone block never shows .agenda__weekday, so every row of the " "the phone block never shows .agenda__weekday, so every row of the "
"month is a bare number — there is no column header at that width") "month is a bare number — there is no column header at that width")
# --- the share row, which is theme and not members area --------------------
def test_the_share_buttons_that_need_a_script_say_so_in_the_markup():
"""Three of the seven cannot be links: Signal has no web intent, Instagram
accepts no URL at all, and copying needs the clipboard. They carry `hidden`
and share.js takes it off — so a reader without scripting sees four buttons
that work rather than seven of which three do nothing.
"""
share = (THEME / "layouts" / "partials" / "share.html").read_text(encoding="utf-8")
for hook in ("data-share-native", "data-share-copy"):
for element in re.findall(r"<(?:a|button)[^>]*" + hook + r"[^>]*>", share):
assert "hidden" in element, f"{hook} without `hidden`: {element[:80]}"
def test_a_hidden_share_button_is_actually_hidden():
"""`[hidden] { display: none }` lives in the browser's own stylesheet, and
an author rule beats a user-agent rule whatever the specificity — so
`.share__btn { display: inline-flex }` quietly un-hid all three. With
scripting off, seven buttons appeared and three of them did nothing, which
is the exact failure the attribute was there to prevent.
"""
css = (THEME / "assets" / "css" / "main.css").read_text(encoding="utf-8")
assert re.search(r"\.share__btn\[hidden\]\s*\{[^}]*display:\s*none", css), (
"main.css gives .share__btn a display without taking it back for "
"[hidden], so the buttons share.js is meant to reveal are visible "
"before it runs — and useless until it does")
def test_every_share_link_is_marked_safe_so_it_is_not_encoded_twice():
"""Go's template escaper treats an href as a URL and escapes it on the way
out. A value already encoded with `urlquery` therefore went out as %253A
and %2b — a WhatsApp link with the percent signs spelled out, which opens
the composer with gibberish in it. `safeURL` is what stops the second pass.
"""
share = (THEME / "layouts" / "partials" / "share.html").read_text(encoding="utf-8")
# By line rather than by matching the attribute: the value contains its own
# quotes — `href="{{ printf "https://…" $enc | safeURL }}"` — and a regex
# for href="..." stops at the first of them and reads nothing.
lines = [line.strip() for line in share.splitlines()
if "href=" in line and "$enc" in line]
assert lines, "share.html builds no encoded links at all any more"
for line in lines:
assert "safeURL" in line, f"encoded twice: {line}"

View File

@ -135,3 +135,35 @@ markup:
unsafe: false unsafe: false
enableRobotsTXT: false # robots.txt is a static file in static/ enableRobotsTXT: false # robots.txt is a static file in static/
# The uploads are mounted twice on purpose.
#
# Hugo copies `static/` and processes `assets/`, and a picture that is only
# copied cannot be resized — which is why a share card used to point at the
# original: a photograph off a phone, two to five megabytes. WhatsApp fetches a
# preview image on a tight budget and gives up on a file that size, so the card
# arrived with a blank where the picture should be.
#
# Mounting `static/uploads` into `assets/uploads` as well lets seo-head.html
# build a 1200×630 card from the same file, while the static copy stays exactly
# where it is: every existing /uploads/… URL, every image in every post, and
# everything the editor commits are untouched.
#
# Declaring any mount means declaring them all — these five are Hugo's own
# defaults, written out so nothing silently stops being read.
module:
mounts:
- source: content
target: content
- source: layouts
target: layouts
- source: data
target: data
- source: assets
target: assets
- source: static
target: static
- source: static/uploads
target: assets/uploads
- source: static/brand
target: assets/brand

View File

@ -1080,9 +1080,8 @@ card and `BlogPosting` for articles. What it now also does:
- **Static pages get all of it** — they had none, so *Acerca de* shared as a bare - **Static pages get all of it** — they had none, so *Acerca de* shared as a bare
link. `WebPage` schema, Open Graph, the card link. `WebPage` schema, Open Graph, the card
- **`og:image` with an alt**, from the post's own picture or `params.defaultImage` - **`og:image` with an alt**, built rather than pointed at — see §11.16b, which
as a fallback. That param is empty: fill it in when there is a logo, and every is the difference between a card with a picture and a card without one
link shared on WhatsApp, Signal, Mastodon or Bluesky starts carrying a picture
- **`Organization`** on the home, with `areaServed: Wien` and a `sameAs` list - **`Organization`** on the home, with `areaServed: Wien` and a `sameAs` list
ready for social profiles — this is how a search or answer engine knows the ready for social profiles — this is how a search or answer engine knows the
Instagram account and this site are one body Instagram account and this site are one body
@ -1098,6 +1097,63 @@ The translation pipeline carries all of it: `image_alt` joins the translated
keys, and `faq` is translated line by line with each half handled separately so keys, and `faq` is translated line by line with each half handled separately so
the `|` survives. the `|` survives.
### 11.16b The share row, and the card that arrives
**Seven buttons under the title of every post and again after the text**, from
`partials/share.html`. Four are ordinary links and work with scripting off:
WhatsApp, Facebook, Bluesky and Mastodon all accept a URL that opens their own
composer.
The other three cannot be links, and it is worth knowing why rather than
rediscovering it:
| | |
|---|---|
| **Signal** | has no web intent at all. It is a share *target* in the operating system's own sheet and nowhere else |
| **Instagram** | accepts no link from anybody, by design. Every site with an Instagram share button is really offering a copied link |
| **Copiar enlace** | the fallback for everything the two above do not cover, including a desktop with no share sheet |
All three call `navigator.share()` where it exists and copy the address where it
does not. They carry `hidden` in the markup and `share.js` removes it, so a
reader without scripting sees four buttons that work rather than seven of which
three do nothing. `main.css` has to say `.share__btn[hidden] { display: none }`
explicitly: `[hidden]` lives in the browser's own stylesheet and an author rule
beats it whatever the specificity, so `display: inline-flex` silently un-hid all
three the first time.
Mastodon has no central address — the composer lives on whichever server the
*reader* has an account on. The button asks once, keeps the answer in
`localStorage`, and without scripting falls back to the association's own server
from *Gestión → Identidad* when one is set.
The links are built with `urlquery` **and** marked `safeURL`. Go's template
escaper treats an href as a URL and escapes it again on the way out, so without
that the WhatsApp link went out as `%253A` and `%2b` — the composer opening with
the percent signs spelled out.
**The card image is generated, not linked.** This is the half that was actually
broken: `og:image` pointed at the original upload, a photograph off a phone of
two to five megabytes, and WhatsApp fetches preview images on a tight budget and
gives up on a file that size — so the card arrived as a title and a link with a
blank where the picture should be.
Hugo copies `static/` and processes `assets/`, and only the second can be
resized, so `config.yaml` mounts `static/uploads` and `static/brand` into
`assets/` **as well**. The static copies stay exactly where they are: every
`/uploads/…` URL, every image in every post and everything the editor commits
are untouched. `seo-head.html` then fills a post's photograph to **1200×630**
(80–150 KB in practice, measured at 93 KB against a 22 MB source) and fits the
logo fallback without cropping — a wordmark filled to a landscape card loses its
ends, and converting a transparent PNG to JPEG puts it on a black square.
`partials/og-image.html` emits the five tags together, including
`og:image:width` and `og:image:height`, which are not decoration: several
clients draw the small card rather than the large one when they would have to
fetch the file to find out how big it is.
A picture the pipeline cannot find falls back to the absolute URL with no
dimensions — exactly what happened before, so nothing is ever worse than it was.
### 11.17 Writing boxes ### 11.17 Writing boxes
Every box where somebody writes prose — the wall, a comment, a private message, a Every box where somebody writes prose — the wall, a comment, a private message, a

View File

@ -4150,3 +4150,100 @@ a.notif-card__message:hover {
letter-spacing: 0.02em; letter-spacing: 0.02em;
vertical-align: middle; vertical-align: middle;
} }
/* --- sharing ------------------------------------------------------------
*
* A tinted strip rather than six bare icons: the row has to be noticed to be
* used, and a label saying what it is costs one word. Drawn twice on a post —
* under the title and after the text — so it meets both the reader who decides
* on sight and the one who decides at the end.
*
* Each button takes its own brand colour on hover and keeps the page's muted
* grey at rest, so the row reads as one object instead of six logos competing
* with the article.
*/
.share {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px;
margin: 18px 0 24px;
padding: 10px 14px;
border: 1px solid var(--border-light, #e0cec8);
border-radius: var(--radius-lg, 14px);
background: var(--surface-soft, #faf2ef);
}
.share__title {
font-size: 0.85rem;
font-weight: 700;
color: var(--muted, #5c3d37);
margin-right: 4px;
}
.share__btn {
display: inline-flex;
align-items: center;
justify-content: center;
width: 38px;
height: 38px;
padding: 0;
border: 1px solid var(--border-light, #e0cec8);
border-radius: 50%;
background: var(--surface, #fff);
color: var(--muted, #5c3d37);
cursor: pointer;
transition: color 120ms ease, border-color 120ms ease, transform 120ms ease;
}
.share__btn svg { width: 20px; height: 20px; fill: currentColor; }
.share__btn:hover { transform: translateY(-1px); }
/* The `hidden` attribute, given back its meaning.
*
* `[hidden] { display: none }` lives in the browser's own stylesheet, and an
* author rule beats a user-agent rule whatever the specificity — so the
* `display: inline-flex` above quietly un-hid the three buttons that are
* supposed to appear only once share.js has run. With scripting off, all
* seven showed and three of them did nothing at all, which is the exact
* failure the attribute was there to prevent. */
.share__btn[hidden] { display: none; }
/* Their own colours, and only on hover: at rest the row belongs to the page. */
.share__btn--whatsapp:hover { color: #25d366; border-color: #25d366; }
.share__btn--facebook:hover { color: #1877f2; border-color: #1877f2; }
.share__btn--bluesky:hover { color: #0085ff; border-color: #0085ff; }
.share__btn--mastodon:hover { color: #6364ff; border-color: #6364ff; }
.share__btn--signal:hover { color: #3a76f0; border-color: #3a76f0; }
.share__btn--instagram:hover { color: #e1306c; border-color: #e1306c; }
.share__btn--copy:hover { color: var(--brand, #c0391c); border-color: var(--brand, #c0391c); }
.share__btn:focus-visible {
outline: 2px solid var(--brand, #c0391c);
outline-offset: 2px;
}
/* The name is for a screen reader and for `title` on a cursor; the icon is for
everybody else. Hidden this way rather than with display:none, which would
take it out of the accessibility tree along with the button's only label. */
.share__name {
position: absolute;
width: 1px;
height: 1px;
margin: -1px;
padding: 0;
overflow: hidden;
clip-path: inset(50%);
white-space: nowrap;
}
/* What the copy button says back. Empty until it has something to say, so it
takes no room on a row that is already seven items wide. */
.share__said {
font-size: 0.8rem;
color: var(--brand-dark, #9a2a0f);
font-weight: 600;
}
@media (pointer: coarse) {
.share__btn { width: 44px; height: 44px; }
}

View File

@ -0,0 +1,116 @@
// The three share buttons that cannot be plain links.
//
// WhatsApp, Facebook, Bluesky and Mastodon all accept a URL that opens their
// own composer, so those are anchors in share.html and work with this file
// absent. These three cannot be:
//
// Signal has no web intent at all. It is a share *target* in the
// operating system's own sheet and nowhere else.
// Instagram accepts no link from anybody, by design. Every site with an
// Instagram share button is really offering a copied link.
// Copiar is the fallback for every case the two above do not cover,
// including a desktop with no share sheet.
//
// All three are `hidden` in the markup and shown here, so a reader without
// scripting sees four buttons that work rather than seven of which three do
// nothing.
(function () {
"use strict";
function copy(text) {
if (navigator.clipboard && navigator.clipboard.writeText) {
return navigator.clipboard.writeText(text);
}
// Older engines, and any page not served over https: a textarea, selected
// and copied the way it was done before the clipboard API existed.
return new Promise(function (resolve, reject) {
var box = document.createElement("textarea");
box.value = text;
box.setAttribute("readonly", "");
box.style.position = "fixed";
box.style.opacity = "0";
document.body.appendChild(box);
box.select();
try {
document.execCommand("copy") ? resolve() : reject();
} catch (error) {
reject(error);
}
document.body.removeChild(box);
});
}
function wire(row) {
var url = row.getAttribute("data-url");
var title = row.getAttribute("data-title");
var text = row.getAttribute("data-text");
var said = row.querySelector(".share__said");
function announce(message) {
if (!said) { return; }
said.textContent = message;
window.setTimeout(function () { said.textContent = ""; }, 2500);
}
function copyAndSay() {
copy(url).then(function () {
announce(row.getAttribute("data-copied"));
}).catch(function () {
// Copying can be refused outright — a permission, an engine without
// either route. Saying nothing would look like a button that does
// nothing, so the address is put on screen to be copied by hand.
announce(url);
});
}
// Signal and Instagram: the operating system's sheet, which lists both
// when they are installed. There is no way to open one app in particular,
// and pretending otherwise is what a broken button is made of.
Array.prototype.forEach.call(row.querySelectorAll("[data-share-native]"), function (button) {
button.hidden = false;
button.addEventListener("click", function () {
if (navigator.share) {
navigator.share({ title: title, text: text, url: url }).catch(function () {
// Dismissed, which is not a failure and needs no message.
});
} else {
copyAndSay();
}
});
});
Array.prototype.forEach.call(row.querySelectorAll("[data-share-copy]"), function (button) {
button.hidden = false;
button.addEventListener("click", copyAndSay);
});
// Mastodon has no central address: the composer lives on whichever server
// the *reader* has an account on. Asked once and kept, because asking on
// every post would be worse than not offering it.
var masto = row.querySelector("[data-share-mastodon]");
if (masto) {
masto.hidden = false;
masto.addEventListener("click", function (event) {
var saved = null;
try { saved = window.localStorage.getItem("vl-mastodon"); } catch (error) { saved = null; }
var host = saved || window.prompt(row.getAttribute("data-ask"), "mastodon.social");
if (!host) {
// Nothing typed: fall through to the association's own server when
// the markup had one, and otherwise do nothing at all.
if (masto.getAttribute("href") === "#") { event.preventDefault(); }
return;
}
host = host.trim().replace(/^https?:\/\//, "").replace(/\/.*$/, "");
if (!host) { event.preventDefault(); return; }
try { window.localStorage.setItem("vl-mastodon", host); } catch (error) { /* private window */ }
masto.setAttribute("href",
"https://" + host + "/share?text=" + encodeURIComponent(text));
});
}
}
document.addEventListener("DOMContentLoaded", function () {
Array.prototype.forEach.call(document.querySelectorAll("[data-share]"), wire);
});
})();

View File

@ -41,6 +41,11 @@
<h1 class="article-single__title">{{ .Title }}</h1> <h1 class="article-single__title">{{ .Title }}</h1>
{{/* Twice on purpose: here for the reader who decides to send it to
somebody the moment they see what it is, and again after the text
for the one who decides having read it. */}}
{{ partial "share.html" . }}
{{/* An event leads with the three things somebody needs before they read {{/* An event leads with the three things somebody needs before they read
a word: when, what time, and where. Everything else on the page is a word: when, what time, and where. Everything else on the page is
the same article it would otherwise be. */}} the same article it would otherwise be. */}}
@ -101,10 +106,18 @@
</section> </section>
{{ end }} {{ end }}
{{ partial "share.html" . }}
<a class="back-link" href="{{ .Site.Home.Permalink }}"> <a class="back-link" href="{{ .Site.Home.Permalink }}">
← Volver al inicio ← Volver al inicio
</a> </a>
{{/* Only on this template: the home page and the lists carry no share
row, so they should not carry its script either. Fingerprinted and
deferred like the others. */}}
{{ $share := resources.Get "js/share.js" | minify | fingerprint }}
<script src="{{ $share.RelPermalink }}" integrity="{{ $share.Data.Integrity }}" defer></script>
</article> </article>
</main> </main>
{{ end }} {{ end }}

View File

@ -0,0 +1,23 @@
{{/* The tags a share card needs to arrive with its picture.
One partial rather than the same five lines in three branches: the article,
the home page and a static page all share cards, and the set drifted once
already — the home page had no `twitter:image` for a while because it was
added to one branch and not the others.
Width and height are not decoration. Several clients draw the small card
instead of the large one when they would have to fetch the file to find
out how big it is, and WhatsApp in particular gives up on a slow or heavy
image rather than waiting for it. Both numbers come from the generated
card, so they cannot disagree with the file.
Takes: url, alt, width, height, type. */}}
{{ with .url }}
<meta property="og:image" content="{{ . }}">
<meta property="og:image:secure_url" content="{{ . }}">
{{ with $.alt }}<meta property="og:image:alt" content="{{ . }}">{{ end }}
{{ with $.width }}<meta property="og:image:width" content="{{ . }}">{{ end }}
{{ with $.height }}<meta property="og:image:height" content="{{ . }}">{{ end }}
{{ with $.type }}<meta property="og:image:type" content="{{ . }}">{{ end }}
<meta name="twitter:image" content="{{ . }}">
{{ end }}

View File

@ -27,9 +27,46 @@
one in config.yaml: most sites want their logo and the field exists for the one in config.yaml: most sites want their logo and the field exists for the
ones that want something else. */}} ones that want something else. */}}
{{ $fallback := or $chosen (or $brandLogo .Site.Params.defaultImage) }} {{ $fallback := or $chosen (or $brandLogo .Site.Params.defaultImage) }}
{{ $image := "" }}
{{ with .Params.image }}{{ $image = . | absURL }} {{/* The card is *generated*, not pointed at.
{{ else }}{{ with $fallback }}{{ $image = . | absURL }}{{ end }}{{ end }}
What used to go out was the original upload — a photograph off a phone,
two to five megabytes. WhatsApp fetches a preview image on a tight budget
and gives up on a file that size, so the card arrived as a title and a
link with a blank where the picture should be. That is the whole reason
`static/uploads` is mounted into `assets/` in config.yaml: Hugo copies
static files and processes asset files, and only one of those can be
resized.
A post's own photograph is filled to 1200×630 — the size every client
draws its large card at — and comes out at 80–150 KB. The fallback is
fitted rather than filled, because a wordmark cropped to a landscape card
is a wordmark with its ends cut off.
An image the pipeline cannot find — a path typed by hand, a file added
after the build — falls back to exactly what happened before: the absolute
URL, no dimensions. Nothing is worse than it was. */}}
{{ $source := or .Params.image $fallback }}
{{ $image := "" }}{{ $cardW := "" }}{{ $cardH := "" }}{{ $cardType := "" }}
{{ with $source }}
{{ $image = . | absURL }}
{{ with resources.Get (strings.TrimPrefix "/" .) }}
{{ $card := "" }}
{{ if $.Params.image }}
{{ $card = .Fill "1200x630 Center q82 jpg" }}
{{ else }}
{{/* Fitted, and in its own format: the fallback is usually the logo, and a
logo cropped to a landscape card loses its ends — while converting a
transparent PNG to JPEG puts it on a black square, because JPEG has no
alpha to put it on anything else. */}}
{{ $card = .Fit "1200x630" }}
{{ end }}
{{ $image = $card.Permalink }}
{{ $cardW = $card.Width }}{{ $cardH = $card.Height }}{{ $cardType = $card.MediaType.Type }}
{{ end }}
{{ end }}
{{ $cardAlt := cond (ne .Params.image_alt nil) .Params.image_alt .Title }}
{{ $card := dict "url" $image "alt" $cardAlt "width" $cardW "height" $cardH "type" $cardType }}
<meta name="description" content="{{ $desc }}"> <meta name="description" content="{{ $desc }}">
@ -54,10 +91,7 @@
{{ range .Translations }} {{ range .Translations }}
{{ with index $localeMap .Language.Lang }}<meta property="og:locale:alternate" content="{{ . }}">{{ end }} {{ with index $localeMap .Language.Lang }}<meta property="og:locale:alternate" content="{{ . }}">{{ end }}
{{ end }} {{ end }}
{{ with $image }} {{ partial "og-image.html" $card }}
<meta property="og:image" content="{{ . }}">
<meta property="og:image:alt" content="{{ $.Params.image_alt | default $.Title }}">
{{ end }}
<meta property="article:published_time" content="{{ .Date.Format "2006-01-02T15:04:05-07:00" }}"> <meta property="article:published_time" content="{{ .Date.Format "2006-01-02T15:04:05-07:00" }}">
<meta property="article:modified_time" content="{{ .Lastmod.Format "2006-01-02T15:04:05-07:00" }}"> <meta property="article:modified_time" content="{{ .Lastmod.Format "2006-01-02T15:04:05-07:00" }}">
{{ with .Params.author }}<meta property="article:author" content="{{ . }}">{{ end }} {{ with .Params.author }}<meta property="article:author" content="{{ . }}">{{ end }}
@ -65,7 +99,6 @@
<meta name="twitter:card" content="{{ if $image }}summary_large_image{{ else }}summary{{ end }}"> <meta name="twitter:card" content="{{ if $image }}summary_large_image{{ else }}summary{{ end }}">
<meta name="twitter:title" content="{{ .Title }}"> <meta name="twitter:title" content="{{ .Title }}">
<meta name="twitter:description" content="{{ $desc }}"> <meta name="twitter:description" content="{{ $desc }}">
{{ with $image }}<meta name="twitter:image" content="{{ . }}">{{ end }}
{{ $schema := dict {{ $schema := dict
"@context" "https://schema.org" "@context" "https://schema.org"
@ -136,11 +169,7 @@
{{/* The home page shared without a picture until there was one to use. Now {{/* The home page shared without a picture until there was one to use. Now
that an admin can upload a logo, the front page of the site is the last that an admin can upload a logo, the front page of the site is the last
place that should share as a bare link. */}} place that should share as a bare link. */}}
{{ with $image }} {{ partial "og-image.html" (merge $card (dict "alt" (partial "site-name.html" .))) }}
<meta property="og:image" content="{{ . }}">
<meta property="og:image:alt" content="{{ $.Site.Title }}">
<meta name="twitter:image" content="{{ . }}">
{{ end }}
{{/* The organisation, as a search or answer engine reads it. Everything {{/* The organisation, as a search or answer engine reads it. Everything
overridable lives in Gestión → Identidad; `areaServed` stays here because a overridable lives in Gestión → Identidad; `areaServed` stays here because a
@ -215,15 +244,11 @@
{{ range .Translations }} {{ range .Translations }}
{{ with index $localeMap .Language.Lang }}<meta property="og:locale:alternate" content="{{ . }}">{{ end }} {{ with index $localeMap .Language.Lang }}<meta property="og:locale:alternate" content="{{ . }}">{{ end }}
{{ end }} {{ end }}
{{ with $image }} {{ partial "og-image.html" $card }}
<meta property="og:image" content="{{ . }}">
<meta property="og:image:alt" content="{{ $.Params.image_alt | default $.Title }}">
{{ end }}
<meta name="twitter:card" content="{{ if $image }}summary_large_image{{ else }}summary{{ end }}"> <meta name="twitter:card" content="{{ if $image }}summary_large_image{{ else }}summary{{ end }}">
<meta name="twitter:title" content="{{ .Title }}"> <meta name="twitter:title" content="{{ .Title }}">
<meta name="twitter:description" content="{{ $desc }}"> <meta name="twitter:description" content="{{ $desc }}">
{{ with $image }}<meta name="twitter:image" content="{{ . }}">{{ end }}
{{ $schema := dict {{ $schema := dict
"@context" "https://schema.org" "@context" "https://schema.org"

View File

@ -0,0 +1,116 @@
{{/* The row of share buttons, drawn under the title and again after the text.
Four of these are ordinary links and work with scripting switched off:
WhatsApp, Facebook, Bluesky and Mastodon all accept a URL that opens their
own composer with the text already in it.
Signal and Instagram do not, and no amount of wanting changes it. Signal
has no web intent at all — it appears in the operating system's own share
sheet and nowhere else — and Instagram cannot be handed a link by anybody,
which is why every site that claims an Instagram share button is really
offering a copied link. So both call `navigator.share()`, which opens that
sheet with every installed app in it, and fall back to copying. They carry
`hidden` until share.js removes it: a button that does nothing at all is
worse than no button.
The icons are simplified marks in one visual language rather than the
official logo files. Reproducing those from memory gives something subtly
wrong, and subtly wrong looks worse than plainly simple; each carries its
name for a screen reader and in `title` for a cursor. Swapping in the real
SVGs later is one file and no other change. */}}
{{ $lang := .Site.Language.Lang }}
{{ $url := .Permalink }}
{{ $text := printf "%s — %s" .Title $url }}
{{/* Encoded once, and marked safe so it is not encoded again. Go's template
escaper treats an href as a URL and escapes it on the way out, so a value
that arrived already encoded came through as %253A and %2b — a link that
opens WhatsApp with the percent signs spelled out. */}}
{{ $encText := $text | urlquery }}
{{ $encUrl := $url | urlquery }}
{{/* Without scripting the Mastodon button needs an instance to aim at, and the
association's own is the only one this page knows. With scripting it asks
the reader for theirs instead and remembers the answer. */}}
{{ $masto := "" }}
{{ with site.Data.site }}{{ with .social }}{{ with .mastodon }}
{{ $masto = (urls.Parse .).Host }}
{{ end }}{{ end }}{{ end }}
<aside class="share" data-share
data-url="{{ $url }}"
data-title="{{ .Title }}"
data-text="{{ $text }}"
data-copied="{{ partial "t.html" (dict "key" "copied" "lang" $lang) }}"
data-ask="{{ partial "t.html" (dict "key" "askmasto" "lang" $lang) }}"
aria-label="{{ partial "t.html" (dict "key" "share" "lang" $lang) }}">
<span class="share__title">{{ partial "t.html" (dict "key" "share" "lang" $lang) }}</span>
<a class="share__btn share__btn--whatsapp" title="WhatsApp" rel="noopener"
target="_blank" href="{{ printf "https://wa.me/?text=%s" $encText | safeURL }}">
<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
<path d="M12 2a9.8 9.8 0 0 0-8.4 15l-1.3 4.6 4.8-1.3A9.8 9.8 0 1 0 12 2Zm0 1.9a7.9 7.9 0 1 1-4.1 14.6l-.4-.2-2.6.7.7-2.5-.3-.4A7.9 7.9 0 0 1 12 3.9Z"/>
<path d="M9.4 7.6c-.2-.5-.4-.5-.6-.5h-.5c-.2 0-.5.1-.8.4-.3.3-1 1-1 2.4s1 2.8 1.2 3c.1.2 2 3.2 5 4.3 2.5.9 3 .7 3.5.7.6-.1 1.8-.7 2-1.5.3-.7.3-1.3.2-1.4l-.6-.3-1.9-.9c-.3-.1-.5-.2-.7.1l-.9 1.1c-.2.2-.3.2-.6.1a7.8 7.8 0 0 1-2.3-1.4 8.6 8.6 0 0 1-1.6-2c-.2-.3 0-.4.1-.6l.4-.5.3-.5v-.5l-.9-2.1Z"/>
</svg>
<span class="share__name">WhatsApp</span>
</a>
<a class="share__btn share__btn--facebook" title="Facebook" rel="noopener"
target="_blank" href="{{ printf "https://www.facebook.com/sharer/sharer.php?u=%s" $encUrl | safeURL }}">
<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
<path d="M12 2a10 10 0 0 0-1.6 19.9v-7h-2.5V12h2.5V9.8c0-2.5 1.5-3.9 3.8-3.9l2.2.2v2.5h-1.3c-1.2 0-1.6.8-1.6 1.6V12h2.8l-.5 2.9h-2.3v7A10 10 0 0 0 12 2Z"/>
</svg>
<span class="share__name">Facebook</span>
</a>
<a class="share__btn share__btn--bluesky" title="Bluesky" rel="noopener"
target="_blank" href="{{ printf "https://bsky.app/intent/compose?text=%s" $encText | safeURL }}">
<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
<path d="M12 10.8C10.9 8.7 7.9 4.7 5.2 3.3 2.6 2 1.6 3.4 1.6 5.3c0 1.9.8 7.9 1.3 8.9.9 1.7 2.6 2 4.1 1.8l-.6.1c-2.4.4-4.5 1.3-1.7 4.4 3 3.3 4.2-.7 4.8-2.7l.5-1.9.5 1.9c.6 2 1.8 6 4.8 2.7 2.8-3.1.7-4-1.7-4.4l-.6-.1c1.5.2 3.2-.1 4.1-1.8.5-1 1.3-7 1.3-8.9 0-1.9-1-3.3-3.6-2C16.1 4.7 13.1 8.7 12 10.8Z"/>
</svg>
<span class="share__name">Bluesky</span>
</a>
<a class="share__btn share__btn--mastodon" title="Mastodon" rel="noopener"
target="_blank" data-share-mastodon
{{ if $masto }}href="{{ printf "https://%s/share?text=%s" $masto $encText | safeURL }}"{{ else }}href="#" hidden{{ end }}>
<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
<path d="M20.9 8.3c0-3.4-2.2-4.4-2.2-4.4C17.5 3.4 15.6 3.1 13.5 3h-.1c-2 0-4 .4-5.1.9 0 0-2.2 1-2.2 4.4v2.9c.1 3.4.6 6.8 3.7 7.6 1.5.4 2.7.5 3.7.4 1.8-.1 2.8-.6 2.8-.6l-.1-1.3s-1.2.4-2.6.3c-1.4 0-2.9-.1-3.1-1.9v-.5c3 .7 5.5.3 6.2.2 2-.2 3.7-1.5 3.9-2.6.3-1.8.3-4.5.3-4.5Zm-2.6 4.3h-1.6V8.7c0-.8-.3-1.2-1-1.2-.8 0-1.2.5-1.2 1.4v2H12.9v-2c0-.9-.4-1.4-1.2-1.4-.7 0-1 .4-1 1.2v3.9H9.1V8.6c0-.8.2-1.4.6-1.9.4-.4 1-.7 1.7-.7.8 0 1.4.3 1.8.9l.4.7.4-.7c.4-.6 1-.9 1.8-.9.7 0 1.3.3 1.7.7.4.5.6 1.1.6 1.9v4Z"/>
</svg>
<span class="share__name">Mastodon</span>
</a>
{{/* The two with nowhere to send a link, and the universal fallback. All
three are hidden until share.js takes the attribute off. */}}
<button class="share__btn share__btn--signal" type="button" title="Signal"
data-share-native hidden>
<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
<path d="M12 2.6a9.4 9.4 0 0 0-8.1 14.1l-1.2 3.9 4-1.1A9.4 9.4 0 1 0 12 2.6Zm0 1.9a7.5 7.5 0 1 1-3.9 13.9l-.4-.2-2.1.6.6-2-.2-.4A7.5 7.5 0 0 1 12 4.5Z"/>
</svg>
<span class="share__name">Signal</span>
</button>
<button class="share__btn share__btn--instagram" type="button" title="Instagram"
data-share-native hidden>
<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
<path d="M16.2 3H7.8A4.8 4.8 0 0 0 3 7.8v8.4A4.8 4.8 0 0 0 7.8 21h8.4a4.8 4.8 0 0 0 4.8-4.8V7.8A4.8 4.8 0 0 0 16.2 3Zm3 13.2a3 3 0 0 1-3 3H7.8a3 3 0 0 1-3-3V7.8a3 3 0 0 1 3-3h8.4a3 3 0 0 1 3 3v8.4Z"/>
<path d="M12 7.3a4.7 4.7 0 1 0 0 9.4 4.7 4.7 0 0 0 0-9.4Zm0 7.6a2.9 2.9 0 1 1 0-5.8 2.9 2.9 0 0 1 0 5.8Z"/>
<circle cx="17.1" cy="6.9" r="1.1"/>
</svg>
<span class="share__name">Instagram</span>
</button>
<button class="share__btn share__btn--copy" type="button"
title="{{ partial "t.html" (dict "key" "copylink" "lang" $lang) }}"
data-share-copy hidden>
<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
<path d="M10.6 13.4a3.6 3.6 0 0 0 5.1 0l2.9-2.9a3.6 3.6 0 0 0-5.1-5.1l-1.4 1.4 1.3 1.3 1.4-1.4a1.8 1.8 0 1 1 2.5 2.5l-2.9 2.9a1.8 1.8 0 0 1-2.5 0l-1.3 1.3Z"/>
<path d="M13.4 10.6a3.6 3.6 0 0 0-5.1 0l-2.9 2.9a3.6 3.6 0 0 0 5.1 5.1l1.4-1.4-1.3-1.3-1.4 1.4a1.8 1.8 0 1 1-2.5-2.5l2.9-2.9a1.8 1.8 0 0 1 2.5 0l1.3-1.3Z"/>
</svg>
<span class="share__name">{{ partial "t.html" (dict "key" "copylink" "lang" $lang) }}</span>
</button>
{{/* What the copy button says back. Polite rather than assertive: it
announces itself once rather than interrupting whatever is being read. */}}
<span class="share__said" role="status" aria-live="polite"></span>
</aside>

View File

@ -19,6 +19,12 @@
"noevents" (dict "es" "No hay nada en este mes." "de" "In diesem Monat ist nichts geplant." "pt-br" "Nada marcado neste mês.") "noevents" (dict "es" "No hay nada en este mes." "de" "In diesem Monat ist nichts geplant." "pt-br" "Nada marcado neste mês.")
"allevents" (dict "es" "Todos los eventos" "de" "Alle Termine" "pt-br" "Todos os eventos") "allevents" (dict "es" "Todos los eventos" "de" "Alle Termine" "pt-br" "Todos os eventos")
"ai" (dict "es" "Generado con IA" "de" "Mit KI erstellt" "pt-br" "Gerado com IA") "ai" (dict "es" "Generado con IA" "de" "Mit KI erstellt" "pt-br" "Gerado com IA")
"share" (dict "es" "Compartir" "de" "Teilen" "pt-br" "Compartilhar")
"copylink" (dict "es" "Copiar enlace" "de" "Link kopieren" "pt-br" "Copiar link")
"copied" (dict "es" "Enlace copiado" "de" "Link kopiert" "pt-br" "Link copiado")
"askmasto" (dict "es" "¿En qué servidor de Mastodon tienes tu cuenta? Por ejemplo: mastodon.social"
"de" "Auf welchem Mastodon-Server hast du dein Konto? Zum Beispiel: mastodon.social"
"pt-br" "Em qual servidor do Mastodon está a sua conta? Por exemplo: mastodon.social")
"aifull" (dict "es" "Quien lo publicó marcó este texto como generado con inteligencia artificial." "aifull" (dict "es" "Quien lo publicó marcó este texto como generado con inteligencia artificial."
"de" "Wer diesen Beitrag veröffentlicht hat, hat ihn als mit künstlicher Intelligenz erstellt gekennzeichnet." "de" "Wer diesen Beitrag veröffentlicht hat, hat ihn als mit künstlicher Intelligenz erstellt gekennzeichnet."
"pt-br" "Quem publicou marcou este texto como gerado com inteligência artificial.") "pt-br" "Quem publicou marcou este texto como gerado com inteligência artificial.")