diff --git a/app/controllers/diary_entry_controller.rb b/app/controllers/diary_entry_controller.rb
index 7c77fc177..c25c8718d 100644
--- a/app/controllers/diary_entry_controller.rb
+++ b/app/controllers/diary_entry_controller.rb
@@ -1,2 +1,16 @@
class DiaryEntryController < ApplicationController
+ layout 'site'
+
+ before_filter :authorize_web
+ before_filter :require_user
+
+ def new
+ if 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
end
diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb
index 9fd20f2ff..3837d0976 100644
--- a/app/controllers/user_controller.rb
+++ b/app/controllers/user_controller.rb
@@ -2,7 +2,7 @@ class UserController < ApplicationController
layout 'site'
before_filter :authorize, :only => [:preferences, :api_details, :api_gpx_files]
- before_filter :authorize_web, :only => [:edit, :account, :go_public, :view]
+ before_filter :authorize_web, :only => [:edit, :account, :go_public, :view, :diary]
before_filter :require_user, :only => [:edit, :account, :go_public]
def save
@@ -139,11 +139,14 @@ class UserController < ApplicationController
render :text => doc.to_s
end
-
def view
@this_user = User.find_by_display_name(params[:display_name])
end
+ def diary
+ @this_user = User.find_by_display_name(params[:display_name])
+ end
+
end
diff --git a/app/models/diary_entry.rb b/app/models/diary_entry.rb
index 2da92d400..ad334151c 100644
--- a/app/models/diary_entry.rb
+++ b/app/models/diary_entry.rb
@@ -1,2 +1,3 @@
class DiaryEntry < ActiveRecord::Base
+ belongs_to :user
end
diff --git a/app/models/user.rb b/app/models/user.rb
index 780e0caaf..7befa479a 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -3,6 +3,7 @@ class User < ActiveRecord::Base
require 'digest/md5'
has_many :traces
+ has_many :diary_entries
validates_confirmation_of :pass_crypt, :message => 'Password must match the confirmation password'
validates_uniqueness_of :display_name, :allow_nil => true
diff --git a/app/views/diary_entry/_diary_entry.rhtml b/app/views/diary_entry/_diary_entry.rhtml
new file mode 100644
index 000000000..cf9115f6c
--- /dev/null
+++ b/app/views/diary_entry/_diary_entry.rhtml
@@ -0,0 +1,3 @@
+<%= diary_entry.title %>
+<%= simple_format(diary_entry.body) %>
+
diff --git a/app/views/diary_entry/new.rhtml b/app/views/diary_entry/new.rhtml
new file mode 100644
index 000000000..ead58944c
--- /dev/null
+++ b/app/views/diary_entry/new.rhtml
@@ -0,0 +1,7 @@
+<%= error_messages_for 'diary_entry' %>
+
+<%= start_form_tag :controller => 'diary_entry', :action => 'new' %>
+subject<%= text_field 'diary_entry', 'title' %>
+body<%= text_area 'diary_entry', 'body' %>
+ <%= submit_tag 'Save' %>
+<% end_form_tag %>
diff --git a/app/views/user/diary.rhtml b/app/views/user/diary.rhtml
new file mode 100644
index 000000000..abe896db9
--- /dev/null
+++ b/app/views/user/diary.rhtml
@@ -0,0 +1,8 @@
+