Commit 6e2c9856b9
Verified · cmc
Layout: unified · split
build.py +8 −3
| @@ -326,13 +326,18 @@ def rewrite_img_urls(build_dir=".build"): | ||
| 326 | 326 | |
| 327 | 327 | Requires the server to serve /var/www/img/ at /img/ on the cleberg.net vhost |
| 328 | 328 | (e.g. `ln -s /var/www/img /var/www/cleberg.net/img`). |
| 329 | ||
| 330 | The pattern tolerates a stray number of slashes after the scheme | |
| 331 | (https:/img, https:///img, ...) so a typo in the org source can't silently | |
| 332 | slip through un-rewritten and ship a broken cross-origin URL. | |
| 329 | 333 | """ |
| 334 | pattern = re.compile(r"https:/+img\.cleberg\.net/") | |
| 330 | 335 | count = 0 |
| 331 | 336 | for html in Path(build_dir).rglob("*.html"): |
| 332 | 337 | text = html.read_text(encoding="utf-8") |
| 333 | new_text = text.replace("https://img.cleberg.net/", "/img/") | |
| 334 | if new_text != text: | |
| 335 | count += text.count("https://img.cleberg.net/") | |
| 338 | new_text, n = pattern.subn("/img/", text) | |
| 339 | if n: | |
| 340 | count += n | |
| 336 | 341 | html.write_text(new_text, encoding="utf-8") |
| 337 | 342 | print(f"Rewrote {count} img.cleberg.net references to /img/") |
| 338 | 343 | |
content/blog/2023-01-05-mass-unlike-tumblr-posts.org +1 −1
| @@ -58,7 +58,7 @@ this (this is in Firefox, Chromium should be similar): | ||
| 58 | 58 | |
| 59 | 59 | #+caption: Firefox Dev Tools |
| 60 | 60 | #+attr_html: :alt Firefox Dev Tools' Console tab will allow you to paste this command. |
| 61 | [[https:///img.cleberg.net/blog/20230105-mass-unlike-tumblr-posts/dev_console.webp]] | |
| 61 | [[https://img.cleberg.net/blog/20230105-mass-unlike-tumblr-posts/dev_console.webp]] | |
| 62 | 62 | |
| 63 | 63 | All you need to do is paste the following snippet into the dev console. |
| 64 | 64 | This code will collect all unlike buttons (=elements=) and then click |