diff --git a/src/invidious/frontend/user_menu.cr b/src/invidious/frontend/user_menu.cr new file mode 100644 index 00000000..9a486f70 --- /dev/null +++ b/src/invidious/frontend/user_menu.cr @@ -0,0 +1,112 @@ +module Invidious::Frontend::UserMenu + extend self + + # ------------------- + # Menu items + # ------------------- + + enum UserContentMenu + Subscriptions + WatchHistory + Playlists + end + + enum UserAccountMenu + Preferences + Account + ImportExport + LogOut + end + + private alias UserMenuItem = UserContentMenu | UserAccountMenu + + # ------------------- + # HTML templates + # ------------------- + + # Generates the following menu: + # + # ``` + #
+ # + # + # ``` + # + # The selected entry will have the "selected" class. + # + def make_menu(env : HTTP::Server::Context, selected_item : UserMenuItem) : String + # A capacity of 1500 is enough to store the HTML (empty) + # plus the URLs with parameters and the translated text. + str_builder = String::Builder.new(1500) + + # TODO: Get variables from HTTP env + locale = env.get("preferences").as(Preferences).locale + params = nil + + # Start of menu #1 + str_builder << <<-HTML + + + HTML + + return str_builder.to_s + end +end