emoji
This commit is contained in:
parent
9515fa9af9
commit
3e6abd1ea1
1 changed files with 83 additions and 35 deletions
118
website/main.ml
118
website/main.ml
|
|
@ -8,6 +8,7 @@ let context: Lib.tournament_scrape_context list = [
|
||||||
id = 384;
|
id = 384;
|
||||||
season = 70083;
|
season = 70083;
|
||||||
name = "LIBERTADORES";
|
name = "LIBERTADORES";
|
||||||
|
emoji = "🌎";
|
||||||
filter_foreigners = false;
|
filter_foreigners = false;
|
||||||
timezone_offset = None;
|
timezone_offset = None;
|
||||||
};
|
};
|
||||||
|
|
@ -15,6 +16,7 @@ let context: Lib.tournament_scrape_context list = [
|
||||||
id = 480;
|
id = 480;
|
||||||
season = 70070;
|
season = 70070;
|
||||||
name = "SUDAMERICANA";
|
name = "SUDAMERICANA";
|
||||||
|
emoji = "🌎";
|
||||||
filter_foreigners = false;
|
filter_foreigners = false;
|
||||||
timezone_offset = None;
|
timezone_offset = None;
|
||||||
};
|
};
|
||||||
|
|
@ -22,20 +24,7 @@ let context: Lib.tournament_scrape_context list = [
|
||||||
id = 373;
|
id = 373;
|
||||||
season = 71944;
|
season = 71944;
|
||||||
name = "COPA DO BRASIL";
|
name = "COPA DO BRASIL";
|
||||||
filter_foreigners = false;
|
emoji = "🇧🇷";
|
||||||
timezone_offset = None;
|
|
||||||
};
|
|
||||||
{
|
|
||||||
id = 1596;
|
|
||||||
season = 69430;
|
|
||||||
name = "COPA DO NORDESTE";
|
|
||||||
filter_foreigners = false;
|
|
||||||
timezone_offset = None;
|
|
||||||
};
|
|
||||||
{
|
|
||||||
id = 1024;
|
|
||||||
season = 70664;
|
|
||||||
name = "COPA ARGENTINA";
|
|
||||||
filter_foreigners = false;
|
filter_foreigners = false;
|
||||||
timezone_offset = None;
|
timezone_offset = None;
|
||||||
};
|
};
|
||||||
|
|
@ -43,6 +32,31 @@ let context: Lib.tournament_scrape_context list = [
|
||||||
id = 325;
|
id = 325;
|
||||||
season = 72034;
|
season = 72034;
|
||||||
name = "BRAZIL 1";
|
name = "BRAZIL 1";
|
||||||
|
emoji = "🇧🇷";
|
||||||
|
filter_foreigners = false;
|
||||||
|
timezone_offset = None;
|
||||||
|
};
|
||||||
|
{
|
||||||
|
id = 390;
|
||||||
|
season = 72603;
|
||||||
|
name = "BRAZIL 2";
|
||||||
|
emoji = "🇧🇷";
|
||||||
|
filter_foreigners = false;
|
||||||
|
timezone_offset = None;
|
||||||
|
};
|
||||||
|
{
|
||||||
|
id = 1596;
|
||||||
|
season = 69430;
|
||||||
|
name = "COPA DO NORDESTE";
|
||||||
|
emoji = "🇧🇷";
|
||||||
|
filter_foreigners = false;
|
||||||
|
timezone_offset = None;
|
||||||
|
};
|
||||||
|
{
|
||||||
|
id = 1024;
|
||||||
|
season = 70664;
|
||||||
|
name = "COPA ARGENTINA";
|
||||||
|
emoji = "🇦🇷";
|
||||||
filter_foreigners = false;
|
filter_foreigners = false;
|
||||||
timezone_offset = None;
|
timezone_offset = None;
|
||||||
};
|
};
|
||||||
|
|
@ -50,6 +64,7 @@ let context: Lib.tournament_scrape_context list = [
|
||||||
id = 155;
|
id = 155;
|
||||||
season = 77826;
|
season = 77826;
|
||||||
name = "ARGENTINA 1, CLAUSURA";
|
name = "ARGENTINA 1, CLAUSURA";
|
||||||
|
emoji = "🇦🇷";
|
||||||
filter_foreigners = false;
|
filter_foreigners = false;
|
||||||
timezone_offset = None;
|
timezone_offset = None;
|
||||||
};
|
};
|
||||||
|
|
@ -57,6 +72,7 @@ let context: Lib.tournament_scrape_context list = [
|
||||||
id = 278;
|
id = 278;
|
||||||
season = 71306;
|
season = 71306;
|
||||||
name = "URUGUAY 1";
|
name = "URUGUAY 1";
|
||||||
|
emoji = "🇺🇾";
|
||||||
filter_foreigners = false;
|
filter_foreigners = false;
|
||||||
timezone_offset = None;
|
timezone_offset = None;
|
||||||
};
|
};
|
||||||
|
|
@ -64,6 +80,7 @@ let context: Lib.tournament_scrape_context list = [
|
||||||
id = 11536;
|
id = 11536;
|
||||||
season = 77825;
|
season = 77825;
|
||||||
name = "COLOMBIA 1";
|
name = "COLOMBIA 1";
|
||||||
|
emoji = "🇨🇴";
|
||||||
filter_foreigners = false;
|
filter_foreigners = false;
|
||||||
timezone_offset = Some ~-5;
|
timezone_offset = Some ~-5;
|
||||||
};
|
};
|
||||||
|
|
@ -71,6 +88,7 @@ let context: Lib.tournament_scrape_context list = [
|
||||||
id = 1335;
|
id = 1335;
|
||||||
season = 76050;
|
season = 76050;
|
||||||
name = "COPA COLOMBIA";
|
name = "COPA COLOMBIA";
|
||||||
|
emoji = "🇨🇴";
|
||||||
filter_foreigners = false;
|
filter_foreigners = false;
|
||||||
timezone_offset = Some ~-5;
|
timezone_offset = Some ~-5;
|
||||||
};
|
};
|
||||||
|
|
@ -78,20 +96,15 @@ let context: Lib.tournament_scrape_context list = [
|
||||||
id = 11653;
|
id = 11653;
|
||||||
season = 71131;
|
season = 71131;
|
||||||
name = "CHILE 1";
|
name = "CHILE 1";
|
||||||
|
emoji = "🇨🇱";
|
||||||
filter_foreigners = false;
|
filter_foreigners = false;
|
||||||
timezone_offset = Some ~-4;
|
timezone_offset = Some ~-4;
|
||||||
};
|
};
|
||||||
{
|
|
||||||
id = 390;
|
|
||||||
season = 72603;
|
|
||||||
name = "BRAZIL 2";
|
|
||||||
filter_foreigners = false;
|
|
||||||
timezone_offset = None;
|
|
||||||
};
|
|
||||||
{
|
{
|
||||||
id = 1221;
|
id = 1221;
|
||||||
season = 71100;
|
season = 71100;
|
||||||
name = "COPA CHILE";
|
name = "COPA CHILE";
|
||||||
|
emoji = "🇨🇱";
|
||||||
filter_foreigners = false;
|
filter_foreigners = false;
|
||||||
timezone_offset = Some ~-4;
|
timezone_offset = Some ~-4;
|
||||||
};
|
};
|
||||||
|
|
@ -99,6 +112,7 @@ let context: Lib.tournament_scrape_context list = [
|
||||||
id = 11541;
|
id = 11541;
|
||||||
season = 69831;
|
season = 69831;
|
||||||
name = "PARAGUAY 1, CLAUSURA";
|
name = "PARAGUAY 1, CLAUSURA";
|
||||||
|
emoji = "🇵🇾";
|
||||||
filter_foreigners = false;
|
filter_foreigners = false;
|
||||||
timezone_offset = None;
|
timezone_offset = None;
|
||||||
};
|
};
|
||||||
|
|
@ -131,7 +145,8 @@ let my_head title' =
|
||||||
(head (title (txt title')) [
|
(head (title (txt title')) [
|
||||||
style [ txt {|
|
style [ txt {|
|
||||||
:root {
|
:root {
|
||||||
--main-bg: #eee; --main-margin: 3px;
|
--main-bg: #eee;
|
||||||
|
--main-margin: 3px;
|
||||||
--celeste: #9ed1ff;
|
--celeste: #9ed1ff;
|
||||||
}
|
}
|
||||||
* {
|
* {
|
||||||
|
|
@ -144,9 +159,17 @@ let my_head title' =
|
||||||
text-decoration-color: unset;
|
text-decoration-color: unset;
|
||||||
color: unset;
|
color: unset;
|
||||||
}
|
}
|
||||||
|
.match-table {
|
||||||
|
text-decoration: none;
|
||||||
|
transition: background-color 0.035s;
|
||||||
|
}
|
||||||
.match-table:last-child {
|
.match-table:last-child {
|
||||||
border-bottom: 0 !important
|
border-bottom: 0 !important
|
||||||
}
|
}
|
||||||
|
.match-table:hover {
|
||||||
|
background-color: var(--main-bg);
|
||||||
|
border-radius 3px 3px;
|
||||||
|
}
|
||||||
.standing tbody tr:nth-child(odd) {
|
.standing tbody tr:nth-child(odd) {
|
||||||
background-color: var(--celeste);
|
background-color: var(--celeste);
|
||||||
}
|
}
|
||||||
|
|
@ -157,6 +180,9 @@ let my_head title' =
|
||||||
td:nth-child(2), thead td {
|
td:nth-child(2), thead td {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
td:nth-child(3) {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|}]
|
|}]
|
||||||
])
|
])
|
||||||
;;
|
;;
|
||||||
|
|
@ -171,7 +197,7 @@ let box ?style elements =
|
||||||
[Tyxml.Html.a_style @@ "padding: var(--main-margin); border-radius: var(--main-margin); \
|
[Tyxml.Html.a_style @@ "padding: var(--main-margin); border-radius: var(--main-margin); \
|
||||||
margin: var(--main-margin); " ^ s]
|
margin: var(--main-margin); " ^ s]
|
||||||
in
|
in
|
||||||
Tyxml.Html.div ~a:attr elements
|
Tyxml.Html.section ~a:attr elements
|
||||||
;;
|
;;
|
||||||
|
|
||||||
let greet (tournaments: Lib.Tournament.t list) =
|
let greet (tournaments: Lib.Tournament.t list) =
|
||||||
|
|
@ -186,7 +212,7 @@ let greet (tournaments: Lib.Tournament.t list) =
|
||||||
(my_head "index")
|
(my_head "index")
|
||||||
(body [
|
(body [
|
||||||
my_header ();
|
my_header ();
|
||||||
main ~a:[a_style "margin: auto; display: flex; flex-direction: row;"]
|
main ~a:[a_style "margin: auto; display: flex; flex-direction: row; flex-wrap: wrap"]
|
||||||
(tournaments
|
(tournaments
|
||||||
|> List.filter_map @@ fun x -> (x
|
|> List.filter_map @@ fun x -> (x
|
||||||
|> Lib.Tournament.matches
|
|> Lib.Tournament.matches
|
||||||
|
|
@ -205,10 +231,9 @@ let greet (tournaments: Lib.Tournament.t list) =
|
||||||
then None
|
then None
|
||||||
else
|
else
|
||||||
Some (
|
Some (
|
||||||
div ~a:[a_class ["match-table"] ;
|
a ~a:[a_class ["match-table"] ; a_href @@ sprintf "/match/%d" match'.api_id ;
|
||||||
a_style "display: flex; justify-content: space-between; \
|
a_style "display: flex; justify-content: space-between; border-bottom: 1px black solid; \
|
||||||
border-bottom: 1px black solid; margin-bottom: calc(var(--main-margin) * 2); padding; \
|
padding-top: calc(var(--main-margin) * 2);"]
|
||||||
var(--main-margin)"]
|
|
||||||
[
|
[
|
||||||
div ~a:[a_style "display: flex; width: 145px; justify-content: space-between;"] [
|
div ~a:[a_style "display: flex; width: 145px; justify-content: space-between;"] [
|
||||||
div ~a:[] [
|
div ~a:[] [
|
||||||
|
|
@ -296,7 +321,8 @@ let greet (tournaments: Lib.Tournament.t list) =
|
||||||
Some (box ~style:"min-width: 200px;"
|
Some (box ~style:"min-width: 200px;"
|
||||||
[
|
[
|
||||||
header [
|
header [
|
||||||
a ~a:[a_href @@ sprintf "/tournament/%d" x.context.id] [h3 [txt x.context.name]];
|
a ~a:[a_href @@ sprintf "/tournament/%d" x.context.id]
|
||||||
|
[h3 [txt @@ sprintf "%s %s" x.context.emoji x.context.name]];
|
||||||
h4 [txt @@ sprintf "(%d/%d) Today" today.tm_mon today.tm_mday];
|
h4 [txt @@ sprintf "(%d/%d) Today" today.tm_mon today.tm_mday];
|
||||||
];
|
];
|
||||||
main y
|
main y
|
||||||
|
|
@ -307,11 +333,26 @@ let greet (tournaments: Lib.Tournament.t list) =
|
||||||
])
|
])
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
let match_details_page _ =
|
||||||
|
let open Tyxml.Html in
|
||||||
|
html
|
||||||
|
(my_head "index")
|
||||||
|
(body [
|
||||||
|
my_header () ;
|
||||||
|
main [
|
||||||
|
box
|
||||||
|
[ ]
|
||||||
|
];
|
||||||
|
footer []
|
||||||
|
]
|
||||||
|
)
|
||||||
|
;;
|
||||||
|
|
||||||
let tournament_page (tournament: Lib.Tournament.t) (tables: Lib.table list) =
|
let tournament_page (tournament: Lib.Tournament.t) (tables: Lib.table list) =
|
||||||
let open Tyxml.Html in
|
let open Tyxml.Html in
|
||||||
let my_table (t: Lib.table) =
|
let my_table (t: Lib.table) =
|
||||||
let attr =
|
let attr =
|
||||||
[a_style "border-collapse: collapse; border: 1px solid black; height: min-content";
|
[a_style "border-collapse: collapse; border: 1px solid black; height: min-content;";
|
||||||
a_class ["standing"]]
|
a_class ["standing"]]
|
||||||
in
|
in
|
||||||
let tab =
|
let tab =
|
||||||
|
|
@ -354,7 +395,7 @@ let tournament_page (tournament: Lib.Tournament.t) (tables: Lib.table list) =
|
||||||
td ~a:attr [txt @@ string_of_int position] ;
|
td ~a:attr [txt @@ string_of_int position] ;
|
||||||
td ~a:attr [
|
td ~a:attr [
|
||||||
div ~a:[a_style "display: flex; justify-content: space-between;"] @@
|
div ~a:[a_style "display: flex; justify-content: space-between;"] @@
|
||||||
(div [ txt @@ team.name ]) :: match is_playing with
|
(div ~a:[a_style "text-wrap: nowrap"] [ txt @@ team.name ]) :: match is_playing with
|
||||||
| None -> []
|
| None -> []
|
||||||
| Some (is_home, score) -> [
|
| Some (is_home, score) -> [
|
||||||
let style =
|
let style =
|
||||||
|
|
@ -414,7 +455,7 @@ let tournament_page (tournament: Lib.Tournament.t) (tables: Lib.table list) =
|
||||||
)
|
)
|
||||||
in
|
in
|
||||||
div [
|
div [
|
||||||
h3 ~a:[a_style "margin-bottom: var(--main-margin)"] [txt t.name] ;
|
h3 ~a:[a_style "margin-bottom: var(--main-margin); text-wrap: nowrap;"] [txt t.name] ;
|
||||||
tab ;
|
tab ;
|
||||||
]
|
]
|
||||||
in
|
in
|
||||||
|
|
@ -423,9 +464,11 @@ let tournament_page (tournament: Lib.Tournament.t) (tables: Lib.table list) =
|
||||||
(body [
|
(body [
|
||||||
my_header () ;
|
my_header () ;
|
||||||
main [
|
main [
|
||||||
box [h3 [txt tournament.context.name]] ;
|
box
|
||||||
box ~style:"display: flex; flex-direction: row; gap: calc(var(--main-margin) * 2)" @@
|
[
|
||||||
List.map my_table tables
|
h3 ~a:[] [txt @@ sprintf "%s %s" tournament.context.emoji tournament.context.name];
|
||||||
|
div (List.rev @@ List.map my_table tables)
|
||||||
|
]
|
||||||
];
|
];
|
||||||
footer []
|
footer []
|
||||||
]
|
]
|
||||||
|
|
@ -443,6 +486,11 @@ Lwt_main.run begin
|
||||||
let* data = Lib.fetch_all_tournaments context in
|
let* data = Lib.fetch_all_tournaments context in
|
||||||
Dream.html @@ html_to_string @@ greet data
|
Dream.html @@ html_to_string @@ greet data
|
||||||
end ;
|
end ;
|
||||||
|
Dream.get "/match/:id" begin fun request ->
|
||||||
|
let id' = int_of_string @@ Dream.param request "id" in
|
||||||
|
let* data = Lib.fetch_match_details id' in
|
||||||
|
Dream.html @@ html_to_string @@ match_details_page data
|
||||||
|
end ;
|
||||||
Dream.get "/tournament/:id" begin fun request ->
|
Dream.get "/tournament/:id" begin fun request ->
|
||||||
let id' = int_of_string @@ Dream.param request "id" in
|
let id' = int_of_string @@ Dream.param request "id" in
|
||||||
let ctx =
|
let ctx =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue