afterpython 0.5.2__py3-none-any.whl → 0.5.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- afterpython/builders/seo.py +27 -0
- afterpython/templates/ci-workflow-template.yml +2 -2
- afterpython/templates/pre-commit-config-template.yaml +1 -1
- {afterpython-0.5.2.dist-info → afterpython-0.5.4.dist-info}/METADATA +7 -7
- {afterpython-0.5.2.dist-info → afterpython-0.5.4.dist-info}/RECORD +7 -7
- {afterpython-0.5.2.dist-info → afterpython-0.5.4.dist-info}/WHEEL +1 -1
- {afterpython-0.5.2.dist-info → afterpython-0.5.4.dist-info}/entry_points.txt +0 -0
afterpython/builders/seo.py
CHANGED
|
@@ -10,6 +10,9 @@ generator:
|
|
|
10
10
|
- internal links rewritten to that canonical form, so `/doc/quickstart` (301 on
|
|
11
11
|
GitHub Pages) becomes `/doc/quickstart/`
|
|
12
12
|
- `noindex` on the SPA fallback (200.html) and 404.html
|
|
13
|
+
- absolute `og:image`/`twitter:image` URLs, plus a large-image `twitter:card`
|
|
14
|
+
when missing, so link previews (X, Slack, LinkedIn) show the thumbnail:
|
|
15
|
+
crawlers ignore relative image paths like `/thumbnail.png`
|
|
13
16
|
- sitemap.xml listing every indexable page, plus a robots.txt pointing to it
|
|
14
17
|
"""
|
|
15
18
|
|
|
@@ -20,6 +23,7 @@ import posixpath
|
|
|
20
23
|
import re
|
|
21
24
|
from functools import partial
|
|
22
25
|
from pathlib import Path, PurePosixPath
|
|
26
|
+
from urllib.parse import urljoin
|
|
23
27
|
from xml.sax.saxutils import escape
|
|
24
28
|
|
|
25
29
|
import click
|
|
@@ -40,6 +44,13 @@ _META_REFRESH = re.compile(r"<meta[^>]*http-equiv=[\"']?refresh", re.IGNORECASE)
|
|
|
40
44
|
_HREF = re.compile(
|
|
41
45
|
r"""(\shref=)(["'])(?![a-zA-Z][\w+.-]*:|#)([^"']+)\2""", re.IGNORECASE
|
|
42
46
|
)
|
|
47
|
+
# content of an og:image / twitter:image meta tag (property/name before content,
|
|
48
|
+
# as both SvelteKit and MyST write it)
|
|
49
|
+
_SOCIAL_IMAGE = re.compile(
|
|
50
|
+
r"""(<meta[^>]*?(?:property|name)=["']?(?:og|twitter):image["']?[^>]*?\scontent=)(["'])([^"']+)\2""",
|
|
51
|
+
re.IGNORECASE,
|
|
52
|
+
)
|
|
53
|
+
_TWITTER_CARD = re.compile(r"<meta[^>]*name=[\"']?twitter:card", re.IGNORECASE)
|
|
43
54
|
|
|
44
55
|
|
|
45
56
|
def _canonical_path(rel: PurePosixPath) -> str:
|
|
@@ -109,6 +120,13 @@ def _rewrite_href(
|
|
|
109
120
|
return f"{prefix}{quote}{new_path}{sep}{rest}{quote}"
|
|
110
121
|
|
|
111
122
|
|
|
123
|
+
def _absolute_image(match: re.Match, page_url: str) -> str:
|
|
124
|
+
"""Resolve an og:image/twitter:image URL against the page's own URL."""
|
|
125
|
+
prefix, quote, url = match.group(1), match.group(2), match.group(3)
|
|
126
|
+
absolute = urljoin(page_url, html.unescape(url))
|
|
127
|
+
return f"{prefix}{quote}{html.escape(absolute)}{quote}"
|
|
128
|
+
|
|
129
|
+
|
|
112
130
|
def _split_url(url: str) -> tuple[str, str, str]:
|
|
113
131
|
"""Split '/a/b?x#y' into ('/a/b', '?', 'x#y')."""
|
|
114
132
|
for i, ch in enumerate(url):
|
|
@@ -173,6 +191,15 @@ def build_seo(base_path: str = ""):
|
|
|
173
191
|
),
|
|
174
192
|
text,
|
|
175
193
|
)
|
|
194
|
+
# link previews need absolute image URLs; already absolute ones pass through
|
|
195
|
+
page_url = site_root + base_path + page_path
|
|
196
|
+
text = _SOCIAL_IMAGE.sub(partial(_absolute_image, page_url=page_url), text)
|
|
197
|
+
# MyST pages only have og:image: without a card type X shows no image
|
|
198
|
+
head = _HEAD_OPEN.search(text)
|
|
199
|
+
if head and _SOCIAL_IMAGE.search(text) and not _TWITTER_CARD.search(text):
|
|
200
|
+
tag = '<meta name="twitter:card" content="summary_large_image">'
|
|
201
|
+
text = text[: head.end()] + tag + text[head.end() :]
|
|
202
|
+
|
|
176
203
|
# a shadowed x/index.html points at its x.html twin
|
|
177
204
|
canonical_url = (
|
|
178
205
|
site_root + base_path + canonical_by_path.get(page_path, page_path)
|
|
@@ -116,7 +116,7 @@ jobs:
|
|
|
116
116
|
- name: Set up pixi
|
|
117
117
|
uses: prefix-dev/setup-pixi@v0.11.3
|
|
118
118
|
with:
|
|
119
|
-
pixi-version: v0.
|
|
119
|
+
pixi-version: v0.85.0
|
|
120
120
|
cache: true
|
|
121
121
|
# install (and cache) only the environment this matrix run tests
|
|
122
122
|
environments: ${{ matrix.environment }}
|
|
@@ -241,7 +241,7 @@ jobs:
|
|
|
241
241
|
if: steps.ty.outputs.enabled == 'true' && hashFiles('pixi.toml') != ''
|
|
242
242
|
uses: prefix-dev/setup-pixi@v0.11.3
|
|
243
243
|
with:
|
|
244
|
-
pixi-version: v0.
|
|
244
|
+
pixi-version: v0.85.0
|
|
245
245
|
cache: true
|
|
246
246
|
environments: default
|
|
247
247
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: afterpython
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.4
|
|
4
4
|
Summary: CLI tool to streamline Python package maintenance and generate a dedicated project website
|
|
5
5
|
Keywords: package-maintenance,project-website,static-site-generator,developer-tools,documentation,cli-tool,ci/cd,mystmd,semantic-release,python-packaging
|
|
6
6
|
Author: Stephen Yau
|
|
@@ -16,21 +16,21 @@ Classifier: Programming Language :: Python :: 3.14
|
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.15
|
|
17
17
|
Requires-Dist: click>=8.5.1
|
|
18
18
|
Requires-Dist: trogon>=0.6.0
|
|
19
|
-
Requires-Dist: httpx2>=2.
|
|
19
|
+
Requires-Dist: httpx2>=2.17.0
|
|
20
20
|
Requires-Dist: tomlkit>=0.15.2
|
|
21
21
|
Requires-Dist: ruamel-yaml>=0.19.1
|
|
22
22
|
Requires-Dist: gitpython>=3.2.1
|
|
23
23
|
Requires-Dist: python-dotenv>=1.2.4
|
|
24
24
|
Requires-Dist: pyproject-metadata>=0.12.1
|
|
25
25
|
Requires-Dist: jupytext>=1.19.6
|
|
26
|
-
Requires-Dist: mystmd>=1.
|
|
26
|
+
Requires-Dist: mystmd>=1.15.0
|
|
27
27
|
Requires-Dist: pdoc>=16.0.0
|
|
28
|
-
Requires-Dist: ruff>=0.17.
|
|
29
|
-
Requires-Dist: prek>=0.
|
|
30
|
-
Requires-Dist: ty>=0.0
|
|
28
|
+
Requires-Dist: ruff>=0.17.6
|
|
29
|
+
Requires-Dist: prek>=0.6.0
|
|
30
|
+
Requires-Dist: ty>=1.0.0
|
|
31
31
|
Requires-Dist: git-cliff>=2.14.2
|
|
32
32
|
Requires-Dist: questionary>=2.1.1
|
|
33
|
-
Requires-Dist: marimo[recommended,lsp]>=0.
|
|
33
|
+
Requires-Dist: marimo[recommended,lsp]>=0.26.0 ; extra == 'marimo'
|
|
34
34
|
Requires-Python: >=3.13
|
|
35
35
|
Project-URL: homepage, https://afterpython.afterpython.org
|
|
36
36
|
Project-URL: repository, https://github.com/AfterPythonOrg/afterpython
|
|
@@ -15,7 +15,7 @@ afterpython/builders/marimo_content.py,sha256=NEsvgomB8Dc90iirxsMMc2m0eXDemc05Pt
|
|
|
15
15
|
afterpython/builders/marimo_notebook.py,sha256=MwcXu5fz5Mvf3-SR_o6phw-UNwDz12IAH3txiM0yoeM,6662
|
|
16
16
|
afterpython/builders/markdown.py,sha256=0ExfRqvOTWsgUkAVaGGNkiNDtNedRr7JR1yTGxpbsmA,8736
|
|
17
17
|
afterpython/builders/metadata.py,sha256=ms17MJ4QD2PNtyDwQAPRTpFs-qBjT-1iKuIGUOjAseY,4042
|
|
18
|
-
afterpython/builders/seo.py,sha256=
|
|
18
|
+
afterpython/builders/seo.py,sha256=hzYDfnLSFPsbBJEJ8iPrSYqN-QNVzCn6IaB2BIjUrME,9867
|
|
19
19
|
afterpython/builders/site_data.py,sha256=29p2Hg1RBraZLd9l4jofvCq_QT43ny209-2TP5MDQBU,7133
|
|
20
20
|
afterpython/builders/url_md.py,sha256=MfXSy0f44J72OlHASir-Xscqq1onA10vtqUO_L4b1xM,3949
|
|
21
21
|
afterpython/cli/__init__.py,sha256=G4AB-rllhmr7tURFc5cXJfkjZZ2bXtMBg3oy4zUGEFw,84
|
|
@@ -47,7 +47,7 @@ afterpython/main.py,sha256=w0z6mTib3u4p2HxMrk-tIJlZtur7uRaqsbE0ewlYlSs,490
|
|
|
47
47
|
afterpython/pcu.py,sha256=nfdY2uKgOxHQ1AqUN9Y-L5BxDLd7NiuZf3tt_ef2wvA,6500
|
|
48
48
|
afterpython/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
49
49
|
afterpython/templates/afterpython-template.toml,sha256=pUGrLa4SwGwSq0Fv0W6SYXgq9WW8MCKIyW_MCGXYWAI,1946
|
|
50
|
-
afterpython/templates/ci-workflow-template.yml,sha256=
|
|
50
|
+
afterpython/templates/ci-workflow-template.yml,sha256=NGOgeCD683xBNbyBNr6WlV3Flkp2yfBp4CknStLlzdc,8943
|
|
51
51
|
afterpython/templates/cliff-template.toml,sha256=HVemOBXIAvxz_8IMMAUcSRqYVmC0etfHleVeTG6woHg,5248
|
|
52
52
|
afterpython/templates/dependabot-template.yml,sha256=CBQEgh8EsXw2X7IqzGtFI7lVT9liF6PW4DvGLB0X2LY,1136
|
|
53
53
|
afterpython/templates/deploy-workflow-template.yml,sha256=n98miM10UUG1vkPATTGSP2QZQoJxvH5LqXnYhbF5Sbw,2858
|
|
@@ -56,7 +56,7 @@ afterpython/templates/pdoc/frame.html.jinja2,sha256=994F5YQODCtePKd8gbe-AvwFlIzM
|
|
|
56
56
|
afterpython/templates/pdoc/module.html.jinja2,sha256=W8LBbvbYmeNucqAQzn-s6vxelEHbcxeTnjBj7JX-95w,648
|
|
57
57
|
afterpython/templates/pdoc/syntax-highlighting.css,sha256=RqxTpVlTYuevLeGAUQbOJzK5UiVsQBhZfNSExvgmHag,10552
|
|
58
58
|
afterpython/templates/pdoc/theme.css,sha256=Qf8GHLKJryY8EBJBxreAGjSoUTG73PDkYTwlGFMO7eI,904
|
|
59
|
-
afterpython/templates/pre-commit-config-template.yaml,sha256=
|
|
59
|
+
afterpython/templates/pre-commit-config-template.yaml,sha256=nCNIek3jcUM89Q1XsiQgcGn9zmkOIMDb8RDKTsgi7tQ,1995
|
|
60
60
|
afterpython/templates/release-workflow-template.yml,sha256=9vd9C3-pWOHhA5WWgSG4PuH4bCBZs7EWmCc1kDIIVJM,4150
|
|
61
61
|
afterpython/templates/ruff-template.toml,sha256=IU33i84L7IhcLFYZ7Cfdg8EVlpq6YVAQJ3vLQGLXOxk,1316
|
|
62
62
|
afterpython/templates/ty-template.toml,sha256=8Z5jTnedzrNBgPaWYHY0RSVdXfg_SeNt1HO1OLnSA7E,666
|
|
@@ -69,7 +69,7 @@ afterpython/tools/prek.py,sha256=NEEGf8alTt9MIelAJ8yxWD-V4mnM_pJ7oHgVQG8pbzo,354
|
|
|
69
69
|
afterpython/tools/pyproject.py,sha256=Slhxo-Z9M7Gn9ZGL2BKmbPONpDgAJ1g33TdiulxwEyQ,3700
|
|
70
70
|
afterpython/utils.py,sha256=JyNFhanWllmuE3Ax5URi6_UxVgM9GsqgGwceg4PbFlo,12572
|
|
71
71
|
afterpython/version.py,sha256=hihRV1S-gc1m46OaXD32ikkEkqzs-Gtq7AcAqOQV-wY,1603
|
|
72
|
-
afterpython-0.5.
|
|
73
|
-
afterpython-0.5.
|
|
74
|
-
afterpython-0.5.
|
|
75
|
-
afterpython-0.5.
|
|
72
|
+
afterpython-0.5.4.dist-info/WHEEL,sha256=kiPuyMTIXtn3KwIlb6zIkrxfbMkdQGyzN-kjAsvva48,81
|
|
73
|
+
afterpython-0.5.4.dist-info/entry_points.txt,sha256=roa0PDgBueM1JPbRG0G2OSxzaN394OUL_oS9iEwVLBc,80
|
|
74
|
+
afterpython-0.5.4.dist-info/METADATA,sha256=1QhAbRurQsrN7CMGrJMku_yHEJVUfRu6z3K-pMR_Afs,6414
|
|
75
|
+
afterpython-0.5.4.dist-info/RECORD,,
|
|
File without changes
|