Merge branch 'master' of https://github.com/r888888888/danbooru
This commit is contained in:
@@ -467,6 +467,7 @@ Danbooru.Note = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$("#image").css("cursor", "crosshair");
|
||||||
Danbooru.Note.TranslationMode.active = true;
|
Danbooru.Note.TranslationMode.active = true;
|
||||||
$(document.body).addClass("mode-translation");
|
$(document.body).addClass("mode-translation");
|
||||||
$("#original-file-link").click();
|
$("#original-file-link").click();
|
||||||
@@ -479,6 +480,7 @@ Danbooru.Note = {
|
|||||||
|
|
||||||
stop: function() {
|
stop: function() {
|
||||||
Danbooru.Note.TranslationMode.active = false;
|
Danbooru.Note.TranslationMode.active = false;
|
||||||
|
$("#image").css("cursor", "auto");
|
||||||
$("#image").unbind("mousedown", Danbooru.Note.TranslationMode.Drag.start);
|
$("#image").unbind("mousedown", Danbooru.Note.TranslationMode.Drag.start);
|
||||||
$(window).unbind("mouseup", Danbooru.Note.TranslationMode.Drag.stop);
|
$(window).unbind("mouseup", Danbooru.Note.TranslationMode.Drag.stop);
|
||||||
$(document.body).removeClass("mode-translation");
|
$(document.body).removeClass("mode-translation");
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ class ApplicationController < ActionController::Base
|
|||||||
before_filter :normalize_search
|
before_filter :normalize_search
|
||||||
before_filter :set_started_at_session
|
before_filter :set_started_at_session
|
||||||
before_filter :api_check
|
before_filter :api_check
|
||||||
|
before_filter :set_safe_mode
|
||||||
|
# before_filter :secure_cookies_check
|
||||||
layout "default"
|
layout "default"
|
||||||
|
|
||||||
rescue_from User::PrivilegeError, :with => :access_denied
|
rescue_from User::PrivilegeError, :with => :access_denied
|
||||||
@@ -102,4 +104,16 @@ protected
|
|||||||
params[:search] ||= {}
|
params[:search] ||= {}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_safe_mode
|
||||||
|
CurrentUser.set_safe_mode(request)
|
||||||
|
end
|
||||||
|
|
||||||
|
def secure_cookies_check
|
||||||
|
if request.ssl?
|
||||||
|
Danbooru::Application.config.session_store :cookie_store, :key => '_danbooru_session', :secure => true
|
||||||
|
else
|
||||||
|
Danbooru::Application.config.session_store :cookie_store, :key => '_danbooru_session', :secure => false
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -42,6 +42,18 @@ class CurrentUser
|
|||||||
user.name
|
user.name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.safe_mode?
|
||||||
|
Thread.current[:safe_mode]
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.set_safe_mode(req)
|
||||||
|
if req.host =~ /safe/
|
||||||
|
Thread.current[:safe_mode] = true
|
||||||
|
else
|
||||||
|
Thread.current[:safe_mode] = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def self.method_missing(method, *params, &block)
|
def self.method_missing(method, *params, &block)
|
||||||
if user.respond_to?(method)
|
if user.respond_to?(method)
|
||||||
user.__send__(method, *params, &block)
|
user.__send__(method, *params, &block)
|
||||||
|
|||||||
@@ -112,6 +112,11 @@ class PostQueryBuilder
|
|||||||
raise ::Post::SearchError.new("You cannot search for more than #{Danbooru.config.tag_query_limit} tags at a time")
|
raise ::Post::SearchError.new("You cannot search for more than #{Danbooru.config.tag_query_limit} tags at a time")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if CurrentUser.safe_mode?
|
||||||
|
relation = relation.where(:rating => "s")
|
||||||
|
relation = relation.where("created_at <= ?", 3.months.ago)
|
||||||
|
end
|
||||||
|
|
||||||
relation = add_range_relation(q[:post_id], "posts.id", relation)
|
relation = add_range_relation(q[:post_id], "posts.id", relation)
|
||||||
relation = add_range_relation(q[:mpixels], "posts.image_width * posts.image_height / 1000000.0", relation)
|
relation = add_range_relation(q[:mpixels], "posts.image_width * posts.image_height / 1000000.0", relation)
|
||||||
relation = add_range_relation(q[:width], "posts.image_width", relation)
|
relation = add_range_relation(q[:width], "posts.image_width", relation)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ module Danbooru
|
|||||||
class Configuration
|
class Configuration
|
||||||
# The version of this Danbooru.
|
# The version of this Danbooru.
|
||||||
def version
|
def version
|
||||||
"2.24.0"
|
"2.25.0"
|
||||||
end
|
end
|
||||||
|
|
||||||
# The name of this Danbooru.
|
# The name of this Danbooru.
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
class AddCustomStyleToUsers < ActiveRecord::Migration
|
class AddCustomStyleToUsers < ActiveRecord::Migration
|
||||||
def change
|
def change
|
||||||
|
execute "set statement_timeout = 0"
|
||||||
add_column :users, :custom_style, :text
|
add_column :users, :custom_style, :text
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2697,7 +2697,8 @@ CREATE TABLE users (
|
|||||||
per_page integer DEFAULT 20 NOT NULL,
|
per_page integer DEFAULT 20 NOT NULL,
|
||||||
hide_deleted_posts boolean DEFAULT false NOT NULL,
|
hide_deleted_posts boolean DEFAULT false NOT NULL,
|
||||||
style_usernames boolean DEFAULT false NOT NULL,
|
style_usernames boolean DEFAULT false NOT NULL,
|
||||||
enable_auto_complete boolean DEFAULT true NOT NULL
|
enable_auto_complete boolean DEFAULT true NOT NULL,
|
||||||
|
custom_style text
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -6425,3 +6426,5 @@ INSERT INTO schema_migrations (version) VALUES ('20130606224559');
|
|||||||
INSERT INTO schema_migrations (version) VALUES ('20130618230158');
|
INSERT INTO schema_migrations (version) VALUES ('20130618230158');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20130620215658');
|
INSERT INTO schema_migrations (version) VALUES ('20130620215658');
|
||||||
|
|
||||||
|
INSERT INTO schema_migrations (version) VALUES ('20130712162600');
|
||||||
@@ -6,6 +6,20 @@ class CurrentUserTest < ActiveSupport::TestCase
|
|||||||
CurrentUser.ip_addr = nil
|
CurrentUser.ip_addr = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context ".safe_mode?" do
|
||||||
|
should "return true if the host contains the string host" do
|
||||||
|
req = mock(:host => "safebooru")
|
||||||
|
CurrentUser.set_safe_mode(req)
|
||||||
|
assert_equal(true, CurrentUser.safe_mode?)
|
||||||
|
end
|
||||||
|
|
||||||
|
should "return false if the host does not contain the string host" do
|
||||||
|
req = mock(:host => "danbooru")
|
||||||
|
CurrentUser.set_safe_mode(req)
|
||||||
|
assert_equal(false, CurrentUser.safe_mode?)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "The current user" do
|
context "The current user" do
|
||||||
should "be set only within the scope of the block" do
|
should "be set only within the scope of the block" do
|
||||||
user = FactoryGirl.create(:user)
|
user = FactoryGirl.create(:user)
|
||||||
|
|||||||
Reference in New Issue
Block a user