web: fix compilation; also fixes some hardcoded static urls (Xinruo Sun)

This commit is contained in:
Simon Michael 2013-01-11 13:54:49 +00:00
parent ab53dd0813
commit 67d1f91909
7 changed files with 14 additions and 11 deletions

View File

@ -58,7 +58,7 @@ strip = lstrip . rstrip
lstrip = dropWhile (`elem` " \t") :: String -> String lstrip = dropWhile (`elem` " \t") :: String -> String
rstrip = reverse . lstrip . reverse rstrip = reverse . lstrip . reverse
stripbrackets = dropWhile (`elem` "([") . reverse . dropWhile (`elem` "])") . reverse stripbrackets = dropWhile (`elem` "([") . reverse . dropWhile (`elem` "])") . reverse :: String -> String
elideLeft width s = elideLeft width s =
if length s > width then ".." ++ reverse (take (width - 2) $ reverse s) else s if length s > width then ".." ++ reverse (take (width - 2) $ reverse s) else s

View File

@ -102,10 +102,10 @@ instance Yesod App where
$(widgetFile "normalize") $(widgetFile "normalize")
addStylesheet $ StaticR css_bootstrap_css addStylesheet $ StaticR css_bootstrap_css
-- load jquery early: -- load jquery early:
toWidgetHead [hamlet| <script type="text/javascript" src="/static/jquery.js"></script> |] toWidgetHead [hamlet| <script type="text/javascript" src="@{StaticR jquery_js}"></script> |]
addScript $ StaticR jquery_url_js addScript $ StaticR jquery_url_js
addScript $ StaticR jquery_flot_js addScript $ StaticR jquery_flot_js
toWidget [hamlet| \<!--[if lte IE 8]> <script type="text/javascript" src="excanvas.min.js"></script> <![endif]--> |] toWidget [hamlet| \<!--[if lte IE 8]> <script type="text/javascript" src="@{StaticR excanvas_min_js}"></script> <![endif]--> |]
addScript $ StaticR dhtmlxcommon_js addScript $ StaticR dhtmlxcommon_js
addScript $ StaticR dhtmlxcombo_js addScript $ StaticR dhtmlxcombo_js
addStylesheet $ StaticR style_css addStylesheet $ StaticR style_css

View File

@ -109,12 +109,12 @@ searchform VD{..} = [hamlet|
filtering = not $ null q filtering = not $ null q
-- | Add transaction form. -- | Add transaction form.
addform :: ViewData -> HtmlUrl AppRoute addform :: Text -> ViewData -> HtmlUrl AppRoute
addform vd@VD{..} = [hamlet| addform staticRootUrl vd@VD{..} = [hamlet|
<script type=text/javascript> <script type=text/javascript>
\$(document).ready(function() { \$(document).ready(function() {
/* dhtmlxcombo setup */ /* dhtmlxcombo setup */
window.dhx_globalImgPath="../static/"; window.dhx_globalImgPath="#{staticRootUrl}/";
var desccombo = new dhtmlXCombo("description"); var desccombo = new dhtmlXCombo("description");
var acct1combo = new dhtmlXCombo("account1"); var acct1combo = new dhtmlXCombo("account1");
var acct2combo = new dhtmlXCombo("account2"); var acct2combo = new dhtmlXCombo("account2");

View File

@ -19,6 +19,7 @@ import Hledger.Web.Options
getJournalEntriesR :: Handler RepHtml getJournalEntriesR :: Handler RepHtml
getJournalEntriesR = do getJournalEntriesR = do
vd@VD{..} <- getViewData vd@VD{..} <- getViewData
staticRootUrl <- (staticRoot . settings) <$> getYesod
let let
sidecontent = sidebar vd sidecontent = sidebar vd
title = "Journal entries" ++ if m /= Any then ", filtered" else "" :: String title = "Journal entries" ++ if m /= Any then ", filtered" else "" :: String
@ -35,7 +36,7 @@ getJournalEntriesR = do
<h2#contenttitle>#{title} <h2#contenttitle>#{title}
^{searchform vd} ^{searchform vd}
^{maincontent} ^{maincontent}
^{addform vd} ^{addform staticRootUrl vd}
^{editform vd} ^{editform vd}
^{importform} ^{importform}
|] |]

View File

@ -17,6 +17,7 @@ import Hledger.Web.Options
getJournalR :: Handler RepHtml getJournalR :: Handler RepHtml
getJournalR = do getJournalR = do
vd@VD{..} <- getViewData vd@VD{..} <- getViewData
staticRootUrl <- (staticRoot . settings) <$> getYesod
let sidecontent = sidebar vd let sidecontent = sidebar vd
-- XXX like registerReportAsHtml -- XXX like registerReportAsHtml
inacct = inAccount qopts inacct = inAccount qopts
@ -42,7 +43,7 @@ getJournalR = do
<h2#contenttitle>#{title} <h2#contenttitle>#{title}
^{searchform vd} ^{searchform vd}
^{maincontent} ^{maincontent}
^{addform vd} ^{addform staticRootUrl vd}
^{editform vd} ^{editform vd}
^{importform} ^{importform}
|] |]

View File

@ -67,8 +67,8 @@ handleAdd = do
tdate=parsedate date tdate=parsedate date
,tdescription=desc ,tdescription=desc
,tpostings=[ ,tpostings=[
Posting False acct1 (mixed amt1) "" RegularPosting [] Nothing Posting Nothing Nothing False acct1 (mixed amt1) "" RegularPosting [] Nothing
,Posting False acct2 (mixed amt2) "" RegularPosting [] Nothing ,Posting Nothing Nothing False acct2 (mixed amt2) "" RegularPosting [] Nothing
] ]
}) })
-- display errors or add transaction -- display errors or add transaction

View File

@ -19,6 +19,7 @@ import Hledger.Web.Options
getRegisterR :: Handler RepHtml getRegisterR :: Handler RepHtml
getRegisterR = do getRegisterR = do
vd@VD{..} <- getViewData vd@VD{..} <- getViewData
staticRootUrl <- (staticRoot . settings) <$> getYesod
let sidecontent = sidebar vd let sidecontent = sidebar vd
-- injournal = isNothing inacct -- injournal = isNothing inacct
filtering = m /= Any filtering = m /= Any
@ -40,7 +41,7 @@ getRegisterR = do
<h2#contenttitle>#{title} <h2#contenttitle>#{title}
^{searchform vd} ^{searchform vd}
^{maincontent} ^{maincontent}
^{addform vd} ^{addform staticRootUrl vd}
^{editform vd} ^{editform vd}
^{importform} ^{importform}
|] |]