diff --git a/Commands/Web.hs b/Commands/Web.hs index 576ccd651..c76ff1344 100644 --- a/Commands/Web.hs +++ b/Commands/Web.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE FlexibleContexts, FlexibleInstances, MultiParamTypeClasses #-} +{-# LANGUAGE CPP, FlexibleContexts, FlexibleInstances, MultiParamTypeClasses #-} {-# OPTIONS_GHC -F -pgmFtrhsx #-} {-| A web-based UI. @@ -23,6 +23,11 @@ import Network.Loli (loli, io, get, post, html, text, public) import Network.Loli.Type (AppUnit) import Network.Loli.Utils (update) import Options hiding (value) +#ifdef MAKE +import Paths_hledger_make (getDataFileName) +#else +import Paths_hledger (getDataFileName) +#endif import System.Directory (getModificationTime) import System.IO.Storage (withStore, putValue, getValue) import System.Process (readProcess) @@ -110,6 +115,7 @@ server :: [Opt] -> [String] -> Ledger -> IO () server opts args l = -- server initialisation withStore "hledger" $ do -- IO () + webfiles <- getDataFileName "web" putValue "hledger" "ledger" l -- XXX hack-happstack abstraction leak hostname <- readProcess "hostname" [] "" `catch` \_ -> return "hostname" @@ -136,7 +142,7 @@ server opts args l = get "/env" $ getenv >>= (text . show) get "/params" $ getenv >>= (text . show . Hack.Contrib.Request.params) get "/inputs" $ getenv >>= (text . show . Hack.Contrib.Request.inputs) - public (Just "Commands/Web") ["/static"] + public (Just webfiles) ["/style.css"] get "/" $ redirect ("transactions") Nothing ) env @@ -186,7 +192,7 @@ hledgerpage env msgs title content = - + <% title %> diff --git a/Makefile b/Makefile index 163f8d355..364bf55c0 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ DOCFILES:=README README2 MANUAL NEWS CONTRIBUTORS SCREENSHOTS BINARYFILENAME=`runhaskell ./hledger.hs --binary-filename` PATCHLEVEL:=$(shell expr `darcs changes --count --from-tag=\\\\\.` - 1) WARNINGS:=-W -fwarn-tabs #-fwarn-orphans -fwarn-simple-patterns -fwarn-monomorphism-restriction -fwarn-name-shadowing -BUILDFLAGS:=-DPATCHLEVEL=$(PATCHLEVEL) $(OPTFLAGS) $(WARNINGS) +BUILDFLAGS:=-DMAKE -DPATCHLEVEL=$(PATCHLEVEL) $(OPTFLAGS) $(WARNINGS) TIME:=$(shell date +"%Y%m%d%H%M") default: tag hledger diff --git a/Paths_hledger_make.hs b/Paths_hledger_make.hs new file mode 100644 index 000000000..c7dff3bf7 --- /dev/null +++ b/Paths_hledger_make.hs @@ -0,0 +1,9 @@ +-- dummy Paths_hledger for use when building with make +-- cabal build generates a more useful one + +module Paths_hledger_make +where + +import System.FilePath.Posix (()) + +getDataFileName path = return $ "data" path diff --git a/Commands/Web/static/style.css b/data/web/style.css similarity index 100% rename from Commands/Web/static/style.css rename to data/web/style.css diff --git a/hledger.cabal b/hledger.cabal index 89e4fd333..8794316c0 100644 --- a/hledger.cabal +++ b/hledger.cabal @@ -22,7 +22,9 @@ stability: experimental tested-with: GHC==6.8, GHC==6.10 cabal-version: >= 1.2 build-type: Custom - +data-dir: data +data-files: + web/style.css extra-tmp-files: extra-source-files: README @@ -97,6 +99,7 @@ executable hledger Ledger.Types Ledger.Utils Options + Paths_hledger Tests Utils Version