Commit e0e6ee0c071efcd1e02bb33b45184f79be4a63c9

Authored by Nick Recobra
1 parent 98db4dcf
Exists in master and in 1 other branch production

Atom feeds per app.

app/controllers/apps_controller.rb
@@ -8,8 +8,15 @@ class AppsController < ApplicationController @@ -8,8 +8,15 @@ class AppsController < ApplicationController
8 end 8 end
9 9
10 def show 10 def show
11 - @errs = @app.errs.ordered.paginate(:page => params[:page], :per_page => Err.per_page)  
12 - @deploys = @app.deploys.order_by(:created_at.desc).limit(5) 11 + respond_to do |format|
  12 + format.html do
  13 + @errs = @app.errs.ordered.paginate(:page => params[:page], :per_page => Err.per_page)
  14 + @deploys = @app.deploys.order_by(:created_at.desc).limit(5)
  15 + end
  16 + format.atom do
  17 + @errs = @app.errs.unresolved.ordered
  18 + end
  19 + end
13 end 20 end
14 21
15 def new 22 def new
app/views/apps/show.atom.builder 0 → 100644
@@ -0,0 +1,4 @@ @@ -0,0 +1,4 @@
  1 +atom_feed do |feed|
  2 + feed.title("Errbit notices for #{h @app.name} at #{root_url}")
  3 + render :partial => "errs/list", :locals => {:feed => feed}
  4 +end
app/views/apps/show.html.haml
1 - content_for :title, @app.name 1 - content_for :title, @app.name
  2 +- content_for :head do
  3 + = auto_discovery_link_tag :atom, app_url(@app, User.token_authentication_key => current_user.authentication_token, :format => "atom"), :title => "Errbit notices for #{@app.name} at #{root_url}"
2 - content_for :meta do 4 - content_for :meta do
3 %strong Errs Caught: 5 %strong Errs Caught:
4 = @app.errs.count 6 = @app.errs.count
app/views/errs/_list.atom.builder 0 → 100644
@@ -0,0 +1,15 @@ @@ -0,0 +1,15 @@
  1 +feed.updated(@errs.first.created_at)
  2 +
  3 +for err in @errs
  4 + notice = err.notices.first
  5 +
  6 + feed.entry(err, :url => app_err_url(err.app, err)) do |entry|
  7 + entry.title "[#{ err.where }] #{err.message.to_s.truncate(27)}"
  8 + entry.author do |author|
  9 + author.name "#{ err.app.name } [#{ err.environment }]"
  10 + end
  11 + if notice
  12 + entry.summary(notice_atom_summary(notice), :type => "html")
  13 + end
  14 + end
  15 +end
app/views/errs/index.atom.builder
1 atom_feed do |feed| 1 atom_feed do |feed|
2 feed.title("Errbit notices at #{root_url}") 2 feed.title("Errbit notices at #{root_url}")
3 - feed.updated(@errs.first.created_at)  
4 -  
5 - for err in @errs  
6 - notice = err.notices.first  
7 -  
8 - feed.entry(err, :url => app_err_url(err.app, err)) do |entry|  
9 - entry.title "[#{ err.where }] #{err.message.to_s.truncate(27)}"  
10 - entry.author do |author|  
11 - author.name "#{ err.app.name } [#{ err.environment }]"  
12 - end  
13 - if notice  
14 - entry.summary(notice_atom_summary(notice), :type => "html")  
15 - end  
16 - end  
17 - end 3 + render :partial => "errs/list", :locals => {:feed => feed}
18 end 4 end