X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/f498a9287a25fc284ef0e1fd90ea8ca91e661183..945e4ddcc85bd8d0ec1b1c950a1af5c98e9460b8:/app/controllers/diary_entry_controller.rb diff --git a/app/controllers/diary_entry_controller.rb b/app/controllers/diary_entry_controller.rb index c25c8718d..9dba46879 100644 --- a/app/controllers/diary_entry_controller.rb +++ b/app/controllers/diary_entry_controller.rb @@ -2,15 +2,39 @@ class DiaryEntryController < ApplicationController layout 'site' before_filter :authorize_web - before_filter :require_user + before_filter :require_user, :only => [:new] def new + @title = 'new diary entry' if params[:diary_entry] - @entry = DiaryEntry.new(@params[:diary_entry]) + @entry = DiaryEntry.new(params[:diary_entry]) @entry.user = @user if @entry.save redirect_to :controller => 'user', :action => 'diary', :display_name => @user.display_name end end 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