reverts old behavior of forum topic highlighting

This commit is contained in:
albert
2011-10-27 19:03:07 -04:00
parent c9cb34beaf
commit 3871188bde
3 changed files with 6 additions and 36 deletions

View File

@@ -1,23 +1,3 @@
(function() { (function() {
Danbooru.ForumPost = {}; Danbooru.ForumPost = {};
Danbooru.ForumPost.initialize_all = function() {
this.initialize_last_forum_read_at();
}
Danbooru.ForumPost.initialize_last_forum_read_at = function() {
var last_forum_read_at = Date.parse(Danbooru.meta("last-forum-read-at"));
$("#c-forum-topics #a-index time").each(function(i, x) {
var $x = $(x);
var $date = Date.parse($x.attr("datetime"));
if (Date.parse($x.attr("datetime")) > last_forum_read_at) {
$x.closest("tr").addClass("new-topic");
}
});
}
})(); })();
$(document).ready(function() {
Danbooru.ForumPost.initialize_all();
});

View File

@@ -2,7 +2,7 @@ class ForumTopicsController < ApplicationController
respond_to :html, :xml, :json respond_to :html, :xml, :json
before_filter :member_only, :except => [:index, :show] before_filter :member_only, :except => [:index, :show]
before_filter :normalize_search, :only => :index before_filter :normalize_search, :only => :index
before_filter :update_last_forum_read_at, :only => [:index, :show] after_filter :update_last_forum_read_at, :only => [:show]
rescue_from User::PrivilegeError, :with => "static/access_denied" rescue_from User::PrivilegeError, :with => "static/access_denied"
def new def new
@@ -37,7 +37,6 @@ class ForumTopicsController < ApplicationController
def update def update
@forum_topic = ForumTopic.find(params[:id]) @forum_topic = ForumTopic.find(params[:id])
check_privilege(@forum_topic) check_privilege(@forum_topic)
assign_special_attributes(@forum_topic)
@forum_topic.update_attributes(params[:forum_topic], :as => CurrentUser.role) @forum_topic.update_attributes(params[:forum_topic], :as => CurrentUser.role)
respond_with(@forum_topic) respond_with(@forum_topic)
end end
@@ -50,17 +49,12 @@ class ForumTopicsController < ApplicationController
end end
private private
def assign_special_attributes(forum_topic)
return unless CurrentUser.is_moderator?
forum_topic.is_locked = params[:forum_topic][:is_locked]
forum_topic.is_sticky = params[:forum_topic][:is_sticky]
end
def update_last_forum_read_at def update_last_forum_read_at
return if CurrentUser.last_forum_read_at.present? && CurrentUser.last_forum_read_at > 1.day.ago return if CurrentUser.is_anonymous?
CurrentUser.update_column(:last_forum_read_at, Time.now) if CurrentUser.last_forum_read_at.nil? || CurrentUser.last_forum_read_at < @forum_topic.updated_at
CurrentUser.update_column(:last_forum_read_at, @forum_topic.updated_at)
end
end end
def normalize_search def normalize_search

View File

@@ -13,7 +13,7 @@
</thead> </thead>
<tbody> <tbody>
<% @forum_topics.each do |topic| %> <% @forum_topics.each do |topic| %>
<tr> <tr class="forum-topic-row <% if topic.updated_at > (CurrentUser.last_forum_read_at || Time.now) %>new-topic<% end %>">
<td> <td>
<% if topic.is_sticky? %> <% if topic.is_sticky? %>
<span class="sticky">Sticky:</span> <span class="sticky">Sticky:</span>
@@ -43,10 +43,6 @@
<%= render "secondary_links" %> <%= render "secondary_links" %>
<%= content_for(:html_header) do %>
<meta name="last-forum-read-at" content="<%= CurrentUser.last_forum_read_at.to_date %>">
<% end %>
<% content_for(:page_title) do %> <% content_for(:page_title) do %>
Forum - <%= Danbooru.config.app_name %> Forum - <%= Danbooru.config.app_name %>
<% end %> <% end %>