packages feed

hledger-web 1.34 → 1.40

raw patch · 7 files changed

+99/−73 lines, 7 filesdep ~hledgerdep ~hledger-libdep ~megaparsecPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: hledger, hledger-lib, megaparsec

API changes (from Hackage documentation)

Files

CHANGES.md view
@@ -7,12 +7,12 @@  Breaking changes +Fixes+ Features  Improvements -Fixes- Docs  API@@ -20,6 +20,21 @@ --> User-visible changes in hledger-web. See also the hledger changelog.+++# 1.40 2024-09-09++Improvements++- We now guess a more robust base url when `--base-url` is not specified.+  Now relative links to js/css resources will use the same hostname etc.+  that the main page was requested from, making them work better+  when accessed via multiple IP addresses/hostnames+  without an explicit `--base-url` setting.+  A followup to [#2099], [#2100] and [#2127]. ++- We now require a http[s] scheme in `--base-url`'s value.+  Previously it accepted just a hostname, and generated bad links.   # 1.34 2024-06-01
Hledger/Web/App.hs view
@@ -52,6 +52,7 @@ import Hledger.Web.Settings.StaticFiles import Hledger.Web.WebOptions import Hledger.Web.Widget.Common (balanceReportAsHtml)+import Data.List (isPrefixOf)  -- | The site argument for your application. This can be a good place to -- keep settings and values requiring initialization before your application@@ -104,19 +105,16 @@ instance Yesod App where    -- Configure the app root, AKA base url, which is prepended to relative hyperlinks.-  -- Broadly, we'd like this:-  -- 1. when --base-url has been specified, use that;-  -- 2. otherwise, guess it from request headers, which helps us respond from the-  --    same hostname/IP address when hledger-web is accessible at multiple IPs;+  -- 1. when a --base-url was specified, use that+  -- 2. otherwise, guess it from request headers, which helps us respond from the same hostname/IP address when accessible via multiple IPs   -- 3. otherwise, leave it empty (relative links stay relative).-  -- But it's hard to see how to achieve this.-  -- For now we do (I believe) 1 or 3, with 2 unfortunately not supported.-  -- Issues include: #2099, #2100, #2127-  approot =-    -- ApprootRelative-    -- ApprootMaster $ appRoot . settings-    -- guessApprootOr (ApprootMaster $ appRoot . settings)-    ApprootMaster $ \(App{settings=AppConfig{appRoot=r}, appOpts=WebOpts{base_url_=bu}}) -> if null bu then r else T.pack bu+  -- Past issues: #2099, #2100, #2127, #hledger-2024-07-18+  approot+    | hasbaseurl = ApprootMaster (T.pack . base_url_ . appOpts)+    | otherwise  = guessApprootOr (ApprootMaster (appRoot . settings))+    where+      hasbaseurl = any ("--base-url" `isPrefixOf`) progArgs+        -- needs unsafePerformIO; does not detect abbreviations like --base    makeSessionBackend _ = do     hledgerdata <- getXdgDirectory XdgCache "hledger"
Hledger/Web/WebOptions.hs view
@@ -1,6 +1,7 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE RecordWildCards #-}  module Hledger.Web.WebOptions where @@ -20,6 +21,7 @@ import Hledger.Web.Settings (defhost, defport, defbaseurl) import qualified Data.Text as T import Data.Char (toLower)+import Data.List (isPrefixOf)  -- cf Hledger.Cli.Version @@ -152,17 +154,22 @@ rawOptsToWebOpts rawopts =   checkWebOpts <$> do     cliopts <- rawOptsToCliOpts rawopts-    let h = fromMaybe defhost $ maybestringopt "host" rawopts-        p = fromMaybe defport $ maybeposintopt "port" rawopts-        b = maybe (defbaseurl h p) stripTrailingSlash $ maybestringopt "base-url" rawopts-        sock = stripTrailingSlash <$> maybestringopt "socket" rawopts-        access =-          case lastMay $ listofstringopt "allow" rawopts of-            Nothing -> AddAccess-            Just t ->-              case parseAccessLevel t of-                Right al -> al-                Left err -> error' ("Unknown access level: " ++ err)  -- PARTIAL:+    let+      h = fromMaybe defhost $ maybestringopt "host" rawopts+      p = fromMaybe defport $ maybeposintopt "port" rawopts+      -- Always set a base-url, constructing it from host and port if not specified.+      -- This will be used when opening a web browser, eg.+      -- App.hs approot will use it if it was specified by --base-url,+      -- otherwise it will infer a better one from the request, which browsers prefer.+      b = maybe (defbaseurl h p) stripTrailingSlash $ maybestringopt "base-url" rawopts+      sock = stripTrailingSlash <$> maybestringopt "socket" rawopts+      access =+        case lastMay $ listofstringopt "allow" rawopts of+          Nothing -> AddAccess+          Just t ->+            case parseAccessLevel t of+              Right al -> al+              Left err -> error' ("Unknown access level: " ++ err)  -- PARTIAL:     return       defwebopts       { serve_ = case sock of@@ -182,11 +189,14 @@     stripTrailingSlash = reverse . dropWhile (== '/') . reverse -- yesod don't like it  checkWebOpts :: WebOpts -> WebOpts-checkWebOpts = id+checkWebOpts wopts@WebOpts{..}+  | not $ null base_url_ || "http://" `isPrefixOf` base_url_ || "https://" `isPrefixOf` base_url_ =+      error' "please begin the --base-url value with http:// or https://"+  | otherwise = wopts  getHledgerWebOpts :: IO WebOpts getHledgerWebOpts = do-  args <- fmap (replaceNumericFlags . ensureDebugHasArg) . expandArgsAt =<< getArgs+  args <- fmap (ensureDebugFlagHasVal . replaceNumericFlags) . expandArgsAt =<< getArgs   rawOptsToWebOpts . either usageError id $ process webmode args  data Permission
hledger-web.1 view
@@ -1,5 +1,5 @@ -.TH "HLEDGER\-WEB" "1" "June 2024" "hledger-web-1.34 " "hledger User Manuals"+.TH "HLEDGER\-WEB" "1" "September 2024" "hledger-web-1.40 " "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.34.+This manual is for hledger\[aq]s web interface, version 1.40. See also the hledger manual for common concepts and file formats. .PP hledger is a robust, user\-friendly, cross\-platform set of programs for@@ -121,12 +121,13 @@ .IP .EX General input/data transformation flags:-  \-f \-\-file=FILE            Read data from FILE, or from stdin if \-. Can be-                            specified more than once. If not specified, reads-                            from $LEDGER_FILE or $HOME/.hledger.journal.-     \-\-rules\-file=RULEFILE  Use conversion rules from this file for+  \-f \-\-file=[FMT:]FILE      Read data from FILE, or from stdin if FILE is \-,+                            inferring format from extension or a FMT: prefix.+                            Can be specified more than once. If not specified,+                            reads from $LEDGER_FILE or $HOME/.hledger.journal.+     \-\-rules=RULESFILE      Use rules defined in this rules file for                             converting subsequent CSV/SSV/TSV files. If not-                            specified, uses FILE.rules for each such FILE.+                            specified, uses FILE.csv.rules for each FILE.csv.      \-\-alias=A=B|/RGX/=RPL  transform account names from A to B, or by                             replacing regular expression matches      \-\-auto                 generate extra postings by applying auto posting@@ -189,7 +190,6 @@      \-\-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.-     \-\-debug=[1\-9]          show this level of debug output (default: 1)  General help flags:   \-h \-\-help                 show command line help@@ -197,6 +197,7 @@      \-\-info                 show the manual with info      \-\-man                  show the manual with man      \-\-version              show version information+     \-\-debug=[1\-9]          show this much debug output (default: 1) .EE .PP hledger\-web shows accounts with zero balances by default (like
hledger-web.cabal view
@@ -1,11 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.36.0.+-- This file has been generated from package.yaml by hpack version 0.37.0. -- -- see: https://github.com/sol/hpack  name:           hledger-web-version:        1.34+version:        1.40 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.@@ -156,7 +156,7 @@   hs-source-dirs:       ./   ghc-options: -Wall -Wredundant-constraints -Wincomplete-record-updates -Wincomplete-uni-patterns-  cpp-options: -DVERSION="1.34"+  cpp-options: -DVERSION="1.40"   build-depends:       Decimal >=0.5.1     , aeson >=1 && <2.3@@ -177,8 +177,8 @@     , filepath     , githash >=0.1.6.2     , hjsmin-    , hledger ==1.34.*-    , hledger-lib ==1.34.*+    , hledger ==1.40.*+    , hledger-lib ==1.40.*     , hspec     , http-client     , http-conduit@@ -223,7 +223,7 @@   hs-source-dirs:       app   ghc-options: -Wall -Wredundant-constraints -Wincomplete-record-updates -Wincomplete-uni-patterns-  cpp-options: -DVERSION="1.34"+  cpp-options: -DVERSION="1.40"   build-depends:       base >=4.14 && <4.20     , hledger-web@@ -247,7 +247,7 @@   hs-source-dirs:       test   ghc-options: -Wall -Wredundant-constraints -Wincomplete-record-updates -Wincomplete-uni-patterns-  cpp-options: -DVERSION="1.34"+  cpp-options: -DVERSION="1.40"   build-depends:       base >=4.14 && <4.20     , hledger-web
hledger-web.info view
@@ -18,7 +18,7 @@ or 'hledger web -- [OPTS] [QUERY]' -   This manual is for hledger's web interface, version 1.34.  See also+   This manual is for hledger's web interface, version 1.40.  See also the hledger manual for common concepts and file formats.     hledger is a robust, user-friendly, cross-platform set of programs@@ -126,12 +126,13 @@    hledger-web also supports many of hledger's general options:  General input/data transformation flags:-  -f --file=FILE            Read data from FILE, or from stdin if -. Can be-                            specified more than once. If not specified, reads-                            from $LEDGER_FILE or $HOME/.hledger.journal.-     --rules-file=RULEFILE  Use conversion rules from this file for+  -f --file=[FMT:]FILE      Read data from FILE, or from stdin if FILE is -,+                            inferring format from extension or a FMT: prefix.+                            Can be specified more than once. If not specified,+                            reads from $LEDGER_FILE or $HOME/.hledger.journal.+     --rules=RULESFILE      Use rules defined in this rules file for                             converting subsequent CSV/SSV/TSV files. If not-                            specified, uses FILE.rules for each such FILE.+                            specified, uses FILE.csv.rules for each FILE.csv.      --alias=A=B|/RGX/=RPL  transform account names from A to B, or by                             replacing regular expression matches      --auto                 generate extra postings by applying auto posting@@ -194,7 +195,6 @@      --pretty[=YN]          Use box-drawing characters in text output? Can be                             'y'/'yes' or 'n'/'no'.                             If YN is specified, the equals is required.-     --debug=[1-9]          show this level of debug output (default: 1)  General help flags:   -h --help                 show command line help@@ -202,6 +202,7 @@      --info                 show the manual with info      --man                  show the manual with man      --version              show version information+     --debug=[1-9]          show this much debug output (default: 1)     hledger-web shows accounts with zero balances by default (like 'hledger-ui', and unlike 'hledger').  Using the '-E/--empty' flag will@@ -524,22 +525,22 @@ Node: Top223 Node: OPTIONS2566 Ref: #options2671-Node: PERMISSIONS10859-Ref: #permissions10998-Node: EDITING UPLOADING DOWNLOADING12210-Ref: #editing-uploading-downloading12391-Node: RELOADING13225-Ref: #reloading13359-Node: JSON API13792-Ref: #json-api13907-Node: DEBUG OUTPUT19441-Ref: #debug-output19566-Node: Debug output19593-Ref: #debug-output-119694-Node: ENVIRONMENT20111-Ref: #environment20230-Node: BUGS20347-Ref: #bugs20431+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  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.34.  See also the+       This manual is for hledger's web interface, version 1.40.  See also the        hledger manual for common concepts and file formats.         hledger is a robust, user-friendly, cross-platform set of programs  for@@ -103,12 +103,13 @@        hledger-web also supports many of hledger's general options:                General input/data transformation flags:-                -f --file=FILE            Read data from FILE, or from stdin if -. Can be-                                          specified more than once. If not specified, reads-                                          from $LEDGER_FILE or $HOME/.hledger.journal.-                   --rules-file=RULEFILE  Use conversion rules from this file for+                -f --file=[FMT:]FILE      Read data from FILE, or from stdin if FILE is -,+                                          inferring format from extension or a FMT: prefix.+                                          Can be specified more than once. If not specified,+                                          reads from $LEDGER_FILE or $HOME/.hledger.journal.+                   --rules=RULESFILE      Use rules defined in this rules file for                                           converting subsequent CSV/SSV/TSV files. If not-                                          specified, uses FILE.rules for each such FILE.+                                          specified, uses FILE.csv.rules for each FILE.csv.                    --alias=A=B|/RGX/=RPL  transform account names from A to B, or by                                           replacing regular expression matches                    --auto                 generate extra postings by applying auto posting@@ -171,7 +172,6 @@                    --pretty[=YN]          Use box-drawing characters in text output? Can be                                           'y'/'yes' or 'n'/'no'.                                           If YN is specified, the equals is required.-                   --debug=[1-9]          show this level of debug output (default: 1)                General help flags:                 -h --help                 show command line help@@ -179,6 +179,7 @@                    --info                 show the manual with info                    --man                  show the manual with man                    --version              show version information+                   --debug=[1-9]          show this much debug output (default: 1)         hledger-web   shows  accounts  with  zero  balances  by  default  (like        hledger-ui, and unlike hledger).  Using the -E/--empty  flag  will  re-@@ -473,4 +474,4 @@ SEE ALSO        hledger(1), hledger-ui(1), hledger-web(1), ledger(1) -hledger-web-1.34                   June 2024                    HLEDGER-WEB(1)+hledger-web-1.40                September 2024                  HLEDGER-WEB(1)