This came up in the context of Docker, but it seems it wasn't possible
for hledger-web to serve remote clients directly (without a proxy)
because of 127.0.0.1 being hardcoded ? Now that can be
changed with --host=IPADDR. The default base url also
uses this address, rather than "localhost" being hardcoded.
Also, the --server flag sounded too close in meaning to --host so
I've renamed it to --serve. The old spelling is still accepted,
at least through the next major release I suppose.
The initial query specified by command line arguments is now preserved
when the journal is reloaded. This does not appear in the web UI, it's
like an invisible extra filter.
Also
- pause for 0.1s before opening the browser, to ensure the app is ready
- don't open a browser if the app fails to start
- terminate the server thread more carefully on exit, may resolve some
lingering background thread issues eg on windows
Make these modules' names more like the heavily-used types they
define (CliOpts, UIOpts, WebOpts). This is consistent with
RawOptions and ReportOptions, and helps with code navigation.
We're now using the wai-handler-launch middleware. This injects a
script in each page that pings the server repeatedly, and terminates
the server if it gets no pings (ie there are no browser tabs
displaying the app) for two minutes. The server can also be easily
terminated at the console by pressing enter, yesod devel style.
The web app's journal state is now kept in the yesod App as an IORef,
instead of using io-storage.
yesod devel now works; it uses the journal file specified by
$LEDGER_FILE, or ~/.hledger.journal.
web: update journal state handling, fix yesod devel - WIP
This refactoring fixes an O(n^2) slowdown in the balance command with
large numbers of accounts. It's now speedy, and the implementation is
clearer. To facilitate this, the Account type now represents a tree of
accounts which can easily be traversed up or down (and/or flattened
into a list).
Benchmark on a 2010 macbook:
+-------------------------------------------++--------------+------------+--------+
| || before: | after: | |
| || hledger-0.18 | hledgeropt | ledger |
+===========================================++==============+============+========+
| -f data/100x100x10.journal balance || 0.21 | 0.07 | 0.09 |
| -f data/1000x1000x10.journal balance || 10.13 | 0.47 | 0.62 |
| -f data/1000x10000x10.journal balance || 40.67 | 0.67 | 1.01 |
| -f data/10000x1000x10.journal balance || 15.01 | 3.22 | 2.36 |
| -f data/10000x1000x10.journal balance aa || 4.77 | 4.40 | 2.33 |
+-------------------------------------------++--------------+------------+--------+
hledger and hledger-web were reading their version number (and program
name) from their cabal files at compile time using cabal-file-th,
which allowed the version number be maintained in one place (per
package).
This meant you had to be in same directory as the cabal file when
building, which made life more complicated, eg emacs compilation mode
could not jump to errors. Also, it slowed down building slightly, and
is a factor in hledger Debian packages being unavailable on a number
of platforms (we also use TH for report templates).
Now, the build version is set with a CPP VERSION flag, which seems
simpler overall. For cabal builds, this needs to be configured
manually in a few more places in each cabal file. For makefile builds,
it is set it to the name of the most recent darcs tag (which should be
more useful than the old behaviour). If not set, it defaults to the
blank string, useful eg for haddock. And, all makefile builds now run
from the top directory.