ShowUser.hs 546 B

1234567891011121314151617181920
  1. module ShowUser (plugin) where
  2. -- This plugin replaces $USER$ with the name of the currently logged in
  3. -- user, or the empty string if no one is logged in.
  4. import Network.Gitit.Interface
  5. plugin :: Plugin
  6. plugin = mkPageTransformM showuser
  7. showuser :: Inline -> PluginM Inline
  8. showuser (Math InlineMath x) | x == "USER" = do
  9. doNotCache -- tell gitit not to cache this page, as it has dynamic content
  10. mbUser <- askUser
  11. case mbUser of
  12. Nothing -> return $ Str ""
  13. Just u -> return $ Str $ uUsername u
  14. showuser x = return x