Skip to content

Atom feeds supported

nnot.at now supports Atom feeds, on top of the existing RSS feed functionality. This wasn't a big lift to add, I had just skipped it on the path of getting something working.

The commit is here https://tangled.org/jola.dev/annot.at/commit/4cf83135c0497ed86b1970fe848559d7f70f6a0a.

Apart from setting up the Saxy SAX parser, the data we extract is not very complicated:

  defp apply_entry_field(entry, "title", text), do: %{entry | title: text}
  defp apply_entry_field(entry, "id", text), do: %{entry | id: text}
  defp apply_entry_field(entry, "summary", text), do: %{entry | summary: text}
  defp apply_entry_field(entry, "content", text), do: %{entry | content: text}
  defp apply_entry_field(entry, "published", text), do: %{entry | published_at: parse_date(text)}

  defp apply_entry_field(entry, "updated", text) do
    %{entry | published_at: entry.published_at || parse_date(text)}
  end

  defp apply_entry_field(entry, _name, _text), do: entry

  defp apply_feed_field(feed, "title", text), do: %{feed | title: text}
  defp apply_feed_field(feed, "subtitle", text), do: %{feed | description: text}
  defp apply_feed_field(feed, _name, _text), do: feed

  defp finalize_entry(%Entry{id: nil, url: url} = entry) when is_binary(url) do
    %{entry | id: url}
  end

  defp finalize_entry(entry), do: entry

Did you enjoy this article?

Recommend it β€” Standard Reader surfaces well-loved writing to more readers across the network.

Across the AtmosphereDiscussions