Compare commits

..

No commits in common. "f9906fa4f7cd2c309882c6fd0ed1008f9fc95696" and "7309e8e37424f48f74ad7ea003ceea160069fedf" have entirely different histories.

3 changed files with 4 additions and 41 deletions

View file

@ -1,12 +0,0 @@
defmodule JOLWeb.FeedController do
use JOLWeb, :controller
def feed(conn, _params) do
feed = JOL.Blog.all_posts()
|> JOLWeb.Feeds.build_feed()
conn
|> put_resp_content_type("text/xml")
|> send_resp(200, feed)
end
end

View file

@ -1,20 +0,0 @@
defmodule JOLWeb.Feeds do
use Phoenix.VerifiedRoutes, endpoint: JOLWeb.Endpoint, router: JOLWeb.Router
alias Atomex.{Feed, Entry}
def build_feed(posts) do
Feed.new(url(~p"/"), DateTime.utc_now, "Jessica Online")
|> Feed.author("Jessica Phoenix Canady", email: "jess@canady.tech")
|> Feed.link(url(~p"/feed.xml"), rel: "self")
|> Feed.entries(Enum.map(posts, &build_entry/1))
|> Feed.build()
|> Atomex.generate_document()
end
defp build_entry(post) do
Entry.new(url(~p"/blog/#{post.slug}"), post.date, post.title)
|> Entry.author(post.author, uri: url(~p"/"))
|> Entry.content(post.body, type: "html")
|> Entry.build()
end
end

View file

@ -14,10 +14,6 @@ defmodule JOLWeb.Router do
plug :accepts, ["json"]
end
pipeline :feeds do
plug :accepts, ["xml"]
end
scope "/", JOLWeb do
pipe_through :browser
@ -31,11 +27,10 @@ defmodule JOLWeb.Router do
get "/blog/:slug", BlogController, :show
end
scope "/", JOLWeb do
pipe_through :feeds
get "/feed.xml", FeedController, :feed
end
# Other scopes may use custom stacks.
# scope "/api", JOLWeb do
# pipe_through :api
# end
# Enable LiveDashboard and Swoosh mailbox preview in development
if Application.compile_env(:jol, :dev_routes) do