[Ur] Uru, new version available

Sergey Mironov grrwlf at gmail.com
Fri Oct 17 13:57:09 EDT 2014


Hi. Recent Ur/Web improvements have made it possible to make Uru even smaller,
so I'd like to announce the new version of the library.

Uru - a modularization library aimed to simplify the writing of user interface
code in Ur/Web.

    https://github.com/grwlf/uru3

In Web programming world, user interface libraries usually contain very
different types of materials to be included into the master project. Most
JavaScript controls are distributes as packages containing JavaScript code, CSS
files,  images, fonts and so on.  For example, Bootstrap [1] library package
includes the following files: bootstrap[.min].css, bootstrap[.min].js,
glyphicons-halflings-regular.eot and few other glyph collections.

Typical process of including such a library into a web project may include a)
Setting up the static content directories and placing the library's files into
it b) For every static CSS file, providing application with correct <link
rel="stylesheet" ...> tag c) For every JavaScript file, providing the
application template's <head> with corresponding <script> tag (and it's
dependencies!). Often, the list of dependencies includes JQuery library and it's
siblings like JQueryUI.

Setting up links to thirdparty user-interface objects as well as keeping
references up to date may become a bothersome task for the unprepared Ur/Web
programmer.

Uru tries to solve parts of the problem by automating steps (a) and (b) and
provide hints for step (c). It attempts to draft a way of grouping resources
into modules and allowing to turn them on or off by calling a single function
only. Here is the example application:

    (* ./Bootstrap/example/E1.urp *)

    library ..

    E1

    (* ./Bootstrap/example/E1.ur *)

    fun main {} : transaction page =
      Uru.run (
      JQuery.add (
      Bootstrap.add (
      Uru.withHeader (
        <xml>
          <title>B3 Login demo</title>
        </xml>) (
      Uru.withBody (fn _ =>
        return
        <xml>
          <div class={Bootstrap.container}>
            <h1>Bootstrap starter template</h1>
            <p class={Bootstrap.lead}>Use this document as a way to
quickly start
            any new project.<br/> All you get is this text and a mostly
            barebones HTML document.</p>
          </div>
        </xml>
      )))))

In this example, `Uru.run' function is responsible for building the main page of
the application. It starts by creating an empty page (see `Uru.dpage' type
constructor) and pass it to it's argument set of transformers. Each transformer
changes the page in some way and passes it downstream.  For example,
`Bootstrap.add' adds full set of references to the Bootstrap CSS library,
including javascript, fonts and glyphs. Finally, the `Uru.withBody' transformer
ends the process by specifying the body of a page.

Note, that Uru's page representation tracks transformer dependencies. For
example, uru3/Bootstrap library is designed to depend on uru3/JQuery. That means
that if you remove call to `JQuery.add ( .. )' from E1.ur, the example will fail
to compile.

This is the uru's third version. It may be considered somewhat stable.
Some demo applications do exist:

  http://hit.msk.ru:8080/B1/main
  http://hit.msk.ru:8080/B2/main
  http://hit.msk.ru:8080/B3_Login/main

Notes:

Automatically generated modules are used for providing static content. The
generator, cake3 [2], is not required for using Uru as a library, but it should
be installed for it's development.

Uru3 contains adopted version of the following pre-existing Ur/Web libraries:
https://github.com/doublec/urweb-persona (interface changes, static content
included, linked with third-party C libraries via pkg-config)
http://hg.impredicative.com/bootstrap (more styles, static content included,
JQuery dependency included)

The Ur/Web following compiler patch is required for building the Bootstrap
demos:
https://github.com/grwlf/uru3/blob/master/1_of_1_HTML5_input_attributes__placeholder__required__autofocus__email_input_type__without_cformTag_equivalent_.patch

Regards,
Sergey

[1] - http://getbootstrap.com/ (Bootstrap library)
[2] - https://github.com/grwlf/cake3 (Makefile + static modules generator)



More information about the Ur mailing list