[Ur] Bootstrap example ported

Adam Chlipala adamc at csail.mit.edu
Fri Aug 1 11:56:20 EDT 2014


Here is my much-delayed response to your thoughtful report!

How does your Bootstrap 3 support compare to what we already had here?
     http://hg.impredicative.com/bootstrap

On 07/07/2014 03:17 AM, Sergey Mironov wrote:
> Hi, I've ported a part of an advanced Bootstrap-3 example to Ur/Web
> and would like to share
> the experience. First of all, the example is running on my server here:
>
>      http://46.38.250.132:8081/B2/main
>
> It copies some (but not all) sections of the original 'theme' example [1]. The
> Ur/Web sources are located at the Github [2].
>
> Here is my feedback:
>
> 1) The Bootstrap as well as other JQuery libraries heavily uses modern HTML5
> tags and CSS3-syntax. Some of them are not well supported by the Ur/Web. As a
> result, one may need to patch bootstrap files before including them in the
> Ur/Web application. For example, bootstrap.css contains the following
> declaration
>
>      @font-face {
>        font-family: 'Glyphicons Halflings';
>        src: url('../fonts/glyphicons-halflings-regular.eot');
>      }
>
> The url declared here expects application to be able to serve static files which
> normally is not the case in the Ur/Web world. I found it rather difficult to use
> thirdparty *css or *js files because of issues like this.

My recommended Ur/Web application deployment mode is as a FastCGI 
program within a standard web server like Apache.  In such a setting, 
it's rather trivial to map arbitrary URL prefixes into arbitrary 
filesystem directories, even as some other prefixes (even prefixes that 
are themselves prefixes of the statically mapped ones) are mapped to the 
FastCGI application.  So, I don't see any issues there.

The 'file' directive for .urp files that I announced yesterday may also 
be relevant here, though I still recommend using a traditional web 
server to serve static files.

> 2) Ur/Web doesn't support aria-* data attributes which is used by bootstrap
> internals. I thinkk we should think about adding this support. Probably, the API
> should be similar to that of data-* attributes.

OK, I've added 'aria-*' support.

> 3) I've tired of rewriting things like  class="btn btn-lg btn-default" into
> class={css (B.btn :: B.btn_lg :: B.btn_default :: [])}. Could we think about
> adding a syntaxic sugar to reduce the amount of code? The new sugar may allow
> writing classes as usual
>
>      class="class-1 class-2 class-3"
>
> but check them against the declarations
>
>      style class_1
>      style class_2
>      style class_3
>
>
> The same thing with data-* attributes: most of the time they are staticly
> included in the code, so I would be happy to have pre-processor which may expand
> my <p data-target="bla"/> into <p data={data_attr "target" "bla"}/>

This request confuses me.  I think both desugarings have already been in 
the Ur/Web compiler for months.

For your particular example, I suggest running [open Bootstrap] to bring 
all the class names into the top-level namespace, so that the standard 
HTML syntax will work.



More information about the Ur mailing list