Fix Style/HeredocIndent type of Ameba issues

This commit is contained in:
Sijawusz Pur Rahnama 2026-01-11 22:49:54 +01:00
parent e5a1131665
commit 2112ee674e
26 changed files with 384 additions and 384 deletions

View File

@ -8,21 +8,21 @@ end
def csv_sample
return <<-CSV
Kanal-ID,Kanal-URL,Kanaltitel
UC0hHW5Y08ggq-9kbrGgWj0A,http://www.youtube.com/channel/UC0hHW5Y08ggq-9kbrGgWj0A,Matias Marolla
UC0vBXGSyV14uvJ4hECDOl0Q,http://www.youtube.com/channel/UC0vBXGSyV14uvJ4hECDOl0Q,Techquickie
UC1sELGmy5jp5fQUugmuYlXQ,http://www.youtube.com/channel/UC1sELGmy5jp5fQUugmuYlXQ,Minecraft
UC9kFnwdCRrX7oTjqKd6-tiQ,http://www.youtube.com/channel/UC9kFnwdCRrX7oTjqKd6-tiQ,LUMOX - Topic
UCBa659QWEk1AI4Tg--mrJ2A,http://www.youtube.com/channel/UCBa659QWEk1AI4Tg--mrJ2A,Tom Scott
UCGu6_XQ64rXPR6nuitMQE_A,http://www.youtube.com/channel/UCGu6_XQ64rXPR6nuitMQE_A,Callcenter Fun
UCGwu0nbY2wSkW8N-cghnLpA,http://www.youtube.com/channel/UCGwu0nbY2wSkW8N-cghnLpA,Jaiden Animations
UCQ0OvZ54pCFZwsKxbltg_tg,http://www.youtube.com/channel/UCQ0OvZ54pCFZwsKxbltg_tg,Methos
UCRE6itj4Jte4manQEu3Y7OA,http://www.youtube.com/channel/UCRE6itj4Jte4manQEu3Y7OA,Chipflake
UCRLc6zsv_d0OEBO8OOkz-DA,http://www.youtube.com/channel/UCRLc6zsv_d0OEBO8OOkz-DA,Kegy
UCSl5Uxu2LyaoAoMMGp6oTJA,http://www.youtube.com/channel/UCSl5Uxu2LyaoAoMMGp6oTJA,Atomic Shrimp
UCXuqSBlHAE6Xw-yeJA0Tunw,http://www.youtube.com/channel/UCXuqSBlHAE6Xw-yeJA0Tunw,Linus Tech Tips
UCZ5XnGb-3t7jCkXdawN2tkA,http://www.youtube.com/channel/UCZ5XnGb-3t7jCkXdawN2tkA,Discord
CSV
Kanal-ID,Kanal-URL,Kanaltitel
UC0hHW5Y08ggq-9kbrGgWj0A,http://www.youtube.com/channel/UC0hHW5Y08ggq-9kbrGgWj0A,Matias Marolla
UC0vBXGSyV14uvJ4hECDOl0Q,http://www.youtube.com/channel/UC0vBXGSyV14uvJ4hECDOl0Q,Techquickie
UC1sELGmy5jp5fQUugmuYlXQ,http://www.youtube.com/channel/UC1sELGmy5jp5fQUugmuYlXQ,Minecraft
UC9kFnwdCRrX7oTjqKd6-tiQ,http://www.youtube.com/channel/UC9kFnwdCRrX7oTjqKd6-tiQ,LUMOX - Topic
UCBa659QWEk1AI4Tg--mrJ2A,http://www.youtube.com/channel/UCBa659QWEk1AI4Tg--mrJ2A,Tom Scott
UCGu6_XQ64rXPR6nuitMQE_A,http://www.youtube.com/channel/UCGu6_XQ64rXPR6nuitMQE_A,Callcenter Fun
UCGwu0nbY2wSkW8N-cghnLpA,http://www.youtube.com/channel/UCGwu0nbY2wSkW8N-cghnLpA,Jaiden Animations
UCQ0OvZ54pCFZwsKxbltg_tg,http://www.youtube.com/channel/UCQ0OvZ54pCFZwsKxbltg_tg,Methos
UCRE6itj4Jte4manQEu3Y7OA,http://www.youtube.com/channel/UCRE6itj4Jte4manQEu3Y7OA,Chipflake
UCRLc6zsv_d0OEBO8OOkz-DA,http://www.youtube.com/channel/UCRLc6zsv_d0OEBO8OOkz-DA,Kegy
UCSl5Uxu2LyaoAoMMGp6oTJA,http://www.youtube.com/channel/UCSl5Uxu2LyaoAoMMGp6oTJA,Atomic Shrimp
UCXuqSBlHAE6Xw-yeJA0Tunw,http://www.youtube.com/channel/UCXuqSBlHAE6Xw-yeJA0Tunw,Linus Tech Tips
UCZ5XnGb-3t7jCkXdawN2tkA,http://www.youtube.com/channel/UCZ5XnGb-3t7jCkXdawN2tkA,Discord
CSV
end
Spectator.describe Invidious::User::Import do

View File

@ -8,7 +8,7 @@ module Invidious::Database::Annotations
INSERT INTO annotations
VALUES ($1, $2)
ON CONFLICT DO NOTHING
SQL
SQL
PG_DB.exec(request, id, annotations)
end
@ -17,7 +17,7 @@ module Invidious::Database::Annotations
request = <<-SQL
SELECT * FROM annotations
WHERE id = $1
SQL
SQL
return PG_DB.query_one?(request, id, as: Annotation)
end

View File

