b0VIM 7.4 {S*w e joey darkstar ~joey/src/git-annex/Assistant/WebApp/Configurators/Local.hs utf-8
3210 #"! U tp o c p c d 6 R ad o M I H i F 0
m
R
:
(
x g O A . x h A @
~
`
C
f B , &
~ @ ? n [ - ; = = \ Y - the user probably wants to put it there. Unless that directory - If run in another directory, that the user can write to, - - ~/Desktop/annex, when a Desktop directory exists, and ~/annex otherwise. {- On first run, if run in the home directory, default to putting it in expandTilde _ path = path expandTilde home ('~':'/':path) = home > path runcheck (chk, msg) = ifM chk ( return $ Just msg, return Nothing ) where Just prob -> Left prob Nothing -> Right $ Just $ T.pack basepath case headMaybe problems of return $ ] , (not <$> canWrite path, "Cannot write a repository there.") , (not <$> doesDirectoryExist parent, "Parent directory does not exist.") , (return $ path == home, "Sorry, using git-annex for your whole home directory is not currently supported.") , (doesFileExist path, "A file already exists with that name.") , (return $ all isSpace basepath, "A blank path? Seems unlikely.") [ (return $ path == "/", "Enter the full path to use for the repository.") problems <- catMaybes <$> mapM runcheck let parent = parentDir path path <- absPath basepath let basepath = expandTilde home $ T.unpack p home <- myHomeDir checkRepositoryPath p = do checkRepositoryPath :: Text -> IO (Either (SomeMessage WebApp) (Maybe Text)) - expanded in the returned path. -} {- As well as checking the path for a lot of silly things, tilde is nopath = return $ Left "Enter a location for the repository" parse _ = nopath parse [] = return $ Right Nothing | otherwise = liftIO $ checkRepositoryPath path | T.null path = nopath parse [path] [whamlet||] view idAttr nameAttr attrs val isReq = where } , fieldView = view #endif , fieldEnctype = UrlEncoded { fieldParse = \l _ -> parse l #else { fieldParse = parse #if ! MIN_VERSION_yesod_form(1,2,0) repositoryPathField autofocus = Field #endif repositoryPathField :: forall sub. Bool -> Field sub WebApp Text #else repositoryPathField :: forall (m :: * -> *). (MonadIO m, HandlerSite m ~ WebApp) => Bool -> Field m Text #if MIN_VERSION_yesod(1,2,0) - to use as a repository. -} - Validates that the path entered is not empty, and is a safe value - {- Custom field display for a RepositoryPath, with an icon etc. deriving Show data RepositoryPath = RepositoryPath Text import qualified Text.Hamlet as Hamlet import Data.Ord import Data.Char import qualified Data.Map as M import qualified Data.Text as T import qualified Types.Remote import qualified Remote.GCrypt as GCrypt import qualified Annex.Branch import Utility.Gpg import Config import Utility.UserInfo import Logs.UUID import Logs.PreferredContent import Types.StandardGroups import Annex.Direct import Annex.UUID import Remote (prettyUUID) import Utility.DataUnits #endif import Utility.Mounts #ifdef WITH_CLIBS import Utility.DiskFree import Utility.FreeDesktop import Config.Files import qualified Annex import qualified Git.Command import qualified Git.Config import qualified Git.Construct import qualified Git import Annex.Init import Assistant.Restart import Assistant.Sync import Assistant.WebApp.MakeRemote import Assistant.WebApp.Gpg import Assistant.WebApp.Common module Assistant.WebApp.Configurators.Local where {-# LANGUAGE CPP, QuasiQuotes, TemplateHaskell, OverloadedStrings, RankNTypes, KindSignatures, TypeFamilies #-} -} - Licensed under the GNU AGPL version 3 or higher. - - Copyright 2012 Joey Hess