[PR #195] [MERGED] [html] Render attachments as file cards #192

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

📋 Pull Request Information

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

Base: main ← Head: feat/attachment-cards


📝 Commits (1)

  • 10c88bb [html] Render attachments as file cards

📊 Changes

12 files changed (+312 additions, -15 deletions)

View changed files

📝 CHANGELOG.md (+4 -0)
📝 boosty_downloader/application/mappers/html_converter.py (+3 -3)
📝 boosty_downloader/application/use_cases/download_single_post.py (+3 -1)
📝 boosty_downloader/infrastructure/html_generator/models.py (+2 -0)
📝 boosty_downloader/infrastructure/html_generator/renderer.py (+114 -4)
➕ boosty_downloader/infrastructure/html_generator/templates/attachments.html (+11 -0)
📝 boosty_downloader/infrastructure/html_generator/templates/base.html (+46 -1)
➖ boosty_downloader/infrastructure/html_generator/templates/file.html (+0 -1)
📝 test/e2e/download_flow_test.py (+4 -1)
📝 test/fixtures/rendered_post.html (+62 -2)
📝 test/unit/html_generator/html_templates_test.py (+59 -0)
📝 test/unit/use_cases/page_elements_test.py (+4 -2)

📄 Description

📝 Summary

Follow-up to #191: attachments in post.html become file cards, so a file reads as a file and not as one more link or a second player.

🔧 What changes

  • Every attachment is a card: an icon by file type (video, audio, image, document, archive, paperclip for the rest), the author's file name, and a File · MP4 · 29.7 KB line with the type and the size the API reported. Unknown size or a name without a usable extension just drop that part of the line.
  • Files that stand next to each other share one block with dividers; a text, an image or a player between them starts a new block. The author's order is kept.
  • The icon comes from the MIME family through mimetypes, the same table the video type= attribute already uses. The size arrives from the domain (PostDataChunkFile.size) through HtmlGenFile.size.
  • file.html is replaced by attachments.html; render_html groups neighbouring HtmlGenFile chunks, render_html_chunk renders a block of one.

💡 Why

After #191 a post with an mp4 attachment next to a Boosty video player showed a player and a bare link with the same name, and it was not clear that the link is a file. The API sends both as separate chunks (a player and a file attachment), so the page mirrors the post; the card makes the difference visible instead of hiding one of them.

🧪 Tests

  • Renderer: icon per file type (7 cases), the meta line by what is known (type and size, bytes, no size, no type, a suffix like v1.2 (final) is not a type), neighbouring files in one block with the order kept.
  • The showcase golden pins a block of two files, one without a size; e2e checks the card of the fixture attachment with its size.
  • task ci green locally: ruff, pyright strict, import-linter, 289 tests + e2e.
  • Live on a small blog: a post with nine attachments and an image between them renders two blocks in the author's order; the same track attached as audio and as a file shows a player and a card under it.

✅ 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/195 **Author:** [@Glitchy-Sheep](https://github.com/Glitchy-Sheep) **Created:** 9/20/2026 **Status:** ✅ Merged **Merged:** 9/20/2026 **Merged by:** [@Glitchy-Sheep](https://github.com/Glitchy-Sheep) **Base:** `main` ← **Head:** `feat/attachment-cards` --- ### 📝 Commits (1) - [`10c88bb`](https://github.com/Glitchy-Sheep/boosty-downloader/commit/10c88bb82526e9f6f8fe9ea1a0557cf4caecac15) [html] Render attachments as file cards ### 📊 Changes **12 files changed** (+312 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+4 -0) 📝 `boosty_downloader/application/mappers/html_converter.py` (+3 -3) 📝 `boosty_downloader/application/use_cases/download_single_post.py` (+3 -1) 📝 `boosty_downloader/infrastructure/html_generator/models.py` (+2 -0) 📝 `boosty_downloader/infrastructure/html_generator/renderer.py` (+114 -4) ➕ `boosty_downloader/infrastructure/html_generator/templates/attachments.html` (+11 -0) 📝 `boosty_downloader/infrastructure/html_generator/templates/base.html` (+46 -1) ➖ `boosty_downloader/infrastructure/html_generator/templates/file.html` (+0 -1) 📝 `test/e2e/download_flow_test.py` (+4 -1) 📝 `test/fixtures/rendered_post.html` (+62 -2) 📝 `test/unit/html_generator/html_templates_test.py` (+59 -0) 📝 `test/unit/use_cases/page_elements_test.py` (+4 -2) </details> ### 📄 Description ## 📝 Summary Follow-up to #191: attachments in `post.html` become file cards, so a file reads as a file and not as one more link or a second player. ## 🔧 What changes - Every attachment is a card: an icon by file type (video, audio, image, document, archive, paperclip for the rest), the author's file name, and a `File · MP4 · 29.7 KB` line with the type and the size the API reported. Unknown size or a name without a usable extension just drop that part of the line. - Files that stand next to each other share one block with dividers; a text, an image or a player between them starts a new block. The author's order is kept. - The icon comes from the MIME family through `mimetypes`, the same table the video `type=` attribute already uses. The size arrives from the domain (`PostDataChunkFile.size`) through `HtmlGenFile.size`. - `file.html` is replaced by `attachments.html`; `render_html` groups neighbouring `HtmlGenFile` chunks, `render_html_chunk` renders a block of one. ## 💡 Why After #191 a post with an mp4 attachment next to a Boosty video player showed a player and a bare link with the same name, and it was not clear that the link is a file. The API sends both as separate chunks (a player and a file attachment), so the page mirrors the post; the card makes the difference visible instead of hiding one of them. ## 🧪 Tests - Renderer: icon per file type (7 cases), the meta line by what is known (type and size, bytes, no size, no type, a suffix like `v1.2 (final)` is not a type), neighbouring files in one block with the order kept. - The showcase golden pins a block of two files, one without a size; e2e checks the card of the fixture attachment with its size. - `task ci` green locally: ruff, pyright strict, import-linter, 289 tests + e2e. - Live on a small blog: a post with nine attachments and an image between them renders two blocks in the author's order; the same track attached as audio and as a file shows a player and a card under it. ## ✅ 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:38 +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#192
No description provided.