Module Os_user_view

This module defines functions to create password forms, connection forms, settings buttons and other common contents arising in applications. As Eliom_content.Html.F is opened by default, if the module D is not explicitly used, HTML tags will be functional.

val generic_email_form : ?a:[< Html_types.form_attrib ] Eliom_content.Html.D.attrib list -> ?label:string Eliom_content.Html.F.wrap -> ?a_placeholder_email:string -> ?text:string -> ?email:string -> service: (unit, 'a, Eliom_service.post, 'b, 'c, 'd, 'e, [< `WithSuffix | `WithoutSuffix ], 'f, [< string Eliom_parameter.setoneradio ] Eliom_parameter.param_name, Eliom_service.non_ocaml) Eliom_service.t -> unit -> [> Html_types.form ] Eliom_content.Html.D.elt

generic_email_form ?a ?label ?text ?email ~service () creates an email POST form with an input of type email and a submit button. Placeholder value "e-mail address" is used for the email input.

  • parameter a

    add attributes of the form.

  • parameter label

    add a label (default is None) to the email input.

  • parameter text

    text for the button (default is "Send").

  • parameter email

    the default value of the email input (default is empty).

  • parameter service

    service which the data is sent to.

val connect_form : ?a_placeholder_email:string -> ?a_placeholder_phone:string -> ?a_placeholder_pwd:string -> ?text_keep_me_logged_in:string -> ?text_sign_in:string -> ?a:[< Html_types.form_attrib ] Eliom_content.Html.D.attrib list -> ?email:string -> unit -> [> Html_types.form ] Eliom_content.Html.D.elt

connect_form ?a ?email () creates a POST login form with email, password, a checkbox to stay logged in (with default text to "keep me logged in" in a span) and a submit button. Default placeholders for input email (resp. password) is "Your email" (resp. "Your password").

The data is sent to Os_services.connect_service.

  • parameter a_placeholder_email

    text for the placeholder of the email input.

  • parameter a_placeholder_pwd

    text for the placeholder of the password input.

  • parameter text_keep_me_logged_in

    text for the check box to stay connected.

  • parameter text_sign_in

    text for the sign in button.

  • parameter a

    attributes of the form.

  • parameter email

    the default value of the email input (default is empty).

val disconnect_button : ?a:[< Html_types.form_attrib ] Eliom_content.Html.F.attrib list -> ?text_logout:string -> unit -> [> Html_types.form ] Eliom_content.Html.F.elt

disconnect_button ?a () creates a disconnect POST form with a button without value, a signout icon and a text message "logout".

  • parameter a

    attributes of the form.

val sign_up_form : ?a:[< Html_types.form_attrib ] Eliom_content.Html.D.attrib list -> ?a_placeholder_email:string -> ?text:string -> ?email:string -> unit -> [> Html_types.form ] Eliom_content.Html.D.elt

sign_up_form ?a ?email () creates a generic_email_form with the service Os_services.sign_up_service.

  • parameter a

    attributes of the form.

  • parameter email

    the default value of the email input (default is empty).

val forgot_password_form : ?a:[< Html_types.form_attrib ] Eliom_content.Html.D.attrib list -> unit -> [> Html_types.form ] Eliom_content.Html.D.elt

forgot_password_form ~a () creates a generic_email_form with the service Os_services.forgot_password_service.

  • parameter a

    attributes of the form.

val information_form : ?a:[< Html_types.form_attrib ] Eliom_content.Html.D.attrib list -> ?a_placeholder_password:string -> ?a_placeholder_retype_password:string -> ?a_placeholder_firstname:string -> ?a_placeholder_lastname:string -> ?text_submit:string -> ?firstname:string -> ?lastname:string -> ?password1:string -> ?password2:string -> unit -> [> Html_types.form ] Eliom_content.Html.D.elt

information_form ~a ~firstname ~lastname ~password1 ~password2 () creates a POST form to update the user information like first name, last name and password. It also checks (client-side) if the passwords match when the send button is pressed and a custom validity message is showed if they don't match. The data is sent to Os_services.set_personal_data_service.

  • parameter a

    attributes of the form.

  • parameter a_placeholder_password

    text for the placeholder of the password input.

  • parameter a_placeholder_retype_password

    text for the placeholder of the confirmation password input.

  • parameter a_placeholder_firstname

    text for the placeholder of the firstname input.

  • parameter a_placeholder_lastname

    text for the placeholder of the lastname input.

  • parameter text_submit

    text for the submit button.

  • parameter firstname

    the default value for the first name.

  • parameter lastname

    the default value for the last name.

  • parameter password1

    the default value for the password1.

  • parameter password2

    the default value for the password2 (ie the confirmation password).

