diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 588c524e9..56086bb25 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,5 +1,6 @@ class UsersController < ApplicationController respond_to :html, :xml, :json + before_filter :member_only, :only => [:edit, :show, :update, :destroy, :create] def new @user = User.new @@ -21,7 +22,10 @@ class UsersController < ApplicationController def create @user = User.new(params[:user].merge(:ip_addr => request.remote_ip)) - flash[:notice] = "You have succesfully created a new account." if @user.save + if @user.save + flash[:notice] = "You have succesfully created a new account." + session[:user_id] = @user.id + end respond_with(@user) end diff --git a/app/models/post.rb b/app/models/post.rb index b86d82898..0f2925e15 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -181,6 +181,7 @@ class Post < ActiveRecord::Base increment_tags.each do |tag| expire_cache(tag) end + expire_cache("") end def set_tag_counts @@ -515,20 +516,17 @@ class Post < ActiveRecord::Base module CountMethods def fast_count(tags) count = Cache.get("pfc:#{Cache.sanitize(tags)}") - return count unless count.nil? - count = Post.find_by_tags(tags).count - expiry = (count < 100) ? 0 : (count * 4).minutes - Cache.put("pfc:#{Cache.sanitize(tags)}", count, expiry) + if count.nil? + count = Post.find_by_tags("#{tags}").count + if count > Danbooru.config.posts_per_page * 10 + Cache.put("pfc:#{Cache.sanitize(tags)}", count, (count * 4).minutes) + end + end count end def fast_delete_count(tags) - count = Cache.get("pfdc:#{Cache.sanitize(tags)}") - return count unless count.nil? - count = Post.find_by_tags("#{tags} status:deleted").count - expiry = (count < 100) ? 0 : (count * 4).minutes - Cache.put("pfc:#{Cache.sanitize(tags)}", count, expiry) - count + fast_count("#{tags} status:deleted") end end diff --git a/app/models/user.rb b/app/models/user.rb index 3547ac026..8e0a40ba0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -4,7 +4,7 @@ class User < ActiveRecord::Base class Error < Exception ; end attr_accessor :password, :old_password, :ip_addr - attr_accessible :password, :old_password, :password_confirmation, :password_hash, :email, :last_logged_in_at, :last_forum_read_at, :has_mail, :receive_email_notifications, :comment_threshold, :always_resize_images, :favorite_tags, :blacklisted_tags, :name + attr_accessible :password, :old_password, :password_confirmation, :password_hash, :email, :last_logged_in_at, :last_forum_read_at, :has_mail, :receive_email_notifications, :comment_threshold, :always_resize_images, :favorite_tags, :blacklisted_tags, :name, :ip_addr validates_length_of :name, :within => 2..20, :on => :create validates_format_of :name, :with => /\A[^\s;,]+\Z/, :on => :create, :message => "cannot have whitespace, commas, or semicolons" validates_uniqueness_of :name, :case_sensitive => false, :on => :create diff --git a/app/presenters/post_set_presenter.rb b/app/presenters/post_set_presenter.rb index 8a5910c2a..33b94ceeb 100644 --- a/app/presenters/post_set_presenter.rb +++ b/app/presenters/post_set_presenter.rb @@ -42,60 +42,47 @@ class PostSetPresenter < Presenter def numbered_pagination_html(template) total_pages = (@post_set.count.to_f / @post_set.limit.to_f).ceil current_page = [1, @post_set.page].max - before_current_page = current_page - 1 - after_current_page = current_page + 1 html = "
" html.html_safe end - def numbered_pagination_item(template, page) + def numbered_pagination_item(template, page, current_page) html = "