-
Notifications
You must be signed in to change notification settings - Fork 0
/
pager.ml
114 lines (102 loc) · 3.93 KB
/
pager.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
(* ************************************************************************** *)
(* Project: Karaokanime *)
(* Description: Pager module. Tools to create Ocsigen pages. *)
(* Author: db0 ([email protected], http://db0.fr/) *)
(* Latest Version is on GitHub: https://github.com/db0company/Karaokanime *)
(* ************************************************************************** *)
open Eliom_content
open Html5.D
open Eliom_parameter
(* ************************************************************************** *)
(* HTTP Header *)
(* ************************************************************************** *)
let http_header =
head (title
(pcdata (Karaokanime.title ^ " :: " ^ Karaokanime.slogan)))
[(css_link ~uri:(make_uri (Eliom_service.static_dir ())
["css";"style.css"]) ())]
(* ************************************************************************** *)
(* Header *)
(* ************************************************************************** *)
let _ =
Eliom_registration.Action.register
~service:Services.search
(fun () (query) -> Lwt.return ())
let search_form =
post_form Services.search
(fun query_name ->
[string_input
~a:[a_class["text"]]
~input_type:`Text
~name:query_name
();
string_input
~input_type:`Submit
~value:"Recherche"
()
]) ()
let display_header =
let list_of_menu list =
List.map
(fun (service, name) ->
a ~service:service [pcdata name] ())
list in
let menu_right = [(Services.faq, "F.A.Q.");
(Services.contact, "Contact");
(Services.upload, "Proposer un karaoké");
(Services.tutorial, "Tutoriaux")
]
and menu_left = [(Services.main, "Accueil");
(Services.list, "Liste des karaokés");
(Services.helpus, "Nous aider ?");
(Services.playlist, "Ma playlist")
] in
let logo = div ~a:[a_class["logo"]]
[a ~service:Services.main
[img ~alt:("Logo " ^ Karaokanime.title)
~src:(make_uri ~service:(Eliom_service.static_dir ())
["images";"interface";"logo.jpg"])
()
] ()] in
(* todo: arrange this alphabet*)
let alphabet = ['~'; 'a'; 'b'; 'c'; 'd'; 'e'; 'f'; 'g'; 'h'; 'i';
'j'; 'k'; 'l'; 'm'; 'n'; 'o'; 'p'; 'q'; 'r'; 's';
't'; 'u'; 'v'; 'w'; 'x'; 'y'; 'z'] in
div
~a:[a_class["header"]]
[div ~a:[a_class["menu"]]
[search_form;
div ~a:[a_class["right_menu"]]
(list_of_menu menu_right);
div ~a:[a_class["left_menu"]]
(list_of_menu menu_left)
];
logo;
div ~a:[a_class["alphabet"]]
(List.map
(fun letter ->
let str = Char.escaped letter in
a ~service:Services.list_query
[pcdata str] str) alphabet);
img ~alt:("test pub")
~src:(make_uri ~service:(Eliom_service.static_dir ())
["images";"pub.jpg"])
()
]
(* ************************************************************************** *)
(* Footer *)
(* ************************************************************************** *)
let display_footer = div ~a:[a_class["footer"]] []
(* ************************************************************************** *)
(* Pager *)
(* ************************************************************************** *)
(* create : "Html body content" list -> "Html content" *)
(* Return a page correctly formatted with header and footer *)
(* containing the given body *)
let create body_content =
(html http_header
(body [div ~a:[a_class["main"]]
[display_header;
div ~a:[a_class ["page"]] body_content;
display_footer]
]))