Skip to content

Commit

Permalink
add rss feed
Browse files Browse the repository at this point in the history
  • Loading branch information
tadejm committed May 6, 2012
1 parent b748834 commit d3d1eb1
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 5 deletions.
9 changes: 9 additions & 0 deletions app/controllers/episodes_controller.rb
@@ -1,5 +1,14 @@
class EpisodesController < ApplicationController
def index
@episodes = Episode.all

respond_to do |format|
format.html
format.atom { @episodes }
end
end

def show
@episode = Episode.find params[:id]
end
end
15 changes: 15 additions & 0 deletions app/views/episodes/index.atom.builder
@@ -0,0 +1,15 @@
atom_feed language: 'en-US' do |feed|
feed.title "Hipsterija"
feed.updated Time.now

@episodes.each do |episode|
feed.entry(episode) do |entry|
entry.url episode.link
entry.title episode.title
entry.content(link_to(episode.link), type: 'html')
# the strftime is needed to work with Google Reader.
entry.updated(episode.created_at.strftime("%Y-%m-%dT%H:%M:%SZ"))
entry.author 'Radio študent'
end
end
end
2 changes: 1 addition & 1 deletion app/views/episodes/index.html.haml
Expand Up @@ -7,4 +7,4 @@
- @episodes.each do |episode|
%li.episode
%h3= episode.title
%p= link_to 'Play', episode.link
%p= link_to 'Play', episode_path(episode)
2 changes: 2 additions & 0 deletions app/views/episodes/show.html.haml
@@ -0,0 +1,2 @@
%h2= @episode.title
= audio_tag(audio_path(@episode.link), autoplay: true, controls: true)
5 changes: 2 additions & 3 deletions app/views/layouts/application.html.haml
Expand Up @@ -4,7 +4,6 @@
%title Hipsterija
= stylesheet_link_tag "application", :media => "all"
= csrf_meta_tags
= auto_discovery_link_tag(:atom, episodes_path(:atom))
%body
= yield

= javascript_include_tag "application"
= yield
2 changes: 1 addition & 1 deletion config/routes.rb
Expand Up @@ -11,7 +11,7 @@
# This route can be invoked with purchase_url(:id => product.id)

# Sample resource route (maps HTTP verbs to controller actions automatically):
# resources :products
resources :episodes

# Sample resource route with options:
# resources :products do
Expand Down

0 comments on commit d3d1eb1

Please sign in to comment.