diff --git a/hledger-web/Application.hs b/hledger-web/Application.hs index a39ea9bf2..592eac9ab 100644 --- a/hledger-web/Application.hs +++ b/hledger-web/Application.hs @@ -14,10 +14,13 @@ import Network.HTTP.Conduit (newManager, def) -- Import all relevant handler modules here. -- Don't forget to add new modules to your cabal file! --- import Handler.Home -import Handler.Handlers +import Handler.RootR +import Handler.JournalR +import Handler.JournalEditR +import Handler.JournalEntriesR +import Handler.RegisterR -import Hledger.Web.Options +import Hledger.Web.Options (defwebopts) -- This line actually creates our YesodDispatch instance. It is the second half -- of the call to mkYesodData which occurs in Foundation.hs. Please see the diff --git a/hledger-web/Handler/Common.hs b/hledger-web/Handler/Common.hs new file mode 100644 index 000000000..c611bd015 --- /dev/null +++ b/hledger-web/Handler/Common.hs @@ -0,0 +1,256 @@ +-- | Common page components. + +module Handler.Common where + +import Import + +import Data.List (sort, nub) +import System.FilePath (takeFileName) + +import Handler.Utils +import Hledger.Data +import Hledger.Query +import Hledger.Reports +import Hledger.Cli.Options +import Hledger.Web.Options + + +-- | 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| +