mirror of
https://github.com/iv-org/invidious.git
synced 2025-07-10 22:25:49 -05:00
feat: optional trending_enabled
and search_enabled
params added
This commit is contained in:
parent
eda7444ca4
commit
e613e3c08c
@ -210,6 +210,22 @@ https_only: false
|
|||||||
##
|
##
|
||||||
#popular_enabled: true
|
#popular_enabled: true
|
||||||
|
|
||||||
|
##
|
||||||
|
## Enable/Disable the "Trending" tab on the main page.
|
||||||
|
##
|
||||||
|
## Accepted values: true, false
|
||||||
|
## Default: true
|
||||||
|
##
|
||||||
|
#trending_enabled: true
|
||||||
|
|
||||||
|
##
|
||||||
|
## Enable/Disable "Search" on the main page.
|
||||||
|
##
|
||||||
|
## Accepted values: true, false
|
||||||
|
## Default: true
|
||||||
|
##
|
||||||
|
#search_enabled: true
|
||||||
|
|
||||||
##
|
##
|
||||||
## Enable/Disable statstics (available at /api/v1/stats).
|
## Enable/Disable statstics (available at /api/v1/stats).
|
||||||
## The following data is available:
|
## The following data is available:
|
||||||
|
@ -91,6 +91,8 @@ class Config
|
|||||||
# Subscribe to channels using PubSubHubbub (requires domain, hmac_key)
|
# Subscribe to channels using PubSubHubbub (requires domain, hmac_key)
|
||||||
property use_pubsub_feeds : Bool | Int32 = false
|
property use_pubsub_feeds : Bool | Int32 = false
|
||||||
property popular_enabled : Bool = true
|
property popular_enabled : Bool = true
|
||||||
|
property trending_enabled : Bool = true
|
||||||
|
property search_enabled : Bool = true
|
||||||
property captcha_enabled : Bool = true
|
property captcha_enabled : Bool = true
|
||||||
property login_enabled : Bool = true
|
property login_enabled : Bool = true
|
||||||
property registration_enabled : Bool = true
|
property registration_enabled : Bool = true
|
||||||
|
@ -4,6 +4,11 @@ module Invidious::Routes::API::V1::Feeds
|
|||||||
|
|
||||||
env.response.content_type = "application/json"
|
env.response.content_type = "application/json"
|
||||||
|
|
||||||
|
if !CONFIG.trending_enabled
|
||||||
|
error_message = {"error" => "Administrator has disabled this endpoint."}.to_json
|
||||||
|
haltf env, 400, error_message
|
||||||
|
end
|
||||||
|
|
||||||
region = env.params.query["region"]?
|
region = env.params.query["region"]?
|
||||||
trending_type = env.params.query["type"]?
|
trending_type = env.params.query["type"]?
|
||||||
|
|
||||||
|
@ -5,6 +5,11 @@ module Invidious::Routes::API::V1::Search
|
|||||||
|
|
||||||
env.response.content_type = "application/json"
|
env.response.content_type = "application/json"
|
||||||
|
|
||||||
|
if !CONFIG.search_enabled
|
||||||
|
error_message = {"error" => "Administrator has disabled this endpoint."}.to_json
|
||||||
|
haltf env, 400, error_message
|
||||||
|
end
|
||||||
|
|
||||||
query = Invidious::Search::Query.new(env.params.query, :regular, region)
|
query = Invidious::Search::Query.new(env.params.query, :regular, region)
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
@ -45,6 +45,7 @@ module Invidious::Routes::Feeds
|
|||||||
def self.trending(env)
|
def self.trending(env)
|
||||||
locale = env.get("preferences").as(Preferences).locale
|
locale = env.get("preferences").as(Preferences).locale
|
||||||
|
|
||||||
|
if CONFIG.trending_enabled
|
||||||
trending_type = env.params.query["type"]?
|
trending_type = env.params.query["type"]?
|
||||||
trending_type ||= "Default"
|
trending_type ||= "Default"
|
||||||
|
|
||||||
@ -58,6 +59,10 @@ module Invidious::Routes::Feeds
|
|||||||
end
|
end
|
||||||
|
|
||||||
templated "feeds/trending"
|
templated "feeds/trending"
|
||||||
|
else
|
||||||
|
message = translate(locale, "The Trending feed has been disabled by the administrator.")
|
||||||
|
templated "message"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.subscriptions(env)
|
def self.subscriptions(env)
|
||||||
|
@ -198,6 +198,14 @@ module Invidious::Routes::PreferencesRoute
|
|||||||
popular_enabled ||= "off"
|
popular_enabled ||= "off"
|
||||||
CONFIG.popular_enabled = popular_enabled == "on"
|
CONFIG.popular_enabled = popular_enabled == "on"
|
||||||
|
|
||||||
|
trending_enabled = env.params.body["trending_enabled"]?.try &.as(String)
|
||||||
|
trending_enabled ||= "off"
|
||||||
|
CONFIG.trending_enabled = trending_enabled == "on"
|
||||||
|
|
||||||
|
search_enabled = env.params.body["search_enabled"]?.try &.as(String)
|
||||||
|
search_enabled ||= "off"
|
||||||
|
CONFIG.search_enabled = search_enabled == "on"
|
||||||
|
|
||||||
captcha_enabled = env.params.body["captcha_enabled"]?.try &.as(String)
|
captcha_enabled = env.params.body["captcha_enabled"]?.try &.as(String)
|
||||||
captcha_enabled ||= "off"
|
captcha_enabled ||= "off"
|
||||||
CONFIG.captcha_enabled = captcha_enabled == "on"
|
CONFIG.captcha_enabled = captcha_enabled == "on"
|
||||||
|
@ -40,6 +40,7 @@ module Invidious::Routes::Search
|
|||||||
prefs = env.get("preferences").as(Preferences)
|
prefs = env.get("preferences").as(Preferences)
|
||||||
locale = prefs.locale
|
locale = prefs.locale
|
||||||
|
|
||||||
|
if CONFIG.search_enabled
|
||||||
region = env.params.query["region"]? || prefs.region
|
region = env.params.query["region"]? || prefs.region
|
||||||
|
|
||||||
query = Invidious::Search::Query.new(env.params.query, :regular, region)
|
query = Invidious::Search::Query.new(env.params.query, :regular, region)
|
||||||
@ -76,6 +77,10 @@ module Invidious::Routes::Search
|
|||||||
|
|
||||||
templated "search"
|
templated "search"
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
message = translate(locale, "Search has been disabled by the administrator.")
|
||||||
|
templated "message"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.hashtag(env : HTTP::Server::Context)
|
def self.hashtag(env : HTTP::Server::Context)
|
||||||
|
@ -287,6 +287,15 @@
|
|||||||
<input name="popular_enabled" id="popular_enabled" type="checkbox" <% if CONFIG.popular_enabled %>checked<% end %>>
|
<input name="popular_enabled" id="popular_enabled" type="checkbox" <% if CONFIG.popular_enabled %>checked<% end %>>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="pure-control-group">
|
||||||
|
<label for="trending_enabled"><%= translate(locale, "Trending enabled: ") %></label>
|
||||||
|
<input name="trending_enabled" id="trending_enabled" type="checkbox" <% if CONFIG.trending_enabled %>checked<% end %>>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="pure-control-group">
|
||||||
|
<label for="search_enabled"><%= translate(locale, "Search enabled: ") %></label>
|
||||||
|
<input name="search_enabled" id="search_enabled" type="checkbox" <% if CONFIG.search_enabled %>checked<% end %>>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="pure-control-group">
|
<div class="pure-control-group">
|
||||||
<label for="captcha_enabled"><%= translate(locale, "CAPTCHA enabled: ") %></label>
|
<label for="captcha_enabled"><%= translate(locale, "CAPTCHA enabled: ") %></label>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user