Patch #1486 ยป show_new_activity.diff
app/controllers/boards_controller.rb | ||
---|---|---|
45 | 45 |
:include => [:author, {:last_reply => :author}], |
46 | 46 |
:limit => @topic_pages.items_per_page, |
47 | 47 |
:offset => @topic_pages.current.offset |
48 |
|
|
49 |
# Mark this board as seen |
|
50 |
(session[:boards] ||= {})[@board.id] = Time.now if User.current.logged? |
|
51 |
|
|
48 | 52 |
render :action => 'show', :layout => !request.xhr? |
49 | 53 |
end |
50 | 54 |
|
app/controllers/messages_controller.rb | ||
---|---|---|
95 | 95 |
find_board |
96 | 96 |
@message = @board.messages.find(params[:id], :include => :parent) |
97 | 97 |
@topic = @message.root |
98 |
|
|
99 |
# Mark this topic as seen. |
|
100 |
(session[:topics] ||= {})[@topic.id] = Time.now if User.current.logged? |
|
98 | 101 |
rescue ActiveRecord::RecordNotFound |
99 | 102 |
render_404 |
100 | 103 |
end |
app/helpers/boards_helper.rb | ||
---|---|---|
16 | 16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | 17 | |
18 | 18 |
module BoardsHelper |
19 |
# Return true if there has been new activity on the board since the user was |
|
20 |
# last seen. |
|
21 |
def new_board_activity?(board) |
|
22 |
return false if board.last_message.nil? || !User.current.logged? |
|
23 |
|
|
24 |
return board.last_message.updated_on > ((session[:boards] ||= {})[board.id] || User.current.last_login_on || Time.now.utc) |
|
25 |
end |
|
26 |
|
|
27 |
# Return true if there has been new activity in the topic since the user was |
|
28 |
# last seen. |
|
29 |
def new_topic_activity?(topic) |
|
30 |
return false if topic.last_reply.nil? || !User.current.logged? |
|
31 |
|
|
32 |
return topic.last_reply.updated_on > ((session[:topics] ||= {})[topic.id] || User.current.last_login_on || Time.now) |
|
33 |
end |
|
19 | 34 |
end |
app/views/boards/index.rhtml | ||
---|---|---|
9 | 9 |
</tr></thead> |
10 | 10 |
<tbody> |
11 | 11 |
<% for board in @boards %> |
12 |
<tr class="<%= cycle 'odd', 'even' %>"> |
|
12 |
<tr class="<%= cycle 'odd', 'even' %> <%=new_board_activity?(board) ? 'new_activity' : '' %>">
|
|
13 | 13 |
<td> |
14 | 14 |
<%= link_to h(board.name), {:action => 'show', :id => board}, :class => "icon22 icon22-comment" %><br /> |
15 | 15 |
<%=h board.description %> |
app/views/boards/show.rhtml | ||
---|---|---|
38 | 38 |
</tr></thead> |
39 | 39 |
<tbody> |
40 | 40 |
<% @topics.each do |topic| %> |
41 |
<tr class="message <%= cycle 'odd', 'even' %> <%= topic.sticky? ? 'sticky' : '' %> <%= topic.locked? ? 'locked' : '' %>"> |
|
41 |
<tr class="message <%= cycle 'odd', 'even' %> <%= topic.sticky? ? 'sticky' : '' %> <%= topic.locked? ? 'locked' : '' %> <%=new_topic_activity?(topic) ? 'new_activity' : '' %>">
|
|
42 | 42 |
<td class="subject"><%= link_to h(topic.subject), { :controller => 'messages', :action => 'show', :board_id => @board, :id => topic }, :class => 'icon' %></td> |
43 | 43 |
<td class="author" align="center"><%= topic.author %></td> |
44 | 44 |
<td class="created_on" align="center"><%= format_time(topic.created_on) %></td> |
public/stylesheets/application.css | ||
---|---|---|
108 | 108 |
tr.message td.last_message { font-size: 80%; } |
109 | 109 |
tr.message.locked td.subject a { background-image: url(../images/locked.png); } |
110 | 110 |
tr.message.sticky td.subject a { background-image: url(../images/sticky.png); font-weight: bold; } |
111 |
tr.message.new_activity td.subject { font-weight: bold;} |
|
111 | 112 | |
112 | 113 |
tr.user td { width:13%; } |
113 | 114 |
tr.user td.email { width:18%; } |
... | ... | |
120 | 121 |
td.hours { text-align: right; font-weight: bold; padding-right: 0.5em; } |
121 | 122 |
td.hours .hours-dec { font-size: 0.9em; } |
122 | 123 | |
124 |
table.boards tr.new_activity { font-weight: bold;} |
|
125 | ||
123 | 126 |
table.list tbody tr:hover { background-color:#ffffdd; } |
124 | 127 |
table td {padding:2px;} |
125 | 128 |
table p {margin:0;} |