I recently created Atomize, a lightweight command-line utility written in Babashka that simplifies the management of Atom feeds. While it's versatile enough for various use cases, I'll share how it's particularly useful when integrated with document management systems.
What is Atomize?
Atomize is a CLI tool that helps you create and update Atom feeds programmatically. Written in Babashka (a Clojure-based scripting tool), it accepts JSON input and seamlessly integrates it into your existing Atom feed file, handling all the XML manipulation behind the scenes.
Key Features
- Easy Feed Creation: If no feed exists, Atomize automatically creates a new one with sensible defaults
- Entry Management: Automatically limits the number of entries (default: 20) to keep your feed size in check
- In-place Updates: Supports updating feeds in-place with an optional backup feature
- Convenient Defaults: Automatically handles missing fields like UUIDs and timestamps
Real-World Use Case: Paperless-ngx Integration
One practical application is using Atomize with Paperless-ngx, a popular document management system. Here's how you can set it up as a post-consume hook to maintain an automated atom feed of processed documents:
1. Create a post-consume script (e.g., update-feed.sh)
#!/bin/bash # Convert Paperless-ngx document info to Atomize's JSON format json_data=$(jq -n \ --arg title "$DOCUMENT_TITLE" \ --arg url "$DOCUMENT_DOWNLOAD_URL" \ --arg content "New document processed: $DOCUMENT_TITLE" \ '{title: $title, url: $url, content: $content}') # Feed the JSON to Atomize echo "$json_data" | atomize -i /path/to/your/feed.atom
2. Make it executable
chmod +x update-feed.sh
Now, every time Paperless-ngx processes a new document, it will automatically update your Atom feed, allowing you to track document additions through any feed reader.
Technical Implementation
Built with Babashka, Atomize leverages Clojure's excellent XML handling capabilities to manage feed content. It uses a data-driven approach to transform JSON input into properly formatted Atom entries, making it easy to integrate into various workflows.
Conclusion
Whether you're maintaining a personal blog, managing content feeds for a larger project, or automating document tracking in systems like Paperless-ngx, Atomize provides a simple, programmable solution for Atom feed management.
If you liked this post, please consider supporting our Free and Open Source software work – you can sponsor us on Github and Patreon or star our FLOSS repositories.