X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/072b0717e4d7fd69e1d28c5c4c3805c7fb4f563e..9b67da24c034bacb0e7cf8c907e8ae3a31423469:/app/controllers/diary_entry_controller.rb?ds=sidebyside diff --git a/app/controllers/diary_entry_controller.rb b/app/controllers/diary_entry_controller.rb index 4b94a7071..b072fc0e3 100644 --- a/app/controllers/diary_entry_controller.rb +++ b/app/controllers/diary_entry_controller.rb @@ -10,31 +10,44 @@ class DiaryEntryController < ApplicationController @entry = DiaryEntry.new(params[:diary_entry]) @entry.user = @user if @entry.save - redirect_to :controller => 'user', :action => 'diary', :display_name => @user.display_name + redirect_to :controller => 'diary_entry', :action => 'list', :display_name => @user.display_name end end end def list - @title = 'recent diary entries' - @entries=DiaryEntry.find(:all, :order => 'created_at DESC', :limit=>20) + if params[:display_name] + @this_user = User.find_by_display_name(params[:display_name]) + @title = @this_user.display_name + "'s diary" + if params[:id] + @entries=DiaryEntry.find(:all, :conditions => ['user_id = ? AND id = ?', @this_user.id, params[:id]]) + else + @entries=DiaryEntry.find(:all, :conditions => ['user_id = ?', @this_user.id], :order => 'created_at DESC') + end + else + @title = 'recent diary entries' + @entries=DiaryEntry.find(:all, :order => 'created_at DESC', :limit => 20) + end 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') + if params[:display_name] + @this_user = User.find_by_display_name(params[:display_name]) + @entries=DiaryEntry.find(:all, :conditions => ['user_id = ?', @this_user.id], :order => 'created_at DESC', :limit => 20) + rss = OSM::GeoRSS.new("OpenStreetMap diary entries for #{@this_user.display_name}", "Recent OpenStreetmap diary entries from #{@this_user.display_name}", "http://www.openstreetmap.org/user/#{@this_user.display_name}/diary") + else + @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') + end @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) + rss.add(latitude, longitude, entry.title, url_for({:controller => 'diary_entry', :action => 'list', :id => entry.id, :display_name => entry.user.display_name}), entry.body, entry.created_at) end - response.headers["Content-Type"] = 'application/rss+xml' - - render :text => rss.to_s + render :text => rss.to_s, :content_type => "application/rss+xml" end end