hledger-web 0.16.5 → 0.17
raw patch · 4 files changed
+40/−34 lines, 4 filesdep +aesondep −aeson-nativedep ~cmdargsdep ~hledgerdep ~hledger-lib
Dependencies added: aeson
Dependencies removed: aeson-native
Dependency ranges changed: cmdargs, hledger, hledger-lib, template-haskell, yesod-core
Files
- Hledger/Web/Handlers.hs +23/−19
- Hledger/Web/Options.hs +6/−4
- hledger-web.cabal +8/−8
- hledger-web.hs +3/−3
Hledger/Web/Handlers.hs view
@@ -14,6 +14,7 @@ import Data.List import Data.Maybe import Data.Text(Text,pack,unpack)+import qualified Data.Text (null) import Data.Time.Calendar import Data.Time.Clock import Data.Time.Format@@ -27,7 +28,7 @@ import Yesod.Json import Hledger hiding (today)-import Hledger.Cli+import Hledger.Cli hiding (version) import Hledger.Web.Foundation import Hledger.Web.Options import Hledger.Web.Settings@@ -388,12 +389,15 @@ -- | Generate javascript/html for a register balance line chart based on -- the provided "TransactionsReportItem"s.-registerChartHtml items = [$hamlet|+registerChartHtml items =+ -- have to make sure plot is not called when our container (maincontent)+ -- is hidden, eg with add form toggled+ [$hamlet| <script type=text/javascript>- $(document).ready(function() {+ if (document.getElementById('maincontent').style.display != 'none')+ \$(document).ready(function() { /* render chart */- /* if ($('#register-chart')) */- $.plot($('#register-chart'),+ \$.plot($('#register-chart'), [ [ $forall i <- items@@ -436,20 +440,20 @@ ------------------------------------------------------------------------------- -- post handlers -postJournalR :: Handler RepPlain+postJournalR :: Handler RepHtml postJournalR = handlePost -postJournalEntriesR :: Handler RepPlain+postJournalEntriesR :: Handler RepHtml postJournalEntriesR = handlePost -postJournalEditR :: Handler RepPlain+postJournalEditR :: Handler RepHtml postJournalEditR = handlePost -postRegisterR :: Handler RepPlain+postRegisterR :: Handler RepHtml postRegisterR = handlePost -- | Handle a post from any of the edit forms.-handlePost :: Handler RepPlain+handlePost :: Handler RepHtml handlePost = do action <- lookupPostParam "action" case action of Just "add" -> handleAdd@@ -458,7 +462,7 @@ _ -> invalidArgs [pack "invalid action"] -- | Handle a post from the transaction add form.-handleAdd :: Handler RepPlain+handleAdd :: Handler RepHtml handleAdd = do VD{..} <- getViewData -- get form input values. M means a Maybe value.@@ -472,8 +476,9 @@ -- supply defaults and parse date and amounts, or get errors. let dateE = maybe (Left "date required") (either (\e -> Left $ showDateParseError e) Right . fixSmartDateStrEither today . unpack) dateM descE = Right $ maybe "" unpack descM- acct1E = maybe (Left "to account required") (Right . unpack) acct1M- acct2E = maybe (Left "from account required") (Right . unpack) acct2M+ maybeNonNull = maybe Nothing (\t -> if Data.Text.null t then Nothing else Just t)+ acct1E = maybe (Left "to account required") (Right . unpack) $ maybeNonNull acct1M+ acct2E = maybe (Left "from account required") (Right . unpack) $ maybeNonNull acct2M amt1E = maybe (Left "amount required") (either (const $ Left "could not parse amount") Right . parseWithCtx nullctx someamount . unpack) amt1M amt2E = maybe (Right missingamt) (either (const $ Left "could not parse amount") Right . parseWithCtx nullctx someamount . unpack) amt2M journalE = maybe (Right $ journalFilePath j)@@ -509,21 +514,20 @@ $forall e<-errs #{e}<br> |]- redirectParams RedirectTemporary RegisterR [("add","1")]- Right t -> do let t' = txnTieKnot t -- XXX move into balanceTransaction liftIO $ do ensureJournalFile journalpath appendToJournalFileOrStdout journalpath $ showTransaction t' -- setMessage $ toHtml $ (printf "Added transaction:\n%s" (show t') :: String) setMessage [$shamlet|<span>Added transaction:<small><pre>#{chomp $ show t'}</pre></small>|]- redirectParams RedirectTemporary RegisterR [("add","1")] + redirectParams RedirectTemporary RegisterR [("add","1")]+ chomp :: String -> String chomp = reverse . dropWhile (`elem` "\r\n") . reverse -- | Handle a post from the journal edit form.-handleEdit :: Handler RepPlain+handleEdit :: Handler RepHtml handleEdit = do VD{..} <- getViewData -- get form input values, or validation errors.@@ -569,7 +573,7 @@ jE -- | Handle a post from the journal import form.-handleImport :: Handler RepPlain+handleImport :: Handler RepHtml handleImport = do setMessage "can't handle file upload yet" redirect RedirectTemporary JournalR@@ -675,7 +679,7 @@ addform :: ViewData -> HtmlUrl AppRoute addform vd@VD{..} = [$hamlet| <script type=text/javascript>- $(document).ready(function() {+ \$(document).ready(function() { /* dhtmlxcombo setup */ window.dhx_globalImgPath="../static/"; var desccombo = new dhtmlXCombo("description");
Hledger/Web/Options.hs view
@@ -10,11 +10,13 @@ import System.Console.CmdArgs import System.Console.CmdArgs.Explicit -import Hledger.Cli hiding (progname,progversion)+import Hledger.Cli hiding (progname,version,prognameandversion) import Hledger.Web.Settings -progname = $(packageVariable (pkgName . package))-progversion = progname ++ " " ++ $(packageVariable (pkgVersion . package)) :: String+progname, version :: String+progname = $(packageVariable (pkgName . package))+version = $(packageVariable (pkgVersion . package))+prognameandversion = progname ++ " " ++ version :: String defbaseurlexample = (reverse $ drop 4 $ reverse $ defbaseurl defport) ++ "PORT" @@ -28,7 +30,7 @@ mainargsflag []){ modeGroupFlags = Group { groupUnnamed = webflags- ,groupHidden = []+ ,groupHidden = [flagNone ["binary-filename"] (setboolopt "binary-filename") "show the download filename for this executable, and exit"] ,groupNamed = [(generalflagstitle, generalflags1)] } ,modeHelpSuffix=[
hledger-web.cabal view
@@ -1,5 +1,5 @@ name: hledger-web-version: 0.16.5+version: 0.17 category: Finance synopsis: A web interface for the hledger accounting tool. description: @@ -17,7 +17,7 @@ homepage: http://hledger.org bug-reports: http://code.google.com/p/hledger/issues stability: beta-tested-with: GHC==6.12, GHC==7.0+tested-with: GHC==7.0, GHC==7.2 cabal-version: >= 1.6 build-type: Simple extra-tmp-files:@@ -71,13 +71,13 @@ Hledger.Web.Settings.StaticFiles Hledger.Web.Handlers build-depends:- hledger == 0.16.1- ,hledger-lib == 0.16.1+ hledger == 0.17+ ,hledger-lib == 0.17 ,HUnit ,base >= 4 && < 5 ,bytestring ,cabal-file-th- ,cmdargs >= 0.8 && < 0.9+ ,cmdargs >= 0.9.1 && < 0.10 ,directory ,filepath ,old-locale@@ -89,14 +89,14 @@ ,io-storage >= 0.3 && < 0.4 ,failure >= 0.1 && < 0.2 ,file-embed == 0.0.*- ,template-haskell >= 2.4 && < 2.6+ ,template-haskell >= 2.4 && < 2.7 ,yesod >= 0.9.2.1 && < 0.10- ,yesod-core+ ,yesod-core >= 0.9.4.1 && < 0.10 ,yesod-form ,yesod-json ,yesod-static >= 0.3- ,aeson-native >= 0.3.3.1+ ,aeson >= 0.3.2.13 ,blaze-html ,clientsession ,data-object
hledger-web.hs view
@@ -24,7 +24,7 @@ #endif import Hledger-import Hledger.Cli hiding (progname,progversion)+import Hledger.Cli hiding (progname,prognameandversion) import Prelude hiding (putStrLn) import Hledger.Utils.UTF8 (putStrLn) import Hledger.Web@@ -33,7 +33,7 @@ main :: IO () main = do opts <- getHledgerWebOpts- when (debug_ $ cliopts_ opts) $ printf "%s\n" progversion >> printf "opts: %s\n" (show opts)+ when (debug_ $ cliopts_ opts) $ printf "%s\n" prognameandversion >> printf "opts: %s\n" (show opts) runWith opts runWith :: WebOpts -> IO ()@@ -41,7 +41,7 @@ where run opts | "help" `in_` (rawopts_ $ cliopts_ opts) = putStr (showModeHelp webmode) >> exitSuccess- | "version" `in_` (rawopts_ $ cliopts_ opts) = putStrLn progversion >> exitSuccess+ | "version" `in_` (rawopts_ $ cliopts_ opts) = putStrLn prognameandversion >> exitSuccess | "binary-filename" `in_` (rawopts_ $ cliopts_ opts) = putStrLn (binaryfilename progname) | otherwise = journalFilePathFromOpts (cliopts_ opts) >>= ensureJournalFile >> withJournalDo' opts web