-- | Common page components and rendering helpers. module Handler.Common where import Import import Data.List import Data.Maybe import Data.Text(pack) import Data.Time.Calendar import System.FilePath (takeFileName) #if BLAZE_HTML_0_5 import Text.Blaze.Internal (preEscapedString) #else import Text.Blaze (preEscapedString) #endif import Text.Printf import Hledger.Utils import Hledger.Data import Hledger.Query import Hledger.Reports import Hledger.Cli.Options import Hledger.Web.Options import Handler.Utils ------------------------------------------------------------------------------- -- Page components -- | Global toolbar/heading area. topbar :: ViewData -> HtmlUrl AppRoute topbar VD{..} = [hamlet| hledger-web
#{version} manual

#{title} $maybe m' <- msg #{m'} |] where title = takeFileName $ journalFilePath j -- | The sidebar used on most views. sidebar :: ViewData -> HtmlUrl AppRoute sidebar vd@VD{..} = accountsReportAsHtml opts vd $ accountsReport (reportopts_ $ cliopts_ opts) 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 -- import transactions -- |] -- | Search form for entering custom queries to filter journal data. searchform :: ViewData -> HtmlUrl AppRoute searchform VD{..} = [hamlet|
Search: \ # $if filtering \ # clear search \ # help
Leave blank to see journal (all transactions), or click account links to see transactions under that account.
Transactions/postings may additionally be filtered by:
acct:REGEXP (target account), # desc:REGEXP (description), # date:PERIODEXP (date), # edate:PERIODEXP (effective date), #
status:BOOL (cleared status), # real:BOOL (real/virtual-ness), # empty:BOOL (posting amount = 0).
not: to negate, enclose space-containing patterns in quotes, multiple filters are AND'ed. |] where filtering = not $ null q -- | Add transaction form. addform :: ViewData -> HtmlUrl AppRoute addform vd@VD{..} = [hamlet|