Skip to content

Commit

Permalink
Add refererLink splice
Browse files Browse the repository at this point in the history
  • Loading branch information
mightybyte committed Apr 3, 2013
1 parent 33801ee commit e9b7ad0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Snap/Extras/SpliceUtils/Compiled.hs
Expand Up @@ -19,9 +19,15 @@ import Text.XmlHtml

utilSplices :: MonadSnap m => [(Text, Splice m)]
utilSplices = [ ("rqparam", paramSplice)
, ("refererLink", refererCSplice)
]


refererCSplice :: MonadSnap m => Splice m
refererCSplice = return $ yieldRuntimeText $ return .
maybe "/" T.decodeUtf8 =<< lift (getsRequest (getHeader "Referer"))


------------------------------------------------------------------------------
-- | Gets the value of a request parameter. Example use:
--
Expand Down
7 changes: 7 additions & 0 deletions src/Snap/Extras/SpliceUtils/Interpreted.hs
Expand Up @@ -8,6 +8,7 @@ module Snap.Extras.SpliceUtils.Interpreted
, runTextAreas
, scriptsSplice
, ifFlagSplice
, refererSplice
) where

-------------------------------------------------------------------------------
Expand All @@ -32,9 +33,15 @@ import Text.XmlHtml
utilSplices :: [(Text, SnapletISplice b)]
utilSplices =
[ ("rqparam", paramSplice)
, ("refererLink", refererSplice)
]


refererSplice :: MonadSnap m => Splice m
refererSplice =
textSplice . maybe "/" T.decodeUtf8 =<< lift (getsRequest (getHeader "Referer"))


------------------------------------------------------------------------------
-- | Gets the value of a request parameter. Example use:
--
Expand Down

0 comments on commit e9b7ad0

Please sign in to comment.