From f9baf5f392370318966c9392e3badbbd715592ad Mon Sep 17 00:00:00 2001 From: Steve Coast Date: Sat, 7 Apr 2007 19:50:55 +0000 Subject: [PATCH] diary / user bits --- app/controllers/diary_entry_controller.rb | 2 ++ app/controllers/user_controller.rb | 2 +- app/helpers/diary_entry_helper.rb | 2 ++ app/models/diary_entry.rb | 2 ++ app/views/layouts/site.rhtml | 3 +-- app/views/user/account.rhtml | 2 +- app/views/user/edit.rhtml | 10 ++++++---- config/routes.rb | 3 ++- db/migrate.sql | 1 + db/migrate/017_create_diary_entries.rb | 10 ++++++++++ 10 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 app/controllers/diary_entry_controller.rb create mode 100644 app/helpers/diary_entry_helper.rb create mode 100644 app/models/diary_entry.rb create mode 100644 db/migrate/017_create_diary_entries.rb diff --git a/app/controllers/diary_entry_controller.rb b/app/controllers/diary_entry_controller.rb new file mode 100644 index 000000000..7c77fc177 --- /dev/null +++ b/app/controllers/diary_entry_controller.rb @@ -0,0 +1,2 @@ +class DiaryEntryController < ApplicationController +end diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index d79041b4f..9fd20f2ff 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] + before_filter :authorize_web, :only => [:edit, :account, :go_public, :view] before_filter :require_user, :only => [:edit, :account, :go_public] def save diff --git a/app/helpers/diary_entry_helper.rb b/app/helpers/diary_entry_helper.rb new file mode 100644 index 000000000..bf6af03da --- /dev/null +++ b/app/helpers/diary_entry_helper.rb @@ -0,0 +1,2 @@ +module DiaryEntryHelper +end diff --git a/app/models/diary_entry.rb b/app/models/diary_entry.rb new file mode 100644 index 000000000..2da92d400 --- /dev/null +++ b/app/models/diary_entry.rb @@ -0,0 +1,2 @@ +class DiaryEntry < ActiveRecord::Base +end diff --git a/app/views/layouts/site.rhtml b/app/views/layouts/site.rhtml index c7670e795..f2cc5b4fe 100644 --- a/app/views/layouts/site.rhtml +++ b/app/views/layouts/site.rhtml @@ -24,8 +24,7 @@ <% if @user %> - Welcome, <%= @user.display_name %> | - <%= link_to 'account', {:controller => 'user', :action => 'account'}, {:id => 'loginanchor'}%> | + Welcome, <%= link_to @user.display_name, {:controller => 'user', :action => 'view', :display_name => @user.display_name}, {:id => 'loginanchor'}%> | <%= link_to 'logout', {:controller => 'user', :action => 'logout'}, {:id => 'loginanchor'}%> <% else %> <%= link_to 'log in', {:controller => 'user', :action => 'login'}, {:id => 'loginanchor'}%> | diff --git a/app/views/user/account.rhtml b/app/views/user/account.rhtml index 81f72fe04..f8047d3d8 100644 --- a/app/views/user/account.rhtml +++ b/app/views/user/account.rhtml @@ -4,7 +4,7 @@ email<%= @user.email %> display name<%= @user.display_name %> (<%= link_to 'change...', :controller => 'user', :action => 'edit' %>) account created<%= @user.creation_time %> (<%= time_ago_in_words(@user.creation_time) %> ago) - description<%= @user.description %> (<%= link_to 'change...', :controller => 'user', :action => 'edit' %>) + description<%= simple_format(@user.description) %> (<%= link_to 'change...', :controller => 'user', :action => 'edit' %>)

Privacy

diff --git a/app/views/user/edit.rhtml b/app/views/user/edit.rhtml index 5e9db6f29..6c30ef0b3 100644 --- a/app/views/user/edit.rhtml +++ b/app/views/user/edit.rhtml @@ -1,7 +1,9 @@ -

Display name:

- +

Edit details:

<%= error_messages_for 'user' %> -<%= start_form_tag :controller => 'user', :action => 'rename' %> -<%= text_field :user, :display_name, :value => @user.display_name %> +<%= start_form_tag :controller => 'user', :action => 'edit', :display_name => @user.display_name %> + + + +
display name<%= text_field :user, :display_name, :value => @user.display_name %>
description<%= text_area :user, :description, :value => @user.description %>
<%= submit_tag 'Change' %> <%= end_form_tag %> diff --git a/config/routes.rb b/config/routes.rb index 039eea09f..8bfc36388 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -33,7 +33,6 @@ ActionController::Routing::Routes.draw do |map| map.connect '/search.html', :controller => 'way_tag', :action => 'search' map.connect '/login.html', :controller => 'user', :action => 'login' map.connect '/logout.html', :controller => 'user', :action => 'logout' - map.connect '/account', :controller => 'user', :action => 'account' map.connect '/create-account.html', :controller => 'user', :action => 'new' map.connect '/forgot-password.html', :controller => 'user', :action => 'lost_password' @@ -57,6 +56,8 @@ ActionController::Routing::Routes.draw do |map| map.connect '/user/:display_name', :controller => 'user', :action => 'view' map.connect '/user/:display_name/diary', :controller => 'diary', :action => 'view' + map.connect '/user/:display_name/edit', :controller => 'user', :action => 'edit' + map.connect '/user/:display_name/account', :controller => 'user', :action => 'account' # test pages map.connect '/test/populate/:table/:from/:count', :controller => 'test', :action => 'populate' diff --git a/db/migrate.sql b/db/migrate.sql index f6d2fc408..6f7266cef 100644 --- a/db/migrate.sql +++ b/db/migrate.sql @@ -35,3 +35,4 @@ alter table users add data_public boolean default false; 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)); diff --git a/db/migrate/017_create_diary_entries.rb b/db/migrate/017_create_diary_entries.rb new file mode 100644 index 000000000..e81044d0f --- /dev/null +++ b/db/migrate/017_create_diary_entries.rb @@ -0,0 +1,10 @@ +class CreateDiaryEntries < ActiveRecord::Migration + def self.up + create_table :diary_entries do |t| + end + end + + def self.down + drop_table :diary_entries + end +end -- 2.39.5