diff --git a/app/controllers/episodes_controller.rb b/app/controllers/episodes_controller.rb index a0c5926..bc4a52a 100644 --- a/app/controllers/episodes_controller.rb +++ b/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 \ No newline at end of file diff --git a/app/views/episodes/index.atom.builder b/app/views/episodes/index.atom.builder new file mode 100644 index 0000000..34daa22 --- /dev/null +++ b/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 \ No newline at end of file diff --git a/app/views/episodes/index.html.haml b/app/views/episodes/index.html.haml index 16d5b6c..7011f8b 100644 --- a/app/views/episodes/index.html.haml +++ b/app/views/episodes/index.html.haml @@ -7,4 +7,4 @@ - @episodes.each do |episode| %li.episode %h3= episode.title - %p= link_to 'Play', episode.link \ No newline at end of file + %p= link_to 'Play', episode_path(episode) \ No newline at end of file diff --git a/app/views/episodes/show.html.haml b/app/views/episodes/show.html.haml new file mode 100644 index 0000000..e68c7f0 --- /dev/null +++ b/app/views/episodes/show.html.haml @@ -0,0 +1,2 @@ +%h2= @episode.title += audio_tag(audio_path(@episode.link), autoplay: true, controls: true) \ No newline at end of file diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index ea3c8c5..f816517 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -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" \ No newline at end of file + = yield \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 2394d15..cc1e5b2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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