pencil-1.0.1: Static site generator

Safe HaskellNone
LanguageHaskell2010

Pencil.Env.Internal

Description

Internal implementation of Pencil's environment.

Synopsis

Documentation

data Value Source #

Represents the data types found in an environment.

This includes at least Aeson Value types, plus other useful ones.

Instances
Eq Value Source # 
Instance details

Defined in Pencil.Env.Internal

Methods

(==) :: Value -> Value -> Bool #

(/=) :: Value -> Value -> Bool #

Show Value Source # 
Instance details

Defined in Pencil.Env.Internal

Methods

showsPrec :: Int -> Value -> ShowS #

show :: Value -> String #

showList :: [Value] -> ShowS #

type Env = HashMap Text Value Source #

Environment map of variables to Values.

toValue :: Value -> Maybe Value Source #

Converts an Aeson Value to a Pencil Value.

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

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.

maybeInsertIntoEnv :: Env -> Text -> Value -> Env Source #

Convert known Aeson Value into a Pencil Value, and insert into the env. If there is no conversion possible, the env is not modified.

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.

toTextRss :: Value -> Text Source #

A version of toText that renders Value acceptable for an RSS feed.

  • Dates are rendered in the RFC 822 format.
  • Everything else defaults to the toText implementation.

You'll probably want to also use escapeXml to render an RSS feed.

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