File: ShowUser.hs

package info (click to toggle)
gitit 0.12.1.1%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,008 kB
  • ctags: 78
  • sloc: haskell: 4,963; xml: 245; sh: 65; makefile: 16
file content (19 lines) | stat: -rw-r--r-- 546 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
module ShowUser (plugin) where

-- This plugin replaces $USER$ with the name of the currently logged in
-- user, or the empty string if no one is logged in.

import Network.Gitit.Interface

plugin :: Plugin
plugin = mkPageTransformM showuser

showuser :: Inline -> PluginM Inline
showuser (Math InlineMath x) | x == "USER"  = do
  doNotCache  -- tell gitit not to cache this page, as it has dynamic content
  mbUser <- askUser
  case mbUser of
       Nothing -> return $ Str ""
       Just u  -> return $ Str $ uUsername u
showuser x = return x