public
Description: The open source social networking platform in Ruby on Rails from the author of RailsSpace
Homepage: http://insoshi.com
Clone URL: git://github.com/insoshi/insoshi.git
Got started on feed message
Works for Connection events
Refactored Markaby helper in the process
Michael Hartl (author)
Sun Mar 09 14:52:56 -0700 2008
commit  482cb4c1fd89597c8c28f17e49df48c750adaaaf
tree    e32dd5e4332fcf822d3d500173dab10fcd3154f4
parent  56674bdb06c4d600c656888daf7ce4931ff25110
...
3
4
5
 
 
 
6
7
8
...
3
4
5
6
7
8
9
10
11
0
@@ -3,6 +3,9 @@ class HomeController < ApplicationController
0
   before_filter :login_required
0
   
0
   def index
0
+
0
+ @feed = Event.find(:all, :limit => 5, :order => "created_at DESC")
0
+
0
     # This is a stub for the real feed.
0
     # TODO: make a real feed :-)
0
     @mary = Person.find_by_email("mary@michaelhartl.com")
...
1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
0
@@ -1,2 +1,29 @@
0
 module EventsHelper
0
+
0
+ # Given an event, return a message for the feed for the event's class.
0
+ def feed_message(event)
0
+ case event.class.to_s
0
+ when "ConnectionEvent"
0
+ link_1 = link_to(event.person.name, event.person)
0
+ link_2 = link_to(event.conn.contact.name, event.conn.contact)
0
+ msg = "#{link_1} and #{link_2} have connected"
0
+ else
0
+ "bar"
0
+ end
0
+ message_row(event, msg)
0
+ end
0
+
0
+
0
+ private
0
+
0
+ # Return a standard row element for a feed message.
0
+ def message_row(event, message)
0
+ markaby do
0
+ tr do
0
+ person = event.person
0
+ td { link_to(image_tag(person.icon), person) }
0
+ td { message }
0
+ end
0
+ end
0
+ end
0
 end
...
1
2
 
 
 
 
 
 
 
3
4
5
...
1
2
3
4
5
6
7
8
9
10
11
12
0
@@ -1,5 +1,12 @@
0
 <table>
0
   <tr><th colspan="3">Activity Feed</th></tr>
0
+
0
+ <%- @feed.each do |event| -%>
0
+ <tr>
0
+ <td><%= feed_message event %></td>
0
+ </tr>
0
+ <%- end -%>
0
+
0
   <tr>
0
       <td><%= image_tag @mary.icon %></td>
0
       <td>

Comments

    No one has commented yet.