Module Ocsigen.Xhtml


module Xhtml: sig .. end

Pages registration (typed xhtml)



type page = Xhtmltypes.xhtml XHTML.M.elt 
val register_service : service:('a, 'b, [ `Internal_Service of 'c ],
[< `WithSuffix | `WithoutSuffix ], 'd, 'e)
Ocsigen.service ->
?error_handler:(Ocsigen.server_params ->
(string * exn) list -> page Lwt.t) ->
(Ocsigen.server_params -> 'a -> 'b -> page Lwt.t) -> unit
Register an service in the global table of the server with the associated generation function. register_service service t f will associate the service service to the function f. f is the function that creates a page. It takes three parameters. The first one has type server_params and allows to have acces to informations about the request. The second and third ones are respectively GET and POST parameters. For example if t is (int "s"), then 'a is int.
val register_service_for_session : Ocsigen.server_params ->
service:('a, 'b, [ `Internal_Service of 'c ],
[< `WithSuffix | `WithoutSuffix ], 'd, 'e)
Ocsigen.service ->
?error_handler:(Ocsigen.server_params ->
(string * exn) list -> page Lwt.t) ->
(Ocsigen.server_params -> 'a -> 'b -> page Lwt.t) -> unit
Registers an service and the associated function in the session table. If the same client does a request to this service, this function will be used instead of the one from the global table.

Warning:


val register_new_service : url:Ocsigen.url_path ->
?prefix:bool ->
get_params:('a, [< `WithSuffix | `WithoutSuffix ] as 'b, 'c)
Ocsigen.params_type ->
?error_handler:(Ocsigen.server_params ->
(string * exn) list -> page Lwt.t) ->
(Ocsigen.server_params -> 'a -> unit -> page Lwt.t) ->
('a, unit, [ `Internal_Service of [ `Public_Service ] ], 'b, 'c,
unit Ocsigen.param_name)
Ocsigen.service
Same as new_service followed by register_service
val register_new_auxiliary_service : fallback:('a, unit, [ `Internal_Service of [ `Public_Service ] ],
[< `WithSuffix | `WithoutSuffix ] as 'b, 'c, 'd)
Ocsigen.service ->
?error_handler:(Ocsigen.server_params ->
(string * exn) list -> page Lwt.t) ->
(Ocsigen.server_params -> 'a -> unit -> page Lwt.t) ->
('a, unit, [ `Internal_Service of [ `Local_Service ] ], 'b, 'c, 'd)
Ocsigen.service
Same as new_auxiliary_service followed by register_service
val register_new_auxiliary_service_for_session : Ocsigen.server_params ->
fallback:('a, unit, [ `Internal_Service of [ `Public_Service ] ],
[< `WithSuffix | `WithoutSuffix ] as 'b, 'c, 'd)
Ocsigen.service ->
?error_handler:(Ocsigen.server_params ->
(string * exn) list -> page Lwt.t) ->
(Ocsigen.server_params -> 'a -> unit -> page Lwt.t) ->
('a, unit, [ `Internal_Service of [ `Local_Service ] ], 'b, 'c, 'd)
Ocsigen.service
Same as new_auxiliary_service followed by register_service_for_session
val register_new_post_service : fallback:('a, unit, [ `Internal_Service of [ `Public_Service ] ],
[< `WithSuffix | `WithoutSuffix ] as 'b, 'c,
unit Ocsigen.param_name)
Ocsigen.service ->
post_params:('d, [ `WithoutSuffix ], 'e) Ocsigen.params_type ->
?error_handler:(Ocsigen.server_params ->
(string * exn) list -> page Lwt.t) ->
(Ocsigen.server_params -> 'a -> 'd -> page Lwt.t) ->
('a, 'd, [ `Internal_Service of [ `Public_Service ] ], 'b, 'c, 'e)
Ocsigen.service
Same as new_post_service followed by register_post_service
val register_new_post_auxiliary_service : fallback:('a, 'b, [ `Internal_Service of [ `Public_Service ] ],
[< `WithSuffix | `WithoutSuffix ] as 'c, 'd, 'e)
Ocsigen.service ->
post_params:('f, [ `WithoutSuffix ], 'g) Ocsigen.params_type ->
?error_handler:(Ocsigen.server_params ->
(string * exn) list -> page Lwt.t) ->
(Ocsigen.server_params -> 'a -> 'f -> page Lwt.t) ->
('a, 'f, [ `Internal_Service of [ `Local_Service ] ], 'c, 'd, 'g)
Ocsigen.service
Same as new_post_auxiliary_service followed by register_post_service
val register_new_post_auxiliary_service_for_session : Ocsigen.server_params ->
fallback:('a, 'b, [ `Internal_Service of [ `Public_Service ] ],
[< `WithSuffix | `WithoutSuffix ] as 'c, 'd, 'e)
Ocsigen.service ->
post_params:('f, [ `WithoutSuffix ], 'g) Ocsigen.params_type ->
?error_handler:(Ocsigen.server_params ->
(string * exn) list -> page Lwt.t) ->
(Ocsigen.server_params -> 'a -> 'f -> page Lwt.t) ->
('a, 'f, [ `Internal_Service of [ `Local_Service ] ], 'c, 'd, 'g)
Ocsigen.service
Same as new_post_auxiliary_service followed by register_post_service_for_session

Creating links, forms, etc.


val a : ?a:Xhtmltypes.a_attrib XHTML.M.attrib list ->
('a, unit, 'b, [< `WithSuffix | `WithoutSuffix ], 'c,
unit Ocsigen.param_name)
Ocsigen.service ->
Ocsigen.server_params ->
Xhtmltypes.a_content XHTML.M.elt list -> 'a -> [> Xhtmltypes.a ] XHTML.M.elt
a service sp cont () creates a link from current to service. The text of the link is cont. For example cont may be something like [pcdata "click here"].

The last parameter is for GET parameters. For example a service sp cont (42,"hello")

The ~a optional parameter is used for extra attributes (see the module XHTML.M)

val css_link : ?a:Xhtmltypes.link_attrib XHTML.M.attrib list ->
XHTML.M.uri -> [> Xhtmltypes.link ] XHTML.M.elt
Creates a <link> tag for a Cascading StyleSheet (CSS).
val js_script : ?a:Xhtmltypes.script_attrib XHTML.M.attrib list ->
XHTML.M.uri -> [> Xhtmltypes.script ] XHTML.M.elt
Creates a <script> tag to add a javascript file
val make_uri : ('a, unit, 'b, [< `WithSuffix | `WithoutSuffix ], 'c, 'd) Ocsigen.service ->
Ocsigen.server_params -> 'a -> XHTML.M.uri
Create the text of the service. Like the a function, it may take extra parameters.
val get_form : ?a:Xhtmltypes.form_attrib XHTML.M.attrib list ->
('a, unit, 'b, 'c, 'd, unit Ocsigen.param_name) Ocsigen.service ->
Ocsigen.server_params ->
('d -> Xhtmltypes.form_content XHTML.M.elt list) ->
[> Xhtmltypes.form ] XHTML.M.elt
get_form service current formgen creates a GET form from current to service. The content of the form is generated by the function formgen, that takes the names of page parameters as parameters.
val post_form : ?a:Xhtmltypes.form_attrib XHTML.M.attrib list ->
('a, 'b, 'c, [< `WithSuffix | `WithoutSuffix ], 'd, 'e) Ocsigen.service ->
Ocsigen.server_params ->
('e -> Xhtmltypes.form_content XHTML.M.elt list) ->
'a -> [> Xhtmltypes.form ] XHTML.M.elt
post_form service current formgen creates a POST form from current to service. The last parameter is for GET parameters (as in the function a).
val int_input : ?a:Xhtmltypes.input_attrib XHTML.M.attrib list ->
?value:int -> int Ocsigen.param_name -> [> Xhtmltypes.input ] XHTML.M.elt
Creates an <input> tag for an integer
val float_input : ?a:Xhtmltypes.input_attrib XHTML.M.attrib list ->
?value:float -> float Ocsigen.param_name -> [> Xhtmltypes.input ] XHTML.M.elt
Creates an <input> tag for a float
val string_input : ?a:Xhtmltypes.input_attrib XHTML.M.attrib list ->
?value:string ->
string Ocsigen.param_name -> [> Xhtmltypes.input ] XHTML.M.elt
Creates an <input> tag for a string
val user_type_input : ?a:Xhtmltypes.input_attrib XHTML.M.attrib list ->
?value:'a ->
('a -> string) -> 'a Ocsigen.param_name -> [> Xhtmltypes.input ] XHTML.M.elt
Creates an <input> tag for a user type
val int_password_input : ?a:Xhtmltypes.input_attrib XHTML.M.attrib list ->
?value:int -> int Ocsigen.param_name -> [> Xhtmltypes.input ] XHTML.M.elt
Creates an <input type="password"> tag for an integer
val float_password_input : ?a:Xhtmltypes.input_attrib XHTML.M.attrib list ->
?value:float -> float Ocsigen.param_name -> [> Xhtmltypes.input ] XHTML.M.elt
Creates an <input type="password"> tag for a float
val string_password_input : ?a:Xhtmltypes.input_attrib XHTML.M.attrib list ->
?value:string ->
string Ocsigen.param_name -> [> Xhtmltypes.input ] XHTML.M.elt
Creates an <input type="password"> tag for a string
val user_type_password_input : ?a:Xhtmltypes.input_attrib XHTML.M.attrib list ->
?value:'a ->
('a -> string) -> 'a Ocsigen.param_name -> [> Xhtmltypes.input ] XHTML.M.elt
Creates an <input type="password"> tag for a user type
val hidden_int_input : ?a:Xhtmltypes.input_attrib XHTML.M.attrib list ->
int Ocsigen.param_name -> int -> [> Xhtmltypes.input ] XHTML.M.elt
Creates an hidden <input> tag for an integer
val hidden_float_input : ?a:Xhtmltypes.input_attrib XHTML.M.attrib list ->
float Ocsigen.param_name -> float -> [> Xhtmltypes.input ] XHTML.M.elt
Creates an hidden <input> tag for a float
val hidden_string_input : ?a:Xhtmltypes.input_attrib XHTML.M.attrib list ->
string Ocsigen.param_name -> string -> [> Xhtmltypes.input ] XHTML.M.elt
Creates an hidden <input> tag for a string
val hidden_user_type_input : ?a:Xhtmltypes.input_attrib XHTML.M.attrib list ->
('a -> string) ->
'a Ocsigen.param_name -> 'a -> [> Xhtmltypes.input ] XHTML.M.elt
Creates an hidden <input> tag for a user type
val bool_checkbox : ?a:Xhtmltypes.input_attrib XHTML.M.attrib list ->
?checked:bool -> bool Ocsigen.param_name -> [> Xhtmltypes.input ] XHTML.M.elt
Creates a checkbox <input> tag
val string_radio : ?a:Xhtmltypes.input_attrib XHTML.M.attrib list ->
?checked:bool ->
string option Ocsigen.param_name ->
string -> [> Xhtmltypes.input ] XHTML.M.elt
Creates a radio <input> tag with string content
val int_radio : ?a:Xhtmltypes.input_attrib XHTML.M.attrib list ->
?checked:bool ->
int option Ocsigen.param_name -> int -> [> Xhtmltypes.input ] XHTML.M.elt
Creates a radio <input> tag with int content
val float_radio : ?a:Xhtmltypes.input_attrib XHTML.M.attrib list ->
?checked:bool ->
float option Ocsigen.param_name -> float -> [> Xhtmltypes.input ] XHTML.M.elt
Creates a radio <input> tag with float content
val user_type_radio : ?a:Xhtmltypes.input_attrib XHTML.M.attrib list ->
?checked:bool ->
('a -> string) ->
'a option Ocsigen.param_name -> 'a -> [> Xhtmltypes.input ] XHTML.M.elt
Creates a radio <input> tag with user_type content
val textarea : ?a:Xhtmltypes.textarea_attrib XHTML.M.attrib list ->
string Ocsigen.param_name ->
rows:XHTML.M.number ->
cols:XHTML.M.number ->
[ `PCDATA ] XHTML.M.elt -> [> Xhtmltypes.textarea ] XHTML.M.elt
Creates a <textarea> tag
val select : ?a:Xhtmltypes.select_attrib XHTML.M.attrib list ->
?selected:(string option * string) option ->
string option * string ->
(string option * string) list ->
string Ocsigen.param_name -> [> Xhtmltypes.select ] XHTML.M.elt
Basic support for the <select> tag.

The associated parameter is of type "string". It is used in forms as for example:

select (None, "inconnue") [(None, "C1"); (None, "C2")] classe

where "classe" is the parameter name. The different choices are of the form (<optional string1>, <string2>). "string2" is presented to the user and if selected it is the returned value except when "string1" is present (where it is "string1"). It is modeled after the way "select" is done in HTML.

Not all features of "select" are implemented.

val submit_input : ?a:Xhtmltypes.input_attrib XHTML.M.attrib list ->
string -> [> Xhtmltypes.input ] XHTML.M.elt
Creates a submit <input> tag
val file_input : ?a:Xhtmltypes.input_attrib XHTML.M.attrib list ->
?value:string ->
Extensions.file_info Ocsigen.param_name -> [> Xhtmltypes.input ] XHTML.M.elt
val action_a : ?a:Xhtmltypes.a_attrib XHTML.M.attrib list ->
?reload:bool ->
('a, 'b) Ocsigen.action ->
Ocsigen.server_params ->
Xhtmltypes.a_content XHTML.M.elt list -> [> Xhtmltypes.form ] XHTML.M.elt
Creates a link that will perform an action (see action). If ~reload:false is specified, the current page will not be reloaded.
val action_form : ?a:Xhtmltypes.form_attrib XHTML.M.attrib list ->
?reload:bool ->
('a, 'b) Ocsigen.action ->
Ocsigen.server_params ->
('b -> Xhtmltypes.form_content XHTML.M.elt list) ->
[> Xhtmltypes.form ] XHTML.M.elt
Creates a form that will perform an action (see action). If ~reload:false is specified, the current page will not be reloaded.