From 03f6119a8d9a3627dfd9fe00eb3e0ed555da23f8 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Fri, 29 Mar 2013 23:21:51 +0000 Subject: [PATCH] notes: snippets --- NOTES.org | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/NOTES.org b/NOTES.org index d23e92862..f726e6ef8 100644 --- a/NOTES.org +++ b/NOTES.org @@ -321,6 +321,34 @@ statistical filing, invoicing and the like. ** snippets +-- type Regexp = String + +-- regexMatchesRegexCompat :: Regexp -> String -> Bool +-- regexMatchesRegexCompat = flip (=~) + + +{- +-- | A simple accounts view. This one is json-capable, returning the chart +-- of accounts as json if the Accept header specifies json. +getAccountsR :: Handler RepHtmlJson +getAccountsR = do + vd@VD{..} <- getViewData + let j' = filterJournalPostings2 m j + html = do + setTitle "hledger-web accounts" + toWidget $ accountsReportAsHtml opts vd $ accountsReport2 (reportopts_ $ cliopts_ opts) am j' + json = jsonMap [("accounts", toJSON $ journalAccountNames j')] + defaultLayoutJson html json + +-- | A json-only version of "getAccountsR", does not require the special Accept header. +getAccountsJsonR :: Handler RepJson +getAccountsJsonR = do + VD{..} <- getViewData + let j' = filterJournalPostings2 m j + jsonToRepJson $ jsonMap [("accounts", toJSON $ journalAccountNames j')] +-} + + let assertAccountsReportItemEqual ((ea1,ea2,ei,eamt), (aa1,aa2,ai,aamt)) = do assertEqual "full account name" ea1 aa1 assertEqual "short account name" ea2 aa2