Skip to content

feat: add automatic banner image download with picsum provider#294

Merged
rochacbruno merged 4 commits intomainfrom
feat/automatic-image-download
Jul 19, 2025
Merged

feat: add automatic banner image download with picsum provider#294
rochacbruno merged 4 commits intomainfrom
feat/automatic-image-download

Conversation

@rochacbruno
Copy link
Copy Markdown
Owner

Summary

This PR implements automatic banner image download functionality as described in issue #152. The feature automatically downloads banner images for posts using the picsum.photos service when no banner image is specified in frontmatter and the image file doesn't exist.

Key Features

  • Automatic Downloads: Images are downloaded only for posts (content with dates), not pages
  • Deterministic Generation: Uses site name + post slug + tags as seed for consistent images
  • Configurable: Enabled via image_provider: picsum in marmite.yaml
  • Non-Intrusive: Only downloads if banner_image not in frontmatter and file doesn't exist
  • Tag-Based Variety: Includes post tags in seed generation for more image variety

Implementation Details

  • Added ImageProvider enum with Picsum variant to config system
  • Created new image_provider module with download functionality
  • Integrated automatic download into Content::from_markdown method
  • Added ureq dependency for HTTP requests
  • Images saved as {slug}.banner.jpg in media folder
  • URL format: https://picsum.photos/seed/{site-name-slug-tags}/1200/300

Documentation

  • Added comprehensive documentation post explaining the feature
  • Includes customization options and troubleshooting tips
  • Updated example configuration with image provider setting

Test plan

  • Run mask fmt and mask check for code quality
  • Test with example site to verify image downloads work
  • Verify images are only downloaded for posts, not pages
  • Confirm deterministic behavior with same seed
  • Test that existing images are not overwritten
  • Validate configuration parsing and error handling

🤖 Generated with Claude Code

rochacbruno and others added 4 commits July 19, 2025 19:50
Implements automatic banner image download for posts using picsum.photos service.
Images are downloaded only for posts (content with dates) when no banner_image
is specified in frontmatter and the image file doesn't exist.

- Add ImageProvider enum with Picsum variant to config
- Add image_provider field to Marmite configuration struct
- Create image_provider module with download functionality
- Integrate automatic download into Content::from_markdown method
- Include post tags in image seed for variety
- Add ureq dependency for HTTP requests
- Add comprehensive documentation post explaining the feature
- Add example configuration to marmite.yaml

The feature uses deterministic image generation with site name, post slug,
and tags as seed to ensure consistent images across rebuilds.

Closes #152

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Remove duplicate slugify implementation in image_provider module
and import the existing one from content module instead.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Add command-line support for configuring automatic image download provider.
Users can now override the image_provider setting from the command line
using --image-provider argument.

- Add image_provider field to CLI Configuration struct
- Implement CLI override handling in config.rs
- Add comprehensive documentation for CLI argument usage
- Update configuration reference with image provider settings
- Add examples and usage instructions in documentation

Usage examples:
- marmite site/ --image-provider picsum
- marmite --generate-config --image-provider picsum

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@rochacbruno rochacbruno merged commit d3f3c27 into main Jul 19, 2025
3 checks passed
@rochacbruno rochacbruno deleted the feat/automatic-image-download branch July 19, 2025 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant