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
Added new messages to home page
Michael Hartl (author)
Fri Feb 29 22:51:37 -0800 2008
commit  40419a96dbf9aeec316460a80e1e6fabd5f0bce7
tree    8c3d92313a9baba7791f80f32f55ae00268ef8e9
parent  8b45e891d018634a7f85a86291facbef9209502f
...
16
17
18
19
20
 
21
22
23
...
84
85
86
87
 
 
 
 
 
 
 
 
 
 
88
89
90
...
16
17
18
 
 
19
20
21
22
...
83
84
85
 
86
87
88
89
90
91
92
93
94
95
96
97
98
0
@@ -16,8 +16,7 @@ class Person < ActiveRecord::Base
0
   SEARCH_LIMIT = 20
0
   SEARCH_PER_PAGE = 5
0
   MESSAGES_PER_PAGE = 5
0
- NUM_RECENT_MESSAGES = 4
0
- NUM_RECENTLY_VIEWED = 4
0
+ NUM_NEW_MESSAGES = 4
0
 
0
   has_one :blog
0
   has_many :comments, :class_name => "WallComment",
0
@@ -84,7 +83,16 @@ class Person < ActiveRecord::Base
0
                                      :order => order,
0
                                      :page => page,
0
                                      :per_page => MESSAGES_PER_PAGE)
0
- end
0
+ end
0
+
0
+ def new_messages
0
+ Message.find(:all,
0
+ :conditions => [%(recipient_id = ? AND
0
+ recipient_read_at IS NULL AND
0
+ recipient_deleted_at IS NULL), id],
0
+ :order => "created_at DESC",
0
+ :limit => NUM_NEW_MESSAGES)
0
+ end
0
   
0
   ## Photo helpers
0
   
...
11
12
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
15
16
...
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
0
@@ -11,6 +11,23 @@
0
 </table>
0
 <%- end -%>
0
 
0
+<%- unless current_person.new_messages.empty? -%>
0
+<table>
0
+ <tr><th colspan="2">New Messages</th></tr>
0
+ <%- current_person.new_messages.each do |message| -%>
0
+ <tr>
0
+ <td><%= link_to image_tag(message.sender.icon), message.sender %></td>
0
+ <td class="small">
0
+ <%= link_to message.subject, message %>
0
+ <br />
0
+ Sent by <%= link_to message.sender.name, message.sender %>
0
+ <%= time_ago_in_words message.created_at %> ago
0
+ </td>
0
+ </tr>
0
+ <%- end -%>
0
+</table>
0
+<%- end -%>
0
+
0
 <table>
0
   <tr><th colspan="4">My Connections</th></tr>
0
   <%- current_person.contacts[(0...11)].collect_every(4) do |row| -%>
...
1
2
3
 
4
5
6
...
1
2
3
4
5
6
7
0
@@ -1,6 +1,7 @@
0
 class CreateCommunications < ActiveRecord::Migration
0
   def self.up
0
     create_table :communications do |t|
0
+ t.string :subject
0
       t.text :content
0
       t.string :parent_id
0
       t.integer :sender_id
...
56
57
58
59
60
61
62
 
 
 
 
 
 
 
63
64
65
...
56
57
58
 
 
 
 
59
60
61
62
63
64
65
66
67
68
0
@@ -56,10 +56,13 @@ def make_messages(text)
0
   michael = Person.find_by_email("michael@michaelhartl.com")
0
   senders = Person.find(:all, :limit => 10)
0
   senders.each do |sender|
0
- Message.create!(:content => text, :sender => michael,
0
- :recipient => sender, :skip_send_mail => true)
0
- Message.create!(:content => text, :sender => sender,
0
- :recipient => michael, :skip_send_mail => true)
0
+ subject = @lipsum.split.shuffle[0..4].join(' ')
0
+ Message.create!(:subject => subject, :content => text,
0
+ :sender => sender, :recipient => michael,
0
+ :skip_send_mail => true)
0
+ Message.create!(:subject => subject, :content => text,
0
+ :sender => michael, :recipient => sender,
0
+ :skip_send_mail => true)
0
   end
0
 end
0
 
...
4
5
6
 
 
 
 
 
 
 
 
7
8
9
...
4
5
6
7
8
9
10
11
12
13
14
15
16
17
0
@@ -4,6 +4,14 @@ body {
0
   font-size: 90%;
0
 }
0
 
0
+a {
0
+ text-decoration: none;
0
+}
0
+
0
+td {
0
+ padding-left: 0px;
0
+}
0
+
0
 #profile_edit h2 {
0
   margin-top: 1em;
0
 }

Comments

    No one has commented yet.