summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-07-31 14:23:17 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-07-31 16:13:09 -0400
commitc70496dc7f89f07e05bea0257b7d93986dd61d89 (patch)
tree767eb09e1e3531e8f1f44b5d02764b7fb1ca00a6
parent0d3686972d9b08b061f86b3e38fb681becf1c833 (diff)
improve first run screen
-rw-r--r--Assistant/WebApp.hs19
-rw-r--r--Assistant/WebApp/Configurators.hs16
-rw-r--r--Assistant/WebApp/DashBoard.hs7
-rw-r--r--templates/configurators/addrepository.hamlet17
-rw-r--r--templates/configurators/intro.hamlet9
5 files changed, 46 insertions, 22 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) -}
diff --git a/Assistant/WebApp/Configurators.hs b/Assistant/WebApp/Configurators.hs
index 66d92ebc0..9fe10aff9 100644
--- a/Assistant/WebApp/Configurators.hs
+++ b/Assistant/WebApp/Configurators.hs
@@ -41,14 +41,22 @@ introDisplay ident = do
where
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 = bootstrap (Just Config) $ do
sideBarDisplay
- setTitle "Configuration"
- $(widgetFile "configurators/main")
+ ifM (lift inFirstRun)
+ ( addRepository True
+ , do
+ setTitle "Configuration"
+ $(widgetFile "configurators/main")
+ )
getAddRepositoryR :: Handler RepHtml
getAddRepositoryR = bootstrap (Just Config) $ do
sideBarDisplay
- setTitle "Add repository"
- $(widgetFile "configurators/addrepository")
+ addRepository False
diff --git a/Assistant/WebApp/DashBoard.hs b/Assistant/WebApp/DashBoard.hs
index 9a9fccdaa..f4f56a476 100644
--- a/Assistant/WebApp/DashBoard.hs
+++ b/Assistant/WebApp/DashBoard.hs
@@ -71,11 +71,14 @@ dashboard warnNoScript = do
$(widgetFile "dashboard/main")
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). -}
getNoScriptR :: Handler RepHtml
-getNoScriptR = bootstrap (Just DashBoard) $ dashboard False
+getNoScriptR = bootstrap (Just DashBoard) $ dashboard False
{- Same as HomeR, except with autorefreshing via meta refresh. -}
getNoScriptAutoR :: Handler RepHtml
diff --git a/templates/configurators/addrepository.hamlet b/templates/configurators/addrepository.hamlet
index 150e08981..20ece2806 100644
--- a/templates/configurators/addrepository.hamlet
+++ b/templates/configurators/addrepository.hamlet
@@ -1,3 +1,16 @@
<div .span9 .hero-unit>
- <h2>
- Sorry, no configuration is implemented yet...
+ $if firstrun
+ <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>
diff --git a/templates/configurators/intro.hamlet b/templates/configurators/intro.hamlet
index be451a91f..5062346a8 100644
--- a/templates/configurators/intro.hamlet
+++ b/templates/configurators/intro.hamlet
@@ -26,12 +26,3 @@
<a .btn .btn-primary .btn-large href="@{AddRepositoryR}">Add another repository</a>
<p>
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>