Skip to content

Commit fb36155

Browse files
committed
Move user routes definitions to a macro in routing.cr
1 parent 7ace3fc commit fb36155

File tree

2 files changed

+28
-23
lines changed

2 files changed

+28
-23
lines changed

src/invidious.cr

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -364,29 +364,8 @@ end
364364
Invidious::Routing.get "/results", Invidious::Routes::Search, :results
365365
Invidious::Routing.get "/search", Invidious::Routes::Search, :search
366366

367-
# User login/out
368-
Invidious::Routing.get "/login", Invidious::Routes::Login, :login_page
369-
Invidious::Routing.post "/login", Invidious::Routes::Login, :login
370-
Invidious::Routing.post "/signout", Invidious::Routes::Login, :signout
371-
372-
# User preferences
373-
Invidious::Routing.get "/preferences", Invidious::Routes::PreferencesRoute, :show
374-
Invidious::Routing.post "/preferences", Invidious::Routes::PreferencesRoute, :update
375-
Invidious::Routing.get "/toggle_theme", Invidious::Routes::PreferencesRoute, :toggle_theme
376-
Invidious::Routing.get "/data_control", Invidious::Routes::PreferencesRoute, :data_control
377-
Invidious::Routing.post "/data_control", Invidious::Routes::PreferencesRoute, :update_data_control
378-
379-
# User account management
380-
Invidious::Routing.get "/change_password", Invidious::Routes::Account, :get_change_password
381-
Invidious::Routing.post "/change_password", Invidious::Routes::Account, :post_change_password
382-
Invidious::Routing.get "/delete_account", Invidious::Routes::Account, :get_delete
383-
Invidious::Routing.post "/delete_account", Invidious::Routes::Account, :post_delete
384-
Invidious::Routing.get "/clear_watch_history", Invidious::Routes::Account, :get_clear_history
385-
Invidious::Routing.post "/clear_watch_history", Invidious::Routes::Account, :post_clear_history
386-
Invidious::Routing.get "/authorize_token", Invidious::Routes::Account, :get_authorize_token
387-
Invidious::Routing.post "/authorize_token", Invidious::Routes::Account, :post_authorize_token
388-
Invidious::Routing.get "/token_manager", Invidious::Routes::Account, :token_manager
389-
Invidious::Routing.post "/token_ajax", Invidious::Routes::Account, :token_ajax
367+
# User routes
368+
define_user_routes()
390369

391370
# Feeds
392371
Invidious::Routing.get "/view_all_playlists", Invidious::Routes::Feeds, :view_all_playlists_redirect

src/invidious/routing.cr

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,32 @@ module Invidious::Routing
1010
{% end %}
1111
end
1212

13+
macro define_user_routes
14+
# User login/out
15+
Invidious::Routing.get "/login", Invidious::Routes::Login, :login_page
16+
Invidious::Routing.post "/login", Invidious::Routes::Login, :login
17+
Invidious::Routing.post "/signout", Invidious::Routes::Login, :signout
18+
19+
# User preferences
20+
Invidious::Routing.get "/preferences", Invidious::Routes::PreferencesRoute, :show
21+
Invidious::Routing.post "/preferences", Invidious::Routes::PreferencesRoute, :update
22+
Invidious::Routing.get "/toggle_theme", Invidious::Routes::PreferencesRoute, :toggle_theme
23+
Invidious::Routing.get "/data_control", Invidious::Routes::PreferencesRoute, :data_control
24+
Invidious::Routing.post "/data_control", Invidious::Routes::PreferencesRoute, :update_data_control
25+
26+
# User account management
27+
Invidious::Routing.get "/change_password", Invidious::Routes::Account, :get_change_password
28+
Invidious::Routing.post "/change_password", Invidious::Routes::Account, :post_change_password
29+
Invidious::Routing.get "/delete_account", Invidious::Routes::Account, :get_delete
30+
Invidious::Routing.post "/delete_account", Invidious::Routes::Account, :post_delete
31+
Invidious::Routing.get "/clear_watch_history", Invidious::Routes::Account, :get_clear_history
32+
Invidious::Routing.post "/clear_watch_history", Invidious::Routes::Account, :post_clear_history
33+
Invidious::Routing.get "/authorize_token", Invidious::Routes::Account, :get_authorize_token
34+
Invidious::Routing.post "/authorize_token", Invidious::Routes::Account, :post_authorize_token
35+
Invidious::Routing.get "/token_manager", Invidious::Routes::Account, :token_manager
36+
Invidious::Routing.post "/token_ajax", Invidious::Routes::Account, :token_ajax
37+
end
38+
1339
macro define_v1_api_routes
1440
{{namespace = Invidious::Routes::API::V1}}
1541
# Videos

0 commit comments

Comments
 (0)