packages feed

hledger-web 1.15 → 1.16

raw patch · 15 files changed

+125/−90 lines, 15 filesdep +utf8-stringdep +wai-corsdep ~basedep ~hledgerdep ~hledger-libPVP ok

version bump matches the API change (PVP)

Dependencies added: utf8-string, wai-cors

Dependency ranges changed: base, hledger, hledger-lib

API changes (from Hackage documentation)

+ Hledger.Web.Import: areqMsg :: (RenderMessage site msg, HandlerSite m ~ site, MonadHandler m) => Field m a -> FieldSettings site -> msg -> Maybe a -> AForm m a
+ Hledger.Web.Import: contentTypeHeaderIsJson :: ByteString -> Bool
+ Hledger.Web.Import: wreqMsg :: (RenderMessage site msg, HandlerSite m ~ site, MonadHandler m) => Field m a -> FieldSettings site -> msg -> Maybe a -> WForm m (FormResult a)
+ Hledger.Web.WebOptions: [cors_] :: WebOpts -> Maybe String
+ Hledger.Web.WebOptions: corsPolicy :: WebOpts -> Application -> Application
+ Hledger.Web.WebOptions: corsPolicyFromString :: String -> Middleware
+ Hledger.Web.WebOptions: simplePolicyWithOrigin :: Origin -> CorsResourcePolicy
- Hledger.Web.WebOptions: WebOpts :: Bool -> Bool -> String -> Int -> String -> Maybe String -> [Capability] -> Maybe (CI ByteString) -> CliOpts -> WebOpts
+ Hledger.Web.WebOptions: WebOpts :: Bool -> Bool -> Maybe String -> String -> Int -> String -> Maybe String -> [Capability] -> Maybe (CI ByteString) -> CliOpts -> WebOpts
- Hledger.Web.WebOptions: webflags :: [Flag [(String, String)]]
+ Hledger.Web.WebOptions: webflags :: [Flag RawOpts]
- Hledger.Web.WebOptions: webmode :: Mode [(String, String)]
+ Hledger.Web.WebOptions: webmode :: Mode RawOpts

Files