preregister_form ~a label creates a generic_email_form with the service Os_services.preregister_service and add the label label to the email input form.

  • parameter a

    attributes of the form.

  • parameter label

    label for the email input.

home_button ~a () creates an input button with value "home" which redirects to the main service.

  • parameter a

    attributes of the form.

val avatar : Os_types.User.t -> [> `I | `Img ] Eliom_content.Html.F.elt

avatar user creates an image HTML tag (with Eliom_content.HTML.F) with an alt attribute to "picture" and with class "os-avatar". If the user has no avatar, the default icon representing the user (see Ot_icons.F.user) is returned.

  • parameter user

    the user.

username user creates a div with class "os_username" containing:

  • firstname lastname if the user has a firstname.
  • "User " concatenated with the userid in other cases.

FIXME/IMPROVEME: use an option for the case the user has no firstname? Firstname must be empty because it must be optional.

  • parameter user

    the user.

val password_form : ?a_placeholder_pwd:string -> ?a_placeholder_confirmation:string -> ?text_send_button:string -> ?a:[< Html_types.form_attrib ] Eliom_content.Html.D.attrib list -> service: (unit, 'a, Eliom_service.post, 'b, 'c, 'd, 'e, [< `WithSuffix | `WithoutSuffix ], 'f, [< string Eliom_parameter.setoneradio ] Eliom_parameter.param_name * [< string Eliom_parameter.setoneradio ] Eliom_parameter.param_name, Eliom_service.non_ocaml) Eliom_service.t -> unit -> [> Html_types.form ] Eliom_content.Html.D.elt

password_form ~a ~service () defines a POST form with two inputs for a password form (password and password confirmation) and a send button. It also checks (client-side) if the passwords match when the send button is pressed.

  • parameter a_placeholder_pwd

    placeholder test for the password input.

  • parameter a_placeholder_confirmation

    placeholder test for the confirmation input.

  • parameter text_send_button

    text for the send button.

  • parameter a

    attributes of the form.

  • parameter service

    service which the data is sent to.

upload_pic_link ?a ?content ?crop ?input ?submit action_after_submit service userid

Creates a link with a label and a submit button to upload a picture.

The client function action_after_submit will be called first, for example to close the menu containing the link.

You can add attributes to the HTML tag with the optional parameter ?a. ?input and ?submit are couples (attributes, content_children) for the label and the submit button where attributes is a list of attributes for the tag and content_children is a list of children. By default, they are empty.

?content is the link text. The default value is "Change profile picture".

service is the service called to upload the picture.

You can crop the picture by giving a value to ?crop.

Link to start to see the help from the beginning. The client function given as first parameter will be called first, for example to close the menu containing the link.

  • parameter text_link

    link text.

Link to disconnect all user sessions.

  • parameter text_link

    link text.

A link to Os_services.disconnect_service.

  • parameter text_logout

    the link text.

  • parameter a

    attributes for the link.

val connected_user_box : user:Os_types.User.t -> [> Html_types.div ] Eliom_content.Html.D.elt

An userbox (in a div with the CSS class "connected-user-box") for connected users with an icon and the username.

val connection_box : ?a_placeholder_email:string -> ?a_placeholder_phone:string -> ?a_placeholder_pwd:string -> ?text_keep_me_logged_in:string -> ?content_popup_forgotpwd:string -> ?text_button_forgotpwd:string -> ?text_sign_in:string -> ?text_sign_up:string -> ?text_send_button:string -> unit -> [> Html_types.div ] Eliom_content.Html.D.elt Lwt.t

A box (in a div with the CSS class "os-connection-box") with a sign in and a sign out button. ?text_sign_in (resp. text_sign_up) is the text for the sign in (resp. sign up) button, default is "Sign in" (resp. "Sign up").

val user_box : ?a_placeholder_email:string -> ?a_placeholder_pwd:string -> ?text_keep_me_logged_in:string -> ?content_popup_forgotpwd:string -> ?text_button_forgotpwd:string -> ?text_sign_in:string -> ?text_sign_up:string -> ?text_send_button:string -> ?user:Os_types.User.t -> unit -> [> Html_types.div ] Eliom_content.Html.F.elt Lwt.t

Return connection_box if no user is connected (i.e. user is None). Else connected_user_box.