packages feed

hledger-web 1.21 → 1.22

raw patch · 14 files changed

+348/−349 lines, 14 filesdep ~basedep ~containersdep ~hledgerPVP ok

version bump matches the API change (PVP)

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

API changes (from Hackage documentation)

- Hledger.Web.Import: DBName :: Text -> DBName
- Hledger.Web.Import: EntityDef :: !HaskellName -> !DBName -> !FieldDef -> ![Attr] -> ![FieldDef] -> ![UniqueDef] -> ![ForeignDef] -> ![Text] -> !Map Text [ExtraLine] -> !Bool -> !Maybe Text -> EntityDef
- Hledger.Web.Import: HaskellName :: Text -> HaskellName
- Hledger.Web.Import: OnlyUniqueException :: String -> OnlyUniqueException
- Hledger.Web.Import: PersistDbSpecific :: ByteString -> PersistValue
- Hledger.Web.Import: PersistLiteral :: ByteString -> PersistValue
- Hledger.Web.Import: PersistLiteralEscaped :: ByteString -> PersistValue
- Hledger.Web.Import: [emFieldCycle] :: EmbedFieldDef -> Maybe HaskellName
- Hledger.Web.Import: [entityAttrs] :: EntityDef -> ![Attr]
- Hledger.Web.Import: [entityComments] :: EntityDef -> !Maybe Text
- Hledger.Web.Import: [entityDB] :: EntityDef -> !DBName
- Hledger.Web.Import: [entityDerives] :: EntityDef -> ![Text]
- Hledger.Web.Import: [entityExtra] :: EntityDef -> !Map Text [ExtraLine]
- Hledger.Web.Import: [entityFields] :: EntityDef -> ![FieldDef]
- Hledger.Web.Import: [entityForeigns] :: EntityDef -> ![ForeignDef]
- Hledger.Web.Import: [entityHaskell] :: EntityDef -> !HaskellName
- Hledger.Web.Import: [entityId] :: EntityDef -> !FieldDef
- Hledger.Web.Import: [entitySum] :: EntityDef -> !Bool
- Hledger.Web.Import: [entityUniques] :: EntityDef -> ![UniqueDef]
- Hledger.Web.Import: [unDBName] :: DBName -> Text
- Hledger.Web.Import: [unHaskellName] :: HaskellName -> Text
- Hledger.Web.Import: data OnlyUniqueException
- Hledger.Web.Import: entityKeyFields :: EntityDef -> [FieldDef]
- Hledger.Web.Import: newtype DBName
- Hledger.Web.Import: newtype HaskellName
- Hledger.Web.Import: toEmbedEntityDef :: EntityDef -> EmbedEntityDef
+ Hledger.Web.Import: ConstraintNameDB :: Text -> ConstraintNameDB
+ Hledger.Web.Import: ConstraintNameHS :: Text -> ConstraintNameHS
+ Hledger.Web.Import: DbSpecific :: LiteralType
+ Hledger.Web.Import: EntityIdField :: !FieldDef -> EntityIdDef
+ Hledger.Web.Import: EntityIdNaturalKey :: !CompositeDef -> EntityIdDef
+ Hledger.Web.Import: EntityNameDB :: Text -> EntityNameDB
+ Hledger.Web.Import: EntityNameHS :: Text -> EntityNameHS
+ Hledger.Web.Import: Escaped :: LiteralType
+ Hledger.Web.Import: FTTypePromoted :: Text -> FieldType
+ Hledger.Web.Import: FieldAttrSql :: Text -> FieldAttr
+ Hledger.Web.Import: FieldNameDB :: Text -> FieldNameDB
+ Hledger.Web.Import: FieldNameHS :: Text -> FieldNameHS
+ Hledger.Web.Import: OptionListGrouped :: [(Text, [Option a])] -> (Text -> Maybe a) -> OptionList a
+ Hledger.Web.Import: PersistLiteral_ :: LiteralType -> ByteString -> PersistValue
+ Hledger.Web.Import: Unescaped :: LiteralType
+ Hledger.Web.Import: [fieldIsImplicitIdColumn] :: FieldDef -> !Bool
+ Hledger.Web.Import: [olOptionsGrouped] :: OptionList a -> [(Text, [Option a])]
+ Hledger.Web.Import: [olReadExternalGrouped] :: OptionList a -> Text -> Maybe a
+ Hledger.Web.Import: [unConstraintNameDB] :: ConstraintNameDB -> Text
+ Hledger.Web.Import: [unConstraintNameHS] :: ConstraintNameHS -> Text
+ Hledger.Web.Import: [unEntityNameDB] :: EntityNameDB -> Text
+ Hledger.Web.Import: [unEntityNameHS] :: EntityNameHS -> Text
+ Hledger.Web.Import: [unFieldNameDB] :: FieldNameDB -> Text
+ Hledger.Web.Import: [unFieldNameHS] :: FieldNameHS -> Text
+ Hledger.Web.Import: addFieldAttr :: FieldAttr -> FieldDef -> FieldDef
+ Hledger.Web.Import: class DatabaseName a
+ Hledger.Web.Import: data EntityIdDef
+ Hledger.Web.Import: data ImplicitIdDef
+ Hledger.Web.Import: data LiteralType
+ Hledger.Web.Import: discoverEntities :: Q Exp
+ Hledger.Web.Import: escapeWith :: DatabaseName a => (Text -> str) -> a -> str
+ Hledger.Web.Import: fieldAttrsContainsNullable :: [FieldAttr] -> IsNullable
+ Hledger.Web.Import: getEntityComments :: EntityDef -> Maybe Text
+ Hledger.Web.Import: getEntityDBName :: EntityDef -> EntityNameDB
+ Hledger.Web.Import: getEntityExtra :: EntityDef -> Map Text [[Text]]
+ Hledger.Web.Import: getEntityFields :: EntityDef -> [FieldDef]
+ Hledger.Web.Import: getEntityFieldsDatabase :: EntityDef -> [FieldDef]
+ Hledger.Web.Import: getEntityForeignDefs :: EntityDef -> [ForeignDef]
+ Hledger.Web.Import: getEntityHaskellName :: EntityDef -> EntityNameHS
+ Hledger.Web.Import: getEntityId :: EntityDef -> EntityIdDef
+ Hledger.Web.Import: getEntityIdField :: EntityDef -> Maybe FieldDef
+ Hledger.Web.Import: getEntityKeyFields :: EntityDef -> NonEmpty FieldDef
+ Hledger.Web.Import: getEntityUniques :: EntityDef -> [UniqueDef]
+ Hledger.Web.Import: isEntitySum :: EntityDef -> Bool
+ Hledger.Web.Import: isFieldMaybe :: FieldDef -> Bool
+ Hledger.Web.Import: isFieldNullable :: FieldDef -> IsNullable
+ Hledger.Web.Import: isHaskellField :: FieldDef -> Bool
+ Hledger.Web.Import: migrateModels :: [EntityDef] -> Migration
+ Hledger.Web.Import: mkOptionListGrouped :: [(Text, [Option a])] -> OptionList a
+ Hledger.Web.Import: mkPersistWith :: MkPersistSettings -> [EntityDef] -> [UnboundEntityDef] -> Q [Dec]
+ Hledger.Web.Import: newtype ConstraintNameDB
+ Hledger.Web.Import: newtype ConstraintNameHS
+ Hledger.Web.Import: newtype EntityNameDB
+ Hledger.Web.Import: newtype EntityNameHS
+ Hledger.Web.Import: newtype FieldNameDB
+ Hledger.Web.Import: newtype FieldNameHS
+ Hledger.Web.Import: onlyOneUniqueDef :: (OnlyOneUniqueKey record, Monad proxy) => proxy record -> UniqueDef
+ Hledger.Web.Import: optionsPairsGrouped :: (MonadHandler m, RenderMessage (HandlerSite m) msg) => [(msg, [(msg, a)])] -> m (OptionList a)
+ Hledger.Web.Import: overEntityFields :: ([FieldDef] -> [FieldDef]) -> EntityDef -> EntityDef
+ Hledger.Web.Import: overFieldAttrs :: ([FieldAttr] -> [FieldAttr]) -> FieldDef -> FieldDef
+ Hledger.Web.Import: pattern PersistDbSpecific :: ByteString -> PersistValue
+ Hledger.Web.Import: pattern PersistLiteral :: ByteString -> PersistValue
+ Hledger.Web.Import: pattern PersistLiteralEscaped :: ByteString -> PersistValue
+ Hledger.Web.Import: selectFieldListGrouped :: (Eq a, RenderMessage site FormMessage, RenderMessage site msg) => [(msg, [(msg, a)])] -> Field (HandlerFor site) a
+ Hledger.Web.Import: setEntityDBName :: EntityNameDB -> EntityDef -> EntityDef
+ Hledger.Web.Import: setEntityId :: FieldDef -> EntityDef -> EntityDef
+ Hledger.Web.Import: setEntityIdDef :: EntityIdDef -> EntityDef -> EntityDef
+ Hledger.Web.Import: setFieldAttrs :: [FieldAttr] -> FieldDef -> FieldDef
+ Hledger.Web.Import: setImplicitIdDef :: ImplicitIdDef -> MkPersistSettings -> MkPersistSettings
+ Hledger.Web.Import: withBaseBackend :: forall backend (m :: Type -> Type) a. HasPersistBackend backend => ReaderT (BaseBackend backend) m a -> ReaderT backend m a
+ Hledger.Web.Import: withCompatibleBackend :: forall sup sub (m :: Type -> Type) a. BackendCompatible sup sub => ReaderT sup m a -> ReaderT sub m a
- Hledger.Web.Import: CompositeDef :: ![FieldDef] -> ![Attr] -> CompositeDef
+ Hledger.Web.Import: CompositeDef :: !NonEmpty FieldDef -> ![Attr] -> CompositeDef
- Hledger.Web.Import: EmbedEntityDef :: !HaskellName -> ![EmbedFieldDef] -> EmbedEntityDef
+ Hledger.Web.Import: EmbedEntityDef :: EntityNameHS -> [EmbedFieldDef] -> EmbedEntityDef
- Hledger.Web.Import: EmbedFieldDef :: !DBName -> Maybe EmbedEntityDef -> Maybe HaskellName -> EmbedFieldDef
+ Hledger.Web.Import: EmbedFieldDef :: FieldNameDB -> Maybe (Either SelfEmbed EntityNameHS) -> EmbedFieldDef
- Hledger.Web.Import: EmbedRef :: EmbedEntityDef -> ReferenceDef
+ Hledger.Web.Import: EmbedRef :: EntityNameHS -> ReferenceDef
- Hledger.Web.Import: FieldDef :: !HaskellName -> !DBName -> !FieldType -> !SqlType -> ![FieldAttr] -> !Bool -> !ReferenceDef -> !FieldCascade -> !Maybe Text -> !Maybe Text -> FieldDef
+ Hledger.Web.Import: FieldDef :: !FieldNameHS -> !FieldNameDB -> !FieldType -> !SqlType -> ![FieldAttr] -> !Bool -> !ReferenceDef -> !FieldCascade -> !Maybe Text -> !Maybe Text -> !Bool -> FieldDef
- Hledger.Web.Import: ForeignDef :: !HaskellName -> !DBName -> !HaskellName -> !DBName -> !FieldCascade -> ![(ForeignFieldDef, ForeignFieldDef)] -> ![Attr] -> Bool -> Bool -> ForeignDef
+ Hledger.Web.Import: ForeignDef :: !EntityNameHS -> !EntityNameDB -> !ConstraintNameHS -> !ConstraintNameDB -> !FieldCascade -> ![(ForeignFieldDef, ForeignFieldDef)] -> ![Attr] -> Bool -> Bool -> ForeignDef
- Hledger.Web.Import: ForeignRef :: !HaskellName -> !FieldType -> ReferenceDef
+ Hledger.Web.Import: ForeignRef :: !EntityNameHS -> ReferenceDef
- Hledger.Web.Import: UniqueDef :: !HaskellName -> !DBName -> ![(HaskellName, DBName)] -> ![Attr] -> UniqueDef
+ Hledger.Web.Import: UniqueDef :: !ConstraintNameHS -> !ConstraintNameDB -> !NonEmpty (FieldNameHS, FieldNameDB) -> ![Attr] -> UniqueDef
- Hledger.Web.Import: [compositeFields] :: CompositeDef -> ![FieldDef]
+ Hledger.Web.Import: [compositeFields] :: CompositeDef -> !NonEmpty FieldDef
- Hledger.Web.Import: [emFieldDB] :: EmbedFieldDef -> !DBName
+ Hledger.Web.Import: [emFieldDB] :: EmbedFieldDef -> FieldNameDB
- Hledger.Web.Import: [emFieldEmbed] :: EmbedFieldDef -> Maybe EmbedEntityDef
+ Hledger.Web.Import: [emFieldEmbed] :: EmbedFieldDef -> Maybe (Either SelfEmbed EntityNameHS)
- Hledger.Web.Import: [embeddedFields] :: EmbedEntityDef -> ![EmbedFieldDef]
+ Hledger.Web.Import: [embeddedFields] :: EmbedEntityDef -> [EmbedFieldDef]
- Hledger.Web.Import: [embeddedHaskell] :: EmbedEntityDef -> !HaskellName
+ Hledger.Web.Import: [embeddedHaskell] :: EmbedEntityDef -> EntityNameHS
- Hledger.Web.Import: [fieldDB] :: FieldDef -> !DBName
+ Hledger.Web.Import: [fieldDB] :: FieldDef -> !FieldNameDB
- Hledger.Web.Import: [fieldHaskell] :: FieldDef -> !HaskellName
+ Hledger.Web.Import: [fieldHaskell] :: FieldDef -> !FieldNameHS
- Hledger.Web.Import: [foreignConstraintNameDBName] :: ForeignDef -> !DBName
+ Hledger.Web.Import: [foreignConstraintNameDBName] :: ForeignDef -> !ConstraintNameDB
- Hledger.Web.Import: [foreignConstraintNameHaskell] :: ForeignDef -> !HaskellName
+ Hledger.Web.Import: [foreignConstraintNameHaskell] :: ForeignDef -> !ConstraintNameHS
- Hledger.Web.Import: [foreignRefTableDBName] :: ForeignDef -> !DBName
+ Hledger.Web.Import: [foreignRefTableDBName] :: ForeignDef -> !EntityNameDB
- Hledger.Web.Import: [foreignRefTableHaskell] :: ForeignDef -> !HaskellName
+ Hledger.Web.Import: [foreignRefTableHaskell] :: ForeignDef -> !EntityNameHS
- Hledger.Web.Import: [uniqueDBName] :: UniqueDef -> !DBName
+ Hledger.Web.Import: [uniqueDBName] :: UniqueDef -> !ConstraintNameDB
- Hledger.Web.Import: [uniqueFields] :: UniqueDef -> ![(HaskellName, DBName)]
+ Hledger.Web.Import: [uniqueFields] :: UniqueDef -> !NonEmpty (FieldNameHS, FieldNameDB)
- Hledger.Web.Import: [uniqueHaskell] :: UniqueDef -> !HaskellName
+ Hledger.Web.Import: [uniqueHaskell] :: UniqueDef -> !ConstraintNameHS
- Hledger.Web.Import: breadcrumbs :: YesodBreadcrumbs site => HandlerFor site (Text, [(Route site, Text)])
+ Hledger.Web.Import: breadcrumbs :: (YesodBreadcrumbs site, Show (Route site), Eq (Route site)) => HandlerFor site (Text, [(Route site, Text)])
- Hledger.Web.Import: class (PersistCore backend, PersistStoreRead backend) => PersistUniqueRead backend
+ Hledger.Web.Import: class PersistStoreRead backend => PersistUniqueRead backend
- Hledger.Web.Import: embedEntityDefs :: [EntityDef] -> [EntityDef]
+ Hledger.Web.Import: embedEntityDefs :: [EntityDef] -> [UnboundEntityDef] -> [UnboundEntityDef]
- Hledger.Web.Import: entitiesPrimary :: EntityDef -> Maybe [FieldDef]
+ Hledger.Web.Import: entitiesPrimary :: EntityDef -> NonEmpty FieldDef
- Hledger.Web.Import: keyAndEntityFields :: EntityDef -> [FieldDef]
+ Hledger.Web.Import: keyAndEntityFields :: EntityDef -> NonEmpty FieldDef
- Hledger.Web.Import: mkDeleteCascade :: MkPersistSettings -> [EntityDef] -> Q [Dec]
+ Hledger.Web.Import: mkDeleteCascade :: MkPersistSettings -> [UnboundEntityDef] -> Q [Dec]
- Hledger.Web.Import: mkEntityDefList :: String -> [EntityDef] -> Q [Dec]
+ Hledger.Web.Import: mkEntityDefList :: String -> [UnboundEntityDef] -> Q [Dec]
- Hledger.Web.Import: mkMigrate :: String -> [EntityDef] -> Q [Dec]
+ Hledger.Web.Import: mkMigrate :: String -> [UnboundEntityDef] -> Q [Dec]
- Hledger.Web.Import: mkPersist :: MkPersistSettings -> [EntityDef] -> Q [Dec]
+ Hledger.Web.Import: mkPersist :: MkPersistSettings -> [UnboundEntityDef] -> Q [Dec]
- Hledger.Web.Import: persistFieldFromEntity :: MkPersistSettings -> EntityDef -> Q [Dec]
+ Hledger.Web.Import: persistFieldFromEntity :: MkPersistSettings -> UnboundEntityDef -> Q [Dec]
- Hledger.Web.Import: persistUniqueToFieldNames :: PersistEntity record => Unique record -> [(HaskellName, DBName)]
+ Hledger.Web.Import: persistUniqueToFieldNames :: PersistEntity record => Unique record -> NonEmpty (FieldNameHS, FieldNameDB)
- Hledger.Web.Import: pkNewtype :: MkPersistSettings -> EntityDef -> Bool
+ Hledger.Web.Import: pkNewtype :: MkPersistSettings -> UnboundEntityDef -> Bool
- Hledger.Web.Import: selectFieldHelper :: (Eq a, RenderMessage site FormMessage) => (Text -> Text -> [(Text, Text)] -> WidgetFor site () -> WidgetFor site ()) -> (Text -> Text -> Bool -> WidgetFor site ()) -> (Text -> Text -> [(Text, Text)] -> Text -> Bool -> Text -> WidgetFor site ()) -> HandlerFor site (OptionList a) -> Field (HandlerFor site) a
+ Hledger.Web.Import: selectFieldHelper :: (Eq a, RenderMessage site FormMessage) => (Text -> Text -> [(Text, Text)] -> WidgetFor site () -> WidgetFor site ()) -> (Text -> Text -> Bool -> WidgetFor site ()) -> (Text -> Text -> [(Text, Text)] -> Text -> Bool -> Text -> WidgetFor site ()) -> Maybe (Text -> WidgetFor site ()) -> HandlerFor site (OptionList a) -> Field (HandlerFor site) a
- Hledger.Web.Import: share :: [[EntityDef] -> Q [Dec]] -> [EntityDef] -> Q [Dec]
+ Hledger.Web.Import: share :: [[a] -> Q [Dec]] -> [a] -> Q [Dec]
- Hledger.Web.Import: type ForeignFieldDef = (HaskellName, DBName)
+ Hledger.Web.Import: type ForeignFieldDef = (FieldNameHS, FieldNameDB)

