Compare commits
No commits in common. "f9906fa4f7cd2c309882c6fd0ed1008f9fc95696" and "7309e8e37424f48f74ad7ea003ceea160069fedf" have entirely different histories.
f9906fa4f7
...
7309e8e374
|
@ -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
|
|
|
@ -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
|
|
|
@ -14,10 +14,6 @@ defmodule JOLWeb.Router do
|
||||||
plug :accepts, ["json"]
|
plug :accepts, ["json"]
|
||||||
end
|
end
|
||||||
|
|
||||||
pipeline :feeds do
|
|
||||||
plug :accepts, ["xml"]
|
|
||||||
end
|
|
||||||
|
|
||||||
scope "/", JOLWeb do
|
scope "/", JOLWeb do
|
||||||
pipe_through :browser
|
pipe_through :browser
|
||||||
|
|
||||||
|
@ -31,11 +27,10 @@ defmodule JOLWeb.Router do
|
||||||
get "/blog/:slug", BlogController, :show
|
get "/blog/:slug", BlogController, :show
|
||||||
end
|
end
|
||||||
|
|
||||||
scope "/", JOLWeb do
|
# Other scopes may use custom stacks.
|
||||||
pipe_through :feeds
|
# scope "/api", JOLWeb do
|
||||||
|
# pipe_through :api
|
||||||
get "/feed.xml", FeedController, :feed
|
# end
|
||||||
end
|
|
||||||
|
|
||||||
# Enable LiveDashboard and Swoosh mailbox preview in development
|
# Enable LiveDashboard and Swoosh mailbox preview in development
|
||||||
if Application.compile_env(:jol, :dev_routes) do
|
if Application.compile_env(:jol, :dev_routes) do
|
||||||
|
|
Loading…
Reference in a new issue