Adding RSS feed to main diary page, with space for lat/long info to be associated with each post in the future, though that needs adding still.

This commit is contained in:
Dan Karran 2007-06-11 21:42:00 +00:00
parent c43fac76df
commit b4e6a72858
2 changed files with 24 additions and 1 deletions

View file

@ -5,6 +5,7 @@ class DiaryEntryController < ApplicationController
before_filter :require_user, :only => [:new]
def new
@title = 'new diary entry'
if params[:diary_entry]
@entry = DiaryEntry.new(params[:diary_entry])
@entry.user = @user
@ -15,6 +16,25 @@ class DiaryEntryController < ApplicationController
end
def list
@title = 'recent diary entries'
@entries=DiaryEntry.find(:all, :order => 'created_at DESC', :limit=>20)
end
def rss
@entries=DiaryEntry.find(:all, :order => 'created_at DESC', :limit=>20)
rss = OSM::GeoRSS.new('OpenStreetMap diary entries', 'Recent diary entries from users of OpenStreetMap', 'http://www.openstreetmap.org/diary')
@entries.each do |entry|
# add geodata here
latitude = nil
longitude = nil
rss.add(latitude, longitude, entry.title, url_for({:controller => 'user', :action => 'diary', :id => entry.id, :display_name => entry.user.display_name}), entry.body, entry.created_at)
end
response.headers["Content-Type"] = 'application/xml+rss'
render :text => rss.to_s
end
end

View file

@ -1,3 +1,6 @@
<h3>most recent posts:</h3>
<h3>Recent diary entries:</h3>
<br />
<%= render :partial => 'diary_entry/diary_entry', :collection => @entries %>
<%= link_to(image_tag("RSS.gif", :size => "16x16", :border => 0), :action => 'rss') %>
<%= auto_discovery_link_tag(:atom, :action => 'rss') %>