1 class DiaryEntryController < ApplicationController
2 layout 'site', :except => :rss
4 before_filter :authorize_web
5 before_filter :require_user, :only => [:new]
8 @title = 'new diary entry'
9 if params[:diary_entry]
10 @diary_entry = DiaryEntry.new(params[:diary_entry])
11 @diary_entry.user = @user
13 redirect_to :controller => 'diary_entry', :action => 'list', :display_name => @user.display_name
19 @entry = DiaryEntry.find(params[:id])
20 @diary_comment = @entry.diary_comments.build(params[:diary_comment])
21 @diary_comment.user = @user
22 if @diary_comment.save
23 Notifier::deliver_diary_comment_notification(@diary_comment)
24 redirect_to :controller => 'diary_entry', :action => 'view', :display_name => @entry.user.display_name, :id => @entry.id
26 render :action => 'view'
31 if params[:display_name]
32 @this_user = User.find_by_display_name(params[:display_name])
34 @title = @this_user.display_name + "'s diary"
35 @entry_pages, @entries = paginate(:diary_entries,
36 :conditions => ['user_id = ?', @this_user.id],
37 :order => 'created_at DESC',
40 @not_found_user = params[:display_name]
41 render :action => 'no_such_user', :status => :not_found
44 @title = "Users' diaries"
45 @entry_pages, @entries = paginate(:diary_entries,
46 :order => 'created_at DESC',
52 if params[:display_name]
53 user = User.find_by_display_name(params[:display_name])
54 @entries = DiaryEntry.find(:all, :conditions => ['user_id = ?', user.id], :order => 'created_at DESC', :limit => 20)
55 @title = "OpenStreetMap diary entries for #{user.display_name}"
56 @description = "Recent OpenStreetmap diary entries from #{user.display_name}"
57 @link = "http://www.openstreetmap.org/user/#{user.display_name}/diary"
59 @entries = DiaryEntry.find(:all, :order => 'created_at DESC', :limit => 20)
60 @title = "OpenStreetMap diary entries"
61 @description = "Recent diary entries from users of OpenStreetMap"
62 @link = "http://www.openstreetmap.org/diary"
65 render :content_type => Mime::RSS
69 user = User.find_by_display_name(params[:display_name])
70 @entry = DiaryEntry.find(:first, :conditions => ['user_id = ? AND id = ?', user.id, params[:id]])