Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Format
- data Asset a
- class Ema model route | route -> model where
- encodeRoute :: model -> route -> FilePath
- decodeRoute :: model -> FilePath -> Maybe route
- allRoutes :: model -> [route]
- data UrlStrategy
- routeUrlWith :: forall r model. Ema model r => UrlStrategy -> model -> r -> Text
- routeUrl :: forall r model. Ema model r => model -> r -> Text
- emaErrorHtmlResponse :: Text -> LByteString
- runEmaPure :: (Some Action -> LByteString) -> IO ()
- runEma :: forall model route b. (Ema model route, Show route) => (Some Action -> model -> route -> Asset LByteString) -> (forall m. (MonadIO m, MonadUnliftIO m, MonadLoggerIO m) => Some Action -> LVar model -> m b) -> IO (Either b (DSum Action Identity))
- runEmaWithCli :: forall model route b. (Ema model route, Show route) => Cli -> (Some Action -> model -> route -> Asset LByteString) -> (forall m. (MonadIO m, MonadUnliftIO m, MonadLoggerIO m) => Some Action -> LVar model -> m b) -> IO (Either b (DSum Action Identity))
Documentation
The type of assets that can be bundled in a static site.
AssetStatic FilePath | A file that is copied as-is from the source directory. Relative paths are assumed relative to the source directory. Absolute paths allow copying static files outside of source directory. |
AssetGenerated Format a | A file whose contents are generated at runtime by user code. |
Instances
Eq a => Eq (Asset a) Source # | |
Ord a => Ord (Asset a) Source # | |
Show a => Show (Asset a) Source # | |
Generic (Asset a) Source # | |
type Rep (Asset a) Source # | |
Defined in Ema.Asset type Rep (Asset a) = D1 ('MetaData "Asset" "Ema.Asset" "ema-0.6.0.0-Gf9N5ZNZjTx7iyuu6ZTKHB" 'False) (C1 ('MetaCons "AssetStatic" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FilePath)) :+: C1 ('MetaCons "AssetGenerated" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Format) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a))) |
class Ema model route | route -> model where Source #
Enrich a model to work with Ema
encodeRoute :: model -> route -> FilePath Source #
Get the filepath on disk corresponding to this route.
decodeRoute :: model -> FilePath -> Maybe route Source #
Decode a filepath on disk into a route.
allRoutes :: model -> [route] Source #
All routes in the site
The gen
command will generate only these routes. On live server, this
function is never used.
data UrlStrategy Source #
Instances
Eq UrlStrategy Source # | |
Defined in Ema.Route (==) :: UrlStrategy -> UrlStrategy -> Bool # (/=) :: UrlStrategy -> UrlStrategy -> Bool # | |
Ord UrlStrategy Source # | |
Defined in Ema.Route compare :: UrlStrategy -> UrlStrategy -> Ordering # (<) :: UrlStrategy -> UrlStrategy -> Bool # (<=) :: UrlStrategy -> UrlStrategy -> Bool # (>) :: UrlStrategy -> UrlStrategy -> Bool # (>=) :: UrlStrategy -> UrlStrategy -> Bool # max :: UrlStrategy -> UrlStrategy -> UrlStrategy # min :: UrlStrategy -> UrlStrategy -> UrlStrategy # | |
Show UrlStrategy Source # | |
Defined in Ema.Route showsPrec :: Int -> UrlStrategy -> ShowS # show :: UrlStrategy -> String # showList :: [UrlStrategy] -> ShowS # | |
FromJSON UrlStrategy Source # | |
Defined in Ema.Route parseJSON :: Value -> Parser UrlStrategy # parseJSONList :: Value -> Parser [UrlStrategy] # |
routeUrlWith :: forall r model. Ema model r => UrlStrategy -> model -> r -> Text Source #
emaErrorHtmlResponse :: Text -> LByteString Source #
A basic error response for displaying in the browser
:: (Some Action -> LByteString) | How to render a route |
-> IO () |
Pure version of runEmaWith
(i.e with no model).
Due to purity, there is no impure state, and thus no time-varying model. Neither is there a concept of route, as only a single route (index.html) is expected, whose HTML contents is specified as the only argument to this function.
:: forall model route b. (Ema model route, Show route) | |
=> (Some Action -> model -> route -> Asset LByteString) | How to render a route, given the model |
-> (forall m. (MonadIO m, MonadUnliftIO m, MonadLoggerIO m) => Some Action -> LVar model -> m b) | A long-running IO action that will update the |
-> IO (Either b (DSum Action Identity)) |
Convenient version of runEmaWith
that takes initial model and an update
function. You typically want to use this.
It uses race_
to properly clean up the update action when the ema thread
exits, and vice-versa.
:: forall model route b. (Ema model route, Show route) | |
=> Cli | |
-> (Some Action -> model -> route -> Asset LByteString) | How to render a route, given the model |
-> (forall m. (MonadIO m, MonadUnliftIO m, MonadLoggerIO m) => Some Action -> LVar model -> m b) | A long-running IO action that will update the |
-> IO (Either b (DSum Action Identity)) |
Like runEma
but takes the CLI action
Useful if you are handling CLI arguments yourself.