1 class DiaryEntryController < ApplicationController
4 before_filter :authorize_web
5 before_filter :require_user, :only => [:new]
8 @title = 'new diary entry'
9 if params[:diary_entry]
10 @entry = DiaryEntry.new(params[:diary_entry])
13 redirect_to :controller => 'diary_entry', :action => 'list', :display_name => @user.display_name
19 if params[:display_name]
20 @this_user = User.find_by_display_name(params[:display_name])
21 @title = @this_user.display_name + "'s diary"
23 @entries=DiaryEntry.find(:all, :conditions => ['user_id = ? AND id = ?', @this_user.id, params[:id]])
25 @entries=DiaryEntry.find(:all, :conditions => ['user_id = ?', @this_user.id], :order => 'created_at DESC')
28 @title = 'recent diary entries'
29 @entries=DiaryEntry.find(:all, :order => 'created_at DESC', :limit => 20)
34 if params[:display_name]
35 @this_user = User.find_by_display_name(params[:display_name])
36 @entries=DiaryEntry.find(:all, :conditions => ['user_id = ?', @this_user.id], :order => 'created_at DESC', :limit => 20)
37 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")
39 @entries=DiaryEntry.find(:all, :order => 'created_at DESC', :limit => 20)
40 rss = OSM::GeoRSS.new('OpenStreetMap diary entries', 'Recent diary entries from users of OpenStreetMap', 'http://www.openstreetmap.org/diary')
43 @entries.each do |entry|
47 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)
50 response.headers["Content-Type"] = 'application/rss+xml'
52 render :text => rss.to_s