happstack-yui-7351.3.0: Utilities for using YUI3 with Happstack.

Safe HaskellNone

Happstack.Server.YUI

Contents

Synopsis

Combo Handler

implYUISiteSource

Arguments

:: Text

The URL of your application, e.g. "http://localhost:8000".

-> Text

The path under which to mount the YUI handler, e.g. "/yui".

-> ServerPartT IO Response 

Mounts a handler for serving YUI.

The handler responds to these routes:

/3.5.1/
The YUI seed file plus the configuration for using our own combo loader.
/3.5.1/combo
The combo loader.
/3.5.1/css
A specialized combo loader for CSS modules, for use in <link/> tags. Simply list the CSS modules in the query string by name rather than file path, for example "/3.5.1/css?reset&base&fonts&grids". Order matters; you'll usually want reset first if you use it.
/3.5.1/bundle/<filename>
Get an individual file without combo loading.
/3.5.1/config
The code for configuring YUI to use our own combo loader. Not needed if you use the seed file mentioned above.

The version number of the bundled YUI release is included in the routes for sake of cache-busting: the routes all respond with far-future expiration dates.

CSS utilities

gridUnit :: Integer -> Integer -> TextSource

Gets the class name for the grid unit of the ratio of the two argument integers. YUI doesn't define redundant classes like "6/24" because that is the same as 1/4 and presumably for sake of a smaller CSS file. This helper function handles that for you, though:

>>> gridUnit 6 24
"yui3-u-1-4"

The intention is for this function to be used in templates to create values for class attributes, for example with HSP:

<div class=(gridUnit 6 24)>
  <% someContent %>
</div>

fontSize :: Integer -> TextSource

Converts a pixel size to a percentage suitable for use with the CSS fonts module:

>>> fontSize 16
"123.1%"

Useful in generated stylesheets, for example with HSP:

<style>
  h1 { font-size: <% fontSize 26 %> }
</style>

Bundle utilities

isYUIFile :: FilePath -> IO BoolSource

Tells if a file is included in the YUI bundle.

>>> isYUIFile "yui/yui-min.js"
True

readYUIFile :: FilePath -> IO ByteStringSource

Reads the contents of a file included in the YUI bundle.