mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-03-16.git
synced 2024-08-15 00:53:18 +00:00
commit
1f7f013e0a
7 changed files with 47 additions and 50 deletions
|
@ -311,12 +311,12 @@ before_all do |env|
|
||||||
env.set "current_page", URI.encode_www_form(current_page)
|
env.set "current_page", URI.encode_www_form(current_page)
|
||||||
end
|
end
|
||||||
|
|
||||||
Invidious::Routing.get "/", Invidious::Routes::Home
|
Invidious::Routing.get "/", Invidious::Routes::Misc, :home
|
||||||
Invidious::Routing.get "/privacy", Invidious::Routes::Privacy
|
Invidious::Routing.get "/privacy", Invidious::Routes::Misc, :privacy
|
||||||
Invidious::Routing.get "/licenses", Invidious::Routes::Licenses
|
Invidious::Routing.get "/licenses", Invidious::Routes::Misc, :licenses
|
||||||
Invidious::Routing.get "/watch", Invidious::Routes::Watch
|
Invidious::Routing.get "/watch", Invidious::Routes::Watch
|
||||||
Invidious::Routing.get "/embed/", Invidious::Routes::Embed::Index
|
Invidious::Routing.get "/embed/", Invidious::Routes::Embed, :redirect
|
||||||
Invidious::Routing.get "/embed/:id", Invidious::Routes::Embed::Show
|
Invidious::Routing.get "/embed/:id", Invidious::Routes::Embed, :show
|
||||||
Invidious::Routing.get "/view_all_playlists", Invidious::Routes::Playlists, :index
|
Invidious::Routing.get "/view_all_playlists", Invidious::Routes::Playlists, :index
|
||||||
Invidious::Routing.get "/create_playlist", Invidious::Routes::Playlists, :new
|
Invidious::Routing.get "/create_playlist", Invidious::Routes::Playlists, :new
|
||||||
Invidious::Routing.post "/create_playlist", Invidious::Routes::Playlists, :create
|
Invidious::Routing.post "/create_playlist", Invidious::Routes::Playlists, :create
|
||||||
|
@ -335,9 +335,9 @@ Invidious::Routing.get "/search", Invidious::Routes::Search, :search
|
||||||
Invidious::Routing.get "/login", Invidious::Routes::Login, :login_page
|
Invidious::Routing.get "/login", Invidious::Routes::Login, :login_page
|
||||||
Invidious::Routing.post "/login", Invidious::Routes::Login, :login
|
Invidious::Routing.post "/login", Invidious::Routes::Login, :login
|
||||||
Invidious::Routing.post "/signout", Invidious::Routes::Login, :signout
|
Invidious::Routing.post "/signout", Invidious::Routes::Login, :signout
|
||||||
Invidious::Routing.get "/preferences", Invidious::Routes::UserPreferences, :show
|
Invidious::Routing.get "/preferences", Invidious::Routes::PreferencesRoute, :show
|
||||||
Invidious::Routing.post "/preferences", Invidious::Routes::UserPreferences, :update
|
Invidious::Routing.post "/preferences", Invidious::Routes::PreferencesRoute, :update
|
||||||
Invidious::Routing.get "/toggle_theme", Invidious::Routes::UserPreferences, :toggle_theme
|
Invidious::Routing.get "/toggle_theme", Invidious::Routes::PreferencesRoute, :toggle_theme
|
||||||
|
|
||||||
# Users
|
# Users
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,29 @@
|
||||||
class Invidious::Routes::Embed::Show < Invidious::Routes::BaseRoute
|
class Invidious::Routes::Embed < Invidious::Routes::BaseRoute
|
||||||
def handle(env)
|
def redirect(env)
|
||||||
|
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
|
||||||
|
|
||||||
|
if plid = env.params.query["list"]?.try &.gsub(/[^a-zA-Z0-9_-]/, "")
|
||||||
|
begin
|
||||||
|
playlist = get_playlist(PG_DB, plid, locale: locale)
|
||||||
|
offset = env.params.query["index"]?.try &.to_i? || 0
|
||||||
|
videos = get_playlist_videos(PG_DB, playlist, offset: offset, locale: locale)
|
||||||
|
rescue ex
|
||||||
|
return error_template(500, ex)
|
||||||
|
end
|
||||||
|
|
||||||
|
url = "/embed/#{videos[0].id}?#{env.params.query}"
|
||||||
|
|
||||||
|
if env.params.query.size > 0
|
||||||
|
url += "?#{env.params.query}"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
url = "/"
|
||||||
|
end
|
||||||
|
|
||||||
|
env.redirect url
|
||||||
|
end
|
||||||
|
|
||||||
|
def show(env)
|
||||||
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
|
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
|
||||||
id = env.params.url["id"]
|
id = env.params.url["id"]
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
class Invidious::Routes::Embed::Index < Invidious::Routes::BaseRoute
|
|
||||||
def handle(env)
|
|
||||||
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
|
|
||||||
|
|
||||||
if plid = env.params.query["list"]?.try &.gsub(/[^a-zA-Z0-9_-]/, "")
|
|
||||||
begin
|
|
||||||
playlist = get_playlist(PG_DB, plid, locale: locale)
|
|
||||||
offset = env.params.query["index"]?.try &.to_i? || 0
|
|
||||||
videos = get_playlist_videos(PG_DB, playlist, offset: offset, locale: locale)
|
|
||||||
rescue ex
|
|
||||||
return error_template(500, ex)
|
|
||||||
end
|
|
||||||
|
|
||||||
url = "/embed/#{videos[0].id}?#{env.params.query}"
|
|
||||||
|
|
||||||
if env.params.query.size > 0
|
|
||||||
url += "?#{env.params.query}"
|
|
||||||
end
|
|
||||||
else
|
|
||||||
url = "/"
|
|
||||||
end
|
|
||||||
|
|
||||||
env.redirect url
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,6 +0,0 @@
|
||||||
class Invidious::Routes::Licenses < Invidious::Routes::BaseRoute
|
|
||||||
def handle(env)
|
|
||||||
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
|
|
||||||
rendered "licenses"
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,5 +1,5 @@
|
||||||
class Invidious::Routes::Home < Invidious::Routes::BaseRoute
|
class Invidious::Routes::Misc < Invidious::Routes::BaseRoute
|
||||||
def handle(env)
|
def home(env)
|
||||||
preferences = env.get("preferences").as(Preferences)
|
preferences = env.get("preferences").as(Preferences)
|
||||||
locale = LOCALES[preferences.locale]?
|
locale = LOCALES[preferences.locale]?
|
||||||
user = env.get? "user"
|
user = env.get? "user"
|
||||||
|
@ -25,4 +25,14 @@ class Invidious::Routes::Home < Invidious::Routes::BaseRoute
|
||||||
templated "empty"
|
templated "empty"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def privacy(env)
|
||||||
|
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
|
||||||
|
templated "privacy"
|
||||||
|
end
|
||||||
|
|
||||||
|
def licenses(env)
|
||||||
|
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
|
||||||
|
rendered "licenses"
|
||||||
|
end
|
||||||
end
|
end
|
|
@ -1,4 +1,4 @@
|
||||||
class Invidious::Routes::UserPreferences < Invidious::Routes::BaseRoute
|
class Invidious::Routes::PreferencesRoute < Invidious::Routes::BaseRoute
|
||||||
def show(env)
|
def show(env)
|
||||||
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
|
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
class Invidious::Routes::Privacy < Invidious::Routes::BaseRoute
|
|
||||||
def handle(env)
|
|
||||||
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
|
|
||||||
templated "privacy"
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
Reference in a new issue