dev:web:docs

This commit is contained in:
Simon Michael 2023-12-15 13:06:43 -10:00
parent e81430f05b
commit 14a9ab5f28
4 changed files with 30 additions and 15 deletions

View File

@ -1,3 +1,9 @@
{-|
Most of the definition of the web app is here.
In the usual Yesod style, this defines the web app's core types and configuration,
and then Application.hs completes the job.
-}
{-# OPTIONS_GHC -fno-warn-orphans #-} {-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE CPP #-} {-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FlexibleInstances #-}
@ -77,15 +83,18 @@ data App = App
-- resources declared below. This is used in Handler.hs by the call to -- resources declared below. This is used in Handler.hs by the call to
-- mkYesodDispatch -- mkYesodDispatch
-- --
-- What this function does *not* do is create a YesodSite instance for -- What this function does *not* do is create a YesodSite instance for App.
-- App. Creating that instance requires all of the handler functions -- AppCreating that instance requires all of the handler functions
-- for our application to be in scope. However, the handler functions -- for our application to be in scope. However, the handler functions
-- usually require access to the AppRoute datatype. Therefore, we -- usually require access to the AppRoute datatype. Therefore, we
-- split these actions into two functions and place them in separate files. -- split these actions into two functions and place the other in a
-- separate file (Application.hs).
-- mkYesodData defines things like:
--
-- * type Handler = HandlerFor App -- HandlerT App IO, https://www.yesodweb.com/book/routing-and-handlers#routing-and-handlers_handler_monad
-- * type Widget = WidgetFor App () -- WidgetT App IO (), https://www.yesodweb.com/book/widgets
--
mkYesodData "App" $(parseRoutesFile "config/routes") mkYesodData "App" $(parseRoutesFile "config/routes")
-- ^ defines things like:
-- type Handler = HandlerFor App -- HandlerT App IO, https://www.yesodweb.com/book/routing-and-handlers#routing-and-handlers_handler_monad
-- type Widget = WidgetFor App () -- WidgetT App IO (), https://www.yesodweb.com/book/widgets
type AppRoute = Route App type AppRoute = Route App
type Form a = Html -> MForm Handler (FormResult a, Widget) type Form a = Html -> MForm Handler (FormResult a, Widget)
@ -193,7 +202,7 @@ instance RenderMessage App FormMessage where
data ViewData = VD data ViewData = VD
{ opts :: WebOpts -- ^ the command-line options at startup { opts :: WebOpts -- ^ the command-line options at startup
, today :: Day -- ^ today's date (for queries containing relative dates) , today :: Day -- ^ today's date (for queries containing relative dates)
, j :: Journal -- ^ the up-to-date parsed unfiltered journal , j :: Journal -- ^ the up-to-date parsed unfiltered journal -- XXX rename
, qparam :: Text -- ^ the current "q" request parameter , qparam :: Text -- ^ the current "q" request parameter
, q :: Query -- ^ a query parsed from the q parameter , q :: Query -- ^ a query parsed from the q parameter
, qopts :: [QueryOpt] -- ^ query options parsed from the q parameter , qopts :: [QueryOpt] -- ^ query options parsed from the q parameter

View File

@ -1,3 +1,8 @@
{-|
Complete the definition of the web app begun in App.hs.
This is always done in two files for (TH?) reasons.
-}
{-# OPTIONS_GHC -fno-warn-orphans #-} {-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TemplateHaskell #-}

View File

@ -1,9 +1,8 @@
{-| {-|
hledger-web - a basic but robust web UI and JSON API server for hledger.
hledger-web - a hledger add-on providing a web interface. Copyright (c) 2007-2023 Simon Michael <simon@joyful.com> and contributors.
Copyright (c) 2007-2020 Simon Michael <simon@joyful.com>
Released under GPL version 3 or later. Released under GPL version 3 or later.
-} -}
{-# LANGUAGE MultiWayIf #-} {-# LANGUAGE MultiWayIf #-}

View File

@ -1,11 +1,13 @@
{-|
Web app 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
by overriding methods in the Yesod typeclass in App.hs.
-}
{-# LANGUAGE CPP #-} {-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
-- | 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
-- by overriding methods in the Yesod typeclass. That instance is
-- declared in the Foundation.hs file.
module Hledger.Web.Settings where module Hledger.Web.Settings where
import Data.Default (def) import Data.Default (def)