packages feed

hledger-web 1.0.1 → 1.1

raw patch · 9 files changed

+169/−111 lines, 9 filesdep ~basedep ~hledgerdep ~hledger-libPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base, hledger, hledger-lib, hledger-web, megaparsec

API changes (from Hackage documentation)

- Hledger.Web.WebOptions: [server_] :: WebOpts -> Bool
- Hledger.Web.WebOptions: defbaseurlexample :: String
+ Hledger.Web.WebOptions: [host_] :: WebOpts -> String
+ Hledger.Web.WebOptions: [serve_] :: WebOpts -> Bool
+ Settings: defhost :: String
- Hledger.Web.WebOptions: WebOpts :: Bool -> Int -> String -> Maybe String -> CliOpts -> WebOpts
+ Hledger.Web.WebOptions: WebOpts :: Bool -> String -> Int -> String -> Maybe String -> CliOpts -> WebOpts
- Settings: defbaseurl :: Int -> String
+ Settings: defbaseurl :: String -> Int -> String

Files

Application.hs view
@@ -59,7 +59,7 @@     return $ logWare app   where     logWare | development  = logStdoutDev-            | server_ opts = logStdout+            | serve_ opts  = logStdout             | otherwise    = id  makeFoundation :: AppConfig DefaultEnv Extra -> WebOpts -> IO App
CHANGES view
@@ -2,6 +2,23 @@ See also the hledger and the project change logs.  +# 1.1 (2016/12/31)++-   add --host option (#429)+    +    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. That can now be+    changed with --host=IPADDR. Also, the default base url uses this+    address rather than a hard-coded "localhost".+    +-   rename --server to --serve++    The --server flag sounded too close in meaning to --host so+    I've renamed it to --serve. The old spelling is still accepted,+    but deprecated and will be removed in the next release.++ # 1.0.1 (2016/10/27)  - allow megaparsec 5.0 or 5.1
Hledger/Web/Main.hs view
@@ -71,7 +71,7 @@   d <- getCurrentDay   let initq = queryFromOpts d $ reportopts_ $ cliopts_ opts       j' = filterJournalTransactions initq j-      h = "127.0.0.1"+      h = host_ opts       p = port_ opts       u = base_url_ opts       staticRoot = pack <$> file_url_ opts@@ -82,8 +82,9 @@                            ,appExtra = Extra "" Nothing staticRoot                            }   app <- makeApplication opts j' appconfig-  _ <- printf "Starting web app on host %s port %d with base url %s\n" h p u-  if server_ opts+  -- XXX would like to allow a host name not just an IP address here+  _ <- printf "Starting web app on IP address %s port %d with base url %s\n" h p u+  if serve_ opts     then do       putStrLn "Press ctrl-c to quit"       hFlush stdout
Hledger/Web/WebOptions.hs view
@@ -21,14 +21,12 @@ prognameandversion :: String prognameandversion = progname ++ " " ++ version :: String -defbaseurlexample :: String-defbaseurlexample = (reverse $ drop 4 $ reverse $ defbaseurl defport) ++ "PORT"- webflags :: [Flag [([Char], [Char])]] webflags = [-  flagNone ["server"]   (setboolopt "server") ("log requests, and don't browse or auto-exit")- ,flagReq  ["port"]     (\s opts -> Right $ setopt "port" s opts) "PORT" ("set the tcp port (default: "++show defport++")")- ,flagReq  ["base-url"] (\s opts -> Right $ setopt "base-url" s opts) "BASEURL" ("set the base url (default: "++defbaseurlexample++")")+  flagNone ["serve","server"]   (setboolopt "serve") ("serve and log requests, don't browse or auto-exit")+ ,flagReq  ["host"]     (\s opts -> Right $ setopt "host" s opts) "IPADDR" ("listen on this IP address (default: "++defhost++")")+ ,flagReq  ["port"]     (\s opts -> Right $ setopt "port" s opts) "PORT" ("listen on this TCP port (default: "++show defport++")")+ ,flagReq  ["base-url"] (\s opts -> Right $ setopt "base-url" s opts) "BASEURL" ("set the base url (default: http://IPADDR:PORT)")  ,flagReq  ["file-url"] (\s opts -> Right $ setopt "file-url" s opts) "FILEURL" ("set the static files url (default: BASEURL/static)")  ] @@ -48,7 +46,8 @@  -- hledger-web options, used in hledger-web and above data WebOpts = WebOpts {-     server_   :: Bool+     serve_    :: Bool+    ,host_     :: String     ,port_     :: Int     ,base_url_ :: String     ,file_url_ :: Maybe String@@ -62,17 +61,22 @@     def     def     def+    def  -- instance Default WebOpts where def = defwebopts  rawOptsToWebOpts :: RawOpts -> IO WebOpts rawOptsToWebOpts rawopts = checkWebOpts <$> do   cliopts <- rawOptsToCliOpts rawopts-  let p = fromMaybe defport $ maybeintopt "port" rawopts+  let+    h = fromMaybe defhost $ maybestringopt "host" rawopts+    p = fromMaybe defport $ maybeintopt "port" rawopts+    b = maybe (defbaseurl h p) stripTrailingSlash $ maybestringopt "base-url" rawopts   return defwebopts {-              port_ = p-             ,server_ = boolopt "server" rawopts-             ,base_url_ = maybe (defbaseurl p) stripTrailingSlash $ maybestringopt "base-url" rawopts+              serve_ = boolopt "serve" rawopts+             ,host_ = h+             ,port_ = p+             ,base_url_ = b              ,file_url_ = stripTrailingSlash <$> maybestringopt "file-url" rawopts              ,cliopts_   = cliopts              }@@ -80,7 +84,12 @@     stripTrailingSlash = reverse . dropWhile (=='/') . reverse -- yesod don't like it  checkWebOpts :: WebOpts -> WebOpts-checkWebOpts = id+checkWebOpts wopts =+  either optserror (const wopts) $ do+    let h = host_ wopts+    if any (not . (`elem` ".0123456789")) h+    then Left $ "--host requires an IP address, not "++show h+    else Right ()  getHledgerWebOpts :: IO WebOpts getHledgerWebOpts = processArgs webmode >>= return . decodeRawOpts >>= rawOptsToWebOpts
Settings.hs view
@@ -20,22 +20,22 @@ import Data.Default (def) import Text.Hamlet -import Text.Printf (printf) - hledgerorgurl, manualurl :: String hledgerorgurl     = "http://hledger.org" manualurl         = hledgerorgurl++"/manual" +-- | The default IP address to listen on. May be overridden with --host.+defhost :: String+defhost = "127.0.0.1"+ -- | The default TCP port to listen on. May be overridden with --port. defport :: Int defport = 5000 -defbaseurl :: Int -> String-defbaseurl port = printf "http://localhost:%d" port---+defbaseurl :: String -> Int -> String+defbaseurl host port =+  "http://" ++ host ++ if port /= 80 then ":" ++ show port else ""  -- Static setting below. Changing these requires a recompile 
doc/hledger-web.1 view
@@ -1,5 +1,5 @@ -.TH "hledger\-web" "1" "October 2016" "hledger\-web 1.0" "hledger User Manuals"+.TH "hledger\-web" "1" "December 2016" "hledger\-web 1.1" "hledger User Manuals"   @@ -59,22 +59,34 @@ \f[] .fi .PP-With \f[C]\-\-server\f[], it starts the web app in non\-transient mode+With \f[C]\-\-serve\f[], it starts the web app in non\-transient mode and logs requests to the console.-Typically when running hledger web as part of a website you\[aq]ll want-to use \f[C]\-\-base\-url\f[] to set the protocol/hostname/port/path to-be used in hyperlinks.-The \f[C]\-\-file\-url\f[] option allows static files to be served from-a different url, eg for better caching or cookie\-less serving. .PP-You can use \f[C]\-\-port\f[] to listen on a different TCP port, eg if-you are running multiple hledger\-web instances.-This need not be the same as the PORT in the base url.+By default the server listens on IP address 127.0.0.1, accessible only+to local requests.+You can use \f[C]\-\-host\f[] to change this, eg+\f[C]\-\-host\ 0.0.0.0\f[] to listen on all configured addresses. .PP-Note there is no built\-in access control, so you will need to hide-hledger\-web behind an authenticating proxy (such as apache or nginx) if-you want to restrict who can see and add entries to your journal.+Similarly, use \f[C]\-\-port\f[] to set a TCP port other than 5000, eg+if you are running multiple hledger\-web instances. .PP+You can use \f[C]\-\-base\-url\f[] to change the protocol, hostname,+port and path that appear in hyperlinks, useful eg for integrating+hledger\-web within a larger website.+The default is \f[C]http://HOST:PORT/\f[] using the server\[aq]s+configured host address and TCP port (or \f[C]http://HOST\f[] if PORT is+80).+.PP+With \f[C]\-\-file\-url\f[] you can set a different base url for static+files, eg for better caching or cookie\-less serving on high performance+websites.+.PP+Note there is no built\-in access control (aside from listening on+127.0.0.1 by default).+So you will need to hide hledger\-web behind an authenticating proxy+(such as apache or nginx) if you want to restrict who can see and add+entries to your journal.+.PP Command\-line options and arguments may be used to set an initial filter on the data. This is not shown in the web UI, but it will be applied in addition to@@ -249,7 +261,8 @@ .RE .TP .B \f[C]\-B\ \-\-cost\f[]-show amounts in their cost price\[aq]s commodity+convert amounts to their cost at transaction time (using the transaction+price, if any) .RS .RE .TP@@ -257,8 +270,6 @@ will transform the journal before any other processing by replacing the account name of every posting having the tag TAG with content VALUE by the account name "TAG:VALUE".-.RS-.RE The TAG will only match if it is a full\-length match. The pivot will only happen if the TAG is on a posting, not if it is on the transaction.
doc/hledger-web.1.info view
@@ -4,7 +4,7 @@  File: hledger-web.1.info,  Node: Top,  Up: (dir) -hledger-web(1) hledger-web 1.0+hledger-web(1) hledger-web 1.1 ******************************  hledger-web is hledger's web interface. It starts a simple web@@ -38,21 +38,31 @@ Starting web browser if possible Web app will auto-exit after a few minutes with no browsers (or press ctrl-c) -   With `--server', it starts the web app in non-transient mode and-logs requests to the console. Typically when running hledger web as part-of a website you'll want to use `--base-url' to set the-protocol/hostname/port/path to be used in hyperlinks. The `--file-url'-option allows static files to be served from a different url, eg for-better caching or cookie-less serving.+   With `--serve', it starts the web app in non-transient mode and logs+requests to the console. -   You can use `--port' to listen on a different TCP port, eg if you-are running multiple hledger-web instances. This need not be the same as-the PORT in the base url.+   By default the server listens on IP address 127.0.0.1, accessible+only to local requests. You can use `--host' to change this, eg `--host+0.0.0.0' to listen on all configured addresses. -   Note there is no built-in access control, so you will need to hide-hledger-web behind an authenticating proxy (such as apache or nginx) if-you want to restrict who can see and add entries to your journal.+   Similarly, use `--port' to set a TCP port other than 5000, eg if you+are running multiple hledger-web instances. +   You can use `--base-url' to change the protocol, hostname, port and+path that appear in hyperlinks, useful eg for integrating hledger-web+within a larger website. The default is `http://HOST:PORT/' using the+server's configured host address and TCP port (or `http://HOST' if PORT+is 80).++   With `--file-url' you can set a different base url for static files,+eg for better caching or cookie-less serving on high performance+websites.++   Note there is no built-in access control (aside from listening on+127.0.0.1 by default). So you will need to hide hledger-web behind an+authenticating proxy (such as apache or nginx) if you want to restrict+who can see and add entries to your journal.+    Command-line options and arguments may be used to set an initial filter on the data. This is not shown in the web UI, but it will be applied in addition to any search query entered there.@@ -175,16 +185,17 @@      show items with zero amount, normally hidden  `-B --cost'-     show amounts in their cost price's commodity+     convert amounts to their cost at transaction time (using the+     transaction price, if any)  `--pivot TAG'      will transform the journal before any other processing by      replacing the account name of every posting having the tag TAG-     with content VALUE by the account name "TAG:VALUE".  The TAG will+     with content VALUE by the account name "TAG:VALUE". The TAG will      only match if it is a full-length match. The pivot will only-     happen if the TAG is on a posting, not if it is on the transaction.-     If the tag value is a multi:level:account:name the new account-     name will be "TAG:multi:level:account:name".+     happen if the TAG is on a posting, not if it is on the+     transaction. If the tag value is a multi:level:account:name the+     new account name will be "TAG:multi:level:account:name".  `--anon'      show anonymized accounts and payees@@ -193,7 +204,7 @@  Tag Table: Node: Top90-Node: OPTIONS2997-Ref: #options3084+Node: OPTIONS3343+Ref: #options3430  End Tag Table
doc/hledger-web.1.txt view
@@ -48,32 +48,40 @@               Starting web browser if possible               Web app will auto-exit after a few minutes with no browsers (or press ctrl-c) -       With  --server,  it  starts  the web app in non-transient mode and logs-       requests to the console.  Typically when running hledger web as part of-       a  website  you'll  want  to  use  --base-url to set the protocol/host--       name/port/path to be used in hyperlinks.  The --file-url option  allows-       static  files  to be served from a different url, eg for better caching-       or cookie-less serving.+       With  --serve,  it  starts  the  web app in non-transient mode and logs+       requests to the console. -       You can use --port to listen on a different TCP port,  eg  if  you  are-       running  multiple  hledger-web instances.  This need not be the same as-       the PORT in the base url.+       By default the server listens on IP address 127.0.0.1, accessible  only+       to   local   requests.    You   can  use  --host  to  change  this,  eg+       --host 0.0.0.0 to listen on all configured addresses. -       Note there is no built-in access control, so  you  will  need  to  hide-       hledger-web behind an authenticating proxy (such as apache or nginx) if-       you want to restrict who can see and add entries to your journal.+       Similarly, use --port to set a TCP port other than 5000, eg if you  are+       running multiple hledger-web instances. +       You  can use --base-url to change the protocol, hostname, port and path+       that appear in hyperlinks, useful eg for integrating hledger-web within+       a  larger website.  The default is http://HOST:PORT/ using the server's+       configured host address and TCP port (or http://HOST if PORT is 80).++       With --file-url you can set a different base url for static  files,  eg+       for better caching or cookie-less serving on high performance websites.++       Note there is no built-in  access  control  (aside  from  listening  on+       127.0.0.1  by default).  So you will need to hide hledger-web behind an+       authenticating proxy (such as apache or nginx) if you want to  restrict+       who can see and add entries to your journal.+        Command-line options and arguments may be used to set an initial filter-       on  the  data.  This is not shown in the web UI, but it will be applied+       on the data.  This is not shown in the web UI, but it will  be  applied        in addition to any search query entered there.         With journal and timeclock files (but not CSV files, currently) the web-       app  detects  changes made by other means and will show the new data on-       the next request.  If a change makes the file unparseable,  hledger-web+       app detects changes made by other means and will show the new  data  on+       the  next request.  If a change makes the file unparseable, hledger-web        will show an error until the file has been fixed.  OPTIONS-       Note:  if invoking hledger-web as a hledger subcommand, write -- before+       Note: if invoking hledger-web as a hledger subcommand, write --  before        options as shown above.         --server@@ -84,21 +92,21 @@               set the TCP port to listen on (default: 5000)         --base-url=URL-              set  the  base  url (default: http://localhost:PORT).  You would+              set the base url (default:  http://localhost:PORT).   You  would               change this when sharing over the network, or integrating within               a larger website.         --file-url=URL               set the static files url (default: BASEURL/static).  hledger-web-              normally serves static files itself, but if you wanted to  serve-              them  from  another server for efficiency, you would set the url+              normally  serves static files itself, but if you wanted to serve+              them from another server for efficiency, you would set  the  url               with this.         hledger general options:         -h     show general usage (or after COMMAND, the command's usage) -       --help show the current program's manual as plain  text  (or  after  an+       --help show  the  current  program's  manual as plain text (or after an               add-on COMMAND, the add-on's manual)         --man  show the current program's manual with man@@ -115,7 +123,7 @@               use a different input file.  For stdin, use -         --rules-file=RULESFILE-              Conversion   rules  file  to  use  when  reading  CSV  (default:+              Conversion  rules  file  to  use  when  reading  CSV   (default:               FILE.rules)         --alias=OLD=NEW@@ -148,7 +156,7 @@               multiperiod/multicolumn report by year         -p --period=PERIODEXP-              set start date, end date, and/or reporting interval all at  once+              set  start date, end date, and/or reporting interval all at once               (overrides the flags above)         --date2@@ -173,32 +181,33 @@               show items with zero amount, normally hidden         -B --cost-              show amounts in their cost price's commodity+              convert amounts to their cost at  transaction  time  (using  the+              transaction price, if any)         --pivot TAG               will  transform  the  journal  before  any  other  processing by               replacing the account name of every posting having the  tag  TAG-              with content VALUE by the account name "TAG:VALUE".-       The  TAG  will only match if it is a full-length match.  The pivot will-       only happen if the TAG is on a posting, not if it is  on  the  transac--       tion.   If  the tag value is a multi:level:account:name the new account-       name will be "TAG:multi:level:account:name".+              with  content  VALUE  by  the account name "TAG:VALUE".  The TAG+              will only match if it is a full-length match.   The  pivot  will+              only  happen  if  the  TAG  is on a posting, not if it is on the+              transaction.  If the tag value is a multi:level:account:name the+              new account name will be "TAG:multi:level:account:name".         --anon show anonymized accounts and payees  ENVIRONMENT        LEDGER_FILE The journal file path when not specified with -f.  Default:-       ~/.hledger.journal  (on  windows,  perhaps C:/Users/USER/.hledger.jour-+       ~/.hledger.journal (on  windows,  perhaps  C:/Users/USER/.hledger.jour-        nal).  FILES-       Reads data from one or more files in hledger journal, timeclock,  time--       dot,   or   CSV   format   specified   with  -f,  or  $LEDGER_FILE,  or-       $HOME/.hledger.journal          (on          windows,           perhaps+       Reads  data from one or more files in hledger journal, timeclock, time-+       dot,  or  CSV  format  specified   with   -f,   or   $LEDGER_FILE,   or+       $HOME/.hledger.journal           (on          windows,          perhaps        C:/Users/USER/.hledger.journal).  BUGS-       The  need  to precede options with -- when invoked from hledger is awk-+       The need to precede options with -- when invoked from hledger  is  awk-        ward.         -f- doesn't work (hledger-web can't read from stdin).@@ -212,7 +221,7 @@   REPORTING BUGS-       Report bugs at http://bugs.hledger.org (or on the #hledger IRC  channel+       Report  bugs at http://bugs.hledger.org (or on the #hledger IRC channel        or hledger mail list)  @@ -226,7 +235,7 @@   SEE ALSO-       hledger(1),      hledger-ui(1),     hledger-web(1),     hledger-api(1),+       hledger(1),     hledger-ui(1),     hledger-web(1),      hledger-api(1),        hledger_csv(5), hledger_journal(5), hledger_timeclock(5), hledger_time-        dot(5), ledger(1) @@ -234,4 +243,4 @@   -hledger-web 1.0                  October 2016                   hledger-web(1)+hledger-web 1.1                  December 2016                  hledger-web(1)
hledger-web.cabal view
@@ -1,9 +1,9 @@--- This file has been generated from package.yaml by hpack version 0.14.0.+-- This file has been generated from package.yaml by hpack version 0.15.0. -- -- see: https://github.com/sol/hpack  name:           hledger-web-version:        1.0.1+version:        1.1 stability:      stable category:       Finance synopsis:       Web interface for the hledger accounting tool@@ -125,11 +125,11 @@  library     ghc-options: -Wall -fno-warn-unused-do-bind -fno-warn-name-shadowing -fno-warn-missing-signatures -fno-warn-type-defaults -fno-warn-orphans-    cpp-options: -DVERSION="1.0.1"+    cpp-options: -DVERSION="1.1"     build-depends:-          hledger-lib >= 1.0.1-        , hledger >= 1.0.1-        , base >=4 && <5+          hledger-lib >= 1.1 && < 1.2+        , hledger >= 1.1 && < 1.2+        , base >=4.8 && <5         , base-compat >=0.8.1         , blaze-html         , blaze-markup@@ -199,11 +199,11 @@     hs-source-dirs:           app     ghc-options: -Wall -fno-warn-unused-do-bind -fno-warn-name-shadowing -fno-warn-missing-signatures -fno-warn-type-defaults -fno-warn-orphans-    cpp-options: -DVERSION="1.0.1"+    cpp-options: -DVERSION="1.1"     build-depends:-          hledger-lib >= 1.0.1-        , hledger >= 1.0.1-        , base >=4 && <5+          hledger-lib >= 1.1 && < 1.2+        , hledger >= 1.1 && < 1.2+        , base >=4.8 && <5         , base-compat >=0.8.1         , blaze-html         , blaze-markup@@ -234,7 +234,7 @@         , yesod-static         , json         , parsec >=3-        , hledger-web == 1.0.1+        , hledger-web == 1.1     if flag(library-only)         buildable: False     if flag(threaded)@@ -264,11 +264,11 @@     hs-source-dirs:           tests     ghc-options: -Wall -fno-warn-unused-do-bind -fno-warn-name-shadowing -fno-warn-missing-signatures -fno-warn-type-defaults -fno-warn-orphans-    cpp-options: -DVERSION="1.0.1"+    cpp-options: -DVERSION="1.1"     build-depends:-          hledger-lib >= 1.0.1-        , hledger >= 1.0.1-        , base >=4 && <5+          hledger-lib >= 1.1 && < 1.2+        , hledger >= 1.1 && < 1.2+        , base >=4.8 && <5         , base-compat >=0.8.1         , blaze-html         , blaze-markup@@ -298,7 +298,7 @@         , yesod-form         , yesod-static         , json-        , hledger-web+        , hledger-web == 1.1         , hspec         , yesod-test     if flag(oldtime)