webapp: When setting up a ssh remote, if the user inputs ~/foo, normalize that to foo, since it's in the home directory by default.

This commit is contained in:
Joey Hess 2014-05-27 14:33:27 -04:00
parent dd5ac19b39
commit a41ddabd73
3 changed files with 19 additions and 7 deletions

View file

@ -91,14 +91,16 @@ sshInputAForm :: Field Handler Text -> SshInput -> AForm Handler SshInput
#else #else
sshInputAForm :: Field WebApp WebApp Text -> SshInput -> AForm WebApp WebApp SshInput sshInputAForm :: Field WebApp WebApp Text -> SshInput -> AForm WebApp WebApp SshInput
#endif #endif
sshInputAForm hostnamefield def = SshInput sshInputAForm hostnamefield def = normalize <$> gen
<$> aopt check_hostname (bfs "Host name") (Just $ inputHostname def)
<*> aopt check_username (bfs "User name") (Just $ inputUsername def)
<*> areq (selectFieldList authmethods) (bfs "Authenticate with") (Just $ inputAuthMethod def)
<*> aopt passwordField (bfs "Password") Nothing
<*> aopt textField (bfs "Directory") (Just $ Just $ fromMaybe (T.pack gitAnnexAssistantDefaultDir) $ inputDirectory def)
<*> areq intField (bfs "Port") (Just $ inputPort def)
where where
gen = SshInput
<$> aopt check_hostname (bfs "Host name") (Just $ inputHostname def)
<*> aopt check_username (bfs "User name") (Just $ inputUsername def)
<*> areq (selectFieldList authmethods) (bfs "Authenticate with") (Just $ inputAuthMethod def)
<*> aopt passwordField (bfs "Password") Nothing
<*> aopt textField (bfs "Directory") (Just $ Just $ fromMaybe (T.pack gitAnnexAssistantDefaultDir) $ inputDirectory def)
<*> areq intField (bfs "Port") (Just $ inputPort def)
authmethods :: [(Text, AuthMethod)] authmethods :: [(Text, AuthMethod)]
authmethods = authmethods =
[ ("password", Password) [ ("password", Password)
@ -129,6 +131,12 @@ sshInputAForm hostnamefield def = SshInput
check_hostname = hostnamefield -- unchecked check_hostname = hostnamefield -- unchecked
#endif #endif
-- The directory is implicitly in home, so remove any leading ~/
normalize i = i { inputDirectory = normalizedir <$> inputDirectory i }
normalizedir d
| "~/" `T.isPrefixOf` d = T.drop 2 d
| otherwise = d
data ServerStatus data ServerStatus
= UntestedServer = UntestedServer
| UnusableServer Text -- reason why it's not usable | UnusableServer Text -- reason why it's not usable

2
debian/changelog vendored
View file

@ -17,6 +17,8 @@ git-annex (5.20140518) UNRELEASED; urgency=medium
unicode characters to 8 bits. Allow any encoding to be used, as with unicode characters to 8 bits. Allow any encoding to be used, as with
filenames (but utf8 is the sane choice). Affects metadata and repository filenames (but utf8 is the sane choice). Affects metadata and repository
descriptions, and preferred content expressions. descriptions, and preferred content expressions.
* webapp: When setting up a ssh remote, if the user inputs ~/foo,
normalize that to foo, since it's in the home directory by default.
-- Joey Hess <joeyh@debian.org> Mon, 19 May 2014 15:59:25 -0400 -- Joey Hess <joeyh@debian.org> Mon, 19 May 2014 15:59:25 -0400

View file

@ -33,3 +33,5 @@ ok external
# End of transcript or log. # End of transcript or log.
"""]] """]]
> [[fixed|done]] --[[Joey]]