Add config options to disable comments and the forum.
Add options to disable comments, the forum, and autocomplete. This is for personal boorus and potentially for safe mode. Note that disabling the forum may cause difficulties with creating and approving BURs. Disabling comments and the forum merely hides them from most areas, rather than completely removing them.
This commit is contained in:
@@ -28,23 +28,27 @@ class AutocompleteService
|
||||
|
||||
TAG_PREFIXES = TagCategory.mapping.keys.map { |prefix| prefix + ":" }
|
||||
|
||||
attr_reader :query, :type, :limit, :current_user
|
||||
attr_reader :query, :type, :limit, :current_user, :enabled
|
||||
alias_method :enabled?, :enabled
|
||||
|
||||
# Perform completion for the given search type and query.
|
||||
# @param query [String] the string being completed
|
||||
# @param type [String] the type of completion being performed
|
||||
# @param current_user [User] the user we're performing completion for
|
||||
# @param limit [Integer] the max number of results to return
|
||||
def initialize(query, type, current_user: User.anonymous, limit: 10)
|
||||
def initialize(query, type, current_user: User.anonymous, limit: 10, enabled: Danbooru.config.autocomplete_enabled?.to_s.truthy?)
|
||||
@query = query.to_s
|
||||
@type = type.to_s.to_sym
|
||||
@current_user = current_user
|
||||
@limit = limit
|
||||
@enabled = enabled
|
||||
end
|
||||
|
||||
# Return the results of the completion.
|
||||
# @return [Array<Hash>] the autocomplete results
|
||||
def autocomplete_results
|
||||
return [] if !enabled?
|
||||
|
||||
case type
|
||||
when :tag_query
|
||||
autocomplete_tag_query
|
||||
|
||||
@@ -16,7 +16,7 @@ class RateLimiter
|
||||
attr_reader :action, :keys, :cost, :rate, :burst, :enabled
|
||||
alias_method :enabled?, :enabled
|
||||
|
||||
def initialize(action, keys = ["*"], cost: 1, rate: 1, burst: 1, enabled: Danbooru.config.rate_limits_enabled?)
|
||||
def initialize(action, keys = ["*"], cost: 1, rate: 1, burst: 1, enabled: Danbooru.config.rate_limits_enabled?.to_s.truthy?)
|
||||
@action = action
|
||||
@keys = keys
|
||||
@cost = cost
|
||||
|
||||
Reference in New Issue
Block a user