Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Betree/atomex
🌊 Elixir RSS/ATOM feed builder with a focus on standards compliance, security and extensibility
https://github.com/Betree/atomex
atom elixir rss
Last synced: 2 months ago
JSON representation
🌊 Elixir RSS/ATOM feed builder with a focus on standards compliance, security and extensibility
- Host: GitHub
- URL: https://github.com/Betree/atomex
- Owner: Betree
- License: mit
- Created: 2018-01-28T14:28:52.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-03-30T05:07:45.000Z (almost 2 years ago)
- Last Synced: 2024-10-30T07:01:53.321Z (2 months ago)
- Topics: atom, elixir, rss
- Language: Elixir
- Homepage:
- Size: 92.8 KB
- Stars: 58
- Watchers: 3
- Forks: 3
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- freaking_awesome_elixir - Elixir - ATOM feed builder with a focus on standards compliance, security and extensibility. (Feeds)
- fucking-awesome-elixir - atomex - ATOM feed builder with a focus on standards compliance, security and extensibility. (Feeds)
- awesome-elixir - atomex - ATOM feed builder with a focus on standards compliance, security and extensibility. (Feeds)
README
# Atomex
[![Coverage Status](https://coveralls.io/repos/github/Betree/atomex/badge.svg?branch=master)](https://coveralls.io/github/Betree/atomex?branch=master)
[![Build Status](https://travis-ci.org/Betree/atomex.svg?branch=master)](https://travis-ci.org/Betree/atomex)Atomex is an ATOM 1.0 feed builder with a focus on [RFC4287](https://tools.ietf.org/html/rfc4287) compliance,
security and extensibility. It is safe to use it with user content: everything is escaped by default.
Built on top of [xml_builder](https://github.com/joshnuss/xml_builder/).API reference is available here: https://hexdocs.pm/atomex/api-reference.html
## TODO
- [x] Feed required params (id, title, updated)
- [x] Feed recommended params (author, link)
- [x] Feed optional params
* [x] category
* [x] contributor
* [x] generator
* [x] icon
* [x] logo
* [x] rights
* [x] subtitle
- [x] Entry required params (id, title, updated)
- [x] Entry recommended params (author, content, link, summary)
- [ ] Entry optional params
* [x] category
* [x] contributor
* [x] published
* [x] rights
* [ ] source
- [ ] Validator## Installation
```elixir
def deps do
[
{:atomex, "0.3.0"}
]
end
```## Basic usage
Required field are always passed in `new` functions. There are however recommended fields that you
should not ignore. See [Validating your feed](#validating-your-feed) below.```elixir
alias Atomex.{Feed, Entry}def build_feed(comments) do
Feed.new("https://example.com", DateTime.utc_now, "My incredible feed")
|> Feed.author("John Doe", email: "[email protected]")
|> Feed.link("https://example.com/feed", rel: "self")
|> Feed.entries(Enum.map(comments, &get_entry/1))
|> Feed.build()
|> Atomex.generate_document()
enddefp get_entry(_comment = %{id, text, inserted_at, user}) do
Entry.new("https://example.com/comments/#{id}", inserted_at, "New comment by #{user.name}")
|> Entry.author(user.name, uri: "https://example.com/users/#{user.id}")
|> Entry.content("Content here will be properly escaped! Text: #{text}
", type: "html")
|> Entry.build()
end
```To avoid escaping, you can pass a tuple as value like this (be careful though, a user may
break it with malicious content):```elixir
Entry.content(entry, {:cdata, "Amazing
"}, type: "html")
# Render as => Amazing]]>
```## Extending the default API
* You can specify custom schemas
```elixir
Feed.build(feed, %{"xmlns:georss" => "http://www.georss.org/georss"})
#
#
#...
```* And custom fields
```elixir
Feed.new(...)
|> Feed.add_field(:custom_field, %{attribute: 42}, "Foobar")
|> Feed.build()
|> Atomex.generate_document()
# ...
# Foobar
```For more complicated use cases, content can also be given a xml element directly. Use XmlBuilder to achieve that.
## Validating your feed
Use [this tool from W3C](https://validator.w3.org/feed/)