From: Dan Karran Date: Mon, 11 Jun 2007 21:42:00 +0000 (+0000) Subject: Adding RSS feed to main diary page, with space for lat/long info to be associated... X-Git-Tag: live~8436 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/b4e6a72858b3dbe2ed282b7e7eced318fa90e516 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. --- diff --git a/app/controllers/diary_entry_controller.rb b/app/controllers/diary_entry_controller.rb index f8e2a5761..9dba46879 100644 --- a/app/controllers/diary_entry_controller.rb +++ b/app/controllers/diary_entry_controller.rb @@ -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 diff --git a/app/views/diary_entry/list.rhtml b/app/views/diary_entry/list.rhtml index 8597380c5..06aebdfef 100644 --- a/app/views/diary_entry/list.rhtml +++ b/app/views/diary_entry/list.rhtml @@ -1,3 +1,6 @@ -

most recent posts:

+

Recent diary entries:


<%= 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') %> \ No newline at end of file