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} ^{accountsheading}
<table.balancereport> <table.balancereport>
$forall i <- items $forall i <- items
^{itemAsHtml' i} ^{itemAsHtml vd i}
<tr.totalrule> <tr.totalrule>
<td colspan=2> <td colspan=2>
<tr> <tr>

View File

@ -1,5 +1,5 @@
<tr.item <tr.item
<td.account <td.account
#{indent} #{indent}
<a href="@{here}?a=#{acctpat}#{pparam}">#{adisplay} <a href="@{here}?a=#{acctpat}#{pparam}">#{adisplay}
<td.balance align=right>#{mixedAmountAsHtml abal} <td.balance align=right>#{mixedAmountAsHtml abal}

View File

@ -1,21 +1,21 @@
<form#editform method=POST style=display:none; <form#editform method=POST style=display:none;
<table.form#editform <table.form#editform
$if manyfiles $if manyfiles
<tr
<td colspan=2
Editing ^{journalselect $ files j}
<tr <tr
<td colspan=2 <td colspan=2
<!-- XXX textarea ids are unquoted journal file paths here, not valid html --> Editing ^{journalselect $ files j}
$forall f <- files j <tr
<textarea id=#{fst f}_textarea name=text rows=25 cols=80 style=display:none; disabled=disabled <td colspan=2
#{snd f} <!-- XXX textarea ids are unquoted journal file paths here, not valid html -->
<tr#addbuttonrow $forall f <- files j
<td <textarea id=#{fst f}_textarea name=text rows=25 cols=80 style=display:none; disabled=disabled
<span.help>^{formathelp} #{snd f}
<td align=right <tr#addbuttonrow
<span.help Are you sure ? This will overwrite the journal. # <td
<input type=hidden name=action value=edit <span.help>^{formathelp}
<input type=submit name=submit value="save journal" <td align=right
\ or # <span.help Are you sure ? This will overwrite the journal. #
<a href onclick="return editformToggle(event)">cancel <input type=hidden name=action value=edit
<input type=submit name=submit value="save journal"
\ or #
<a href onclick="return editformToggle(event)">cancel

View File

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

View File

@ -1,25 +1,25 @@
<div#filterformdiv <div#filterformdiv
<form#filterform.form method=GET style=display:#{visible}; <form#filterform.form method=GET style=display:#{visible};
<table.form <table.form
<tr.#{filteringperiodclass} <tr.#{filteringperiodclass}
<td <td
filter by period: filter by period:
\ # \ #
<td <td
<input name=p size=60 value=#{p} <input name=p size=60 value=#{p}
^{phelp} ^{phelp}
\ # \ #
<td align=right <td align=right
^{stopfilteringperiod} ^{stopfilteringperiod}
<tr.#{filteringclass} <tr.#{filteringclass}
<td <td
filter by account/description: filter by account/description:
\ # \ #
<td <td
<input name=a size=60 value=#{a} <input name=a size=60 value=#{a}
^{ahelp} ^{ahelp}
\ # \ #
<input type=submit value=filter # <input type=submit value=filter #
\ # \ #
<td align=right <td align=right
^{stopfiltering} ^{stopfiltering}

View File

@ -1,9 +1,9 @@
<form#importform method=POST style=display:none; <form#importform method=POST style=display:none;
<table.form <table.form
<tr <tr
<td <td
<input type=file name=file <input type=file name=file
<input type=hidden name=action value=import <input type=hidden name=action value=import
<input type=submit name=submit value="import from file" <input type=submit name=submit value="import from file"
\ or # \ or #
<a href onclick="return importformToggle(event)" cancel <a href onclick="return importformToggle(event)" cancel

View File

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

View File

@ -1,3 +1,3 @@
<tr.item.#{evenodd} > <tr.item.#{evenodd}>
<td.transaction> <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 $forall f <- journalfiles
<option value=#{fst f}>#{fst f} <option value=#{fst f}>#{fst f}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -16,10 +16,10 @@ module Settings
, widgetFile , widgetFile
, datadir , datadir
, staticdir , staticdir
-- , staticroot
, defhost , defhost
, defport , defport
, defapproot , defapproot
-- , staticroot
-- , browserstartdelay -- , browserstartdelay
, hledgerorgurl , hledgerorgurl
, manualurl , manualurl
@ -65,27 +65,27 @@ defapproot = pack $ printf "http://%s:%d" defhost defport
datadir :: FilePath datadir :: FilePath
datadir = "./.hledger/web/" 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 -- | The location of static files on your system. This is a file system
-- path. The default value works properly with your scaffolded site. -- path. The default value works properly with your scaffolded site.
staticdir :: FilePath staticdir :: FilePath
staticdir = datadir++"static" 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 -- The rest of this file contains settings which rarely need changing by a

View File

@ -43,7 +43,6 @@ Flag devel
executable hledger-web executable hledger-web
main-is: hledger-web.hs main-is: hledger-web.hs
-- hs-source-dirs: ., config
if flag(devel) if flag(devel)
Buildable: False Buildable: False
if flag(production) if flag(production)
@ -109,33 +108,3 @@ library
Settings Settings
StaticFiles StaticFiles
Handlers 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

View File

@ -1,4 +1,4 @@
/static StaticR Static getStatic /static StaticR Static getStatic
/favicon.ico FaviconR GET /favicon.ico FaviconR GET
/robots.txt RobotsR GET /robots.txt RobotsR GET
/ RootR GET / RootR GET