diff options
author | Joey Hess <joey@kitenet.net> | 2012-07-31 14:23:17 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-07-31 16:13:09 -0400 |
commit | c70496dc7f89f07e05bea0257b7d93986dd61d89 (patch) | |
tree | 767eb09e1e3531e8f1f44b5d02764b7fb1ca00a6 /Assistant/WebApp.hs | |
parent | 0d3686972d9b08b061f86b3e38fb681becf1c833 (diff) |
improve first run screen
Diffstat (limited to 'Assistant/WebApp.hs')
-rw-r--r-- | Assistant/WebApp.hs | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/Assistant/WebApp.hs b/Assistant/WebApp.hs index 2a1fcb6b4..3351aa48f 100644 --- a/Assistant/WebApp.hs +++ b/Assistant/WebApp.hs @@ -52,25 +52,34 @@ navBarRoute DashBoard = HomeR navBarRoute Config = ConfigR navBarRoute About = AboutR -navBar :: Maybe NavBarItem -> [(Text, Route WebApp, Bool)] -navBar r = map details [DashBoard, Config, About] - where - details i = (navBarName i, navBarRoute i, Just i == r) +defaultNavBar :: [NavBarItem] +defaultNavBar = [DashBoard, Config, About] + +firstRunNavBar :: [NavBarItem] +firstRunNavBar = [Config, About] + +selectNavBar :: Handler [NavBarItem] +selectNavBar = ifM (inFirstRun) (return firstRunNavBar, return defaultNavBar) + +inFirstRun :: Handler Bool +inFirstRun = isNothing . threadState <$> getYesod {- Used instead of defaultContent; highlights the current page if it's - on the navbar. -} bootstrap :: Maybe NavBarItem -> Widget -> Handler RepHtml bootstrap navbaritem content = do webapp <- getYesod + navbar <- map navdetails <$> selectNavBar page <- widgetToPageContent $ do addStylesheet $ StaticR css_bootstrap_css addStylesheet $ StaticR css_bootstrap_responsive_css addScript $ StaticR jquery_full_js addScript $ StaticR js_bootstrap_dropdown_js addScript $ StaticR js_bootstrap_modal_js - let navbar = navBar navbaritem $(widgetFile "page") hamletToRepHtml $(hamletFile $ hamletTemplate "bootstrap") + where + navdetails i = (navBarName i, navBarRoute i, Just i == navbaritem) instance Yesod WebApp where {- Require an auth token be set when accessing any (non-static route) -} |