implemented last-forum-read-at
This commit is contained in:
1
Gemfile
1
Gemfile
@@ -25,4 +25,3 @@ gem "nokogiri"
|
|||||||
gem "meta_search", :git => "git://github.com/ernie/meta_search.git"
|
gem "meta_search", :git => "git://github.com/ernie/meta_search.git"
|
||||||
gem "silent-postgres"
|
gem "silent-postgres"
|
||||||
gem "whenever", :require => false
|
gem "whenever", :require => false
|
||||||
gem "bourbon"
|
|
||||||
|
|||||||
@@ -48,8 +48,6 @@ GEM
|
|||||||
multi_json (~> 1.0)
|
multi_json (~> 1.0)
|
||||||
arel (2.1.4)
|
arel (2.1.4)
|
||||||
bcrypt-ruby (2.1.4)
|
bcrypt-ruby (2.1.4)
|
||||||
bourbon (0.1.5)
|
|
||||||
sass (>= 3.1)
|
|
||||||
builder (3.0.0)
|
builder (3.0.0)
|
||||||
daemons (1.1.4)
|
daemons (1.1.4)
|
||||||
delayed_job (2.1.4)
|
delayed_job (2.1.4)
|
||||||
@@ -105,7 +103,6 @@ GEM
|
|||||||
thor (~> 0.14.6)
|
thor (~> 0.14.6)
|
||||||
rake (0.9.2)
|
rake (0.9.2)
|
||||||
rdoc (3.9.1)
|
rdoc (3.9.1)
|
||||||
sass (3.1.7)
|
|
||||||
shoulda (2.11.3)
|
shoulda (2.11.3)
|
||||||
silent-postgres (0.0.8)
|
silent-postgres (0.0.8)
|
||||||
simple_form (1.4.2)
|
simple_form (1.4.2)
|
||||||
@@ -137,7 +134,6 @@ PLATFORMS
|
|||||||
ruby
|
ruby
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
bourbon
|
|
||||||
delayed_job
|
delayed_job
|
||||||
factory_girl
|
factory_girl
|
||||||
ffaker!
|
ffaker!
|
||||||
|
|||||||
@@ -5,6 +5,19 @@
|
|||||||
$("#c-forum-topics #preview").hide();
|
$("#c-forum-topics #preview").hide();
|
||||||
|
|
||||||
this.initialize_preview_link();
|
this.initialize_preview_link();
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Danbooru.ForumPost.initialize_preview_link = function() {
|
Danbooru.ForumPost.initialize_preview_link = function() {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
/*= require "smoothness/jquery-ui-1.8.5.custom.css" */
|
/*= require "smoothness/jquery-ui-1.8.5.custom.css" */
|
||||||
@import 'bourbon';
|
|
||||||
|
|
||||||
$link_color: #006FFA;
|
$link_color: #006FFA;
|
||||||
$link_hover_color: #9093FF;
|
$link_hover_color: #9093FF;
|
||||||
@@ -897,6 +896,10 @@ div#c-forum-topics {
|
|||||||
color: #AAA;
|
color: #AAA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tr.new-topic {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
div#form-content {
|
div#form-content {
|
||||||
float: left;
|
float: left;
|
||||||
width: 450px;
|
width: 450px;
|
||||||
|
|||||||
@@ -2,6 +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]
|
||||||
rescue_from User::PrivilegeError, :with => "static/access_denied"
|
rescue_from User::PrivilegeError, :with => "static/access_denied"
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@@ -56,6 +57,12 @@ private
|
|||||||
forum_topic.is_sticky = params[:forum_topic][:is_sticky]
|
forum_topic.is_sticky = params[:forum_topic][:is_sticky]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def update_last_forum_read_at
|
||||||
|
return if CurrentUser.last_forum_read_at.present? && CurrentUser.last_forum_read_at > 1.day.ago
|
||||||
|
|
||||||
|
CurrentUser.update_column(:last_forum_read_at, Time.now)
|
||||||
|
end
|
||||||
|
|
||||||
def normalize_search
|
def normalize_search
|
||||||
if params[:title_matches]
|
if params[:title_matches]
|
||||||
params[:search] ||= {}
|
params[:search] ||= {}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ class SessionsController < ApplicationController
|
|||||||
def create
|
def create
|
||||||
if User.authenticate(params[:name], params[:password])
|
if User.authenticate(params[:name], params[:password])
|
||||||
@user = User.find_by_name(params[:name])
|
@user = User.find_by_name(params[:name])
|
||||||
|
@user.update_column(:last_logged_in_at, Time.now)
|
||||||
session[:user_id] = @user.id
|
session[:user_id] = @user.id
|
||||||
redirect_to(params[:url] || session[:previous_uri] || posts_path, :notice => "You are now logged in.")
|
redirect_to(params[:url] || session[:previous_uri] || posts_path, :notice => "You are now logged in.")
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -23,13 +23,20 @@ module ApplicationHelper
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def time_tag(content = nil, time)
|
||||||
|
zone = time.strftime("%z")
|
||||||
|
datetime = time.strftime("%Y-%m-%dT%H:%M" + zone[0, 3] + ":" + zone[3, 2])
|
||||||
|
|
||||||
|
content_tag(:time, content || datetime, :datetime => datetime)
|
||||||
|
end
|
||||||
|
|
||||||
def compact_time(time)
|
def compact_time(time)
|
||||||
if time > Time.now.beginning_of_day
|
if time > Time.now.beginning_of_day
|
||||||
time.strftime("%H:%M")
|
time_tag(time.strftime("%H:%M"), time)
|
||||||
elsif time > Time.now.beginning_of_year
|
elsif time > Time.now.beginning_of_year
|
||||||
time.strftime("%b %e")
|
time_tag(time.strftime("%b %e"), time)
|
||||||
else
|
else
|
||||||
time.strftime("%b %e, %Y")
|
time_tag(time.strftime("%b %e, %Y"), time)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -112,6 +112,13 @@ class AnonymousUser
|
|||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def last_forum_read_at
|
||||||
|
Time.now
|
||||||
|
end
|
||||||
|
|
||||||
|
def update_column(*params)
|
||||||
|
end
|
||||||
|
|
||||||
%w(member banned privileged contributor janitor moderator admin).each do |name|
|
%w(member banned privileged contributor janitor moderator admin).each do |name|
|
||||||
define_method("is_#{name}?") do
|
define_method("is_#{name}?") do
|
||||||
false
|
false
|
||||||
|
|||||||
@@ -5,8 +5,4 @@ class ForumTopicPresenter < Presenter
|
|||||||
@forum_posts = forum_posts
|
@forum_posts = forum_posts
|
||||||
@forum_topic = forum_topic
|
@forum_topic = forum_topic
|
||||||
end
|
end
|
||||||
|
|
||||||
def pagination_html(template)
|
|
||||||
Paginators::ForumTopic.new(forum_topic, forum_posts).numbered_pagination_html(template)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
<%= @forum_topic.presenter(@forum_posts).pagination_html(self) %>
|
|
||||||
@@ -22,7 +22,13 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<%= numbered_paginator(@forum_topics) %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= 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 %>
|
||||||
|
|||||||
@@ -7,7 +7,8 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= render "forum_posts/listing", :forum_posts => @forum_posts %>
|
<%= render "forum_posts/listing", :forum_posts => @forum_posts %>
|
||||||
<%= render "paginator" %>
|
|
||||||
|
<%= numbered_paginator(@forum_posts) %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user