hledger-web 1.40 → 1.41
raw patch · 11 files changed
+166/−88 lines, 11 filesdep +base-compatdep −ghc-debug-stubdep ~basedep ~hledgerdep ~hledger-lib
Dependencies added: base-compat
Dependencies removed: ghc-debug-stub
Dependency ranges changed: base, hledger, hledger-lib
Files
- CHANGES.md +34/−0
- Hledger/Web/Handler/MiscR.hs +1/−1
- Hledger/Web/Handler/RegisterR.hs +3/−2
- Hledger/Web/Main.hs +20/−2
- Hledger/Web/Test.hs +2/−1
- hledger-web.1 +12/−6
- hledger-web.cabal +24/−27
- hledger-web.info +22/−25
- hledger-web.txt +12/−6
- static/hledger.js +25/−12
- templates/add-form.hamlet +11/−6
CHANGES.md view
@@ -22,6 +22,40 @@ See also the hledger changelog. +# 2024-12-09 1.41++Breaking changes++- When built with ghc 9.10.1, error messages are displayed with two extra trailing newlines.++Fixes++- Autocompletions now work in newly created account fields. [#2215]++- Bash shell completions are now up to date. [#986]++Features++Improvements++- Added --pager and --color options as in hledger, affecting command line help.++- Added a new `debug` build flag. Builds made with ghc 9.10+ and this flag+ will show some kind of partial stack trace if the program exits with an error.+ These will improve in future ghc versions.++- Disabled the unused `ghcdebug` build flag and ghc-debug support, for now.++- allow megaparsec 9.7++- ghc 9.10 / base 4.20 are now supported.++Docs++- Install, manual: new shell completions doc. [#986]+++ # 1.40 2024-09-09 Improvements
Hledger/Web/Handler/MiscR.hs view
@@ -84,7 +84,7 @@ VD{j} <- getViewData require ViewPermission selectRep $ do- provideJson $ (M.keys . jinferredcommodities) j+ provideJson $ (M.keys . jinferredcommoditystyles) j getAccountsR :: Handler TypedContent getAccountsR = do
Hledger/Web/Handler/RegisterR.hs view
@@ -9,9 +9,9 @@ module Hledger.Web.Handler.RegisterR where +import qualified Data.List.NonEmpty.Compat as NonEmpty -- from base-compat for ghc 8.10 import Data.List (intersperse, nub, partition) import qualified Data.Text as T-import Safe (tailDef) import Text.Hamlet (hamletFile) import Hledger@@ -42,10 +42,11 @@ map (\(acct,(name,comma)) -> (acct, (T.pack name, T.pack comma))) . undecorateLinks . elideRightDecorated 40 . decorateLinks . addCommas . preferReal . otherTransactionAccounts q acctQuery+ snoc xs x = NonEmpty.prependList xs $ NonEmpty.singleton x addCommas xs = zip xs $ zip (map (T.unpack . accountSummarisedName . paccount) xs) $- tailDef [""] $ (", "<$xs)+ NonEmpty.tail $ snoc (", "<$xs) "" items = styleAmounts (journalCommodityStylesWith HardRounding j) $ accountTransactionsReport rspec{_rsQuery=q} j acctQuery
Hledger/Web/Main.hs view
@@ -5,6 +5,7 @@ Released under GPL version 3 or later. -} +{-# LANGUAGE CPP #-} {-# LANGUAGE MultiWayIf #-} {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE OverloadedStrings #-}@@ -12,6 +13,9 @@ module Hledger.Web.Main where import Control.Exception (bracket)+#if MIN_VERSION_base(4,20,0)+import Control.Exception.Backtrace (setBacktraceMechanismState, BacktraceMechanism(..))+#endif import Control.Monad (when) import Data.String (fromString) import qualified Data.Text as T@@ -49,13 +53,27 @@ hledgerWebMain = withGhcDebug' $ do when (ghcDebugMode == GDPauseAtStart) $ ghcDebugPause' +#if MIN_VERSION_base(4,20,0)+ -- Control ghc 9.10+'s stack traces.+ -- CostCentreBacktrace - collect cost-centre stack backtraces (only available when built with profiling)+ -- HasCallStackBacktrace - collect HasCallStack backtraces+ -- ExecutionBacktrace - collect backtraces from native execution stack unwinding+ -- IPEBacktrace - collect backtraces from Info Table Provenance Entries+#ifdef DEBUG+ setBacktraceMechanismState HasCallStackBacktrace True+#else+ setBacktraceMechanismState HasCallStackBacktrace False+#endif+#endif+ -- try to encourage user's $PAGER to properly display ANSI (in command line help)- when useColorOnStdout setupPager+ usecolor <- useColorOnStdout+ when usecolor setupPager wopts@WebOpts{cliopts_=copts@CliOpts{debug_, rawopts_}} <- getHledgerWebOpts when (debug_ > 0) $ printf "%s\n" prognameandversion >> printf "opts: %s\n" (show wopts) if- | boolopt "help" rawopts_ -> pager $ showModeUsage webmode ++ "\n"+ | boolopt "help" rawopts_ -> runPager $ showModeUsage webmode ++ "\n" | boolopt "tldr" rawopts_ -> runTldrForPage "hledger-web" | boolopt "info" rawopts_ -> runInfoForTopic "hledger-web" Nothing | boolopt "man" rawopts_ -> runManForTopic "hledger-web" Nothing
Hledger/Web/Test.hs view
@@ -126,9 +126,10 @@ -- yit "can add transactions" $ do + usecolor <- useColorOnStdout let rawopts = [("forecast","")]- iopts = rawOptsToInputOpts d $ mkRawOpts rawopts+ iopts = rawOptsToInputOpts d usecolor True $ mkRawOpts rawopts f = "fake" -- need a non-null filename so forecast transactions get index 0 pj <- readJournal' (T.pack $ unlines -- PARTIAL: readJournal' should not fail ["~ monthly"
hledger-web.1 view
@@ -1,5 +1,5 @@ -.TH "HLEDGER\-WEB" "1" "September 2024" "hledger-web-1.40 " "hledger User Manuals"+.TH "HLEDGER\-WEB" "1" "October 2024" "hledger-web-1.41 " "hledger User Manuals" @@ -17,7 +17,7 @@ .PD \f[CR]hledger web \-\- [OPTS] [QUERY]\f[R] .SH DESCRIPTION-This manual is for hledger\[aq]s web interface, version 1.40.+This manual is for hledger\[aq]s web interface, version 1.41. See also the hledger manual for common concepts and file formats. .PP hledger is a robust, user\-friendly, cross\-platform set of programs for@@ -166,9 +166,11 @@ \-C \-\-cleared include only cleared postings/transactions (\-U/\-P/\-C can be combined) \-R \-\-real include only non\-virtual postings- \-\-depth=NUM or \-NUM: show only top NUM levels of accounts \-E \-\-empty Show zero items, which are normally hidden. In hledger\-ui & hledger\-web, do the opposite.+ \-\-depth=DEPTHEXP if a number (or \-NUM): show only top NUM levels+ of accounts. If REGEXP=NUM, only apply limiting to+ accounts matching the regular expression. \-B \-\-cost show amounts converted to their cost/sale amount \-V \-\-market Show amounts converted to their value at period end(s) in their default valuation commodity.@@ -185,8 +187,6 @@ YYYY\-MM\-DD: value on given date \-c \-\-commodity\-style=S Override a commodity\[aq]s display style. Eg: \-c \[aq].\[aq] or \-c \[aq]1.000,00 EUR\[aq]- \-\-color=YN \-\-colour Use ANSI color codes in text output? Can be- \[aq]y\[aq]/\[aq]yes\[aq]/\[aq]always\[aq], \[aq]n\[aq]/\[aq]no\[aq]/\[aq]never\[aq] or \[aq]auto\[aq]. \-\-pretty[=YN] Use box\-drawing characters in text output? Can be \[aq]y\[aq]/\[aq]yes\[aq] or \[aq]n\[aq]/\[aq]no\[aq]. If YN is specified, the equals is required.@@ -198,6 +198,8 @@ \-\-man show the manual with man \-\-version show version information \-\-debug=[1\-9] show this much debug output (default: 1)+ \-\-pager=YN use a pager when needed ? y/yes (default) or n/no+ \-\-color=YNA \-\-colour use ANSI color ? y/yes, n/no, or auto (default) .EE .PP hledger\-web shows accounts with zero balances by default (like@@ -211,6 +213,10 @@ Reporting options and/or query arguments can be used to set an initial query, which although not shown in the UI, will restrict the data shown (in addition to any search query entered in the UI).+.PP+If you use the bash shell, you can auto\-complete flags by pressing TAB+in the command line.+If this is not working see Install > Shell completions. .SH PERMISSIONS By default, hledger\-web allows anyone who can reach it to view the journal and to add new transactions, but not to change existing data.@@ -496,7 +502,7 @@ Default: \f[CR]$HOME/.hledger.journal\f[R]. .SH BUGS We welcome bug reports in the hledger issue tracker (shortcut:-http://bugs.hledger.org), or on the #hledger chat or hledger mail list+https://bugs.hledger.org), or on the hledger chat or mail list (https://hledger.org/support). .PP Some known issues:
hledger-web.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: hledger-web-version: 1.40+version: 1.41 synopsis: Web user interface for the hledger accounting system description: A simple web user interface for the hledger accounting system, providing a more modern UI than the command-line or terminal interfaces.@@ -112,16 +112,16 @@ type: git location: https://github.com/simonmichael/hledger +flag debug+ description: Build with GHC 9.10+'s stack traces enabled+ manual: True+ default: False+ flag dev description: Turn on development settings, like auto-reload templates. manual: False default: False -flag ghcdebug- description: Build with support for attaching a ghc-debug client- manual: True- default: False- flag library-only description: Build for use with "yesod devel" manual: False@@ -156,11 +156,12 @@ hs-source-dirs: ./ ghc-options: -Wall -Wredundant-constraints -Wincomplete-record-updates -Wincomplete-uni-patterns- cpp-options: -DVERSION="1.40"+ cpp-options: -DVERSION="1.41" build-depends: Decimal >=0.5.1 , aeson >=1 && <2.3- , base >=4.14 && <4.20+ , base >=4.14 && <4.21+ , base-compat >=0.14.0 , base64 , blaze-html , blaze-markup@@ -177,13 +178,13 @@ , filepath , githash >=0.1.6.2 , hjsmin- , hledger ==1.40.*- , hledger-lib ==1.40.*+ , hledger ==1.41.*+ , hledger-lib ==1.41.* , hspec , http-client , http-conduit , http-types- , megaparsec >=7.0.0 && <9.7+ , megaparsec >=7.0.0 && <9.8 , mtl >=2.2.1 , network , safe >=0.3.20@@ -211,10 +212,8 @@ cpp-options: -DDEVELOPMENT if flag(dev) ghc-options: -O0- if (flag(ghcdebug))- cpp-options: -DGHCDEBUG- build-depends:- ghc-debug-stub >=0.6.0.0 && <0.7+ if (flag(debug))+ cpp-options: -DDEBUG executable hledger-web main-is: main.hs@@ -223,19 +222,18 @@ hs-source-dirs: app ghc-options: -Wall -Wredundant-constraints -Wincomplete-record-updates -Wincomplete-uni-patterns- cpp-options: -DVERSION="1.40"+ cpp-options: -DVERSION="1.41" build-depends:- base >=4.14 && <4.20+ base >=4.14 && <4.21+ , base-compat >=0.14.0 , hledger-web default-language: Haskell2010 if (flag(dev)) || (flag(library-only)) cpp-options: -DDEVELOPMENT if flag(dev) ghc-options: -O0- if (flag(ghcdebug))- cpp-options: -DGHCDEBUG- build-depends:- ghc-debug-stub >=0.6.0.0 && <0.7+ if (flag(debug))+ cpp-options: -DDEBUG if flag(library-only) buildable: False if flag(threaded)@@ -247,16 +245,15 @@ hs-source-dirs: test ghc-options: -Wall -Wredundant-constraints -Wincomplete-record-updates -Wincomplete-uni-patterns- cpp-options: -DVERSION="1.40"+ cpp-options: -DVERSION="1.41" build-depends:- base >=4.14 && <4.20+ base >=4.14 && <4.21+ , base-compat >=0.14.0 , hledger-web default-language: Haskell2010 if (flag(dev)) || (flag(library-only)) cpp-options: -DDEVELOPMENT if flag(dev) ghc-options: -O0- if (flag(ghcdebug))- cpp-options: -DGHCDEBUG- build-depends:- ghc-debug-stub >=0.6.0.0 && <0.7+ if (flag(debug))+ cpp-options: -DDEBUG
hledger-web.info view
@@ -1,4 +1,4 @@-This is hledger-web.info, produced by makeinfo version 7.1 from stdin.+This is hledger-web.info, produced by makeinfo version 7.1.1 from stdin. INFO-DIR-SECTION User Applications START-INFO-DIR-ENTRY@@ -18,7 +18,7 @@ or 'hledger web -- [OPTS] [QUERY]' - This manual is for hledger's web interface, version 1.40. See also+ This manual is for hledger's web interface, version 1.41. See also the hledger manual for common concepts and file formats. hledger is a robust, user-friendly, cross-platform set of programs@@ -171,9 +171,11 @@ -C --cleared include only cleared postings/transactions (-U/-P/-C can be combined) -R --real include only non-virtual postings- --depth=NUM or -NUM: show only top NUM levels of accounts -E --empty Show zero items, which are normally hidden. In hledger-ui & hledger-web, do the opposite.+ --depth=DEPTHEXP if a number (or -NUM): show only top NUM levels+ of accounts. If REGEXP=NUM, only apply limiting to+ accounts matching the regular expression. -B --cost show amounts converted to their cost/sale amount -V --market Show amounts converted to their value at period end(s) in their default valuation commodity.@@ -190,8 +192,6 @@ YYYY-MM-DD: value on given date -c --commodity-style=S Override a commodity's display style. Eg: -c '.' or -c '1.000,00 EUR'- --color=YN --colour Use ANSI color codes in text output? Can be- 'y'/'yes'/'always', 'n'/'no'/'never' or 'auto'. --pretty[=YN] Use box-drawing characters in text output? Can be 'y'/'yes' or 'n'/'no'. If YN is specified, the equals is required.@@ -203,6 +203,8 @@ --man show the manual with man --version show version information --debug=[1-9] show this much debug output (default: 1)+ --pager=YN use a pager when needed ? y/yes (default) or n/no+ --color=YNA --colour use ANSI color ? y/yes, n/no, or auto (default) hledger-web shows accounts with zero balances by default (like 'hledger-ui', and unlike 'hledger'). Using the '-E/--empty' flag will@@ -215,6 +217,10 @@ initial query, which although not shown in the UI, will restrict the data shown (in addition to any search query entered in the UI). + If you use the bash shell, you can auto-complete flags by pressing+TAB in the command line. If this is not working see Install > Shell+completions.+ File: hledger-web.info, Node: PERMISSIONS, Next: EDITING UPLOADING DOWNLOADING, Prev: OPTIONS, Up: Top @@ -513,7 +519,7 @@ ****** We welcome bug reports in the hledger issue tracker (shortcut:-http://bugs.hledger.org), or on the #hledger chat or hledger mail list+https://bugs.hledger.org), or on the hledger chat or mail list (https://hledger.org/support). Some known issues:@@ -522,25 +528,16 @@ Tag Table:-Node: Top223-Node: OPTIONS2566-Ref: #options2671-Node: PERMISSIONS10945-Ref: #permissions11084-Node: EDITING UPLOADING DOWNLOADING12296-Ref: #editing-uploading-downloading12477-Node: RELOADING13311-Ref: #reloading13445-Node: JSON API13878-Ref: #json-api13993-Node: DEBUG OUTPUT19527-Ref: #debug-output19652-Node: Debug output19679-Ref: #debug-output-119780-Node: ENVIRONMENT20197-Ref: #environment20316-Node: BUGS20433-Ref: #bugs20517+Node: Top225+Node: OPTIONS2568+Node: PERMISSIONS11257+Node: EDITING UPLOADING DOWNLOADING12608+Node: RELOADING13623+Node: JSON API14190+Node: DEBUG OUTPUT19839+Node: Debug output19991+Node: ENVIRONMENT20509+Node: BUGS20745 End Tag Table
hledger-web.txt view
@@ -11,7 +11,7 @@ hledger web -- [OPTS] [QUERY] DESCRIPTION- This manual is for hledger's web interface, version 1.40. See also the+ This manual is for hledger's web interface, version 1.41. See also the hledger manual for common concepts and file formats. hledger is a robust, user-friendly, cross-platform set of programs for@@ -148,9 +148,11 @@ -C --cleared include only cleared postings/transactions (-U/-P/-C can be combined) -R --real include only non-virtual postings- --depth=NUM or -NUM: show only top NUM levels of accounts -E --empty Show zero items, which are normally hidden. In hledger-ui & hledger-web, do the opposite.+ --depth=DEPTHEXP if a number (or -NUM): show only top NUM levels+ of accounts. If REGEXP=NUM, only apply limiting to+ accounts matching the regular expression. -B --cost show amounts converted to their cost/sale amount -V --market Show amounts converted to their value at period end(s) in their default valuation commodity.@@ -167,8 +169,6 @@ YYYY-MM-DD: value on given date -c --commodity-style=S Override a commodity's display style. Eg: -c '.' or -c '1.000,00 EUR'- --color=YN --colour Use ANSI color codes in text output? Can be- 'y'/'yes'/'always', 'n'/'no'/'never' or 'auto'. --pretty[=YN] Use box-drawing characters in text output? Can be 'y'/'yes' or 'n'/'no'. If YN is specified, the equals is required.@@ -180,6 +180,8 @@ --man show the manual with man --version show version information --debug=[1-9] show this much debug output (default: 1)+ --pager=YN use a pager when needed ? y/yes (default) or n/no+ --color=YNA --colour use ANSI color ? y/yes, n/no, or auto (default) hledger-web shows accounts with zero balances by default (like hledger-ui, and unlike hledger). Using the -E/--empty flag will re-@@ -192,6 +194,10 @@ query, which although not shown in the UI, will restrict the data shown (in addition to any search query entered in the UI). + If you use the bash shell, you can auto-complete flags by pressing TAB+ in the command line. If this is not working see Install > Shell com-+ pletions.+ PERMISSIONS By default, hledger-web allows anyone who can reach it to view the journal and to add new transactions, but not to change existing data.@@ -449,7 +455,7 @@ BUGS We welcome bug reports in the hledger issue tracker (shortcut:- http://bugs.hledger.org), or on the #hledger chat or hledger mail list+ https://bugs.hledger.org), or on the hledger chat or mail list (https://hledger.org/support). Some known issues:@@ -474,4 +480,4 @@ SEE ALSO hledger(1), hledger-ui(1), hledger-web(1), ledger(1) -hledger-web-1.40 September 2024 HLEDGER-WEB(1)+hledger-web-1.41 October 2024 HLEDGER-WEB(1)
static/hledger.js view
@@ -163,8 +163,8 @@ // Set the add-new-row-on-keypress handler on the add form's current last amount field, only. // (NB: removes all other keypress handlers from all amount fields). function addformLastAmountBindKey() {- $('.amount-input').off('keypress');- $('.amount-input:last').keypress(addformAddPosting);+ $('input[name=amount]').off('keypress');+ $('input[name=amount]:last').keypress(addformAddPosting); } // Pre-fill today's date and focus the description field in the add form.@@ -186,16 +186,29 @@ // Insert another posting row in the add form. function addformAddPosting() {- if (!$('#addform').is(':visible')) {- return;- }- // Clone the old last row to make a new last row- $('#addform .account-postings').append( $('#addform .account-group:last').clone().addClass('added-row') );- // renumber and clear the new last account and amount fields- var n = $('#addform .account-group').length;- $('.account-input:last').prop('placeholder', 'Account '+n).val('');- $('.amount-input:last').prop('placeholder','Amount '+n).val(''); // XXX Enable typehead on dynamically created inputs- // and move the keypress handler to the new last amount field+ if (!$('#addform').is(':visible')) { return; }++ // Clone the last row.+ var newrow = $('#addform .account-group:last').clone().addClass('added-row');+ var newnum = $('#addform .account-group').length + 1;++ // Clear the new account and amount fields and update their placeholder text.+ var accountfield = newrow.find('input[name=account]');+ var amountfield = newrow.find('input[name=amount]');+ accountfield.val('').prop('placeholder', 'Account '+newnum);+ amountfield.val('').prop('placeholder', 'Amount '+newnum);++ // Enable autocomplete in the new account field.+ // We must first remove these typehead helper elements cloned from the old row,+ // or it will recursively add helper elements for those, causing confusion (#2215).+ newrow.find('.tt-hint').remove();+ newrow.find('.tt-input').removeClass('tt-input');+ accountfield.typeahead({ highlight: true }, { source: globalThis.accountsCompleter.ttAdapter() });++ // Add the new row to the page.+ $('#addform .account-postings').append(newrow);++ // And move the keypress handler to the new last amount field. addformLastAmountBindKey(); }
templates/add-form.hamlet view
@@ -1,23 +1,28 @@ <script>+ jQuery(document).ready(function() {- descriptionsSuggester = new Bloodhound({++ // Set up global completers which can be attached to appropriate inputs when needed++ globalThis.descriptionsCompleter = new Bloodhound({ local:#{toBloodhoundJson (toList descriptions)}, limit:100, datumTokenizer: function(d) { return [d.value]; }, queryTokenizer: function(q) { return [q]; } });- descriptionsSuggester.initialize();+ globalThis.descriptionsCompleter.initialize(); - accountsSuggester = new Bloodhound({+ globalThis.accountsCompleter = new Bloodhound({ local:#{toBloodhoundJson (journalAccountNamesDeclaredOrImplied j)}, limit:100, datumTokenizer: function(d) { return [d.value]; }, queryTokenizer: function(q) { return [q]; } });- accountsSuggester.initialize();+ globalThis.accountsCompleter.initialize(); - jQuery('input[name=description]').typeahead({ highlight: true }, { source: descriptionsSuggester.ttAdapter() });- jQuery('input[name=account]').typeahead({ highlight: true }, { source: accountsSuggester.ttAdapter() });+ // Attach the completers to the initial form inputs.+ jQuery('input[name=description]').typeahead({ highlight: true }, { source: globalThis.descriptionsCompleter.ttAdapter() });+ jQuery('input[name=account]' ).typeahead({ highlight: true }, { source: globalThis.accountsCompleter.ttAdapter() }); }); const utf8textdecoder = new TextDecoder();