implemented the addrepository form
shiny!
This commit is contained in:
parent
bcf5c81593
commit
4b5ffe8f9b
4 changed files with 53 additions and 12 deletions
|
@ -95,6 +95,11 @@ instance Yesod WebApp where
|
||||||
makeSessionBackend = webAppSessionBackend
|
makeSessionBackend = webAppSessionBackend
|
||||||
jsLoader _ = BottomOfHeadBlocking
|
jsLoader _ = BottomOfHeadBlocking
|
||||||
|
|
||||||
|
instance RenderMessage WebApp FormMessage where
|
||||||
|
renderMessage _ _ = defaultFormMessage
|
||||||
|
|
||||||
|
type Form x = Html -> MForm WebApp WebApp (FormResult x, Widget)
|
||||||
|
|
||||||
data WebAppState = WebAppState
|
data WebAppState = WebAppState
|
||||||
{ showIntro :: Bool
|
{ showIntro :: Bool
|
||||||
}
|
}
|
||||||
|
@ -145,3 +150,10 @@ instance PathPiece NotificationId where
|
||||||
instance PathPiece AlertId where
|
instance PathPiece AlertId where
|
||||||
toPathPiece = pack . show
|
toPathPiece = pack . show
|
||||||
fromPathPiece = readish . unpack
|
fromPathPiece = readish . unpack
|
||||||
|
|
||||||
|
{- Adds the auth parameter as a hidden field on a form. Must be put into
|
||||||
|
- every form. -}
|
||||||
|
webAppFormAuthToken :: Widget
|
||||||
|
webAppFormAuthToken = do
|
||||||
|
webapp <- lift getYesod
|
||||||
|
[whamlet|<input type="hidden" name="auth" value="#{secretToken webapp}">|]
|
||||||
|
|
|
@ -19,7 +19,7 @@ import Logs.Trust
|
||||||
import Annex.UUID (getUUID)
|
import Annex.UUID (getUUID)
|
||||||
|
|
||||||
import Yesod
|
import Yesod
|
||||||
import Data.Text (Text)
|
import Data.Text (Text, pack)
|
||||||
|
|
||||||
{- An intro message, list of repositories, and nudge to make more. -}
|
{- An intro message, list of repositories, and nudge to make more. -}
|
||||||
introDisplay :: Text -> Widget
|
introDisplay :: Text -> Widget
|
||||||
|
@ -41,10 +41,44 @@ introDisplay ident = do
|
||||||
where
|
where
|
||||||
counter = map show ([1..] :: [Int])
|
counter = map show ([1..] :: [Int])
|
||||||
|
|
||||||
|
data RepositoryPath = RepositoryPath Text
|
||||||
|
deriving Show
|
||||||
|
|
||||||
|
addRepositoryForm :: Form RepositoryPath
|
||||||
|
addRepositoryForm msg = do
|
||||||
|
cwd <- liftIO $ getCurrentDirectory
|
||||||
|
(pathRes, pathView) <- mreq textField "" (Just $ pack cwd)
|
||||||
|
let widget = do
|
||||||
|
webAppFormAuthToken
|
||||||
|
toWidget [julius|
|
||||||
|
$(function() {
|
||||||
|
$('##{fvId pathView}').focus();
|
||||||
|
})
|
||||||
|
|]
|
||||||
|
[whamlet|
|
||||||
|
#{msg}
|
||||||
|
<p>
|
||||||
|
<div .input-prepend .input-append>
|
||||||
|
<span .add-on>
|
||||||
|
<i .icon-folder-open></i>
|
||||||
|
^{fvInput pathView}
|
||||||
|
<button type=submit .btn>
|
||||||
|
Make Repository
|
||||||
|
|]
|
||||||
|
return (RepositoryPath <$> pathRes, widget)
|
||||||
|
|
||||||
addRepository :: Bool -> Widget
|
addRepository :: Bool -> Widget
|
||||||
addRepository firstrun = do
|
addRepository firstrun = do
|
||||||
setTitle $ if firstrun then "Getting started" else "Add repository"
|
setTitle $ if firstrun then "Getting started" else "Add repository"
|
||||||
$(widgetFile "configurators/addrepository")
|
((res, form), enctype) <- lift $ runFormGet addRepositoryForm
|
||||||
|
case res of
|
||||||
|
FormSuccess (RepositoryPath p) -> error $ "TODO" ++ show p
|
||||||
|
_ -> $(widgetFile "configurators/addrepository")
|
||||||
|
|
||||||
|
getAddRepositoryR :: Handler RepHtml
|
||||||
|
getAddRepositoryR = bootstrap (Just Config) $ do
|
||||||
|
sideBarDisplay
|
||||||
|
addRepository False
|
||||||
|
|
||||||
getConfigR :: Handler RepHtml
|
getConfigR :: Handler RepHtml
|
||||||
getConfigR = bootstrap (Just Config) $ do
|
getConfigR = bootstrap (Just Config) $ do
|
||||||
|
@ -55,8 +89,3 @@ getConfigR = bootstrap (Just Config) $ do
|
||||||
setTitle "Configuration"
|
setTitle "Configuration"
|
||||||
$(widgetFile "configurators/main")
|
$(widgetFile "configurators/main")
|
||||||
)
|
)
|
||||||
|
|
||||||
getAddRepositoryR :: Handler RepHtml
|
|
||||||
getAddRepositoryR = bootstrap (Just Config) $ do
|
|
||||||
sideBarDisplay
|
|
||||||
addRepository False
|
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
/ HomeR GET
|
/ HomeR GET
|
||||||
/noscript NoScriptR GET
|
/noscript NoScriptR GET
|
||||||
/noscriptauto NoScriptAutoR GET
|
/noscriptauto NoScriptAutoR GET
|
||||||
|
/about AboutR GET
|
||||||
|
|
||||||
/config ConfigR GET
|
/config ConfigR GET
|
||||||
/config/addrepository AddRepositoryR GET
|
/config/addrepository AddRepositoryR GET
|
||||||
/about AboutR GET
|
|
||||||
|
|
||||||
/transfers/#NotificationId TransfersR GET
|
/transfers/#NotificationId TransfersR GET
|
||||||
/sidebar/#NotificationId SideBarR GET
|
/sidebar/#NotificationId SideBarR GET
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
<p>
|
<p>
|
||||||
Files in this repository will managed by git-annex, #
|
Files in this repository will managed by git-annex, #
|
||||||
and kept in sync with your repositories on other devices.
|
and kept in sync with your repositories on other devices.
|
||||||
<form .form-inline>
|
<p>
|
||||||
<i class="icon-folder-open"></i> #
|
<form .form-inline enctype=#{enctype}>
|
||||||
<input type="text" .input-xlarge placeholder="directory"> #
|
^{form}
|
||||||
<button type="submit" .btn .btn-primary .btn-large>Make Repository</button>
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue