Skip to content
Snippets Groups Projects
Verified Commit ba544e38 authored by jan.hamal.dvorak's avatar jan.hamal.dvorak
Browse files

Add link feedback

parent aef39a58
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,8 @@ Maintainer : mordae@anilinux.org ...@@ -7,7 +7,8 @@ Maintainer : mordae@anilinux.org
Stability : unstable Stability : unstable
Portability : non-portable (ghc) Portability : non-portable (ghc)
This module provides various ways to build local links. This module provides various ways to build local links and provide
feedback based on the request path.
-} -}
module Hikaru.Link module Hikaru.Link
...@@ -18,6 +19,10 @@ module Hikaru.Link ...@@ -18,6 +19,10 @@ module Hikaru.Link
, lhref_ , lhref_
, phref_ , phref_
, qhref_ , qhref_
-- ** Path Feedback
, isActivePath
, isActivePrefix
) )
where where
import BasePrelude import BasePrelude
...@@ -96,4 +101,26 @@ where ...@@ -96,4 +101,26 @@ where
qhref_ qs = href_ (makeLink [] qs) qhref_ qs = href_ (makeLink [] qs)
-- Path Feedback -----------------------------------------------------------
-- |
-- Determine whether the supplied path is the one user has requested.
--
isActivePath :: (MonadAction m) => [Text] -> m Bool
isActivePath link = do
path <- getPathInfo
return $ link == path
-- |
-- Determine whether the supplied path is a prefix of the one user has
-- requested. Empty path components in the supplied path are ignored.
--
isActivePrefix :: (MonadAction m) => [Text] -> m Bool
isActivePrefix link = do
path <- getPathInfo
return $ isPrefixOf (filter (/= "") link) path
-- vim:set ft=haskell sw=2 ts=2 et: -- vim:set ft=haskell sw=2 ts=2 et:
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment