Skip to content

Commit 30cf422

Browse files
author
Marylou Lenhart
committed
Atom feed midstage
Currently, all the content is being populated, but the actual Atom feed is not rendering properly.
1 parent ba10454 commit 30cf422

7 files changed

Lines changed: 45 additions & 23 deletions

File tree

app/controllers/questions_controller.rb

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ def create
1010
end
1111

1212
def show
13+
@title = "Questions"
1314
@answer = Answer.new
1415
show!
1516
end
@@ -66,11 +67,17 @@ def set_presenter
6667
end
6768

6869
def feed
69-
@questions = @question.all(:select => "title, description, solution_id, created_at", :order => "created_at DESC", :limit => 20)
70-
70+
@title = "Questions Feed"
71+
72+
@questions = Question.all(:select => "title, description, solution_id, created_at", :order => "created_at DESC", :limit => 20)
73+
74+
@updated = @questions.first.updated_at unless @questions.empty?
75+
7176
respond_to do |format|
72-
format.html
73-
format.rss { render :layout => false }
77+
# format.html #{ render :layout => false }
78+
format.atom #{ render :layout => "application" }
79+
# format.rss { redirect_to feed_path(:format => :atom), :status => :moved_permanently }
80+
# format.xml { render :xml => @questions }
7481
end
7582
end
7683

app/views/layouts/application.html.haml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
!!!
33
%html
44
%head
5+
= auto_discovery_link_tag :atom, feed_path
6+
= auto_discovery_link_tag :rss, feed_path
7+
58
- title = yield :title
69
%title #{title.blank? ? "" : "#{title} | "}Hackety Hack!
710

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
atom_feed :language => 'en-US' do |feed|
2+
feed.title @title
3+
feed.updated @updated
4+
5+
@questions.each do |item|
6+
next if item.created_at.blank?
7+
8+
feed.entry( item ) do |entry|
9+
entry.url questions_url(item)
10+
entry.title item.title
11+
entry.content item.description, :type => 'html'
12+
entry.updated(item.created_at.strftime("%Y-%m-%dT%H:%M:%SZ"))
13+
14+
entry.author do |author|
15+
author.name entry.user
16+
end
17+
end
18+
end
19+
end
20+

app/views/questions/feed.rss.builder

Lines changed: 0 additions & 17 deletions
This file was deleted.

app/views/questions/index.html.haml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
= render :partial => "shared/questions_blurb"
1111
- else
1212
= render :partial => "shared/support_blurb"
13+
%section.support
14+
%p Subscribe to the #{link_to "Questions Atom Feed", feed_path}.
15+
16+
17+
//= render :partial => "shared/atom_blurb"
1318
1419
%ul.questions
1520
= render :partial => "list", :collection => collection

app/views/shared/_support_blurb.html.haml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@
22
%h2 Support
33
%p Having a problem running Hackety Hack? Found a bug? Check out the #{link_to "support section", support_questions_path}
44

5-
%a.href auto_discovery_link_tag(:rss, questions_url)

config/routes.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@
22

33
resources :lessons, :only => [:index, :show]
44

5+
resources :questions
6+
match '/feed' => 'questions#feed',
7+
:as => :feed,
8+
:defaults => { :format => 'atom' }
9+
510
resources :questions do
611
resources :answers
712
end
8-
13+
914
get "/downloads/latest/:platform", :to => "static#download", :as => 'downloads'
1015
get "/downloads/latest", :to => "static#download", :as => 'download'
1116
match "/download" => redirect("/downloads/latest")

0 commit comments

Comments
 (0)