UI for enabling existing webdav remotes
This commit is contained in:
parent
7addb89dc1
commit
453587d392
6 changed files with 67 additions and 4 deletions
|
@ -175,6 +175,9 @@ repoList reposelector
|
||||||
Just "directory" -> val False EnableDirectoryR
|
Just "directory" -> val False EnableDirectoryR
|
||||||
#ifdef WITH_S3
|
#ifdef WITH_S3
|
||||||
Just "S3" -> val True EnableS3R
|
Just "S3" -> val True EnableS3R
|
||||||
|
#endif
|
||||||
|
#ifdef WITH_WEBDAV
|
||||||
|
Just "webdav" -> val True EnableWebDAVR
|
||||||
#endif
|
#endif
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
where
|
where
|
||||||
|
|
|
@ -21,12 +21,19 @@ import qualified Remote
|
||||||
import Types.Remote (RemoteConfig)
|
import Types.Remote (RemoteConfig)
|
||||||
import Types.StandardGroups
|
import Types.StandardGroups
|
||||||
import Logs.PreferredContent
|
import Logs.PreferredContent
|
||||||
|
import Logs.Remote
|
||||||
|
|
||||||
import Yesod
|
import Yesod
|
||||||
import Data.Text (Text)
|
import Data.Text (Text)
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
|
|
||||||
|
webDAVConfigurator :: Widget -> Handler RepHtml
|
||||||
|
webDAVConfigurator a = bootstrap (Just Config) $ do
|
||||||
|
sideBarDisplay
|
||||||
|
setTitle "Add a WebDAV repository"
|
||||||
|
a
|
||||||
|
|
||||||
boxConfigurator :: Widget -> Handler RepHtml
|
boxConfigurator :: Widget -> Handler RepHtml
|
||||||
boxConfigurator a = bootstrap (Just Config) $ do
|
boxConfigurator a = bootstrap (Just Config) $ do
|
||||||
sideBarDisplay
|
sideBarDisplay
|
||||||
|
@ -45,6 +52,12 @@ boxComAForm = WebDAVInput
|
||||||
<*> areq passwordField "Box.com Password" Nothing
|
<*> areq passwordField "Box.com Password" Nothing
|
||||||
<*> areq textField "Directory" (Just "annex")
|
<*> areq textField "Directory" (Just "annex")
|
||||||
|
|
||||||
|
webDAVCredsAForm :: AForm WebApp WebApp WebDAVInput
|
||||||
|
webDAVCredsAForm = WebDAVInput
|
||||||
|
<$> areq textField "Username or Email" Nothing
|
||||||
|
<*> areq passwordField "Password" Nothing
|
||||||
|
<*> pure (T.empty)
|
||||||
|
|
||||||
getAddBoxComR :: Handler RepHtml
|
getAddBoxComR :: Handler RepHtml
|
||||||
getAddBoxComR = boxConfigurator $ do
|
getAddBoxComR = boxConfigurator $ do
|
||||||
((result, form), enctype) <- lift $
|
((result, form), enctype) <- lift $
|
||||||
|
@ -67,6 +80,30 @@ getAddBoxComR = boxConfigurator $ do
|
||||||
setgroup r = runAnnex () $
|
setgroup r = runAnnex () $
|
||||||
setStandardGroup (Remote.uuid r) TransferGroup
|
setStandardGroup (Remote.uuid r) TransferGroup
|
||||||
|
|
||||||
|
getEnableWebDAVR :: UUID -> Handler RepHtml
|
||||||
|
getEnableWebDAVR uuid = do
|
||||||
|
m <- runAnnex M.empty readRemoteLog
|
||||||
|
let c = fromJust $ M.lookup uuid m
|
||||||
|
let name = fromJust $ M.lookup "name" c
|
||||||
|
let url = fromJust $ M.lookup "url" c
|
||||||
|
go name url
|
||||||
|
where
|
||||||
|
go name url
|
||||||
|
| "box.com/" `isInfixOf` url = boxConfigurator $ enable name url
|
||||||
|
| otherwise = webDAVConfigurator $ enable name url
|
||||||
|
|
||||||
|
enable name url = do
|
||||||
|
((result, form), enctype) <- lift $
|
||||||
|
runFormGet $ renderBootstrap webDAVCredsAForm
|
||||||
|
case result of
|
||||||
|
FormSuccess creds -> lift $
|
||||||
|
makeWebDavRemote name creds (const noop) M.empty
|
||||||
|
_ -> do
|
||||||
|
let authtoken = webAppFormAuthToken
|
||||||
|
description <- lift $ runAnnex "" $
|
||||||
|
T.pack . concat <$> Remote.prettyListUUIDs [uuid]
|
||||||
|
$(widgetFile "configurators/enablewebdav")
|
||||||
|
|
||||||
makeWebDavRemote :: String -> WebDAVInput -> (Remote -> Handler ()) -> RemoteConfig -> Handler ()
|
makeWebDavRemote :: String -> WebDAVInput -> (Remote -> Handler ()) -> RemoteConfig -> Handler ()
|
||||||
makeWebDavRemote name input setup config = do
|
makeWebDavRemote name input setup config = do
|
||||||
remotename <- runAnnex name $ fromRepo $ uniqueRemoteName name 0
|
remotename <- runAnnex name $ fromRepo $ uniqueRemoteName name 0
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
/config/repository/enable/rsync/#UUID EnableRsyncR GET
|
/config/repository/enable/rsync/#UUID EnableRsyncR GET
|
||||||
/config/repository/enable/directory/#UUID EnableDirectoryR GET
|
/config/repository/enable/directory/#UUID EnableDirectoryR GET
|
||||||
/config/repository/enable/S3/#UUID EnableS3R GET
|
/config/repository/enable/S3/#UUID EnableS3R GET
|
||||||
|
/config/repository/enable/webdav/#UUID EnableWebDAVR GET
|
||||||
|
|
||||||
/transfers/#NotificationId TransfersR GET
|
/transfers/#NotificationId TransfersR GET
|
||||||
/notifier/transfers NotifierTransfersR GET
|
/notifier/transfers NotifierTransfersR GET
|
||||||
|
|
|
@ -9,11 +9,11 @@ several cloud providers via [[special_remotes]].
|
||||||
More should be added, such as:
|
More should be added, such as:
|
||||||
|
|
||||||
* Google drive (attractive because it's free, only 5 gb tho)
|
* Google drive (attractive because it's free, only 5 gb tho)
|
||||||
* Owncloud (has several [providers](http://owncloud.org/providers/)
|
* Owncloud (has several [providers](http://owncloud.org/providers/);
|
||||||
that also provide 5 gb free; open DAV based API)
|
at least one provides 5 gb free; open DAV based API)
|
||||||
* OpenStack Swift (teh future)
|
* OpenStack Swift (teh future)
|
||||||
* Box.com (it's free, and current method is hard to set up and a sorta
|
* Box.com (it's free, and current method is hard to set up and a sorta
|
||||||
shakey; a better method would be to use its API)
|
shakey; a better method would be to use its API) **done**
|
||||||
* Dropbox? That would be ironic.. Via its API, presumably.
|
* Dropbox? That would be ironic.. Via its API, presumably.
|
||||||
* [[Amazon Glacier|todo/special_remote_for_amazon_glacier]]
|
* [[Amazon Glacier|todo/special_remote_for_amazon_glacier]]
|
||||||
* [nimbus.io](https://nimbus.io/) Fairly low prices ($0.06/GB);
|
* [nimbus.io](https://nimbus.io/) Fairly low prices ($0.06/GB);
|
||||||
|
|
|
@ -6,7 +6,7 @@ locally paired systems, and remote servers with rsync.
|
||||||
Help me prioritize my work: What special remote would you most like
|
Help me prioritize my work: What special remote would you most like
|
||||||
to use with the git-annex assistant?
|
to use with the git-annex assistant?
|
||||||
|
|
||||||
[[!poll open=yes 15 "Amazon S3 (done)" 12 "Amazon Glacier" 9 "Box.com" 62 "My phone (or MP3 player)" 15 "Tahoe-LAFS" 6 "OpenStack SWIFT" 23 "Google Drive"]]
|
[[!poll open=yes 15 "Amazon S3 (done)" 12 "Amazon Glacier" 9 "Box.com (done)" 62 "My phone (or MP3 player)" 15 "Tahoe-LAFS" 6 "OpenStack SWIFT" 23 "Google Drive"]]
|
||||||
|
|
||||||
This poll is ordered with the options I consider easiest to build
|
This poll is ordered with the options I consider easiest to build
|
||||||
listed first. Mostly because git-annex already supports them and they
|
listed first. Mostly because git-annex already supports them and they
|
||||||
|
|
22
templates/configurators/enablewebdav.hamlet
Normal file
22
templates/configurators/enablewebdav.hamlet
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<div .span9 .hero-unit>
|
||||||
|
<h2>
|
||||||
|
Enabling #{description}
|
||||||
|
<p>
|
||||||
|
This is a WebDAV repository located at #
|
||||||
|
<a href="#{url}">
|
||||||
|
#{url}
|
||||||
|
<p>
|
||||||
|
<form .form-horizontal enctype=#{enctype}>
|
||||||
|
<fieldset>
|
||||||
|
^{form}
|
||||||
|
^{authtoken}
|
||||||
|
<div .form-actions>
|
||||||
|
<button .btn .btn-primary type=submit onclick="$('#workingmodal').modal('show');">
|
||||||
|
Enable repository
|
||||||
|
<div .modal .fade #workingmodal>
|
||||||
|
<div .modal-header>
|
||||||
|
<h3>
|
||||||
|
Enabling repository ...
|
||||||
|
<div .modal-body>
|
||||||
|
<p>
|
||||||
|
Enabling this WebDAV repository. This could take a minute.
|
Loading…
Add table
Add a link
Reference in a new issue