diff --git a/app/controllers/questions_controller.rb b/app/controllers/questions_controller.rb index 34483830..fa8fdf8c 100644 --- a/app/controllers/questions_controller.rb +++ b/app/controllers/questions_controller.rb @@ -10,6 +10,7 @@ def create end def show + @title = "Questions" @answer = Answer.new show! end @@ -18,6 +19,18 @@ def update params[:question][:solution_id] != @question.solution_id ? update!(:notice => "Okay! We've selected that answer") : update! end + def feed + @title = "Questions Feed" + + @questions = Question.sort(:created_at.desc).limit(20).all + + @updated = @questions.first.updated_at + + respond_to do |format| + format.atom + end + end + def collection @questions = @presenter.apply_scope(end_of_association_chain).newest_first.paginate(:page => params[:page]) end diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index b9ef0bf4..d1af2297 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -2,6 +2,8 @@ !!! %html %head + = auto_discovery_link_tag :atom, "/questions/feed.atom" # I don't even care + - title = yield :title %title #{title.blank? ? "" : "#{title} | "}Hackety Hack! diff --git a/app/views/questions/feed.atom.builder b/app/views/questions/feed.atom.builder new file mode 100644 index 00000000..b6e18944 --- /dev/null +++ b/app/views/questions/feed.atom.builder @@ -0,0 +1,17 @@ +atom_feed :language => 'en-US' do |feed| + feed.title @title + feed.updated @updated + + @questions.each do |item| + next if item.created_at.blank? + + feed.entry item do |entry| + entry.url questions_url(item) + entry.title item.title + entry.content item.description, :type => 'html' + entry.updated(item.created_at.strftime("%Y-%m-%dT%H:%M:%SZ")) + entry.author item.user + end + end +end + diff --git a/app/views/questions/index.html.haml b/app/views/questions/index.html.haml index b552bace..eeea5447 100644 --- a/app/views/questions/index.html.haml +++ b/app/views/questions/index.html.haml @@ -10,6 +10,7 @@ = render :partial => "shared/questions_blurb" - else = render :partial => "shared/support_blurb" + = render :partial => "shared/atom_blurb" %ul.questions = render :partial => "list", :collection => collection diff --git a/app/views/shared/_atom_blurb.html.haml b/app/views/shared/_atom_blurb.html.haml new file mode 100644 index 00000000..137e93fc --- /dev/null +++ b/app/views/shared/_atom_blurb.html.haml @@ -0,0 +1,4 @@ +%section.support + %p Subscribe to the #{link_to "Questions Atom Feed", "/questions/feed"}. + + diff --git a/app/views/shared/_support_blurb.html.haml b/app/views/shared/_support_blurb.html.haml index 2c526e65..7d808ac0 100644 --- a/app/views/shared/_support_blurb.html.haml +++ b/app/views/shared/_support_blurb.html.haml @@ -1,3 +1,4 @@ %section.support %h2 Support %p Having a problem running Hackety Hack? Found a bug? Check out the #{link_to "support section", support_questions_path} + diff --git a/config/routes.rb b/config/routes.rb index 410a0336..4d0fcf49 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,6 +2,12 @@ resources :lessons, :only => [:index, :show] + resources :questions do + match 'feed' => 'questions#feed', + :as => :feed, + :on => :collection + end + resources :questions do resources :answers end diff --git a/features/admin.feature b/features/admin.feature new file mode 100644 index 00000000..c9772c03 --- /dev/null +++ b/features/admin.feature @@ -0,0 +1,2 @@ +Feature: Admin functionality + Scenario: Admin page diff --git a/views/admin/index.haml b/views/admin/index.haml new file mode 100644 index 00000000..98f5a270 --- /dev/null +++ b/views/admin/index.haml @@ -0,0 +1,24 @@ +%h1= current_user.username + "'s admin page" +%img{:src => current_user.gravatar_url} + +%p Total Hacker Count: #{@usercount} + +%p New Users Today: #{@newusers} +%ul + - @newusernames.each do |name| + %li + %a{:href => "/hackers/#{name.username}"}= name.username + +%p New Forum Discussions: #{@forumposts} +%ul + - @postlinks.each do |postlink| + %li + %a{:href => "/forums/#{postlink.forum}/#{postlink.slug}"}= postlink.title + +%p New Forum Replies: #{@forumreplies} +%ul + - @postlinks.each do |replylink| + %li + %a{:href => "/forums/#{replylink.forum}/#{replylink.slug}"}= replylink.slug + +