From a1a17acb326020f1b57f587230cb439e901784df Mon Sep 17 00:00:00 2001 From: Daniel Gnoutcheff Date: Fri, 27 May 2016 16:00:00 -0400 Subject: Ported to Debian jessie Most of the churn here comes from rebasing the Yesod boilerplate. --- Handler/Journal.hs | 10 +++------- Handler/Register.hs | 10 +++------- 2 files changed, 6 insertions(+), 14 deletions(-) (limited to 'Handler') diff --git a/Handler/Journal.hs b/Handler/Journal.hs index dc68fa5..aa9d18c 100644 --- a/Handler/Journal.hs +++ b/Handler/Journal.hs @@ -25,19 +25,15 @@ import qualified Data.Map as Map typeCsv :: ContentType typeCsv = "text/csv; charset=utf-8" -newtype RepCsv = RepCsv Content -instance HasReps RepCsv where - chooseRep (RepCsv c) _ = return (typeCsv, c) - -getJournalR :: JReportType -> Text -> Handler RepCsv +getJournalR :: JReportType -> Text -> Handler TypedContent getJournalR jrt ledger = do ledgers <- fmap hledgerConfig getYesod case Map.lookup ledger ledgers of Nothing -> notFound Just fn -> do csv <- liftIO $ (jReport jrt) fn - setHeader "Content-Disposition" (T.concat ["attachment; filename=", ledger, "-", (T.pack . show) jrt, ".csv"]) - return $ RepCsv $ toContent csv + addHeader "Content-Disposition" (T.concat ["attachment; filename=", ledger, "-", (T.pack . show) jrt, ".csv"]) + sendResponse (typeCsv, toContent csv) where jReport PandL = pAndL jReport Assets = assets diff --git a/Handler/Register.hs b/Handler/Register.hs index 26e38a2..2718036 100644 --- a/Handler/Register.hs +++ b/Handler/Register.hs @@ -25,16 +25,12 @@ import qualified Data.Map as Map typeCsv :: ContentType typeCsv = "text/csv; charset=utf-8" -newtype RepCsv = RepCsv Content -instance HasReps RepCsv where - chooseRep (RepCsv c) _ = return (typeCsv, c) - -getRegisterR :: Text -> Handler RepCsv +getRegisterR :: Text -> Handler TypedContent getRegisterR ledger = do ledgers <- fmap hledgerConfig getYesod case Map.lookup ledger ledgers of Nothing -> notFound Just fn -> do csv <- liftIO $ convertJournalToRegisterCSV fn - setHeader "Content-Disposition" (T.concat ["attachment; filename=", ledger, ".csv"]) - return $ RepCsv $ toContent csv + addHeader "Content-Disposition" (T.concat ["attachment; filename=", ledger, ".csv"]) + sendResponse (typeCsv, toContent csv) -- cgit v1.2.3