1 class DiaryEntryController < ApplicationController
2 layout 'site', :except => :rss
4 before_filter :authorize_web
5 before_filter :require_user, :only => [:new]
6 before_filter :check_database_availability
9 @title = 'new diary entry'
10 if params[:diary_entry]
11 @diary_entry = DiaryEntry.new(params[:diary_entry])
12 @diary_entry.user = @user
14 redirect_to :controller => 'diary_entry', :action => 'list', :display_name => @user.display_name
20 @entry = DiaryEntry.find(params[:id])
21 @diary_comment = @entry.diary_comments.build(params[:diary_comment])
22 @diary_comment.user = @user
23 if @diary_comment.save
24 Notifier::deliver_diary_comment_notification(@diary_comment)
25 redirect_to :controller => 'diary_entry', :action => 'view', :display_name => @entry.user.display_name, :id => @entry.id
27 render :action => 'view'
32 if params[:display_name]
33 @this_user = User.find_by_display_name(params[:display_name])
35 @title = @this_user.display_name + "'s diary"
36 @entry_pages, @entries = paginate(:diary_entries,
37 :conditions => ['user_id = ?', @this_user.id],
38 :order => 'created_at DESC',
41 @not_found_user = params[:display_name]
43 render :action => 'no_such_user', :status => :not_found
46 @title = "Users' diaries"
47 @entry_pages, @entries = paginate(:diary_entries,
48 :order => 'created_at DESC',
54 if params[:display_name]
55 user = User.find_by_display_name(params[:display_name])
58 @entries = DiaryEntry.find(:all, :conditions => ['user_id = ?', user.id], :order => 'created_at DESC', :limit => 20)
59 @title = "OpenStreetMap diary entries for #{user.display_name}"
60 @description = "Recent OpenStreetmap diary entries from #{user.display_name}"
61 @link = "http://www.openstreetmap.org/user/#{user.display_name}/diary"
63 render :content_type => Mime::RSS
65 render :nothing => true, :status => :not_found
68 @entries = DiaryEntry.find(:all, :order => 'created_at DESC', :limit => 20)
69 @title = "OpenStreetMap diary entries"
70 @description = "Recent diary entries from users of OpenStreetMap"
71 @link = "http://www.openstreetmap.org/diary"
73 render :content_type => Mime::RSS
78 user = User.find_by_display_name(params[:display_name])
81 @entry = DiaryEntry.find(:first, :conditions => ['user_id = ? AND id = ?', user.id, params[:id]])
83 @not_found_user = params[:display_name]
85 render :action => 'no_such_user', :status => :not_found