[Ur] serving css from urweb

Zach Tatlock ztatlock at cs.ucsd.edu
Wed Jun 22 01:38:15 EDT 2011


Hello,

What is the standard way to serve css from within Ur/Web?

Most examples I've seen rely on an external server.  The Bitparking
exchange [1] seems to avoid this dependence, but its source is not yet
available.

Here's the simplest solution [2] I could cobble together from skimming
the demos and manual:

----- snip -----

style quote

val css = "
  body {
    width: 50%;
    margin: 40px auto;
  }

  .Css_quote {
    background: #ccc;
    ...
    border-radius: 20px;
  }
"

fun retCss () =
  returnBlob (textBlob css) (blessMime "text/css")

fun main () = return <xml>
  <head>
    <link rel="stylesheet" type="text/css" href={url (retCss ())}/>
  </head>
  <body>
    <div class={quote}>
      The time you enjoy wasting is not wasted time.<br/><br/>
      -- Bertrand Russell
    </div>
  </body>
</xml>

----- snip -----

Is this reasonable?

Is there a way to get the fully qualified name of a style as a string?
 It would be nice to use that within the css string literal.

Thanks!

- Zach


[1]
  https://exchange.bitparking.com/main

[2]
  http://godel.ucsd.edu/urweb-css/css.ur
  http://godel.ucsd.edu/urweb-css/css.urp
  http://godel.ucsd.edu/urweb-css/css.urs
  http://godel.ucsd.edu:8080/Css/main



More information about the Ur mailing list