Add a feed for statuses
This commit is contained in:
14
app/actions/feeds/statuses_rss.rb
Normal file
14
app/actions/feeds/statuses_rss.rb
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
module Adamantium
|
||||||
|
module Actions
|
||||||
|
module Feeds
|
||||||
|
class StatusesRss < Action
|
||||||
|
include Deps["views.feeds.statuses_rss"]
|
||||||
|
|
||||||
|
def handle(req, res)
|
||||||
|
res.content_type = "application/rss+xml"
|
||||||
|
res.render statuses_rss, format: :xml
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@@ -153,6 +153,15 @@ module Adamantium
|
|||||||
.to_a
|
.to_a
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def statuses_for_rss
|
||||||
|
posts
|
||||||
|
.where(post_type: "post", name: nil, location: nil)
|
||||||
|
.published
|
||||||
|
.combine(:tags)
|
||||||
|
.order(Sequel.desc(:published_at))
|
||||||
|
.to_a
|
||||||
|
end
|
||||||
|
|
||||||
def fetch!(slug)
|
def fetch!(slug)
|
||||||
posts
|
posts
|
||||||
.published
|
.published
|
||||||
|
20
app/templates/feeds/statuses_rss.xml.builder
Normal file
20
app/templates/feeds/statuses_rss.xml.builder
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
xml.instruct!(:xml, version: "2.0", encoding: "utf-8")
|
||||||
|
|
||||||
|
xml.channel do |channel|
|
||||||
|
channel.title "Daniel Nitsikopoulos"
|
||||||
|
channel.description "The RSS feed for https://dnitza.com"
|
||||||
|
channel.lastBuildDate Time.now.rfc2822
|
||||||
|
channel.pubDate Time.now.rfc2822
|
||||||
|
channel.ttl 1800
|
||||||
|
|
||||||
|
posts.each do |post|
|
||||||
|
channel.item do |item|
|
||||||
|
item.title post.display_title
|
||||||
|
item.description do |desc|
|
||||||
|
desc.cdata! post.feed_content
|
||||||
|
end
|
||||||
|
item.guid(post.slug, isPermaLink: true)
|
||||||
|
item.pubDate post.machine_published_at
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@@ -16,6 +16,7 @@ html
|
|||||||
link rel="pingback" href=Hanami.app.settings.pingback_url
|
link rel="pingback" href=Hanami.app.settings.pingback_url
|
||||||
link rel="feed" type="text/html" href="/posts"
|
link rel="feed" type="text/html" href="/posts"
|
||||||
link rel="feed alternate" type="application/rss+xml" href="/feeds/rss"
|
link rel="feed alternate" type="application/rss+xml" href="/feeds/rss"
|
||||||
|
link rel="feed alternate" type="application/rss+xml" href="/feeds/statuses_rss"
|
||||||
|
|
||||||
link rel="me" href=Hanami.app.settings.mastodon_url
|
link rel="me" href=Hanami.app.settings.mastodon_url
|
||||||
link rel="me" href=Hanami.app.settings.github_url
|
link rel="me" href=Hanami.app.settings.github_url
|
||||||
|
23
app/views/feeds/statuses_rss.rb
Normal file
23
app/views/feeds/statuses_rss.rb
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
require "builder"
|
||||||
|
|
||||||
|
module Adamantium
|
||||||
|
module Views
|
||||||
|
module Feeds
|
||||||
|
class StatusesRss < Adamantium::View
|
||||||
|
include Deps["repos.post_repo"]
|
||||||
|
|
||||||
|
expose :posts do
|
||||||
|
post_repo.statuses_for_rss.map do |post|
|
||||||
|
Decorators::Posts::Decorator.new post
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
expose :xml, decorate: false, layout: true
|
||||||
|
|
||||||
|
def xml
|
||||||
|
Builder::XmlMarkup.new(indent: 2)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@@ -33,6 +33,7 @@ module Adamantium
|
|||||||
get "/key", to: "key.show" if Hanami.app.settings.micropub_pub_key
|
get "/key", to: "key.show" if Hanami.app.settings.micropub_pub_key
|
||||||
|
|
||||||
get "/feeds/rss", to: "feeds.rss"
|
get "/feeds/rss", to: "feeds.rss"
|
||||||
|
get "/feeds/statuses_rss", to: "feeds.statuses_rss"
|
||||||
|
|
||||||
get "/:slug", to: "pages.show"
|
get "/:slug", to: "pages.show"
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user