{-# LANGUAGE CPP, OverloadedStrings, QuasiQuotes, RecordWildCards #-} -- | Common page components and rendering helpers. -- For global page layout, see Application.hs. module Handler.Common where import Import import Data.List -- import Data.Text (Text) import qualified Data.Text as T import Data.Time.Calendar import System.FilePath (takeFileName) #if BLAZE_HTML_0_4 import Text.Blaze (preEscapedString) #else import Text.Blaze.Internal (preEscapedString) #endif import Text.Printf import Hledger.Utils import Hledger.Data import Hledger.Query import Hledger.Reports import Hledger.Cli.CliOptions import Hledger.Web.WebOptions ------------------------------------------------------------------------------- -- Common page layout -- | Standard hledger-web page layout. hledgerLayout :: ViewData -> String -> HtmlUrl AppRoute -> HandlerT App IO Html hledgerLayout vd title content = do defaultLayout $ do setTitle $ toHtml $ title ++ " - hledger-web" toWidget [hamlet| ^{topbar vd} ^{sidebar vd}
where journalcurrent = if here == JournalR then "current" else "" :: String accounts = balanceReportAsHtml opts vd $ balanceReport (reportopts_ $ cliopts_ opts){empty_=True} am j -- -- | Navigation link, preserving parameters and possibly highlighted. -- navlink :: ViewData -> String -> AppRoute -> String -> HtmlUrl AppRoute -- navlink VD{..} s dest title = [hamlet| -- #{s} -- |] -- where u' = (dest, if null q then [] else [("q", pack q)]) -- style | dest == here = "navlinkcurrent" -- | otherwise = "navlink" :: Text -- -- | Links to the various journal editing forms. -- editlinks :: HtmlUrl AppRoute -- editlinks = [hamlet| -- edit -- \ | # -- add --