web: cleanup

This commit is contained in:
Simon Michael 2011-05-27 06:13:05 +00:00
parent b5c39dfa8f
commit f2ac47b567
20 changed files with 137 additions and 181 deletions

View File

@ -1,7 +1,7 @@
^{accountsheading}
<table.balancereport>
$forall i <- items
^{itemAsHtml' i}
^{itemAsHtml vd i}
<tr.totalrule>
<td colspan=2>
<tr>

View File

@ -1,4 +1,4 @@
<tr.item
<tr.item
<td.account
#{indent}
<a href="@{here}?a=#{acctpat}#{pparam}">#{adisplay}

View File

@ -1,4 +1,4 @@
<form#editform method=POST style=display:none;
<form#editform method=POST style=display:none;
<table.form#editform
$if manyfiles
<tr

View File

@ -1,4 +1,4 @@
<a#addformlink href onclick="return addformToggle(event)">add transaction
<a#importformlink href onclick="return importformToggle(event)" style="display:none;">import transactions
\ | #
<a#editformlink href onclick="return editformToggle(event)">edit journal
<a#addformlink href onclick="return addformToggle(event)">add transaction
<a#importformlink href onclick="return importformToggle(event)" style="display:none;">import transactions
\ | #
<a#editformlink href onclick="return editformToggle(event)">edit journal

View File

@ -1,4 +1,4 @@
<div#filterformdiv
<div#filterformdiv
<form#filterform.form method=GET style=display:#{visible};
<table.form
<tr.#{filteringperiodclass}

View File

@ -1,4 +1,4 @@
<form#importform method=POST style=display:none;
<form#importform method=POST style=display:none;
<table.form
<tr
<td

View File

@ -1,3 +1,3 @@
<table.journalreport>
$forall i <- number items
^{itemAsHtml' i}
$forall i <- numbered items
^{itemAsHtml vd i}

View File

@ -1,3 +1,3 @@
<tr.item.#{evenodd} >
<tr.item.#{evenodd}>
<td.transaction>
<pre> #{txn}
<pre>#{txn}

View File

@ -1,3 +1,3 @@
<select id=journalselect name=journal onchange="editformJournalSelect(event)"
<select id=journalselect name=journal onchange="editformJournalSelect(event)"
$forall f <- journalfiles
<option value=#{fst f}>#{fst f}

View File

@ -1,4 +1,4 @@
<div#navlinks
<div#navlinks
^{accountsjournallink}
\ | #
^{accountsregisterlink}

View File

@ -1,4 +1,4 @@
<tr#postingrow
<tr#postingrow
<td align=right>#{acctlabel}:
<td
<select id=#{acctvar} name=#{acctvar}
@ -6,7 +6,7 @@
$forall a <- acctnames
<option value=#{a}>#{a}
^{amtfield}
<tr.helprow
<tr.helprow
<td
<td
<span.help>#{accthelp}

View File

@ -1,4 +1,4 @@
<td style=padding-left:1em;
<td style=padding-left:1em;
Amount:
<td
<td
<input.textinput size=15 name=#{amtvar} value=""

View File

@ -5,5 +5,5 @@
<th.account align=left Account
<th.amount align=right Amount
<th.balance align=right Balance
$forall i <- number items
^{itemAsHtml' i}
$forall i <- numbered items
^{itemAsHtml vd i}

View File

@ -1,7 +1,6 @@
<tr.item.#{evenodd}.#{firstposting}
<tr.item.#{evenodd}.#{firstposting}
<td.date>#{date}
<td.description>#{desc}
<td.account
<a href="@{here}?a=#{acctpat}#{pparam}">#{acct}
<td.account><a href="@{here}?a=#{acctpat}#{pparam}">#{acct}
<td.amount align=right>#{mixedAmountAsHtml $ pamount posting}
<td.balance align=right>#{mixedAmountAsHtml b}

View File

@ -81,8 +81,8 @@ instance Yesod App where
addCassius $(Settings.cassiusFile "default-layout")
hamletToRepHtml $(Settings.hamletFile "default-layout")
-- This is done to provide an optimization for serving static files from
-- a separate domain. Please see the staticroot setting in Settings.hs
-- -- This is done to provide an optimization for serving static files from
-- -- a separate domain. Please see the staticroot setting in Settings.hs
-- urlRenderOverride a (StaticR s) =
-- Just $ uncurry (joinPath a Settings.staticroot) $ renderRoute s
-- urlRenderOverride _ _ = Nothing

View File

@ -2,24 +2,22 @@
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module AppRun
( withApp
, withDevelApp
) where
module AppRun (
withApp
,withDevelApp
)
where
import App
import Settings
import Yesod.Helpers.Static
-- import Data.ByteString (ByteString)
import Network.Wai (Application)
import Data.Dynamic (Dynamic, toDyn)
-- import System.FilePath ((</>))
-- Import all relevant handler modules here.
import Handlers
import Network.Wai (Application)
import Yesod.Helpers.Static
import Hledger.Data (nulljournal)
import App
import Handlers
import Settings
-- This line actually creates our YesodSite instance. It is the second half
-- of the call to mkYesodData which occurs in App.hs. Please see
-- the comments there for more details.
@ -30,13 +28,9 @@ mkYesodDispatch "App" resourcesApp
-- place to put your migrate statements to have automatic database
-- migrations handled by Yesod.
withApp :: App -> (Application -> IO a) -> IO a
withApp a f = do
toWaiApp a >>= f
-- where
-- s = static Settings.staticdir
withApp a f = toWaiApp a >>= f
withDevelApp :: Dynamic
-- withDevelApp = undefined
withDevelApp = toDyn (withApp a :: (Application -> IO ()) -> IO ())
where a = App{
getStatic=static Settings.staticdir
@ -45,4 +39,3 @@ withDevelApp = toDyn (withApp a :: (Application -> IO ()) -> IO ())
,appArgs=[]
,appJournal=nulljournal
}

View File

@ -57,7 +57,6 @@ getJournalR = do
vd@VD{opts=opts,fspec=fspec,j=j} <- getViewData
let sidecontent = balanceReportAsHtml opts vd $ balanceReport opts fspec j
maincontent = journalReportAsHtml opts vd $ journalReport opts fspec j
editform' = editform vd
defaultLayout $ do
setTitle "hledger-web journal"
addHamlet $(Settings.hamletFile "journal")
@ -115,7 +114,6 @@ getAccountsOnlyR = do
balanceReportAsHtml :: [Opt] -> ViewData -> BalanceReport -> Hamlet AppRoute
balanceReportAsHtml _ vd@VD{here=here,a=a,p=p} (items,total) = $(Settings.hamletFile "balancereport")
where
itemAsHtml' = itemAsHtml vd
itemAsHtml :: ViewData -> BalanceReportItem -> Hamlet AppRoute
itemAsHtml VD{p=p} (acct, adisplay, adepth, abal) = $(Settings.hamletFile "balancereportitem")
where
@ -143,8 +141,6 @@ balanceReportAsHtml _ vd@VD{here=here,a=a,p=p} (items,total) = $(Settings.hamlet
journalReportAsHtml :: [Opt] -> ViewData -> JournalReport -> Hamlet AppRoute
journalReportAsHtml _ vd items = $(Settings.hamletFile "journalreport")
where
number = zip [1..]
itemAsHtml' = itemAsHtml vd
itemAsHtml :: ViewData -> (Int, JournalReportItem) -> Hamlet AppRoute
itemAsHtml _ (n, t) = $(Settings.hamletFile "journalreportitem")
where
@ -155,8 +151,6 @@ journalReportAsHtml _ vd items = $(Settings.hamletFile "journalreport")
registerReportAsHtml :: [Opt] -> ViewData -> RegisterReport -> Hamlet AppRoute
registerReportAsHtml _ vd items = $(Settings.hamletFile "registerreport")
where
number = zip [1..]
itemAsHtml' = itemAsHtml vd
itemAsHtml :: ViewData -> (Int, RegisterReportItem) -> Hamlet AppRoute
itemAsHtml VD{here=here,p=p} (n, (ds, posting, b)) = $(Settings.hamletFile "registerreportitem")
where
@ -494,3 +488,4 @@ words' = fromparse . parsewith ((quotedPattern <|> pattern) `sepBy` many1 spacen
pattern = many (noneOf " \n\r\"")
quotedPattern = between (oneOf "'\"") (oneOf "'\"") $ many $ noneOf "'\""
numbered = zip [1..]

View File

@ -16,10 +16,10 @@ module Settings
, widgetFile
, datadir
, staticdir
-- , staticroot
, defhost
, defport
, defapproot
-- , staticroot
-- , browserstartdelay
, hledgerorgurl
, manualurl
@ -65,27 +65,27 @@ defapproot = pack $ printf "http://%s:%d" defhost defport
datadir :: FilePath
datadir = "./.hledger/web/"
-- -- | The base URL for your static files. As you can see by the default
-- -- value, this can simply be "static" appended to your application root.
-- -- A powerful optimization can be serving static files from a separate
-- -- domain name. This allows you to use a web server optimized for static
-- -- files, more easily set expires and cache values, and avoid possibly
-- -- costly transference of cookies on static files. For more information,
-- -- please see:
-- -- http://code.google.com/speed/page-speed/docs/request.html#ServeFromCookielessDomain
-- --
-- -- If you change the resource pattern for StaticR in hledger-web.hs, you will
-- -- have to make a corresponding change here.
-- --
-- -- To see how this value is used, see urlRenderOverride in hledger-web.hs
-- staticroot :: Text
-- staticroot = defapproot `mappend` "/static"
-- | The location of static files on your system. This is a file system
-- path. The default value works properly with your scaffolded site.
staticdir :: FilePath
staticdir = datadir++"static"
-- | The base URL for your static files. As you can see by the default
-- value, this can simply be "static" appended to your application root.
-- A powerful optimization can be serving static files from a separate
-- domain name. This allows you to use a web server optimized for static
-- files, more easily set expires and cache values, and avoid possibly
-- costly transference of cookies on static files. For more information,
-- please see:
-- http://code.google.com/speed/page-speed/docs/request.html#ServeFromCookielessDomain
--
-- If you change the resource pattern for StaticR in hledger-web.hs, you will
-- have to make a corresponding change here.
--
-- To see how this value is used, see urlRenderOverride in hledger-web.hs
-- staticroot :: Text
-- staticroot = defapproot `mappend` "/static"
-- The rest of this file contains settings which rarely need changing by a

View File

@ -43,7 +43,6 @@ Flag devel
executable hledger-web
main-is: hledger-web.hs
-- hs-source-dirs: ., config
if flag(devel)
Buildable: False
if flag(production)
@ -109,33 +108,3 @@ library
Settings
StaticFiles
Handlers
-- executable hledger-web
-- if flag(devel)
-- Buildable: False
-- if flag(production)
-- cpp-options: -DPRODUCTION
-- ghc-options: -Wall -threaded -O2
-- else
-- ghc-options: -Wall -threaded
-- main-is: config/hledger-web.hs
-- hs-source-dirs: ., config
-- build-depends: base >= 4 && < 5
-- , yesod-core >= 0.8 && < 0.9
-- , yesod-static
-- , wai-extra
-- , directory
-- , bytestring
-- , text
-- , template-haskell
-- , hamlet
-- , web-routes
-- , transformers
-- , wai
-- , warp
-- , blaze-builder