Compare commits

...
8 Commits
Author SHA1 Message Date
Phil 22e588377f Merge branch 'feat/v2.18.3-webmention-skip-hosts' for v2.18.3 release
Build Container / build (push) Successful in 9m38s
2026-11-12 13:42:10 -07:00
PhilandClaude Opus 5.5 b9e5321df2 fix: don't send webmentions to this site or WEBMENTION_SKIP_HOSTS (v2.18.3)
Links to the site itself, and to self-hosted apps like Gitea, timed out
from inside the container and sat in the admin Log. They are now skipped
when queueing; already queued or failed ones are dropped at worker start.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 13:40:27 -07:00
Phil 52ecf0f713 Merge branch 'feat/v2.18.2-tables-width' for v2.18.2 release
Build Container / build (push) Successful in 9m38s
2026-11-12 13:31:43 -07:00
PhilandClaude Opus 5.5 5fb521e89e style: header and footer share one 60rem frame on public and admin pages (v2.18.2)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 13:28:19 -07:00
PhilandClaude Opus 5.5 bba2178496 fix: tables fill the column as a card, matching common Markdown viewers (v2.18.2)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 13:24:37 -07:00
PhilandClaude Opus 5.5 41c373f46c fix: readable tables in notes and articles; public pages 48rem wide (v2.18.2)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 13:22:43 -07:00
Phil 7158713a2a Merge branch 'feat/v2.18.1-mcp-slug-docs' for v2.18.1 release
Build Container / build (push) Successful in 9m29s
2026-11-12 13:18:52 -07:00
PhilandClaude Opus 5.5 73a68157cc docs: MCP create_note describes article URLs and title slugs (v2.18.1)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 13:10:21 -07:00
15 changed files with 286 additions and 10 deletions

No files matched your search

