Safe Haskell | None |
---|---|
Language | Haskell2010 |
Internal implementation of Pencil's environment.
Synopsis
- data Value
- type Env = HashMap Text Value
- toValue :: Value -> Maybe Value
- toDateTime :: String -> Maybe UTCTime
- parseIso8601 :: Maybe String -> String -> Maybe UTCTime
- getNodes :: Env -> [PNode]
- findEnv :: [PNode] -> Env
- aesonToEnv :: Object -> Env
- maybeInsertIntoEnv :: Env -> Text -> Value -> Env
- getContent :: Env -> Maybe Text
- toText :: Value -> Text
- toTextRss :: Value -> Text
- rfc822DateFormat :: String
Documentation
toDateTime :: String -> Maybe UTCTime Source #
Accepted format is ISO 8601 (YYYY-MM-DD), optionally with an appended "THH:MM:SS". Examples:
- 2010-01-30
- 2010-01-30T09:08:00
parseIso8601 :: Maybe String -> String -> Maybe UTCTime Source #
Helper for parseTimeM
using ISO 8601. YYYY-MM-DDTHH:MM:SS and
YYYY-MM-DD formats.
https://hackage.haskell.org/package/time-1.9/docs/Data-Time-Format.html#v:iso8601DateFormat
getNodes :: Env -> [PNode] Source #
Gets the nodes from the env, from the this.nodes
variable. Returns empty
list if this variable is missing.
findEnv :: [PNode] -> Env Source #
Find preamble node, and load as an Env. If no preamble is found, return a blank Env.
aesonToEnv :: Object -> Env Source #
Converts an Aeson Object to an Env.
getContent :: Env -> Maybe Text Source #
Gets the rendered content from the env, from the this.content
variable.
Returns empty is the variable is missing (e.g. has not been rendered).
toText :: Value -> Text Source #
Renders environment value for human consumption. This is the default one.
rfc822DateFormat :: String Source #
RFC 822 date format.
Helps to pass https://validator.w3.org/feed/check.cgi.
Same as https://hackage.haskell.org/package/time/docs/Data-Time-Format.html#v:rfc822DateFormat but no padding for the day section, so that single-digit days only has one space preceeding it.
Also changed to spit out the offset timezone (+0000) because the default was spitting out UTC which is not valid RFC 822. Weird, since the defaultTimeLocal source and docs show that it won't use UTC: https://hackage.haskell.org/package/time/docs/Data-Time-Format.html#v:defaultTimeLocale