improve first run screen

This commit is contained in:
Joey Hess 2012-07-31 14:23:17 -04:00
parent 0d3686972d
commit c70496dc7f
5 changed files with 46 additions and 22 deletions

View file

@ -52,25 +52,34 @@ navBarRoute DashBoard = HomeR
navBarRoute Config = ConfigR navBarRoute Config = ConfigR
navBarRoute About = AboutR navBarRoute About = AboutR
navBar :: Maybe NavBarItem -> [(Text, Route WebApp, Bool)] defaultNavBar :: [NavBarItem]
navBar r = map details [DashBoard, Config, About] defaultNavBar = [DashBoard, Config, About]
where
details i = (navBarName i, navBarRoute i, Just i == r) 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 {- Used instead of defaultContent; highlights the current page if it's
- on the navbar. -} - on the navbar. -}
bootstrap :: Maybe NavBarItem -> Widget -> Handler RepHtml bootstrap :: Maybe NavBarItem -> Widget -> Handler RepHtml
bootstrap navbaritem content = do bootstrap navbaritem content = do
webapp <- getYesod webapp <- getYesod
navbar <- map navdetails <$> selectNavBar
page <- widgetToPageContent $ do page <- widgetToPageContent $ do
addStylesheet $ StaticR css_bootstrap_css addStylesheet $ StaticR css_bootstrap_css
addStylesheet $ StaticR css_bootstrap_responsive_css addStylesheet $ StaticR css_bootstrap_responsive_css
addScript $ StaticR jquery_full_js addScript $ StaticR jquery_full_js
addScript $ StaticR js_bootstrap_dropdown_js addScript $ StaticR js_bootstrap_dropdown_js
addScript $ StaticR js_bootstrap_modal_js addScript $ StaticR js_bootstrap_modal_js
let navbar = navBar navbaritem
$(widgetFile "page") $(widgetFile "page")
hamletToRepHtml $(hamletFile $ hamletTemplate "bootstrap") hamletToRepHtml $(hamletFile $ hamletTemplate "bootstrap")
where
navdetails i = (navBarName i, navBarRoute i, Just i == navbaritem)
instance Yesod WebApp where instance Yesod WebApp where
{- Require an auth token be set when accessing any (non-static route) -} {- Require an auth token be set when accessing any (non-static route) -}

View file

@ -41,14 +41,22 @@ introDisplay ident = do
where where
counter = map show ([1..] :: [Int]) counter = map show ([1..] :: [Int])
addRepository :: Bool -> Widget
addRepository firstrun = do
setTitle $ if firstrun then "Getting started" else "Add repository"
$(widgetFile "configurators/addrepository")
getConfigR :: Handler RepHtml getConfigR :: Handler RepHtml
getConfigR = bootstrap (Just Config) $ do getConfigR = bootstrap (Just Config) $ do
sideBarDisplay sideBarDisplay
setTitle "Configuration" ifM (lift inFirstRun)
$(widgetFile "configurators/main") ( addRepository True
, do
setTitle "Configuration"
$(widgetFile "configurators/main")
)
getAddRepositoryR :: Handler RepHtml getAddRepositoryR :: Handler RepHtml
getAddRepositoryR = bootstrap (Just Config) $ do getAddRepositoryR = bootstrap (Just Config) $ do
sideBarDisplay sideBarDisplay
setTitle "Add repository" addRepository False
$(widgetFile "configurators/addrepository")

View file

@ -71,11 +71,14 @@ dashboard warnNoScript = do
$(widgetFile "dashboard/main") $(widgetFile "dashboard/main")
getHomeR :: Handler RepHtml getHomeR :: Handler RepHtml
getHomeR = bootstrap (Just DashBoard) $ dashboard True getHomeR = ifM (inFirstRun)
( redirect ConfigR
, bootstrap (Just DashBoard) $ dashboard True
)
{- Same as HomeR, except no autorefresh at all (and no noscript warning). -} {- Same as HomeR, except no autorefresh at all (and no noscript warning). -}
getNoScriptR :: Handler RepHtml getNoScriptR :: Handler RepHtml
getNoScriptR = bootstrap (Just DashBoard) $ dashboard False getNoScriptR = bootstrap (Just DashBoard) $ dashboard False
{- Same as HomeR, except with autorefreshing via meta refresh. -} {- Same as HomeR, except with autorefreshing via meta refresh. -}
getNoScriptAutoR :: Handler RepHtml getNoScriptAutoR :: Handler RepHtml

View file

@ -1,3 +1,16 @@
<div .span9 .hero-unit> <div .span9 .hero-unit>
<h2> $if firstrun
Sorry, no configuration is implemented yet... <h2>
Welcome to git-annex!
<p>
There's just one thing to do before you can start using the power #
and convenience of git-annex.
<h2>
Create a git-annex repository
<p>
Files in this repository will managed by git-annex, #
and kept in sync with your repositories on other devices.
<form .form-inline>
<i class="icon-folder-open"></i> #
<input type="text" .input-xlarge placeholder="directory"> #
<button type="submit" .btn .btn-primary .btn-large>Make Repository</button>

View file

@ -26,12 +26,3 @@
<a .btn .btn-primary .btn-large href="@{AddRepositoryR}">Add another repository</a> <a .btn .btn-primary .btn-large href="@{AddRepositoryR}">Add another repository</a>
<p> <p>
Or just sit back, watch the magic, and get on with using your files. Or just sit back, watch the magic, and get on with using your files.
$nothing
<h2>
Creating a git-annex repository
<p>
Files in this repository will managed by git-annex, #
and kept in sync with your repositories on other devices.
<form .form-inline>
<input type="text" .input-xlarge placeholder="directory"> #
<button type="submit" .btn .btn-primary .btn-large>Make Repository</button>