+3
View File
@@ -130,6 +130,9 @@ CSRF_ENABLED=true
# Background worker that verifies received webmentions, sends outgoing ones,
# and sends response notifications (v2.14.0) (default: true)
# WEBMENTION_WORKER_ENABLED=true
# Hosts never sent webmentions, comma-separated, e.g. self-hosted apps that
# don't accept them. Links to this site itself are always skipped (v2.18.3)
# WEBMENTION_SKIP_HOSTS=git.example.com,photos.example.com
# Seconds between queue checks (default: 10) and after an error (default: 60)
# WEBMENTION_POLL_INTERVAL=10
# WEBMENTION_ERROR_BACKOFF=60
+35
View File
@@ -7,6 +7,41 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [2.18.3] - 2026-11-12
### Added
- `WEBMENTION_SKIP_HOSTS`: comma-separated hosts that are never sent webmentions, for self-hosted apps that don't accept them (Gitea, say). The Settings page lists them
### Fixed
- StarPunk sent webmentions to links pointing at itself. It only takes webmentions for its posts, and its own public address can time out from inside the container, so these failed and sat in the Log. Links to this site are now skipped
- Sends to this site or a skipped host that were already queued or failed are dropped when the worker starts, so they leave the Log
## [2.18.2] - 2026-11-12
### Fixed
- Tables in notes and articles: words in cells were split mid-word (a narrow
first column read "Colo/r", "Blac/k") and cells had no padding or left
alignment. Tables now keep words whole and render as a card that fills the
column: raised background, rounded border, shaded header row, roomy cells,
sans-serif text at reading size, bold first column. Rendered tables are
wrapped in `<div class="table-wrap">`, which scrolls sideways on narrow
screens.
### Changed
- Public pages are wider: 48rem instead of 40rem (about 85 characters per
line at the reading font). Admin pages stay at 60rem.
- The site header (title, menu, search) and footer are 60rem wide on every
page, so they sit in the same place on public and admin pages; only the
content column differs.
## [2.18.1] - 2026-11-12
### Changed
- The MCP `create_note` tool says that articles live at `/article/<slug>` with a slug made from the title, so AI clients leave `slug` out unless they want a specific one
## [2.18.0] - 2026-11-12
A tidier admin area.
@@ -0,0 +1,9 @@
# v2.18.1: MCP create_note describes article URLs and slugs
Documentation-only follow-up to ADR-077 (v2.17.x). The MCP `create_note`
tool description now says that a title makes the post an article at
`/article/<slug>`, that articles get their slug from the title and other
notes from the time, and that `slug` is only needed for a specific slug.
AI clients read tool descriptions to decide which arguments to send, so
this keeps them from making up a slug the title would already give.
No behaviour change.
@@ -0,0 +1,34 @@
# v2.18.3: Don't send webmentions to this site or skipped hosts
## Why
The admin Log showed two sends that could never succeed, both "timed out":
- a note linking to `https://starpunk.thesatelliteoflove.com/` (this site),
- a note linking to a Gitea repository on `git.thesatelliteoflove.com`.
From inside the container both names resolve to the server's public address,
which isn't reachable from there (no NAT hairpinning). Routing them to the
internal proxy with `extra_hosts` wouldn't help: the SSRF guard blocks
private addresses. And neither target wants the webmention: StarPunk only
takes webmentions for its posts, and Gitea advertises no endpoint.
## What changed
| Area | Change |
|---|---|
| Config | `WEBMENTION_SKIP_HOSTS` (comma-separated, lowercased) |
| Sender | `webmention_sender.skipped_hosts(config)` = `SITE_URL`'s host + the setting; `is_skipped(url, hosts)` matches the exact host, any port. `queue_webmentions_for_note` drops those links before the 10-link cap, and from re-sends on update |
| Worker | `_send_webmention` marks a skipped target `no_endpoint` without fetching it (rows queued before the setting changed). At startup `_drop_skipped_targets` does the same for `pending` and `failed` rows, so they leave the Log |
| Settings | A Webmentions section lists the skipped hosts |
`no_endpoint` with `last_error` = "Not sent: …" is used rather than a new
status because `webmention_queue.status` has a CHECK constraint; changing it
would mean rebuilding the table. The Log only lists `pending` and `failed`.
Exact host matching is deliberate: skipping `thesatelliteoflove.com` should
not skip its subdomains, or the reverse.
## Tests
`tests/test_webmention_skip_hosts.py`.
+2 -2
View File
@@ -468,5 +468,5 @@ def create_app(config=None):
# Package version (Semantic Versioning 2.0.0)
# See docs/standards/versioning-strategy.md for details
__version__ = "2.18.0"
__version_info__ = (2, 18, 0)
__version__ = "2.18.3"
__version_info__ = (2, 18, 3)
+4
View File
@@ -106,6 +106,10 @@ def load_config(app, config_override=None):
# Webmention configuration (v1.6.0)
app.config["WEBMENTION_ENABLED"] = os.getenv("WEBMENTION_ENABLED", "true").lower() == "true"
# Hosts never sent webmentions, besides this site itself (v2.18.3)
app.config["WEBMENTION_SKIP_HOSTS"] = [
h.strip().lower() for h in os.getenv("WEBMENTION_SKIP_HOSTS", "").split(",") if h.strip()
]
# WebSub (v2.10.0, ADR-071): built-in hub unless WEBSUB_HUB_URL names another
app.config["WEBSUB_ENABLED"] = os.getenv("WEBSUB_ENABLED", "true").lower() == "true"
+5 -3
View File
@@ -232,9 +232,11 @@ def register_tools(server: MCPServer, app: Flask) -> None:
) -> dict:
"""Create a note (Markdown). It is a draft unless draft is false;
publishing makes it public and crossposts it to the syndicate_to
targets. A title makes it an article; summary is its short summary,
shown on the homepage and in feeds and crossposts. At most one of like_of,
repost_of and bookmark_of. published_at is an ISO 8601 date."""
targets. A title makes it an article, at /article/<slug>; summary is its
short summary, shown on the homepage and in feeds and crossposts. The
slug is made from the title for articles and from the time for other
notes, so leave slug out unless a specific one is wanted. At most one of
like_of, repost_of and bookmark_of. published_at is an ISO 8601 date."""
info = _token_info()
_require(info, "create", "draft")
+3 -1
View File
@@ -62,7 +62,9 @@ ALLOWED_ATTRIBUTES = {
def render_markdown(text: str) -> str:
"""Note Markdown (or HTML) to sanitized HTML"""
html = markdown.markdown(text, extensions=MARKDOWN_EXTENSIONS)
return nh3.clean(html, tags=ALLOWED_TAGS, attributes=ALLOWED_ATTRIBUTES)
html = nh3.clean(html, tags=ALLOWED_TAGS, attributes=ALLOWED_ATTRIBUTES)
# A wrapper lets a table fill the column yet scroll sideways when too wide (v2.18.2)
return re.sub(r"<table\b", '<div class="table-wrap"><table', html).replace("</table>", "</table></div>")
# Likes, reposts and bookmarks (v2.5.0, v2.9.0)
+4 -1
View File
@@ -728,7 +728,10 @@ def _notify_status() -> dict:
@require_auth
def settings():
"""Site settings: notifications (v2.18.0). Template: templates/admin/settings.html"""
return render_template("admin/settings.html", notify=_notify_status(), user_me=g.me)
from starpunk.webmention_sender import skipped_hosts
return render_template("admin/settings.html", notify=_notify_status(), user_me=g.me,
skip_hosts=sorted(skipped_hosts(current_app.config)))
@bp.route("/log")
+27 -2
View File
@@ -22,6 +22,22 @@ from urllib.parse import urlparse
logger = logging.getLogger(__name__)
SKIPPED_NOTE = "Not sent: links to this site and WEBMENTION_SKIP_HOSTS are skipped"
def skipped_hosts(config) -> set[str]:
"""Hosts that never get webmentions: this site and WEBMENTION_SKIP_HOSTS (v2.18.3)"""
hosts = set(config.get("WEBMENTION_SKIP_HOSTS") or [])
site = urlparse(config.get("SITE_URL") or "").hostname
if site:
hosts.add(site.lower())
return hosts
def is_skipped(url: str, hosts: set[str]) -> bool:
"""True if url is on one of the skipped hosts (exact host, any port)"""
return (urlparse(url).hostname or "").lower() in hosts
def extract_links_from_html(html_content: str, exclude_code_blocks: bool = True) -> list[str]:
"""
@@ -189,17 +205,26 @@ def queue_webmentions_for_note(
Returns:
Number of webmentions queued
"""
# Links to this site or a skipped host are dropped before the cap (v2.18.3):
# this site only takes webmentions for its posts, and its own public
# address may not be reachable from inside the container
from flask import current_app, has_app_context
hosts = skipped_hosts(current_app.config) if has_app_context() else set()
def wanted(urls):
return [u for u in urls if not is_skipped(u, hosts)]
# Targets for the current content: reply target first, then links in
# document order, at most 10
links = extract_links_from_html(content_html) if content_html else []
current = _dedupe(([in_reply_to] if in_reply_to else []) + links)[:10]
current = wanted(_dedupe(([in_reply_to] if in_reply_to else []) + links))[:10]
if old_content_html is not None:
# Update (spec 3.1.4): also re-send to every target notified before,
# and to links the edit removed, so they can update or remove the
# mention. These are not capped.
removed = [u for u in extract_links_from_html(old_content_html) if u not in links]
target_urls = _dedupe(current + previous_targets(db_path, note_id) + removed)
target_urls = _dedupe(current + wanted(previous_targets(db_path, note_id) + removed))
else:
target_urls = current
+43
View File
@@ -205,6 +205,40 @@ class WebmentionWorker(threading.Thread):
except Exception as e:
logger.error(f"Failed to cleanup orphaned items: {e}")
self._drop_skipped_targets()
def _skipped_hosts(self) -> set:
from starpunk.webmention_sender import skipped_hosts
return skipped_hosts(self.app.config) if self.app is not None else set()
def _drop_skipped_targets(self):
"""
Stop sending to this site and WEBMENTION_SKIP_HOSTS (v2.18.3)
Queued or failed sends to those hosts are set to 'no_endpoint' (nothing
to send to), so they leave the retry queue and the admin Log.
"""
from starpunk.webmention_sender import SKIPPED_NOTE, is_skipped
hosts = self._skipped_hosts()
if not hosts:
return
try:
conn = sqlite3.connect(self.db_path)
rows = conn.execute(
"SELECT id, target_url FROM webmention_queue WHERE status IN ('pending', 'failed')"
).fetchall()
ids = [(SKIPPED_NOTE, i) for i, url in rows if is_skipped(url, hosts)]
if ids:
conn.executemany(
"UPDATE webmention_queue SET status = 'no_endpoint', last_error = ? WHERE id = ?",
ids)
conn.commit()
logger.info(f"Dropped {len(ids)} queued webmention(s) to skipped hosts")
conn.close()
except Exception as e:
logger.error(f"Failed to drop skipped webmention targets: {e}")
def _process_pending_validations(self) -> int:
"""
Process pending incoming webmentions
@@ -583,6 +617,15 @@ class WebmentionWorker(threading.Thread):
conn.commit()
conn.close()
from starpunk.webmention_sender import SKIPPED_NOTE, is_skipped
if is_skipped(target_url, self._skipped_hosts()):
conn = sqlite3.connect(self.db_path)
conn.execute("UPDATE webmention_queue SET status = 'no_endpoint', last_error = ? WHERE id = ?",
(SKIPPED_NOTE, queue_id))
conn.commit()
conn.close()
return
try:
# Discover endpoint if not cached
endpoint = cached_endpoint
+13 -1
View File
@@ -8,7 +8,7 @@
--font-reading: Charter, 'Bitstream Charter', 'Sitka Text', Cambria, 'Noto Serif', Georgia, serif;
--font-mono: ui-monospace, 'SF Mono', Monaco, Consolas, 'Liberation Mono', monospace;
--spacing-xs: 0.25rem; --spacing-sm: 0.5rem; --spacing-md: 1rem; --spacing-lg: 2rem; --spacing-xl: 4rem;
--max-width: 40rem; --border-radius: 6px;
--max-width: 48rem; --frame-width: 60rem; --border-radius: 6px;
}
@media (prefers-color-scheme: dark) {
@@ -40,6 +40,9 @@ pre code { padding: 0; background: none; }
/* Page frame */
.site-header, main, .site-footer { width: 100%; max-width: var(--max-width); margin-left: auto; margin-right: auto; }
/* Header and footer share one width on every page, public and admin (v2.18.2);
only the content column (main) differs: 48rem to read, 60rem for admin tables. */
.site-header, .site-footer { max-width: var(--frame-width); }
main { flex: 1; margin-bottom: var(--spacing-xl); }
.site-header {
@@ -91,6 +94,15 @@ main { flex: 1; margin-bottom: var(--spacing-xl); }
.e-content blockquote { margin: 0 0 var(--spacing-md); padding-left: var(--spacing-md); border-left: 3px solid var(--color-border); color: var(--color-text-light); }
.e-content ul, .e-content ol { margin: 0 0 var(--spacing-md) 1.25rem; }
.e-content img { max-width: 100%; height: auto; }
/* Tables (v2.18.2): a card that fills the column, in the page's sans font at
the reading size; scrolls sideways when wider than the column. Words in
cells are never split (overflow-wrap: anywhere above is for long URLs in
prose; in a cell it squeezed columns to a few letters). */
.e-content .table-wrap { overflow-x: auto; margin: 0 0 var(--spacing-md); background: var(--color-bg-alt); border: 1px solid var(--color-border); border-radius: var(--border-radius); }
.e-content table { width: 100%; border-collapse: collapse; font-family: var(--font-body); font-size: 1.0625rem; line-height: 1.6; }
.e-content th, .e-content td { padding: 0.9rem 1.25rem; text-align: left; vertical-align: top; overflow-wrap: normal; }
.e-content th { font-weight: 600; white-space: nowrap; background: color-mix(in srgb, var(--color-text) 6%, var(--color-bg-alt)); }
.e-content td:first-child { font-weight: 600; }
.e-content h1, .e-content h2, .e-content h3 { font-family: var(--font-body); }
.reaction { margin-bottom: var(--spacing-sm); font-size: 0.9375rem; color: var(--color-text-light); overflow-wrap: anywhere; }
.reaction-verb { font-weight: 600; margin-right: 0.25rem; }
+7
View File
@@ -19,5 +19,12 @@
<p>Off. Set <code>NOTIFY_URLS</code> to one or more Apprise URLs to be notified of new responses.</p>
{% endif %}
</section>
{# Outgoing webmentions (v2.18.3) #}
<section>
<h3>Webmentions</h3>
<p>Never sent to: {% for h in skip_hosts %}<code>{{ h }}</code>{{ ", " if not loop.last }}{% endfor %}.
This site is always skipped; add others with <code>WEBMENTION_SKIP_HOSTS</code>.</p>
</section>
</div>
{% endblock %}
+9
View File
@@ -0,0 +1,9 @@
def test_tables_get_a_scroll_wrapper():
"""v2.18.2: tables are wrapped so they can fill the column and scroll sideways"""
from starpunk.models import render_markdown
html = render_markdown("| Color | Why |\n|---|---|\n| Black | Removal |\n\nAfter")
assert html.startswith('<div class="table-wrap"><table>') and "</table></div>" in html
assert "<p>After</p>" in html
+88
View File
@@ -0,0 +1,88 @@
"""
Webmentions are never sent to this site or WEBMENTION_SKIP_HOSTS (v2.18.3)
From inside the container the site's own public address can time out, and
self-hosted apps like Gitea don't take webmentions, so these sends only
failed and stayed in the admin Log.
"""
import sqlite3
from starpunk.webmention_sender import (
SKIPPED_NOTE, is_skipped, queue_webmentions_for_note, skipped_hosts)
from starpunk.webmention_worker import WebmentionWorker
SKIP = "git.example.com"
def queued(db_path):
conn = sqlite3.connect(db_path)
rows = conn.execute("SELECT target_url, status, last_error FROM webmention_queue ORDER BY id").fetchall()
conn.close()
return rows
def test_hosts_include_this_site(app):
app.config["WEBMENTION_SKIP_HOSTS"] = [SKIP]
hosts = skipped_hosts(app.config)
assert hosts == {"localhost", SKIP}
assert is_skipped("https://GIT.example.com:443/phil/x", hosts)
assert not is_skipped("https://example.com/", hosts) # exact host only
def test_links_to_skipped_hosts_are_not_queued(app):
app.config["WEBMENTION_SKIP_HOSTS"] = [SKIP]
html = "".join(f'<p><a href="{u}">x</a></p>' for u in [
"http://localhost:5000/note/other", f"https://{SKIP}/phil/StarPunk"]
+ [f"https://site{i}.example/" for i in range(10)])
with app.app_context():
n = queue_webmentions_for_note(app.config["DATABASE_PATH"], 1, "http://localhost:5000/note/a",
html, in_reply_to="http://localhost:5000/note/b")
targets = [t for t, _, _ in queued(app.config["DATABASE_PATH"])]
assert n == 10 and targets == [f"https://site{i}.example/" for i in range(10)] # skipped ones don't use the cap
def test_worker_drops_queued_and_failed_sends(app):
app.config["WEBMENTION_SKIP_HOSTS"] = [SKIP]
db_path = app.config["DATABASE_PATH"]
conn = sqlite3.connect(db_path)
conn.executemany(
"INSERT INTO webmention_queue (source_url, target_url, status, last_error) VALUES (?, ?, ?, ?)",
[("http://localhost:5000/note/1", f"https://{SKIP}/phil/StarPunk", "failed", "timed out"),
("http://localhost:5000/note/1", "http://localhost:5000/", "pending", "timed out"),
("http://localhost:5000/note/1", "https://example.org/post", "failed", "timed out"),
("http://localhost:5000/note/2", "http://localhost:5000/x", "sent", None)])
conn.commit()
conn.close()
WebmentionWorker(app, db_path=db_path, site_url=app.config["SITE_URL"])._drop_skipped_targets()
assert [(s, e) for _, s, e in queued(db_path)] == [
("no_endpoint", SKIPPED_NOTE), ("no_endpoint", SKIPPED_NOTE),
("failed", "timed out"), # other sites are left alone
("sent", None)]
def test_worker_skips_without_fetching(app):
db_path = app.config["DATABASE_PATH"]
conn = sqlite3.connect(db_path)
conn.execute("INSERT INTO webmention_queue (source_url, target_url, status) VALUES (?, ?, 'pending')",
("http://localhost:5000/note/1", "http://localhost:5000/"))
conn.commit()
(queue_id,) = conn.execute("SELECT id FROM webmention_queue").fetchone()
conn.close()
worker = WebmentionWorker(app, db_path=db_path, site_url=app.config["SITE_URL"])
worker._discover_endpoint = lambda url: (_ for _ in ()).throw(AssertionError("fetched"))
worker._send_webmention(queue_id, "http://localhost:5000/note/1", "http://localhost:5000/", None, 0)
assert queued(db_path)[0][1:] == ("no_endpoint", SKIPPED_NOTE)
def test_settings_page_lists_skipped_hosts(app, client):
from starpunk.auth import create_session
app.config["WEBMENTION_SKIP_HOSTS"] = [SKIP]
with app.test_request_context():
client.set_cookie("starpunk_session", create_session(app.config["ADMIN_ME"]))
html = client.get("/admin/settings").data.decode()
assert f"<code>{SKIP}</code>" in html and "<code>localhost</code>" in html