web: fix compilation; also fixes some hardcoded static urls (Xinruo Sun)
This commit is contained in:
		
							parent
							
								
									ab53dd0813
								
							
						
					
					
						commit
						67d1f91909
					
				| @ -58,7 +58,7 @@ strip = lstrip . rstrip | ||||
| lstrip = dropWhile (`elem` " \t") :: String -> String | ||||
| rstrip = reverse . lstrip . reverse | ||||
| 
 | ||||
| stripbrackets = dropWhile (`elem` "([") . reverse . dropWhile (`elem` "])") . reverse | ||||
| stripbrackets = dropWhile (`elem` "([") . reverse . dropWhile (`elem` "])") . reverse :: String -> String | ||||
| 
 | ||||
| elideLeft width s = | ||||
|     if length s > width then ".." ++ reverse (take (width - 2) $ reverse s) else s | ||||
|  | ||||
| @ -102,10 +102,10 @@ instance Yesod App where | ||||
|             $(widgetFile "normalize") | ||||
|             addStylesheet $ StaticR css_bootstrap_css | ||||
|             -- 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_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 dhtmlxcombo_js | ||||
|             addStylesheet $ StaticR style_css | ||||
|  | ||||
| @ -109,12 +109,12 @@ searchform VD{..} = [hamlet| | ||||
|   filtering = not $ null q | ||||
| 
 | ||||
| -- | Add transaction form. | ||||
| addform :: ViewData -> HtmlUrl AppRoute | ||||
| addform vd@VD{..} = [hamlet| | ||||
| addform :: Text -> ViewData -> HtmlUrl AppRoute | ||||
| addform staticRootUrl vd@VD{..} = [hamlet| | ||||
| <script type=text/javascript> | ||||
|  \$(document).ready(function() { | ||||
|     /* dhtmlxcombo setup */ | ||||
|     window.dhx_globalImgPath="../static/"; | ||||
|     window.dhx_globalImgPath="#{staticRootUrl}/"; | ||||
|     var desccombo  = new dhtmlXCombo("description"); | ||||
|     var acct1combo = new dhtmlXCombo("account1"); | ||||
|     var acct2combo = new dhtmlXCombo("account2"); | ||||
|  | ||||
| @ -19,6 +19,7 @@ import Hledger.Web.Options | ||||
| getJournalEntriesR :: Handler RepHtml | ||||
| getJournalEntriesR = do | ||||
|   vd@VD{..} <- getViewData | ||||
|   staticRootUrl <- (staticRoot . settings) <$> getYesod | ||||
|   let | ||||
|       sidecontent = sidebar vd | ||||
|       title = "Journal entries" ++ if m /= Any then ", filtered" else "" :: String | ||||
| @ -35,7 +36,7 @@ getJournalEntriesR = do | ||||
|    <h2#contenttitle>#{title} | ||||
|    ^{searchform vd} | ||||
|    ^{maincontent} | ||||
|   ^{addform vd} | ||||
|   ^{addform staticRootUrl vd} | ||||
|   ^{editform vd} | ||||
|   ^{importform} | ||||
| |] | ||||
|  | ||||
| @ -17,6 +17,7 @@ import Hledger.Web.Options | ||||
| getJournalR :: Handler RepHtml | ||||
| getJournalR = do | ||||
|   vd@VD{..} <- getViewData | ||||
|   staticRootUrl <- (staticRoot . settings) <$> getYesod | ||||
|   let sidecontent = sidebar vd | ||||
|       -- XXX like registerReportAsHtml | ||||
|       inacct = inAccount qopts | ||||
| @ -42,7 +43,7 @@ getJournalR = do | ||||
|    <h2#contenttitle>#{title} | ||||
|    ^{searchform vd} | ||||
|    ^{maincontent} | ||||
|   ^{addform vd} | ||||
|   ^{addform staticRootUrl vd} | ||||
|   ^{editform vd} | ||||
|   ^{importform} | ||||
| |] | ||||
|  | ||||
| @ -67,8 +67,8 @@ handleAdd = do | ||||
|                            tdate=parsedate date | ||||
|                           ,tdescription=desc | ||||
|                           ,tpostings=[ | ||||
|                             Posting False acct1 (mixed amt1) "" RegularPosting [] Nothing | ||||
|                            ,Posting False acct2 (mixed amt2) "" RegularPosting [] Nothing | ||||
|                             Posting Nothing Nothing False acct1 (mixed amt1) "" RegularPosting [] Nothing | ||||
|                            ,Posting Nothing Nothing False acct2 (mixed amt2) "" RegularPosting [] Nothing | ||||
|                            ] | ||||
|                           }) | ||||
|   -- display errors or add transaction | ||||
|  | ||||
| @ -19,6 +19,7 @@ import Hledger.Web.Options | ||||
| getRegisterR :: Handler RepHtml | ||||
| getRegisterR = do | ||||
|   vd@VD{..} <- getViewData | ||||
|   staticRootUrl <- (staticRoot . settings) <$> getYesod | ||||
|   let sidecontent = sidebar vd | ||||
|       -- injournal = isNothing inacct | ||||
|       filtering = m /= Any | ||||
| @ -40,7 +41,7 @@ getRegisterR = do | ||||
|    <h2#contenttitle>#{title} | ||||
|    ^{searchform vd} | ||||
|    ^{maincontent} | ||||
|   ^{addform vd} | ||||
|   ^{addform staticRootUrl vd} | ||||
|   ^{editform vd} | ||||
|   ^{importform} | ||||
| |] | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user