web: get static files from the cabal data dir, or the current dir when using make (#13)
This commit is contained in:
parent
23e3c81acc
commit
7bd14a367a
@ -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 =
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv = "Content-Type" content = "text/html; charset=utf-8" />
|
||||
<link rel="stylesheet" type="text/css" href="/static/style.css" media="all" />
|
||||
<link rel="stylesheet" type="text/css" href="/style.css" media="all" />
|
||||
<title><% title %></title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
2
Makefile
2
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
|
||||
|
||||
9
Paths_hledger_make.hs
Normal file
9
Paths_hledger_make.hs
Normal file
@ -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
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user