@ -16,13 +16,13 @@ module Invidious::Database::Channels
request = <<-SQL
INSERT INTO channels
VALUES (#{arg_array(channel_array)})
SQL
SQL
if update_on_conflict
request += <<-SQL
ON CONFLICT (id) DO UPDATE
SET author = $2, updated = $3
SQL
SQL
end
PG_DB.exec(request, args: channel_array)
@ -37,7 +37,7 @@ module Invidious::Database::Channels
UPDATE channels
SET updated = now(), author = $1, deleted = false
WHERE id = $2
SQL
SQL
PG_DB.exec(request, author, id)
end
@ -47,7 +47,7 @@ module Invidious::Database::Channels
UPDATE channels
SET subscribed = now()
WHERE id = $1
SQL
SQL
PG_DB.exec(request, id)
end
@ -57,7 +57,7 @@ module Invidious::Database::Channels
UPDATE channels
SET updated = now(), deleted = true
WHERE id = $1
SQL
SQL
PG_DB.exec(request, id)
end
@ -70,7 +70,7 @@ module Invidious::Database::Channels
request = <<-SQL
SELECT * FROM channels
WHERE id = $1
SQL
SQL
return PG_DB.query_one?(request, id, as: InvidiousChannel)
end
@ -81,7 +81,7 @@ module Invidious::Database::Channels
request = <<-SQL
SELECT * FROM channels
WHERE id = ANY($1)
SQL
SQL
return PG_DB.query_all(request, ids, as: InvidiousChannel)
end
@ -112,7 +112,7 @@ module Invidious::Database::ChannelVideos
SET title = $2, published = $3, updated = $4, ucid = $5,
author = $6, length_seconds = $7, live_now = $8, #{last_items}
RETURNING (xmax=0) AS was_insert
SQL
SQL
return PG_DB.query_one(request, *video.to_tuple, as: Bool)
end
@ -128,7 +128,7 @@ module Invidious::Database::ChannelVideos
SELECT * FROM channel_videos
WHERE id = ANY($1)
ORDER BY published DESC
SQL
SQL
return PG_DB.query_all(request, ids, as: ChannelVideo)
end
@ -139,7 +139,7 @@ module Invidious::Database::ChannelVideos
WHERE ucid = $1 AND published > $2
ORDER BY published DESC
LIMIT 15
SQL
SQL
return PG_DB.query_all(request, ucid, since, as: ChannelVideo)
end
@ -151,7 +151,7 @@ module Invidious::Database::ChannelVideos
WHERE ucid IN (SELECT channel FROM (SELECT UNNEST(subscriptions) AS channel FROM users) AS d
GROUP BY channel ORDER BY COUNT(channel) DESC LIMIT 40)
ORDER BY ucid, published DESC
SQL
SQL
PG_DB.query_all(request, as: ChannelVideo)
end

View File

@ -4,27 +4,27 @@ module Invidious::Database::Migrations
def up(conn : DB::Connection)
conn.exec <<-SQL
CREATE TABLE IF NOT EXISTS public.channels
(
id text NOT NULL,
author text,
updated timestamp with time zone,
deleted boolean,
subscribed timestamp with time zone,
CONSTRAINT channels_id_key UNIQUE (id)
);
SQL
CREATE TABLE IF NOT EXISTS public.channels
(
id text NOT NULL,
author text,
updated timestamp with time zone,
deleted boolean,
subscribed timestamp with time zone,
CONSTRAINT channels_id_key UNIQUE (id)
);
SQL
conn.exec <<-SQL
GRANT ALL ON TABLE public.channels TO current_user;
SQL
GRANT ALL ON TABLE public.channels TO current_user;
SQL
conn.exec <<-SQL
CREATE INDEX IF NOT EXISTS channels_id_idx
ON public.channels
USING btree
(id COLLATE pg_catalog."default");
SQL
CREATE INDEX IF NOT EXISTS channels_id_idx
ON public.channels
USING btree
(id COLLATE pg_catalog."default");
SQL
end
end
end

View File

@ -4,25 +4,25 @@ module Invidious::Database::Migrations
def up(conn : DB::Connection)
conn.exec <<-SQL
CREATE UNLOGGED TABLE IF NOT EXISTS public.videos
(
id text NOT NULL,
info text,
updated timestamp with time zone,
CONSTRAINT videos_pkey PRIMARY KEY (id)
);
SQL
CREATE UNLOGGED TABLE IF NOT EXISTS public.videos
(
id text NOT NULL,
info text,
updated timestamp with time zone,
CONSTRAINT videos_pkey PRIMARY KEY (id)
);
SQL
conn.exec <<-SQL
GRANT ALL ON TABLE public.videos TO current_user;
SQL
GRANT ALL ON TABLE public.videos TO current_user;
SQL
conn.exec <<-SQL
CREATE UNIQUE INDEX IF NOT EXISTS id_idx
ON public.videos
USING btree
(id COLLATE pg_catalog."default");
SQL
CREATE UNIQUE INDEX IF NOT EXISTS id_idx
ON public.videos
USING btree
(id COLLATE pg_catalog."default");
SQL
end
end
end

View File

@ -4,32 +4,32 @@ module Invidious::Database::Migrations
def up(conn : DB::Connection)
conn.exec <<-SQL
CREATE TABLE IF NOT EXISTS public.channel_videos
(
id text NOT NULL,
title text,
published timestamp with time zone,
updated timestamp with time zone,
ucid text,
author text,
length_seconds integer,
live_now boolean,
premiere_timestamp timestamp with time zone,
views bigint,
CONSTRAINT channel_videos_id_key UNIQUE (id)
);
SQL
CREATE TABLE IF NOT EXISTS public.channel_videos
(
id text NOT NULL,
title text,
published timestamp with time zone,
updated timestamp with time zone,
ucid text,
author text,
length_seconds integer,
live_now boolean,
premiere_timestamp timestamp with time zone,
views bigint,
CONSTRAINT channel_videos_id_key UNIQUE (id)
);
SQL
conn.exec <<-SQL
GRANT ALL ON TABLE public.channel_videos TO current_user;
SQL
GRANT ALL ON TABLE public.channel_videos TO current_user;
SQL
conn.exec <<-SQL
CREATE INDEX IF NOT EXISTS channel_videos_ucid_idx
ON public.channel_videos
USING btree
(ucid COLLATE pg_catalog."default");
SQL
CREATE INDEX IF NOT EXISTS channel_videos_ucid_idx
ON public.channel_videos
USING btree
(ucid COLLATE pg_catalog."default");
SQL
end
end
end

View File

@ -4,31 +4,31 @@ module Invidious::Database::Migrations
def up(conn : DB::Connection)
conn.exec <<-SQL
CREATE TABLE IF NOT EXISTS public.users
(
updated timestamp with time zone,
notifications text[],
subscriptions text[],
email text NOT NULL,
preferences text,
password text,
token text,
watched text[],
feed_needs_update boolean,
CONSTRAINT users_email_key UNIQUE (email)
);
SQL
CREATE TABLE IF NOT EXISTS public.users
(
updated timestamp with time zone,
notifications text[],
subscriptions text[],
email text NOT NULL,
preferences text,
password text,
token text,
watched text[],
feed_needs_update boolean,
CONSTRAINT users_email_key UNIQUE (email)
);
SQL
conn.exec <<-SQL
GRANT ALL ON TABLE public.users TO current_user;
SQL
GRANT ALL ON TABLE public.users TO current_user;
SQL
conn.exec <<-SQL
CREATE UNIQUE INDEX IF NOT EXISTS email_unique_idx
ON public.users
USING btree
(lower(email) COLLATE pg_catalog."default");
SQL
CREATE UNIQUE INDEX IF NOT EXISTS email_unique_idx
ON public.users
USING btree
(lower(email) COLLATE pg_catalog."default");
SQL
end
end
end

View File

@ -4,25 +4,25 @@ module Invidious::Database::Migrations
def up(conn : DB::Connection)
conn.exec <<-SQL
CREATE TABLE IF NOT EXISTS public.session_ids
(
id text NOT NULL,
email text,
issued timestamp with time zone,
CONSTRAINT session_ids_pkey PRIMARY KEY (id)
);
SQL
CREATE TABLE IF NOT EXISTS public.session_ids
(
id text NOT NULL,
email text,
issued timestamp with time zone,
CONSTRAINT session_ids_pkey PRIMARY KEY (id)
);
SQL
conn.exec <<-SQL
GRANT ALL ON TABLE public.session_ids TO current_user;
SQL
GRANT ALL ON TABLE public.session_ids TO current_user;
SQL
conn.exec <<-SQL
CREATE INDEX IF NOT EXISTS session_ids_id_idx
ON public.session_ids
USING btree
(id COLLATE pg_catalog."default");
SQL
CREATE INDEX IF NOT EXISTS session_ids_id_idx
ON public.session_ids
USING btree
(id COLLATE pg_catalog."default");
SQL
end
end
end

View File

@ -4,24 +4,24 @@ module Invidious::Database::Migrations
def up(conn : DB::Connection)
conn.exec <<-SQL
CREATE TABLE IF NOT EXISTS public.nonces
(
nonce text,
expire timestamp with time zone,
CONSTRAINT nonces_id_key UNIQUE (nonce)
);
SQL
CREATE TABLE IF NOT EXISTS public.nonces
(
nonce text,
expire timestamp with time zone,
CONSTRAINT nonces_id_key UNIQUE (nonce)
);
SQL
conn.exec <<-SQL
GRANT ALL ON TABLE public.nonces TO current_user;
SQL
GRANT ALL ON TABLE public.nonces TO current_user;
SQL
conn.exec <<-SQL
CREATE INDEX IF NOT EXISTS nonces_nonce_idx
ON public.nonces
USING btree
(nonce COLLATE pg_catalog."default");
SQL
CREATE INDEX IF NOT EXISTS nonces_nonce_idx
ON public.nonces
USING btree
(nonce COLLATE pg_catalog."default");
SQL
end
end
end

View File

@ -4,17 +4,17 @@ module Invidious::Database::Migrations
def up(conn : DB::Connection)
conn.exec <<-SQL
CREATE TABLE IF NOT EXISTS public.annotations
(
id text NOT NULL,
annotations xml,
CONSTRAINT annotations_id_key UNIQUE (id)
);
SQL
CREATE TABLE IF NOT EXISTS public.annotations
(
id text NOT NULL,
annotations xml,
CONSTRAINT annotations_id_key UNIQUE (id)
);
SQL
conn.exec <<-SQL
GRANT ALL ON TABLE public.annotations TO current_user;
SQL
GRANT ALL ON TABLE public.annotations TO current_user;
SQL
end
end
end

View File

@ -5,33 +5,33 @@ module Invidious::Database::Migrations
def up(conn : DB::Connection)
if !privacy_type_exists?(conn)
conn.exec <<-SQL
CREATE TYPE public.privacy AS ENUM
(
'Public',
'Unlisted',
'Private'
);
SQL
CREATE TYPE public.privacy AS ENUM
(
'Public',
'Unlisted',
'Private'
);
SQL
end
conn.exec <<-SQL
CREATE TABLE IF NOT EXISTS public.playlists
(
title text,
id text primary key,
author text,
description text,
video_count integer,
created timestamptz,
updated timestamptz,
privacy privacy,
index int8[]
);
SQL
CREATE TABLE IF NOT EXISTS public.playlists
(
title text,
id text primary key,
author text,
description text,
video_count integer,
created timestamptz,
updated timestamptz,
privacy privacy,
index int8[]
);
SQL
conn.exec <<-SQL
GRANT ALL ON public.playlists TO current_user;
SQL
GRANT ALL ON public.playlists TO current_user;
SQL
end
private def privacy_type_exists?(conn : DB::Connection) : Bool
@ -42,7 +42,7 @@ module Invidious::Database::Migrations
WHERE pg_namespace.nspname = 'public'
AND pg_type.typname = 'privacy'
LIMIT 1;
SQL
SQL
!conn.query_one?(request, as: Int32).nil?
end

View File

@ -4,24 +4,24 @@ module Invidious::Database::Migrations
def up(conn : DB::Connection)
conn.exec <<-SQL
CREATE TABLE IF NOT EXISTS public.playlist_videos
(
title text,
id text,
author text,
ucid text,
length_seconds integer,
published timestamptz,
plid text references playlists(id),
index int8,
live_now boolean,
PRIMARY KEY (index,plid)
);
SQL
CREATE TABLE IF NOT EXISTS public.playlist_videos
(
title text,
id text,
author text,
ucid text,
length_seconds integer,
published timestamptz,
plid text references playlists(id),
index int8,
live_now boolean,
PRIMARY KEY (index,plid)
);
SQL
conn.exec <<-SQL
GRANT ALL ON TABLE public.playlist_videos TO current_user;
SQL
GRANT ALL ON TABLE public.playlist_videos TO current_user;
SQL
end
end
end

View File

@ -4,8 +4,8 @@ module Invidious::Database::Migrations
def up(conn : DB::Connection)
conn.exec <<-SQL
ALTER TABLE public.videos SET UNLOGGED;
SQL
ALTER TABLE public.videos SET UNLOGGED;
SQL
end
end
end

View File

@ -44,6 +44,6 @@ class Invidious::Database::Migrator
id bigserial PRIMARY KEY,
version bigint NOT NULL
)
SQL
SQL
end
end

