mirror of
https://git.nadeko.net/Fijxu/invidious.git
synced 2025-12-17 10:28:51 +00:00
Merge branch 'iv-org:master' into verified-badge
This commit is contained in:
@@ -38,12 +38,15 @@ def error_template_helper(env : HTTP::Server::Context, status_code : Int32, exce
|
||||
|
||||
issue_title = "#{exception.message} (#{exception.class})"
|
||||
|
||||
issue_template = %(Title: `#{issue_title}`)
|
||||
issue_template += %(\nDate: `#{Time::Format::ISO_8601_DATE_TIME.format(Time.utc)}`)
|
||||
issue_template += %(\nRoute: `#{env.request.resource}`)
|
||||
issue_template += %(\nVersion: `#{SOFTWARE["version"]} @ #{SOFTWARE["branch"]}`)
|
||||
# issue_template += github_details("Preferences", env.get("preferences").as(Preferences).to_pretty_json)
|
||||
issue_template += github_details("Backtrace", exception.inspect_with_backtrace)
|
||||
issue_template = <<-TEXT
|
||||
Title: `#{HTML.escape(issue_title)}`
|
||||
Date: `#{Time::Format::ISO_8601_DATE_TIME.format(Time.utc)}`
|
||||
Route: `#{HTML.escape(env.request.resource)}`
|
||||
Version: `#{SOFTWARE["version"]} @ #{SOFTWARE["branch"]}`
|
||||
|
||||
TEXT
|
||||
|
||||
issue_template += github_details("Backtrace", HTML.escape(exception.inspect_with_backtrace))
|
||||
|
||||
# URLs for the error message below
|
||||
url_faq = "https://github.com/iv-org/documentation/blob/master/FAQ.md"
|
||||
|
||||
@@ -30,6 +30,7 @@ LOCALES_LIST = {
|
||||
"pt-PT" => "Português de Portugal", # Portuguese (Portugal)
|
||||
"ro" => "Română", # Romanian
|
||||
"ru" => "русский", # Russian
|
||||
"sq" => "Shqip", # Albanian
|
||||
"sr" => "srpski (latinica)", # Serbian (Latin)
|
||||
"sr_Cyrl" => "српски (ћирилица)", # Serbian (Cyrillic)
|
||||
"sv-SE" => "Svenska", # Swedish
|
||||
@@ -135,7 +136,7 @@ def translate_count(locale : String, key : String, count : Int, format = NumberF
|
||||
# Try #2: Fallback to english
|
||||
translation = translate_count("en-US", key, count)
|
||||
else
|
||||
# Return key if we're already in english, as the tranlation is missing
|
||||
# Return key if we're already in english, as the translation is missing
|
||||
LOGGER.warn("i18n: Missing translation key \"#{key}\"")
|
||||
return key
|
||||
end
|
||||
|
||||
@@ -44,7 +44,7 @@ def sign_token(key, hash)
|
||||
|
||||
# TODO: figure out which "key" variable is used
|
||||
# Ameba reports a warning for "Lint/ShadowingOuterLocalVar" on this
|
||||
# variable, but its preferrable to not touch that (works fine atm).
|
||||
# variable, but it's preferable to not touch that (works fine atm).
|
||||
hash.each do |key, value|
|
||||
next if key == "signature"
|
||||
|
||||
|
||||
@@ -51,6 +51,24 @@ def recode_length_seconds(time)
|
||||
end
|
||||
end
|
||||
|
||||
def decode_interval(string : String) : Time::Span
|
||||
rawMinutes = string.try &.to_i32?
|
||||
|
||||
if !rawMinutes
|
||||
hours = /(?<hours>\d+)h/.match(string).try &.["hours"].try &.to_i32
|
||||
hours ||= 0
|
||||
|
||||
minutes = /(?<minutes>\d+)m(?!s)/.match(string).try &.["minutes"].try &.to_i32
|
||||
minutes ||= 0
|
||||
|
||||
time = Time::Span.new(hours: hours, minutes: minutes)
|
||||
else
|
||||
time = Time::Span.new(minutes: rawMinutes)
|
||||
end
|
||||
|
||||
return time
|
||||
end
|
||||
|
||||
def decode_time(string)
|
||||
time = string.try &.to_f?
|
||||
|
||||
@@ -161,11 +179,11 @@ def short_text_to_number(short_text : String) : Int32
|
||||
end
|
||||
|
||||
def number_to_short_text(number)
|
||||
seperated = number_with_separator(number).gsub(",", ".").split("")
|
||||
text = seperated.first(2).join
|
||||
separated = number_with_separator(number).gsub(",", ".").split("")
|
||||
text = separated.first(2).join
|
||||
|
||||
if seperated[2]? && seperated[2] != "."
|
||||
text += seperated[2]
|
||||
if separated[2]? && separated[2] != "."
|
||||
text += separated[2]
|
||||
end
|
||||
|
||||
text = text.rchop(".0")
|
||||
@@ -323,8 +341,8 @@ def fetch_random_instance
|
||||
instance_list.each do |data|
|
||||
# TODO Check if current URL is onion instance and use .onion types if so.
|
||||
if data[1]["type"] == "https"
|
||||
# Instances can have statisitics disabled, which is an requirement of version validation.
|
||||
# as_nil? doesn't exist. Thus we'll have to handle the error rasied if as_nil fails.
|
||||
# Instances can have statistics disabled, which is an requirement of version validation.
|
||||
# as_nil? doesn't exist. Thus we'll have to handle the error raised if as_nil fails.
|
||||
begin
|
||||
data[1]["stats"].as_nil
|
||||
next
|
||||
|
||||
Reference in New Issue
Block a user