CHANGES.md view
@@ -1,18 +1,28 @@ User-visible changes in hledger-web. See also the hledger changelog. -# 1.15 2019-09-01+# 1.16 2019-12-01 -- web: ?sidebar= hides the sidebar, like ?sidebar=0+- add support for GHC 8.8, base-compat 0.11 (#1090).+  For now, hledger-web needs an unreleased version of json. -- web: --serve-api disables server-side UI+- drop support for GHC 7.10 -- register page: clip linked accounts to 40 characters (Henning Thielemann)-  This was the behaviour before adding the links.+- Weeks in the add form's date picker now start on Mondays (#1109)+  (Timofey Zakrevskiy) -- avoid spaces before commas in register account links (Henning Thielemann)+- The --cors option allows simple cross-origin requests to hledger-web+  (Alejandro García Montoro) -- add links to accounts in register transactions (Henning Thielemann)+- The test suite has been disabled for now.++# 1.15 2019-09-01++- --serve-api disables the usual server-side web UI (leaving only the API routes)++- register page: account names are hyperlinked++- ?sidebar= now hides the sidebar, same as ?sidebar=0  - fix "_create_locale could not be located" error on windows 7 (#1039) 
Hledger/Web/Application.hs view
@@ -23,7 +23,7 @@ import Hledger.Web.Handler.JournalR import Hledger.Web.Handler.RegisterR import Hledger.Web.Import-import Hledger.Web.WebOptions (WebOpts(serve_,serve_api_))+import Hledger.Web.WebOptions (WebOpts(serve_,serve_api_), corsPolicy)  -- This line actually creates our YesodDispatch instance. It is the second half -- of the call to mkYesodData which occurs in Foundation.hs. Please see the@@ -38,7 +38,7 @@ makeApplication opts' j' conf' = do     foundation <- makeFoundation conf' opts'     writeIORef (appJournal foundation) j'-    logWare <$> toWaiApp foundation+    (logWare . (corsPolicy opts')) <$> toWaiApp foundation   where     logWare | development  = logStdoutDev             | serve_ opts' || serve_api_ opts' = logStdout
Hledger/Web/Foundation.hs view
@@ -21,7 +21,9 @@ import Data.Traversable (for) import Data.IORef (IORef, readIORef, writeIORef) import Data.Maybe (fromMaybe)+#if !(MIN_VERSION_base(4,13,0)) import Data.Monoid ((<>))+#endif import Data.Text (Text) import qualified Data.Text as T import Data.Time.Calendar (Day)
Hledger/Web/Handler/MiscR.hs view
@@ -52,7 +52,7 @@   addHeader "Content-Disposition" ("attachment; filename=\"" <> T.pack f' <> "\"")   sendResponse ("text/plain" :: ByteString, toContent txt) --- hledger-web equivalents of hledger-api's handlers+-- hledger-web equivalents of the old hledger-api's handlers  getAccountnamesR :: Handler TypedContent getAccountnamesR = do
Hledger/Web/Json.hs view
@@ -37,8 +37,7 @@  import           Hledger.Data --- JSON instances. See also hledger-api.--- Should they be in hledger-lib Types.hs ?+-- JSON instances. Should they be in hledger-lib Types.hs ?  -- To JSON 
Hledger/Web/Settings.hs view
@@ -7,7 +7,9 @@ module Hledger.Web.Settings where  import Data.Default (def)+#if !(MIN_VERSION_base(4,13,0)) import Data.Semigroup ((<>))+#endif import Data.Text (Text) import Data.Yaml import Language.Haskell.TH.Syntax (Q, Exp)
Hledger/Web/WebOptions.hs view
@@ -4,6 +4,7 @@  import Data.ByteString (ByteString) import qualified Data.ByteString.Char8 as BC+import Data.ByteString.UTF8 (fromString) import Data.CaseInsensitive (CI, mk) import Control.Monad (join) import Data.Default (Default(def))@@ -11,6 +12,8 @@ import qualified Data.Text as T import Data.Text (Text) import System.Environment (getArgs)+import Network.Wai as WAI+import Network.Wai.Middleware.Cors  import Hledger.Cli hiding (progname, version) import Hledger.Web.Settings (defhost, defport, defbaseurl)@@ -25,7 +28,7 @@ prognameandversion :: String prognameandversion = progname ++ " " ++ version :: String -webflags :: [Flag [(String, String)]]+webflags :: [Flag RawOpts] webflags =   [ flagNone       ["serve", "server"]@@ -36,6 +39,11 @@       (setboolopt "serve-api")       "like --serve, but serve only the JSON web API, without the server-side web UI"   , flagReq+      ["cors"]+      (\s opts -> Right $ setopt "cors" s opts)+      "ORIGIN"+      ("allow cross-origin requests from the specified origin; setting ORIGIN to \"*\" allows requests from any origin")+  , flagReq       ["host"]       (\s opts -> Right $ setopt "host" s opts)       "IPADDR"@@ -67,11 +75,11 @@       "read capabilities to enable from a HTTP header, like X-Sandstorm-Permissions (default: disabled)"   ] -webmode :: Mode [(String, String)]+webmode :: Mode RawOpts webmode =   (mode      "hledger-web"-     [("command", "web")]+     (setopt "command" "web" def)      "start serving the hledger web interface"      (argsFlag "[PATTERNS]")      [])@@ -94,6 +102,7 @@ data WebOpts = WebOpts   { serve_ :: Bool   , serve_api_ :: Bool+  , cors_ :: Maybe String   , host_ :: String   , port_ :: Int   , base_url_ :: String@@ -104,7 +113,7 @@   } deriving (Show)  defwebopts :: WebOpts-defwebopts = WebOpts def def def def def def [CapView, CapAdd] Nothing def+defwebopts = WebOpts def def Nothing def def def def [CapView, CapAdd] Nothing def  instance Default WebOpts where def = defwebopts @@ -126,6 +135,7 @@       defwebopts       { serve_ = boolopt "serve" rawopts       , serve_api_ = boolopt "serve-api" rawopts+      , cors_ = maybestringopt "cors" rawopts       , host_ = h       , port_ = p       , base_url_ = b@@ -147,7 +157,7 @@ getHledgerWebOpts :: IO WebOpts getHledgerWebOpts = do   args <- fmap replaceNumericFlags . expandArgsAt =<< getArgs-  rawOptsToWebOpts . decodeRawOpts . either usageError id $ process webmode args+  rawOptsToWebOpts . either usageError id $ process webmode args  data Capability   = CapView@@ -166,3 +176,21 @@ capabilityFromBS "add" = Right CapAdd capabilityFromBS "manage" = Right CapManage capabilityFromBS x = Left x++simplePolicyWithOrigin :: Origin -> CorsResourcePolicy+simplePolicyWithOrigin origin =+    simpleCorsResourcePolicy { corsOrigins = Just ([origin], False) }+++corsPolicyFromString :: String -> WAI.Middleware+corsPolicyFromString origin =+  let+    policy = case origin of+        "*" -> simpleCorsResourcePolicy+        url -> simplePolicyWithOrigin $ fromString url+  in+    cors (const $ Just policy)++corsPolicy :: WebOpts -> (Application -> Application)+corsPolicy opts =+  maybe id corsPolicyFromString $ cors_ opts
Hledger/Web/Widget/AddForm.hs view
@@ -15,7 +15,9 @@ import Data.Bifunctor (first) import Data.List (dropWhileEnd, nub, sort, unfoldr) import Data.Maybe (isJust)+#if !(MIN_VERSION_base(4,13,0)) import Data.Semigroup ((<>))+#endif import Data.Text (Text) import qualified Data.Text as T import Data.Time (Day)
Hledger/Web/Widget/Common.hs view
@@ -18,7 +18,9 @@  import Data.Default (def) import Data.Foldable (find, for_)+#if !(MIN_VERSION_base(4,13,0)) import Data.Semigroup ((<>))+#endif import Data.Text (Text) import qualified Data.Text as T import System.FilePath (takeFileName)
hledger-web.1 view
@@ -1,5 +1,5 @@ -.TH "hledger-web" "1" "August 2019" "hledger-web 1.15" "hledger User Manuals"+.TH "hledger-web" "1" "December 2019" "hledger-web 1.16" "hledger User Manuals"   @@ -289,9 +289,8 @@ .PP In addition to the web UI, hledger-web provides some API routes that serve JSON in response to GET requests.-Currently these are same ones provided by the hledger-api tool, but-hledger-web will likely receive more attention than hledger-api in-future:+(And when started with \f[C]--serve-api\f[R], it provides only these+routes.): .IP .nf \f[C]@@ -377,7 +376,7 @@  .SH COPYRIGHT -Copyright (C) 2007-2016 Simon Michael.+Copyright (C) 2007-2019 Simon Michael. .br Released under GNU GPL v3 or later. 
hledger-web.cabal view
@@ -4,19 +4,19 @@ -- -- see: https://github.com/sol/hpack ----- hash: 0edf95448e05cc75fb3c049d3ecc20264e8869497966ac5eb8783ee803dbce35+-- hash: feb3102322a4d8c36e44d90678edc2708511ccd69f6d6d1558de68da63c7f325  name:           hledger-web-version:        1.15+version:        1.16 synopsis:       Web interface for the hledger accounting tool description:    This is hledger's web interface.                 It provides a more user-friendly and collaborative UI than the-                command-line or curses-style interfaces.+                command-line or terminal interfaces.                 .                 hledger is a cross-platform program for tracking money, time, or                 any other commodity, using double-entry accounting and a simple,                 editable file format. It is inspired by and largely compatible-                with ledger(1).  hledger provides command-line, curses and web+                with ledger(1).  hledger provides command-line, terminal and web                 interfaces, and aims to be a reliable, practical tool for daily                 use. category:       Finance@@ -27,7 +27,7 @@ maintainer:     Simon Michael <simon@joyful.com> license:        GPL-3 license-file:   LICENSE-tested-with:    GHC==7.10.3, GHC==8.0.2, GHC==8.2.2, GHC==8.4.3, GHC==8.6.5+tested-with:    GHC==8.0.2, GHC==8.2.2, GHC==8.4.3, GHC==8.6.5, GHC==8.8.1 build-type:     Simple extra-source-files:     CHANGES.md@@ -150,12 +150,12 @@       Paths_hledger_web   hs-source-dirs:       ./.-  ghc-options: -Wall -fwarn-tabs-  cpp-options: -DVERSION="1.15"+  ghc-options: -Wall -fwarn-tabs -Wcompat -Wincomplete-uni-patterns -Wincomplete-record-updates -Wredundant-constraints+  cpp-options: -DVERSION="1.16"   build-depends:       Decimal     , aeson-    , base >=4.8 && <4.13+    , base >=4.9 && <4.14     , blaze-html     , blaze-markup     , bytestring@@ -169,8 +169,8 @@     , directory     , filepath     , hjsmin-    , hledger >=1.15 && <1.16-    , hledger-lib >=1.15 && <1.16+    , hledger >=1.16 && <1.17+    , hledger-lib >=1.16 && <1.17     , http-client     , http-conduit     , http-types@@ -183,25 +183,21 @@     , text >=1.2     , time >=1.5     , transformers+    , utf8-string     , wai+    , wai-cors     , wai-extra     , wai-handler-launch >=1.3     , warp     , yaml+    , yesod >=1.4 && <1.7+    , yesod-core >=1.4 && <1.7+    , yesod-form >=1.4 && <1.7+    , yesod-static >=1.4 && <1.7   if (flag(dev)) || (flag(library-only))     cpp-options: -DDEVELOPMENT   if flag(dev)     ghc-options: -O0-  if impl(ghc >=8)-    ghc-options: -Wcompat -Wincomplete-uni-patterns -Wincomplete-record-updates -Wredundant-constraints-  if os(darwin) && impl(ghc < 8.0)-    buildable: False-  else-    build-depends:-        yesod >=1.4 && <1.7-      , yesod-core >=1.4 && <1.7-      , yesod-form >=1.4 && <1.7-      , yesod-static >=1.4 && <1.7   default-language: Haskell2010  executable hledger-web@@ -210,8 +206,8 @@       Paths_hledger_web   hs-source-dirs:       app-  ghc-options: -Wall -fwarn-tabs-  cpp-options: -DVERSION="1.15"+  ghc-options: -Wall -fwarn-tabs -Wcompat -Wincomplete-uni-patterns -Wincomplete-record-updates -Wredundant-constraints+  cpp-options: -DVERSION="1.16"   build-depends:       base     , hledger-web@@ -219,12 +215,8 @@     cpp-options: -DDEVELOPMENT   if flag(dev)     ghc-options: -O0-  if impl(ghc >=8)-    ghc-options: -Wcompat -Wincomplete-uni-patterns -Wincomplete-record-updates -Wredundant-constraints   if flag(library-only)     buildable: False   if flag(threaded)     ghc-options: -threaded-  if os(darwin) && impl(ghc < 8.0)-    buildable: False   default-language: Haskell2010
hledger-web.info view
@@ -3,7 +3,7 @@  File: hledger-web.info,  Node: Top,  Next: OPTIONS,  Up: (dir) -hledger-web(1) hledger-web 1.15+hledger-web(1) hledger-web 1.16 *******************************  hledger-web is hledger's web interface.  It starts a simple web@@ -298,9 +298,8 @@ **********  In addition to the web UI, hledger-web provides some API routes that-serve JSON in response to GET requests.  Currently these are same ones-provided by the hledger-api tool, but hledger-web will likely receive-more attention than hledger-api in future:+serve JSON in response to GET requests.  (And when started with+'--serve-api', it provides only these routes.):  /accountnames /transactions
hledger-web.txt view
@@ -19,9 +19,9 @@        hledger-web is hledger's web interface.  It starts a simple web  appli-        cation for browsing and adding transactions, and optionally opens it in        a web browser window if possible.  It provides a more user-friendly  UI-       than  the  hledger  CLI  or  hledger-ui interface, showing more at once-       (accounts, the current account register, balance charts)  and  allowing-       history-aware data entry, interactive searching, and bookmarking.+       than the hledger CLI or hledger-ui interface, showing more at once (ac-+       counts, the current account register, balance charts) and allowing his-+       tory-aware data entry, interactive searching, and bookmarking.         hledger-web  also  lets you share a ledger with multiple users, or even        the public web.  There is no access control, so if you  need  that  you@@ -127,8 +127,8 @@               using period expressions syntax         --date2-              match  the  secondary  date  instead (see command help for other-              effects)+              match the secondary date instead (see command help for other ef-+              fects)         -U --unmarked               include only unmarked postings/txns (can combine with -P or -C)@@ -208,14 +208,14 @@        for better caching or cookie-less serving on high performance websites.  PERMISSIONS-       By default, hledger-web allows anyone who can  reach  it  to  view  the+       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.         You can restrict who can reach it by -       o setting  the IP address it listens on (see --host above).  By default-         it listens on  127.0.0.1,  accessible  to  all  users  on  the  local-         machine.+       o setting the IP address it listens on (see --host above).  By  default+         it  listens  on  127.0.0.1,  accessible to all users on the local ma-+         chine.         o putting it behind an authenticating proxy, using eg apache or nginx @@ -224,55 +224,54 @@        You can restrict what the users who reach it can do, by         o using the --capabilities=CAP[,CAP..] flag when you start it, enabling-         one or more of the following  capabilities.   The  default  value  is+         one  or  more  of  the  following capabilities.  The default value is          view,add:           o view - allows viewing the journal file and all included files           o add - allows adding new transactions to the main journal file -         o manage  -  allows  editing,  uploading  or  downloading the main or-           included files+         o manage - allows editing, uploading or downloading the main  or  in-+           cluded files -       o using the --capabilities-header=HTTPHEADER flag  to  specify  a  HTTP-         header  from  which it will read capabilities to enable.  hledger-web-         on Sandstorm uses the  X-Sandstorm-Permissions  header  to  integrate+       o using  the  --capabilities-header=HTTPHEADER  flag  to specify a HTTP+         header from which it will read capabilities to  enable.   hledger-web+         on  Sandstorm  uses  the  X-Sandstorm-Permissions header to integrate          with Sandstorm's permissions.  This is disabled by default.  EDITING, UPLOADING, DOWNLOADING-       If  you  enable the manage capability mentioned above, you'll see a new-       "spanner" button to the right of the search form.  Clicking  this  will-       let  you  edit,  upload,  or  download the journal file or any files it-       includes.+       If you enable the manage capability mentioned above, you'll see  a  new+       "spanner"  button  to the right of the search form.  Clicking this will+       let you edit, upload, or download the journal file or any files it  in-+       cludes. -       Note, unlike any other hledger command, in this mode you (or any  visi-+       Note,  unlike any other hledger command, in this mode you (or any visi-        tor) can alter or wipe the data files. -       Normally  whenever  a  file is changed in this way, hledger-web saves a-       numbered backup (assuming file permissions allow it, the  disk  is  not-       full,  etc.)  hledger-web is not aware of version control systems, cur--       rently; if you use one, you'll have to arrange to  commit  the  changes+       Normally whenever a file is changed in this way,  hledger-web  saves  a+       numbered  backup  (assuming  file permissions allow it, the disk is not+       full, etc.) hledger-web is not aware of version control  systems,  cur-+       rently;  if  you  use one, you'll have to arrange to commit the changes        yourself (eg with a cron job or a file watcher like entr). -       Changes  which would leave the journal file(s) unparseable or non-valid-       (eg with failing balance assertions) are prevented.   (Probably.   This+       Changes which would leave the journal file(s) unparseable or  non-valid+       (eg  with  failing balance assertions) are prevented.  (Probably.  This        needs re-testing.)  RELOADING        hledger-web detects changes made to the files by other means (eg if you-       edit it directly, outside of hledger-web), and it  will  show  the  new-       data  when  you reload the page or navigate to a new page.  If a change-       makes a file unparseable, hledger-web will  display  an  error  message-       until the file has been fixed.+       edit  it  directly,  outside  of hledger-web), and it will show the new+       data when you reload the page or navigate to a new page.  If  a  change+       makes a file unparseable, hledger-web will display an error message un-+       til the file has been fixed.         (Note: if you are viewing files mounted from another machine, make sure        that both machine clocks are roughly in step.)  JSON API-       In addition to the web UI, hledger-web provides some  API  routes  that-       serve  JSON in response to GET requests.  Currently these are same ones-       provided by the hledger-api tool, but hledger-web will  likely  receive-       more attention than hledger-api in future:+       In  addition  to  the web UI, hledger-web provides some API routes that+       serve JSON in  response  to  GET  requests.   (And  when  started  with+       --serve-api, it provides only these routes.):                /accountnames               /transactions@@ -345,7 +344,7 @@   COPYRIGHT-       Copyright (C) 2007-2016 Simon Michael.+       Copyright (C) 2007-2019 Simon Michael.        Released under GNU GPL v3 or later.  @@ -358,4 +357,4 @@   -hledger-web 1.15                  August 2019                   hledger-web(1)+hledger-web 1.16                 December 2019                  hledger-web(1)
static/hledger.js view
@@ -9,7 +9,8 @@   var dateEl = $('#dateWrap').datepicker({     showOnFocus: false,     autoclose: true,-    format: 'yyyy-mm-dd'+    format: 'yyyy-mm-dd',+    weekStart: 1 // Monday   });;    // ensure add form always focuses its first field
static/js/excanvas.js view
@@ -50,7 +50,7 @@   var Z2 = Z / 2;    /**-   * This funtion is assigned to the <canvas> elements as element.getContext().+   * This function is assigned to the <canvas> elements as element.getContext().    * @this {HTMLElement}    * @return {CanvasRenderingContext2D_}    */