various diary bits
This commit is contained in:
parent
f9baf5f392
commit
f498a9287a
11 changed files with 61 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
class DiaryEntry < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
3
app/views/diary_entry/_diary_entry.rhtml
Normal file
3
app/views/diary_entry/_diary_entry.rhtml
Normal file
|
@ -0,0 +1,3 @@
|
|||
<b><%= diary_entry.title %></b><br />
|
||||
<%= simple_format(diary_entry.body) %>
|
||||
<br />
|
7
app/views/diary_entry/new.rhtml
Normal file
7
app/views/diary_entry/new.rhtml
Normal file
|
@ -0,0 +1,7 @@
|
|||
<%= 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 %>
|
8
app/views/user/diary.rhtml
Normal file
8
app/views/user/diary.rhtml
Normal file
|
@ -0,0 +1,8 @@
|
|||
<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 %>
|
|
@ -12,7 +12,8 @@ By creating an account, you agree that all work uploaded to openstreetmap.org an
|
|||
<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">
|
||||
|
||||
|
|
13
app/views/user/view.rhtml
Normal file
13
app/views/user/view.rhtml
Normal file
|
@ -0,0 +1,13 @@
|
|||
<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) %>
|
||||
|
||||
|
|
@ -55,7 +55,8 @@ ActionController::Routing::Routes.draw do |map|
|
|||
# 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'
|
||||
|
||||
|
|
|
@ -36,3 +36,8 @@ alter table gpx_files drop column tmpname;
|
|||
|
||||
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;
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue