mirror of
https://github.com/iv-org/invidious.git
synced 2026-01-28 15:58:30 -06:00
Fix Style/HeredocIndent type of Ameba issues
This commit is contained in:
parent
e5a1131665
commit
2112ee674e
@ -8,21 +8,21 @@ end
|
|||||||
|
|
||||||
def csv_sample
|
def csv_sample
|
||||||
return <<-CSV
|
return <<-CSV
|
||||||
Kanal-ID,Kanal-URL,Kanaltitel
|
Kanal-ID,Kanal-URL,Kanaltitel
|
||||||
UC0hHW5Y08ggq-9kbrGgWj0A,http://www.youtube.com/channel/UC0hHW5Y08ggq-9kbrGgWj0A,Matias Marolla
|
UC0hHW5Y08ggq-9kbrGgWj0A,http://www.youtube.com/channel/UC0hHW5Y08ggq-9kbrGgWj0A,Matias Marolla
|
||||||
UC0vBXGSyV14uvJ4hECDOl0Q,http://www.youtube.com/channel/UC0vBXGSyV14uvJ4hECDOl0Q,Techquickie
|
UC0vBXGSyV14uvJ4hECDOl0Q,http://www.youtube.com/channel/UC0vBXGSyV14uvJ4hECDOl0Q,Techquickie
|
||||||
UC1sELGmy5jp5fQUugmuYlXQ,http://www.youtube.com/channel/UC1sELGmy5jp5fQUugmuYlXQ,Minecraft
|
UC1sELGmy5jp5fQUugmuYlXQ,http://www.youtube.com/channel/UC1sELGmy5jp5fQUugmuYlXQ,Minecraft
|
||||||
UC9kFnwdCRrX7oTjqKd6-tiQ,http://www.youtube.com/channel/UC9kFnwdCRrX7oTjqKd6-tiQ,LUMOX - Topic
|
UC9kFnwdCRrX7oTjqKd6-tiQ,http://www.youtube.com/channel/UC9kFnwdCRrX7oTjqKd6-tiQ,LUMOX - Topic
|
||||||
UCBa659QWEk1AI4Tg--mrJ2A,http://www.youtube.com/channel/UCBa659QWEk1AI4Tg--mrJ2A,Tom Scott
|
UCBa659QWEk1AI4Tg--mrJ2A,http://www.youtube.com/channel/UCBa659QWEk1AI4Tg--mrJ2A,Tom Scott
|
||||||
UCGu6_XQ64rXPR6nuitMQE_A,http://www.youtube.com/channel/UCGu6_XQ64rXPR6nuitMQE_A,Callcenter Fun
|
UCGu6_XQ64rXPR6nuitMQE_A,http://www.youtube.com/channel/UCGu6_XQ64rXPR6nuitMQE_A,Callcenter Fun
|
||||||
UCGwu0nbY2wSkW8N-cghnLpA,http://www.youtube.com/channel/UCGwu0nbY2wSkW8N-cghnLpA,Jaiden Animations
|
UCGwu0nbY2wSkW8N-cghnLpA,http://www.youtube.com/channel/UCGwu0nbY2wSkW8N-cghnLpA,Jaiden Animations
|
||||||
UCQ0OvZ54pCFZwsKxbltg_tg,http://www.youtube.com/channel/UCQ0OvZ54pCFZwsKxbltg_tg,Methos
|
UCQ0OvZ54pCFZwsKxbltg_tg,http://www.youtube.com/channel/UCQ0OvZ54pCFZwsKxbltg_tg,Methos
|
||||||
UCRE6itj4Jte4manQEu3Y7OA,http://www.youtube.com/channel/UCRE6itj4Jte4manQEu3Y7OA,Chipflake
|
UCRE6itj4Jte4manQEu3Y7OA,http://www.youtube.com/channel/UCRE6itj4Jte4manQEu3Y7OA,Chipflake
|
||||||
UCRLc6zsv_d0OEBO8OOkz-DA,http://www.youtube.com/channel/UCRLc6zsv_d0OEBO8OOkz-DA,Kegy
|
UCRLc6zsv_d0OEBO8OOkz-DA,http://www.youtube.com/channel/UCRLc6zsv_d0OEBO8OOkz-DA,Kegy
|
||||||
UCSl5Uxu2LyaoAoMMGp6oTJA,http://www.youtube.com/channel/UCSl5Uxu2LyaoAoMMGp6oTJA,Atomic Shrimp
|
UCSl5Uxu2LyaoAoMMGp6oTJA,http://www.youtube.com/channel/UCSl5Uxu2LyaoAoMMGp6oTJA,Atomic Shrimp
|
||||||
UCXuqSBlHAE6Xw-yeJA0Tunw,http://www.youtube.com/channel/UCXuqSBlHAE6Xw-yeJA0Tunw,Linus Tech Tips
|
UCXuqSBlHAE6Xw-yeJA0Tunw,http://www.youtube.com/channel/UCXuqSBlHAE6Xw-yeJA0Tunw,Linus Tech Tips
|
||||||
UCZ5XnGb-3t7jCkXdawN2tkA,http://www.youtube.com/channel/UCZ5XnGb-3t7jCkXdawN2tkA,Discord
|
UCZ5XnGb-3t7jCkXdawN2tkA,http://www.youtube.com/channel/UCZ5XnGb-3t7jCkXdawN2tkA,Discord
|
||||||
CSV
|
CSV
|
||||||
end
|
end
|
||||||
|
|
||||||
Spectator.describe Invidious::User::Import do
|
Spectator.describe Invidious::User::Import do
|
||||||
|
|||||||
@ -8,7 +8,7 @@ module Invidious::Database::Annotations
|
|||||||
INSERT INTO annotations
|
INSERT INTO annotations
|
||||||
VALUES ($1, $2)
|
VALUES ($1, $2)
|
||||||
ON CONFLICT DO NOTHING
|
ON CONFLICT DO NOTHING
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, id, annotations)
|
PG_DB.exec(request, id, annotations)
|
||||||
end
|
end
|
||||||
@ -17,7 +17,7 @@ module Invidious::Database::Annotations
|
|||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
SELECT * FROM annotations
|
SELECT * FROM annotations
|
||||||
WHERE id = $1
|
WHERE id = $1
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
return PG_DB.query_one?(request, id, as: Annotation)
|
return PG_DB.query_one?(request, id, as: Annotation)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -16,13 +16,13 @@ module Invidious::Database::Channels
|
|||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
INSERT INTO channels
|
INSERT INTO channels
|
||||||
VALUES (#{arg_array(channel_array)})
|
VALUES (#{arg_array(channel_array)})
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
if update_on_conflict
|
if update_on_conflict
|
||||||
request += <<-SQL
|
request += <<-SQL
|
||||||
ON CONFLICT (id) DO UPDATE
|
ON CONFLICT (id) DO UPDATE
|
||||||
SET author = $2, updated = $3
|
SET author = $2, updated = $3
|
||||||
SQL
|
SQL
|
||||||
end
|
end
|
||||||
|
|
||||||
PG_DB.exec(request, args: channel_array)
|
PG_DB.exec(request, args: channel_array)
|
||||||
@ -37,7 +37,7 @@ module Invidious::Database::Channels
|
|||||||
UPDATE channels
|
UPDATE channels
|
||||||
SET updated = now(), author = $1, deleted = false
|
SET updated = now(), author = $1, deleted = false
|
||||||
WHERE id = $2
|
WHERE id = $2
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, author, id)
|
PG_DB.exec(request, author, id)
|
||||||
end
|
end
|
||||||
@ -47,7 +47,7 @@ module Invidious::Database::Channels
|
|||||||
UPDATE channels
|
UPDATE channels
|
||||||
SET subscribed = now()
|
SET subscribed = now()
|
||||||
WHERE id = $1
|
WHERE id = $1
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, id)
|
PG_DB.exec(request, id)
|
||||||
end
|
end
|
||||||
@ -57,7 +57,7 @@ module Invidious::Database::Channels
|
|||||||
UPDATE channels
|
UPDATE channels
|
||||||
SET updated = now(), deleted = true
|
SET updated = now(), deleted = true
|
||||||
WHERE id = $1
|
WHERE id = $1
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, id)
|
PG_DB.exec(request, id)
|
||||||
end
|
end
|
||||||
@ -70,7 +70,7 @@ module Invidious::Database::Channels
|
|||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
SELECT * FROM channels
|
SELECT * FROM channels
|
||||||
WHERE id = $1
|
WHERE id = $1
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
return PG_DB.query_one?(request, id, as: InvidiousChannel)
|
return PG_DB.query_one?(request, id, as: InvidiousChannel)
|
||||||
end
|
end
|
||||||
@ -81,7 +81,7 @@ module Invidious::Database::Channels
|
|||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
SELECT * FROM channels
|
SELECT * FROM channels
|
||||||
WHERE id = ANY($1)
|
WHERE id = ANY($1)
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
return PG_DB.query_all(request, ids, as: InvidiousChannel)
|
return PG_DB.query_all(request, ids, as: InvidiousChannel)
|
||||||
end
|
end
|
||||||
@ -112,7 +112,7 @@ module Invidious::Database::ChannelVideos
|
|||||||
SET title = $2, published = $3, updated = $4, ucid = $5,
|
SET title = $2, published = $3, updated = $4, ucid = $5,
|
||||||
author = $6, length_seconds = $7, live_now = $8, #{last_items}
|
author = $6, length_seconds = $7, live_now = $8, #{last_items}
|
||||||
RETURNING (xmax=0) AS was_insert
|
RETURNING (xmax=0) AS was_insert
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
return PG_DB.query_one(request, *video.to_tuple, as: Bool)
|
return PG_DB.query_one(request, *video.to_tuple, as: Bool)
|
||||||
end
|
end
|
||||||
@ -128,7 +128,7 @@ module Invidious::Database::ChannelVideos
|
|||||||
SELECT * FROM channel_videos
|
SELECT * FROM channel_videos
|
||||||
WHERE id = ANY($1)
|
WHERE id = ANY($1)
|
||||||
ORDER BY published DESC
|
ORDER BY published DESC
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
return PG_DB.query_all(request, ids, as: ChannelVideo)
|
return PG_DB.query_all(request, ids, as: ChannelVideo)
|
||||||
end
|
end
|
||||||
@ -139,7 +139,7 @@ module Invidious::Database::ChannelVideos
|
|||||||
WHERE ucid = $1 AND published > $2
|
WHERE ucid = $1 AND published > $2
|
||||||
ORDER BY published DESC
|
ORDER BY published DESC
|
||||||
LIMIT 15
|
LIMIT 15
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
return PG_DB.query_all(request, ucid, since, as: ChannelVideo)
|
return PG_DB.query_all(request, ucid, since, as: ChannelVideo)
|
||||||
end
|
end
|
||||||
@ -151,7 +151,7 @@ module Invidious::Database::ChannelVideos
|
|||||||
WHERE ucid IN (SELECT channel FROM (SELECT UNNEST(subscriptions) AS channel FROM users) AS d
|
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)
|
GROUP BY channel ORDER BY COUNT(channel) DESC LIMIT 40)
|
||||||
ORDER BY ucid, published DESC
|
ORDER BY ucid, published DESC
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.query_all(request, as: ChannelVideo)
|
PG_DB.query_all(request, as: ChannelVideo)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -4,27 +4,27 @@ module Invidious::Database::Migrations
|
|||||||
|
|
||||||
def up(conn : DB::Connection)
|
def up(conn : DB::Connection)
|
||||||
conn.exec <<-SQL
|
conn.exec <<-SQL
|
||||||
CREATE TABLE IF NOT EXISTS public.channels
|
CREATE TABLE IF NOT EXISTS public.channels
|
||||||
(
|
(
|
||||||
id text NOT NULL,
|
id text NOT NULL,
|
||||||
author text,
|
author text,
|
||||||
updated timestamp with time zone,
|
updated timestamp with time zone,
|
||||||
deleted boolean,
|
deleted boolean,
|
||||||
subscribed timestamp with time zone,
|
subscribed timestamp with time zone,
|
||||||
CONSTRAINT channels_id_key UNIQUE (id)
|
CONSTRAINT channels_id_key UNIQUE (id)
|
||||||
);
|
);
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
conn.exec <<-SQL
|
conn.exec <<-SQL
|
||||||
GRANT ALL ON TABLE public.channels TO current_user;
|
GRANT ALL ON TABLE public.channels TO current_user;
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
conn.exec <<-SQL
|
conn.exec <<-SQL
|
||||||
CREATE INDEX IF NOT EXISTS channels_id_idx
|
CREATE INDEX IF NOT EXISTS channels_id_idx
|
||||||
ON public.channels
|
ON public.channels
|
||||||
USING btree
|
USING btree
|
||||||
(id COLLATE pg_catalog."default");
|
(id COLLATE pg_catalog."default");
|
||||||
SQL
|
SQL
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -4,25 +4,25 @@ module Invidious::Database::Migrations
|
|||||||
|
|
||||||
def up(conn : DB::Connection)
|
def up(conn : DB::Connection)
|
||||||
conn.exec <<-SQL
|
conn.exec <<-SQL
|
||||||
CREATE UNLOGGED TABLE IF NOT EXISTS public.videos
|
CREATE UNLOGGED TABLE IF NOT EXISTS public.videos
|
||||||
(
|
(
|
||||||
id text NOT NULL,
|
id text NOT NULL,
|
||||||
info text,
|
info text,
|
||||||
updated timestamp with time zone,
|
updated timestamp with time zone,
|
||||||
CONSTRAINT videos_pkey PRIMARY KEY (id)
|
CONSTRAINT videos_pkey PRIMARY KEY (id)
|
||||||
);
|
);
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
conn.exec <<-SQL
|
conn.exec <<-SQL
|
||||||
GRANT ALL ON TABLE public.videos TO current_user;
|
GRANT ALL ON TABLE public.videos TO current_user;
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
conn.exec <<-SQL
|
conn.exec <<-SQL
|
||||||
CREATE UNIQUE INDEX IF NOT EXISTS id_idx
|
CREATE UNIQUE INDEX IF NOT EXISTS id_idx
|
||||||
ON public.videos
|
ON public.videos
|
||||||
USING btree
|
USING btree
|
||||||
(id COLLATE pg_catalog."default");
|
(id COLLATE pg_catalog."default");
|
||||||
SQL
|
SQL
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -4,32 +4,32 @@ module Invidious::Database::Migrations
|
|||||||
|
|
||||||
def up(conn : DB::Connection)
|
def up(conn : DB::Connection)
|
||||||
conn.exec <<-SQL
|
conn.exec <<-SQL
|
||||||
CREATE TABLE IF NOT EXISTS public.channel_videos
|
CREATE TABLE IF NOT EXISTS public.channel_videos
|
||||||
(
|
(
|
||||||
id text NOT NULL,
|
id text NOT NULL,
|
||||||
title text,
|
title text,
|
||||||
published timestamp with time zone,
|
published timestamp with time zone,
|
||||||
updated timestamp with time zone,
|
updated timestamp with time zone,
|
||||||
ucid text,
|
ucid text,
|
||||||
author text,
|
author text,
|
||||||
length_seconds integer,
|
length_seconds integer,
|
||||||
live_now boolean,
|
live_now boolean,
|
||||||
premiere_timestamp timestamp with time zone,
|
premiere_timestamp timestamp with time zone,
|
||||||
views bigint,
|
views bigint,
|
||||||
CONSTRAINT channel_videos_id_key UNIQUE (id)
|
CONSTRAINT channel_videos_id_key UNIQUE (id)
|
||||||
);
|
);
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
conn.exec <<-SQL
|
conn.exec <<-SQL
|
||||||
GRANT ALL ON TABLE public.channel_videos TO current_user;
|
GRANT ALL ON TABLE public.channel_videos TO current_user;
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
conn.exec <<-SQL
|
conn.exec <<-SQL
|
||||||
CREATE INDEX IF NOT EXISTS channel_videos_ucid_idx
|
CREATE INDEX IF NOT EXISTS channel_videos_ucid_idx
|
||||||
ON public.channel_videos
|
ON public.channel_videos
|
||||||
USING btree
|
USING btree
|
||||||
(ucid COLLATE pg_catalog."default");
|
(ucid COLLATE pg_catalog."default");
|
||||||
SQL
|
SQL
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -4,31 +4,31 @@ module Invidious::Database::Migrations
|
|||||||
|
|
||||||
def up(conn : DB::Connection)
|
def up(conn : DB::Connection)
|
||||||
conn.exec <<-SQL
|
conn.exec <<-SQL
|
||||||
CREATE TABLE IF NOT EXISTS public.users
|
CREATE TABLE IF NOT EXISTS public.users
|
||||||
(
|
(
|
||||||
updated timestamp with time zone,
|
updated timestamp with time zone,
|
||||||
notifications text[],
|
notifications text[],
|
||||||
subscriptions text[],
|
subscriptions text[],
|
||||||
email text NOT NULL,
|
email text NOT NULL,
|
||||||
preferences text,
|
preferences text,
|
||||||
password text,
|
password text,
|
||||||
token text,
|
token text,
|
||||||
watched text[],
|
watched text[],
|
||||||
feed_needs_update boolean,
|
feed_needs_update boolean,
|
||||||
CONSTRAINT users_email_key UNIQUE (email)
|
CONSTRAINT users_email_key UNIQUE (email)
|
||||||
);
|
);
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
conn.exec <<-SQL
|
conn.exec <<-SQL
|
||||||
GRANT ALL ON TABLE public.users TO current_user;
|
GRANT ALL ON TABLE public.users TO current_user;
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
conn.exec <<-SQL
|
conn.exec <<-SQL
|
||||||
CREATE UNIQUE INDEX IF NOT EXISTS email_unique_idx
|
CREATE UNIQUE INDEX IF NOT EXISTS email_unique_idx
|
||||||
ON public.users
|
ON public.users
|
||||||
USING btree
|
USING btree
|
||||||
(lower(email) COLLATE pg_catalog."default");
|
(lower(email) COLLATE pg_catalog."default");
|
||||||
SQL
|
SQL
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -4,25 +4,25 @@ module Invidious::Database::Migrations
|
|||||||
|
|
||||||
def up(conn : DB::Connection)
|
def up(conn : DB::Connection)
|
||||||
conn.exec <<-SQL
|
conn.exec <<-SQL
|
||||||
CREATE TABLE IF NOT EXISTS public.session_ids
|
CREATE TABLE IF NOT EXISTS public.session_ids
|
||||||
(
|
(
|
||||||
id text NOT NULL,
|
id text NOT NULL,
|
||||||
email text,
|
email text,
|
||||||
issued timestamp with time zone,
|
issued timestamp with time zone,
|
||||||
CONSTRAINT session_ids_pkey PRIMARY KEY (id)
|
CONSTRAINT session_ids_pkey PRIMARY KEY (id)
|
||||||
);
|
);
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
conn.exec <<-SQL
|
conn.exec <<-SQL
|
||||||
GRANT ALL ON TABLE public.session_ids TO current_user;
|
GRANT ALL ON TABLE public.session_ids TO current_user;
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
conn.exec <<-SQL
|
conn.exec <<-SQL
|
||||||
CREATE INDEX IF NOT EXISTS session_ids_id_idx
|
CREATE INDEX IF NOT EXISTS session_ids_id_idx
|
||||||
ON public.session_ids
|
ON public.session_ids
|
||||||
USING btree
|
USING btree
|
||||||
(id COLLATE pg_catalog."default");
|
(id COLLATE pg_catalog."default");
|
||||||
SQL
|
SQL
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -4,24 +4,24 @@ module Invidious::Database::Migrations
|
|||||||
|
|
||||||
def up(conn : DB::Connection)
|
def up(conn : DB::Connection)
|
||||||
conn.exec <<-SQL
|
conn.exec <<-SQL
|
||||||
CREATE TABLE IF NOT EXISTS public.nonces
|
CREATE TABLE IF NOT EXISTS public.nonces
|
||||||
(
|
(
|
||||||
nonce text,
|
nonce text,
|
||||||
expire timestamp with time zone,
|
expire timestamp with time zone,
|
||||||
CONSTRAINT nonces_id_key UNIQUE (nonce)
|
CONSTRAINT nonces_id_key UNIQUE (nonce)
|
||||||
);
|
);
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
conn.exec <<-SQL
|
conn.exec <<-SQL
|
||||||
GRANT ALL ON TABLE public.nonces TO current_user;
|
GRANT ALL ON TABLE public.nonces TO current_user;
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
conn.exec <<-SQL
|
conn.exec <<-SQL
|
||||||
CREATE INDEX IF NOT EXISTS nonces_nonce_idx
|
CREATE INDEX IF NOT EXISTS nonces_nonce_idx
|
||||||
ON public.nonces
|
ON public.nonces
|
||||||
USING btree
|
USING btree
|
||||||
(nonce COLLATE pg_catalog."default");
|
(nonce COLLATE pg_catalog."default");
|
||||||
SQL
|
SQL
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -4,17 +4,17 @@ module Invidious::Database::Migrations
|
|||||||
|
|
||||||
def up(conn : DB::Connection)
|
def up(conn : DB::Connection)
|
||||||
conn.exec <<-SQL
|
conn.exec <<-SQL
|
||||||
CREATE TABLE IF NOT EXISTS public.annotations
|
CREATE TABLE IF NOT EXISTS public.annotations
|
||||||
(
|
(
|
||||||
id text NOT NULL,
|
id text NOT NULL,
|
||||||
annotations xml,
|
annotations xml,
|
||||||
CONSTRAINT annotations_id_key UNIQUE (id)
|
CONSTRAINT annotations_id_key UNIQUE (id)
|
||||||
);
|
);
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
conn.exec <<-SQL
|
conn.exec <<-SQL
|
||||||
GRANT ALL ON TABLE public.annotations TO current_user;
|
GRANT ALL ON TABLE public.annotations TO current_user;
|
||||||
SQL
|
SQL
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -5,33 +5,33 @@ module Invidious::Database::Migrations
|
|||||||
def up(conn : DB::Connection)
|
def up(conn : DB::Connection)
|
||||||
if !privacy_type_exists?(conn)
|
if !privacy_type_exists?(conn)
|
||||||
conn.exec <<-SQL
|
conn.exec <<-SQL
|
||||||
CREATE TYPE public.privacy AS ENUM
|
CREATE TYPE public.privacy AS ENUM
|
||||||
(
|
(
|
||||||
'Public',
|
'Public',
|
||||||
'Unlisted',
|
'Unlisted',
|
||||||
'Private'
|
'Private'
|
||||||
);
|
);
|
||||||
SQL
|
SQL
|
||||||
end
|
end
|
||||||
|
|
||||||
conn.exec <<-SQL
|
conn.exec <<-SQL
|
||||||
CREATE TABLE IF NOT EXISTS public.playlists
|
CREATE TABLE IF NOT EXISTS public.playlists
|
||||||
(
|
(
|
||||||
title text,
|
title text,
|
||||||
id text primary key,
|
id text primary key,
|
||||||
author text,
|
author text,
|
||||||
description text,
|
description text,
|
||||||
video_count integer,
|
video_count integer,
|
||||||
created timestamptz,
|
created timestamptz,
|
||||||
updated timestamptz,
|
updated timestamptz,
|
||||||
privacy privacy,
|
privacy privacy,
|
||||||
index int8[]
|
index int8[]
|
||||||
);
|
);
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
conn.exec <<-SQL
|
conn.exec <<-SQL
|
||||||
GRANT ALL ON public.playlists TO current_user;
|
GRANT ALL ON public.playlists TO current_user;
|
||||||
SQL
|
SQL
|
||||||
end
|
end
|
||||||
|
|
||||||
private def privacy_type_exists?(conn : DB::Connection) : Bool
|
private def privacy_type_exists?(conn : DB::Connection) : Bool
|
||||||
@ -42,7 +42,7 @@ module Invidious::Database::Migrations
|
|||||||
WHERE pg_namespace.nspname = 'public'
|
WHERE pg_namespace.nspname = 'public'
|
||||||
AND pg_type.typname = 'privacy'
|
AND pg_type.typname = 'privacy'
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
!conn.query_one?(request, as: Int32).nil?
|
!conn.query_one?(request, as: Int32).nil?
|
||||||
end
|
end
|
||||||
|
|||||||
@ -4,24 +4,24 @@ module Invidious::Database::Migrations
|
|||||||
|
|
||||||
def up(conn : DB::Connection)
|
def up(conn : DB::Connection)
|
||||||
conn.exec <<-SQL
|
conn.exec <<-SQL
|
||||||
CREATE TABLE IF NOT EXISTS public.playlist_videos
|
CREATE TABLE IF NOT EXISTS public.playlist_videos
|
||||||
(
|
(
|
||||||
title text,
|
title text,
|
||||||
id text,
|
id text,
|
||||||
author text,
|
author text,
|
||||||
ucid text,
|
ucid text,
|
||||||
length_seconds integer,
|
length_seconds integer,
|
||||||
published timestamptz,
|
published timestamptz,
|
||||||
plid text references playlists(id),
|
plid text references playlists(id),
|
||||||
index int8,
|
index int8,
|
||||||
live_now boolean,
|
live_now boolean,
|
||||||
PRIMARY KEY (index,plid)
|
PRIMARY KEY (index,plid)
|
||||||
);
|
);
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
conn.exec <<-SQL
|
conn.exec <<-SQL
|
||||||
GRANT ALL ON TABLE public.playlist_videos TO current_user;
|
GRANT ALL ON TABLE public.playlist_videos TO current_user;
|
||||||
SQL
|
SQL
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -4,8 +4,8 @@ module Invidious::Database::Migrations
|
|||||||
|
|
||||||
def up(conn : DB::Connection)
|
def up(conn : DB::Connection)
|
||||||
conn.exec <<-SQL
|
conn.exec <<-SQL
|
||||||
ALTER TABLE public.videos SET UNLOGGED;
|
ALTER TABLE public.videos SET UNLOGGED;
|
||||||
SQL
|
SQL
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -44,6 +44,6 @@ class Invidious::Database::Migrator
|
|||||||
id bigserial PRIMARY KEY,
|
id bigserial PRIMARY KEY,
|
||||||
version bigint NOT NULL
|
version bigint NOT NULL
|
||||||
)
|
)
|
||||||
SQL
|
SQL
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -12,7 +12,7 @@ module Invidious::Database::Nonces
|
|||||||
INSERT INTO nonces
|
INSERT INTO nonces
|
||||||
VALUES ($1, $2)
|
VALUES ($1, $2)
|
||||||
ON CONFLICT DO NOTHING
|
ON CONFLICT DO NOTHING
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, nonce, expire)
|
PG_DB.exec(request, nonce, expire)
|
||||||
end
|
end
|
||||||
@ -21,7 +21,7 @@ module Invidious::Database::Nonces
|
|||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
DELETE FROM nonces *
|
DELETE FROM nonces *
|
||||||
WHERE expire < now()
|
WHERE expire < now()
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request)
|
PG_DB.exec(request)
|
||||||
end
|
end
|
||||||
@ -35,7 +35,7 @@ module Invidious::Database::Nonces
|
|||||||
UPDATE nonces
|
UPDATE nonces
|
||||||
SET expire = $1
|
SET expire = $1
|
||||||
WHERE nonce = $2
|
WHERE nonce = $2
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, Time.utc(1990, 1, 1), nonce)
|
PG_DB.exec(request, Time.utc(1990, 1, 1), nonce)
|
||||||
end
|
end
|
||||||
@ -48,7 +48,7 @@ module Invidious::Database::Nonces
|
|||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
SELECT * FROM nonces
|
SELECT * FROM nonces
|
||||||
WHERE nonce = $1
|
WHERE nonce = $1
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
return PG_DB.query_one?(request, nonce, as: {String, Time})
|
return PG_DB.query_one?(request, nonce, as: {String, Time})
|
||||||
end
|
end
|
||||||
|
|||||||
@ -16,7 +16,7 @@ module Invidious::Database::Playlists
|
|||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
INSERT INTO playlists
|
INSERT INTO playlists
|
||||||
VALUES (#{arg_array(playlist_array)})
|
VALUES (#{arg_array(playlist_array)})
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, args: playlist_array)
|
PG_DB.exec(request, args: playlist_array)
|
||||||
end
|
end
|
||||||
@ -27,7 +27,7 @@ module Invidious::Database::Playlists
|
|||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
DELETE FROM playlists *
|
DELETE FROM playlists *
|
||||||
WHERE id = $1
|
WHERE id = $1
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, id)
|
PG_DB.exec(request, id)
|
||||||
end
|
end
|
||||||
@ -41,7 +41,7 @@ module Invidious::Database::Playlists
|
|||||||
UPDATE playlists
|
UPDATE playlists
|
||||||
SET title = $1, privacy = $2, description = $3, updated = $4
|
SET title = $1, privacy = $2, description = $3, updated = $4
|
||||||
WHERE id = $5
|
WHERE id = $5
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, title, privacy, description, updated, id)
|
PG_DB.exec(request, title, privacy, description, updated, id)
|
||||||
end
|
end
|
||||||
@ -51,7 +51,7 @@ module Invidious::Database::Playlists
|
|||||||
UPDATE playlists
|
UPDATE playlists
|
||||||
SET description = $1
|
SET description = $1
|
||||||
WHERE id = $2
|
WHERE id = $2
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, description, id)
|
PG_DB.exec(request, description, id)
|
||||||
end
|
end
|
||||||
@ -61,7 +61,7 @@ module Invidious::Database::Playlists
|
|||||||
UPDATE playlists
|
UPDATE playlists
|
||||||
SET subscribed = now()
|
SET subscribed = now()
|
||||||
WHERE id = $1
|
WHERE id = $1
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, id)
|
PG_DB.exec(request, id)
|
||||||
end
|
end
|
||||||
@ -73,7 +73,7 @@ module Invidious::Database::Playlists
|
|||||||
video_count = cardinality(index) + 1,
|
video_count = cardinality(index) + 1,
|
||||||
updated = now()
|
updated = now()
|
||||||
WHERE id = $2
|
WHERE id = $2
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, index, id)
|
PG_DB.exec(request, index, id)
|
||||||
end
|
end
|
||||||
@ -85,7 +85,7 @@ module Invidious::Database::Playlists
|
|||||||
video_count = cardinality(index) - 1,
|
video_count = cardinality(index) - 1,
|
||||||
updated = now()
|
updated = now()
|
||||||
WHERE id = $2
|
WHERE id = $2
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, index, id)
|
PG_DB.exec(request, index, id)
|
||||||
end
|
end
|
||||||
@ -98,7 +98,7 @@ module Invidious::Database::Playlists
|
|||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
SELECT * FROM playlists
|
SELECT * FROM playlists
|
||||||
WHERE id = $1
|
WHERE id = $1
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
return PG_DB.query_one?(request, id, as: InvidiousPlaylist)
|
return PG_DB.query_one?(request, id, as: InvidiousPlaylist)
|
||||||
end
|
end
|
||||||
@ -107,7 +107,7 @@ module Invidious::Database::Playlists
|
|||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
SELECT * FROM playlists
|
SELECT * FROM playlists
|
||||||
WHERE author = $1
|
WHERE author = $1
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
return PG_DB.query_all(request, author, as: InvidiousPlaylist)
|
return PG_DB.query_all(request, author, as: InvidiousPlaylist)
|
||||||
end
|
end
|
||||||
@ -121,7 +121,7 @@ module Invidious::Database::Playlists
|
|||||||
SELECT * FROM playlists
|
SELECT * FROM playlists
|
||||||
WHERE author = $1 AND id LIKE 'IV%'
|
WHERE author = $1 AND id LIKE 'IV%'
|
||||||
ORDER BY created
|
ORDER BY created
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.query_all(request, email, as: InvidiousPlaylist)
|
PG_DB.query_all(request, email, as: InvidiousPlaylist)
|
||||||
end
|
end
|
||||||
@ -131,7 +131,7 @@ module Invidious::Database::Playlists
|
|||||||
SELECT * FROM playlists
|
SELECT * FROM playlists
|
||||||
WHERE author = $1 AND id NOT LIKE 'IV%'
|
WHERE author = $1 AND id NOT LIKE 'IV%'
|
||||||
ORDER BY created
|
ORDER BY created
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.query_all(request, email, as: InvidiousPlaylist)
|
PG_DB.query_all(request, email, as: InvidiousPlaylist)
|
||||||
end
|
end
|
||||||
@ -141,7 +141,7 @@ module Invidious::Database::Playlists
|
|||||||
SELECT id,title FROM playlists
|
SELECT id,title FROM playlists
|
||||||
WHERE author = $1 AND id LIKE 'IV%'
|
WHERE author = $1 AND id LIKE 'IV%'
|
||||||
ORDER BY title
|
ORDER BY title
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.query_all(request, email, as: {String, String})
|
PG_DB.query_all(request, email, as: {String, String})
|
||||||
end
|
end
|
||||||
@ -155,7 +155,7 @@ module Invidious::Database::Playlists
|
|||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
SELECT id FROM playlists
|
SELECT id FROM playlists
|
||||||
WHERE id = $1
|
WHERE id = $1
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
return PG_DB.query_one?(request, id, as: String).nil?
|
return PG_DB.query_one?(request, id, as: String).nil?
|
||||||
end
|
end
|
||||||
@ -165,7 +165,7 @@ module Invidious::Database::Playlists
|
|||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
SELECT count(*) FROM playlists
|
SELECT count(*) FROM playlists
|
||||||
WHERE author = $1
|
WHERE author = $1
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
return PG_DB.query_one?(request, author, as: Int64) || 0_i64
|
return PG_DB.query_one?(request, author, as: Int64) || 0_i64
|
||||||
end
|
end
|
||||||
@ -189,7 +189,7 @@ module Invidious::Database::PlaylistVideos
|
|||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
INSERT INTO playlist_videos
|
INSERT INTO playlist_videos
|
||||||
VALUES (#{arg_array(video_array)})
|
VALUES (#{arg_array(video_array)})
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, args: video_array)
|
PG_DB.exec(request, args: video_array)
|
||||||
end
|
end
|
||||||
@ -198,7 +198,7 @@ module Invidious::Database::PlaylistVideos
|
|||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
DELETE FROM playlist_videos *
|
DELETE FROM playlist_videos *
|
||||||
WHERE index = $1
|
WHERE index = $1
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, index)
|
PG_DB.exec(request, index)
|
||||||
end
|
end
|
||||||
@ -207,7 +207,7 @@ module Invidious::Database::PlaylistVideos
|
|||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
DELETE FROM playlist_videos *
|
DELETE FROM playlist_videos *
|
||||||
WHERE plid = $1
|
WHERE plid = $1
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, plid)
|
PG_DB.exec(request, plid)
|
||||||
end
|
end
|
||||||
@ -223,7 +223,7 @@ module Invidious::Database::PlaylistVideos
|
|||||||
ORDER BY array_position($2, index)
|
ORDER BY array_position($2, index)
|
||||||
LIMIT $3
|
LIMIT $3
|
||||||
OFFSET $4
|
OFFSET $4
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
return PG_DB.query_all(request, plid, index, limit, offset, as: PlaylistVideo)
|
return PG_DB.query_all(request, plid, index, limit, offset, as: PlaylistVideo)
|
||||||
end
|
end
|
||||||
@ -233,7 +233,7 @@ module Invidious::Database::PlaylistVideos
|
|||||||
SELECT index FROM playlist_videos
|
SELECT index FROM playlist_videos
|
||||||
WHERE plid = $1 AND id = $2
|
WHERE plid = $1 AND id = $2
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
return PG_DB.query_one?(request, plid, vid, as: Int64)
|
return PG_DB.query_one?(request, plid, vid, as: Int64)
|
||||||
end
|
end
|
||||||
@ -244,7 +244,7 @@ module Invidious::Database::PlaylistVideos
|
|||||||
WHERE plid = $1
|
WHERE plid = $1
|
||||||
ORDER BY array_position($2, index)
|
ORDER BY array_position($2, index)
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
return PG_DB.query_one?(request, plid, index, as: String)
|
return PG_DB.query_one?(request, plid, index, as: String)
|
||||||
end
|
end
|
||||||
@ -255,7 +255,7 @@ module Invidious::Database::PlaylistVideos
|
|||||||
WHERE plid = $1
|
WHERE plid = $1
|
||||||
ORDER BY array_position($2, index)
|
ORDER BY array_position($2, index)
|
||||||
LIMIT $3
|
LIMIT $3
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
return PG_DB.query_all(request, plid, index, limit, as: String)
|
return PG_DB.query_all(request, plid, index, limit, as: String)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -11,7 +11,7 @@ module Invidious::Database::SessionIDs
|
|||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
INSERT INTO session_ids
|
INSERT INTO session_ids
|
||||||
VALUES ($1, $2, now())
|
VALUES ($1, $2, now())
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
request += " ON CONFLICT (id) DO NOTHING" if handle_conflicts
|
request += " ON CONFLICT (id) DO NOTHING" if handle_conflicts
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ module Invidious::Database::SessionIDs
|
|||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
DELETE FROM session_ids *
|
DELETE FROM session_ids *
|
||||||
WHERE id = $1
|
WHERE id = $1
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, sid)
|
PG_DB.exec(request, sid)
|
||||||
end
|
end
|
||||||
@ -35,7 +35,7 @@ module Invidious::Database::SessionIDs
|
|||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
DELETE FROM session_ids *
|
DELETE FROM session_ids *
|
||||||
WHERE email = $1
|
WHERE email = $1
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, email)
|
PG_DB.exec(request, email)
|
||||||
end
|
end
|
||||||
@ -44,7 +44,7 @@ module Invidious::Database::SessionIDs
|
|||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
DELETE FROM session_ids *
|
DELETE FROM session_ids *
|
||||||
WHERE id = $1 AND email = $2
|
WHERE id = $1 AND email = $2
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, sid, email)
|
PG_DB.exec(request, sid, email)
|
||||||
end
|
end
|
||||||
@ -57,7 +57,7 @@ module Invidious::Database::SessionIDs
|
|||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
SELECT email FROM session_ids
|
SELECT email FROM session_ids
|
||||||
WHERE id = $1
|
WHERE id = $1
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.query_one?(request, sid, as: String)
|
PG_DB.query_one?(request, sid, as: String)
|
||||||
end
|
end
|
||||||
@ -67,7 +67,7 @@ module Invidious::Database::SessionIDs
|
|||||||
SELECT id, issued FROM session_ids
|
SELECT id, issued FROM session_ids
|
||||||
WHERE email = $1
|
WHERE email = $1
|
||||||
ORDER BY issued DESC
|
ORDER BY issued DESC
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.query_all(request, email, as: {session: String, issued: Time})
|
PG_DB.query_all(request, email, as: {session: String, issued: Time})
|
||||||
end
|
end
|
||||||
|
|||||||
@ -10,7 +10,7 @@ module Invidious::Database::Statistics
|
|||||||
def count_users_total : Int64
|
def count_users_total : Int64
|
||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
SELECT count(*) FROM users
|
SELECT count(*) FROM users
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.query_one(request, as: Int64)
|
PG_DB.query_one(request, as: Int64)
|
||||||
end
|
end
|
||||||
@ -19,7 +19,7 @@ module Invidious::Database::Statistics
|
|||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
SELECT count(*) FROM users
|
SELECT count(*) FROM users
|
||||||
WHERE CURRENT_TIMESTAMP - updated < '6 months'
|
WHERE CURRENT_TIMESTAMP - updated < '6 months'
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.query_one(request, as: Int64)
|
PG_DB.query_one(request, as: Int64)
|
||||||
end
|
end
|
||||||
@ -28,7 +28,7 @@ module Invidious::Database::Statistics
|
|||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
SELECT count(*) FROM users
|
SELECT count(*) FROM users
|
||||||
WHERE CURRENT_TIMESTAMP - updated < '1 month'
|
WHERE CURRENT_TIMESTAMP - updated < '1 month'
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.query_one(request, as: Int64)
|
PG_DB.query_one(request, as: Int64)
|
||||||
end
|
end
|
||||||
@ -42,7 +42,7 @@ module Invidious::Database::Statistics
|
|||||||
SELECT updated FROM channels
|
SELECT updated FROM channels
|
||||||
ORDER BY updated DESC
|
ORDER BY updated DESC
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.query_one?(request, as: Time)
|
PG_DB.query_one?(request, as: Time)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -14,13 +14,13 @@ module Invidious::Database::Users
|
|||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
INSERT INTO users
|
INSERT INTO users
|
||||||
VALUES (#{arg_array(user_array)})
|
VALUES (#{arg_array(user_array)})
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
if update_on_conflict
|
if update_on_conflict
|
||||||
request += <<-SQL
|
request += <<-SQL
|
||||||
ON CONFLICT (email) DO UPDATE
|
ON CONFLICT (email) DO UPDATE
|
||||||
SET updated = $1, subscriptions = $3
|
SET updated = $1, subscriptions = $3
|
||||||
SQL
|
SQL
|
||||||
end
|
end
|
||||||
|
|
||||||
PG_DB.exec(request, args: user_array)
|
PG_DB.exec(request, args: user_array)
|
||||||
@ -30,7 +30,7 @@ module Invidious::Database::Users
|
|||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
DELETE FROM users *
|
DELETE FROM users *
|
||||||
WHERE email = $1
|
WHERE email = $1
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, user.email)
|
PG_DB.exec(request, user.email)
|
||||||
end
|
end
|
||||||
@ -44,7 +44,7 @@ module Invidious::Database::Users
|
|||||||
UPDATE users
|
UPDATE users
|
||||||
SET watched = $1
|
SET watched = $1
|
||||||
WHERE email = $2
|
WHERE email = $2
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, user.watched, user.email)
|
PG_DB.exec(request, user.watched, user.email)
|
||||||
end
|
end
|
||||||
@ -54,7 +54,7 @@ module Invidious::Database::Users
|
|||||||
UPDATE users
|
UPDATE users
|
||||||
SET watched = array_append(array_remove(watched, $1), $1)
|
SET watched = array_append(array_remove(watched, $1), $1)
|
||||||
WHERE email = $2
|
WHERE email = $2
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, vid, user.email)
|
PG_DB.exec(request, vid, user.email)
|
||||||
end
|
end
|
||||||
@ -64,7 +64,7 @@ module Invidious::Database::Users
|
|||||||
UPDATE users
|
UPDATE users
|
||||||
SET watched = array_remove(watched, $1)
|
SET watched = array_remove(watched, $1)
|
||||||
WHERE email = $2
|
WHERE email = $2
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, vid, user.email)
|
PG_DB.exec(request, vid, user.email)
|
||||||
end
|
end
|
||||||
@ -74,7 +74,7 @@ module Invidious::Database::Users
|
|||||||
UPDATE users
|
UPDATE users
|
||||||
SET watched = '{}'
|
SET watched = '{}'
|
||||||
WHERE email = $1
|
WHERE email = $1
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, user.email)
|
PG_DB.exec(request, user.email)
|
||||||
end
|
end
|
||||||
@ -88,7 +88,7 @@ module Invidious::Database::Users
|
|||||||
UPDATE users
|
UPDATE users
|
||||||
SET feed_needs_update = true, subscriptions = $1
|
SET feed_needs_update = true, subscriptions = $1
|
||||||
WHERE email = $2
|
WHERE email = $2
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, user.subscriptions, user.email)
|
PG_DB.exec(request, user.subscriptions, user.email)
|
||||||
end
|
end
|
||||||
@ -99,7 +99,7 @@ module Invidious::Database::Users
|
|||||||
SET feed_needs_update = true,
|
SET feed_needs_update = true,
|
||||||
subscriptions = array_append(subscriptions,$1)
|
subscriptions = array_append(subscriptions,$1)
|
||||||
WHERE email = $2
|
WHERE email = $2
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, ucid, user.email)
|
PG_DB.exec(request, ucid, user.email)
|
||||||
end
|
end
|
||||||
@ -110,7 +110,7 @@ module Invidious::Database::Users
|
|||||||
SET feed_needs_update = true,
|
SET feed_needs_update = true,
|
||||||
subscriptions = array_remove(subscriptions, $1)
|
subscriptions = array_remove(subscriptions, $1)
|
||||||
WHERE email = $2
|
WHERE email = $2
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, ucid, user.email)
|
PG_DB.exec(request, ucid, user.email)
|
||||||
end
|
end
|
||||||
@ -125,7 +125,7 @@ module Invidious::Database::Users
|
|||||||
SET notifications = array_cat(notifications, $1),
|
SET notifications = array_cat(notifications, $1),
|
||||||
feed_needs_update = true
|
feed_needs_update = true
|
||||||
WHERE $2 = ANY(subscriptions)
|
WHERE $2 = ANY(subscriptions)
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, video_ids, channel_id)
|
PG_DB.exec(request, video_ids, channel_id)
|
||||||
end
|
end
|
||||||
@ -135,7 +135,7 @@ module Invidious::Database::Users
|
|||||||
UPDATE users
|
UPDATE users
|
||||||
SET notifications = array_remove(notifications, $1)
|
SET notifications = array_remove(notifications, $1)
|
||||||
WHERE email = $2
|
WHERE email = $2
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, vid, user.email)
|
PG_DB.exec(request, vid, user.email)
|
||||||
end
|
end
|
||||||
@ -145,7 +145,7 @@ module Invidious::Database::Users
|
|||||||
UPDATE users
|
UPDATE users
|
||||||
SET notifications = '{}', updated = now()
|
SET notifications = '{}', updated = now()
|
||||||
WHERE email = $1
|
WHERE email = $1
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, user.email)
|
PG_DB.exec(request, user.email)
|
||||||
end
|
end
|
||||||
@ -159,7 +159,7 @@ module Invidious::Database::Users
|
|||||||
UPDATE users
|
UPDATE users
|
||||||
SET feed_needs_update = true
|
SET feed_needs_update = true
|
||||||
WHERE $1 = ANY(subscriptions)
|
WHERE $1 = ANY(subscriptions)
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, channel_id)
|
PG_DB.exec(request, channel_id)
|
||||||
end
|
end
|
||||||
@ -169,7 +169,7 @@ module Invidious::Database::Users
|
|||||||
UPDATE users
|
UPDATE users
|
||||||
SET preferences = $1
|
SET preferences = $1
|
||||||
WHERE email = $2
|
WHERE email = $2
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, user.preferences.to_json, user.email)
|
PG_DB.exec(request, user.preferences.to_json, user.email)
|
||||||
end
|
end
|
||||||
@ -179,7 +179,7 @@ module Invidious::Database::Users
|
|||||||
UPDATE users
|
UPDATE users
|
||||||
SET password = $1
|
SET password = $1
|
||||||
WHERE email = $2
|
WHERE email = $2
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, pass, user.email)
|
PG_DB.exec(request, pass, user.email)
|
||||||
end
|
end
|
||||||
@ -192,7 +192,7 @@ module Invidious::Database::Users
|
|||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
SELECT * FROM users
|
SELECT * FROM users
|
||||||
WHERE email = $1
|
WHERE email = $1
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
return PG_DB.query_one?(request, email, as: User)
|
return PG_DB.query_one?(request, email, as: User)
|
||||||
end
|
end
|
||||||
@ -202,7 +202,7 @@ module Invidious::Database::Users
|
|||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
SELECT * FROM users
|
SELECT * FROM users
|
||||||
WHERE email = $1
|
WHERE email = $1
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
return PG_DB.query_one(request, email, as: User)
|
return PG_DB.query_one(request, email, as: User)
|
||||||
end
|
end
|
||||||
@ -211,7 +211,7 @@ module Invidious::Database::Users
|
|||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
SELECT * FROM users
|
SELECT * FROM users
|
||||||
WHERE token = $1
|
WHERE token = $1
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
return PG_DB.query_one?(request, token, as: User)
|
return PG_DB.query_one?(request, token, as: User)
|
||||||
end
|
end
|
||||||
@ -221,7 +221,7 @@ module Invidious::Database::Users
|
|||||||
SELECT notifications
|
SELECT notifications
|
||||||
FROM users
|
FROM users
|
||||||
WHERE email = $1
|
WHERE email = $1
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
return PG_DB.query_one(request, user.email, as: Array(String))
|
return PG_DB.query_one(request, user.email, as: Array(String))
|
||||||
end
|
end
|
||||||
|
|||||||
@ -8,7 +8,7 @@ module Invidious::Database::Videos
|
|||||||
INSERT INTO videos
|
INSERT INTO videos
|
||||||
VALUES ($1, $2, $3)
|
VALUES ($1, $2, $3)
|
||||||
ON CONFLICT (id) DO NOTHING
|
ON CONFLICT (id) DO NOTHING
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, video.id, video.info.to_json, video.updated)
|
PG_DB.exec(request, video.id, video.info.to_json, video.updated)
|
||||||
end
|
end
|
||||||
@ -17,7 +17,7 @@ module Invidious::Database::Videos
|
|||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
DELETE FROM videos *
|
DELETE FROM videos *
|
||||||
WHERE id = $1
|
WHERE id = $1
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, id)
|
PG_DB.exec(request, id)
|
||||||
end
|
end
|
||||||
@ -26,7 +26,7 @@ module Invidious::Database::Videos
|
|||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
DELETE FROM videos *
|
DELETE FROM videos *
|
||||||
WHERE updated < (now() - interval '6 hours')
|
WHERE updated < (now() - interval '6 hours')
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request)
|
PG_DB.exec(request)
|
||||||
end
|
end
|
||||||
@ -36,7 +36,7 @@ module Invidious::Database::Videos
|
|||||||
UPDATE videos
|
UPDATE videos
|
||||||
SET (id, info, updated) = ($1, $2, $3)
|
SET (id, info, updated) = ($1, $2, $3)
|
||||||
WHERE id = $1
|
WHERE id = $1
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, video.id, video.info.to_json, video.updated)
|
PG_DB.exec(request, video.id, video.info.to_json, video.updated)
|
||||||
end
|
end
|
||||||
@ -45,7 +45,7 @@ module Invidious::Database::Videos
|
|||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
SELECT * FROM videos
|
SELECT * FROM videos
|
||||||
WHERE id = $1
|
WHERE id = $1
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
return PG_DB.query_one?(request, id, as: Video)
|
return PG_DB.query_one?(request, id, as: Video)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -16,33 +16,33 @@ module Invidious::Frontend::Comments
|
|||||||
|
|
||||||
if child.depth > 0
|
if child.depth > 0
|
||||||
html << <<-END_HTML
|
html << <<-END_HTML
|
||||||
<div class="pure-g">
|
<div class="pure-g">
|
||||||
<div class="pure-u-1-24">
|
<div class="pure-u-1-24">
|
||||||
</div>
|
</div>
|
||||||
<div class="pure-u-23-24">
|
<div class="pure-u-23-24">
|
||||||
END_HTML
|
END_HTML
|
||||||
else
|
else
|
||||||
html << <<-END_HTML
|
html << <<-END_HTML
|
||||||
<div class="pure-g">
|
<div class="pure-g">
|
||||||
<div class="pure-u-1">
|
<div class="pure-u-1">
|
||||||
END_HTML
|
END_HTML
|
||||||
end
|
end
|
||||||
|
|
||||||
html << <<-END_HTML
|
html << <<-END_HTML
|
||||||
<p>
|
<p>
|
||||||
<a href="javascript:void(0)" data-onclick="toggle_parent">[ − ]</a>
|
<a href="javascript:void(0)" data-onclick="toggle_parent">[ − ]</a>
|
||||||
<b><a href="https://www.reddit.com/user/#{child.author}">#{child.author}</a></b>
|
<b><a href="https://www.reddit.com/user/#{child.author}">#{child.author}</a></b>
|
||||||
#{translate_count(locale, "comments_points_count", child.score, NumberFormatting::Separator)}
|
#{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>
|
<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>
|
<a href="https://www.reddit.com#{child.permalink}" title="#{translate(locale, "permalink")}">#{translate(locale, "permalink")}</a>
|
||||||
</p>
|
</p>
|
||||||
<div>
|
<div>
|
||||||
#{body_html}
|
#{body_html}
|
||||||
#{replies_html}
|
#{replies_html}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
END_HTML
|
END_HTML
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -13,16 +13,16 @@ module Invidious::Frontend::Comments
|
|||||||
)
|
)
|
||||||
|
|
||||||
replies_html = <<-END_HTML
|
replies_html = <<-END_HTML
|
||||||
<div id="replies" class="pure-g">
|
<div id="replies" class="pure-g">
|
||||||
<div class="pure-u-1-24"></div>
|
<div class="pure-u-1-24"></div>
|
||||||
<div class="pure-u-23-24">
|
<div class="pure-u-23-24">
|
||||||
<p>
|
<p>
|
||||||
<a href="javascript:void(0)" data-continuation="#{child["replies"]["continuation"]}"
|
<a href="javascript:void(0)" data-continuation="#{child["replies"]["continuation"]}"
|
||||||
data-onclick="get_youtube_replies" data-load-replies>#{replies_count_text}</a>
|
data-onclick="get_youtube_replies" data-load-replies>#{replies_count_text}</a>
|
||||||
</p>
|
</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
END_HTML
|
||||||
END_HTML
|
|
||||||
elsif comments["authorId"]? && !comments["singlePost"]?
|
elsif comments["authorId"]? && !comments["singlePost"]?
|
||||||
# for posts we should display a link to the post
|
# for posts we should display a link to the post
|
||||||
replies_count_text = translate_count(locale,
|
replies_count_text = translate_count(locale,
|
||||||
@ -32,15 +32,15 @@ module Invidious::Frontend::Comments
|
|||||||
)
|
)
|
||||||
|
|
||||||
replies_html = <<-END_HTML
|
replies_html = <<-END_HTML
|
||||||
<div class="pure-g">
|
<div class="pure-g">
|
||||||
<div class="pure-u-1-24"></div>
|
<div class="pure-u-1-24"></div>
|
||||||
<div class="pure-u-23-24">
|
<div class="pure-u-23-24">
|
||||||
<p>
|
<p>
|
||||||
<a href="/post/#{child["commentId"]}?ucid=#{comments["authorId"]}">#{replies_count_text}</a>
|
<a href="/post/#{child["commentId"]}?ucid=#{comments["authorId"]}">#{replies_count_text}</a>
|
||||||
</p>
|
</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
END_HTML
|
||||||
END_HTML
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if !thin_mode
|
if !thin_mode
|
||||||
@ -66,18 +66,18 @@ module Invidious::Frontend::Comments
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
html << <<-END_HTML
|
html << <<-END_HTML
|
||||||
<div class="pure-g" style="width:100%">
|
<div class="pure-g" style="width:100%">
|
||||||
<div class="channel-profile pure-u-4-24 pure-u-md-2-24">
|
<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="" />
|
<img loading="lazy" style="margin-right:1em;margin-top:1em;width:90%" src="#{author_thumbnail}" alt="" />
|
||||||
</div>
|
</div>
|
||||||
<div class="pure-u-20-24 pure-u-md-22-24">
|
<div class="pure-u-20-24 pure-u-md-22-24">
|
||||||
<p>
|
<p>
|
||||||
<b>
|
<b>
|
||||||
<a class="#{child["authorIsChannelOwner"] == true ? "channel-owner" : ""}" href="#{child["authorUrl"]}">#{author_name}</a>
|
<a class="#{child["authorIsChannelOwner"] == true ? "channel-owner" : ""}" href="#{child["authorUrl"]}">#{author_name}</a>
|
||||||
</b>
|
</b>
|
||||||
#{sponsor_icon}
|
#{sponsor_icon}
|
||||||
<p style="white-space:pre-wrap">#{child["contentHtml"]}</p>
|
<p style="white-space:pre-wrap">#{child["contentHtml"]}</p>
|
||||||
END_HTML
|
END_HTML
|
||||||
|
|
||||||
if child["attachment"]?
|
if child["attachment"]?
|
||||||
attachment = child["attachment"]
|
attachment = child["attachment"]
|
||||||
@ -87,25 +87,25 @@ module Invidious::Frontend::Comments
|
|||||||
attachment = attachment["imageThumbnails"][1]
|
attachment = attachment["imageThumbnails"][1]
|
||||||
|
|
||||||
html << <<-END_HTML
|
html << <<-END_HTML
|
||||||
<div class="pure-g">
|
<div class="pure-g">
|
||||||
<div class="pure-u-1 pure-u-md-1-2">
|
<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="" />
|
<img loading="lazy" style="width:100%" src="/ggpht#{URI.parse(attachment["url"].as_s).request_target}" alt="" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
END_HTML
|
||||||
END_HTML
|
|
||||||
when "video"
|
when "video"
|
||||||
if attachment["error"]?
|
if attachment["error"]?
|
||||||
html << <<-END_HTML
|
html << <<-END_HTML
|
||||||
<div class="pure-g video-iframe-wrapper">
|
<div class="pure-g video-iframe-wrapper">
|
||||||
<p>#{attachment["error"]}</p>
|
<p>#{attachment["error"]}</p>
|
||||||
</div>
|
</div>
|
||||||
END_HTML
|
END_HTML
|
||||||
else
|
else
|
||||||
html << <<-END_HTML
|
html << <<-END_HTML
|
||||||
<div class="pure-g video-iframe-wrapper">
|
<div class="pure-g video-iframe-wrapper">
|
||||||
<iframe class="video-iframe" src='/embed/#{attachment["videoId"]?}?autoplay=0'></iframe>
|
<iframe class="video-iframe" src='/embed/#{attachment["videoId"]?}?autoplay=0'></iframe>
|
||||||
</div>
|
</div>
|
||||||
END_HTML
|
END_HTML
|
||||||
end
|
end
|
||||||
when "multiImage"
|
when "multiImage"
|
||||||
html << <<-END_HTML
|
html << <<-END_HTML
|
||||||
@ -133,35 +133,35 @@ module Invidious::Frontend::Comments
|
|||||||
END_HTML
|
END_HTML
|
||||||
end
|
end
|
||||||
html << <<-END_HTML
|
html << <<-END_HTML
|
||||||
</div>
|
</div>
|
||||||
<div id="skip-#{child["commentId"]}"></div>
|
<div id="skip-#{child["commentId"]}"></div>
|
||||||
</section>
|
</section>
|
||||||
END_HTML
|
END_HTML
|
||||||
else nil # Ignore
|
else nil # Ignore
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
html << <<-END_HTML
|
html << <<-END_HTML
|
||||||
<p>
|
<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>
|
<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
|
END_HTML
|
||||||
|
|
||||||
if comments["videoId"]?
|
if comments["videoId"]?
|
||||||
html << <<-END_HTML
|
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>
|
<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"]?
|
elsif comments["authorId"]?
|
||||||
html << <<-END_HTML
|
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>
|
<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
|
end
|
||||||
|
|
||||||
html << <<-END_HTML
|
html << <<-END_HTML
|
||||||
<i class="icon ion-ios-thumbs-up"></i> #{number_with_separator(child["likeCount"])}
|
<i class="icon ion-ios-thumbs-up"></i> #{number_with_separator(child["likeCount"])}
|
||||||
END_HTML
|
END_HTML
|
||||||
|
|
||||||
if child["creatorHeart"]?
|
if child["creatorHeart"]?
|
||||||
if !thin_mode
|
if !thin_mode
|
||||||
@ -180,28 +180,28 @@ module Invidious::Frontend::Comments
|
|||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
END_HTML
|
END_HTML
|
||||||
end
|
end
|
||||||
|
|
||||||
html << <<-END_HTML
|
html << <<-END_HTML
|
||||||
</p>
|
</p>
|
||||||
#{replies_html}
|
#{replies_html}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
END_HTML
|
||||||
END_HTML
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if comments["continuation"]?
|
if comments["continuation"]?
|
||||||
html << <<-END_HTML
|
html << <<-END_HTML
|
||||||
<div class="pure-g">
|
<div class="pure-g">
|
||||||
<div class="pure-u-1">
|
<div class="pure-u-1">
|
||||||
<p>
|
<p>
|
||||||
<a href="javascript:void(0)" data-continuation="#{comments["continuation"]}"
|
<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>
|
data-onclick="get_youtube_replies" data-load-more #{"data-load-replies" if is_replies}>#{translate(locale, "Load more")}</a>
|
||||||
</p>
|
</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
END_HTML
|
||||||
END_HTML
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -22,12 +22,12 @@ def get_issue_template(env : HTTP::Server::Context, exception : Exception) : Tup
|
|||||||
issue_title = "#{exception.message} (#{exception.class})"
|
issue_title = "#{exception.message} (#{exception.class})"
|
||||||
|
|
||||||
issue_template = <<-TEXT
|
issue_template = <<-TEXT
|
||||||
Title: `#{HTML.escape(issue_title)}`
|
Title: `#{HTML.escape(issue_title)}`
|
||||||
Date: `#{Time::Format::ISO_8601_DATE_TIME.format(Time.utc)}`
|
Date: `#{Time::Format::ISO_8601_DATE_TIME.format(Time.utc)}`
|
||||||
Route: `#{HTML.escape(env.request.resource)}`
|
Route: `#{HTML.escape(env.request.resource)}`
|
||||||
Version: `#{SOFTWARE["version"]} @ #{SOFTWARE["branch"]}`
|
Version: `#{SOFTWARE["version"]} @ #{SOFTWARE["branch"]}`
|
||||||
|
|
||||||
TEXT
|
TEXT
|
||||||
|
|
||||||
issue_template += github_details("Backtrace", exception.inspect_with_backtrace)
|
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 -->
|
<!-- TODO: Add a "copy to clipboard" button -->
|
||||||
<pre class="error-issue-template">#{issue_template}</pre>
|
<pre class="error-issue-template">#{issue_template}</pre>
|
||||||
</div>
|
</div>
|
||||||
END_HTML
|
END_HTML
|
||||||
|
|
||||||
# Don't show the usual "next steps" widget. The same options are
|
# Don't show the usual "next steps" widget. The same options are
|
||||||
# proposed above the error message, just worded differently.
|
# 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>
|
<a rel="noreferrer noopener" href="https://youtube.com#{env.request.resource}">#{go_to_youtube}</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
END_HTML
|
END_HTML
|
||||||
else
|
else
|
||||||
return ""
|
return ""
|
||||||
end
|
end
|
||||||
|
|||||||
@ -83,14 +83,14 @@ end
|
|||||||
|
|
||||||
def template_mix(mix, listen)
|
def template_mix(mix, listen)
|
||||||
html = <<-END_HTML
|
html = <<-END_HTML
|
||||||
<h3>
|
<h3>
|
||||||
<a href="/mix?list=#{mix["mixId"]}">
|
<a href="/mix?list=#{mix["mixId"]}">
|
||||||
#{mix["title"]}
|
#{mix["title"]}
|
||||||
</a>
|
</a>
|
||||||
</h3>
|
</h3>
|
||||||
<div class="pure-menu pure-menu-scrollable playlist-restricted">
|
<div class="pure-menu pure-menu-scrollable playlist-restricted">
|
||||||
<ol class="pure-menu-list">
|
<ol class="pure-menu-list">
|
||||||
END_HTML
|
END_HTML
|
||||||
|
|
||||||
mix["videos"].as_a.each do |video|
|
mix["videos"].as_a.each do |video|
|
||||||
html += <<-END_HTML
|
html += <<-END_HTML
|
||||||
@ -106,14 +106,14 @@ def template_mix(mix, listen)
|
|||||||
</p>
|
</p>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
END_HTML
|
END_HTML
|
||||||
end
|
end
|
||||||
|
|
||||||
html += <<-END_HTML
|
html += <<-END_HTML
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
END_HTML
|
END_HTML
|
||||||
|
|
||||||
html
|
html
|
||||||
end
|
end
|
||||||
|
|||||||
@ -509,14 +509,14 @@ end
|
|||||||
|
|
||||||
def template_playlist(playlist, listen)
|
def template_playlist(playlist, listen)
|
||||||
html = <<-END_HTML
|
html = <<-END_HTML
|
||||||
<h3>
|
<h3>
|
||||||
<a href="/playlist?list=#{playlist["playlistId"]}">
|
<a href="/playlist?list=#{playlist["playlistId"]}">
|
||||||
#{playlist["title"]}
|
#{playlist["title"]}
|
||||||
</a>
|
</a>
|
||||||
</h3>
|
</h3>
|
||||||
<div class="pure-menu pure-menu-scrollable playlist-restricted">
|
<div class="pure-menu pure-menu-scrollable playlist-restricted">
|
||||||
<ol class="pure-menu-list">
|
<ol class="pure-menu-list">
|
||||||
END_HTML
|
END_HTML
|
||||||
|
|
||||||
playlist["videos"].as_a.each do |video|
|
playlist["videos"].as_a.each do |video|
|
||||||
html += <<-END_HTML
|
html += <<-END_HTML
|
||||||
@ -532,14 +532,14 @@ def template_playlist(playlist, listen)
|
|||||||
</p>
|
</p>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
END_HTML
|
END_HTML
|
||||||
end
|
end
|
||||||
|
|
||||||
html += <<-END_HTML
|
html += <<-END_HTML
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
END_HTML
|
END_HTML
|
||||||
|
|
||||||
html
|
html
|
||||||
end
|
end
|
||||||
|
|||||||
@ -20,28 +20,28 @@ struct Invidious::User
|
|||||||
end
|
end
|
||||||
|
|
||||||
clock_svg = <<-END_SVG
|
clock_svg = <<-END_SVG
|
||||||
<svg viewBox="0 0 100 100" width="200px" height="200px">
|
<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>
|
<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="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="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="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="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="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="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="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="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="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="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="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="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>
|
<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="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="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>
|
<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>
|
</svg>
|
||||||
END_SVG
|
END_SVG
|
||||||
|
|
||||||
image = "data:image/png;base64,"
|
image = "data:image/png;base64,"
|
||||||
image += Process.run(%(rsvg-convert -w 400 -h 400 -b none -f png), shell: true,
|
image += Process.run(%(rsvg-convert -w 400 -h 400 -b none -f png), shell: true,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user