pellest/src/home.ml
2022-12-06 02:31:33 +01:00

22 lines
748 B
OCaml

open Tyxml.Html
let get request =
let title = "Pellest is the best game ever!" in
let page =
if User.is_logged_in request then
let welcome =
div [ txt (Format.sprintf "welcome %s" (User.get_nick_unsafe request)) ]
in
let island =
div [ a ~a:[ a_href "/island" ] [ txt "🏝️ Go to your island !" ] ]
in
let logout = div [ a ~a:[ a_href "/logout" ] [ txt "Logout" ] ] in
[ welcome; island; logout ]
else
let about = div [ txt App.about ] in
let register = div [ a ~a:[ a_href "/register" ] [ txt "Register" ] ] in
let login = div [ a ~a:[ a_href "/login" ] [ txt "Login" ] ] in
[ about; login; register ]
in
Template.render ~title ~scripts:[] (div page)