mirror of
https://git.nadeko.net/Fijxu/invidious.git
synced 2026-01-30 10:42:53 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -190,7 +190,7 @@ def error_redirect_helper(env : HTTP::Server::Context)
|
||||
<a href="/redirect?referer=#{env.get("current_page")}">#{switch_instance}</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://youtube.com#{env.request.resource}">#{go_to_youtube}</a>
|
||||
<a rel="noreferrer noopener" href="https://youtube.com#{env.request.resource}">#{go_to_youtube}</a>
|
||||
</li>
|
||||
</ul>
|
||||
END_HTML
|
||||
|
||||
@@ -97,7 +97,7 @@ class AuthHandler < Kemal::Handler
|
||||
if token = env.request.headers["Authorization"]?
|
||||
token = JSON.parse(URI.decode_www_form(token.lchop("Bearer ")))
|
||||
session = URI.decode_www_form(token["session"].as_s)
|
||||
scopes, expire, signature = validate_request(token, session, env.request, HMAC_KEY, nil)
|
||||
scopes, _, _ = validate_request(token, session, env.request, HMAC_KEY, nil)
|
||||
|
||||
if email = Invidious::Database::SessionIDs.select_email(session)
|
||||
user = Invidious::Database::Users.select!(email: email)
|
||||
|
||||
@@ -95,7 +95,6 @@ module I18next::Plurals
|
||||
"hr" => PluralForms::Special_Hungarian_Serbian,
|
||||
"it" => PluralForms::Special_Spanish_Italian,
|
||||
"pt" => PluralForms::Special_French_Portuguese,
|
||||
"pt" => PluralForms::Special_French_Portuguese,
|
||||
"sr" => PluralForms::Special_Hungarian_Serbian,
|
||||
}
|
||||
|
||||
@@ -189,7 +188,7 @@ module I18next::Plurals
|
||||
|
||||
# Emulate the `rule.numbers.size == 2 && rule.numbers[0] == 1` check
|
||||
# from original i18next code
|
||||
private def is_simple_plural(form : PluralForms) : Bool
|
||||
private def simple_plural?(form : PluralForms) : Bool
|
||||
case form
|
||||
when .single_gt_one? then return true
|
||||
when .single_not_one? then return true
|
||||
@@ -211,7 +210,7 @@ module I18next::Plurals
|
||||
idx = SuffixIndex.get_index(plural_form, count)
|
||||
|
||||
# Simple plurals are handled differently in all versions (but v4)
|
||||
if @simplify_plural_suffix && is_simple_plural(plural_form)
|
||||
if @simplify_plural_suffix && simple_plural?(plural_form)
|
||||
return (idx == 1) ? "_plural" : ""
|
||||
end
|
||||
|
||||
@@ -262,9 +261,9 @@ module I18next::Plurals
|
||||
when .special_hebrew? then return special_hebrew(count)
|
||||
when .special_odia? then return special_odia(count)
|
||||
# Mixed v3/v4 forms
|
||||
when .special_spanish_italian? then return special_cldr_Spanish_Italian(count)
|
||||
when .special_french_portuguese? then return special_cldr_French_Portuguese(count)
|
||||
when .special_hungarian_serbian? then return special_cldr_Hungarian_Serbian(count)
|
||||
when .special_spanish_italian? then return special_cldr_spanish_italian(count)
|
||||
when .special_french_portuguese? then return special_cldr_french_portuguese(count)
|
||||
when .special_hungarian_serbian? then return special_cldr_hungarian_serbian(count)
|
||||
else
|
||||
# default, if nothing matched above
|
||||
return 0_u8
|
||||
@@ -535,7 +534,7 @@ module I18next::Plurals
|
||||
#
|
||||
# This rule is mostly compliant to CLDR v42
|
||||
#
|
||||
def self.special_cldr_Spanish_Italian(count : Int) : UInt8
|
||||
def self.special_cldr_spanish_italian(count : Int) : UInt8
|
||||
return 0_u8 if (count == 1) # one
|
||||
return 1_u8 if (count != 0 && count % 1_000_000 == 0) # many
|
||||
return 2_u8 # other
|
||||
@@ -545,7 +544,7 @@ module I18next::Plurals
|
||||
#
|
||||
# This rule is mostly compliant to CLDR v42
|
||||
#
|
||||
def self.special_cldr_French_Portuguese(count : Int) : UInt8
|
||||
def self.special_cldr_french_portuguese(count : Int) : UInt8
|
||||
return 0_u8 if (count == 0 || count == 1) # one
|
||||
return 1_u8 if (count % 1_000_000 == 0) # many
|
||||
return 2_u8 # other
|
||||
@@ -555,7 +554,7 @@ module I18next::Plurals
|
||||
#
|
||||
# This rule is mostly compliant to CLDR v42
|
||||
#
|
||||
def self.special_cldr_Hungarian_Serbian(count : Int) : UInt8
|
||||
def self.special_cldr_hungarian_serbian(count : Int) : UInt8
|
||||
n_mod_10 = count % 10
|
||||
n_mod_100 = count % 100
|
||||
|
||||
|
||||
@@ -34,24 +34,11 @@ class Invidious::LogHandler < Kemal::BaseLogHandler
|
||||
context
|
||||
end
|
||||
|
||||
def puts(message : String)
|
||||
@io << message << '\n'
|
||||
@io.flush
|
||||
end
|
||||
|
||||
def write(message : String)
|
||||
@io << message
|
||||
@io.flush
|
||||
end
|
||||
|
||||
def set_log_level(level : String)
|
||||
@level = LogLevel.parse(level)
|
||||
end
|
||||
|
||||
def set_log_level(level : LogLevel)
|
||||
@level = level
|
||||
end
|
||||
|
||||
{% for level in %w(trace debug info warn error fatal) %}
|
||||
def {{level.id}}(message : String)
|
||||
if LogLevel::{{level.id.capitalize}} >= @level
|
||||
|
||||
@@ -52,9 +52,9 @@ def recode_length_seconds(time)
|
||||
end
|
||||
|
||||
def decode_interval(string : String) : Time::Span
|
||||
rawMinutes = string.try &.to_i32?
|
||||
raw_minutes = string.try &.to_i32?
|
||||
|
||||
if !rawMinutes
|
||||
if !raw_minutes
|
||||
hours = /(?<hours>\d+)h/.match(string).try &.["hours"].try &.to_i32
|
||||
hours ||= 0
|
||||
|
||||
@@ -63,7 +63,7 @@ def decode_interval(string : String) : Time::Span
|
||||
|
||||
time = Time::Span.new(hours: hours, minutes: minutes)
|
||||
else
|
||||
time = Time::Span.new(minutes: rawMinutes)
|
||||
time = Time::Span.new(minutes: raw_minutes)
|
||||
end
|
||||
|
||||
return time
|
||||
|
||||
Reference in New Issue
Block a user