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
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
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
class DiaryEntry < ActiveRecord::Base
+ belongs_to :user
end
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
--- /dev/null
+<b><%= diary_entry.title %></b><br />
+<%= simple_format(diary_entry.body) %>
+<br />
--- /dev/null
+<%= error_messages_for 'diary_entry' %>
+
+<%= start_form_tag :controller => 'diary_entry', :action => 'new' %>
+subject<%= text_field 'diary_entry', 'title' %><br>
+body<%= text_area 'diary_entry', 'body' %><br>
+ <%= submit_tag 'Save' %>
+<% end_form_tag %>
--- /dev/null
+<h2><%= @this_user.display_name %>'s diary</h2>
+<% if @this_user.id == @user.id %>
+ <%= link_to 'new post', :controller => 'diary_entry', :action => 'new', :display_name => @user.display_name %>
+<% end %>
+
+<h3>recent posts:</h3>
+FIXME: geoRSS needed<br><br>
+<%= render :partial => 'diary_entry/diary_entry', :collection => @this_user.diary_entries %>
<tr><td>password:</td><td><%= password_field('user', 'pass_crypt',{:size => 50, :maxlength => 255}) %></td></tr>
<tr><td>retype password:</td><td><%= password_field('user', 'pass_crypt_confirmation',{:size => 50, :maxlength => 255}) %></td></tr>
</table>
-
+<br>
+FIXME OL map so people can submit where they live
<br>
<input type="submit" value="Signup">
--- /dev/null
+<h2><%= @this_user.display_name %></h2>
+<% if @this_user.id == @user.id %>
+ <%= link_to 'go to your account page', :controller => 'user', :action => 'account', :display_name => @user.display_name %><br /><br />
+<% else %>
+ <%= link_to 'send message', :controller => 'user', :action => 'message', :display_name => @user.display_name %><br /><br /> |
+ <%= link_to 'Add as friend', :controller => 'user', :action => 'make_friend', :display_name => @user.display_name %><br /><br />
+<% end %>
+
+<%= link_to 'diary', :controller => 'user', :action => 'diary', :display_name => @user.display_name %><br /><br />
+
+<%= simple_format(@this_user.description) %>
+
+
# user pages
map.connect '/user/:display_name', :controller => 'user', :action => 'view'
- map.connect '/user/:display_name/diary', :controller => 'diary', :action => 'view'
+ map.connect '/user/:display_name/diary', :controller => 'user', :action => 'diary'
+ map.connect '/user/:display_name/diary/newpost', :controller => 'diary_entry', :action => 'new'
map.connect '/user/:display_name/edit', :controller => 'user', :action => 'edit'
map.connect '/user/:display_name/account', :controller => 'user', :action => 'account'
alter table users add column description text not null;
create table diary_entries(id bigint not null auto_increment, user_id bigint not null, title varchar(255), body text, primary key(id));
+alter table diary_entries add created_at datetime;
+alter table diary_entries add updated_at datetime;
+
+
+