[PR #191] [MERGED] [downloader] Link attachments in post.html and skip unfinished uploads #189

Closed
opened 2026-10-13 19:48:34 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Glitchy-Sheep/boosty-downloader/pull/191
Author: @Glitchy-Sheep
Created: 9/14/2026
Status: ✅ Merged
Merged: 9/15/2026
Merged by: @Glitchy-Sheep

Base: main ← Head: fix/attachments-on-page


📝 Commits (4)

  • ef70045 [api] Skip file attachments the author has not finished uploading
  • ce99e0b [downloader] Link attachments in post.html
  • c945d28 [html] Keep a styled heading in one piece and render line breaks in text
  • 74850b9 [html] Show the video title and tidy the page templates

📊 Changes

24 files changed (+320 additions, -67 deletions)

View changed files

📝 CHANGELOG.md (+11 -0)
📝 boosty_downloader/application/mappers/html_converter.py (+6 -0)
📝 boosty_downloader/application/mappers/link_header_text.py (+22 -1)
📝 boosty_downloader/application/mappers/post_mapper.py (+3 -0)
📝 boosty_downloader/application/use_cases/download_single_post.py (+7 -5)
📝 boosty_downloader/cli/commands/download.py (+2 -2)
📝 boosty_downloader/infrastructure/boosty_api/models/post/post_data_types/post_data_file.py (+3 -0)
📝 boosty_downloader/infrastructure/html_generator/models.py (+0 -4)
📝 boosty_downloader/infrastructure/html_generator/renderer.py (+6 -2)
📝 boosty_downloader/infrastructure/html_generator/templates/audio.html (+1 -1)
📝 boosty_downloader/infrastructure/html_generator/templates/base.html (+8 -9)
📝 boosty_downloader/infrastructure/html_generator/templates/file.html (+1 -1)
📝 boosty_downloader/infrastructure/html_generator/templates/image.html (+1 -1)
📝 boosty_downloader/infrastructure/html_generator/templates/text.html (+10 -8)
📝 boosty_downloader/infrastructure/html_generator/templates/video.html (+9 -4)
📝 docs/concepts/boosty/download-flow.md (+1 -1)
📝 test/e2e/download_flow_test.py (+6 -0)
📝 test/fixtures/rendered_post.html (+25 -21)
📝 test/unit/download_plan/download_plan_test.py (+6 -2)
📝 test/unit/html_generator/html_templates_test.py (+23 -2)

...and 4 more files

📄 Description

📝 Summary

Audit stage 5, block 1 of 4 (mappers and render): attachments reach the page, unfinished uploads stop failing posts, and two text rendering losses are fixed.

🔧 What changes

Fixed

  • Attachments downloaded into files/, but post.html never mentioned them. Every file that downloaded is now a link on its own line at its place in the post, in the author's order; the link opens the file. A failed attachment is left off the page and still does not hold the page back: the page stays a snapshot of the run until pages can be rebuilt from disk (stage 7).
  • The API marks a file the author has not finished uploading with complete: false, and its url answers 404. The DTO did not read the flag, so such a post burned 5 attempts of 404, landed in the failed list and re-downloaded its images on every attempt. The mapper now skips the file like an unfinished video or audio, warns about unfinished uploads and marks files for the next run. --dry-run no longer promises such files.
  • A line break inside a text fragment (Shift+Enter in the editor) collapsed into a space: the template turned only a lone \n fragment into <br>. The mapper now gives every line break a fragment of its own.
  • A heading with a styled word split into one <hN> per fragment and dropped the style. The template now opens the heading on the first fragment of a level and closes it on the last, with bold, italic, underline and links inside.

Changed

  • A Boosty video shows its title above the player, the way audio already did; .audio-title became the shared .media-title.
  • image.html takes alt from the model and drops the inline max-width style; image and file paths go through _media_src like video and audio, so Windows paths get forward slashes.
  • Dead CSS (p, .new-paragraph) and unused model fields (HtmlGenImage.width/height, HtmlGenVideo.poster, HtmlGenFile.title) are gone.

🚫 Not changed on purpose

  • The page rule stays: a failed page element blocks post.html, a failed attachment does not. Linking attachments before they land was considered and dropped: only downloaded files belong on the page.
  • check still counts unfinished files in the blog overview: count_media works on DTOs. Backlog.
  • External videos: the DTO has no complete field and 335 live posts had no external video to check one against, so nothing to change.

📚 Docs

  • docs/concepts/boosty/download-flow.md: the page links only the attachments that landed.
  • download --help: the note about post_content without the video filters names files too.

🧪 Tests

  • Mapper: an unfinished file is skipped and marked; a file without the flag is treated as finished; the plan does not promise an unfinished file.
  • Use case: a saved attachment becomes a HtmlGenFile element; without post_content in the run it gets none.
  • e2e: the full run links files/fixture-archive.zip; the retried run pins that a page written before the retry has no link.
  • Text mapper: a break inside the text, style and heading level of the pieces, BLOCK_END with text.
  • Templates: a styled heading renders as one <h2>; the showcase golden pins the video title block, the attachment block and the CSS changes.
  • task ci green locally: ruff, pyright strict, import-linter, 276 tests + e2e.
  • Live on a small blog: a post with three unfinished attachments finishes without a single 404 attempt and the dry-run stops promising them; a post with nine attachments gets nine links that all resolve on disk; videos show their titles; a third-party post with a break glued to its text shows <br> where a space used to be.

✅ Checklist

  • Tested live on a real blog (feature or fix)
  • Updated CLI --help and README if needed
  • Updated docs/ if the download flow or dev process changed
  • Added a line to ## Unreleased in CHANGELOG.md (or the ci/skip-changelog label if not user-facing)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Glitchy-Sheep/boosty-downloader/pull/191 **Author:** [@Glitchy-Sheep](https://github.com/Glitchy-Sheep) **Created:** 9/14/2026 **Status:** ✅ Merged **Merged:** 9/15/2026 **Merged by:** [@Glitchy-Sheep](https://github.com/Glitchy-Sheep) **Base:** `main` ← **Head:** `fix/attachments-on-page` --- ### 📝 Commits (4) - [`ef70045`](https://github.com/Glitchy-Sheep/boosty-downloader/commit/ef70045976bbf33787e58d8d5520212221967fa1) [api] Skip file attachments the author has not finished uploading - [`ce99e0b`](https://github.com/Glitchy-Sheep/boosty-downloader/commit/ce99e0b143956ce31afc2935436b63a77a96c156) [downloader] Link attachments in post.html - [`c945d28`](https://github.com/Glitchy-Sheep/boosty-downloader/commit/c945d28a89daf40a1b42f83d26f14ab33b47c1d4) [html] Keep a styled heading in one piece and render line breaks in text - [`74850b9`](https://github.com/Glitchy-Sheep/boosty-downloader/commit/74850b9c8fdb0257c78bf0fca086f707bf9097cb) [html] Show the video title and tidy the page templates ### 📊 Changes **24 files changed** (+320 additions, -67 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+11 -0) 📝 `boosty_downloader/application/mappers/html_converter.py` (+6 -0) 📝 `boosty_downloader/application/mappers/link_header_text.py` (+22 -1) 📝 `boosty_downloader/application/mappers/post_mapper.py` (+3 -0) 📝 `boosty_downloader/application/use_cases/download_single_post.py` (+7 -5) 📝 `boosty_downloader/cli/commands/download.py` (+2 -2) 📝 `boosty_downloader/infrastructure/boosty_api/models/post/post_data_types/post_data_file.py` (+3 -0) 📝 `boosty_downloader/infrastructure/html_generator/models.py` (+0 -4) 📝 `boosty_downloader/infrastructure/html_generator/renderer.py` (+6 -2) 📝 `boosty_downloader/infrastructure/html_generator/templates/audio.html` (+1 -1) 📝 `boosty_downloader/infrastructure/html_generator/templates/base.html` (+8 -9) 📝 `boosty_downloader/infrastructure/html_generator/templates/file.html` (+1 -1) 📝 `boosty_downloader/infrastructure/html_generator/templates/image.html` (+1 -1) 📝 `boosty_downloader/infrastructure/html_generator/templates/text.html` (+10 -8) 📝 `boosty_downloader/infrastructure/html_generator/templates/video.html` (+9 -4) 📝 `docs/concepts/boosty/download-flow.md` (+1 -1) 📝 `test/e2e/download_flow_test.py` (+6 -0) 📝 `test/fixtures/rendered_post.html` (+25 -21) 📝 `test/unit/download_plan/download_plan_test.py` (+6 -2) 📝 `test/unit/html_generator/html_templates_test.py` (+23 -2) _...and 4 more files_ </details> ### 📄 Description ## 📝 Summary Audit stage 5, block 1 of 4 (mappers and render): attachments reach the page, unfinished uploads stop failing posts, and two text rendering losses are fixed. ## 🔧 What changes **Fixed** - Attachments downloaded into `files/`, but `post.html` never mentioned them. Every file that downloaded is now a link on its own line at its place in the post, in the author's order; the link opens the file. A failed attachment is left off the page and still does not hold the page back: the page stays a snapshot of the run until pages can be rebuilt from disk (stage 7). - The API marks a file the author has not finished uploading with `complete: false`, and its url answers 404. The DTO did not read the flag, so such a post burned 5 attempts of 404, landed in the failed list and re-downloaded its images on every attempt. The mapper now skips the file like an unfinished video or audio, warns about unfinished uploads and marks `files` for the next run. `--dry-run` no longer promises such files. - A line break inside a text fragment (Shift+Enter in the editor) collapsed into a space: the template turned only a lone `\n` fragment into `<br>`. The mapper now gives every line break a fragment of its own. - A heading with a styled word split into one `<hN>` per fragment and dropped the style. The template now opens the heading on the first fragment of a level and closes it on the last, with bold, italic, underline and links inside. **Changed** - A Boosty video shows its title above the player, the way audio already did; `.audio-title` became the shared `.media-title`. - `image.html` takes `alt` from the model and drops the inline `max-width` style; image and file paths go through `_media_src` like video and audio, so Windows paths get forward slashes. - Dead CSS (`p`, `.new-paragraph`) and unused model fields (`HtmlGenImage.width/height`, `HtmlGenVideo.poster`, `HtmlGenFile.title`) are gone. ## 🚫 Not changed on purpose - The page rule stays: a failed page element blocks `post.html`, a failed attachment does not. Linking attachments before they land was considered and dropped: only downloaded files belong on the page. - `check` still counts unfinished files in the blog overview: `count_media` works on DTOs. Backlog. - External videos: the DTO has no `complete` field and 335 live posts had no external video to check one against, so nothing to change. ## 📚 Docs - `docs/concepts/boosty/download-flow.md`: the page links only the attachments that landed. - `download --help`: the note about `post_content` without the video filters names `files` too. ## 🧪 Tests - Mapper: an unfinished file is skipped and marked; a file without the flag is treated as finished; the plan does not promise an unfinished file. - Use case: a saved attachment becomes a `HtmlGenFile` element; without `post_content` in the run it gets none. - e2e: the full run links `files/fixture-archive.zip`; the retried run pins that a page written before the retry has no link. - Text mapper: a break inside the text, style and heading level of the pieces, `BLOCK_END` with text. - Templates: a styled heading renders as one `<h2>`; the showcase golden pins the video title block, the attachment block and the CSS changes. - `task ci` green locally: ruff, pyright strict, import-linter, 276 tests + e2e. - Live on a small blog: a post with three unfinished attachments finishes without a single 404 attempt and the dry-run stops promising them; a post with nine attachments gets nine links that all resolve on disk; videos show their titles; a third-party post with a break glued to its text shows `<br>` where a space used to be. ## ✅ Checklist - [x] Tested live on a real blog (feature or fix) - [x] Updated CLI `--help` and README if needed - [x] Updated `docs/` if the download flow or dev process changed - [x] Added a line to `## Unreleased` in CHANGELOG.md (or the `ci/skip-changelog` label if not user-facing) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-13 19:48:34 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Glitchy-Sheep/boosty-downloader#189
No description provided.