module type LINKS =sig
..end
type +'a
elt
type +'a
attrib
type
uri
val make_uri : ?absolute:bool ->
?absolute_path:bool ->
?https:bool ->
service:('get, unit, Eliom_service.get, 'a, 'b, 'c, 'd,
[< `WithSuffix | `WithoutSuffix ], 'e, unit, 'f)
Eliom_service.t ->
?hostname:string ->
?port:int ->
?fragment:string ->
?keep_nl_params:[ `All | `None | `Persistent ] ->
?nl_params:Eliom_parameter.nl_params_set -> 'get -> uri
The function make_uri service get_params
returns the URL of
the service service
applied to the GET parameters
get_params
. By default the returned URL is relative to the
current request URL but it is absolute when one of the following
conditions is met:
~absolute_path
is true
.~absolute
is true
.~https
is true
(resp. false
) and
the current request protocol is http
(resp. https
).~https
is true
and the function is
used outside of a service handlerservice
has been created with ~https:true
and the
current request protocol is http
.service
has been created with ~https:true
and the
function is used outside of a service handler.When only the first condition is met (~absolute_path
is
true
) the returned URL is just the absolute path, but when any
other condition is satisfied the returned URL is prefixed with
protocol://hostname[:port]
, where:
protocol
is:
https
if the service
has been created with
~https:true
or the optional parameter ~https
is
true
;http
if the optional parameter ~https
is false
;http
in any other case.hostname
is:
~hostname
if given;defaulthostname
of <host>
tag in
configuration file or the machine hostname if the
option <usedefaulthostname/>
is set;Host
http header of the current request if
available;defaulthostname
of <host>
tag in
configuration file or the machine hostname in any other
case.port
is:
~port
if given;defaulthttpsport
(resp. defaulthttpport
) of <host>
tag in
configuration file or 443
(resp. 80) if protocol
is
https
(resp. http
) and the current request protocol
is http
(resp. https
);defaulthttpsport
(resp. defaulthttpsport
) of <host>
tag in
configuration file or 443
(resp. 80) if the option
<usedefaulthostname/>
is set and protocol
is
https
(resp. http
);Host
http header of the
current request if available;defaulthttpport
(resp. defaulthttpsport
) of <host>
tag in
configuration file or 80
(resp. 443
) in any other
case.If given the optional parameter ~fragment
is prefixed by #
and appended to the URL.
The optional parameter keep_nl_params
allows one to override
the keep_nl_params
parameter used when creating the service
,
see Eliom_service.create
for a detailed description.
The optional parameter nl_params
allows one to add non
localized GET parameter to the URL. See the eliom manual for
more information about .
val uri_of_string : (unit -> string) -> uri
The function uri_of_string f
returns a URI whose content is
equivalent to f ()
.
For XML tree build with TyXML, like Html
or Svg.F
, the
function f
is applied each time the XML tree is sent to the
client (either as page content or as a marshalled OCaml
value). Hence, the function is always evaluated in the context
of a service handler.
For other module, the function f
is immediately applied.
val css_link : ?a:[< Html_types.link_attrib ] attrib list ->
uri:uri ->
unit -> [> Html_types.link ] elt
The function css_link ~uri ()
creates a <link>
node that
reference a Cascading StyleSheet (CSS).
If the CSS is generated by an Eliom service, use Eliom_form_sigs.LINKS.make_uri
to
calculate the service URI. If the CSS is a static file, you may
also use Eliom_service.static_dir
or Eliom_service.extern
to abstract the file with a service.
The optional parameter ~a
allows one to add extra HTML
attributes to the generated node.
val js_script : ?a:[< Html_types.script_attrib ] attrib list ->
uri:uri ->
unit -> [> Html_types.script ] elt
The function js_script ~uri ()
creates a <script>
node that
reference a javascript file.
If the script content is generated by an Eliom service, use
Eliom_form_sigs.LINKS.make_uri
to calculate the service URI. If it is a static
file, you may also use Eliom_service.static_dir
or
Eliom_service.extern
to abstract the file with a service.
The optional parameter ~a
allows one to add extra HTML
attributes to the generated node.
val a : ?absolute:bool ->
?absolute_path:bool ->
?https:bool ->
?a:[< Html_types.a_attrib ] attrib list ->
service:('get, unit, Eliom_service.get, 'b, 'c, 'd, 'e,
[< `WithSuffix | `WithoutSuffix ], 'f, unit,
Eliom_service.non_ocaml)
Eliom_service.t ->
?hostname:string ->
?port:int ->
?fragment:string ->
?keep_nl_params:[ `All | `None | `Persistent ] ->
?nl_params:Eliom_parameter.nl_params_set ->
?xhr:bool ->
'a elt list ->
'get -> [> 'a Html_types.a ] elt
The function a service a_content get_params
creates a <a>
node that link to service
applied to GET parameters
get_params
and whose content is a_content
. By default, the
href
attribute is a relative URL recomputed at each request
with Eliom_form_sigs.LINKS.make_uri
.
By default, the link is implemented in a way that allows the client-side Eliom application to keep running, irrespectable of the usage of the link (cf. ).
By contrast, if the optional parameter ~xhr:false
is given,
the link is realized as a standard HTML link and clicking it
discontinues the Eliom application. The ~xhr
parameter has no
effect outside an Eliom application.
The default value of ~xhr
is configurable through
.
The optional parameter ~a
allows one to add extra HTML
attributes to the generated node.
See Eliom_form_sigs.LINKS.make_uri
for description of other optional
parameters.
To create a <a>
node that is not associated to a service, use
Raw.a
.