diff --git a/hledger-web/Hledger/Web/Application.hs b/hledger-web/Hledger/Web/Application.hs index ead279cc9..ebf078bbe 100644 --- a/hledger-web/Hledger/Web/Application.hs +++ b/hledger-web/Hledger/Web/Application.hs @@ -24,7 +24,7 @@ import Network.Wai (Application) import Hledger.Web.Foundation import Hledger.Web.Handlers import Hledger.Web.Options -import Hledger.Web.Settings (parseExtra) +import Hledger.Web.Settings (Extra(..), parseExtra) import Hledger.Web.Settings.StaticFiles (staticSite) -- This line actually creates our YesodSite instance. It is the second half diff --git a/hledger-web/Hledger/Web/Foundation.hs b/hledger-web/Hledger/Web/Foundation.hs index 2cc621ac3..15e360b1b 100644 --- a/hledger-web/Hledger/Web/Foundation.hs +++ b/hledger-web/Hledger/Web/Foundation.hs @@ -8,7 +8,6 @@ module Hledger.Web.Foundation , Handler , Widget , module Yesod.Core - , module Hledger.Web.Settings , liftIO ) where @@ -24,7 +23,7 @@ import Text.Hamlet import Hledger.Web.Options import qualified Hledger.Web.Settings -import Hledger.Web.Settings (Extra (..), widgetFile) +import Hledger.Web.Settings (Extra (..)) import Hledger.Web.Settings.StaticFiles @@ -75,8 +74,8 @@ instance Yesod App where encryptKey _ = fmap Just $ getKey "client_session_key.aes" defaultLayout widget = do - master <- getYesod - mmsg <- getMessage + -- master <- getYesod + -- mmsg <- getMessage -- We break up the default layout into two components: -- default-layout is the contents of the body tag, and -- default-layout-wrapper is the entire page. Since the final @@ -88,7 +87,7 @@ instance Yesod App where -- hamletToRepHtml $(hamletFile "templates/default-layout-wrapper.hamlet") pc <- widgetToPageContent $ do widget - hamletToRepHtml [$hamlet| + hamletToRepHtml [hamlet| !!! )) --- import Data.Aeson -import Data.ByteString (ByteString) import Data.Either (lefts,rights) import Data.List import Data.Maybe @@ -19,7 +17,7 @@ import qualified Data.Text (null) import Data.Time.Calendar import Data.Time.Clock import Data.Time.Format -import System.FilePath (takeFileName, ()) +import System.FilePath (takeFileName) import System.IO.Storage (putValue, getValue) import System.Locale (defaultTimeLocale) import Text.Blaze (preEscapedString, toHtml) @@ -28,7 +26,7 @@ import Text.Printf import Yesod.Core -- import Yesod.Json -import Hledger hiding (today) +import Hledger hiding (today,subs,is,d) import Hledger.Cli hiding (version) import Hledger.Web.Foundation import Hledger.Web.Options @@ -60,15 +58,15 @@ getJournalR = do filtering = m /= Any -- showlastcolumn = if injournal && not filtering then False else True title = case inacct of - Nothing -> "Journal"++filter - Just (a,subs) -> "Transactions in "++a++andsubs++filter - where andsubs = if subs then " (and subaccounts)" else "" + Nothing -> "Journal"++s2 + Just (a,subs) -> "Transactions in "++a++s1++s2 + where s1 = if subs then " (and subaccounts)" else "" where - filter = if filtering then ", filtered" else "" + s2 = if filtering then ", filtered" else "" maincontent = journalTransactionsReportAsHtml opts vd $ journalTransactionsReport (reportopts_ $ cliopts_ opts) j m defaultLayout $ do setTitle "hledger-web journal" - addHamlet [$hamlet| + addHamlet [hamlet| ^{topbar vd} ViewData -> AccountsReport -> HtmlUrl AppRoute accountsReportAsHtml _ vd@VD{..} (items',total) = - [$hamlet| + [hamlet| [+] filter (matchesAccount m . \(a,_,_,_)->a) items') showacctmatcher itemAsHtml :: ViewData -> AccountsReportItem -> HtmlUrl AppRoute - itemAsHtml _ (acct, adisplay, aindent, abal) = [$hamlet| + itemAsHtml _ (acct, adisplay, aindent, abal) = [hamlet| if m `matchesAccount` acct then "inacct" else "notinacct" + Just m' -> if m' `matchesAccount` acct then "inacct" else "notinacct" Nothing -> "" :: String indent = preEscapedString $ concat $ replicate (2 * (1+aindent)) " " acctquery = (RegisterR, [("q", pack $ accountQuery acct)]) @@ -274,19 +272,19 @@ accountQuery a = "inacct:" ++ quoteIfSpaced a -- (accountNameToAccountRegex a) accountOnlyQuery :: AccountName -> String accountOnlyQuery a = "inacctonly:" ++ quoteIfSpaced a -- (accountNameToAccountRegex a) --- accountUrl :: AppRoute -> AccountName -> (AppRoute,[(String,ByteString)]) -accountUrl r a = (r, [("q",pack $ accountQuery a)]) +accountUrl :: AppRoute -> AccountName -> (AppRoute, [(Text, Text)]) +accountUrl r a = (r, [("q", pack $ accountQuery a)]) -- | Render a "EntriesReport" as HTML for the journal entries view. entriesReportAsHtml :: WebOpts -> ViewData -> EntriesReport -> HtmlUrl AppRoute -entriesReportAsHtml _ vd items = [$hamlet| +entriesReportAsHtml _ vd items = [hamlet| $forall i <- numbered items ^{itemAsHtml vd i} |] where itemAsHtml :: ViewData -> (Int, EntriesReportItem) -> HtmlUrl AppRoute - itemAsHtml _ (n, t) = [$hamlet| + itemAsHtml _ (n, t) = [hamlet|
#{txn}
@@ -297,7 +295,7 @@ entriesReportAsHtml _ vd items = [$hamlet|
 
 -- | Render an "TransactionsReport" as HTML for the formatted journal view.
 journalTransactionsReportAsHtml :: WebOpts -> ViewData -> TransactionsReport -> HtmlUrl AppRoute
-journalTransactionsReportAsHtml _ vd (_,items) = [$hamlet|
+journalTransactionsReportAsHtml _ vd (_,items) = [hamlet|
 Date
@@ -310,19 +308,19 @@ journalTransactionsReportAsHtml _ vd (_,items) = [$hamlet|
  where
 -- .#{datetransition}
    itemAsHtml :: ViewData -> (Int, Bool, Bool, Bool, TransactionsReportItem) -> HtmlUrl AppRoute
-   itemAsHtml VD{..} (n, _, _, _, (t, _, split, _, amt, _)) = [$hamlet|
+   itemAsHtml VD{..} (n, _, _, _, (t, _, split, _, amt, _)) = [hamlet|
 #{date}
  #{elideRight 60 desc}
  
   $if showamt
    #{mixedAmountAsHtml amt}
-$forall p <- tpostings t
+$forall p' <- tpostings t
    #{elideRight 40 $ paccount p}
-   #{mixedAmountAsHtml $ pamount p}
+    #{elideRight 40 $ paccount p'}
+   #{mixedAmountAsHtml $ pamount p'}
 |]
      where
        evenodd = if even n then "even" else "odd" :: String
@@ -335,14 +333,14 @@ $forall p <- tpostings t
 
 -- Generate html for an account register, including a balance chart and transaction list.
 registerReportHtml :: WebOpts -> ViewData -> TransactionsReport -> HtmlUrl AppRoute
-registerReportHtml opts vd r@(_,items) = [$hamlet|
+registerReportHtml opts vd r@(_,items) = [hamlet|
  ^{registerChartHtml items}
  ^{registerItemsHtml opts vd r}
 |]
 
 -- Generate html for a transaction list from an "TransactionsReport".
 registerItemsHtml :: WebOpts -> ViewData -> TransactionsReport -> HtmlUrl AppRoute
-registerItemsHtml _ vd (balancelabel,items) = [$hamlet|
+registerItemsHtml _ vd (balancelabel,items) = [hamlet|
 Date
@@ -360,7 +358,7 @@ registerItemsHtml _ vd (balancelabel,items) = [$hamlet|
    -- inacct = inAccount qopts
    -- filtering = m /= Any
    itemAsHtml :: ViewData -> (Int, Bool, Bool, Bool, TransactionsReportItem) -> HtmlUrl AppRoute
-   itemAsHtml VD{..} (n, newd, newm, _, (t, _, split, acct, amt, bal)) = [$hamlet|
+   itemAsHtml VD{..} (n, newd, newm, _, (t, _, split, acct, amt, bal)) = [hamlet|
 #{date}
  #{elideRight 30 desc}
@@ -374,12 +372,12 @@ registerItemsHtml _ vd (balancelabel,items) = [$hamlet|
   $if showamt
    #{mixedAmountAsHtml amt}
  #{mixedAmountAsHtml bal}
-$forall p <- tpostings t
+$forall p' <- tpostings t
   #{elideRight 40 $ paccount p}
-   #{mixedAmountAsHtml $ pamount p}
+    #{elideRight 40 $ paccount p'}
+   #{mixedAmountAsHtml $ pamount p'}
    
 |]
      where
@@ -394,10 +392,15 @@ $forall p <- tpostings t
 
 -- | Generate javascript/html for a register balance line chart based on
 -- the provided "TransactionsReportItem"s.
+               -- registerChartHtml :: forall t (t1 :: * -> *) t2 t3 t4 t5.
+               --                      Data.Foldable.Foldable t1 =>
+               --                      t1 (Transaction, t2, t3, t4, t5, MixedAmount)
+               --                      -> t -> Text.Blaze.Internal.HtmlM ()
+registerChartHtml :: [TransactionsReportItem] -> HtmlUrl AppRoute
 registerChartHtml items =
  -- have to make sure plot is not called when our container (maincontent)
  -- is hidden, eg with add form toggled
- [$hamlet|
+ [hamlet|