zh / tamanegi

RSS/Atom feeds aggregator, powered by Ramaze. Using Sequel for ORM.

tamanegi / controller / item.rb
100644 29 lines (24 sloc) 0.787 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class ItemController < Ramaze::Controller
  map '/'
  layout :layout
  deny_layout :atom
  helper :pager
 
  def index
    @title = "The state of the onion"
    @ids, @pager = paginate(Item.order(:id.desc).map(:id),
                            :limit => Configuration.for('app').one_page)
  end
 
  def show title
    redirect Rs() unless @item = Item[:title => title.uri_unescape]
    @title = @item.title
  end
 
  # cached for 15 minutes
  def atom
    sup_id = Configuration.for('app').sup_id
    response['Content-Type'] = 'application/atom+xml'
    response['Cache-Control'] = 'max-age=900, public'
    response['Expires'] = (Time.now + 900).utc.rfc2822
    response['X-SUP-ID'] = "http://friendfeed.com/api/public-sup.json##{sup_id}"
    respond Tamanegi::to_atom.to_xml
  end
 
end