View File

@ -12,7 +12,7 @@ module Invidious::Database::Nonces
INSERT INTO nonces
VALUES ($1, $2)
ON CONFLICT DO NOTHING
SQL
SQL
PG_DB.exec(request, nonce, expire)
end
@ -21,7 +21,7 @@ module Invidious::Database::Nonces
request = <<-SQL
DELETE FROM nonces *
WHERE expire < now()
SQL
SQL
PG_DB.exec(request)
end
@ -35,7 +35,7 @@ module Invidious::Database::Nonces
UPDATE nonces
SET expire = $1
WHERE nonce = $2
SQL
SQL
PG_DB.exec(request, Time.utc(1990, 1, 1), nonce)
end
@ -48,7 +48,7 @@ module Invidious::Database::Nonces
request = <<-SQL
SELECT * FROM nonces
WHERE nonce = $1
SQL
SQL
return PG_DB.query_one?(request, nonce, as: {String, Time})
end

View File

@ -16,7 +16,7 @@ module Invidious::Database::Playlists
request = <<-SQL
INSERT INTO playlists
VALUES (#{arg_array(playlist_array)})
SQL
SQL
PG_DB.exec(request, args: playlist_array)
end
@ -27,7 +27,7 @@ module Invidious::Database::Playlists
request = <<-SQL
DELETE FROM playlists *
WHERE id = $1
SQL
SQL
PG_DB.exec(request, id)
end
@ -41,7 +41,7 @@ module Invidious::Database::Playlists
UPDATE playlists
SET title = $1, privacy = $2, description = $3, updated = $4
WHERE id = $5
SQL
SQL
PG_DB.exec(request, title, privacy, description, updated, id)
end
@ -51,7 +51,7 @@ module Invidious::Database::Playlists
UPDATE playlists
SET description = $1
WHERE id = $2
SQL
SQL
PG_DB.exec(request, description, id)
end
@ -61,7 +61,7 @@ module Invidious::Database::Playlists
UPDATE playlists
SET subscribed = now()
WHERE id = $1
SQL
SQL
PG_DB.exec(request, id)
end
@ -73,7 +73,7 @@ module Invidious::Database::Playlists
video_count = cardinality(index) + 1,
updated = now()
WHERE id = $2
SQL
SQL
PG_DB.exec(request, index, id)
end
@ -85,7 +85,7 @@ module Invidious::Database::Playlists
video_count = cardinality(index) - 1,
updated = now()
WHERE id = $2
SQL
SQL
PG_DB.exec(request, index, id)
end
@ -98,7 +98,7 @@ module Invidious::Database::Playlists
request = <<-SQL
SELECT * FROM playlists
WHERE id = $1
SQL
SQL
return PG_DB.query_one?(request, id, as: InvidiousPlaylist)
end
@ -107,7 +107,7 @@ module Invidious::Database::Playlists
request = <<-SQL
SELECT * FROM playlists
WHERE author = $1
SQL
SQL
return PG_DB.query_all(request, author, as: InvidiousPlaylist)
end
@ -121,7 +121,7 @@ module Invidious::Database::Playlists
SELECT * FROM playlists
WHERE author = $1 AND id LIKE 'IV%'
ORDER BY created
SQL
SQL
PG_DB.query_all(request, email, as: InvidiousPlaylist)
end
@ -131,7 +131,7 @@ module Invidious::Database::Playlists
SELECT * FROM playlists
WHERE author = $1 AND id NOT LIKE 'IV%'
ORDER BY created
SQL
SQL
PG_DB.query_all(request, email, as: InvidiousPlaylist)
end
@ -141,7 +141,7 @@ module Invidious::Database::Playlists
SELECT id,title FROM playlists
WHERE author = $1 AND id LIKE 'IV%'
ORDER BY title
SQL
SQL
PG_DB.query_all(request, email, as: {String, String})
end
@ -155,7 +155,7 @@ module Invidious::Database::Playlists
request = <<-SQL
SELECT id FROM playlists
WHERE id = $1
SQL
SQL
return PG_DB.query_one?(request, id, as: String).nil?
end
@ -165,7 +165,7 @@ module Invidious::Database::Playlists
request = <<-SQL
SELECT count(*) FROM playlists
WHERE author = $1
SQL
SQL
return PG_DB.query_one?(request, author, as: Int64) || 0_i64
end
@ -189,7 +189,7 @@ module Invidious::Database::PlaylistVideos
request = <<-SQL
INSERT INTO playlist_videos
VALUES (#{arg_array(video_array)})
SQL
SQL
PG_DB.exec(request, args: video_array)
end
@ -198,7 +198,7 @@ module Invidious::Database::PlaylistVideos
request = <<-SQL
DELETE FROM playlist_videos *
WHERE index = $1
SQL
SQL
PG_DB.exec(request, index)
end
@ -207,7 +207,7 @@ module Invidious::Database::PlaylistVideos
request = <<-SQL
DELETE FROM playlist_videos *
WHERE plid = $1
SQL
SQL
PG_DB.exec(request, plid)
end
@ -223,7 +223,7 @@ module Invidious::Database::PlaylistVideos
ORDER BY array_position($2, index)
LIMIT $3
OFFSET $4
SQL
SQL
return PG_DB.query_all(request, plid, index, limit, offset, as: PlaylistVideo)
end
@ -233,7 +233,7 @@ module Invidious::Database::PlaylistVideos
SELECT index FROM playlist_videos
WHERE plid = $1 AND id = $2
LIMIT 1
SQL
SQL
return PG_DB.query_one?(request, plid, vid, as: Int64)
end
@ -244,7 +244,7 @@ module Invidious::Database::PlaylistVideos
WHERE plid = $1
ORDER BY array_position($2, index)
LIMIT 1
SQL
SQL
return PG_DB.query_one?(request, plid, index, as: String)
end
@ -255,7 +255,7 @@ module Invidious::Database::PlaylistVideos
WHERE plid = $1
ORDER BY array_position($2, index)
LIMIT $3
SQL
SQL
return PG_DB.query_all(request, plid, index, limit, as: String)
end

View File

@ -11,7 +11,7 @@ module Invidious::Database::SessionIDs
request = <<-SQL
INSERT INTO session_ids
VALUES ($1, $2, now())
SQL
SQL
request += " ON CONFLICT (id) DO NOTHING" if handle_conflicts
@ -26,7 +26,7 @@ module Invidious::Database::SessionIDs
request = <<-SQL
DELETE FROM session_ids *
WHERE id = $1
SQL
SQL
PG_DB.exec(request, sid)
end
@ -35,7 +35,7 @@ module Invidious::Database::SessionIDs
request = <<-SQL
DELETE FROM session_ids *
WHERE email = $1
SQL
SQL
PG_DB.exec(request, email)
end
@ -44,7 +44,7 @@ module Invidious::Database::SessionIDs
request = <<-SQL
DELETE FROM session_ids *
WHERE id = $1 AND email = $2
SQL
SQL
PG_DB.exec(request, sid, email)
end
@ -57,7 +57,7 @@ module Invidious::Database::SessionIDs
request = <<-SQL
SELECT email FROM session_ids
WHERE id = $1
SQL
SQL
PG_DB.query_one?(request, sid, as: String)
end
@ -67,7 +67,7 @@ module Invidious::Database::SessionIDs
SELECT id, issued FROM session_ids
WHERE email = $1
ORDER BY issued DESC
SQL
SQL
PG_DB.query_all(request, email, as: {session: String, issued: Time})
end

View File

@ -10,7 +10,7 @@ module Invidious::Database::Statistics
def count_users_total : Int64
request = <<-SQL
SELECT count(*) FROM users
SQL
SQL
PG_DB.query_one(request, as: Int64)
end
@ -19,7 +19,7 @@ module Invidious::Database::Statistics
request = <<-SQL
SELECT count(*) FROM users
WHERE CURRENT_TIMESTAMP - updated < '6 months'
SQL
SQL
PG_DB.query_one(request, as: Int64)
end
@ -28,7 +28,7 @@ module Invidious::Database::Statistics
request = <<-SQL
SELECT count(*) FROM users
WHERE CURRENT_TIMESTAMP - updated < '1 month'
SQL
SQL
PG_DB.query_one(request, as: Int64)
end
@ -42,7 +42,7 @@ module Invidious::Database::Statistics
SELECT updated FROM channels
ORDER BY updated DESC
LIMIT 1
SQL
SQL
PG_DB.query_one?(request, as: Time)
end

View File

@ -14,13 +14,13 @@ module Invidious::Database::Users
request = <<-SQL
INSERT INTO users
VALUES (#{arg_array(user_array)})
SQL
SQL
if update_on_conflict
request += <<-SQL
ON CONFLICT (email) DO UPDATE
SET updated = $1, subscriptions = $3
SQL
SQL
end
PG_DB.exec(request, args: user_array)
@ -30,7 +30,7 @@ module Invidious::Database::Users
request = <<-SQL
DELETE FROM users *
WHERE email = $1
SQL
SQL
PG_DB.exec(request, user.email)
end
@ -44,7 +44,7 @@ module Invidious::Database::Users
UPDATE users
SET watched = $1
WHERE email = $2
SQL
SQL
PG_DB.exec(request, user.watched, user.email)
end
@ -54,7 +54,7 @@ module Invidious::Database::Users
UPDATE users
SET watched = array_append(array_remove(watched, $1), $1)
WHERE email = $2
SQL
SQL
PG_DB.exec(request, vid, user.email)
end
@ -64,7 +64,7 @@ module Invidious::Database::Users
UPDATE users
SET watched = array_remove(watched, $1)
WHERE email = $2
SQL
SQL
PG_DB.exec(request, vid, user.email)
end
@ -74,7 +74,7 @@ module Invidious::Database::Users
UPDATE users
SET watched = '{}'
WHERE email = $1
SQL
SQL
PG_DB.exec(request, user.email)
end
@ -88,7 +88,7 @@ module Invidious::Database::Users
UPDATE users
SET feed_needs_update = true, subscriptions = $1
WHERE email = $2
SQL
SQL
PG_DB.exec(request, user.subscriptions, user.email)
end
@ -99,7 +99,7 @@ module Invidious::Database::Users
SET feed_needs_update = true,
subscriptions = array_append(subscriptions,$1)
WHERE email = $2
SQL
SQL
PG_DB.exec(request, ucid, user.email)
end
@ -110,7 +110,7 @@ module Invidious::Database::Users
SET feed_needs_update = true,
subscriptions = array_remove(subscriptions, $1)
WHERE email = $2
SQL
SQL
PG_DB.exec(request, ucid, user.email)
end
@ -125,7 +125,7 @@ module Invidious::Database::Users
SET notifications = array_cat(notifications, $1),
feed_needs_update = true
WHERE $2 = ANY(subscriptions)
SQL
SQL
PG_DB.exec(request, video_ids, channel_id)
end
@ -135,7 +135,7 @@ module Invidious::Database::Users
UPDATE users
SET notifications = array_remove(notifications, $1)
WHERE email = $2
SQL
SQL
PG_DB.exec(request, vid, user.email)
end
@ -145,7 +145,7 @@ module Invidious::Database::Users
UPDATE users
SET notifications = '{}', updated = now()
WHERE email = $1
SQL
SQL
PG_DB.exec(request, user.email)
end
@ -159,7 +159,7 @@ module Invidious::Database::Users
UPDATE users
SET feed_needs_update = true
WHERE $1 = ANY(subscriptions)
SQL
SQL
PG_DB.exec(request, channel_id)
end
@ -169,7 +169,7 @@ module Invidious::Database::Users
UPDATE users
SET preferences = $1
WHERE email = $2
SQL
SQL
PG_DB.exec(request, user.preferences.to_json, user.email)
end
@ -179,7 +179,7 @@ module Invidious::Database::Users
UPDATE users
SET password = $1
WHERE email = $2
SQL
SQL
PG_DB.exec(request, pass, user.email)
end
@ -192,7 +192,7 @@ module Invidious::Database::Users
request = <<-SQL
SELECT * FROM users
WHERE email = $1
SQL
SQL
return PG_DB.query_one?(request, email, as: User)
end
@ -202,7 +202,7 @@ module Invidious::Database::Users
request = <<-SQL
SELECT * FROM users
WHERE email = $1
SQL
SQL
return PG_DB.query_one(request, email, as: User)
end
@ -211,7 +211,7 @@ module Invidious::Database::Users
request = <<-SQL
SELECT * FROM users
WHERE token = $1
SQL
SQL
return PG_DB.query_one?(request, token, as: User)
end
@ -221,7 +221,7 @@ module Invidious::Database::Users
SELECT notifications
FROM users
WHERE email = $1
SQL
SQL
return PG_DB.query_one(request, user.email, as: Array(String))
end

View File

@ -8,7 +8,7 @@ module Invidious::Database::Videos
INSERT INTO videos
VALUES ($1, $2, $3)
ON CONFLICT (id) DO NOTHING
SQL
SQL
PG_DB.exec(request, video.id, video.info.to_json, video.updated)
end
@ -17,7 +17,7 @@ module Invidious::Database::Videos
request = <<-SQL
DELETE FROM videos *
WHERE id = $1
SQL
SQL
PG_DB.exec(request, id)
end
@ -26,7 +26,7 @@ module Invidious::Database::Videos
request = <<-SQL
DELETE FROM videos *
WHERE updated < (now() - interval '6 hours')
SQL
SQL
PG_DB.exec(request)
end
@ -36,7 +36,7 @@ module Invidious::Database::Videos
UPDATE videos
SET (id, info, updated) = ($1, $2, $3)
WHERE id = $1
SQL
SQL
PG_DB.exec(request, video.id, video.info.to_json, video.updated)
end
@ -45,7 +45,7 @@ module Invidious::Database::Videos
request = <<-SQL
SELECT * FROM videos
WHERE id = $1
SQL
SQL
return PG_DB.query_one?(request, id, as: Video)
end

View File

@ -16,33 +16,33 @@ module Invidious::Frontend::Comments
if child.depth > 0
html << <<-END_HTML
<div class="pure-g">
<div class="pure-u-1-24">
</div>
<div class="pure-u-23-24">
END_HTML
<div class="pure-g">
<div class="pure-u-1-24">
</div>
<div class="pure-u-23-24">
END_HTML
else
html << <<-END_HTML
<div class="pure-g">
<div class="pure-u-1">
END_HTML
<div class="pure-g">
<div class="pure-u-1">
END_HTML
end
html << <<-END_HTML
<p>
<a href="javascript:void(0)" data-onclick="toggle_parent">[ ]</a>
<b><a href="https://www.reddit.com/user/#{child.author}">#{child.author}</a></b>
#{translate_count(locale, "comments_points_count", child.score, NumberFormatting::Separator)}
<span title="#{child.created_utc.to_s("%a %B %-d %T %Y UTC")}">#{translate(locale, "`x` ago", recode_date(child.created_utc, locale))}</span>
<a href="https://www.reddit.com#{child.permalink}" title="#{translate(locale, "permalink")}">#{translate(locale, "permalink")}</a>
</p>
<div>
#{body_html}
#{replies_html}
</div>
</div>
</div>
END_HTML
<p>
<a href="javascript:void(0)" data-onclick="toggle_parent">[ ]</a>
<b><a href="https://www.reddit.com/user/#{child.author}">#{child.author}</a></b>
#{translate_count(locale, "comments_points_count", child.score, NumberFormatting::Separator)}
<span title="#{child.created_utc.to_s("%a %B %-d %T %Y UTC")}">#{translate(locale, "`x` ago", recode_date(child.created_utc, locale))}</span>
<a href="https://www.reddit.com#{child.permalink}" title="#{translate(locale, "permalink")}">#{translate(locale, "permalink")}</a>
</p>
<div>
#{body_html}
#{replies_html}
</div>
</div>
</div>
END_HTML
end
end
end

View File

@ -13,16 +13,16 @@ module Invidious::Frontend::Comments
)
replies_html = <<-END_HTML
<div id="replies" class="pure-g">
<div class="pure-u-1-24"></div>
<div class="pure-u-23-24">
<p>
<a href="javascript:void(0)" data-continuation="#{child["replies"]["continuation"]}"
data-onclick="get_youtube_replies" data-load-replies>#{replies_count_text}</a>
</p>
<div id="replies" class="pure-g">
<div class="pure-u-1-24"></div>
<div class="pure-u-23-24">
<p>
<a href="javascript:void(0)" data-continuation="#{child["replies"]["continuation"]}"
data-onclick="get_youtube_replies" data-load-replies>#{replies_count_text}</a>
</p>
</div>
</div>
</div>
END_HTML
END_HTML
elsif comments["authorId"]? && !comments["singlePost"]?
# for posts we should display a link to the post
replies_count_text = translate_count(locale,
@ -32,15 +32,15 @@ module Invidious::Frontend::Comments
)
replies_html = <<-END_HTML
<div class="pure-g">
<div class="pure-u-1-24"></div>
<div class="pure-u-23-24">
<p>
<a href="/post/#{child["commentId"]}?ucid=#{comments["authorId"]}">#{replies_count_text}</a>
</p>
<div class="pure-g">
<div class="pure-u-1-24"></div>
<div class="pure-u-23-24">
<p>
<a href="/post/#{child["commentId"]}?ucid=#{comments["authorId"]}">#{replies_count_text}</a>
</p>
</div>
</div>
</div>
END_HTML
END_HTML
end
if !thin_mode
@ -66,18 +66,18 @@ module Invidious::Frontend::Comments
end
end
html << <<-END_HTML
<div class="pure-g" style="width:100%">
<div class="channel-profile pure-u-4-24 pure-u-md-2-24">
<img loading="lazy" style="margin-right:1em;margin-top:1em;width:90%" src="#{author_thumbnail}" alt="" />
</div>
<div class="pure-u-20-24 pure-u-md-22-24">
<p>
<b>
<a class="#{child["authorIsChannelOwner"] == true ? "channel-owner" : ""}" href="#{child["authorUrl"]}">#{author_name}</a>
</b>
#{sponsor_icon}
<p style="white-space:pre-wrap">#{child["contentHtml"]}</p>
END_HTML
<div class="pure-g" style="width:100%">
<div class="channel-profile pure-u-4-24 pure-u-md-2-24">
<img loading="lazy" style="margin-right:1em;margin-top:1em;width:90%" src="#{author_thumbnail}" alt="" />
</div>
<div class="pure-u-20-24 pure-u-md-22-24">
<p>
<b>
<a class="#{child["authorIsChannelOwner"] == true ? "channel-owner" : ""}" href="#{child["authorUrl"]}">#{author_name}</a>
</b>
#{sponsor_icon}
<p style="white-space:pre-wrap">#{child["contentHtml"]}</p>
END_HTML
if child["attachment"]?
attachment = child["attachment"]
@ -87,25 +87,25 @@ module Invidious::Frontend::Comments
attachment = attachment["imageThumbnails"][1]
html << <<-END_HTML
<div class="pure-g">
<div class="pure-u-1 pure-u-md-1-2">
<img loading="lazy" style="width:100%" src="/ggpht#{URI.parse(attachment["url"].as_s).request_target}" alt="" />
<div class="pure-g">
<div class="pure-u-1 pure-u-md-1-2">
<img loading="lazy" style="width:100%" src="/ggpht#{URI.parse(attachment["url"].as_s).request_target}" alt="" />
</div>
</div>
</div>
END_HTML
END_HTML
when "video"
if attachment["error"]?
html << <<-END_HTML
<div class="pure-g video-iframe-wrapper">
<p>#{attachment["error"]}</p>
</div>
END_HTML
<div class="pure-g video-iframe-wrapper">
<p>#{attachment["error"]}</p>
</div>
END_HTML
else
html << <<-END_HTML
<div class="pure-g video-iframe-wrapper">
<iframe class="video-iframe" src='/embed/#{attachment["videoId"]?}?autoplay=0'></iframe>
</div>
END_HTML
<div class="pure-g video-iframe-wrapper">
<iframe class="video-iframe" src='/embed/#{attachment["videoId"]?}?autoplay=0'></iframe>
</div>
END_HTML
end
when "multiImage"
html << <<-END_HTML
@ -133,35 +133,35 @@ module Invidious::Frontend::Comments
END_HTML
end
html << <<-END_HTML
</div>
<div id="skip-#{child["commentId"]}"></div>
</section>
END_HTML
</div>
<div id="skip-#{child["commentId"]}"></div>
</section>
END_HTML
else nil # Ignore
end
end
html << <<-END_HTML
<p>
<span title="#{Time.unix(child["published"].as_i64).to_s(translate(locale, "%A %B %-d, %Y"))}">#{translate(locale, "`x` ago", recode_date(Time.unix(child["published"].as_i64), locale))} #{child["isEdited"] == true ? translate(locale, "(edited)") : ""}</span>
|
END_HTML
<p>
<span title="#{Time.unix(child["published"].as_i64).to_s(translate(locale, "%A %B %-d, %Y"))}">#{translate(locale, "`x` ago", recode_date(Time.unix(child["published"].as_i64), locale))} #{child["isEdited"] == true ? translate(locale, "(edited)") : ""}</span>
|
END_HTML
if comments["videoId"]?
html << <<-END_HTML
<a rel="noreferrer noopener" href="https://www.youtube.com/watch?v=#{comments["videoId"]}&lc=#{child["commentId"]}" title="#{translate(locale, "YouTube comment permalink")}">[YT]</a>
|
END_HTML
END_HTML
elsif comments["authorId"]?
html << <<-END_HTML
<a rel="noreferrer noopener" href="https://www.youtube.com/channel/#{comments["authorId"]}/community?lb=#{child["commentId"]}" title="#{translate(locale, "YouTube comment permalink")}">[YT]</a>
|
END_HTML
END_HTML
end
html << <<-END_HTML
<i class="icon ion-ios-thumbs-up"></i> #{number_with_separator(child["likeCount"])}
END_HTML
END_HTML
if child["creatorHeart"]?
if !thin_mode
@ -180,28 +180,28 @@ module Invidious::Frontend::Comments
</span>
</span>
</span>
END_HTML
END_HTML
end
html << <<-END_HTML
</p>
#{replies_html}
</p>
#{replies_html}
</div>
</div>
</div>
END_HTML
END_HTML
end
if comments["continuation"]?
html << <<-END_HTML
<div class="pure-g">
<div class="pure-u-1">
<p>
<a href="javascript:void(0)" data-continuation="#{comments["continuation"]}"
data-onclick="get_youtube_replies" data-load-more #{"data-load-replies" if is_replies}>#{translate(locale, "Load more")}</a>
</p>
<div class="pure-g">
<div class="pure-u-1">
<p>
<a href="javascript:void(0)" data-continuation="#{comments["continuation"]}"
data-onclick="get_youtube_replies" data-load-more #{"data-load-replies" if is_replies}>#{translate(locale, "Load more")}</a>
</p>
</div>
</div>
</div>
END_HTML
END_HTML
end
end
end

View File

@ -22,12 +22,12 @@ def get_issue_template(env : HTTP::Server::Context, exception : Exception) : Tup
issue_title = "#{exception.message} (#{exception.class})"
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"]}`
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
TEXT
issue_template += github_details("Backtrace", exception.inspect_with_backtrace)
@ -80,7 +80,7 @@ def error_template_helper(env : HTTP::Server::Context, status_code : Int32, exce
<!-- TODO: Add a "copy to clipboard" button -->
<pre class="error-issue-template">#{issue_template}</pre>
</div>
END_HTML
END_HTML
# Don't show the usual "next steps" widget. The same options are
# proposed above the error message, just worded differently.
@ -204,7 +204,7 @@ def error_redirect_helper(env : HTTP::Server::Context)
<a rel="noreferrer noopener" href="https://youtube.com#{env.request.resource}">#{go_to_youtube}</a>
</li>
</ul>
END_HTML
END_HTML
else
return ""
end

View File

@ -83,14 +83,14 @@ end
def template_mix(mix, listen)
html = <<-END_HTML
<h3>
<a href="/mix?list=#{mix["mixId"]}">
#{mix["title"]}
</a>
</h3>
<div class="pure-menu pure-menu-scrollable playlist-restricted">
<ol class="pure-menu-list">
END_HTML
<h3>
<a href="/mix?list=#{mix["mixId"]}">
#{mix["title"]}
</a>
</h3>
<div class="pure-menu pure-menu-scrollable playlist-restricted">
<ol class="pure-menu-list">
END_HTML
mix["videos"].as_a.each do |video|
html += <<-END_HTML
@ -106,14 +106,14 @@ def template_mix(mix, listen)
</p>
</a>
</li>
END_HTML
END_HTML
end
html += <<-END_HTML
</ol>
</div>
<hr>
END_HTML
</ol>
</div>
<hr>
END_HTML
html
end

View File

@ -509,14 +509,14 @@ end
def template_playlist(playlist, listen)
html = <<-END_HTML
<h3>
<a href="/playlist?list=#{playlist["playlistId"]}">
#{playlist["title"]}
</a>
</h3>
<div class="pure-menu pure-menu-scrollable playlist-restricted">
<ol class="pure-menu-list">
END_HTML
<h3>
<a href="/playlist?list=#{playlist["playlistId"]}">
#{playlist["title"]}
</a>
</h3>
<div class="pure-menu pure-menu-scrollable playlist-restricted">
<ol class="pure-menu-list">
END_HTML
playlist["videos"].as_a.each do |video|
html += <<-END_HTML
@ -532,14 +532,14 @@ def template_playlist(playlist, listen)
</p>
</a>
</li>
END_HTML
END_HTML
end
html += <<-END_HTML
</ol>
</div>
<hr>
END_HTML
</ol>
</div>
<hr>
END_HTML
html
end

View File

@ -20,28 +20,28 @@ struct Invidious::User
end
clock_svg = <<-END_SVG
<svg viewBox="0 0 100 100" width="200px" height="200px">
<circle cx="50" cy="50" r="45" fill="#eee" stroke="black" stroke-width="2"></circle>
<svg viewBox="0 0 100 100" width="200px" height="200px">
<circle cx="50" cy="50" r="45" fill="#eee" stroke="black" stroke-width="2"></circle>
<text x="69" y="20.091" text-anchor="middle" fill="black" font-family="Arial" font-size="10px"> 1</text>
<text x="82.909" y="34" text-anchor="middle" fill="black" font-family="Arial" font-size="10px"> 2</text>
<text x="88" y="53" text-anchor="middle" fill="black" font-family="Arial" font-size="10px"> 3</text>
<text x="82.909" y="72" text-anchor="middle" fill="black" font-family="Arial" font-size="10px"> 4</text>
<text x="69" y="85.909" text-anchor="middle" fill="black" font-family="Arial" font-size="10px"> 5</text>
<text x="50" y="91" text-anchor="middle" fill="black" font-family="Arial" font-size="10px"> 6</text>
<text x="31" y="85.909" text-anchor="middle" fill="black" font-family="Arial" font-size="10px"> 7</text>
<text x="17.091" y="72" text-anchor="middle" fill="black" font-family="Arial" font-size="10px"> 8</text>
<text x="12" y="53" text-anchor="middle" fill="black" font-family="Arial" font-size="10px"> 9</text>
<text x="17.091" y="34" text-anchor="middle" fill="black" font-family="Arial" font-size="10px">10</text>
<text x="31" y="20.091" text-anchor="middle" fill="black" font-family="Arial" font-size="10px">11</text>
<text x="50" y="15" text-anchor="middle" fill="black" font-family="Arial" font-size="10px">12</text>
<text x="69" y="20.091" text-anchor="middle" fill="black" font-family="Arial" font-size="10px"> 1</text>
<text x="82.909" y="34" text-anchor="middle" fill="black" font-family="Arial" font-size="10px"> 2</text>
<text x="88" y="53" text-anchor="middle" fill="black" font-family="Arial" font-size="10px"> 3</text>
<text x="82.909" y="72" text-anchor="middle" fill="black" font-family="Arial" font-size="10px"> 4</text>
<text x="69" y="85.909" text-anchor="middle" fill="black" font-family="Arial" font-size="10px"> 5</text>
<text x="50" y="91" text-anchor="middle" fill="black" font-family="Arial" font-size="10px"> 6</text>
<text x="31" y="85.909" text-anchor="middle" fill="black" font-family="Arial" font-size="10px"> 7</text>
<text x="17.091" y="72" text-anchor="middle" fill="black" font-family="Arial" font-size="10px"> 8</text>
<text x="12" y="53" text-anchor="middle" fill="black" font-family="Arial" font-size="10px"> 9</text>
<text x="17.091" y="34" text-anchor="middle" fill="black" font-family="Arial" font-size="10px">10</text>
<text x="31" y="20.091" text-anchor="middle" fill="black" font-family="Arial" font-size="10px">11</text>
<text x="50" y="15" text-anchor="middle" fill="black" font-family="Arial" font-size="10px">12</text>
<circle cx="50" cy="50" r="3" fill="black"></circle>
<line id="second" transform="rotate(#{second_angle}, 50, 50)" x1="50" y1="50" x2="50" y2="12" fill="black" stroke="black" stroke-width="1"></line>
<line id="minute" transform="rotate(#{minute_angle}, 50, 50)" x1="50" y1="50" x2="50" y2="16" fill="black" stroke="black" stroke-width="2"></line>
<line id="hour" transform="rotate(#{hour_angle}, 50, 50)" x1="50" y1="50" x2="50" y2="24" fill="black" stroke="black" stroke-width="2"></line>
</svg>
END_SVG
<circle cx="50" cy="50" r="3" fill="black"></circle>
<line id="second" transform="rotate(#{second_angle}, 50, 50)" x1="50" y1="50" x2="50" y2="12" fill="black" stroke="black" stroke-width="1"></line>
<line id="minute" transform="rotate(#{minute_angle}, 50, 50)" x1="50" y1="50" x2="50" y2="16" fill="black" stroke="black" stroke-width="2"></line>
<line id="hour" transform="rotate(#{hour_angle}, 50, 50)" x1="50" y1="50" x2="50" y2="24" fill="black" stroke="black" stroke-width="2"></line>
</svg>
END_SVG
image = "data:image/png;base64,"
image += Process.run(%(rsvg-convert -w 400 -h 400 -b none -f png), shell: true,