howtos rss
This commit is contained in:
@@ -17,4 +17,11 @@ class Api::RssController < ApiController
|
||||
xml = RssService.new.releases_feed
|
||||
render xml: xml, content_type: "application/rss+xml"
|
||||
end
|
||||
|
||||
api :GET, "/api/rss/howtos", "HowTos RSS feed"
|
||||
returns code: 200, desc: "RSS XML feed of tech howtos"
|
||||
def howtos
|
||||
xml = RssService.new.howtos_feed
|
||||
render xml: xml, content_type: "application/rss+xml"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,6 +2,7 @@ require "rss"
|
||||
|
||||
class RssService
|
||||
SITE_URL = ENV.fetch("SITE_URL", "https://teletypegames.org").freeze
|
||||
WIKI_URL = ENV.fetch("WIKI_URL", "https://wiki.teletypegames.org").freeze
|
||||
|
||||
def blog_feed
|
||||
pages = WikiService.new.pages(tag: "blog", limit: 30)
|
||||
@@ -48,4 +49,25 @@ class RssService
|
||||
end
|
||||
end.to_s
|
||||
end
|
||||
|
||||
def howtos_feed
|
||||
pages = WikiService.new.pages(tag: "howto", limit: 30)
|
||||
items = pages.fetch("pages", [])
|
||||
|
||||
RSS::Maker.make("2.0") do |maker|
|
||||
maker.channel.title = "Teletype Games HowTos"
|
||||
maker.channel.link = "#{SITE_URL}/howtos"
|
||||
maker.channel.description = "Latest tech howtos from Teletype Games"
|
||||
maker.channel.language = "hu"
|
||||
|
||||
items.each do |page|
|
||||
maker.items.new_item do |item|
|
||||
item.title = page["title"]
|
||||
item.link = "#{WIKI_URL}/#{page["path"]}"
|
||||
item.description = page["description"].to_s
|
||||
item.pubDate = Time.parse(page["createdAt"]) rescue Time.current
|
||||
end
|
||||
end
|
||||
end.to_s
|
||||
end
|
||||
end
|
||||
|
||||
@@ -16,7 +16,7 @@ ActiveAdmin.setup do |config|
|
||||
admin.build_menu :utility_navigation do |menu|
|
||||
menu.add id: "site_link",
|
||||
label: "🏠",
|
||||
url: "/",
|
||||
url: ENV.fetch("SITE_URL", "https://teletypegames.org"),
|
||||
html_options: { target: "_blank", title: "Open site", style: "font-size:18px;" },
|
||||
priority: 1
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ Rails.application.routes.draw do
|
||||
get "wiki/pages", to: "wiki#index"
|
||||
get "rss/blog", to: "rss#blog"
|
||||
get "rss/releases", to: "rss#releases"
|
||||
get "rss/howtos", to: "rss#howtos"
|
||||
get "download", to: "downloads#show"
|
||||
end
|
||||
get "update", to: "update#update"
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
<title>Teletype Games</title>
|
||||
<link rel="alternate" type="application/rss+xml" title="Teletype Games Blog" href="/api/rss/blog" />
|
||||
<link rel="alternate" type="application/rss+xml" title="Teletype Games Releases" href="/api/rss/releases" />
|
||||
<link rel="alternate" type="application/rss+xml" title="Teletype Games HowTos" href="/api/rss/howtos" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
||||
@@ -61,6 +61,10 @@
|
||||
<a href="/api/rss/releases" target="_blank" class="hover:text-orange-400 transition-colors" title="Releases RSS">
|
||||
📡 Releases
|
||||
</a>
|
||||
<span class="text-gray-600">|</span>
|
||||
<a href="/api/rss/howtos" target="_blank" class="hover:text-orange-400 transition-colors" title="HowTos RSS">
|
||||
📡 HowTos
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user