Skip to content

Commit be1213e

Browse files
committed
Just needs some final testing...
1 parent 69256d4 commit be1213e

10 files changed

Lines changed: 4076 additions & 98 deletions

File tree

app/controllers/messages_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class MessagesController < ApplicationController
22
def index
3-
@messages = Message.all
3+
@messages = Message.find(:all, :conditions => ["recipient_id == ?", current_user.id])
44
end
55

66
def show
@@ -21,7 +21,7 @@ def create
2121

2222
if @message.save
2323
flash[:notice] = 'Message was successfully created.'
24-
redirect_to dashboard_url
24+
redirect_to user_path(@message.recipient)
2525
else
2626
render :action => "new"
2727
end

app/controllers/user_sessions_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def create
77
@user_session = UserSession.new(params[:user_session])
88
if @user_session.save
99
flash[:notice] = "Successfully logged in."
10-
redirect_to dashboard_url
10+
redirect_to user_path(current_user)
1111
else
1212
render :action => 'new'
1313
end

app/controllers/users_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def create
1111
steve.watchings.build(:watches_id => @user.id).save
1212
@user.watchings.build(:watches_id => 1).save
1313
flash[:notice] = "Registration successful."
14-
redirect_to dashboard_url
14+
redirect_to user_path(@user)
1515
else
1616
render :action => 'new'
1717
end

app/views/dashboard/index.html.erb

Lines changed: 0 additions & 63 deletions
This file was deleted.

app/views/layouts/application.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<%= image_tag "hhhello.png", :id => "hello" %>
1515
<div id="nav">
1616
<% if current_user %>
17-
<%= link_to "Dashboard", dashboard_path %> |
17+
<%= link_to "My messages", messages_path %> |
1818
<%= link_to "My page", user_path(current_user.username) %> |
1919
<%= link_to "Edit info", edit_user_path(current_user.username) %> |
2020
<%= link_to "Log out", logout_path %>

app/views/messages/index.html.erb

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,7 @@
1-
<h1>Listing messages</h1>
2-
3-
<table>
4-
<tr>
5-
<th>Sender</th>
6-
<th>Recipient</th>
7-
<th>Text</th>
8-
</tr>
9-
10-
<% @messages.each do |message| %>
11-
<tr>
12-
<td><%=h message.sender_id %></td>
13-
<td><%=h message.recipient_id %></td>
14-
<td><%=h message.text %></td>
15-
<td><%= link_to 'Show', message %></td>
16-
<td><%= link_to 'Edit', edit_message_path(message) %></td>
17-
<td><%= link_to 'Destroy', message, :confirm => 'Are you sure?', :method => :delete %></td>
18-
</tr>
19-
<% end %>
20-
</table>
21-
22-
<br />
23-
24-
<%= link_to 'New message', new_message_path %>
1+
<%= link_to "Send a message", new_message_path %><br /><br />
2+
<% if @messages.count == 0 %>
3+
<p>Sorry, you don't have any messages.</p>
4+
<% end %>
5+
<% for message in @messages %>
6+
<div style="text-align:left;float:left;max-width:550px" ><%= link_to image_tag(message.sender.avatar_url, :style => "height:2em;"), user_path(message.sender.username) %><span style="vertical-align:super"><%= truncate message.text, :length => 45 %><%= link_to "(full)", message %></span></div><br style="clear:both" />
7+
<% end %>

app/views/programs/show.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
<h2>Comments</h2><br />
1717
<% @program.comments.each do |comment| %>
1818
<% if cycle("yes","no") == "yes" %>
19-
<div style="text-align:left;float:left;max-width:550px" ><%= image_tag comment.user.avatar_url, :style => "height:2em;" %><span style="vertical-align:super"><%= comment.text %></span></div><br style="clear:both" />
19+
<div style="text-align:left;float:left;max-width:550px" ><%= link_to image_tag(comment.user.avatar_url, :style => "height:2em;"), user_path(comment.user.username) %><span style="vertical-align:super"><%= comment.text %></span></div><br style="clear:both" />
2020
<% else %>
21-
<div style="text-align:right;float:right;max-width:550px" ><span style="vertical-align:super"><%= comment.text %></span><%= image_tag comment.user.avatar_url, :style => "height:2em;" %></div><br style="clear:both" />
21+
<div style="text-align:right;float:right;max-width:550px" ><span style="vertical-align:super"><%= comment.text %></span><%= link_to image_tag(comment.user.avatar_url, :style => "height:2em;"), user_path(comment.user.username) %></div><br style="clear:both" />
2222
<% end %>
2323
<% end %>
2424
<br style="clear:both"/>

app/views/users/show.html.erb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
<p><%= link_to @user.link, @user.link %></p>
66
<p><%= @user.about %></p>
77
<% unless @user == current_user %>
8-
<%= link_to "Watch #{@user.username}", watchings_path(:watches_id => @user), :method => :post %>
8+
<% if current_user.watches.include? @user %>
9+
<%= link_to "Stop watching #{@user.username}", watching_path(current_user.watchings.detect(@user).first), :method => :delete %>
10+
<% else %>
11+
<%= link_to "Watch #{@user.username}", watchings_path(:watches_id => @user), :method => :post %>
12+
<% end %>
913
<% else %>
1014
<br />
1115
<% end %>
@@ -21,6 +25,9 @@
2125
<li><%= link_to program.name, program %> - <%= program.description %></li>
2226
<% end %>
2327
</ul>
28+
<% if @user == current_user %>
29+
<%= link_to "Make a new program", new_program_path %>
30+
<% end %>
2431
</div>
2532
<br style="clear:both" />
2633
<hr style="width:550px;" />

config/routes.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
map.root :controller => "welcome"
1111

12-
map.dashboard "/dashboard", :controller => "dashboard"
13-
1412
map.login "login", :controller => "user_sessions", :action => "new"
1513
map.logout "logout", :controller => "user_sessions", :action => "destroy"
1614

0 commit comments

Comments
 (0)