From a93720f09e7136c361586a2fcfc1e23941b86f28 Mon Sep 17 00:00:00 2001 From: balat Date: Fri, 29 Dec 2023 16:08:40 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20ocsigen/?= =?UTF-8?q?tuto@e0b1cf1469827169df8838870eb7d21cd9b93f69=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 7.1/manual/application.html | 4 +- 7.1/manual/basics-server.html | 392 ++++++++++++++++++ 7.1/manual/basics.html | 35 +- 7.1/manual/basicwebsite.html | 155 ------- 7.1/manual/chat.html | 4 +- 7.1/manual/custom-conf.html | 4 +- 7.1/manual/hash-password.html | 4 +- ...e-a-cryptographically-safe-identifier.html | 4 +- .../how-does-a-page-s-source-code-look.html | 4 +- 7.1/manual/how-to-add-a-div.html | 4 +- 7.1/manual/how-to-add-a-favicon.html | 4 +- .../how-to-add-a-javascript-script.html | 4 +- 7.1/manual/how-to-add-a-list.html | 4 +- ...to-add-a-select-or-other-form-element.html | 4 +- 7.1/manual/how-to-add-an-image.html | 4 +- 7.1/manual/how-to-add-css-stylesheet.html | 4 +- ...o-attach-ocaml-values-to-dom-elements.html | 4 +- ...-to-the-html-nodes-sent-to-the-client.html | 4 +- 7.1/manual/how-to-build-js-object.html | 4 +- ...server-side-function-from-client-side.html | 4 +- ...o-call-an-ocaml-function-from-js-code.html | 4 +- .../how-to-compile-my-ocsigen-pages.html | 4 +- ...nfigure-and-launch-the-ocsigen-server.html | 4 +- ...ding-on-data-entered-on-previous-ones.html | 4 +- ...-current-page-without-knowing-its-url.html | 4 +- .../how-to-detect-channel-disconnection.html | 4 +- ...-side-state-for-the-process-is-closed.html | 4 +- .../how-to-do-links-to-other-pages.html | 4 +- ...ow-to-implement-a-notification-system.html | 4 +- ...belonging-to-a-form-towards-a-service.html | 4 +- ...all-sessions-for-one-user-or-all-tabs.html | 4 +- ...e-browser-window-has-the-focus-or-not.html | 4 +- .../how-to-make-hello-world-in-ocsigen.html | 4 +- 7.1/manual/how-to-make-page-a-skeleton.html | 4 +- 7.1/manual/how-to-make-responsive-css.html | 4 +- ...-the-server-and-insert-it-in-the-page.html | 4 +- ...vice-that-decides-itself-what-to-send.html | 4 +- 7.1/manual/how-to-register-session-data.html | 4 +- ...r-without-stopping-the-client-process.html | 4 +- 7.1/manual/how-to-send-file-download.html | 4 +- 7.1/manual/how-to-send-file-upload.html | 4 +- ...-or-other-attributes-to-html-elements.html | 4 +- ...w-to-stop-default-behaviour-of-events.html | 4 +- ...t-parameters-or-parameters-in-the-url.html | 4 +- 7.1/manual/how-to-write-a-json-service.html | 4 +- 7.1/manual/how-to-write-forms.html | 4 +- .../how-to-write-titles-and-paragraphs.html | 4 +- 7.1/manual/html.html | 4 +- 7.1/manual/interaction.html | 4 +- 7.1/manual/intro.html | 8 +- 7.1/manual/lwt.html | 4 +- 7.1/manual/macaque.html | 4 +- 7.1/manual/misc.html | 4 +- 7.1/manual/mobile.html | 4 +- 7.1/manual/music.html | 4 +- 7.1/manual/ocsipersist.html | 4 +- 7.1/manual/pictures.html | 4 +- 7.1/manual/reactivemediaplayer.html | 4 +- 7.1/manual/rest.html | 4 +- 7.1/manual/start.html | 4 +- 7.1/manual/tutoreact.html | 4 +- 7.1/manual/tutowidgets.html | 4 +- dev/manual/application.html | 4 +- dev/manual/basics-server.html | 392 ++++++++++++++++++ dev/manual/basics.html | 35 +- dev/manual/basicwebsite.html | 155 ------- dev/manual/chat.html | 4 +- dev/manual/custom-conf.html | 4 +- dev/manual/hash-password.html | 4 +- ...e-a-cryptographically-safe-identifier.html | 4 +- .../how-does-a-page-s-source-code-look.html | 4 +- dev/manual/how-to-add-a-div.html | 4 +- dev/manual/how-to-add-a-favicon.html | 4 +- .../how-to-add-a-javascript-script.html | 4 +- dev/manual/how-to-add-a-list.html | 4 +- ...to-add-a-select-or-other-form-element.html | 4 +- dev/manual/how-to-add-an-image.html | 4 +- dev/manual/how-to-add-css-stylesheet.html | 4 +- ...o-attach-ocaml-values-to-dom-elements.html | 4 +- ...-to-the-html-nodes-sent-to-the-client.html | 4 +- dev/manual/how-to-build-js-object.html | 4 +- ...server-side-function-from-client-side.html | 4 +- ...o-call-an-ocaml-function-from-js-code.html | 4 +- .../how-to-compile-my-ocsigen-pages.html | 4 +- ...nfigure-and-launch-the-ocsigen-server.html | 4 +- ...ding-on-data-entered-on-previous-ones.html | 4 +- ...-current-page-without-knowing-its-url.html | 4 +- .../how-to-detect-channel-disconnection.html | 4 +- ...-side-state-for-the-process-is-closed.html | 4 +- .../how-to-do-links-to-other-pages.html | 4 +- ...ow-to-implement-a-notification-system.html | 4 +- ...belonging-to-a-form-towards-a-service.html | 4 +- ...all-sessions-for-one-user-or-all-tabs.html | 4 +- ...e-browser-window-has-the-focus-or-not.html | 4 +- .../how-to-make-hello-world-in-ocsigen.html | 4 +- dev/manual/how-to-make-page-a-skeleton.html | 4 +- dev/manual/how-to-make-responsive-css.html | 4 +- ...-the-server-and-insert-it-in-the-page.html | 4 +- ...vice-that-decides-itself-what-to-send.html | 4 +- dev/manual/how-to-register-session-data.html | 4 +- ...r-without-stopping-the-client-process.html | 4 +- dev/manual/how-to-send-file-download.html | 4 +- dev/manual/how-to-send-file-upload.html | 4 +- ...-or-other-attributes-to-html-elements.html | 4 +- ...w-to-stop-default-behaviour-of-events.html | 4 +- ...t-parameters-or-parameters-in-the-url.html | 4 +- dev/manual/how-to-write-a-json-service.html | 4 +- dev/manual/how-to-write-forms.html | 4 +- .../how-to-write-titles-and-paragraphs.html | 4 +- dev/manual/html.html | 4 +- dev/manual/interaction.html | 4 +- dev/manual/intro.html | 8 +- dev/manual/lwt.html | 4 +- dev/manual/macaque.html | 4 +- dev/manual/misc.html | 4 +- dev/manual/mobile.html | 4 +- dev/manual/music.html | 4 +- dev/manual/ocsipersist.html | 4 +- dev/manual/pictures.html | 4 +- dev/manual/reactivemediaplayer.html | 4 +- dev/manual/rest.html | 4 +- dev/manual/start.html | 4 +- dev/manual/tutoreact.html | 4 +- dev/manual/tutowidgets.html | 4 +- 124 files changed, 1044 insertions(+), 600 deletions(-) create mode 100644 7.1/manual/basics-server.html delete mode 100644 7.1/manual/basicwebsite.html create mode 100644 dev/manual/basics-server.html delete mode 100644 dev/manual/basicwebsite.html diff --git a/7.1/manual/application.html b/7.1/manual/application.html index dd446bfc..1a28c1a8 100644 --- a/7.1/manual/application.html +++ b/7.1/manual/application.html @@ -41,9 +41,9 @@
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    Writing a client/server Eliom application

    In this chapter, we will write a collaborative +

    Writing a client/server Eliom application

    In this chapter, we will write a collaborative drawing application. It is a client/server web application displaying an area where users can draw using the mouse, and see what other users are drawing at the same time and in real-time. diff --git a/7.1/manual/basics-server.html b/7.1/manual/basics-server.html new file mode 100644 index 00000000..b34b60db --- /dev/null +++ b/7.1/manual/basics-server.html @@ -0,0 +1,392 @@ +Server-side Web sites in one page

    Warning: Reason support is experimental. +We are looking for beta-tester and contributors. +

    Server-side Web sites in one page

    While Eliom is well known for its unique client-server programming +model, it is also perfectly suited to programming more traditional +websites. This page describes how you can generate Web pages in OCaml, +and handle links, forms, page parameters, sessions, etc. You will see +that you can get very quickly a working Web site without having to learn +innovative concepts and this might be enough for your needs. +

    You will then learn how Eliom is simplifying the programming of very +common behaviours by introducing innovative concepts like scoped +sessions or continuation-based Web programming. +

    Programming with Eliom will make your website ready for future +evolutions by allowing you to introduce progressively client-side +features like event handlers, fully in OCaml. You will even be able to +turn your website into a distributed client-server Web app, +and even a mobile app if needed in the future, without having to rewrite +anything. +

    Table of contents

    OCaml

    This programming guide assumes you know the OCaml language. +Many resources and books are available online.

    Lwt

    Lwt is a concurrent programming library for OCaml, initially written +by Jérôme Vouillon in 2001 for the +Unison file synchronizer. +It provides an alternative to the more usual preemptive threads approach +for programming concurrent applications, that avoids most problems of concurrent +data access and deadlocks. +It is used by Ocsigen Server and Eliom and has now become one of the +standard ways to implement concurrent applications in OCaml. +All your Web sites must be written in Lwt-compatible way! +

    How it works

    Instead of calling blocking functions, like Unix.sleep +or Unix.read, that could block the entire program, replace them +by their cooperative counterparts (Lwt_unix.sleep, +Lwt_unix.read, etc.). Instead of taking time to execute, +they always return immediately a promise of the result, +of type 'a Lwt.t. This type is abstract, and the only way +to use the result is to bind a function to the promise. +Lwt.bind p f means: "when promise p is completed, give its result +to function f". +

    Syntax let%lwt x = p in e is equivalent to Lwt.bind p (fun x -> e) +and makes it very natural to sequentialize computations without blocking the rest +of the program.

    To learn Lwt, read this short tutorial, or its user manual.

    Eliom: Services

    The following code shows how to create a service that answers +for requests at URL http://.../aaa/bbb, by invoking an +Ocaml function f of type: +

    f : (string * string) list -> unit -> string Lwt.t

    Function f generates HTML as a string, taking as first argument the list +of URL parameters (GET parameters), and as second argument the list of POST +parameters (here none). +

    let f _ () =
    +  Lwt.return "<html><head><title>Hello world</title></head><body>Welcome</body></html>"
    +
    +let myservice =
    +  Eliom_service.create
    +    ~path:(Eliom_service.Path ["aaa"; "bbb"])
    +    ~meth:(Eliom_service.Get Eliom_parameter.any)
    +    ()
    +
    +let () =
    +  Eliom_registration.Html_text.register
    +    ~service:myservice
    +    f

    Eliom_service.Get Eliom_parameter.any means that the service uses the GET HTTP method +and takes any GET parameter. +

    Module Eliom_registration.Html_text is used to register a service sending +HTML as strings. But we recommend to used typed-HTML instead (see below).

    Compiling

    Eliom provides an helper program called eliom-distillery to create your projects easily, with the right dune configuration and all default directories you usually need for a Web application (static files, server logs, database, etc.). We will show how to use eliom-distillery in another section below. +

    In this section, we will show how to compile and run a server-side only Web site by creating your project manually. +

    opam install eliom
    +dune init proj --kind=lib mysite
    +cd mysite
    +

    Add (libraries eliom.server) into file lib/dune. +

    Create your .ml files in directory lib. +For example, copy the definition and registration of service myservice above. +

    Compile: +

    dune build
    +

    Create a configuration file mysite.conf with this content on your project root directory: +

    <ocsigen>
    +  <server>
    +    <port>8080</port>
    +
    +    <logdir>local/var/log/mysite</logdir>
    +    <datadir>local/var/data/mysite</datadir>
    +    <charset>utf-8</charset>
    +
    +    <commandpipe>local/var/run/mysite-cmd</commandpipe>
    +    <extension findlib-package="ocsigenserver.ext.staticmod"/>
    +    <extension findlib-package="ocsipersist.sqlite"/>
    +    <extension findlib-package="eliom.server">
    +      <ignoredgetparams regexp="utm_[a-z]*|[a-z]*clid|li_fat_id"/>
    +    </extension>
    +    <host hostfilter="*">
    +      <static dir="static" />
    +      <static dir="local/var/www/mysite/eliom" />
    +      <eliommodule module="_build/default/lib/mysite.cma" />
    +      <eliom/>
    +    </host>
    +  </server>
    +</ocsigen>
    +

    Create the missing directories: +

    mkdir -p local/var/log/mysite
    +mkdir -p local/var/data/mysite
    +mkdir -p local/var/run
    +

    Launch the application: +

    ocsigenserver -c mysite.conf
    +

    Open URL http://localhost:8080/aaa/bbb with your browser.

    TyXML: typing HTML

    TyXML statically checks that your OCaml functions will never +generate wrong HTML. For example a program that could generate a paragraph +containing another paragraph will be rejected at compile time. +

    Example of use: +

    let open Eliom_content.Html.F in
    +html
    +  (head (title (txt "Ex")) [])
    +  (body [h1 ~a:[a_id "toto"; a_class ["blah"; "blih"]]
    +           [txt "Hallo!"]])

    How it works

    TyXML builds the page as an OCaml data-structure using a construction function +for each HTML tag. These functions take as parameters and return nodes +of type 'a elt where 'a is a polymorphic variant type added in the +module signature to constrain usage (phantom type).

    Example of typing error

    p [p [txt "Aïe"]]
    +   ^^^^^^^^^^^^^
    +Error: This expression has type
    +         ([> Html_types.p ] as 'a) Eliom_content.Html.F.elt =
    +           'a Eliom_content.Html.elt
    +       but an expression was expected of type
    +         ([< Html_types.p_content_fun ] as 'b) Eliom_content.Html.F.elt =
    +           'b Eliom_content.Html.elt
    +       Type 'a = [> `P ] is not compatible with type
    +         'b =
    +           [< `A of Html_types.phrasing_without_interactive
    +            | `Abbr
    +            | `Audio of Html_types.phrasing_without_media
    +            ...
    +            | `Output
    +            | `PCDATA
    +            | `Progress
    +            | `Q
    +            ...
    +            | `Wbr ]
    +       The second variant type does not allow tag(s) `P

    Read more about TyXML in this short tutorial or in its user manual.

    Eliom: Service returning typed HTML

    To use typed HTML, just replace module Eliom_registration.Html_text +by Eliom_registration.Html: +

    let f _ () =
    +  Lwt.return
    +    Eliom_content.Html.F.(html (head (title (txt "")) [])
    +                               (body [h1 [txt myparam]]))
    +
    +let myservice =
    +  Eliom_service.create
    +    ~path:(Eliom_service.Path ["aaa"; "bbb"])
    +    ~meth:(Eliom_service.Get Eliom_parameter.any)
    +    ()
    +
    +let () =
    +  Eliom_registration.Html.register
    +    ~service:myservice
    +    f

    Outputs

    Services can return a typed HTML page as in the example above, but also +any other kind of result. To choose the return type, use the register function +from the corresponding submodule of +Eliom_registration: +

    HtmlServices returning typed HTML pages
    Html_textServices returning untyped HTML pages as strings
    AppApply this functor to generate registration functions for services belonging to an Eliom client/server application. These services also return typed HTML pages, but Eliom will automatically add the client-side program as a JS file, and all the data needed (values of all injections, etc.)
    FlowServices returning portions of HTML pages.
    ActionServices performing actions (server side effects) with or without reloading the page (e.g. login, logout, payment, modification of user information...)
    FilesServe files from the server hard drive
    OcamlServices returning OCaml values to be sent to a client side OCaml program (this kind of services is used as low level interface for server functions – see below)
    StringServices returning any OCaml string (array of byte)
    RedirectionServices returning an HTTP redirection to another service
    AnyTo be used to make the service chose what it sends. Call function send from the corresponding module to choose the output.
    CustomizeApply this functor to define your own registration module

    Eliom: Typing page parameters

    Instead of taking GET parameters as an untyped string * string +association list, you can ask Eliom to decode and check parameter types +automatically. +

    For example, the following code defines a service at URL /foo, +that will use GET HTTP method, and take one parameter of type string, +named s, and one of type int, named i. +

    let myservice =
    +  Eliom_service.create
    +    ~path:(Eliom_service.Path ["foo"])
    +    ~meth:(Eliom_service.Get (Eliom_parameter.(string "s" ** int "i")))
    +    ()

    Then register an OCaml function as handler on this service: +

    let () =
    +  Eliom_registration.Html.register ~service:myservice
    +    (fun (s, i) () ->
    +      Lwt.return
    +         Eliom_content.Html.F.(html (head (title (txt "")) [])
    +                                    (body [h1 [txt (s^string_of_int i)]])))

    The handler takes as first parameter the GET page parameters, typed according to +the parameter specification given while creating the service. +The second parameter is for POST parameters (see below). +

    Recompile you program, and to to URL http://localhost:8080/foo?s=hello&i=22 +to see the result. +

    Parameters

    Module Eliom_parameter +is used to describe the type of service parameters. +

    Examples: +

    Eliom_parameter.(int "i" ** (string "s" ** bool "b"))
    +   (* /path?i=42&s=toto&b=on *)
    +
    +Eliom_parameter.(int "i" ** opt (string "s"))
    +   (* An integer named i, and an optional string named s *)
    +
    +Eliom_parameter.(int "i" ** any)
    +   (* An integer named i, and any other parameters, as an association list
    +      of type (string * string) list *)
    +
    +Eliom_parameter.(set string "s")
    +   (* /path?s=toto&s=titi&s=bobo *)
    +
    +Eliom_parameter.(list "l" (int "i"))
    +   (* /path?l[0]=11&l[1]=2&l[2]=42 *)
    +
    +Eliom_parameter.(suffix (int "year" ** int "month"))
    +   (* /path/2012/09 *)
    +
    +Eliom_parameter.(suffix_prod (int "year" ** int "month") (int "a"))
    +   (* /path/2012/09?a=4 *)

    Eliom: POST services

    To define a service with POST parameters, just change the ~meth parameter. +For example the following example takes the same GET parameters as the service +above, plus one POST parameter of type string, named "mypostparam". +

    ~meth:(Eliom_service.Post (Eliom_parameter.((string "s" ** int "i"),
    +                                            (string "mypostparam"))))

    Eliom: Other kinds of services

    Pathless services

    Pathless services are not identified by the path in the URL, +but by a name given as parameter. This name can be specified manually +using the ~name optional parameter, otherwise, a random name is +generated automatically. +This is used to implement server functions (see below). +If you are programming a client-server Eliom app, you will probably prefer server functions. +If you are using traditional service based Web programming, +use this to make a functionality available from all pages +(for example: log-in or log-out actions, add something in a shopping basket ...). +

    let pathless_service =
    +  Eliom_service.create
    +    ~name:"pathless_example"
    +    ~path:Eliom_service.No_path
    +    ~meth:(Eliom_service.Get (Eliom_parameter.(int "i")))
    +    ()

    More information +in the manual. +

    External services

    Use Eliom_service.extern to create +links or forms towards external Web sites as if they were Eliom services. +

    Predefined services

    Use service (Eliom_service.static_dir ()) +to create links towards static files (see example below for images). +

    Use service Eliom_service.reload_action and its variants to create links or forms towards the current URL (reload the page). From a client section, you can also call Os_lib.reload to reload the page and restart the client-side program. +

    Full documentation about services, a tutorial about traditional service based Web programming, API documentation of modules Eliom_service and Eliom_registration. +

    This example shows how to insert an image using static_dir: +

    img
    +  ~alt:"blip"
    +  ~src:(Eliom_content.Html.F.make_uri
    +         (Eliom_service.static_dir ())
    +         ["dir" ; "image.jpg"])
    +  ()

    Forms and links

    Function Eliom_content.Html.F.a creates typed links to services with their parameters. +For example, if home_service expects no parameter +and other_service expects a string and an optional int: +

    Eliom_content.Html.F.a ~service:home_service [txt "Home"] ()
    +Eliom_content.Html.F.a ~service:other_service [txt "Other"] ("hello", Some 4)

    Module Eliom_content.Html.F +defines the form's elements with the usual typed interface from TyXML. +Use this for example if you have a client side program and +want to manipulate the form's content from client side functions +(for example do a server function call with the form's elements' content). +

    In contrast, +module Eliom_content.Html.F.Form defines a typed interface +for form elements. Use this for links (see above), or if you program traditional +server-side Web interaction (with or without client-side program). This will statically check that your forms +match the services. Example: +

    let open Eliom_content.Html.F in
    +Form.post_form
    + ~service:connection_service
    +   (fun (name, password) ->
    +     [fieldset
    +       [label ~a:[a_for name] [txt "Name: "];
    +        Form.input ~input_type:`Text ~name:name Form.int;
    +        br ();
    +        Form.input
    +          ~a:[a_placeholder "Password"]
    +          ~input_type:`Password
    +          ~name:password
    +          Form.string;
    +        br ();
    +        Form.input ~input_type:`Submit ~value:"Connect" Form.string
    +      ]]) ()

    As you can see, function +Eliom_content.Html.F.Form.post_form +is used to create a form sending parameters using the POST HTTP method +(and similarly, get_form for GET method). +It takes the service as first parameter, and a function that will generate the form. +This function takes the names of the GET or POST parameters as arguments. +

    Form elements (like inputs) are also built from using the +Eliom_content.Html.F.Form module. +They take the names as parameters, and a last parameter (like Form.int or Form.string) to match the expected type.

    Sessions

    Session data is saved on server side in Eliom references. +

    The following Eliom reference will count the number of visits of a user on a page: +

    let%server count_ref =
    +  Eliom_reference.eref
    +    ~scope:Eliom_common.session
    +    0 (* default value for everyone *)

    And somewhere in your service handler, increment the counter: +

    let%lwt count = Eliom_reference.get count_ref in
    +Eliom_reference.set count_ref (count + 1);
    +Lwt.return ()

    With function Eliom_reference.eref_from_fun, +you can create Eliom references without initial value. The initial value is computed for the session +the first time you use it. +

    An Eliom reference can be persistant (value saved on hard drive) or volatile (in memory). +

    Scopes

    Sessions are relative to a browser, and implemented using browser cookies. +But Eliom allows to create Eliom references with other scopes than session: +

    global_scopeGlobal value for all the Web server
    site_scopeGlobal value for the Eliom app in that subsite of the Web site
    default_group_scopeValue for a group of sessions. For example Ocsigen Start defines a group of session for each user, making it possible to save server side data for all sessions of a user.
    default_session_scopeThe usual session data, based on browser cookies
    default_process_scopeServer side data for a given client-side process (a tab of the browser or a mobile app). This is available only with a client-server Eliom app.

    Applications based on Ocsigen Start use these scopes for user management. +Session or client process data are discarded when a user logs in or out. +But Ocsigen Start also defines scopes +Os_session.user_indep_session_scope +and +Os_session.user_indep_process_scope +which remain even if a user logs in or out. +

    When session group is not set (for example the user is not connected), +you can still use the group session scope: in that case, the group contains only +one session.

    Browser events

    Database access

    You can use your favourite database library with Ocsigen. +Ocsigen Start's template uses +PG'OCaml +(typed queries for Postgresql using a PPX syntax extension). +

    Here is an example, taken from Ocsigen Start's demo: +

    let get () =
    +  full_transaction_block (fun dbh ->
    +    [%pgsql dbh "SELECT lastname FROM ocsigen_start.users"])

    Continuation-based Web programming

    Internationalisation

    Ocsigen i18n +is an internationalisation library for your OCaml programs. +

    Create a .tsv file with, on each line, a key and the text in several languages: +

    welcome_message Welcome everybody!        Bienvenue à tous !      Benvenuti a tutti !
    +

    and Ocsigen i18n will automatically generate functions like this one: +

    let%shared welcome_message ?(lang = get_language ()) () () =
    +  match lang with
    +  | En -> [txt "Welcome everybody!"]
    +  | Fr -> [txt "Bienvenue à tous !"]
    +  | It -> [txt "Benvenuti a tutti !"]

    Ocsigen i18n also defines a syntax extension to use these functions: +

    Eliom_content.Html.F.h1 [%i18n welcome_message]

    Ocsigen i18n offers many other features: +

    • Text can be inserted as a TyXML node (as in the example above) or as a string (ex: [%i18n S.welcome_message]), +
    • Text can be parametrizable, or contain holes (ex: [%i18n welcome ~capitalize:true ~name:"William"]) +
    • .tsv file can be split into several modules +

    Have a look at the +README file +to see the full documentation, +and see examples in +Ocsigen Start's template.

    Ocsigen Server

    Ocsigen Server is a full featured Web server. +

    It is now based on Cohttp. +

    It has a powerful +extension mechanism that makes it easy to plug your own OCaml modules +for generating pages. Many extensions are already written: +

    Staticmod +
    to serve static files. +
    Eliom +
    to create reliable client/server Web applications +or Web sites in OCaml using advanced high level concepts. +
    Extendconfiguration +
    allows for more options in the configuration file. +
    Accesscontrol +
    restricts access to the sites from the config file (to requests coming from a subnet, containing some headers, etc.). +
    Authbasic +
    restricts access to the sites from the config file using Basic HTTP Authentication. +
    CGImod +
    serves CGI scripts. It may also be used to serve PHP through CGI. +
    Deflatemod +
    used to compress data before sending it to the client. +
    Redirectmod +
    sets redirections towards other Web sites from the configuration file. +
    Revproxy +
    a reverse proxy for Ocsigen Server. +It allows to ask another server to handle the request. +
    Rewritemod +
    changes incoming requests before sending them to other extensions. +
    Outputfilter +
    rewrites some parts of the output before sending it to the client. +
    Userconf +
    allows users to have their own configuration files. +
    Comet +
    facilitates server to client communications. +

    Ocsigen Server has a sophisticated configuration file mechanism allowing +complex configurations of sites.

    diff --git a/7.1/manual/basics.html b/7.1/manual/basics.html index 84a7efac..1cec1433 100644 --- a/7.1/manual/basics.html +++ b/7.1/manual/basics.html @@ -1,4 +1,4 @@ -All Ocsigen in one page

    Warning: Reason support is experimental. -We are looking for beta-tester and contributors. -

    Writing a basic Web site in OCaml

    The code of this tutorial has been tested against Eliom 6.0.
    -

    In this tutorial, we will show how to use the Ocsigen framework -(mainly Eliom) to write a lightweight Web site by generating pages -using OCaml functions. The goal is to show that, -even though Eliom makes it possible to write complete client-server -Web and mobile apps, -you can still use Eliom even if you don't need all these features (for example if you don't want HTML type checking or client-side features). Besides, this will allow you to extend your Web site in a full Web application if you need, later on. This tutorial is also a good overview of the basics of Eliom. -

    A service generating a page

    The following code shows how to create a service that answers -for requests at URL http://.../aaa/bbb, by invoking an -Ocaml function f of type: -

    f : (string * string) list -> unit -> string Lwt.t

    Function f generates HTML as a string, taking as argument the list of URL parameters (GET parameters). -

    let f _ () =
    -  Lwt.return "<html><head><title>Hello world</title></head><body>Welcome</body></html>"
    -
    -let main_service =
    -  (* create the service and register it at once *)
    -  Eliom_registration.Html_text.create
    -    ~path:(Eliom_service.Path ["aaa"; "bbb"])
    -    ~meth:(Eliom_service.Get Eliom_parameter.any)
    -    f

    Eliom_service.Get Eliom_parameter.any means that the service uses the GET method and takes any GET parameter. -

    We recommend to use the program eliom-distillery -to generate a template for your application (a Makefile and a default -configuration file for Ocsigen Server). -

    $ eliom-distillery -name mysite -template client-server.basic -target-directory mysite

    Modify file mysite.eliom to include the piece of code above, -instead of the default one. -Then compile and run the server by doing: -

    $ make test.byte

    Your page is now available at URL http://localhost:8080/aaa/bbb. -

    If you dont want to use the Makefile provided by eliom-distillery, -just replace mysite.eliom by a file mysite.ml, -compile and run with -

    $ ocamlfind ocamlc -package eliom.server -thread -c mysite.ml
    -$ ocsigenserver -c mysite.conf

    where mysite.conf is adapted from -local/etc/mysite/mysite-test.conf -by replacing mysite.cma by your cmo. -

    POST service

    Services using the POST HTTP method can be created and registered using the function -Eliom_registration.Html.create. -

    let g getp postp = Lwt.return ("t = " ^ (string_of_int postp))
    -
    -let post_service =
    -  Eliom_registration.Html_text.create
    -    ~path:(Eliom_service.Path [""])
    -    ~meth:(Eliom_service.Post (Eliom_parameter.any,Eliom_parameter.int "t"))
    -    g

    What if the user comes back later without POST parameters, for example -because he put a bookmark on this URL? -This may produce an error, to prevent this from happening we can -create a service without POST parameters using the same URL as the first one, -which will be used whenever the POST parameters are not provided. -

    let g' getp postp = Lwt.return "..."
    -
    -let get_service =
    -  Eliom_registration.Html_text.create
    -    ~path:(Eliom_service.Path [""])
    -    ~meth:(Eliom_service.Get Eliom_parameter.any)
    -    g'

    Going further

    That is probably all you need for a very basic Web site in OCaml. -

    Instead of generating HTML in OCaml strings, we highly recommend to use -typed HTML. It is very easy to use, once you have learned the basics, -and helps a lot to efficiently write modular and valid HTML. -To do this, use module -Eliom_registration.Html -instead of -Eliom_registration.Html_text. -See this -tutorial -for more information, a comprehensive documentation -here, -and a more advanced manual -here. -

    Have a look at Eliom's API documentation to see other kinds of services, -for example Eliom_registration.Redirection -to create HTTP redirections. -

    Eliom also has a way to typecheck forms and GET or POST parameters. -By giving a description of the parameters your service expects, -Eliom will check their presence automatically, and convert them -for you to OCaml types. -See -this tutorial -and this manual page. -

    Eliom also has other ways to identify services (besides just the PATH -in the URL). For example Eliom can identify a service just by a parameter -(whatever the path is). This is called non-attached coservices and -this makes it possible for instance to have the same feature on every page -(for example a connection service). -See -this tutorial -and this manual page. -

    One of the main features of Eliom is the ability to write complete -Web and mobile applications in OCaml. Annotations are used to -separate the code to be executed server-side from the client code. -Client functions are translated into Javascript using -Ocsigen Js_of_ocaml. -See -this tutorial for -a quick introduction, -or this one for a -more comprehensive one. -You can also have a look at -this manual page. -

    Another interesting feature of Eliom is its session model, that uses a -very simple interface to record session data server-side. -It is even possible to choose -the scope of this data: either a browser, or a tab, or even a group -of browsers (belonging for instance to a same user). -See -this section -and the beginning of -this manual page. -

    We suggest to continue your reading by one of these tutorials: -

    diff --git a/7.1/manual/chat.html b/7.1/manual/chat.html index 13834d1c..9e260211 100644 --- a/7.1/manual/chat.html +++ b/7.1/manual/chat.html @@ -41,9 +41,9 @@
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    Chat: Design Overview

    Chat is a chatting module and application, currently for conversations +

    Chat: Design Overview

    Chat is a chatting module and application, currently for conversations between two users each. (Extension for multi-user channels is left as an exercise to the user.)

    You can find the code here. diff --git a/7.1/manual/custom-conf.html b/7.1/manual/custom-conf.html index 6818265f..16316333 100644 --- a/7.1/manual/custom-conf.html +++ b/7.1/manual/custom-conf.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    Custom configuration options

    It is not convenient to have to edit the code to change some +

    Custom configuration options

    It is not convenient to have to edit the code to change some configurations, like the location where are saved the favorite images in the Graffiti tutorial (see: Saving favorite pictures). diff --git a/7.1/manual/hash-password.html b/7.1/manual/hash-password.html index 6d4d52c3..b7e9feb5 100644 --- a/7.1/manual/hash-password.html +++ b/7.1/manual/hash-password.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    Protecting your passwords

    For protecting the user passwords or other sensitive data, +

    Protecting your passwords

    For protecting the user passwords or other sensitive data, we can use ocaml-safepass.

    We can now write the encrypted password in our database diff --git a/7.1/manual/how-do-i-create-a-cryptographically-safe-identifier.html b/7.1/manual/how-do-i-create-a-cryptographically-safe-identifier.html index 714a5d19..c90a02f5 100644 --- a/7.1/manual/how-do-i-create-a-cryptographically-safe-identifier.html +++ b/7.1/manual/how-do-i-create-a-cryptographically-safe-identifier.html @@ -41,6 +41,6 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    +

    diff --git a/7.1/manual/how-does-a-page-s-source-code-look.html b/7.1/manual/how-does-a-page-s-source-code-look.html index 3edbde4d..06c05168 100644 --- a/7.1/manual/how-does-a-page-s-source-code-look.html +++ b/7.1/manual/how-does-a-page-s-source-code-look.html @@ -41,9 +41,9 @@
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How does a client-server app source code look like?

    Eliom client-server applications

    Eliom client-server applications are running in your browser for a certain lifetime and consist of one or several pages/URLs. +

    How does a client-server app source code look like?

    Eliom client-server applications

    Eliom client-server applications are running in your browser for a certain lifetime and consist of one or several pages/URLs. An application has its associated js file, which must have the same name (generated automatically by the default makefile and added automatically by Eliom in the page).

    For example, we define an application called example:

    module Example =
    diff --git a/7.1/manual/how-to-add-a-div.html b/7.1/manual/how-to-add-a-div.html
    index c518888e..83fd20d9 100644
    --- a/7.1/manual/how-to-add-a-div.html
    +++ b/7.1/manual/how-to-add-a-div.html
    @@ -41,9 +41,9 @@
     
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to add a div?

    div ~a:[a_class ["firstclass"; "secondclass"]] [txt "Hello!"]

    Required parameter: list containing other elements +

    How to add a div?

    div ~a:[a_class ["firstclass"; "secondclass"]] [txt "Hello!"]

    Required parameter: list containing other elements (Details of available elements in type Html_types.flow5).

    Optional parameter for attributes "a" (How to set and id, classes or other attributes to HTML elements?). diff --git a/7.1/manual/how-to-add-a-favicon.html b/7.1/manual/how-to-add-a-favicon.html index cc018e08..59dcbc64 100644 --- a/7.1/manual/how-to-add-a-favicon.html +++ b/7.1/manual/how-to-add-a-favicon.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to add a Favicon?

    A favicon is a file of type "ico" which contain a picture of size 16x16px. It is the picture that you can ususally see next to the title of the page on a browser. +

    How to add a Favicon?

    A favicon is a file of type "ico" which contain a picture of size 16x16px. It is the picture that you can ususally see next to the title of the page on a browser.

    favicon for Ocsigen.org

    By default, all browsers look for a file favicon.ico at the root of the website: diff --git a/7.1/manual/how-to-add-a-javascript-script.html b/7.1/manual/how-to-add-a-javascript-script.html index aa2d2d1f..abdaa88b 100644 --- a/7.1/manual/how-to-add-a-javascript-script.html +++ b/7.1/manual/how-to-add-a-javascript-script.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to add a Javacript script?

    If you have client-side programs on your website, you can use Eliom's client-server features, that will compile client side parts to JS using Ocsigen Js_of_ocaml, and include automatically the script in the page. But in some cases you may also want to include yourselves external JS scripts. +

    How to add a Javacript script?

    If you have client-side programs on your website, you can use Eliom's client-server features, that will compile client side parts to JS using Ocsigen Js_of_ocaml, and include automatically the script in the page. But in some cases you may also want to include yourselves external JS scripts.

    Include the script on the html header

    Javascript scripts are included in the header using the js_script function (defined in Error a_api: exception Dune__exe__Api.Error("invalid ocaml id \"Eliom_content.Html.D\"")).

    open Eliom_content.Html.D (* for make_uri an js_script *)
     
    diff --git a/7.1/manual/how-to-add-a-list.html b/7.1/manual/how-to-add-a-list.html
    index d78804a7..25a92c99 100644
    --- a/7.1/manual/how-to-add-a-list.html
    +++ b/7.1/manual/how-to-add-a-list.html
    @@ -41,9 +41,9 @@
     
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to add lists in a page?

    Simple list and ordered list

    Simple list
    ul
    +

    How to add lists in a page?

    Simple list and ordered list

    Simple list
    ul
         [li [txt "first item"];
          li [txt "second item"];
          li [txt "third item"];
    diff --git a/7.1/manual/how-to-add-a-select-or-other-form-element.html b/7.1/manual/how-to-add-a-select-or-other-form-element.html
    index e02f348a..dbd058a4 100644
    --- a/7.1/manual/how-to-add-a-select-or-other-form-element.html
    +++ b/7.1/manual/how-to-add-a-select-or-other-form-element.html
    @@ -41,9 +41,9 @@
     
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to add a select (or other form element)?

    In forms towards Eliom services:

    open Eliom_content
    +

    How to add a select (or other form element)?

    In forms towards Eliom services:

    open Eliom_content
     
     Html.D.Form.select ~name:select_name
       Html.D.Form.string (* type of the parameter *)
    diff --git a/7.1/manual/how-to-add-an-image.html b/7.1/manual/how-to-add-an-image.html
    index 3466f540..da7e60cd 100644
    --- a/7.1/manual/how-to-add-an-image.html
    +++ b/7.1/manual/how-to-add-an-image.html
    @@ -41,9 +41,9 @@
     
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to add an image?

    Internal image +

    How to add an image?

    Internal image

    img ~alt:("Ocsigen Logo")
           ~src:(make_uri
                   ~service:(Eliom_service.static_dir ())
    diff --git a/7.1/manual/how-to-add-css-stylesheet.html b/7.1/manual/how-to-add-css-stylesheet.html
    index 66f8c742..996c94a3 100644
    --- a/7.1/manual/how-to-add-css-stylesheet.html
    +++ b/7.1/manual/how-to-add-css-stylesheet.html
    @@ -41,9 +41,9 @@
     
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to add a CSS stylesheet?

    Warning: css_link and make_uri come from Eliom_content.Html.D module. This module is opened for each piece of code +

    How to add a CSS stylesheet?

    Warning: css_link and make_uri come from Eliom_content.Html.D module. This module is opened for each piece of code

    CSS stylesheet are included in the header using the css_link function.

    css_link
          ~uri:(make_uri (Eliom_service.static_dir ())
    diff --git a/7.1/manual/how-to-attach-ocaml-values-to-dom-elements.html b/7.1/manual/how-to-attach-ocaml-values-to-dom-elements.html
    index 51217a72..3b1ee0d0 100644
    --- a/7.1/manual/how-to-attach-ocaml-values-to-dom-elements.html
    +++ b/7.1/manual/how-to-attach-ocaml-values-to-dom-elements.html
    @@ -41,9 +41,9 @@
     
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to attach OCaml values to DOM elements?

    It is often convenient to attach OCaml values to certain elements of +

    How to attach OCaml values to DOM elements?

    It is often convenient to attach OCaml values to certain elements of the page. There are several ways to achieve this.

    • The first possibility is to use DATA attributes (for example if the page is generated on server side). diff --git a/7.1/manual/how-to-attach-ocaml-values-to-the-html-nodes-sent-to-the-client.html b/7.1/manual/how-to-attach-ocaml-values-to-the-html-nodes-sent-to-the-client.html index 24464488..a6362002 100644 --- a/7.1/manual/how-to-attach-ocaml-values-to-the-html-nodes-sent-to-the-client.html +++ b/7.1/manual/how-to-attach-ocaml-values-to-the-html-nodes-sent-to-the-client.html @@ -41,6 +41,6 @@
    • Blog
    • Installation
    • Source code -

    Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    +

    diff --git a/7.1/manual/how-to-build-js-object.html b/7.1/manual/how-to-build-js-object.html index 83cff498..690c55f7 100644 --- a/7.1/manual/how-to-build-js-object.html +++ b/7.1/manual/how-to-build-js-object.html @@ -41,9 +41,9 @@
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to build js object?

    Use syntax new%js: +

    How to build js object?

    Use syntax new%js:

    Example:

    let get_timestamp () =
       let date = new%js Js.date_now in
    diff --git a/7.1/manual/how-to-call-a-server-side-function-from-client-side.html b/7.1/manual/how-to-call-a-server-side-function-from-client-side.html
    index 834575e4..405559b9 100644
    --- a/7.1/manual/how-to-call-a-server-side-function-from-client-side.html
    +++ b/7.1/manual/how-to-call-a-server-side-function-from-client-side.html
    @@ -41,9 +41,9 @@
     
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to call a server-side function from client-side?

    It is possible to call server-side functions in client-side. +

    How to call a server-side function from client-side?

    It is possible to call server-side functions in client-side. For security reasons, these functions must first be declared explicitely as RPCs (with the type of their argument). diff --git a/7.1/manual/how-to-call-an-ocaml-function-from-js-code.html b/7.1/manual/how-to-call-an-ocaml-function-from-js-code.html index 5db2b913..2a444144 100644 --- a/7.1/manual/how-to-call-an-ocaml-function-from-js-code.html +++ b/7.1/manual/how-to-call-an-ocaml-function-from-js-code.html @@ -41,6 +41,6 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to call an OCaml function from JS code?

    Have a look at function Js.wrap_callback

    +

    How to call an OCaml function from JS code?

    Have a look at function Js.wrap_callback

    diff --git a/7.1/manual/how-to-compile-my-ocsigen-pages.html b/7.1/manual/how-to-compile-my-ocsigen-pages.html index d2ceee3e..93ec3b2d 100644 --- a/7.1/manual/how-to-compile-my-ocsigen-pages.html +++ b/7.1/manual/how-to-compile-my-ocsigen-pages.html @@ -41,9 +41,9 @@
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to compile my Ocsigen pages?

    Eliom distillery

    Eliom-distillery will help you to build your client-server application +

    How to compile my Ocsigen pages?

    Eliom distillery

    Eliom-distillery will help you to build your client-server application using Eliom. It comes with several templates ("client-server.basic", "os.pgocaml", and more to come ...). diff --git a/7.1/manual/how-to-configure-and-launch-the-ocsigen-server.html b/7.1/manual/how-to-configure-and-launch-the-ocsigen-server.html index 6edfba03..fb503610 100644 --- a/7.1/manual/how-to-configure-and-launch-the-ocsigen-server.html +++ b/7.1/manual/how-to-configure-and-launch-the-ocsigen-server.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to configure and launch the Ocsigen Server?

    Default configuration file

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to create a form wizard (sequence of pages depending on data entered on previous ones)?

    The solution to implement wizard-like forms (that is a sequence of pages +

    How to create a form wizard (sequence of pages depending on data entered on previous ones)?

    The solution to implement wizard-like forms (that is a sequence of pages depending on data entered on previous ones) is to create dynamically new services especially for one user. If you use session data (eliom references) it won't work if you have several tabs on the same site (or if you use the diff --git a/7.1/manual/how-to-create-link-to-a-current-page-without-knowing-its-url.html b/7.1/manual/how-to-create-link-to-a-current-page-without-knowing-its-url.html index b77fdbcb..193e1b9b 100644 --- a/7.1/manual/how-to-create-link-to-a-current-page-without-knowing-its-url.html +++ b/7.1/manual/how-to-create-link-to-a-current-page-without-knowing-its-url.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to create a link to the current page (without knowing its URL)?

    Void coservices are here for that: +

    How to create a link to the current page (without knowing its URL)?

    Void coservices are here for that:

    a ~service:Eliom_service.reload_action
       [txt "Click to reload"] ();

    More information in Eliom's manual, and API documentation of diff --git a/7.1/manual/how-to-detect-channel-disconnection.html b/7.1/manual/how-to-detect-channel-disconnection.html index 976269aa..986d2709 100644 --- a/7.1/manual/how-to-detect-channel-disconnection.html +++ b/7.1/manual/how-to-detect-channel-disconnection.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to detect channel disconnection

    Question

    Is there a way to detect that some Eliom_comet channel became +

    How to detect channel disconnection

    Question

    Is there a way to detect that some Eliom_comet channel became disconnected? I would like to warn the user if the server becomes unreachable.

    Answer

    If you are using Ocsigen-start, you probably have nothing to do. diff --git a/7.1/manual/how-to-detect-on-client-side-that-the-server-side-state-for-the-process-is-closed.html b/7.1/manual/how-to-detect-on-client-side-that-the-server-side-state-for-the-process-is-closed.html index cb0347a8..1f6e73f0 100644 --- a/7.1/manual/how-to-detect-on-client-side-that-the-server-side-state-for-the-process-is-closed.html +++ b/7.1/manual/how-to-detect-on-client-side-that-the-server-side-state-for-the-process-is-closed.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to detect on client side that the server side state for the process is closed?

    If you are using Ocsigen-start, you probably have nothing to do. +

    How to detect on client side that the server side state for the process is closed?

    If you are using Ocsigen-start, you probably have nothing to do. Ocsigen-start will monitor the life of sessions and close the process when needed.

    If you are not using Ocsigen-start, you must catch exceptions diff --git a/7.1/manual/how-to-do-links-to-other-pages.html b/7.1/manual/how-to-do-links-to-other-pages.html index c7d8b557..be3ed6b7 100644 --- a/7.1/manual/how-to-do-links-to-other-pages.html +++ b/7.1/manual/how-to-do-links-to-other-pages.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to do links to other pages?

    Examples: +

    How to do links to other pages?

    Examples:

    (* Link to a service without parameter: *)
     Html.D.a ~service:coucou [txt "coucou"] ();
     
    diff --git a/7.1/manual/how-to-implement-a-notification-system.html b/7.1/manual/how-to-implement-a-notification-system.html
    index 7dd147a0..3172346c 100644
    --- a/7.1/manual/how-to-implement-a-notification-system.html
    +++ b/7.1/manual/how-to-implement-a-notification-system.html
    @@ -41,9 +41,9 @@
     
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to implement a notification system?

    The easiest way for the server to send notifications to the client is +

    How to implement a notification system?

    The easiest way for the server to send notifications to the client is to use module Os_notif from Ocsigen-start (OS), but it requires to use OS's user management system. If you are not using OS, we recommend to get inspiration from diff --git a/7.1/manual/how-to-insert-raw-form-elements-not-belonging-to-a-form-towards-a-service.html b/7.1/manual/how-to-insert-raw-form-elements-not-belonging-to-a-form-towards-a-service.html index 17cc71f4..7767e8a0 100644 --- a/7.1/manual/how-to-insert-raw-form-elements-not-belonging-to-a-form-towards-a-service.html +++ b/7.1/manual/how-to-insert-raw-form-elements-not-belonging-to-a-form-towards-a-service.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to insert "raw" form elements (not belonging to a form towards a service)?

    Eliom redefines most forms elements (inputs, textareas, checkboxes, etc.) +

    How to insert "raw" form elements (not belonging to a form towards a service)?

    Eliom redefines most forms elements (inputs, textareas, checkboxes, etc.) to make possible to check the type of the form w.r.t. the type of the service.

    If you don't want that (for example if you want to use it only from a client side program), you can use "raw form elements" (that is, basic tyxml elements), using diff --git a/7.1/manual/how-to-iterate-on-all-sessions-for-one-user-or-all-tabs.html b/7.1/manual/how-to-iterate-on-all-sessions-for-one-user-or-all-tabs.html index 99a9d061..b7a16fa7 100644 --- a/7.1/manual/how-to-iterate-on-all-sessions-for-one-user-or-all-tabs.html +++ b/7.1/manual/how-to-iterate-on-all-sessions-for-one-user-or-all-tabs.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to iterate on all session belonging to the same user, or all tabs?

    You must create a session group for each user, then iterate on all +

    How to iterate on all session belonging to the same user, or all tabs?

    You must create a session group for each user, then iterate on all the sessions from this group, and possibly on all client processes for each session:

    (* We get the session group state for this user: *)
    diff --git a/7.1/manual/how-to-know-whether-the-browser-window-has-the-focus-or-not.html b/7.1/manual/how-to-know-whether-the-browser-window-has-the-focus-or-not.html
    index 1e711d2d..f24ab622 100644
    --- a/7.1/manual/how-to-know-whether-the-browser-window-has-the-focus-or-not.html
    +++ b/7.1/manual/how-to-know-whether-the-browser-window-has-the-focus-or-not.html
    @@ -41,9 +41,9 @@
     
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to know whether the browser window has the focus or not?

    Example: +

    How to know whether the browser window has the focus or not?

    Example:

    let has_focus = ref true
     
     let _ =
    diff --git a/7.1/manual/how-to-make-hello-world-in-ocsigen.html b/7.1/manual/how-to-make-hello-world-in-ocsigen.html
    index fee52739..9d18a5a6 100644
    --- a/7.1/manual/how-to-make-hello-world-in-ocsigen.html
    +++ b/7.1/manual/how-to-make-hello-world-in-ocsigen.html
    @@ -41,9 +41,9 @@
     
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to make a "hello world" in Ocsigen?

    Here it is! The famous "Hello World" for a client/server Eliom application: +

    How to make a "hello world" in Ocsigen?

    Here it is! The famous "Hello World" for a client/server Eliom application:

    open Eliom_content
     open Html.D
     open Eliom_parameter
    diff --git a/7.1/manual/how-to-make-page-a-skeleton.html b/7.1/manual/how-to-make-page-a-skeleton.html
    index 7289f6e8..9f816584 100644
    --- a/7.1/manual/how-to-make-page-a-skeleton.html
    +++ b/7.1/manual/how-to-make-page-a-skeleton.html
    @@ -41,9 +41,9 @@
     
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to make a page skeleton?

    The same header for all your pages

    When your site will grow, you will have several different services for pages which will often contain the same header informations. +

    How to make a page skeleton?

    The same header for all your pages

    When your site will grow, you will have several different services for pages which will often contain the same header informations.

    A great solutions to avoid code copy-pasting of these recurrent informations are to make a page skeleton function:

    let skeleton body_content =
       Lwt.return
    diff --git a/7.1/manual/how-to-make-responsive-css.html b/7.1/manual/how-to-make-responsive-css.html
    index 3253f77a..d95a3cf0 100644
    --- a/7.1/manual/how-to-make-responsive-css.html
    +++ b/7.1/manual/how-to-make-responsive-css.html
    @@ -41,9 +41,9 @@
     
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to make reponsive CSS with ocsigen?

    The best way to do that is to make one general css sheet plus three css sheets, small, medium and large screen using media queries, a feature introduced in CSS3. +

    How to make reponsive CSS with ocsigen?

    The best way to do that is to make one general css sheet plus three css sheets, small, medium and large screen using media queries, a feature introduced in CSS3.

    Write theses lines in your css sheets:

    @media only screen and (max-device-width: 480px)
     @media only screen and (min-device-width: 481px) and (max-device-width: 768px)
    diff --git a/7.1/manual/how-to-make-the-client-side-program-get-an-html-element-from-the-server-and-insert-it-in-the-page.html b/7.1/manual/how-to-make-the-client-side-program-get-an-html-element-from-the-server-and-insert-it-in-the-page.html
    index 011a3061..0af0d893 100644
    --- a/7.1/manual/how-to-make-the-client-side-program-get-an-html-element-from-the-server-and-insert-it-in-the-page.html
    +++ b/7.1/manual/how-to-make-the-client-side-program-get-an-html-element-from-the-server-and-insert-it-in-the-page.html
    @@ -41,9 +41,9 @@
     
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to make the client side program get an HTML element from the server and insert it in the page?

    A very convenient way to do that is to use RPCs : +

    How to make the client side program get an HTML element from the server and insert it in the page?

    A very convenient way to do that is to use RPCs :

    let%rpc get_mydiv (() : unit) : _ Lwt.t = div [ ... ]
    [%client
       ...
       let%lwt mydiv = get_mydiv () in
    diff --git a/7.1/manual/how-to-register-a-service-that-decides-itself-what-to-send.html b/7.1/manual/how-to-register-a-service-that-decides-itself-what-to-send.html
    index 2d1a3ebc..88738f8e 100644
    --- a/7.1/manual/how-to-register-a-service-that-decides-itself-what-to-send.html
    +++ b/7.1/manual/how-to-register-a-service-that-decides-itself-what-to-send.html
    @@ -41,9 +41,9 @@
     
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to register a service that decides itself what to send?

    Use Eliom_registration.Any. +

    How to register a service that decides itself what to send?

    Use Eliom_registration.Any.

    In the following example, we send an Html page or a redirection:

    let send_any =
       Eliom_registration.Any.create
    diff --git a/7.1/manual/how-to-register-session-data.html b/7.1/manual/how-to-register-session-data.html
    index f161e15e..74e87355 100644
    --- a/7.1/manual/how-to-register-session-data.html
    +++ b/7.1/manual/how-to-register-session-data.html
    @@ -41,9 +41,9 @@
     
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to register session data?

    It is very easy to register session data using Eliom references. +

    How to register session data?

    It is very easy to register session data using Eliom references. Just create an Eliom reference of scope session and its value will be different for each session (one session = one browser process).

    But most of the time, what we want is to store data for one user, diff --git a/7.1/manual/how-to-send-a-file-to-server-without-stopping-the-client-process.html b/7.1/manual/how-to-send-a-file-to-server-without-stopping-the-client-process.html index 3a6bcf0e..19705646 100644 --- a/7.1/manual/how-to-send-a-file-to-server-without-stopping-the-client-process.html +++ b/7.1/manual/how-to-send-a-file-to-server-without-stopping-the-client-process.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to send a file to the server without stopping the client process?

    This requires Eliom ≥ 3.1. +

    How to send a file to the server without stopping the client process?

    This requires Eliom ≥ 3.1.

    Due to security reasons, browsers have limitations on sending files. But if the file is chosen by the user through an input file element, there is a way to send it to the server. You can't use the server_function diff --git a/7.1/manual/how-to-send-file-download.html b/7.1/manual/how-to-send-file-download.html index 5bd933f6..f601409c 100644 --- a/7.1/manual/how-to-send-file-download.html +++ b/7.1/manual/how-to-send-file-download.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to send a file (download)?

    To serve file, you can use Ocsigen Server's module staticmod. +

    How to send a file (download)?

    To serve file, you can use Ocsigen Server's module staticmod. But it is also possible to ask Eliom to send files using module Eliom_registration.File, for example if you want Eliom to perform some privacy checks before sending, diff --git a/7.1/manual/how-to-send-file-upload.html b/7.1/manual/how-to-send-file-upload.html index 31fb06b4..241d2006 100644 --- a/7.1/manual/how-to-send-file-upload.html +++ b/7.1/manual/how-to-send-file-upload.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to send a file (upload)?

    To upload a file, use Eliom_parameter.file as service parameter type. +

    How to send a file (upload)?

    To upload a file, use Eliom_parameter.file as service parameter type.

    Ocsigen server will save the file at a temporary location and keep it there during the request. Then the file will be removed. You must link it somewhere else on the disk yourself if you want to keep it. diff --git a/7.1/manual/how-to-set-and-id-classes-or-other-attributes-to-html-elements.html b/7.1/manual/how-to-set-and-id-classes-or-other-attributes-to-html-elements.html index a55d44d4..90ab8fad 100644 --- a/7.1/manual/how-to-set-and-id-classes-or-other-attributes-to-html-elements.html +++ b/7.1/manual/how-to-set-and-id-classes-or-other-attributes-to-html-elements.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to set and id, classes or other attributes to HTML elements?

    Mandatory element attributes are given as OCaml named parameters to +

    How to set and id, classes or other attributes to HTML elements?

    Mandatory element attributes are given as OCaml named parameters to constructions function.

    Optional element attributes are added using the optional OCaml parameter "?a" which is more or less available for every HTML5 elements. This parameter is taking a list of attributes compatible with the element.

    div ~a:[a_class ["red";"shadow"];
    diff --git a/7.1/manual/how-to-stop-default-behaviour-of-events.html b/7.1/manual/how-to-stop-default-behaviour-of-events.html
    index 527fdf29..85017813 100644
    --- a/7.1/manual/how-to-stop-default-behaviour-of-events.html
    +++ b/7.1/manual/how-to-stop-default-behaviour-of-events.html
    @@ -41,9 +41,9 @@
     
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to stop default behaviour of events?

    Example: +

    How to stop default behaviour of events?

    Example:

    (** Disable Js event with stopping propagation during capture phase **)
     let disable_event event html_elt =
       Lwt.async (fun () ->
    diff --git a/7.1/manual/how-to-use-get-parameters-or-parameters-in-the-url.html b/7.1/manual/how-to-use-get-parameters-or-parameters-in-the-url.html
    index eabed96a..358a7cdd 100644
    --- a/7.1/manual/how-to-use-get-parameters-or-parameters-in-the-url.html
    +++ b/7.1/manual/how-to-use-get-parameters-or-parameters-in-the-url.html
    @@ -41,9 +41,9 @@
     
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to use GET parameters (parameters in the URL)?

    Pages are generated by services. +

    How to use GET parameters (parameters in the URL)?

    Pages are generated by services.

    Funcrions to create services using GET HTTP method take two mandatory parameters: ~path and ~get_params.

    path

    This argument is a list of string, corresponding to the URL where your page service can be found. diff --git a/7.1/manual/how-to-write-a-json-service.html b/7.1/manual/how-to-write-a-json-service.html index 0e0ef761..216b19d3 100644 --- a/7.1/manual/how-to-write-a-json-service.html +++ b/7.1/manual/how-to-write-a-json-service.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to write a JSON service?

    Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to write forms?

    To write an HTML form towards an Eliom service

    Just as we do for links, we provide form-building functions that call +

    How to write forms?

    To write an HTML form towards an Eliom service

    Just as we do for links, we provide form-building functions that call Eliom services in a safe manner. These functions are provided in the module Eliom_content.Html.D.Form (and diff --git a/7.1/manual/how-to-write-titles-and-paragraphs.html b/7.1/manual/how-to-write-titles-and-paragraphs.html index d45047b2..2e848b66 100644 --- a/7.1/manual/how-to-write-titles-and-paragraphs.html +++ b/7.1/manual/how-to-write-titles-and-paragraphs.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to write titles and paragrahs?

    Titles +

    How to write titles and paragrahs?

    Titles

    h3 [txt "Hello world"]

    There are 6 types of titles: h1, h2, h3, h4, h5 and h6. h1 is the largest and h6 is the smallest.

    Pagragraph

    p [txt "Some text, blah blah blah"]

    Required parameter: list containing other elements (content: Html_types.flow5 elements). diff --git a/7.1/manual/html.html b/7.1/manual/html.html index a3a7d5e2..5929b8a1 100644 --- a/7.1/manual/html.html +++ b/7.1/manual/html.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    HTML in 5 minutes

    The Tyxml library makes it possible to type-check HTML pages. +

    HTML in 5 minutes

    The Tyxml library makes it possible to type-check HTML pages. This means that your Ocsigen program will never generate pages which do not follow the recommendations from the W3C. For example a program that could generate a page with a paragraph diff --git a/7.1/manual/interaction.html b/7.1/manual/interaction.html index 0126c3c6..bdfbb5d6 100644 --- a/7.1/manual/interaction.html +++ b/7.1/manual/interaction.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    Implementing Web Interaction Using Eliom

    The code of this tutorial has been tested with Eliom 6.0.
    +

    Implementing Web Interaction Using Eliom

    The code of this tutorial has been tested with Eliom 6.0.

    This chapter of the tutorial explains how to create a small web site with several pages, users, sessions, and other elements of classical web development. Then, in diff --git a/7.1/manual/intro.html b/7.1/manual/intro.html index da62cd10..43ae32ff 100644 --- a/7.1/manual/intro.html +++ b/7.1/manual/intro.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    Introduction

    Ocsigen is a complete framework for developing Web and mobile apps +

    Introduction

    Ocsigen is a complete framework for developing Web and mobile apps using cutting edge techniques. It can be used to write simple server side Web sites, client-side programs, or complex client-server Web and mobile apps. @@ -97,8 +97,8 @@ if you plan to build a client-server Web (and/or mobile) app. It will help you to build your first app very quickly, with many code samples to study. -

  • Basic web site explains how to write a basic -Web site using OCaml functions +
  • Basic web site explains how to write a +website in OCaml, if you don't plan to have client-side features yet
  • If you are fluent in OCaml and want a quick introduction to client-server Web programming with Eliom, read tutorial diff --git a/7.1/manual/lwt.html b/7.1/manual/lwt.html index 0f68db76..35526c33 100644 --- a/7.1/manual/lwt.html +++ b/7.1/manual/lwt.html @@ -41,9 +41,9 @@
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    Lwt in 5 minutes

    Principles

    The Lwt library implements cooperative threads for OCaml. Cooperative +

    Lwt in 5 minutes

    Principles

    The Lwt library implements cooperative threads for OCaml. Cooperative threads are an alternative to preemptive threads (used in many languages and in OCaml's Thread module) that solve most common issues with preemptive threads: with Lwt, there is very limited risk diff --git a/7.1/manual/macaque.html b/7.1/manual/macaque.html index 55a42b4f..e0103494 100644 --- a/7.1/manual/macaque.html +++ b/7.1/manual/macaque.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    Type safe database requests using Macaque

    The Macaque library allows easy manipulation of Postgresql +

    Type safe database requests using Macaque

    The Macaque library allows easy manipulation of Postgresql database fully compatible with Lwt. (For more information see Macaque manual).

    Macaque is fuly compatible with PGOcaml, and both can be used diff --git a/7.1/manual/misc.html b/7.1/manual/misc.html index 6ed1cfa9..bd65d165 100644 --- a/7.1/manual/misc.html +++ b/7.1/manual/misc.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    Traditional web interaction in a client-server app

    The code of this tutorial has been tested with Eliom 6.0.
    +

    Traditional web interaction in a client-server app

    The code of this tutorial has been tested with Eliom 6.0.

    Multi-user collaborative drawing application

    We now want to turn our collaborative drawing application into a multi-user one. Each user will have their own drawing, where everyone can draw. diff --git a/7.1/manual/mobile.html b/7.1/manual/mobile.html index e3ecc6f1..fa5c7f71 100644 --- a/7.1/manual/mobile.html +++ b/7.1/manual/mobile.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    Mobile applications with Ocsigen

    Since Eliom 6.0, the Ocsigen framework provides infrastructure for +

    Mobile applications with Ocsigen

    Since Eliom 6.0, the Ocsigen framework provides infrastructure for building mobile applications. This enables rapid development of Android, iOS, and Windows Mobile apps with the same APIs and programming style as for a regular client-server Web application. In diff --git a/7.1/manual/music.html b/7.1/manual/music.html index 42f57e0a..562506e8 100644 --- a/7.1/manual/music.html +++ b/7.1/manual/music.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    Listening music

    We will add an audio player to the page that will stay when page +

    Listening music

    We will add an audio player to the page that will stay when page changes. This emphasises the fact that browsing inside an application does not stop the client side code: the music keeps playing when the content of the page and the url change. diff --git a/7.1/manual/ocsipersist.html b/7.1/manual/ocsipersist.html index b79c201d..8e410266 100644 --- a/7.1/manual/ocsipersist.html +++ b/7.1/manual/ocsipersist.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    Lightweight database using Ocsipersist

    Ocsipersist is a module for persistent references and tables. +

    Lightweight database using Ocsipersist

    Ocsipersist is a module for persistent references and tables.

    For persistent references, Eliom has a higher level interface, called Eliom references, and you probably want to use it instead of using Ocsipersist directly. diff --git a/7.1/manual/pictures.html b/7.1/manual/pictures.html index 48d0d5d2..03899a48 100644 --- a/7.1/manual/pictures.html +++ b/7.1/manual/pictures.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    Saving favorite pictures

    We will now add a button to the Graffiti application to save the current +

    Saving favorite pictures

    We will now add a button to the Graffiti application to save the current image. The images will be saved to the filesystem using the module Lwt_io. We will then make an Atom feed with the saved images using Syndic. diff --git a/7.1/manual/reactivemediaplayer.html b/7.1/manual/reactivemediaplayer.html index 6b0f8162..a02817b6 100644 --- a/7.1/manual/reactivemediaplayer.html +++ b/7.1/manual/reactivemediaplayer.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    Reactive Media Player

    You should read the Playing Music tutorial before this one. +

    Reactive Media Player

    You should read the Playing Music tutorial before this one.

    Since version 4, Eliom embeds the React library in order to provide reactive HTML elements diff --git a/7.1/manual/rest.html b/7.1/manual/rest.html index a82aaea1..0fb59474 100644 --- a/7.1/manual/rest.html +++ b/7.1/manual/rest.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    RESTful JSON API using Eliom

    This tutorial will show you how to create a simple, yet complete, REST API +

    RESTful JSON API using Eliom

    This tutorial will show you how to create a simple, yet complete, REST API using JSON as the serialization format.

    To illustrate our example, let's say we want to give access to a database of locations storing a description and coordinates (latitude and longitude). diff --git a/7.1/manual/start.html b/7.1/manual/start.html index f3406f97..cb105664 100644 --- a/7.1/manual/start.html +++ b/7.1/manual/start.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    Your first app in 5 minutes

    The code of this tutorial has been tested against Eliom 6.0.
    +

    Your first app in 5 minutes

    The code of this tutorial has been tested against Eliom 6.0.

    This tutorial describes how to get started with Ocsigen quickly. Thanks to an application template provided by the Ocsigen team, you will get to a working application with standard diff --git a/7.1/manual/tutoreact.html b/7.1/manual/tutoreact.html index 79f25538..f9cbb50b 100644 --- a/7.1/manual/tutoreact.html +++ b/7.1/manual/tutoreact.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    Client server reactive application with Ocsigen

    This is a short tutorial showing how to implement a simple reactive +

    Client server reactive application with Ocsigen

    This is a short tutorial showing how to implement a simple reactive client-server application using Js_of_ocaml, Eliom and Ocsigen Start.

    We are going to implement an application that can display a list of messages and diff --git a/7.1/manual/tutowidgets.html b/7.1/manual/tutowidgets.html index d10f4864..e26acb03 100644 --- a/7.1/manual/tutowidgets.html +++ b/7.1/manual/tutowidgets.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    Mini-tutorial: client-server widgets

    This short tutorial is an example of client-server Eliom application. +

    Mini-tutorial: client-server widgets

    This short tutorial is an example of client-server Eliom application. It gives an example of client-server widgets.

    It is probably a good starting point if you know OCaml well, and want to quickly learn how to write a client-server Eliom application with a diff --git a/dev/manual/application.html b/dev/manual/application.html index 891ab5cd..83a0e195 100644 --- a/dev/manual/application.html +++ b/dev/manual/application.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    Writing a client/server Eliom application

    In this chapter, we will write a collaborative +

    Writing a client/server Eliom application

    In this chapter, we will write a collaborative drawing application. It is a client/server web application displaying an area where users can draw using the mouse, and see what other users are drawing at the same time and in real-time. diff --git a/dev/manual/basics-server.html b/dev/manual/basics-server.html new file mode 100644 index 00000000..38460d26 --- /dev/null +++ b/dev/manual/basics-server.html @@ -0,0 +1,392 @@ +Server-side Web sites in one page

    Warning: Reason support is experimental. +We are looking for beta-tester and contributors. +

    Server-side Web sites in one page

    While Eliom is well known for its unique client-server programming +model, it is also perfectly suited to programming more traditional +websites. This page describes how you can generate Web pages in OCaml, +and handle links, forms, page parameters, sessions, etc. You will see +that you can get very quickly a working Web site without having to learn +innovative concepts and this might be enough for your needs. +

    You will then learn how Eliom is simplifying the programming of very +common behaviours by introducing innovative concepts like scoped +sessions or continuation-based Web programming. +

    Programming with Eliom will make your website ready for future +evolutions by allowing you to introduce progressively client-side +features like event handlers, fully in OCaml. You will even be able to +turn your website into a distributed client-server Web app, +and even a mobile app if needed in the future, without having to rewrite +anything. +

    Table of contents

    OCaml

    This programming guide assumes you know the OCaml language. +Many resources and books are available online.

    Lwt

    Lwt is a concurrent programming library for OCaml, initially written +by Jérôme Vouillon in 2001 for the +Unison file synchronizer. +It provides an alternative to the more usual preemptive threads approach +for programming concurrent applications, that avoids most problems of concurrent +data access and deadlocks. +It is used by Ocsigen Server and Eliom and has now become one of the +standard ways to implement concurrent applications in OCaml. +All your Web sites must be written in Lwt-compatible way! +

    How it works

    Instead of calling blocking functions, like Unix.sleep +or Unix.read, that could block the entire program, replace them +by their cooperative counterparts (Lwt_unix.sleep, +Lwt_unix.read, etc.). Instead of taking time to execute, +they always return immediately a promise of the result, +of type 'a Lwt.t. This type is abstract, and the only way +to use the result is to bind a function to the promise. +Lwt.bind p f means: "when promise p is completed, give its result +to function f". +

    Syntax let%lwt x = p in e is equivalent to Lwt.bind p (fun x -> e) +and makes it very natural to sequentialize computations without blocking the rest +of the program.

    To learn Lwt, read this short tutorial, or its user manual.

    Eliom: Services

    The following code shows how to create a service that answers +for requests at URL http://.../aaa/bbb, by invoking an +Ocaml function f of type: +

    f : (string * string) list -> unit -> string Lwt.t

    Function f generates HTML as a string, taking as first argument the list +of URL parameters (GET parameters), and as second argument the list of POST +parameters (here none). +

    let f _ () =
    +  Lwt.return "<html><head><title>Hello world</title></head><body>Welcome</body></html>"
    +
    +let myservice =
    +  Eliom_service.create
    +    ~path:(Eliom_service.Path ["aaa"; "bbb"])
    +    ~meth:(Eliom_service.Get Eliom_parameter.any)
    +    ()
    +
    +let () =
    +  Eliom_registration.Html_text.register
    +    ~service:myservice
    +    f

    Eliom_service.Get Eliom_parameter.any means that the service uses the GET HTTP method +and takes any GET parameter. +

    Module Eliom_registration.Html_text is used to register a service sending +HTML as strings. But we recommend to used typed-HTML instead (see below).

    Compiling

    Eliom provides an helper program called eliom-distillery to create your projects easily, with the right dune configuration and all default directories you usually need for a Web application (static files, server logs, database, etc.). We will show how to use eliom-distillery in another section below. +

    In this section, we will show how to compile and run a server-side only Web site by creating your project manually. +

    opam install eliom
    +dune init proj --kind=lib mysite
    +cd mysite
    +

    Add (libraries eliom.server) into file lib/dune. +

    Create your .ml files in directory lib. +For example, copy the definition and registration of service myservice above. +

    Compile: +

    dune build
    +

    Create a configuration file mysite.conf with this content on your project root directory: +

    <ocsigen>
    +  <server>
    +    <port>8080</port>
    +
    +    <logdir>local/var/log/mysite</logdir>
    +    <datadir>local/var/data/mysite</datadir>
    +    <charset>utf-8</charset>
    +
    +    <commandpipe>local/var/run/mysite-cmd</commandpipe>
    +    <extension findlib-package="ocsigenserver.ext.staticmod"/>
    +    <extension findlib-package="ocsipersist.sqlite"/>
    +    <extension findlib-package="eliom.server">
    +      <ignoredgetparams regexp="utm_[a-z]*|[a-z]*clid|li_fat_id"/>
    +    </extension>
    +    <host hostfilter="*">
    +      <static dir="static" />
    +      <static dir="local/var/www/mysite/eliom" />
    +      <eliommodule module="_build/default/lib/mysite.cma" />
    +      <eliom/>
    +    </host>
    +  </server>
    +</ocsigen>
    +

    Create the missing directories: +

    mkdir -p local/var/log/mysite
    +mkdir -p local/var/data/mysite
    +mkdir -p local/var/run
    +

    Launch the application: +

    ocsigenserver -c mysite.conf
    +

    Open URL http://localhost:8080/aaa/bbb with your browser.

    TyXML: typing HTML

    TyXML statically checks that your OCaml functions will never +generate wrong HTML. For example a program that could generate a paragraph +containing another paragraph will be rejected at compile time. +

    Example of use: +

    let open Eliom_content.Html.F in
    +html
    +  (head (title (txt "Ex")) [])
    +  (body [h1 ~a:[a_id "toto"; a_class ["blah"; "blih"]]
    +           [txt "Hallo!"]])

    How it works

    TyXML builds the page as an OCaml data-structure using a construction function +for each HTML tag. These functions take as parameters and return nodes +of type 'a elt where 'a is a polymorphic variant type added in the +module signature to constrain usage (phantom type).

    Example of typing error

    p [p [txt "Aïe"]]
    +   ^^^^^^^^^^^^^
    +Error: This expression has type
    +         ([> Html_types.p ] as 'a) Eliom_content.Html.F.elt =
    +           'a Eliom_content.Html.elt
    +       but an expression was expected of type
    +         ([< Html_types.p_content_fun ] as 'b) Eliom_content.Html.F.elt =
    +           'b Eliom_content.Html.elt
    +       Type 'a = [> `P ] is not compatible with type
    +         'b =
    +           [< `A of Html_types.phrasing_without_interactive
    +            | `Abbr
    +            | `Audio of Html_types.phrasing_without_media
    +            ...
    +            | `Output
    +            | `PCDATA
    +            | `Progress
    +            | `Q
    +            ...
    +            | `Wbr ]
    +       The second variant type does not allow tag(s) `P

    Read more about TyXML in this short tutorial or in its user manual.

    Eliom: Service returning typed HTML

    To use typed HTML, just replace module Eliom_registration.Html_text +by Eliom_registration.Html: +

    let f _ () =
    +  Lwt.return
    +    Eliom_content.Html.F.(html (head (title (txt "")) [])
    +                               (body [h1 [txt myparam]]))
    +
    +let myservice =
    +  Eliom_service.create
    +    ~path:(Eliom_service.Path ["aaa"; "bbb"])
    +    ~meth:(Eliom_service.Get Eliom_parameter.any)
    +    ()
    +
    +let () =
    +  Eliom_registration.Html.register
    +    ~service:myservice
    +    f

    Outputs

    Services can return a typed HTML page as in the example above, but also +any other kind of result. To choose the return type, use the register function +from the corresponding submodule of +Eliom_registration: +

    HtmlServices returning typed HTML pages
    Html_textServices returning untyped HTML pages as strings
    AppApply this functor to generate registration functions for services belonging to an Eliom client/server application. These services also return typed HTML pages, but Eliom will automatically add the client-side program as a JS file, and all the data needed (values of all injections, etc.)
    FlowServices returning portions of HTML pages.
    ActionServices performing actions (server side effects) with or without reloading the page (e.g. login, logout, payment, modification of user information...)
    FilesServe files from the server hard drive
    OcamlServices returning OCaml values to be sent to a client side OCaml program (this kind of services is used as low level interface for server functions – see below)
    StringServices returning any OCaml string (array of byte)
    RedirectionServices returning an HTTP redirection to another service
    AnyTo be used to make the service chose what it sends. Call function send from the corresponding module to choose the output.
    CustomizeApply this functor to define your own registration module

    Eliom: Typing page parameters

    Instead of taking GET parameters as an untyped string * string +association list, you can ask Eliom to decode and check parameter types +automatically. +

    For example, the following code defines a service at URL /foo, +that will use GET HTTP method, and take one parameter of type string, +named s, and one of type int, named i. +

    let myservice =
    +  Eliom_service.create
    +    ~path:(Eliom_service.Path ["foo"])
    +    ~meth:(Eliom_service.Get (Eliom_parameter.(string "s" ** int "i")))
    +    ()

    Then register an OCaml function as handler on this service: +

    let () =
    +  Eliom_registration.Html.register ~service:myservice
    +    (fun (s, i) () ->
    +      Lwt.return
    +         Eliom_content.Html.F.(html (head (title (txt "")) [])
    +                                    (body [h1 [txt (s^string_of_int i)]])))

    The handler takes as first parameter the GET page parameters, typed according to +the parameter specification given while creating the service. +The second parameter is for POST parameters (see below). +

    Recompile you program, and to to URL http://localhost:8080/foo?s=hello&i=22 +to see the result. +

    Parameters

    Module Eliom_parameter +is used to describe the type of service parameters. +

    Examples: +

    Eliom_parameter.(int "i" ** (string "s" ** bool "b"))
    +   (* /path?i=42&s=toto&b=on *)
    +
    +Eliom_parameter.(int "i" ** opt (string "s"))
    +   (* An integer named i, and an optional string named s *)
    +
    +Eliom_parameter.(int "i" ** any)
    +   (* An integer named i, and any other parameters, as an association list
    +      of type (string * string) list *)
    +
    +Eliom_parameter.(set string "s")
    +   (* /path?s=toto&s=titi&s=bobo *)
    +
    +Eliom_parameter.(list "l" (int "i"))
    +   (* /path?l[0]=11&l[1]=2&l[2]=42 *)
    +
    +Eliom_parameter.(suffix (int "year" ** int "month"))
    +   (* /path/2012/09 *)
    +
    +Eliom_parameter.(suffix_prod (int "year" ** int "month") (int "a"))
    +   (* /path/2012/09?a=4 *)

    Eliom: POST services

    To define a service with POST parameters, just change the ~meth parameter. +For example the following example takes the same GET parameters as the service +above, plus one POST parameter of type string, named "mypostparam". +

    ~meth:(Eliom_service.Post (Eliom_parameter.((string "s" ** int "i"),
    +                                            (string "mypostparam"))))

    Eliom: Other kinds of services

    Pathless services

    Pathless services are not identified by the path in the URL, +but by a name given as parameter. This name can be specified manually +using the ~name optional parameter, otherwise, a random name is +generated automatically. +This is used to implement server functions (see below). +If you are programming a client-server Eliom app, you will probably prefer server functions. +If you are using traditional service based Web programming, +use this to make a functionality available from all pages +(for example: log-in or log-out actions, add something in a shopping basket ...). +

    let pathless_service =
    +  Eliom_service.create
    +    ~name:"pathless_example"
    +    ~path:Eliom_service.No_path
    +    ~meth:(Eliom_service.Get (Eliom_parameter.(int "i")))
    +    ()

    More information +in the manual. +

    External services

    Use Eliom_service.extern to create +links or forms towards external Web sites as if they were Eliom services. +

    Predefined services

    Use service (Eliom_service.static_dir ()) +to create links towards static files (see example below for images). +

    Use service Eliom_service.reload_action and its variants to create links or forms towards the current URL (reload the page). From a client section, you can also call Os_lib.reload to reload the page and restart the client-side program. +

    Full documentation about services, a tutorial about traditional service based Web programming, API documentation of modules Eliom_service and Eliom_registration. +

    This example shows how to insert an image using static_dir: +

    img
    +  ~alt:"blip"
    +  ~src:(Eliom_content.Html.F.make_uri
    +         (Eliom_service.static_dir ())
    +         ["dir" ; "image.jpg"])
    +  ()

    Forms and links

    Function Eliom_content.Html.F.a creates typed links to services with their parameters. +For example, if home_service expects no parameter +and other_service expects a string and an optional int: +

    Eliom_content.Html.F.a ~service:home_service [txt "Home"] ()
    +Eliom_content.Html.F.a ~service:other_service [txt "Other"] ("hello", Some 4)

    Module Eliom_content.Html.F +defines the form's elements with the usual typed interface from TyXML. +Use this for example if you have a client side program and +want to manipulate the form's content from client side functions +(for example do a server function call with the form's elements' content). +

    In contrast, +module Eliom_content.Html.F.Form defines a typed interface +for form elements. Use this for links (see above), or if you program traditional +server-side Web interaction (with or without client-side program). This will statically check that your forms +match the services. Example: +

    let open Eliom_content.Html.F in
    +Form.post_form
    + ~service:connection_service
    +   (fun (name, password) ->
    +     [fieldset
    +       [label ~a:[a_for name] [txt "Name: "];
    +        Form.input ~input_type:`Text ~name:name Form.int;
    +        br ();
    +        Form.input
    +          ~a:[a_placeholder "Password"]
    +          ~input_type:`Password
    +          ~name:password
    +          Form.string;
    +        br ();
    +        Form.input ~input_type:`Submit ~value:"Connect" Form.string
    +      ]]) ()

    As you can see, function +Eliom_content.Html.F.Form.post_form +is used to create a form sending parameters using the POST HTTP method +(and similarly, get_form for GET method). +It takes the service as first parameter, and a function that will generate the form. +This function takes the names of the GET or POST parameters as arguments. +

    Form elements (like inputs) are also built from using the +Eliom_content.Html.F.Form module. +They take the names as parameters, and a last parameter (like Form.int or Form.string) to match the expected type.

    Sessions

    Session data is saved on server side in Eliom references. +

    The following Eliom reference will count the number of visits of a user on a page: +

    let%server count_ref =
    +  Eliom_reference.eref
    +    ~scope:Eliom_common.session
    +    0 (* default value for everyone *)

    And somewhere in your service handler, increment the counter: +

    let%lwt count = Eliom_reference.get count_ref in
    +Eliom_reference.set count_ref (count + 1);
    +Lwt.return ()

    With function Eliom_reference.eref_from_fun, +you can create Eliom references without initial value. The initial value is computed for the session +the first time you use it. +

    An Eliom reference can be persistant (value saved on hard drive) or volatile (in memory). +

    Scopes

    Sessions are relative to a browser, and implemented using browser cookies. +But Eliom allows to create Eliom references with other scopes than session: +

    global_scopeGlobal value for all the Web server
    site_scopeGlobal value for the Eliom app in that subsite of the Web site
    default_group_scopeValue for a group of sessions. For example Ocsigen Start defines a group of session for each user, making it possible to save server side data for all sessions of a user.
    default_session_scopeThe usual session data, based on browser cookies
    default_process_scopeServer side data for a given client-side process (a tab of the browser or a mobile app). This is available only with a client-server Eliom app.

    Applications based on Ocsigen Start use these scopes for user management. +Session or client process data are discarded when a user logs in or out. +But Ocsigen Start also defines scopes +Os_session.user_indep_session_scope +and +Os_session.user_indep_process_scope +which remain even if a user logs in or out. +

    When session group is not set (for example the user is not connected), +you can still use the group session scope: in that case, the group contains only +one session.

    Browser events

    Database access

    You can use your favourite database library with Ocsigen. +Ocsigen Start's template uses +PG'OCaml +(typed queries for Postgresql using a PPX syntax extension). +

    Here is an example, taken from Ocsigen Start's demo: +

    let get () =
    +  full_transaction_block (fun dbh ->
    +    [%pgsql dbh "SELECT lastname FROM ocsigen_start.users"])

    Continuation-based Web programming

    Internationalisation

    Ocsigen i18n +is an internationalisation library for your OCaml programs. +

    Create a .tsv file with, on each line, a key and the text in several languages: +

    welcome_message Welcome everybody!        Bienvenue à tous !      Benvenuti a tutti !
    +

    and Ocsigen i18n will automatically generate functions like this one: +

    let%shared welcome_message ?(lang = get_language ()) () () =
    +  match lang with
    +  | En -> [txt "Welcome everybody!"]
    +  | Fr -> [txt "Bienvenue à tous !"]
    +  | It -> [txt "Benvenuti a tutti !"]

    Ocsigen i18n also defines a syntax extension to use these functions: +

    Eliom_content.Html.F.h1 [%i18n welcome_message]

    Ocsigen i18n offers many other features: +

    • Text can be inserted as a TyXML node (as in the example above) or as a string (ex: [%i18n S.welcome_message]), +
    • Text can be parametrizable, or contain holes (ex: [%i18n welcome ~capitalize:true ~name:"William"]) +
    • .tsv file can be split into several modules +

    Have a look at the +README file +to see the full documentation, +and see examples in +Ocsigen Start's template.

    Ocsigen Server

    Ocsigen Server is a full featured Web server. +

    It is now based on Cohttp. +

    It has a powerful +extension mechanism that makes it easy to plug your own OCaml modules +for generating pages. Many extensions are already written: +

    Staticmod +
    to serve static files. +
    Eliom +
    to create reliable client/server Web applications +or Web sites in OCaml using advanced high level concepts. +
    Extendconfiguration +
    allows for more options in the configuration file. +
    Accesscontrol +
    restricts access to the sites from the config file (to requests coming from a subnet, containing some headers, etc.). +
    Authbasic +
    restricts access to the sites from the config file using Basic HTTP Authentication. +
    CGImod +
    serves CGI scripts. It may also be used to serve PHP through CGI. +
    Deflatemod +
    used to compress data before sending it to the client. +
    Redirectmod +
    sets redirections towards other Web sites from the configuration file. +
    Revproxy +
    a reverse proxy for Ocsigen Server. +It allows to ask another server to handle the request. +
    Rewritemod +
    changes incoming requests before sending them to other extensions. +
    Outputfilter +
    rewrites some parts of the output before sending it to the client. +
    Userconf +
    allows users to have their own configuration files. +
    Comet +
    facilitates server to client communications. +

    Ocsigen Server has a sophisticated configuration file mechanism allowing +complex configurations of sites.

    diff --git a/dev/manual/basics.html b/dev/manual/basics.html index 1963cfb8..20479733 100644 --- a/dev/manual/basics.html +++ b/dev/manual/basics.html @@ -1,4 +1,4 @@ -All Ocsigen in one page

    Warning: Reason support is experimental. -We are looking for beta-tester and contributors. -

    Writing a basic Web site in OCaml

    The code of this tutorial has been tested against Eliom 6.0.
    -

    In this tutorial, we will show how to use the Ocsigen framework -(mainly Eliom) to write a lightweight Web site by generating pages -using OCaml functions. The goal is to show that, -even though Eliom makes it possible to write complete client-server -Web and mobile apps, -you can still use Eliom even if you don't need all these features (for example if you don't want HTML type checking or client-side features). Besides, this will allow you to extend your Web site in a full Web application if you need, later on. This tutorial is also a good overview of the basics of Eliom. -

    A service generating a page

    The following code shows how to create a service that answers -for requests at URL http://.../aaa/bbb, by invoking an -Ocaml function f of type: -

    f : (string * string) list -> unit -> string Lwt.t

    Function f generates HTML as a string, taking as argument the list of URL parameters (GET parameters). -

    let f _ () =
    -  Lwt.return "<html><head><title>Hello world</title></head><body>Welcome</body></html>"
    -
    -let main_service =
    -  (* create the service and register it at once *)
    -  Eliom_registration.Html_text.create
    -    ~path:(Eliom_service.Path ["aaa"; "bbb"])
    -    ~meth:(Eliom_service.Get Eliom_parameter.any)
    -    f

    Eliom_service.Get Eliom_parameter.any means that the service uses the GET method and takes any GET parameter. -

    We recommend to use the program eliom-distillery -to generate a template for your application (a Makefile and a default -configuration file for Ocsigen Server). -

    $ eliom-distillery -name mysite -template client-server.basic -target-directory mysite

    Modify file mysite.eliom to include the piece of code above, -instead of the default one. -Then compile and run the server by doing: -

    $ make test.byte

    Your page is now available at URL http://localhost:8080/aaa/bbb. -

    If you dont want to use the Makefile provided by eliom-distillery, -just replace mysite.eliom by a file mysite.ml, -compile and run with -

    $ ocamlfind ocamlc -package eliom.server -thread -c mysite.ml
    -$ ocsigenserver -c mysite.conf

    where mysite.conf is adapted from -local/etc/mysite/mysite-test.conf -by replacing mysite.cma by your cmo. -

    POST service

    Services using the POST HTTP method can be created and registered using the function -Eliom_registration.Html.create. -

    let g getp postp = Lwt.return ("t = " ^ (string_of_int postp))
    -
    -let post_service =
    -  Eliom_registration.Html_text.create
    -    ~path:(Eliom_service.Path [""])
    -    ~meth:(Eliom_service.Post (Eliom_parameter.any,Eliom_parameter.int "t"))
    -    g

    What if the user comes back later without POST parameters, for example -because he put a bookmark on this URL? -This may produce an error, to prevent this from happening we can -create a service without POST parameters using the same URL as the first one, -which will be used whenever the POST parameters are not provided. -

    let g' getp postp = Lwt.return "..."
    -
    -let get_service =
    -  Eliom_registration.Html_text.create
    -    ~path:(Eliom_service.Path [""])
    -    ~meth:(Eliom_service.Get Eliom_parameter.any)
    -    g'

    Going further

    That is probably all you need for a very basic Web site in OCaml. -

    Instead of generating HTML in OCaml strings, we highly recommend to use -typed HTML. It is very easy to use, once you have learned the basics, -and helps a lot to efficiently write modular and valid HTML. -To do this, use module -Eliom_registration.Html -instead of -Eliom_registration.Html_text. -See this -tutorial -for more information, a comprehensive documentation -here, -and a more advanced manual -here. -

    Have a look at Eliom's API documentation to see other kinds of services, -for example Eliom_registration.Redirection -to create HTTP redirections. -

    Eliom also has a way to typecheck forms and GET or POST parameters. -By giving a description of the parameters your service expects, -Eliom will check their presence automatically, and convert them -for you to OCaml types. -See -this tutorial -and this manual page. -

    Eliom also has other ways to identify services (besides just the PATH -in the URL). For example Eliom can identify a service just by a parameter -(whatever the path is). This is called non-attached coservices and -this makes it possible for instance to have the same feature on every page -(for example a connection service). -See -this tutorial -and this manual page. -

    One of the main features of Eliom is the ability to write complete -Web and mobile applications in OCaml. Annotations are used to -separate the code to be executed server-side from the client code. -Client functions are translated into Javascript using -Ocsigen Js_of_ocaml. -See -this tutorial for -a quick introduction, -or this one for a -more comprehensive one. -You can also have a look at -this manual page. -

    Another interesting feature of Eliom is its session model, that uses a -very simple interface to record session data server-side. -It is even possible to choose -the scope of this data: either a browser, or a tab, or even a group -of browsers (belonging for instance to a same user). -See -this section -and the beginning of -this manual page. -

    We suggest to continue your reading by one of these tutorials: -

    diff --git a/dev/manual/chat.html b/dev/manual/chat.html index 19f8e1c2..c23ed6c7 100644 --- a/dev/manual/chat.html +++ b/dev/manual/chat.html @@ -41,9 +41,9 @@
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    Chat: Design Overview

    Chat is a chatting module and application, currently for conversations +

    Chat: Design Overview

    Chat is a chatting module and application, currently for conversations between two users each. (Extension for multi-user channels is left as an exercise to the user.)

    You can find the code here. diff --git a/dev/manual/custom-conf.html b/dev/manual/custom-conf.html index 5fdfb5b0..05b80484 100644 --- a/dev/manual/custom-conf.html +++ b/dev/manual/custom-conf.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    Custom configuration options

    It is not convenient to have to edit the code to change some +

    Custom configuration options

    It is not convenient to have to edit the code to change some configurations, like the location where are saved the favorite images in the Graffiti tutorial (see: Saving favorite pictures). diff --git a/dev/manual/hash-password.html b/dev/manual/hash-password.html index 1af203e1..01c9f146 100644 --- a/dev/manual/hash-password.html +++ b/dev/manual/hash-password.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    Protecting your passwords

    For protecting the user passwords or other sensitive data, +

    Protecting your passwords

    For protecting the user passwords or other sensitive data, we can use ocaml-safepass.

    We can now write the encrypted password in our database diff --git a/dev/manual/how-do-i-create-a-cryptographically-safe-identifier.html b/dev/manual/how-do-i-create-a-cryptographically-safe-identifier.html index 5f41f61a..04e6110a 100644 --- a/dev/manual/how-do-i-create-a-cryptographically-safe-identifier.html +++ b/dev/manual/how-do-i-create-a-cryptographically-safe-identifier.html @@ -41,6 +41,6 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    +

    diff --git a/dev/manual/how-does-a-page-s-source-code-look.html b/dev/manual/how-does-a-page-s-source-code-look.html index d29060e0..0da6faa0 100644 --- a/dev/manual/how-does-a-page-s-source-code-look.html +++ b/dev/manual/how-does-a-page-s-source-code-look.html @@ -41,9 +41,9 @@
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How does a client-server app source code look like?

    Eliom client-server applications

    Eliom client-server applications are running in your browser for a certain lifetime and consist of one or several pages/URLs. +

    How does a client-server app source code look like?

    Eliom client-server applications

    Eliom client-server applications are running in your browser for a certain lifetime and consist of one or several pages/URLs. An application has its associated js file, which must have the same name (generated automatically by the default makefile and added automatically by Eliom in the page).

    For example, we define an application called example:

    module Example =
    diff --git a/dev/manual/how-to-add-a-div.html b/dev/manual/how-to-add-a-div.html
    index d05e6274..9d75005d 100644
    --- a/dev/manual/how-to-add-a-div.html
    +++ b/dev/manual/how-to-add-a-div.html
    @@ -41,9 +41,9 @@
     
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to add a div?

    div ~a:[a_class ["firstclass"; "secondclass"]] [txt "Hello!"]

    Required parameter: list containing other elements +

    How to add a div?

    div ~a:[a_class ["firstclass"; "secondclass"]] [txt "Hello!"]

    Required parameter: list containing other elements (Details of available elements in type Html_types.flow5).

    Optional parameter for attributes "a" (How to set and id, classes or other attributes to HTML elements?). diff --git a/dev/manual/how-to-add-a-favicon.html b/dev/manual/how-to-add-a-favicon.html index 3c38cd2a..f124fb74 100644 --- a/dev/manual/how-to-add-a-favicon.html +++ b/dev/manual/how-to-add-a-favicon.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to add a Favicon?

    A favicon is a file of type "ico" which contain a picture of size 16x16px. It is the picture that you can ususally see next to the title of the page on a browser. +

    How to add a Favicon?

    A favicon is a file of type "ico" which contain a picture of size 16x16px. It is the picture that you can ususally see next to the title of the page on a browser.

    favicon for Ocsigen.org

    By default, all browsers look for a file favicon.ico at the root of the website: diff --git a/dev/manual/how-to-add-a-javascript-script.html b/dev/manual/how-to-add-a-javascript-script.html index b502a30a..b79dde02 100644 --- a/dev/manual/how-to-add-a-javascript-script.html +++ b/dev/manual/how-to-add-a-javascript-script.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to add a Javacript script?

    If you have client-side programs on your website, you can use Eliom's client-server features, that will compile client side parts to JS using Ocsigen Js_of_ocaml, and include automatically the script in the page. But in some cases you may also want to include yourselves external JS scripts. +

    How to add a Javacript script?

    If you have client-side programs on your website, you can use Eliom's client-server features, that will compile client side parts to JS using Ocsigen Js_of_ocaml, and include automatically the script in the page. But in some cases you may also want to include yourselves external JS scripts.

    Include the script on the html header

    Javascript scripts are included in the header using the js_script function (defined in Error a_api: exception Dune__exe__Api.Error("invalid ocaml id \"Eliom_content.Html.D\"")).

    open Eliom_content.Html.D (* for make_uri an js_script *)
     
    diff --git a/dev/manual/how-to-add-a-list.html b/dev/manual/how-to-add-a-list.html
    index 6a9ba627..933a7834 100644
    --- a/dev/manual/how-to-add-a-list.html
    +++ b/dev/manual/how-to-add-a-list.html
    @@ -41,9 +41,9 @@
     
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to add lists in a page?

    Simple list and ordered list

    Simple list
    ul
    +

    How to add lists in a page?

    Simple list and ordered list

    Simple list
    ul
         [li [txt "first item"];
          li [txt "second item"];
          li [txt "third item"];
    diff --git a/dev/manual/how-to-add-a-select-or-other-form-element.html b/dev/manual/how-to-add-a-select-or-other-form-element.html
    index 909d62ce..6c0f6b6a 100644
    --- a/dev/manual/how-to-add-a-select-or-other-form-element.html
    +++ b/dev/manual/how-to-add-a-select-or-other-form-element.html
    @@ -41,9 +41,9 @@
     
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to add a select (or other form element)?

    In forms towards Eliom services:

    open Eliom_content
    +

    How to add a select (or other form element)?

    In forms towards Eliom services:

    open Eliom_content
     
     Html.D.Form.select ~name:select_name
       Html.D.Form.string (* type of the parameter *)
    diff --git a/dev/manual/how-to-add-an-image.html b/dev/manual/how-to-add-an-image.html
    index ad08c3e3..1b697f78 100644
    --- a/dev/manual/how-to-add-an-image.html
    +++ b/dev/manual/how-to-add-an-image.html
    @@ -41,9 +41,9 @@
     
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to add an image?

    Internal image +

    How to add an image?

    Internal image

    img ~alt:("Ocsigen Logo")
           ~src:(make_uri
                   ~service:(Eliom_service.static_dir ())
    diff --git a/dev/manual/how-to-add-css-stylesheet.html b/dev/manual/how-to-add-css-stylesheet.html
    index d5911c19..8bbc47dd 100644
    --- a/dev/manual/how-to-add-css-stylesheet.html
    +++ b/dev/manual/how-to-add-css-stylesheet.html
    @@ -41,9 +41,9 @@
     
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to add a CSS stylesheet?

    Warning: css_link and make_uri come from Eliom_content.Html.D module. This module is opened for each piece of code +

    How to add a CSS stylesheet?

    Warning: css_link and make_uri come from Eliom_content.Html.D module. This module is opened for each piece of code

    CSS stylesheet are included in the header using the css_link function.

    css_link
          ~uri:(make_uri (Eliom_service.static_dir ())
    diff --git a/dev/manual/how-to-attach-ocaml-values-to-dom-elements.html b/dev/manual/how-to-attach-ocaml-values-to-dom-elements.html
    index 8c9b6768..ef53a6d8 100644
    --- a/dev/manual/how-to-attach-ocaml-values-to-dom-elements.html
    +++ b/dev/manual/how-to-attach-ocaml-values-to-dom-elements.html
    @@ -41,9 +41,9 @@
     
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to attach OCaml values to DOM elements?

    It is often convenient to attach OCaml values to certain elements of +

    How to attach OCaml values to DOM elements?

    It is often convenient to attach OCaml values to certain elements of the page. There are several ways to achieve this.

    • The first possibility is to use DATA attributes (for example if the page is generated on server side). diff --git a/dev/manual/how-to-attach-ocaml-values-to-the-html-nodes-sent-to-the-client.html b/dev/manual/how-to-attach-ocaml-values-to-the-html-nodes-sent-to-the-client.html index c0967c54..a75213e1 100644 --- a/dev/manual/how-to-attach-ocaml-values-to-the-html-nodes-sent-to-the-client.html +++ b/dev/manual/how-to-attach-ocaml-values-to-the-html-nodes-sent-to-the-client.html @@ -41,6 +41,6 @@
    • Blog
    • Installation
    • Source code -

    Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    +

    diff --git a/dev/manual/how-to-build-js-object.html b/dev/manual/how-to-build-js-object.html index 9ba1e9b2..65828b3f 100644 --- a/dev/manual/how-to-build-js-object.html +++ b/dev/manual/how-to-build-js-object.html @@ -41,9 +41,9 @@
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to build js object?

    Use syntax new%js: +

    How to build js object?

    Use syntax new%js:

    Example:

    let get_timestamp () =
       let date = new%js Js.date_now in
    diff --git a/dev/manual/how-to-call-a-server-side-function-from-client-side.html b/dev/manual/how-to-call-a-server-side-function-from-client-side.html
    index e1836f74..e7b984aa 100644
    --- a/dev/manual/how-to-call-a-server-side-function-from-client-side.html
    +++ b/dev/manual/how-to-call-a-server-side-function-from-client-side.html
    @@ -41,9 +41,9 @@
     
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to call a server-side function from client-side?

    It is possible to call server-side functions in client-side. +

    How to call a server-side function from client-side?

    It is possible to call server-side functions in client-side. For security reasons, these functions must first be declared explicitely as RPCs (with the type of their argument). diff --git a/dev/manual/how-to-call-an-ocaml-function-from-js-code.html b/dev/manual/how-to-call-an-ocaml-function-from-js-code.html index d448aa93..577b33b7 100644 --- a/dev/manual/how-to-call-an-ocaml-function-from-js-code.html +++ b/dev/manual/how-to-call-an-ocaml-function-from-js-code.html @@ -41,6 +41,6 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to call an OCaml function from JS code?

    Have a look at function Js.wrap_callback

    +

    How to call an OCaml function from JS code?

    Have a look at function Js.wrap_callback

    diff --git a/dev/manual/how-to-compile-my-ocsigen-pages.html b/dev/manual/how-to-compile-my-ocsigen-pages.html index 8e56609a..b2b608dc 100644 --- a/dev/manual/how-to-compile-my-ocsigen-pages.html +++ b/dev/manual/how-to-compile-my-ocsigen-pages.html @@ -41,9 +41,9 @@
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to compile my Ocsigen pages?

    Eliom distillery

    Eliom-distillery will help you to build your client-server application +

    How to compile my Ocsigen pages?

    Eliom distillery

    Eliom-distillery will help you to build your client-server application using Eliom. It comes with several templates ("client-server.basic", "os.pgocaml", and more to come ...). diff --git a/dev/manual/how-to-configure-and-launch-the-ocsigen-server.html b/dev/manual/how-to-configure-and-launch-the-ocsigen-server.html index 4e239b3a..8fab734f 100644 --- a/dev/manual/how-to-configure-and-launch-the-ocsigen-server.html +++ b/dev/manual/how-to-configure-and-launch-the-ocsigen-server.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to configure and launch the Ocsigen Server?

    Default configuration file

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to create a form wizard (sequence of pages depending on data entered on previous ones)?

    The solution to implement wizard-like forms (that is a sequence of pages +

    How to create a form wizard (sequence of pages depending on data entered on previous ones)?

    The solution to implement wizard-like forms (that is a sequence of pages depending on data entered on previous ones) is to create dynamically new services especially for one user. If you use session data (eliom references) it won't work if you have several tabs on the same site (or if you use the diff --git a/dev/manual/how-to-create-link-to-a-current-page-without-knowing-its-url.html b/dev/manual/how-to-create-link-to-a-current-page-without-knowing-its-url.html index c7ac3e18..fc38919a 100644 --- a/dev/manual/how-to-create-link-to-a-current-page-without-knowing-its-url.html +++ b/dev/manual/how-to-create-link-to-a-current-page-without-knowing-its-url.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to create a link to the current page (without knowing its URL)?

    Void coservices are here for that: +

    How to create a link to the current page (without knowing its URL)?

    Void coservices are here for that:

    a ~service:Eliom_service.reload_action
       [txt "Click to reload"] ();

    More information in Eliom's manual, and API documentation of diff --git a/dev/manual/how-to-detect-channel-disconnection.html b/dev/manual/how-to-detect-channel-disconnection.html index ee2bd46b..72ac62df 100644 --- a/dev/manual/how-to-detect-channel-disconnection.html +++ b/dev/manual/how-to-detect-channel-disconnection.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to detect channel disconnection

    Question

    Is there a way to detect that some Eliom_comet channel became +

    How to detect channel disconnection

    Question

    Is there a way to detect that some Eliom_comet channel became disconnected? I would like to warn the user if the server becomes unreachable.

    Answer

    If you are using Ocsigen-start, you probably have nothing to do. diff --git a/dev/manual/how-to-detect-on-client-side-that-the-server-side-state-for-the-process-is-closed.html b/dev/manual/how-to-detect-on-client-side-that-the-server-side-state-for-the-process-is-closed.html index 3d13db66..bb3796db 100644 --- a/dev/manual/how-to-detect-on-client-side-that-the-server-side-state-for-the-process-is-closed.html +++ b/dev/manual/how-to-detect-on-client-side-that-the-server-side-state-for-the-process-is-closed.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to detect on client side that the server side state for the process is closed?

    If you are using Ocsigen-start, you probably have nothing to do. +

    How to detect on client side that the server side state for the process is closed?

    If you are using Ocsigen-start, you probably have nothing to do. Ocsigen-start will monitor the life of sessions and close the process when needed.

    If you are not using Ocsigen-start, you must catch exceptions diff --git a/dev/manual/how-to-do-links-to-other-pages.html b/dev/manual/how-to-do-links-to-other-pages.html index 52f036ba..fe1303ef 100644 --- a/dev/manual/how-to-do-links-to-other-pages.html +++ b/dev/manual/how-to-do-links-to-other-pages.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to do links to other pages?

    Examples: +

    How to do links to other pages?

    Examples:

    (* Link to a service without parameter: *)
     Html.D.a ~service:coucou [txt "coucou"] ();
     
    diff --git a/dev/manual/how-to-implement-a-notification-system.html b/dev/manual/how-to-implement-a-notification-system.html
    index e4854b4c..a3f850b6 100644
    --- a/dev/manual/how-to-implement-a-notification-system.html
    +++ b/dev/manual/how-to-implement-a-notification-system.html
    @@ -41,9 +41,9 @@
     
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to implement a notification system?

    The easiest way for the server to send notifications to the client is +

    How to implement a notification system?

    The easiest way for the server to send notifications to the client is to use module Os_notif from Ocsigen-start (OS), but it requires to use OS's user management system. If you are not using OS, we recommend to get inspiration from diff --git a/dev/manual/how-to-insert-raw-form-elements-not-belonging-to-a-form-towards-a-service.html b/dev/manual/how-to-insert-raw-form-elements-not-belonging-to-a-form-towards-a-service.html index 7e5e22e5..01cc918e 100644 --- a/dev/manual/how-to-insert-raw-form-elements-not-belonging-to-a-form-towards-a-service.html +++ b/dev/manual/how-to-insert-raw-form-elements-not-belonging-to-a-form-towards-a-service.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to insert "raw" form elements (not belonging to a form towards a service)?

    Eliom redefines most forms elements (inputs, textareas, checkboxes, etc.) +

    How to insert "raw" form elements (not belonging to a form towards a service)?

    Eliom redefines most forms elements (inputs, textareas, checkboxes, etc.) to make possible to check the type of the form w.r.t. the type of the service.

    If you don't want that (for example if you want to use it only from a client side program), you can use "raw form elements" (that is, basic tyxml elements), using diff --git a/dev/manual/how-to-iterate-on-all-sessions-for-one-user-or-all-tabs.html b/dev/manual/how-to-iterate-on-all-sessions-for-one-user-or-all-tabs.html index a1a2e7b8..56099211 100644 --- a/dev/manual/how-to-iterate-on-all-sessions-for-one-user-or-all-tabs.html +++ b/dev/manual/how-to-iterate-on-all-sessions-for-one-user-or-all-tabs.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to iterate on all session belonging to the same user, or all tabs?

    You must create a session group for each user, then iterate on all +

    How to iterate on all session belonging to the same user, or all tabs?

    You must create a session group for each user, then iterate on all the sessions from this group, and possibly on all client processes for each session:

    (* We get the session group state for this user: *)
    diff --git a/dev/manual/how-to-know-whether-the-browser-window-has-the-focus-or-not.html b/dev/manual/how-to-know-whether-the-browser-window-has-the-focus-or-not.html
    index efcf65fc..4a5047c0 100644
    --- a/dev/manual/how-to-know-whether-the-browser-window-has-the-focus-or-not.html
    +++ b/dev/manual/how-to-know-whether-the-browser-window-has-the-focus-or-not.html
    @@ -41,9 +41,9 @@
     
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to know whether the browser window has the focus or not?

    Example: +

    How to know whether the browser window has the focus or not?

    Example:

    let has_focus = ref true
     
     let _ =
    diff --git a/dev/manual/how-to-make-hello-world-in-ocsigen.html b/dev/manual/how-to-make-hello-world-in-ocsigen.html
    index c9cd4f4b..2c5ea07d 100644
    --- a/dev/manual/how-to-make-hello-world-in-ocsigen.html
    +++ b/dev/manual/how-to-make-hello-world-in-ocsigen.html
    @@ -41,9 +41,9 @@
     
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to make a "hello world" in Ocsigen?

    Here it is! The famous "Hello World" for a client/server Eliom application: +

    How to make a "hello world" in Ocsigen?

    Here it is! The famous "Hello World" for a client/server Eliom application:

    open Eliom_content
     open Html.D
     open Eliom_parameter
    diff --git a/dev/manual/how-to-make-page-a-skeleton.html b/dev/manual/how-to-make-page-a-skeleton.html
    index f69ca7b3..c5d3bce4 100644
    --- a/dev/manual/how-to-make-page-a-skeleton.html
    +++ b/dev/manual/how-to-make-page-a-skeleton.html
    @@ -41,9 +41,9 @@
     
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to make a page skeleton?

    The same header for all your pages

    When your site will grow, you will have several different services for pages which will often contain the same header informations. +

    How to make a page skeleton?

    The same header for all your pages

    When your site will grow, you will have several different services for pages which will often contain the same header informations.

    A great solutions to avoid code copy-pasting of these recurrent informations are to make a page skeleton function:

    let skeleton body_content =
       Lwt.return
    diff --git a/dev/manual/how-to-make-responsive-css.html b/dev/manual/how-to-make-responsive-css.html
    index 60546fff..a0f820a8 100644
    --- a/dev/manual/how-to-make-responsive-css.html
    +++ b/dev/manual/how-to-make-responsive-css.html
    @@ -41,9 +41,9 @@
     
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to make reponsive CSS with ocsigen?

    The best way to do that is to make one general css sheet plus three css sheets, small, medium and large screen using media queries, a feature introduced in CSS3. +

    How to make reponsive CSS with ocsigen?

    The best way to do that is to make one general css sheet plus three css sheets, small, medium and large screen using media queries, a feature introduced in CSS3.

    Write theses lines in your css sheets:

    @media only screen and (max-device-width: 480px)
     @media only screen and (min-device-width: 481px) and (max-device-width: 768px)
    diff --git a/dev/manual/how-to-make-the-client-side-program-get-an-html-element-from-the-server-and-insert-it-in-the-page.html b/dev/manual/how-to-make-the-client-side-program-get-an-html-element-from-the-server-and-insert-it-in-the-page.html
    index a85b9b65..e26d3b4d 100644
    --- a/dev/manual/how-to-make-the-client-side-program-get-an-html-element-from-the-server-and-insert-it-in-the-page.html
    +++ b/dev/manual/how-to-make-the-client-side-program-get-an-html-element-from-the-server-and-insert-it-in-the-page.html
    @@ -41,9 +41,9 @@
     
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to make the client side program get an HTML element from the server and insert it in the page?

    A very convenient way to do that is to use RPCs : +

    How to make the client side program get an HTML element from the server and insert it in the page?

    A very convenient way to do that is to use RPCs :

    let%rpc get_mydiv (() : unit) : _ Lwt.t = div [ ... ]
    [%client
       ...
       let%lwt mydiv = get_mydiv () in
    diff --git a/dev/manual/how-to-register-a-service-that-decides-itself-what-to-send.html b/dev/manual/how-to-register-a-service-that-decides-itself-what-to-send.html
    index e66892d1..1aef3b76 100644
    --- a/dev/manual/how-to-register-a-service-that-decides-itself-what-to-send.html
    +++ b/dev/manual/how-to-register-a-service-that-decides-itself-what-to-send.html
    @@ -41,9 +41,9 @@
     
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to register a service that decides itself what to send?

    Use Eliom_registration.Any. +

    How to register a service that decides itself what to send?

    Use Eliom_registration.Any.

    In the following example, we send an Html page or a redirection:

    let send_any =
       Eliom_registration.Any.create
    diff --git a/dev/manual/how-to-register-session-data.html b/dev/manual/how-to-register-session-data.html
    index 9b36effe..45940898 100644
    --- a/dev/manual/how-to-register-session-data.html
    +++ b/dev/manual/how-to-register-session-data.html
    @@ -41,9 +41,9 @@
     
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to register session data?

    It is very easy to register session data using Eliom references. +

    How to register session data?

    It is very easy to register session data using Eliom references. Just create an Eliom reference of scope session and its value will be different for each session (one session = one browser process).

    But most of the time, what we want is to store data for one user, diff --git a/dev/manual/how-to-send-a-file-to-server-without-stopping-the-client-process.html b/dev/manual/how-to-send-a-file-to-server-without-stopping-the-client-process.html index e2ed2557..8fe75030 100644 --- a/dev/manual/how-to-send-a-file-to-server-without-stopping-the-client-process.html +++ b/dev/manual/how-to-send-a-file-to-server-without-stopping-the-client-process.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to send a file to the server without stopping the client process?

    This requires Eliom ≥ 3.1. +

    How to send a file to the server without stopping the client process?

    This requires Eliom ≥ 3.1.

    Due to security reasons, browsers have limitations on sending files. But if the file is chosen by the user through an input file element, there is a way to send it to the server. You can't use the server_function diff --git a/dev/manual/how-to-send-file-download.html b/dev/manual/how-to-send-file-download.html index 77abef26..8bbeeb6b 100644 --- a/dev/manual/how-to-send-file-download.html +++ b/dev/manual/how-to-send-file-download.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to send a file (download)?

    To serve file, you can use Ocsigen Server's module staticmod. +

    How to send a file (download)?

    To serve file, you can use Ocsigen Server's module staticmod. But it is also possible to ask Eliom to send files using module Eliom_registration.File, for example if you want Eliom to perform some privacy checks before sending, diff --git a/dev/manual/how-to-send-file-upload.html b/dev/manual/how-to-send-file-upload.html index ceb1f476..510208ae 100644 --- a/dev/manual/how-to-send-file-upload.html +++ b/dev/manual/how-to-send-file-upload.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to send a file (upload)?

    To upload a file, use Eliom_parameter.file as service parameter type. +

    How to send a file (upload)?

    To upload a file, use Eliom_parameter.file as service parameter type.

    Ocsigen server will save the file at a temporary location and keep it there during the request. Then the file will be removed. You must link it somewhere else on the disk yourself if you want to keep it. diff --git a/dev/manual/how-to-set-and-id-classes-or-other-attributes-to-html-elements.html b/dev/manual/how-to-set-and-id-classes-or-other-attributes-to-html-elements.html index 12261317..69c51c6b 100644 --- a/dev/manual/how-to-set-and-id-classes-or-other-attributes-to-html-elements.html +++ b/dev/manual/how-to-set-and-id-classes-or-other-attributes-to-html-elements.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to set and id, classes or other attributes to HTML elements?

    Mandatory element attributes are given as OCaml named parameters to +

    How to set and id, classes or other attributes to HTML elements?

    Mandatory element attributes are given as OCaml named parameters to constructions function.

    Optional element attributes are added using the optional OCaml parameter "?a" which is more or less available for every HTML5 elements. This parameter is taking a list of attributes compatible with the element.

    div ~a:[a_class ["red";"shadow"];
    diff --git a/dev/manual/how-to-stop-default-behaviour-of-events.html b/dev/manual/how-to-stop-default-behaviour-of-events.html
    index 3ee54409..df6ffc57 100644
    --- a/dev/manual/how-to-stop-default-behaviour-of-events.html
    +++ b/dev/manual/how-to-stop-default-behaviour-of-events.html
    @@ -41,9 +41,9 @@
     
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to stop default behaviour of events?

    Example: +

    How to stop default behaviour of events?

    Example:

    (** Disable Js event with stopping propagation during capture phase **)
     let disable_event event html_elt =
       Lwt.async (fun () ->
    diff --git a/dev/manual/how-to-use-get-parameters-or-parameters-in-the-url.html b/dev/manual/how-to-use-get-parameters-or-parameters-in-the-url.html
    index 3e0d7830..3317cd21 100644
    --- a/dev/manual/how-to-use-get-parameters-or-parameters-in-the-url.html
    +++ b/dev/manual/how-to-use-get-parameters-or-parameters-in-the-url.html
    @@ -41,9 +41,9 @@
     
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to use GET parameters (parameters in the URL)?

    Pages are generated by services. +

    How to use GET parameters (parameters in the URL)?

    Pages are generated by services.

    Funcrions to create services using GET HTTP method take two mandatory parameters: ~path and ~get_params.

    path

    This argument is a list of string, corresponding to the URL where your page service can be found. diff --git a/dev/manual/how-to-write-a-json-service.html b/dev/manual/how-to-write-a-json-service.html index b1e9f5e2..c9721f72 100644 --- a/dev/manual/how-to-write-a-json-service.html +++ b/dev/manual/how-to-write-a-json-service.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to write a JSON service?

    Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to write forms?

    To write an HTML form towards an Eliom service

    Just as we do for links, we provide form-building functions that call +

    How to write forms?

    To write an HTML form towards an Eliom service

    Just as we do for links, we provide form-building functions that call Eliom services in a safe manner. These functions are provided in the module Eliom_content.Html.D.Form (and diff --git a/dev/manual/how-to-write-titles-and-paragraphs.html b/dev/manual/how-to-write-titles-and-paragraphs.html index f0c32ce9..6830efe9 100644 --- a/dev/manual/how-to-write-titles-and-paragraphs.html +++ b/dev/manual/how-to-write-titles-and-paragraphs.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    How to write titles and paragrahs?

    Titles +

    How to write titles and paragrahs?

    Titles

    h3 [txt "Hello world"]

    There are 6 types of titles: h1, h2, h3, h4, h5 and h6. h1 is the largest and h6 is the smallest.

    Pagragraph

    p [txt "Some text, blah blah blah"]

    Required parameter: list containing other elements (content: Html_types.flow5 elements). diff --git a/dev/manual/html.html b/dev/manual/html.html index 641a448d..d15373d7 100644 --- a/dev/manual/html.html +++ b/dev/manual/html.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    HTML in 5 minutes

    The Tyxml library makes it possible to type-check HTML pages. +

    HTML in 5 minutes

    The Tyxml library makes it possible to type-check HTML pages. This means that your Ocsigen program will never generate pages which do not follow the recommendations from the W3C. For example a program that could generate a page with a paragraph diff --git a/dev/manual/interaction.html b/dev/manual/interaction.html index 3bf4de7d..b22f32d3 100644 --- a/dev/manual/interaction.html +++ b/dev/manual/interaction.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    Implementing Web Interaction Using Eliom

    The code of this tutorial has been tested with Eliom 6.0.
    +

    Implementing Web Interaction Using Eliom

    The code of this tutorial has been tested with Eliom 6.0.

    This chapter of the tutorial explains how to create a small web site with several pages, users, sessions, and other elements of classical web development. Then, in diff --git a/dev/manual/intro.html b/dev/manual/intro.html index bb1b60cb..8c53a568 100644 --- a/dev/manual/intro.html +++ b/dev/manual/intro.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    Introduction

    Ocsigen is a complete framework for developing Web and mobile apps +

    Introduction

    Ocsigen is a complete framework for developing Web and mobile apps using cutting edge techniques. It can be used to write simple server side Web sites, client-side programs, or complex client-server Web and mobile apps. @@ -97,8 +97,8 @@ if you plan to build a client-server Web (and/or mobile) app. It will help you to build your first app very quickly, with many code samples to study. -

  • Basic web site explains how to write a basic -Web site using OCaml functions +
  • Basic web site explains how to write a +website in OCaml, if you don't plan to have client-side features yet
  • If you are fluent in OCaml and want a quick introduction to client-server Web programming with Eliom, read tutorial diff --git a/dev/manual/lwt.html b/dev/manual/lwt.html index 49af9229..3af49f66 100644 --- a/dev/manual/lwt.html +++ b/dev/manual/lwt.html @@ -41,9 +41,9 @@
  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    Lwt in 5 minutes

    Principles

    The Lwt library implements cooperative threads for OCaml. Cooperative +

    Lwt in 5 minutes

    Principles

    The Lwt library implements cooperative threads for OCaml. Cooperative threads are an alternative to preemptive threads (used in many languages and in OCaml's Thread module) that solve most common issues with preemptive threads: with Lwt, there is very limited risk diff --git a/dev/manual/macaque.html b/dev/manual/macaque.html index e5aafcad..6dda6d75 100644 --- a/dev/manual/macaque.html +++ b/dev/manual/macaque.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    Type safe database requests using Macaque

    The Macaque library allows easy manipulation of Postgresql +

    Type safe database requests using Macaque

    The Macaque library allows easy manipulation of Postgresql database fully compatible with Lwt. (For more information see Macaque manual).

    Macaque is fuly compatible with PGOcaml, and both can be used diff --git a/dev/manual/misc.html b/dev/manual/misc.html index 66695cab..f37eb610 100644 --- a/dev/manual/misc.html +++ b/dev/manual/misc.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    Traditional web interaction in a client-server app

    The code of this tutorial has been tested with Eliom 6.0.
    +

    Traditional web interaction in a client-server app

    The code of this tutorial has been tested with Eliom 6.0.

    Multi-user collaborative drawing application

    We now want to turn our collaborative drawing application into a multi-user one. Each user will have their own drawing, where everyone can draw. diff --git a/dev/manual/mobile.html b/dev/manual/mobile.html index 32b0d568..c772cc78 100644 --- a/dev/manual/mobile.html +++ b/dev/manual/mobile.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    Mobile applications with Ocsigen

    Since Eliom 6.0, the Ocsigen framework provides infrastructure for +

    Mobile applications with Ocsigen

    Since Eliom 6.0, the Ocsigen framework provides infrastructure for building mobile applications. This enables rapid development of Android, iOS, and Windows Mobile apps with the same APIs and programming style as for a regular client-server Web application. In diff --git a/dev/manual/music.html b/dev/manual/music.html index 65366c6b..6aa9d9f3 100644 --- a/dev/manual/music.html +++ b/dev/manual/music.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    Listening music

    We will add an audio player to the page that will stay when page +

    Listening music

    We will add an audio player to the page that will stay when page changes. This emphasises the fact that browsing inside an application does not stop the client side code: the music keeps playing when the content of the page and the url change. diff --git a/dev/manual/ocsipersist.html b/dev/manual/ocsipersist.html index cadf356f..fa83141b 100644 --- a/dev/manual/ocsipersist.html +++ b/dev/manual/ocsipersist.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    Lightweight database using Ocsipersist

    Ocsipersist is a module for persistent references and tables. +

    Lightweight database using Ocsipersist

    Ocsipersist is a module for persistent references and tables.

    For persistent references, Eliom has a higher level interface, called Eliom references, and you probably want to use it instead of using Ocsipersist directly. diff --git a/dev/manual/pictures.html b/dev/manual/pictures.html index 9fa1e904..a1e8fa9d 100644 --- a/dev/manual/pictures.html +++ b/dev/manual/pictures.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    Saving favorite pictures

    We will now add a button to the Graffiti application to save the current +

    Saving favorite pictures

    We will now add a button to the Graffiti application to save the current image. The images will be saved to the filesystem using the module Lwt_io. We will then make an Atom feed with the saved images using Syndic. diff --git a/dev/manual/reactivemediaplayer.html b/dev/manual/reactivemediaplayer.html index b41be112..b506e7a8 100644 --- a/dev/manual/reactivemediaplayer.html +++ b/dev/manual/reactivemediaplayer.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    Reactive Media Player

    You should read the Playing Music tutorial before this one. +

    Reactive Media Player

    You should read the Playing Music tutorial before this one.

    Since version 4, Eliom embeds the React library in order to provide reactive HTML elements diff --git a/dev/manual/rest.html b/dev/manual/rest.html index f2b7d0fe..de0375a4 100644 --- a/dev/manual/rest.html +++ b/dev/manual/rest.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    RESTful JSON API using Eliom

    This tutorial will show you how to create a simple, yet complete, REST API +

    RESTful JSON API using Eliom

    This tutorial will show you how to create a simple, yet complete, REST API using JSON as the serialization format.

    To illustrate our example, let's say we want to give access to a database of locations storing a description and coordinates (latitude and longitude). diff --git a/dev/manual/start.html b/dev/manual/start.html index 17f95660..a6d94368 100644 --- a/dev/manual/start.html +++ b/dev/manual/start.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    Your first app in 5 minutes

    The code of this tutorial has been tested against Eliom 6.0.
    +

    Your first app in 5 minutes

    The code of this tutorial has been tested against Eliom 6.0.

    This tutorial describes how to get started with Ocsigen quickly. Thanks to an application template provided by the Ocsigen team, you will get to a working application with standard diff --git a/dev/manual/tutoreact.html b/dev/manual/tutoreact.html index 383e87c7..4ae461a2 100644 --- a/dev/manual/tutoreact.html +++ b/dev/manual/tutoreact.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    Client server reactive application with Ocsigen

    This is a short tutorial showing how to implement a simple reactive +

    Client server reactive application with Ocsigen

    This is a short tutorial showing how to implement a simple reactive client-server application using Js_of_ocaml, Eliom and Ocsigen Start.

    We are going to implement an application that can display a list of messages and diff --git a/dev/manual/tutowidgets.html b/dev/manual/tutowidgets.html index a9cbac9c..362f4b85 100644 --- a/dev/manual/tutowidgets.html +++ b/dev/manual/tutowidgets.html @@ -41,9 +41,9 @@

  • Blog
  • Installation
  • Source code -
  • Warning: Reason support is experimental. +

    Warning: Reason support is experimental. We are looking for beta-tester and contributors. -

    Mini-tutorial: client-server widgets

    This short tutorial is an example of client-server Eliom application. +

    Mini-tutorial: client-server widgets

    This short tutorial is an example of client-server Eliom application. It gives an example of client-server widgets.

    It is probably a good starting point if you know OCaml well, and want to quickly learn how to write a client-server Eliom application with a