philomena/lib/philomena_web/controllers/api/rss/watched_controller.ex

21 lines
622 B
Elixir
Raw Permalink Normal View History

2019-12-04 01:50:23 +01:00
defmodule PhilomenaWeb.Api.Rss.WatchedController do
2019-12-01 00:11:24 +01:00
use PhilomenaWeb, :controller
alias PhilomenaWeb.ImageLoader
alias Philomena.Images.Image
alias PhilomenaQuery.Search
import Ecto.Query
2019-12-01 00:11:24 +01:00
def index(conn, _params) do
{:ok, {images, _tags}} = ImageLoader.search_string(conn, "my:watched")
images = Search.search_records(images, preload(Image, [:sources, tags: :aliases]))
2019-12-01 00:11:24 +01:00
# NB: this is RSS, but using the RSS format causes Phoenix not to
# escape HTML
conn
|> put_resp_header("content-type", "application/rss+xml")
|> render("index.html", layout: false, images: images)
2019-12-01 00:11:24 +01:00
end
end