Files

CHANGES.md view
@@ -1,5 +1,32 @@+<!--+              _     +__      _____| |__  +\ \ /\ / / _ \ '_ \ + \ V  V /  __/ |_) |+  \_/\_/ \___|_.__/ +                    +--> User-visible changes in hledger-web. See also the hledger changelog.++# 1.22 2021-07-03++Improvements++- The --version flag shows more detail (git tag/patchlevel/commit+  hash, platform/architecture). (Stephen Morgan)++- Allow yesod-form 1.7 (Felix Yan)++- Add now-required lower bound on containers. (#1514)++- GHC 9.0 is now officially supported, and GHC 8.0, 8.2, 8.4 are not;+  building hledger now requires GHC 8.6 or greater.++Fixes++- In the add form, fix a bug where extra posting rows were not added+  when needed in certain web browsers. (charukiewicz)  # 1.21 2021-03-10 
Hledger/Web/Foundation.hs view
@@ -1,15 +1,14 @@-{-# OPTIONS_GHC -fno-warn-orphans #-}-{-# LANGUAGE CPP #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE LambdaCase #-}+{-# OPTIONS_GHC -fno-warn-orphans  #-}+{-# LANGUAGE CPP                   #-}+{-# LANGUAGE FlexibleInstances     #-}+{-# LANGUAGE LambdaCase            #-} {-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE NamedFieldPuns #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE QuasiQuotes #-}-{-# LANGUAGE TemplateHaskell #-}-{-# LANGUAGE TypeFamilies #-}-{-# LANGUAGE TypeSynonymInstances #-}-{-# LANGUAGE ViewPatterns #-}+{-# LANGUAGE NamedFieldPuns        #-}+{-# LANGUAGE OverloadedStrings     #-}+{-# LANGUAGE QuasiQuotes           #-}+{-# LANGUAGE TemplateHaskell       #-}+{-# LANGUAGE TypeFamilies          #-}+{-# LANGUAGE ViewPatterns          #-}  -- | Define the web application's foundation, in the usual Yesod style. --   See a default Yesod app's comments for more details of each part.@@ -22,9 +21,6 @@ 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)@@ -91,11 +87,7 @@ -- | A convenience alias. type AppRoute = Route App -#if MIN_VERSION_yesod(1,6,0) type Form x = Html -> MForm (HandlerFor App) (FormResult x, Widget)-#else-type Form x = Html -> MForm (HandlerT App IO) (FormResult x, Widget)-#endif  -- Please see the documentation for the Yesod typeclass. There are a number -- of settings which can be configured by overriding methods here.
Hledger/Web/Handler/JournalR.hs view
@@ -27,7 +27,7 @@         Just (a, inclsubs) -> "Transactions in " <> a <> if inclsubs then "" else " (excluding subaccounts)"       title' = title <> if m /= Any then ", filtered" else ""       acctlink a = (RegisterR, [("q", replaceInacct q $ accountQuery a)])-      items = transactionsReport (rsOpts . reportspec_ $ cliopts_ opts) j m+      items = transactionsReport (reportspec_ $ cliopts_ opts) j m       transactionFrag = transactionFragment j    defaultLayout $ do
Hledger/Web/Import.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE CPP #-} module Hledger.Web.Import   ( module Import   ) where@@ -25,7 +24,3 @@ import           Hledger.Web.Settings             as Import import           Hledger.Web.Settings.StaticFiles as Import import           Hledger.Web.WebOptions           as Import (Capability(..))--#if !(MIN_VERSION_base(4,11,0))-import           Data.Monoid          as Import ((<>))-#endif
Hledger/Web/Settings.hs view
@@ -1,4 +1,7 @@-{-# LANGUAGE CPP, OverloadedStrings, QuasiQuotes #-}+{-# LANGUAGE CPP               #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE QuasiQuotes       #-}+ -- | Settings are centralized, as much as possible, into this file. This -- includes database connection settings, static file locations, etc. -- In addition, you can configure a number of different aspects of Yesod@@ -7,9 +10,6 @@ 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
@@ -27,7 +27,7 @@ version = "" #endif prognameandversion :: String-prognameandversion = progname ++ " " ++ version :: String+prognameandversion = versiondescription progname  webflags :: [Flag RawOpts] webflags =
Hledger/Web/Widget/AddForm.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE OverloadedStrings #-}@@ -13,11 +12,10 @@  import Control.Monad.State.Strict (evalStateT) import Data.Bifunctor (first)+import Data.Foldable (toList) import Data.List (dropWhileEnd, intercalate, unfoldr) import Data.Maybe (isJust)-#if !(MIN_VERSION_base(4,13,0))-import Data.Semigroup ((<>))-#endif+import qualified Data.Set as S import Data.Text (Text) import qualified Data.Text as T import Data.Time (Day)@@ -27,16 +25,11 @@  import Hledger import Hledger.Web.Settings (widgetFile)-import Data.List.Extra (nubSort)  addModal ::      ( MonadWidget m      , r ~ Route (HandlerSite m)-#if MIN_VERSION_yesod(1,6,0)      , m ~ WidgetFor (HandlerSite m)-#else-     , m ~ WidgetT (HandlerSite m) IO-#endif      , RenderMessage (HandlerSite m) FormMessage      )   => r -> Journal -> Day -> m ()@@ -59,11 +52,7 @@   => Journal   -> Day   -> Markup-#if MIN_VERSION_yesod(1,6,0)   -> MForm m (FormResult Transaction, WidgetFor site ())-#else-  -> MForm m (FormResult Transaction, WidgetT site IO ())-#endif addForm j today = identifyForm "add" $ \extra -> do   (dateRes, dateView) <- mreq dateField dateFS Nothing   (descRes, descView) <- mreq textField descFS Nothing@@ -72,7 +61,7 @@   let (postRes, displayRows) = validatePostings acctRes amtRes    -- bindings used in add-form.hamlet-  let descriptions = nubSort $ journalPayeesDeclaredOrUsed j ++ journalDescriptions j+  let descriptions = foldMap S.fromList [journalPayeesDeclaredOrUsed j, journalDescriptions j]       journals = fst <$> jfiles j    pure (validateTransaction dateRes descRes postRes, $(widgetFile "add-form"))@@ -121,7 +110,7 @@   -> FormResult Transaction validateTransaction dateRes descRes postingsRes =   case makeTransaction <$> dateRes <*> descRes <*> postingsRes of-    FormSuccess txn -> case balanceTransaction Nothing txn of+    FormSuccess txn -> case balanceTransaction balancingOpts txn of       Left e -> FormFailure [T.pack e]       Right txn' -> FormSuccess txn'     x -> x@@ -157,7 +146,7 @@   zipRow (Left e) (Left e') = Left (Just e, Just e')   zipRow (Left e) (Right _) = Left (Just e, Nothing)   zipRow (Right _) (Left e) = Left (Nothing, Just e)-  zipRow (Right acct) (Right amt) = Right (nullposting {paccount = acct, pamount = Mixed [amt]})+  zipRow (Right acct) (Right amt) = Right (nullposting {paccount = acct, pamount = mixedAmount amt})    errorToFormMsg = first (("Invalid value: " <>) . T.pack .                           foldl (\s a -> s <> parseErrorTextPretty a) "" .
Hledger/Web/Widget/Common.hs view
@@ -1,9 +1,8 @@-{-# LANGUAGE CPP #-}-{-# LANGUAGE LambdaCase #-}-{-# LANGUAGE NamedFieldPuns #-}+{-# LANGUAGE LambdaCase        #-}+{-# LANGUAGE NamedFieldPuns    #-} {-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE QuasiQuotes #-}-{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE QuasiQuotes       #-}+{-# LANGUAGE TemplateHaskell   #-}  module Hledger.Web.Widget.Common   ( accountQuery@@ -23,9 +22,6 @@ import Data.Default (def) import Data.Foldable (find, for_) import Data.List (elemIndex)-#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)@@ -42,11 +38,7 @@ import Hledger.Web.Settings (manualurl) import qualified Hledger.Query as Query -#if MIN_VERSION_yesod(1,6,0) journalFile404 :: FilePath -> Journal -> HandlerFor m (FilePath, Text)-#else-journalFile404 :: FilePath -> Journal -> HandlerT m IO (FilePath, Text)-#endif journalFile404 f j =   case find ((== f) . fst) (jfiles j) of     Just (_, txt) -> pure (takeFileName f, txt)
hledger-web.1 view
@@ -1,12 +1,12 @@ -.TH "HLEDGER-WEB" "1" "December 2020" "hledger-web-1.21 " "hledger User Manuals"+.TH "HLEDGER-WEB" "1" "July 2021" "hledger-web-1.22 " "hledger User Manuals"    .SH NAME .PP hledger-web is a web interface (WUI) for the hledger accounting tool.-This manual is for hledger-web 1.21.+This manual is for hledger-web 1.22. .SH SYNOPSIS .PP \f[C]hledger-web [OPTIONS]\f[R]@@ -41,7 +41,7 @@ timeclock, timedot, or CSV format specified with \f[C]-f\f[R], or \f[C]$LEDGER_FILE\f[R], or \f[C]$HOME/.hledger.journal\f[R] (on windows, perhaps \f[C]C:/Users/USER/.hledger.journal\f[R]).-For more about this see hledger(1), hledger_journal(5) etc.+For more about this see hledger(1). .SH OPTIONS .PP Command-line options and arguments may be used to set an initial filter@@ -126,10 +126,12 @@ hledger reporting options: .TP \f[B]\f[CB]-b --begin=DATE\f[B]\f[R]-include postings/txns on or after this date+include postings/txns on or after this date (will be adjusted to+preceding subperiod start when using a report interval) .TP \f[B]\f[CB]-e --end=DATE\f[B]\f[R]-include postings/txns before this date+include postings/txns before this date (will be adjusted to following+subperiod end when using a report interval) .TP \f[B]\f[CB]-D --daily\f[B]\f[R] multiperiod/multicolumn report by day
hledger-web.cabal view
@@ -1,13 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.33.0.+-- This file has been generated from package.yaml by hpack version 0.34.4. -- -- see: https://github.com/sol/hpack------ hash: c793d9fd89a3465f15601f7ef6a3f790ccd62c4f8e5139e54ca0ed071c5e2f35  name:           hledger-web-version:        1.21+version:        1.22 synopsis:       Web-based user interface for the hledger accounting system description:    A simple web-based user interface for the hledger accounting system,                 providing a more modern UI than the command-line or terminal interfaces.@@ -28,8 +26,9 @@ maintainer:     Simon Michael <simon@joyful.com> license:        GPL-3 license-file:   LICENSE-tested-with:    GHC==8.2.2, GHC==8.4.4, GHC==8.6.5, GHC==8.8.3, GHC==8.10.0.20200123 build-type:     Simple+tested-with:+    GHC==8.8.4, GHC==8.10.4 extra-source-files:     CHANGES.md     README.md@@ -150,13 +149,13 @@   other-modules:       Paths_hledger_web   hs-source-dirs:-      ./.+      ./   ghc-options: -Wall -fwarn-tabs -Wcompat -Wincomplete-uni-patterns -Wincomplete-record-updates -Wredundant-constraints-  cpp-options: -DVERSION="1.21"+  cpp-options: -DVERSION="1.22"   build-depends:       Decimal >=0.5.1     , aeson >=1-    , base >=4.9 && <4.15+    , base >=4.10.1.0 && <4.16     , blaze-html     , blaze-markup     , bytestring@@ -165,14 +164,14 @@     , cmdargs >=0.10     , conduit     , conduit-extra >=1.1-    , containers+    , containers >=0.5.9     , data-default     , directory >=1.2.3.0     , extra >=1.6.3     , filepath     , hjsmin-    , hledger >=1.21 && <1.22-    , hledger-lib >=1.21 && <1.22+    , hledger ==1.22.*+    , hledger-lib ==1.22.*     , hspec     , http-client     , http-conduit@@ -196,7 +195,7 @@     , yaml     , yesod >=1.4 && <1.7     , yesod-core >=1.4 && <1.7-    , yesod-form >=1.4 && <1.7+    , yesod-form >=1.4 && <1.8     , yesod-static >=1.4 && <1.7     , yesod-test   if (flag(dev)) || (flag(library-only))@@ -212,7 +211,7 @@   hs-source-dirs:       app   ghc-options: -Wall -fwarn-tabs -Wcompat -Wincomplete-uni-patterns -Wincomplete-record-updates -Wredundant-constraints-  cpp-options: -DVERSION="1.21"+  cpp-options: -DVERSION="1.22"   build-depends:       base     , hledger-web@@ -232,7 +231,7 @@   hs-source-dirs:       test   ghc-options: -Wall -fwarn-tabs -Wcompat -Wincomplete-uni-patterns -Wincomplete-record-updates -Wredundant-constraints-  cpp-options: -DVERSION="1.21"+  cpp-options: -DVERSION="1.22"   build-depends:       base     , hledger
hledger-web.info view
@@ -1,41 +1,45 @@-This is hledger-web/hledger-web.info, produced by makeinfo version 4.8-from stdin.+This is hledger-web.info, produced by makeinfo version 6.7 from stdin. +INFO-DIR-SECTION User Applications+START-INFO-DIR-ENTRY+* hledger-web: (hledger-web/hledger-web).  Web UI/API for the hledger accounting tool.+END-INFO-DIR-ENTRY+ -File: hledger-web.info,  Node: Top,  Up: (dir)+File: hledger-web.info,  Node: Top,  Next: OPTIONS,  Up: (dir)  hledger-web(1) **************  hledger-web is a web interface (WUI) for the hledger accounting tool.-This manual is for hledger-web 1.21.+This manual is for hledger-web 1.22. -   `hledger-web [OPTIONS]'-`hledger web -- [OPTIONS]'+   'hledger-web [OPTIONS]'+'hledger web -- [OPTIONS]'     hledger is a reliable, cross-platform set of programs for tracking money, time, or any other commodity, using double-entry accounting and a-simple, editable file format. hledger is inspired by and largely+simple, editable file format.  hledger is inspired by and largely compatible with ledger(1). -   hledger-web is hledger's web interface. It starts a simple web+   hledger-web is hledger's web interface.  It starts a simple web application 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.+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.     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-should put it behind a suitable web proxy. As a small protection against-data loss when running an unprotected instance, it writes a numbered-backup of the main journal file (only ?) on every edit.+the public web.  There is no access control, so if you need that you+should put it behind a suitable web proxy.  As a small protection+against data loss when running an unprotected instance, it writes a+numbered backup of the main journal file (only ?)  on every edit.     Like hledger, it reads data from one or more files in hledger-journal, timeclock, timedot, or CSV format specified with `-f', or-`$LEDGER_FILE', or `$HOME/.hledger.journal' (on windows, perhaps-`C:/Users/USER/.hledger.journal'). For more about this see hledger(1),-hledger_journal(5) etc.+journal, timeclock, timedot, or CSV format specified with '-f', or+'$LEDGER_FILE', or '$HOME/.hledger.journal' (on windows, perhaps+'C:/Users/USER/.hledger.journal').  For more about this see hledger(1).  * Menu: @@ -55,163 +59,168 @@ *********  Command-line options and arguments may be used to set an initial filter-on the data. These filter options are not shown in the web UI, but it+on the data.  These filter options are not shown in the web UI, but it will be applied in addition to any search query entered there. -   Note: if invoking hledger-web as a hledger subcommand, write `--'+   Note: if invoking hledger-web as a hledger subcommand, write '--' before options, as shown in the synopsis above. -`--serve'+'--serve'+      serve and log requests, don't browse or auto-exit+'--serve-api' -`--serve-api'      like -serve, but serve only the JSON web API, without the      server-side web UI+'--host=IPADDR' -`--host=IPADDR'      listen on this IP address (default: 127.0.0.1)+'--port=PORT' -`--port=PORT'      listen on this TCP port (default: 5000)+'--socket=SOCKETFILE' -`--socket=SOCKETFILE'      use a unix domain socket file to listen for requests instead of a-     TCP socket. Implies `--serve'. It can only be used if the operating-     system can provide this type of socket.+     TCP socket.  Implies '--serve'.  It can only be used if the+     operating system can provide this type of socket.+'--base-url=URL' -`--base-url=URL'      set the base url (default: http://IPADDR:PORT). You would change      this when sharing over the network, or integrating within a larger      website.+'--file-url=URL' -`--file-url=URL'-     set the static files url (default: BASEURL/static). hledger-web+     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-     with this.+     them from another server for efficiency, you would set the url with+     this.+'--capabilities=CAP[,CAP..]' -`--capabilities=CAP[,CAP..]'      enable the view, add, and/or manage capabilities (default:      view,add)+'--capabilities-header=HTTPHEADER' -`--capabilities-header=HTTPHEADER'      read capabilities to enable from a HTTP header, like      X-Sandstorm-Permissions (default: disabled)+'--test' -`--test'-     run hledger-web's tests and exit. hspec test runner args may+     run hledger-web's tests and exit.  hspec test runner args may      follow a -, eg: hledger-web -test - -help     hledger input options: -`-f FILE --file=FILE'-     use a different input file. For stdin, use - (default:-     `$LEDGER_FILE' or `$HOME/.hledger.journal')+'-f FILE --file=FILE' -`--rules-file=RULESFILE'+     use a different input file.  For stdin, use - (default:+     '$LEDGER_FILE' or '$HOME/.hledger.journal')+'--rules-file=RULESFILE'+      Conversion rules file to use when reading CSV (default: FILE.rules)+'--separator=CHAR' -`--separator=CHAR'      Field separator to expect when reading CSV (default: ',')+'--alias=OLD=NEW' -`--alias=OLD=NEW'      rename accounts named OLD to NEW+'--anon' -`--anon'      anonymize accounts and payees+'--pivot FIELDNAME' -`--pivot FIELDNAME'      use some other field or tag for the account name+'-I --ignore-assertions' -`-I --ignore-assertions'      disable balance assertion checks (note: does not disable balance      assignments)+'-s --strict' -`-s --strict'      do extra error checking (check that all posted accounts are      declared)     hledger reporting options: -`-b --begin=DATE'-     include postings/txns on or after this date+'-b --begin=DATE' -`-e --end=DATE'-     include postings/txns before this date+     include postings/txns on or after this date (will be adjusted to+     preceding subperiod start when using a report interval)+'-e --end=DATE' -`-D --daily'+     include postings/txns before this date (will be adjusted to+     following subperiod end when using a report interval)+'-D --daily'+      multiperiod/multicolumn report by day+'-W --weekly' -`-W --weekly'      multiperiod/multicolumn report by week+'-M --monthly' -`-M --monthly'      multiperiod/multicolumn report by month+'-Q --quarterly' -`-Q --quarterly'      multiperiod/multicolumn report by quarter+'-Y --yearly' -`-Y --yearly'      multiperiod/multicolumn report by year+'-p --period=PERIODEXP' -`-p --period=PERIODEXP'      set start date, end date, and/or reporting interval all at once      using period expressions syntax+'--date2' -`--date2'      match the secondary date instead (see command help for other      effects)+'-U --unmarked' -`-U --unmarked'      include only unmarked postings/txns (can combine with -P or -C)+'-P --pending' -`-P --pending'      include only pending postings/txns+'-C --cleared' -`-C --cleared'      include only cleared postings/txns+'-R --real' -`-R --real'      include only non-virtual postings+'-NUM --depth=NUM' -`-NUM --depth=NUM'      hide/aggregate accounts or postings more than NUM levels deep+'-E --empty' -`-E --empty'      show items with zero amount, normally hidden (and vice-versa in      hledger-ui/hledger-web)+'-B --cost' -`-B --cost'      convert amounts to their cost/selling amount at transaction time+'-V --market' -`-V --market'      convert amounts to their market value in default valuation      commodities+'-X --exchange=COMM' -`-X --exchange=COMM'      convert amounts to their market value in commodity COMM+'--value' -`--value'      convert amounts to cost or market value, more flexibly than      -B/-V/-X+'--infer-market-prices' -`--infer-market-prices'      use transaction prices (recorded with @ or @@) as additional market      prices, as if they were P directives+'--auto' -`--auto'      apply automated posting rules to modify transactions.+'--forecast' -`--forecast'      generate future transactions from periodic transaction rules, for-     the next 6 months or till report end date. In hledger-ui, also+     the next 6 months or till report end date.  In hledger-ui, also      make ordinary future transactions visible.+'--color=WHEN (or --colour=WHEN)' -`--color=WHEN (or --colour=WHEN)'      Should color-supporting commands use ANSI color codes in text      output.  'auto' (default): whenever stdout seems to be a      color-supporting terminal.  'always' or 'yes': always, useful eg-     when piping output into 'less -R'.  'never' or 'no': never.  A+     when piping output into 'less -R'. 'never' or 'no': never.  A      NO_COLOR environment variable overrides this.     When a reporting option appears more than once in the command line,@@ -221,62 +230,62 @@     hledger help options: -`-h --help'+'-h --help'+      show general or COMMAND help+'--man' -`--man'      show general or COMMAND user manual with man+'--info' -`--info'      show general or COMMAND user manual with info+'--version' -`--version'      show general or ADDONCMD version+'--debug[=N]' -`--debug[=N]'      show debug output (levels 1-9, default: 1)     A @FILE argument will be expanded to the contents of FILE, which-should contain one command line option/argument per line. (To prevent-this, insert a `--' argument before.)+should contain one command line option/argument per line.  (To prevent+this, insert a '--' argument before.)     By default, hledger-web starts the web app in "transient mode" and-also opens it in your default web browser if possible. In this mode the+also opens it in your default web browser if possible.  In this mode the web app will keep running for as long as you have it open in a browser window, and will exit after two minutes of inactivity (no requests and-no browser windows viewing it). With `--serve', it just runs the web-app without exiting, and logs requests to the console. With-`--serve-api', only the JSON web api (see below) is served, with the+no browser windows viewing it).  With '--serve', it just runs the web+app without exiting, and logs requests to the console.  With+'--serve-api', only the JSON web api (see below) is served, with the usual HTML server-side web UI disabled.     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+only to local requests.  You can use '--host' to change this, eg '--host 0.0.0.0' to listen on all configured addresses. -   Similarly, use `--port' to set a TCP port other than 5000, eg if you+   Similarly, use '--port' to set a TCP port other than 5000, eg if you are running multiple hledger-web instances. -   Both of these options are ignored when `--socket' is used. In this-case, it creates an `AF_UNIX' socket file at the supplied path and uses-that for communication. This is an alternative way of running multiple-hledger-web instances behind a reverse proxy that handles-authentication for different users. The path can be derived in a-predictable way, eg by using the username within the path. As an-example, `nginx' as reverse proxy can use the variable `$remote_user'-to derive a path from the username used in a HTTP basic authentication.-The following `proxy_pass' directive allows access to all `hledger-web'-instances that created a socket in `/tmp/hledger/':-+   Both of these options are ignored when '--socket' is used.  In this+case, it creates an 'AF_UNIX' socket file at the supplied path and uses+that for communication.  This is an alternative way of running multiple+hledger-web instances behind a reverse proxy that handles authentication+for different users.  The path can be derived in a predictable way, eg+by using the username within the path.  As an example, 'nginx' as+reverse proxy can use the variable '$remote_user' to derive a path from+the username used in a HTTP basic authentication.  The following+'proxy_pass' directive allows access to all 'hledger-web' instances that+created a socket in '/tmp/hledger/':    proxy_pass http://unix:/tmp/hledger/${remote_user}.socket; -   You can use `--base-url' to change the protocol, hostname, port and+   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+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,+   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. @@ -291,32 +300,28 @@     You can restrict who can reach it by -   * setting the IP address it listens on (see `--host' above). By+   * 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.-    * putting it behind an authenticating proxy, using eg apache or nginx-    * custom firewall rules     You can restrict what the users who reach it can do, by -   * using the `--capabilities=CAP[,CAP..]' flag when you start it,-     enabling one or more of the following capabilities. The default-     value is `view,add':-        * `view' - allows viewing the journal file and all included+   * using the '--capabilities=CAP[,CAP..]' flag when you start it,+     enabling one or more of the following capabilities.  The default+     value is 'view,add':+        * 'view' - allows viewing the journal file and all included           files--        * `add' - allows adding new transactions to the main journal+        * 'add' - allows adding new transactions to the main journal           file--        * `manage' - allows editing, uploading or downloading the main+        * 'manage' - allows editing, uploading or downloading the main           or included files -   * using the `--capabilities-header=HTTPHEADER' flag to specify a HTTP-     header from which it will read capabilities to enable. hledger-web+   * 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.+     with Sandstorm's permissions.  This is disabled by default.   File: hledger-web.info,  Node: EDITING UPLOADING DOWNLOADING,  Next: RELOADING,  Prev: PERMISSIONS,  Up: Top@@ -324,8 +329,8 @@ 3 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+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. @@ -334,13 +339,13 @@     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,+full, etc.)  hledger-web is not aware of version control systems, currently; 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 needs re-testing.)+(Probably.  This needs re-testing.)   File: hledger-web.info,  Node: RELOADING,  Next: JSON API,  Prev: EDITING UPLOADING DOWNLOADING,  Up: Top@@ -350,7 +355,7 @@  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+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. @@ -364,16 +369,14 @@ **********  In addition to the web UI, hledger-web also serves a JSON API that can-be used to get data or add new transactions. If you want the JSON API-only, you can use the `--serve-api' flag. Eg:-+be used to get data or add new transactions.  If you want the JSON API+only, you can use the '--serve-api' flag.  Eg:  $ hledger-web -f examples/sample.journal --serve-api ...     You can get JSON data from these routes: - /version /accountnames /transactions@@ -386,7 +389,6 @@ command).  (hledger-web's JSON does not include newlines, here we use python to prettify it): - $ curl -s http://127.0.0.1:5000/accountnames | python -m json.tool [     "assets",@@ -406,7 +408,6 @@     Or all transactions: - $ curl -s http://127.0.0.1:5000/transactions | python -m json.tool [     {@@ -428,25 +429,24 @@     Most of the JSON corresponds to hledger's data types; for details of what the fields mean, see the Hledger.Data.Json haddock docs and click-on the various data types, eg Transaction. And for a higher level+on the various data types, eg Transaction.  And for a higher level understanding, see the journal manual.     In some cases there is outer JSON corresponding to a "Report" type.-To understand that, go to the Hledger.Web.Handler.MiscR haddock and-look at the source for the appropriate handler to see what it returns.-Eg for `/accounttransactions' it's getAccounttransactionsR, returning a-"`accountTransactionsReport ...'". Looking up the haddock for that we+To understand that, go to the Hledger.Web.Handler.MiscR haddock and look+at the source for the appropriate handler to see what it returns.  Eg+for '/accounttransactions' it's getAccounttransactionsR, returning a+"'accountTransactionsReport ...'".  Looking up the haddock for that we can see that /accounttransactions returns an AccountTransactionsReport, which consists of a report title and a list of AccountTransactionsReportItem (etc).     You can add a new transaction to the journal with a PUT request to-`/add', if hledger-web was started with the `add' capability (enabled-by default). The payload must be the full, exact JSON representation of-a hledger transaction (partial data won't do). You can get sample JSON-from hledger-web's `/transactions' or `/accounttransactions', or you-can export it with hledger-lib, eg like so:-+'/add', if hledger-web was started with the 'add' capability (enabled by+default).  The payload must be the full, exact JSON representation of a+hledger transaction (partial data won't do).  You can get sample JSON+from hledger-web's '/transactions' or '/accounttransactions', or you can+export it with hledger-lib, eg like so:  .../hledger$ stack ghci hledger-lib >>> writeJsonFile "txn.json" (head $ jtxns samplejournal)@@ -455,7 +455,6 @@    Here's how it looks as of hledger-1.17 (remember, this JSON corresponds to hledger's Transaction and related data types): - {     "tcomment": "",     "tpostings": [@@ -542,10 +541,9 @@     "tstatus": "Unmarked" } -   And here's how to test adding it with curl. This should add a new+   And here's how to test adding it with curl.  This should add a new entry to your journal: - $ curl http://127.0.0.1:5000/add -X PUT -H 'Content-Type: application/json' --data-binary @txn.json  @@ -554,26 +552,25 @@ 6 ENVIRONMENT ************* -*LEDGER_FILE* The journal file path when not specified with `-f'.-Default: `~/.hledger.journal' (on windows, perhaps-`C:/Users/USER/.hledger.journal').+*LEDGER_FILE* The journal file path when not specified with '-f'.+Default: '~/.hledger.journal' (on windows, perhaps+'C:/Users/USER/.hledger.journal'). -   A typical value is `~/DIR/YYYY.journal', where DIR is a-version-controlled finance directory and YYYY is the current year. Or-`~/DIR/current.journal', where current.journal is a symbolic link to+   A typical value is '~/DIR/YYYY.journal', where DIR is a+version-controlled finance directory and YYYY is the current year.  Or+'~/DIR/current.journal', where current.journal is a symbolic link to YYYY.journal. -   On Mac computers, you can set this and other environment variables-in a more thorough way that also affects applications started from the-GUI (say, an Emacs dock icon). Eg on MacOS Catalina I have a-`~/.MacOSX/environment.plist' file containing-+   On Mac computers, you can set this and other environment variables in+a more thorough way that also affects applications started from the GUI+(say, an Emacs dock icon).  Eg on MacOS Catalina I have a+'~/.MacOSX/environment.plist' file containing  {   "LEDGER_FILE" : "~/finance/current.journal" } -   To see the effect you may need to `killall Dock', or reboot.+   To see the effect you may need to 'killall Dock', or reboot.   File: hledger-web.info,  Node: FILES,  Next: BUGS,  Prev: ENVIRONMENT,  Up: Top@@ -582,9 +579,9 @@ *******  Reads data from one or more files in hledger journal, timeclock,-timedot, or CSV format specified with `-f', or `$LEDGER_FILE', or-`$HOME/.hledger.journal' (on windows, perhaps-`C:/Users/USER/.hledger.journal').+timedot, or CSV format specified with '-f', or '$LEDGER_FILE', or+'$HOME/.hledger.journal' (on windows, perhaps+'C:/Users/USER/.hledger.journal').   File: hledger-web.info,  Node: BUGS,  Prev: FILES,  Up: Top@@ -592,10 +589,10 @@ 8 BUGS ****** -The need to precede options with `--' when invoked from hledger is+The need to precede options with '--' when invoked from hledger is awkward. -   `-f-' doesn't work (hledger-web can't read from stdin).+   '-f-' doesn't work (hledger-web can't read from stdin).     Query arguments and some hledger options are ignored. @@ -603,25 +600,24 @@     Does not work well on small screens. -  Tag Table:-Node: Top84-Node: OPTIONS1748-Ref: #options1853-Node: PERMISSIONS9104-Ref: #permissions9243-Node: EDITING UPLOADING DOWNLOADING10455-Ref: #editing-uploading-downloading10636-Node: RELOADING11467-Ref: #reloading11601-Node: JSON API12033-Ref: #json-api12147-Node: ENVIRONMENT17636-Ref: #environment17752-Node: FILES18484-Ref: #files18584-Node: BUGS18797-Ref: #bugs18875+Node: Top235+Node: OPTIONS1898+Ref: #options2003+Node: PERMISSIONS9436+Ref: #permissions9575+Node: EDITING UPLOADING DOWNLOADING10787+Ref: #editing-uploading-downloading10968+Node: RELOADING11802+Ref: #reloading11936+Node: JSON API12369+Ref: #json-api12483+Node: ENVIRONMENT17973+Ref: #environment18089+Node: FILES18822+Ref: #files18922+Node: BUGS19135+Ref: #bugs19213  End Tag Table
hledger-web.txt view
@@ -5,7 +5,7 @@  NAME        hledger-web  is  a web interface (WUI) for the hledger accounting tool.-       This manual is for hledger-web 1.21.+       This manual is for hledger-web 1.22.  SYNOPSIS        hledger-web [OPTIONS]@@ -33,22 +33,21 @@        Like hledger, it reads data from one or more files in hledger  journal,        timeclock,  timedot,  or CSV format specified with -f, or $LEDGER_FILE,        or       $HOME/.hledger.journal       (on       windows,        perhaps-       C:/Users/USER/.hledger.journal).   For  more about this see hledger(1),-       hledger_journal(5) etc.+       C:/Users/USER/.hledger.journal).  For more about this see hledger(1).  OPTIONS        Command-line options and arguments may be used to set an initial filter-       on  the data.  These filter options are not shown in the web UI, but it+       on the data.  These filter options are not shown in the web UI, but  it        will be applied in addition to any search query entered there. -       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 in the synopsis above.         --serve               serve and log requests, don't browse or auto-exit         --serve-api-              like  --serve,  but  serve  only  the  JSON web API, without the+              like --serve, but serve only  the  JSON  web  API,  without  the               server-side web UI         --host=IPADDR@@ -58,30 +57,30 @@               listen on this TCP port (default: 5000)         --socket=SOCKETFILE-              use a unix domain socket file to listen for requests instead  of-              a  TCP  socket.   Implies  --serve.   It can only be used if the+              use  a unix domain socket file to listen for requests instead of+              a TCP socket.  Implies --serve.  It can  only  be  used  if  the               operating system can provide this type of socket.         --base-url=URL-              set the  base  url  (default:  http://IPADDR:PORT).   You  would+              set  the  base  url  (default:  http://IPADDR: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.         --capabilities=CAP[,CAP..]-              enable  the  view,  add,  and/or  manage  capabilities (default:+              enable the  view,  add,  and/or  manage  capabilities  (default:               view,add)         --capabilities-header=HTTPHEADER-              read capabilities to enable from a  HTTP  header,  like  X-Sand-+              read  capabilities  to  enable  from a HTTP header, like X-Sand-               storm-Permissions (default: disabled) -       --test run  hledger-web's  tests  and exit.  hspec test runner args may+       --test run hledger-web's tests and exit.  hspec test  runner  args  may               follow a --, eg: hledger-web --test -- --help         hledger input options:@@ -91,7 +90,7 @@               $LEDGER_FILE or $HOME/.hledger.journal)         --rules-file=RULESFILE-              Conversion   rules  file  to  use  when  reading  CSV  (default:+              Conversion  rules  file  to  use  when  reading  CSV   (default:               FILE.rules)         --separator=CHAR@@ -110,16 +109,18 @@               assignments)         -s --strict-              do  extra  error  checking  (check  that all posted accounts are+              do extra error checking (check  that  all  posted  accounts  are               declared)         hledger reporting options:         -b --begin=DATE-              include postings/txns on or after this date+              include postings/txns on or after this date (will be adjusted to+              preceding subperiod start when using a report interval)         -e --end=DATE-              include postings/txns before this date+              include postings/txns before this date (will be adjusted to fol-+              lowing subperiod end when using a report interval)         -D --daily               multiperiod/multicolumn report by day@@ -137,11 +138,11 @@               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               using period expressions syntax         --date2-              match  the  secondary  date  instead (see command help for other+              match the secondary date instead (see  command  help  for  other               effects)         -U --unmarked@@ -160,39 +161,39 @@               hide/aggregate accounts or postings more than NUM levels deep         -E --empty-              show items with zero amount, normally hidden (and vice-versa  in+              show  items with zero amount, normally hidden (and vice-versa in               hledger-ui/hledger-web)         -B --cost               convert amounts to their cost/selling amount at transaction time         -V --market-              convert amounts to their market value in default valuation  com-+              convert  amounts to their market value in default valuation com-               modities         -X --exchange=COMM               convert amounts to their market value in commodity COMM         --value-              convert  amounts  to  cost  or  market value, more flexibly than+              convert amounts to cost or  market  value,  more  flexibly  than               -B/-V/-X         --infer-market-prices-              use transaction prices (recorded with @  or  @@)  as  additional+              use  transaction  prices  (recorded  with @ or @@) as additional               market prices, as if they were P directives         --auto apply automated posting rules to modify transactions.         --forecast-              generate  future  transactions  from periodic transaction rules,-              for the next 6 months or till report end date.   In  hledger-ui,+              generate future transactions from  periodic  transaction  rules,+              for  the  next 6 months or till report end date.  In hledger-ui,               also make ordinary future transactions visible.         --color=WHEN (or --colour=WHEN)-              Should  color-supporting  commands  use ANSI color codes in text-              output.  'auto' (default): whenever stdout seems to be a  color--              supporting  terminal.  'always' or 'yes': always, useful eg when-              piping output into  'less  -R'.   'never'  or  'no':  never.   A+              Should color-supporting commands use ANSI color  codes  in  text+              output.   'auto' (default): whenever stdout seems to be a color-+              supporting terminal.  'always' or 'yes': always, useful eg  when+              piping  output  into  'less  -R'.   'never'  or  'no': never.  A               NO_COLOR environment variable overrides this.         When a reporting option appears more than once in the command line, the@@ -216,54 +217,54 @@               show debug output (levels 1-9, default: 1)         A @FILE argument will be expanded to the contents of FILE, which should-       contain  one  command line option/argument per line.  (To prevent this,+       contain one command line option/argument per line.  (To  prevent  this,        insert a -- argument before.)         By default, hledger-web starts the web app in "transient mode" and also        opens it in your default web browser if possible.  In this mode the web        app will keep running for as long as you have it open in a browser win--       dow,  and will exit after two minutes of inactivity (no requests and no-       browser windows viewing it).  With --serve, it just runs  the  web  app-       without  exiting,  and logs requests to the console.  With --serve-api,-       only the JSON web api (see  below)  is  served,  with  the  usual  HTML+       dow, and will exit after two minutes of inactivity (no requests and  no+       browser  windows  viewing  it).  With --serve, it just runs the web app+       without exiting, and logs requests to the console.   With  --serve-api,+       only  the  JSON  web  api  (see  below)  is served, with the usual HTML        server-side web UI disabled. -       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+       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. -       Similarly,  use --port to set a TCP port other than 5000, eg if you are+       Similarly, use --port to set a TCP port other than 5000, eg if you  are        running multiple hledger-web instances.         Both of these options are ignored when --socket is used.  In this case,-       it  creates  an  AF_UNIX socket file at the supplied path and uses that-       for communication.  This is an  alternative  way  of  running  multiple-       hledger-web  instances  behind a reverse proxy that handles authentica--       tion for different users.  The path can be  derived  in  a  predictable+       it creates an AF_UNIX socket file at the supplied path  and  uses  that+       for  communication.   This  is  an  alternative way of running multiple+       hledger-web instances behind a reverse proxy that  handles  authentica-+       tion  for  different  users.   The path can be derived in a predictable        way, eg by using the username within the path.  As an example, nginx as-       reverse proxy can use the variable $remote_user to derive a  path  from-       the  username  used  in  a  HTTP  basic  authentication.  The following-       proxy_pass directive allows access to all  hledger-web  instances  that+       reverse  proxy  can use the variable $remote_user to derive a path from+       the username used  in  a  HTTP  basic  authentication.   The  following+       proxy_pass  directive  allows  access to all hledger-web instances that        created a socket in /tmp/hledger/:                  proxy_pass http://unix:/tmp/hledger/${remote_user}.socket; -       You  can use --base-url to change the protocol, hostname, port and path+       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+       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+       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.  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+       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 putting it behind an authenticating proxy, using eg apache or nginx@@ -273,53 +274,53 @@        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+         o manage - allows editing,  uploading  or  downloading  the  main  or            included 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+       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. -       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+       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.         (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 also serves a JSON API that  can-       be  used to get data or add new transactions.  If you want the JSON API+       In  addition to the web UI, hledger-web also serves a JSON API that can+       be used to get data or add new transactions.  If you want the JSON  API        only, you can use the --serve-api flag.  Eg:                $ hledger-web -f examples/sample.journal --serve-api@@ -336,7 +337,7 @@               /accounttransactions/ACCOUNTNAME         Eg, all account names in the journal (similar to the accounts command).-       (hledger-web's  JSON  does  not include newlines, here we use python to+       (hledger-web's JSON does not include newlines, here we  use  python  to        prettify it):                $ curl -s http://127.0.0.1:5000/accountnames | python -m json.tool@@ -377,25 +378,25 @@                                       "aprice": null,               ... -       Most of the JSON corresponds to hledger's data types;  for  details  of-       what  the fields mean, see the Hledger.Data.Json haddock docs and click-       on the various data types, eg Transaction.   And  for  a  higher  level+       Most  of  the  JSON corresponds to hledger's data types; for details of+       what the fields mean, see the Hledger.Data.Json haddock docs and  click+       on  the  various  data  types,  eg Transaction.  And for a higher level        understanding, see the journal manual.         In some cases there is outer JSON corresponding to a "Report" type.  To-       understand that, go to the Hledger.Web.Handler.MiscR haddock  and  look-       at  the  source for the appropriate handler to see what it returns.  Eg+       understand  that,  go to the Hledger.Web.Handler.MiscR haddock and look+       at the source for the appropriate handler to see what it  returns.   Eg        for  /accounttransactions  it's  getAccounttransactionsR,  returning  a-       "accountTransactionsReport  ...".   Looking  up the haddock for that we+       "accountTransactionsReport ...".  Looking up the haddock  for  that  we        can see that /accounttransactions returns an AccountTransactionsReport,-       which  consists  of a report title and a list of AccountTransactionsRe-+       which consists of a report title and a list  of  AccountTransactionsRe-        portItem (etc). -       You can add a new transaction to the journal  with  a  PUT  request  to-       /add,  if  hledger-web  was started with the add capability (enabled by+       You  can  add  a  new  transaction to the journal with a PUT request to+       /add, if hledger-web was started with the add  capability  (enabled  by        default).  The payload must be the full, exact JSON representation of a-       hledger  transaction  (partial data won't do).  You can get sample JSON-       from hledger-web's /transactions or /accounttransactions,  or  you  can+       hledger transaction (partial data won't do).  You can get  sample  JSON+       from  hledger-web's  /transactions  or /accounttransactions, or you can        export it with hledger-lib, eg like so:                .../hledger$ stack ghci hledger-lib@@ -491,23 +492,23 @@                   "tstatus": "Unmarked"               } -       And here's how to test adding it with curl.   This  should  add  a  new+       And  here's  how  to  test  adding it with curl.  This should add a new        entry to your journal:                $ curl http://127.0.0.1:5000/add -X PUT -H 'Content-Type: application/json' --data-binary @txn.json  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). -       A  typical  value  is  ~/DIR/YYYY.journal,  where DIR is a version-con--       trolled finance directory and YYYY is the current year.  Or  ~/DIR/cur-+       A typical value is ~/DIR/YYYY.journal,  where  DIR  is  a  version-con-+       trolled  finance directory and YYYY is the current year.  Or ~/DIR/cur-        rent.journal, where current.journal is a symbolic link to YYYY.journal.         On Mac computers, you can set this and other environment variables in a-       more  thorough  way that also affects applications started from the GUI-       (say,  an  Emacs  dock  icon).   Eg  on  MacOS  Catalina   I   have   a+       more thorough way that also affects applications started from  the  GUI+       (say,   an   Emacs   dock  icon).   Eg  on  MacOS  Catalina  I  have  a        ~/.MacOSX/environment.plist file containing                {@@ -517,13 +518,13 @@        To see the effect you may need to killall Dock, or reboot.  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).@@ -537,7 +538,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)  @@ -555,4 +556,4 @@   -hledger-web-1.21                 December 2020                  HLEDGER-WEB(1)+hledger-web-1.22                   July 2021                    HLEDGER-WEB(1)
static/hledger.js view
@@ -23,6 +23,12 @@       dateEl.datepicker('hide');     }); +  // ensure that the keypress listener on the final amount input is always active+  $('#addform')+    .on('focus', '.amount-input:last', function() {+      addformLastAmountBindKey();+    });+   // keyboard shortcuts   // 'body' seems to hold focus better than document in FF   $('body').bind('keydown', 'h',       function(){ $('#helpmodal').modal('toggle'); return false; });
templates/add-form.hamlet view
@@ -1,7 +1,7 @@ <script>   jQuery(document).ready(function() {     descriptionsSuggester = new Bloodhound({-      local:#{toBloodhoundJson descriptions},+      local:#{toBloodhoundJson (toList descriptions)},       limit:100,       datumTokenizer: function(d) { return [d.value]; },       queryTokenizer: function(q) { return [q]; }