{-# LANGUAGE QuasiQuotes #-}{-# LANGUAGE GeneralizedNewtypeDeriving #-}{-# LANGUAGE CPP #-}{-# LANGUAGE OverloadedStrings #-}{-# LANGUAGE DeriveDataTypeable #-}-- | Normal users should never need access to these.---- Note that no guarantees of API stability are provided on this module. Use at your own risk.moduleYesod.Internal(-- * Error responsesErrorResponse(..),HandlerContents(..)-- * Header,Header(..)-- * Cookie names,langKey-- * Widgets,GWData(..),Location(..),UniqueList(..),Script(..),Stylesheet(..),Title(..),Head(..),Body(..),locationToHtmlUrl,runUniqueList,toUnique-- * Names,tokenKey)whereimportText.Hamlet(HtmlUrl,Html)importText.Blaze.Html(toHtml)importText.Julius(JavascriptUrl)importData.Monoid(Monoid(..),Last)importData.List(nub)importData.Text(Text)importData.Typeable(Typeable)importControl.Exception(Exception)importqualifiedNetwork.HTTP.TypesasHimportData.String(IsString)importqualifiedData.MapasMapimportData.Text.Lazy.Builder(Builder)importWeb.Cookie(SetCookie(..))importData.ByteString(ByteString)importqualifiedNetwork.WaiasWimportYesod.Content(ChooseRep,ContentType)-- | Responses to indicate some form of an error occurred. These are different-- from 'SpecialResponse' in that they allow for custom error pages.dataErrorResponse=NotFound|InternalErrorText|InvalidArgs[Text]|PermissionDeniedText|BadMethodH.Methodderiving(Show,Eq,Typeable)instanceExceptionErrorResponse----- header stuff-- | Headers to be added to a 'Result'.dataHeader=AddCookieSetCookie|DeleteCookieByteStringByteString|HeaderByteStringByteStringderiving(Eq,Show)langKey::IsStringa=>alangKey="_LANG"dataLocationurl=Localurl|RemoteTextderiving(Show,Eq)locationToHtmlUrl::Locationurl->HtmlUrlurllocationToHtmlUrl(Localurl)render=toHtml$renderurl[]locationToHtmlUrl(Remotes)_=toHtmlsnewtypeUniqueListx=UniqueList([x]->[x])instanceMonoid(UniqueListx)wheremempty=UniqueListidUniqueListx`mappend`UniqueListy=UniqueList$x.yrunUniqueList::Eqx=>UniqueListx->[x]runUniqueList(UniqueListx)=nub$x[]toUnique::x->UniqueListxtoUnique=UniqueList.(:)dataScripturl=Script{scriptLocation::Locationurl,scriptAttributes::[(Text,Text)]}deriving(Show,Eq)dataStylesheeturl=Stylesheet{styleLocation::Locationurl,styleAttributes::[(Text,Text)]}deriving(Show,Eq)newtypeTitle=Title{unTitle::Html}newtypeHeadurl=Head(HtmlUrlurl)derivingMonoidnewtypeBodyurl=Body(HtmlUrlurl)derivingMonoidtokenKey::IsStringa=>atokenKey="_TOKEN"typeCssBuilderUrla=(a->[(Text,Text)]->Text)->BuilderdataGWDataa=GWData{gwdBody::!(Bodya),gwdTitle::!(LastTitle),gwdScripts::!(UniqueList(Scripta)),gwdStylesheets::!(UniqueList(Stylesheeta)),gwdCss::!(Map.Map(MaybeText)(CssBuilderUrla))-- media type,gwdJavascript::!(Maybe(JavascriptUrla)),gwdHead::!(Heada)}instanceMonoid(GWDataa)wheremempty=GWDatamemptymemptymemptymemptymemptymemptymemptymappend(GWDataa1a2a3a4a5a6a7)(GWDatab1b2b3b4b5b6b7)=GWData(a1`mappend`b1)(a2`mappend`b2)(a3`mappend`b3)(a4`mappend`b4)(Map.unionWithmappenda5b5)(a6`mappend`b6)(a7`mappend`b7)dataHandlerContents=HCContentH.StatusChooseRep|HCErrorErrorResponse|HCSendFileContentTypeFilePath(MaybeW.FilePart)-- FIXME replace FilePath with opaque type from system-filepath?|HCRedirectH.StatusText|HCCreatedText|HCWaiW.ResponsederivingTypeableinstanceShowHandlerContentswhereshow_="Cannot show a HandlerContents"instanceExceptionHandlerContents