Skip to content

Added "loggedinuser" template variable #414

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Network/Gitit/Layout.hs
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,14 @@ defaultRenderPage :: T.StringTemplate String -> PageLayout -> Html -> Handler
defaultRenderPage templ layout htmlContents = do
cfg <- getConfig
base' <- getWikiBase
user <- getLoggedInUser
ok . setContentType "text/html; charset=utf-8" . toResponse . T.render .
filledPageTemplate base' cfg layout htmlContents $ templ
filledPageTemplate base' user cfg layout htmlContents $ templ

-- | Returns a page template with gitit variables filled in.
filledPageTemplate :: String -> Config -> PageLayout -> Html ->
filledPageTemplate :: String -> Maybe User -> Config -> PageLayout -> Html ->
T.StringTemplate String -> T.StringTemplate String
filledPageTemplate base' cfg layout htmlContents templ =
filledPageTemplate base' user cfg layout htmlContents templ =
let rev = pgRevision layout
page = pgPageName layout
prefixedScript x = case x of
Expand Down Expand Up @@ -109,6 +110,7 @@ filledPageTemplate base' cfg layout htmlContents templ =
setBoolAttr "isdiscusspage" (isDiscussPage page) .
setBoolAttr "pagetools" (pgShowPageTools layout) .
setBoolAttr "sitenav" (pgShowSiteNav layout) .
maybe id (T.setAttribute "loggedinuser" . uUsername) user .
maybe id (T.setAttribute "markuphelp") (pgMarkupHelp layout) .
setBoolAttr "printable" (pgPrintable layout) .
maybe id (T.setAttribute "revision") rev .
Expand Down