Skip to content

Commit 620ccac

Browse files
committed
add #387 RSSフィード作成
必要なタグがわからなかったので、すぐ出せる情報のみでRSSフィードページを作成しました
1 parent a6942b6 commit 620ccac

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

app/controllers/podcasts_controller.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,12 @@ def show
1414
@content = Kramdown::Document.new(@episode.content, input: 'GFM').to_html
1515
@url = request.url
1616
end
17+
18+
def feed
19+
@episodes = Podcast.all.sort_by{|episode| episode.filename.rjust(3, '0')}
20+
@domainname = request.base_url
21+
respond_to do |format|
22+
format.rss { render :layout => false }
23+
end
24+
end
1725
end

app/views/podcasts/feed.rss.builder

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
xml.instruct! :xml, :version => "1.0"
2+
xml.rss :version => "2.0" do
3+
xml.channel do
4+
xml.title full_title ""
5+
xml.description full_description ""
6+
xml.link root_url
7+
8+
@episodes.each do |episode|
9+
xml.item do
10+
xml.title episode.title
11+
xml.description episode.description
12+
xml.link @domainname + episode.url + ".mp3"
13+
xml.guid({:isPermaLink => "false"}, @domainname + episode.url)
14+
end
15+
end
16+
end
17+
end

config/routes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
get "/docs/charter_en", to: redirect('/charter_en')
1212
get "/docs/financial-report", to: redirect('/financial-report')
1313
get "/login", to: redirect('/login-8717e64efaf19d7d')
14+
get "/podcasts/feed" => "podcasts#feed"
1415
get "/charter" => "docs#show", id: 'charter'
1516
get "/charter_en" => "docs#show", id: 'charter_en'
1617
get "/financial-report" => "docs#show", id: 'financial-report'

0 commit comments

Comments
 (0)