packages feed

git-annex 3.20120825 → 3.20120924

raw patch · 331 files changed

+30369/−2981 lines, 331 filesdep +blaze-builderdep +blaze-htmldep +case-insensitivesetup-changedbinary-added

Dependencies added: blaze-builder, blaze-html, case-insensitive, clientsession, crypto-api, data-default, dbus, hamlet, http-types, network-info, network-multicast, template-haskell, transformers, wai, wai-logger, warp, yesod, yesod-default, yesod-static

Files

.gitignore view
@@ -12,9 +12,12 @@ *.tix .hpc Utility/Touch.hs+Utility/Mounts.hs Utility/*.o dist # Sandboxed builds cabal-dev # Project-local emacs configuration .dir-locals.el+# OSX related+.DS_Store
Annex/Branch.hs view
@@ -18,14 +18,12 @@ 	get, 	change, 	commit,-	stage, 	files, ) where  import qualified Data.ByteString.Lazy.Char8 as L  import Common.Annex-import Annex.Exception import Annex.BranchState import Annex.Journal import qualified Git@@ -37,9 +35,9 @@ import Git.HashObject import Git.Types import Git.FilePath-import qualified Git.Index import Annex.CatFile import Annex.Perms+import qualified Annex  {- Name of the branch that is used to store git-annex's information. -} name :: Git.Ref@@ -86,43 +84,53 @@ 			return sha 		branchsha = inRepo $ Git.Ref.sha fullname -{- Ensures that the branch and index are is up-to-date; should be- - called before data is read from it. Runs only once per git-annex run.- -}+{- Ensures that the branch and index are up-to-date; should be+ - called before data is read from it. Runs only once per git-annex run. -} update :: Annex ()-update = runUpdateOnce $ updateTo =<< siblingBranches+update = runUpdateOnce $ void $ updateTo =<< siblingBranches  {- Forces an update even if one has already been run. -}-forceUpdate :: Annex ()+forceUpdate :: Annex Bool forceUpdate = updateTo =<< siblingBranches  {- Merges the specified Refs into the index, if they have any changes not  - already in it. The Branch names are only used in the commit message;  - it's even possible that the provided Branches have not been updated to  - point to the Refs yet.+ - + - The branch is fast-forwarded if possible, otherwise a merge commit is+ - made.  -- - Before refs are merged into the index, it's important to first stage the+ - Before Refs are merged into the index, it's important to first stage the  - journal into the index. Otherwise, any changes in the journal would  - later get staged, and might overwrite changes made during the merge.- - If no Refs are provided, the journal is still staged and committed.- -- - (It would be cleaner to handle the merge by updating the journal, not the- - index, with changes from the branches.)+ - This is only done if some of the Refs do need to be merged.  -- - The branch is fast-forwarded if possible, otherwise a merge commit is- - made.+ - Returns True if any refs were merged in, False otherwise.  -}-updateTo :: [(Git.Ref, Git.Branch)] -> Annex ()+updateTo :: [(Git.Ref, Git.Branch)] -> Annex Bool updateTo pairs = do 	-- ensure branch exists, and get its current ref 	branchref <- getBranch-	-- check what needs updating before taking the lock-	dirty <- unCommitted+	dirty <- journalDirty 	(refs, branches) <- unzip <$> filterM isnewer pairs-	if not dirty && null refs-		then updateIndex branchref-		else withIndex $ lockJournal $ do-			when dirty stageJournal+	if null refs+ 		{- Even when no refs need to be merged, the index+		 - may still be updated if the branch has gotten ahead +		 - of the index. -}+		then whenM (needUpdateIndex branchref) $ lockJournal $ do+			forceUpdateIndex branchref+			{- When there are journalled changes+			 - as well as the branch being updated,+			 - a commit needs to be done. -}+			when dirty $+				go branchref True [] []+		else lockJournal $ go branchref dirty refs branches+	return $ not $ null refs+	where+		isnewer (r, _) = inRepo $ Git.Branch.changed fullname r+		go branchref dirty refs branches = withIndex $ do+			cleanjournal <- if dirty then stageJournal else return noop 			let merge_desc = if null branches 				then "update" 				else "merging " ++@@ -139,11 +147,14 @@ 				else commitBranch branchref merge_desc 					(nub $ fullname:refs) 			invalidateCache-	where-		isnewer (r, _) = inRepo $ Git.Branch.changed fullname r+			liftIO cleanjournal -{- Gets the content of a file on the branch, or content from the journal, or- - staged in the index.+{- Gets the content of a file, which may be in the journal, or committed+ - to the branch. Due to limitatons of git cat-file, does *not* get content+ - that has only been staged to the index.+ - + - Updates the branch if necessary, to ensure the most up-to-date available+ - content is available.  -  - Returns an empty string if the file doesn't exist yet. -} get :: FilePath -> Annex String@@ -163,7 +174,9 @@ 		fromjournal (Just content) = cache content 		fromjournal Nothing 			| staleok = withIndex frombranch-			| otherwise = withIndexUpdate $ frombranch >>= cache+			| otherwise = do+				update+				withIndex $ frombranch >>= cache 		frombranch = L.unpack <$> catFile fullname file 		cache content = do 			setCache file content@@ -185,16 +198,11 @@  {- Stages the journal, and commits staged changes to the branch. -} commit :: String -> Annex ()-commit message = whenM unCommitted $ lockJournal $ do-	stageJournal+commit message = whenM journalDirty $ lockJournal $ do+	cleanjournal <- stageJournal 	ref <- getBranch 	withIndex $ commitBranch ref message [fullname]--{- Stages the journal, not making a commit to the branch. -}-stage :: Annex ()-stage = whenM journalDirty $ lockJournal $ do-	stageJournal-	setUnCommitted+	liftIO $ cleanjournal  {- Commits the staged changes in the index to the branch.  - @@ -216,13 +224,16 @@  -} commitBranch :: Git.Ref -> String -> [Git.Ref] -> Annex () commitBranch branchref message parents = do+	showStoringStateAction+	commitBranch' branchref message parents+commitBranch' :: Git.Ref -> String -> [Git.Ref] -> Annex ()+commitBranch' branchref message parents = do 	updateIndex branchref 	committedref <- inRepo $ Git.Branch.commit message fullname parents 	setIndexSha committedref 	parentrefs <- commitparents <$> catObject committedref 	when (racedetected branchref parentrefs) $ 		fixrace committedref parentrefs-	setCommitted 	where 		-- look for "parent ref" lines and return the refs 		commitparents = map (Git.Ref . snd) . filter isparent .@@ -247,12 +258,13 @@  {- Lists all files on the branch. There may be duplicates in the list. -} files :: Annex [FilePath]-files = withIndexUpdate $ do-	bfiles <- inRepo $ Git.Command.pipeNullSplit-		[Params "ls-tree --name-only -r -z", Param $ show fullname]-	jfiles <- getJournalledFiles-	return $ jfiles ++ bfiles-+files = do+	update+	withIndex $ do+		bfiles <- inRepo $ Git.Command.pipeNullSplit+			[Params "ls-tree --name-only -r -z", Param $ show fullname]+		jfiles <- getJournalledFiles+		return $ jfiles ++ bfiles  {- Populates the branch's index file with the current branch contents.  - @@ -277,18 +289,19 @@ withIndex' :: Bool -> Annex a -> Annex a withIndex' bootstrapping a = do 	f <- fromRepo gitAnnexIndex-	bracketIO (Git.Index.override f) id $ do-		checkIndexOnce $ unlessM (liftIO $ doesFileExist f) $ do-			unless bootstrapping create-			liftIO $ createDirectoryIfMissing True $ takeDirectory f-			unless bootstrapping $ inRepo genIndex-		a+	g <- gitRepo+	let g' = g { gitEnv = Just [("GIT_INDEX_FILE", f)] } -{- Runs an action using the branch's index file, first making sure that- - the branch and index are up-to-date. -}-withIndexUpdate :: Annex a -> Annex a-withIndexUpdate a = update >> withIndex a+	Annex.changeState $ \s -> s { Annex.repo = g' }+	checkIndexOnce $ unlessM (liftIO $ doesFileExist f) $ do+		unless bootstrapping create+		liftIO $ createDirectoryIfMissing True $ takeDirectory f+		unless bootstrapping $ inRepo genIndex+	r <- a+	Annex.changeState $ \s -> s { Annex.repo = (Annex.repo s) { gitEnv = gitEnv g} } +	return r+ {- Updates the branch's index to reflect the current contents of the branch.  - Any changes staged in the index will be preserved.  -@@ -296,13 +309,21 @@  - ref of the branch to see if an update is needed.  -} updateIndex :: Git.Ref -> Annex ()-updateIndex branchref = do+updateIndex branchref = whenM (needUpdateIndex branchref) $+	forceUpdateIndex branchref++forceUpdateIndex :: Git.Ref -> Annex ()+forceUpdateIndex branchref = do+	withIndex $ mergeIndex [fullname]+	setIndexSha branchref++{- Checks if the index needs to be updated. -}+needUpdateIndex :: Git.Ref -> Annex Bool+needUpdateIndex branchref = do 	lock <- fromRepo gitAnnexIndexLock 	lockref <- Git.Ref . firstLine <$>-		liftIO (catchDefaultIO (readFileStrict lock) "")-	when (lockref /= branchref) $ do-		withIndex $ mergeIndex [fullname]-		setIndexSha branchref+		liftIO (catchDefaultIO "" $ readFileStrict lock)+	return (lockref /= branchref)  {- Record that the branch's index has been updated to correspond to a  - given ref of the branch. -}@@ -312,39 +333,24 @@ 	liftIO $ writeFile lock $ show ref ++ "\n" 	setAnnexPerm lock -{- Checks if there are uncommitted changes in the branch's index or journal. -}-unCommitted :: Annex Bool-unCommitted = do-	d <- liftIO . doesFileExist =<< fromRepo gitAnnexIndexDirty-	if d-		then return d-		else journalDirty--setUnCommitted :: Annex ()-setUnCommitted = do-	file <- fromRepo gitAnnexIndexDirty-	liftIO $ writeFile file "1"--setCommitted :: Annex ()-setCommitted = void $ do-	file <- fromRepo gitAnnexIndexDirty-	liftIO $ tryIO $ removeFile file--{- Stages the journal into the index. -}-stageJournal :: Annex ()-stageJournal = do-	showStoringStateAction-	fs <- getJournalFiles+{- Stages the journal into the index and returns an action that will+ - clean up the staged journal files, which should only be run once+ - the index has been committed to the branch. Should be run within+ - lockJournal, to prevent others from modifying the journal. -}+stageJournal :: Annex (IO ())+stageJournal = withIndex $ do 	g <- gitRepo-	withIndex $ liftIO $ do+	let dir = gitAnnexJournalDir g+	fs <- getJournalFiles+	liftIO $ do 		h <- hashObjectStart g 		Git.UpdateIndex.streamUpdateIndex g-			[genstream (gitAnnexJournalDir g) h fs]+			[genstream dir h fs] 		hashObjectStop h+	return $ liftIO $ mapM_ removeFile $ map (dir </>) fs 	where 		genstream dir h fs streamer = forM_ fs $ \file -> do 			let path = dir </> file 			sha <- hashFile h path-			_ <- streamer $ Git.UpdateIndex.updateIndexLine+			streamer $ Git.UpdateIndex.updateIndexLine 				sha FileBlob (asTopFilePath $ fileJournal file)-			removeFile path
Annex/Content.hs view
@@ -280,7 +280,7 @@ getKeysPresent = liftIO . traverse (2 :: Int) =<< fromRepo gitAnnexObjectDir 	where 		traverse depth dir = do-			contents <- catchDefaultIO (dirContents dir) []+			contents <- catchDefaultIO [] (dirContents dir) 			if depth == 0 				then continue (mapMaybe (fileKey . takeFileName) contents) [] 				else do@@ -298,11 +298,11 @@  - especially if performing a short-lived action.  -} saveState :: Bool -> Annex ()-saveState oneshot = doSideAction $ do+saveState nocommit = doSideAction $ do 	Annex.Queue.flush-	unless oneshot $-		ifM alwayscommit-			( Annex.Branch.commit "update" , Annex.Branch.stage)+	unless nocommit $+		whenM alwayscommit $+			Annex.Branch.commit "update" 	where 		alwayscommit = fromMaybe True . Git.Config.isTrue 			<$> getConfig (annexConfig "alwayscommit") ""
Annex/Exception.hs view
@@ -8,12 +8,13 @@ module Annex.Exception ( 	bracketIO, 	handle,+	tryAnnex, 	throw, ) where -import Control.Exception.Lifted (handle)+import Control.Exception.Lifted (handle, try) import Control.Monad.Trans.Control (liftBaseOp)-import Control.Exception hiding (handle, throw)+import Control.Exception hiding (handle, try, throw)  import Common.Annex @@ -21,6 +22,10 @@ bracketIO :: IO c -> (c -> IO b) -> Annex a -> Annex a bracketIO setup cleanup go = 	liftBaseOp (Control.Exception.bracket setup cleanup) (const go)++{- try in the Annex monad -}+tryAnnex :: Annex a -> Annex (Either SomeException a)+tryAnnex = try  {- Throws an exception in the Annex monad. -} throw :: Control.Exception.Exception e => e -> Annex a
Annex/Journal.hs view
@@ -47,8 +47,8 @@ getJournalFiles :: Annex [FilePath] getJournalFiles = do 	g <- gitRepo-	fs <- liftIO $-		catchDefaultIO (getDirectoryContents $ gitAnnexJournalDir g) []+	fs <- liftIO $ catchDefaultIO [] $+		getDirectoryContents $ gitAnnexJournalDir g 	return $ filter (`notElem` [".", ".."]) fs  {- Checks if there are changes in the journal. -}
Annex/Ssh.hs view
@@ -42,7 +42,13 @@ 	( do 		dir <- fromRepo gitAnnexSshDir 		let socketfile = dir </> hostport2socket host port-	 	return (Just socketfile, cacheParams socketfile)+		if valid_unix_socket_path socketfile+			then return (Just socketfile, cacheParams socketfile)+			else do+				socketfile' <- liftIO $ relPathCwdToFile socketfile+				if valid_unix_socket_path socketfile'+					then return (Just socketfile', cacheParams socketfile')+					else return (Nothing, []) 	, return (Nothing, []) 	) 	where@@ -65,7 +71,7 @@ sshCleanup = do 	dir <- fromRepo gitAnnexSshDir 	sockets <- filter (not . isLock) <$>-		liftIO (catchDefaultIO (dirContents dir) [])+		liftIO (catchDefaultIO [] $ dirContents dir) 	forM_ sockets cleanup 	where 		cleanup socketfile = do@@ -118,3 +124,16 @@  lockExt :: String lockExt = ".lock"++{- This is the size of the sun_path component of sockaddr_un, which+ - is the limit to the total length of the filename of a unix socket.+ -+ - On Linux, this is 108. On OSX, 104. TODO: Probe+ -}+sizeof_sockaddr_un_sun_path :: Int+sizeof_sockaddr_un_sun_path = 100++{- Note that this looks at the true length of the path in bytes, as it will+ - appear on disk. -}+valid_unix_socket_path :: FilePath -> Bool+valid_unix_socket_path f = length (decodeW8 f) < sizeof_sockaddr_un_sun_path
Annex/UUID.hs view
@@ -32,8 +32,10 @@ {- Generates a UUID. There is a library for this, but it's not packaged,  - so use the command line tool. -} genUUID :: IO UUID-genUUID = pOpen ReadFromPipe command params $ liftM toUUID . hGetLine+genUUID = gen . lines <$> readProcess command params 	where+		gen [] = error $ "no output from " ++ command+		gen (l:_) = toUUID l 		command = SysConfig.uuid 		params 			-- request a random uuid be generated
Assistant.hs view
@@ -10,7 +10,7 @@  - 	The initial thread run, double forks to background, starts other  - 	threads, and then stops, waiting for them to terminate,  - 	or for a ctrl-c.- - Thread 2: watcher+ - Thread 2: Watcher  - 	Notices new files, and calls handlers for events, queuing changes.  - Thread 3: inotify internal  - 	Used by haskell inotify library to ensure inotify event buffer is@@ -19,67 +19,190 @@  - 	Scans the tree and registers inotify watches for each directory.  -	A MVar lock is used to prevent other inotify handlers from running  -	until this is complete.- - Thread 5: committer+ - Thread 5: Committer  - 	Waits for changes to occur, and runs the git queue to update its- - 	index, then commits.- - Thread 6: status logger+ - 	index, then commits. Also queues Transfer events to send added+ - 	files to other remotes.+ - Thread 6: Pusher+ - 	Waits for commits to be made, and pushes updated branches to remotes,+ - 	in parallel. (Forks a process for each git push.)+ - Thread 7: PushRetryer+ - 	Runs every 30 minutes when there are failed pushes, and retries+ - 	them.+ - Thread 8: Merger+ - 	Waits for pushes to be received from remotes, and merges the+ - 	updated branches into the current branch.+ - 	(This uses inotify on .git/refs/heads, so there are additional+ - 	inotify threads associated with it, too.)+ - Thread 9: TransferWatcher+ - 	Watches for transfer information files being created and removed,+ - 	and maintains the DaemonStatus currentTransfers map.+ - 	(This uses inotify on .git/annex/transfer/, so there are+ - 	additional inotify threads associated with it, too.)+ - Thread 10: TransferPoller+ -	Polls to determine how much of each ongoing transfer is complete.+ - Thread 11: Transferrer+ - 	Waits for Transfers to be queued and does them.+ - Thread 12: StatusLogger  - 	Wakes up periodically and records the daemon's status to disk.- - Thread 7: sanity checker+ - Thread 13: SanityChecker  - 	Wakes up periodically (rarely) and does sanity checks.+ - Thread 14: MountWatcher+ - 	Either uses dbus to watch for drive mount events, or, when+ - 	there's no dbus, polls to find newly mounted filesystems.+ - 	Once a filesystem that contains a remote is mounted, updates+ - 	state about that remote, pulls from it, and queues a push to it,+ - 	as well as an update, and queues it onto the+ - 	ConnectedRemoteChan+ - Thread 15: NetWatcher+ - 	Deals with network connection interruptions, which would cause+ - 	transfers to fail, and can be recovered from by waiting for a+ - 	network connection, and syncing with all network remotes.+ - 	Uses dbus to watch for network connections, or when dbus+ - 	cannot be used, assumes there's been one every 30 minutes.+ - Thread 16: TransferScanner+ - 	Does potentially expensive checks to find data that needs to be+ - 	transferred from or to remotes, and queues Transfers.+ - 	Uses the ScanRemotes map.a+ - Thread 17: PairListener+ - 	Listens for incoming pairing traffic, and takes action.+ - Thread 18: WebApp+ - 	Spawns more threads as necessary to handle clients.+ - 	Displays the DaemonStatus.  -  - ThreadState: (MVar)  - 	The Annex state is stored here, which allows resuscitating the- - 	Annex monad in IO actions run by the inotify and committer+ - 	Annex monad in IO actions run by the watcher and committer  - 	threads. Thus, a single state is shared amoung the threads, and  - 	only one at a time can access it.- - DaemonStatusHandle: (MVar)- - 	The daemon's current status. This MVar should only be manipulated- - 	from inside the Annex monad, which ensures it's accessed only- - 	after the ThreadState MVar.+ - DaemonStatusHandle: (STM TMVar)+ - 	The daemon's current status.  - ChangeChan: (STM TChan)  - 	Changes are indicated by writing to this channel. The committer  - 	reads from it.+ - CommitChan: (STM TChan)+ - 	Commits are indicated by writing to this channel. The pusher reads+ - 	from it.+ - FailedPushMap (STM TMVar)+ - 	Failed pushes are indicated by writing to this TMVar. The push+ - 	retrier blocks until they're available.+ - TransferQueue (STM TChan)+ - 	Transfers to make are indicated by writing to this channel.+ - TransferSlots (QSemN)+ - 	Count of the number of currently available transfer slots.+ - 	Updated by the transfer watcher, this allows other threads+ - 	to block until a slot is available.+ - 	This MVar should only be manipulated from inside the Annex monad,+ - 	which ensures it's accessed only after the ThreadState MVar.+ - ScanRemotes (STM TMVar)+ - 	Remotes that have been disconnected, and should be scanned+ - 	are indicated by writing to this TMVar.+ - UrlRenderer (MVar)+ - 	A Yesod route rendering function is stored here. This allows+ - 	things that need to render Yesod routes to block until the webapp+ - 	has started up and such rendering is possible.  -} +{-# LANGUAGE CPP #-}+ module Assistant where -import Common.Annex+import Assistant.Common import Assistant.ThreadedMonad import Assistant.DaemonStatus import Assistant.Changes-import Assistant.Watcher-import Assistant.Committer-import Assistant.SanityChecker+import Assistant.Commits+import Assistant.Pushes+import Assistant.ScanRemotes+import Assistant.TransferQueue+import Assistant.TransferSlots+import Assistant.Threads.DaemonStatus+import Assistant.Threads.Watcher+import Assistant.Threads.Committer+import Assistant.Threads.Pusher+import Assistant.Threads.Merger+import Assistant.Threads.TransferWatcher+import Assistant.Threads.Transferrer+import Assistant.Threads.SanityChecker+import Assistant.Threads.MountWatcher+import Assistant.Threads.NetWatcher+import Assistant.Threads.TransferScanner+import Assistant.Threads.TransferPoller+#ifdef WITH_WEBAPP+import Assistant.WebApp+import Assistant.Threads.WebApp+#ifdef WITH_PAIRING+import Assistant.Threads.PairListener+#endif+#else+#warning Building without the webapp. You probably need to install Yesod..+#endif import qualified Utility.Daemon import Utility.LogFile+import Utility.ThreadScheduler  import Control.Concurrent -startDaemon :: Bool -> Annex ()-startDaemon foreground+type NamedThread = IO () -> IO (String, IO ())++stopDaemon :: Annex ()+stopDaemon = liftIO . Utility.Daemon.stopDaemon =<< fromRepo gitAnnexPidFile++startDaemon :: Bool -> Bool -> Maybe (String -> FilePath -> IO ()) -> Annex ()+startDaemon assistant foreground webappwaiter 	| foreground = do-		showStart "watch" "."+		showStart (if assistant then "assistant" else "watch") "."+		liftIO . Utility.Daemon.lockPidFile =<< fromRepo gitAnnexPidFile 		go id 	| otherwise = do 		logfd <- liftIO . openLog =<< fromRepo gitAnnexLogFile 		pidfile <- fromRepo gitAnnexPidFile 		go $ Utility.Daemon.daemonize logfd (Just pidfile) False 	where-		go a = withThreadState $ \st -> do-			checkCanWatch-			dstatus <- startDaemonStatus-			liftIO $ a $ do-				changechan <- newChangeChan-				-- The commit thread is started early,-				-- so that the user can immediately-				-- begin adding files and having them-				-- committed, even while the startup scan-				-- is taking place.-				_ <- forkIO $ commitThread st changechan-				_ <- forkIO $ daemonStatusThread st dstatus-				_ <- forkIO $ sanityCheckerThread st dstatus changechan-				-- Does not return.-				watchThread st dstatus changechan+		go d = startAssistant assistant d webappwaiter -stopDaemon :: Annex ()-stopDaemon = liftIO . Utility.Daemon.stopDaemon =<< fromRepo gitAnnexPidFile+startAssistant :: Bool -> (IO () -> IO ()) -> Maybe (String -> FilePath -> IO ()) -> Annex ()+startAssistant assistant daemonize webappwaiter = withThreadState $ \st -> do+	checkCanWatch+	dstatus <- startDaemonStatus+	liftIO $ daemonize $ run dstatus st+	where+		run dstatus st = do+			changechan <- newChangeChan+			commitchan <- newCommitChan+			pushmap <- newFailedPushMap+			transferqueue <- newTransferQueue+			transferslots <- newTransferSlots+			scanremotes <- newScanRemoteMap+#ifdef WITH_WEBAPP+			urlrenderer <- newUrlRenderer+#endif+			mapM_ (startthread dstatus)+				[ watch $ commitThread st changechan commitchan transferqueue dstatus+#ifdef WITH_WEBAPP+				, assist $ webAppThread (Just st) dstatus scanremotes transferqueue transferslots urlrenderer Nothing webappwaiter+#ifdef WITH_PAIRING+				, assist $ pairListenerThread st dstatus scanremotes urlrenderer+#endif+#endif+				, assist $ pushThread st dstatus commitchan pushmap+				, assist $ pushRetryThread st dstatus pushmap+				, assist $ mergeThread st dstatus transferqueue+				, assist $ transferWatcherThread st dstatus transferqueue+				, assist $ transferPollerThread st dstatus+				, assist $ transfererThread st dstatus transferqueue transferslots+				, assist $ daemonStatusThread st dstatus+				, assist $ sanityCheckerThread st dstatus transferqueue changechan+				, assist $ mountWatcherThread st dstatus scanremotes+				, assist $ netWatcherThread st dstatus scanremotes+				, assist $ netWatcherFallbackThread st dstatus scanremotes+				, assist $ transferScannerThread st dstatus scanremotes transferqueue+				, watch $ watchThread st dstatus transferqueue changechan+				]+			waitForTermination+		watch a = (True, a)+		assist a = (False, a)+		startthread dstatus (watcher, t)+			| watcher || assistant = void $ forkIO $+				runNamedThread dstatus t+			| otherwise = noop
+ Assistant/Alert.hs view
@@ -0,0 +1,357 @@+{- git-annex assistant alerts+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++{-# LANGUAGE RankNTypes, OverloadedStrings #-}++module Assistant.Alert where++import Common.Annex+import qualified Remote+import Utility.Tense+import Logs.Transfer++import qualified Data.Text as T+import Data.Text (Text)+import qualified Data.Map as M+import Data.String++{- Different classes of alerts are displayed differently. -}+data AlertClass = Success | Message | Activity | Warning | Error+	deriving (Eq, Ord)++data AlertPriority = Filler | Low | Medium | High | Pinned+	deriving (Eq, Ord)++{- An alert can have an name, which is used to combine it with other similar+ - alerts. -}+data AlertName +	= FileAlert TenseChunk+	| SanityCheckFixAlert+	| WarningAlert String+	| PairAlert String+	deriving (Eq)++{- The first alert is the new alert, the second is an old alert.+ - Should return a modified version of the old alert. -}+type AlertCombiner = Alert -> Alert -> Maybe Alert++data Alert = Alert+	{ alertClass :: AlertClass+	, alertHeader :: Maybe TenseText+	, alertMessageRender :: [TenseChunk] -> TenseText+	, alertData :: [TenseChunk]+	, alertBlockDisplay :: Bool+	, alertClosable :: Bool+	, alertPriority :: AlertPriority+	, alertIcon :: Maybe AlertIcon+	, alertCombiner :: Maybe AlertCombiner+	, alertName :: Maybe AlertName+	, alertButton :: Maybe AlertButton+	}++data AlertIcon = ActivityIcon | SuccessIcon | ErrorIcon | InfoIcon++bootstrapIcon :: AlertIcon -> String+bootstrapIcon ActivityIcon = "refresh"+bootstrapIcon InfoIcon = "info-sign"+bootstrapIcon SuccessIcon = "ok"+bootstrapIcon ErrorIcon = "exclamation-sign"++{- When clicked, a button always redirects to a URL+ - It may also run an IO action in the background, which is useful+ - to make the button close or otherwise change the alert. -}+data AlertButton = AlertButton+	{ buttonLabel :: Text+	, buttonUrl :: Text+	, buttonAction :: Maybe (AlertId -> IO ())+	}++type AlertPair = (AlertId, Alert)++type AlertMap = M.Map AlertId Alert++{- Higher AlertId indicates a more recent alert. -}+newtype AlertId = AlertId Integer+        deriving (Read, Show, Eq, Ord)++firstAlertId :: AlertId+firstAlertId = AlertId 0++nextAlertId :: AlertId -> AlertId+nextAlertId (AlertId i) = AlertId $ succ i++{- This is as many alerts as it makes sense to display at a time.+ - A display might be smaller, or larger, the point is to not overwhelm the+ - user with a ton of alerts. -}+displayAlerts :: Int+displayAlerts = 6++{- This is not a hard maximum, but there's no point in keeping a great+ - many filler alerts in an AlertMap, so when there's more than this many,+ - they start being pruned, down toward displayAlerts. -}+maxAlerts :: Int+maxAlerts = displayAlerts * 2++{- The desired order is the reverse of:+ -+ - - Pinned alerts+ - - High priority alerts, newest first+ - - Medium priority Activity, newest first (mostly used for Activity)+ - - Low priority alerts, newest first+ - - Filler priorty alerts, newest first+ - - Ties are broken by the AlertClass, with Errors etc coming first.+ -}+compareAlertPairs :: AlertPair -> AlertPair -> Ordering+compareAlertPairs+	(aid, Alert { alertClass = aclass, alertPriority = aprio })+	(bid, Alert { alertClass = bclass, alertPriority = bprio })+	 = compare aprio bprio+		`thenOrd` compare aid bid+			`thenOrd` compare aclass bclass++sortAlertPairs :: [AlertPair] -> [AlertPair]+sortAlertPairs = sortBy compareAlertPairs++{- Renders an alert's header for display, if it has one. -}+renderAlertHeader :: Alert -> Maybe Text+renderAlertHeader alert = renderTense (alertTense alert) <$> alertHeader alert++{- Renders an alert's message for display. -}+renderAlertMessage :: Alert -> Text+renderAlertMessage alert = renderTense (alertTense alert) $+	(alertMessageRender alert) (alertData alert)++alertTense :: Alert -> Tense+alertTense alert+	| alertClass alert == Activity = Present+	| otherwise = Past++{- Checks if two alerts display the same. -}+effectivelySameAlert :: Alert -> Alert -> Bool+effectivelySameAlert x y = all id +	[ alertClass x == alertClass y+	, alertHeader x == alertHeader y+	, alertData x == alertData y+	, alertBlockDisplay x == alertBlockDisplay y+	, alertClosable x == alertClosable y+	, alertPriority x == alertPriority y+	]++makeAlertFiller :: Bool -> Alert -> Alert+makeAlertFiller success alert+	| isFiller alert = alert+	| otherwise = alert+		{ alertClass = if c == Activity then c' else c+		, alertPriority = Filler+		, alertClosable = True+		, alertButton = Nothing+		, alertIcon = Just $ if success then SuccessIcon else ErrorIcon+		}+	where+		c = alertClass alert+		c'+			| success = Success+			| otherwise = Error++isFiller :: Alert -> Bool+isFiller alert = alertPriority alert == Filler++{- Updates the Alertmap, adding or updating an alert.+ -+ - Any old filler that looks the same as the alert is removed.+ -+ - Or, if the alert has an alertCombiner that combines it with+ - an old alert, the old alert is replaced with the result, and the+ - alert is removed.+ -+ - Old filler alerts are pruned once maxAlerts is reached.+ -}+mergeAlert :: AlertId -> Alert -> AlertMap -> AlertMap+mergeAlert i al m = maybe updatePrune updateCombine (alertCombiner al)+	where+		pruneSame k al' = k == i || not (effectivelySameAlert al al')+		pruneBloat m'+			| bloat > 0 = M.fromList $ pruneold $ M.toList m'+			| otherwise = m'+			where+				bloat = M.size m' - maxAlerts+				pruneold l =+			 		let (f, rest) = partition (\(_, a) -> isFiller a) l+					in drop bloat f ++ rest+		updatePrune = pruneBloat $ M.filterWithKey pruneSame $+			M.insertWith' const i al m+		updateCombine combiner = +			let combined = M.mapMaybe (combiner al) m+			in if M.null combined+				then updatePrune+				else M.delete i $ M.union combined m++baseActivityAlert :: Alert+baseActivityAlert = Alert+	{ alertClass = Activity+	, alertHeader = Nothing+	, alertMessageRender = tenseWords+	, alertData = []+	, alertBlockDisplay = False+	, alertClosable = False+	, alertPriority = Medium+	, alertIcon = Just ActivityIcon+	, alertCombiner = Nothing+	, alertName = Nothing+	, alertButton = Nothing+	}++warningAlert :: String -> String -> Alert+warningAlert name msg = Alert+	{ alertClass = Warning+	, alertHeader = Just $ tenseWords ["warning"]+	, alertMessageRender = tenseWords+	, alertData = [UnTensed $ T.pack msg]+	, alertBlockDisplay = True+	, alertClosable = True+	, alertPriority = High+	, alertIcon = Just ErrorIcon+	, alertCombiner = Just $ dataCombiner (++)+	, alertName = Just $ WarningAlert name+	, alertButton = Nothing+	}++activityAlert :: Maybe TenseText -> [TenseChunk] -> Alert+activityAlert header dat = baseActivityAlert+	{ alertHeader = header+	, alertData = dat+	}++startupScanAlert :: Alert+startupScanAlert = activityAlert Nothing+	[Tensed "Performing" "Performed", "startup scan"]++commitAlert :: Alert+commitAlert = activityAlert Nothing+	[Tensed "Committing" "Committed", "changes to git"]++showRemotes :: [Remote] -> TenseChunk+showRemotes = UnTensed . T.unwords . map (T.pack . Remote.name)++pushAlert :: [Remote] -> Alert+pushAlert rs = activityAlert Nothing+	[Tensed "Syncing" "Synced", "with", showRemotes rs]++pushRetryAlert :: [Remote] -> Alert+pushRetryAlert rs = activityAlert+	(Just $ tenseWords [Tensed "Retrying" "Retried", "sync"])+	["with", showRemotes rs]++syncAlert :: [Remote] -> Alert+syncAlert rs = baseActivityAlert+	{ alertHeader = Just $ tenseWords+		[Tensed "Syncing" "Synced", "with", showRemotes rs]+	, alertData = []+	, alertPriority = Low+        }++scanAlert :: [Remote] -> Alert+scanAlert rs = baseActivityAlert+	{ alertHeader = Just $ tenseWords+		[Tensed "Scanning" "Scanned", showRemotes rs]+	, alertBlockDisplay = True+	, alertPriority = Low+	}++sanityCheckAlert :: Alert+sanityCheckAlert = activityAlert+	(Just $ tenseWords [Tensed "Running" "Ran", "daily sanity check"])+	["to make sure everything is ok."]++sanityCheckFixAlert :: String -> Alert+sanityCheckFixAlert msg = Alert+	{ alertClass = Warning+	, alertHeader = Just $ tenseWords ["Fixed a problem"]+	, alertMessageRender = render+	, alertData = [UnTensed $ T.pack msg]+	, alertBlockDisplay = True+	, alertPriority = High+	, alertClosable = True+	, alertIcon = Just ErrorIcon+	, alertName = Just SanityCheckFixAlert+	, alertCombiner = Just $ dataCombiner (++)+	, alertButton = Nothing+	}+	where+		render dta = tenseWords $ alerthead : dta ++ [alertfoot]+		alerthead = "The daily sanity check found and fixed a problem:"+		alertfoot = "If these problems persist, consider filing a bug report."++pairingAlert :: AlertButton -> Alert+pairingAlert button = baseActivityAlert+	{ alertData = [ UnTensed "Pairing in progress" ]+	, alertPriority = High+	, alertButton = Just button+	}++pairRequestReceivedAlert :: String -> AlertButton -> Alert+pairRequestReceivedAlert repo button = Alert+	{ alertClass = Message+	, alertHeader = Nothing+	, alertMessageRender = tenseWords+	, alertData = [UnTensed $ T.pack $ repo ++ " is sending a pair request."]+	, alertBlockDisplay = False+	, alertPriority = High+	, alertClosable = True+	, alertIcon = Just InfoIcon+	, alertName = Just $ PairAlert repo+	, alertCombiner = Just $ dataCombiner $ \_old new -> new+	, alertButton = Just button+	}++pairRequestAcknowledgedAlert :: String -> Maybe AlertButton -> Alert+pairRequestAcknowledgedAlert repo button = baseActivityAlert+	{ alertData = ["Pair request with", UnTensed (T.pack repo), Tensed "in progress" "complete"]+	, alertPriority = High+	, alertCombiner = Just $ dataCombiner $ \_old new -> new+	, alertButton = button+	}++fileAlert :: TenseChunk -> FilePath -> Alert+fileAlert msg file = (activityAlert Nothing [f])+	{ alertName = Just $ FileAlert msg+	, alertMessageRender = render+	, alertCombiner = Just $ dataCombiner combiner+	}+	where+		f = fromString $ shortFile $ takeFileName file+		render fs = tenseWords $ msg : fs+		combiner new old = take 10 $ new ++ old++addFileAlert :: FilePath -> Alert+addFileAlert = fileAlert (Tensed "Adding" "Added")++{- This is only used as a success alert after a transfer, not during it. -}+transferFileAlert :: Direction -> Bool -> FilePath -> Alert+transferFileAlert direction True+	| direction == Upload = fileAlert "Uploaded"+	| otherwise = fileAlert "Downloaded"+transferFileAlert direction False+	| direction == Upload = fileAlert "Upload failed"+	| otherwise = fileAlert "Download failed"++dataCombiner :: ([TenseChunk] -> [TenseChunk] -> [TenseChunk]) -> AlertCombiner+dataCombiner combiner new old+	| alertClass new /= alertClass old = Nothing+	| alertName new == alertName old = +		Just $! old { alertData = alertData new `combiner` alertData old }+	| otherwise = Nothing++shortFile :: FilePath -> String+shortFile f+	| len < maxlen = f+	| otherwise = take half f ++ ".." ++ drop (len - half) f+	where+		len = length f+		maxlen = 20+		half = (maxlen - 2) `div` 2 +
Assistant/Changes.hs view
@@ -1,6 +1,8 @@ {- git-annex assistant change tracking  -  - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.  -}  module Assistant.Changes where@@ -8,14 +10,14 @@ import Common.Annex import qualified Annex.Queue import Types.KeySource+import Utility.TSet -import Control.Concurrent.STM import Data.Time.Clock  data ChangeType = AddChange | LinkChange | RmChange | RmDirChange 	deriving (Show, Eq) -type ChangeChan = TChan Change+type ChangeChan = TSet Change  data Change 	= Change @@ -29,11 +31,8 @@ 		} 	deriving (Show) -runChangeChan :: STM a -> IO a-runChangeChan = atomically- newChangeChan :: IO ChangeChan-newChangeChan = atomically newTChan+newChangeChan = newTSet  {- Handlers call this when they made a change that needs to get committed. -} madeChange :: FilePath -> ChangeType -> Annex (Maybe Change)@@ -65,17 +64,13 @@ {- Gets all unhandled changes.  - Blocks until at least one change is made. -} getChanges :: ChangeChan -> IO [Change]-getChanges chan = runChangeChan $ do-	c <- readTChan chan-	go [c]-	where-		go l = do-			v <- tryReadTChan chan-			case v of-				Nothing -> return l-				Just c -> go (c:l)+getChanges = getTSet  {- Puts unhandled changes back into the channel.  - Note: Original order is not preserved. -} refillChanges :: ChangeChan -> [Change] -> IO ()-refillChanges chan cs = runChangeChan $ mapM_ (writeTChan chan) cs+refillChanges = putTSet++{- Records a change in the channel. -}+recordChange :: ChangeChan -> Change -> IO ()+recordChange = putTSet1
+ Assistant/Commits.hs view
@@ -0,0 +1,34 @@+{- git-annex assistant commit tracking+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++module Assistant.Commits where++import Utility.TSet++import Data.Time.Clock++type CommitChan = TSet Commit++data Commit = Commit UTCTime+	deriving (Show)++newCommitChan :: IO CommitChan+newCommitChan = newTSet++{- Gets all unhandled commits.+ - Blocks until at least one commit is made. -}+getCommits :: CommitChan -> IO [Commit]+getCommits = getTSet++{- Puts unhandled commits back into the channel.+ - Note: Original order is not preserved. -}+refillCommits :: CommitChan -> [Commit] -> IO ()+refillCommits = putTSet++{- Records a commit in the channel. -}+recordCommit :: CommitChan -> Commit -> IO ()+recordCommit = putTSet1
− Assistant/Committer.hs
@@ -1,195 +0,0 @@-{- git-annex assistant commit thread- -- - Copyright 2012 Joey Hess <joey@kitenet.net>- -}--module Assistant.Committer where--import Common.Annex-import Assistant.Changes-import Assistant.ThreadedMonad-import Assistant.Watcher-import qualified Annex-import qualified Annex.Queue-import qualified Git.Command-import qualified Git.HashObject-import Git.Types-import qualified Command.Add-import Utility.ThreadScheduler-import qualified Utility.Lsof as Lsof-import qualified Utility.DirWatcher as DirWatcher-import Types.KeySource--import Data.Time.Clock-import Data.Tuple.Utils-import qualified Data.Set as S-import Data.Either--{- This thread makes git commits at appropriate times. -}-commitThread :: ThreadState -> ChangeChan -> IO ()-commitThread st changechan = runEvery (Seconds 1) $ do-	-- We already waited one second as a simple rate limiter.-	-- Next, wait until at least one change is available for-	-- processing.-	changes <- getChanges changechan-	-- Now see if now's a good time to commit.-	time <- getCurrentTime-	if shouldCommit time changes-		then do-			readychanges <- handleAdds st changechan changes-			if shouldCommit time readychanges-				then do-					void $ tryIO $ runThreadState st commitStaged-				else refillChanges changechan readychanges-		else refillChanges changechan changes--commitStaged :: Annex ()-commitStaged = do-	Annex.Queue.flush-	inRepo $ Git.Command.run "commit"-		[ Param "--allow-empty-message"-		, Param "-m", Param ""-		-- Empty commits may be made if tree changes cancel-		-- each other out, etc-		, Param "--allow-empty"-		-- Avoid running the usual git-annex pre-commit hook;-		-- watch does the same symlink fixing, and we don't want-		-- to deal with unlocked files in these commits.-		, Param "--quiet"-		]--{- Decide if now is a good time to make a commit.- - Note that the list of change times has an undefined order.- -- - Current strategy: If there have been 10 changes within the past second,- - a batch activity is taking place, so wait for later.- -}-shouldCommit :: UTCTime -> [Change] -> Bool-shouldCommit now changes-	| len == 0 = False-	| len > 10000 = True -- avoid bloating queue too much-	| length (filter thisSecond changes) < 10 = True-	| otherwise = False -- batch activity-	where-		len = length changes-		thisSecond c = now `diffUTCTime` changeTime c <= 1--{- If there are PendingAddChanges, the files have not yet actually been- - added to the annex (probably), and that has to be done now, before- - committing.- -- - Deferring the adds to this point causes batches to be bundled together,- - which allows faster checking with lsof that the files are not still open- - for write by some other process.- -- - When a file is added, Inotify will notice the new symlink. So this waits- - for additional Changes to arrive, so that the symlink has hopefully been- - staged before returning, and will be committed immediately.- -- - OTOH, for kqueue, eventsCoalesce, so instead the symlink is directly- - created and staged.- -- - Returns a list of all changes that are ready to be committed.- - Any pending adds that are not ready yet are put back into the ChangeChan,- - where they will be retried later.- -}-handleAdds :: ThreadState -> ChangeChan -> [Change] -> IO [Change]-handleAdds st changechan cs = returnWhen (null pendingadds) $ do-	(postponed, toadd) <- partitionEithers <$>-		safeToAdd st pendingadds--	unless (null postponed) $-		refillChanges changechan postponed--	returnWhen (null toadd) $ do-		added <- catMaybes <$> forM toadd add-		if (DirWatcher.eventsCoalesce || null added)-			then return $ added ++ otherchanges-			else do-				r <- handleAdds st changechan-					=<< getChanges changechan-				return $ r ++ added ++ otherchanges-	where-		(pendingadds, otherchanges) = partition isPendingAddChange cs--		returnWhen c a-			| c = return otherchanges-			| otherwise = a--		add :: Change -> IO (Maybe Change)-		add change@(PendingAddChange { keySource = ks }) = do-			r <- catchMaybeIO $ sanitycheck ks $ runThreadState st $ do-				showStart "add" $ keyFilename ks-				handle (finishedChange change) (keyFilename ks)-					=<< Command.Add.ingest ks-			return $ maybeMaybe r-		add _ = return Nothing--		maybeMaybe (Just j@(Just _)) = j-		maybeMaybe _ = Nothing--		handle _ _ Nothing = do-			showEndFail-			return Nothing-		handle change file (Just key) = do-			link <- Command.Add.link file key True-			when DirWatcher.eventsCoalesce $ do-				sha <- inRepo $-					Git.HashObject.hashObject BlobObject link-				stageSymlink file sha-			showEndOk-			return $ Just change--		{- Check that the keysource's keyFilename still exists,-		 - and is still a hard link to its contentLocation,-		 - before ingesting it. -}-		sanitycheck keysource a = do-			fs <- getSymbolicLinkStatus $ keyFilename keysource-			ks <- getSymbolicLinkStatus $ contentLocation keysource-			if deviceID ks == deviceID fs && fileID ks == fileID fs-				then a-				else return Nothing--{- PendingAddChanges can Either be Right to be added now,- - or are unsafe, and must be Left for later.- -- - Check by running lsof on the temp directory, which- - the KeySources are locked down in.- -}-safeToAdd :: ThreadState -> [Change] -> IO [Either Change Change]-safeToAdd st changes = runThreadState st $-	ifM (Annex.getState Annex.force)-		( allRight changes -- force bypasses lsof check-		, do-			tmpdir <- fromRepo gitAnnexTmpDir-			openfiles <- S.fromList . map fst3 . filter openwrite <$>-				liftIO (Lsof.queryDir tmpdir)-			-			let checked = map (check openfiles) changes--			{- If new events are received when files are closed,-			 - there's no need to retry any changes that cannot-			 - be done now. -}-			if DirWatcher.closingTracked-				then do-					mapM_ canceladd $ lefts checked-					allRight $ rights checked-				else return checked-		)-	where-		check openfiles change@(PendingAddChange { keySource = ks })-			| S.member (contentLocation ks) openfiles = Left change-		check _ change = Right change--		canceladd (PendingAddChange { keySource = ks }) = do-			warning $ keyFilename ks-				++ " still has writers, not adding"-			-- remove the hard link-			void $ liftIO $ tryIO $-				removeFile $ contentLocation ks-		canceladd _ = noop--		openwrite (_file, mode, _pid) =-			mode == Lsof.OpenWriteOnly || mode == Lsof.OpenReadWrite--		allRight = return . map Right
+ Assistant/Common.hs view
@@ -0,0 +1,45 @@+{- Common infrastructure for the git-annex assistant threads.+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++module Assistant.Common (+	module X,+	ThreadName,+	NamedThread(..),+	runNamedThread,+	debug+) where++import Common.Annex as X+import Assistant.DaemonStatus+import Assistant.Alert++import System.Log.Logger+import qualified Control.Exception as E++type ThreadName = String+data NamedThread = NamedThread ThreadName (IO ())++debug :: ThreadName -> [String] -> IO ()+debug threadname ws = debugM threadname $ unwords $ (threadname ++ ":") : ws++runNamedThread :: DaemonStatusHandle -> NamedThread -> IO ()+runNamedThread dstatus (NamedThread name a) = go+	where+		go = do+			r <- E.try a :: IO (Either E.SomeException ())+			case r of+				Right _ -> noop+				Left e -> do+					let msg = unwords+						[ name+						, "crashed:"+						, show e+						]+					hPutStrLn stderr msg+					-- TODO click to restart+					void $ addAlert dstatus $+						warningAlert name msg
Assistant/DaemonStatus.hs view
@@ -1,20 +1,29 @@ {- git-annex assistant daemon status  -  - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.  -} +{-# LANGUAGE CPP, RankNTypes, ImpredicativeTypes #-}+ module Assistant.DaemonStatus where  import Common.Annex-import Assistant.ThreadedMonad-import Utility.ThreadScheduler+import Assistant.Alert+import Assistant.Pairing import Utility.TempFile+import Utility.NotificationBroadcaster+import Logs.Transfer+import Logs.Trust+import qualified Remote -import Control.Concurrent+import Control.Concurrent.STM import System.Posix.Types import Data.Time.Clock.POSIX import Data.Time import System.Locale+import qualified Data.Map as M  data DaemonStatus = DaemonStatus 	-- False when the daemon is performing its startup scan@@ -25,48 +34,90 @@ 	, sanityCheckRunning :: Bool 	-- Last time the sanity checker ran 	, lastSanityCheck :: Maybe POSIXTime+	-- Currently running file content transfers+	, currentTransfers :: TransferMap+	-- Messages to display to the user.+	, alertMap :: AlertMap+	, lastAlertId :: AlertId+	-- Ordered list of remotes to talk to.+	, knownRemotes :: [Remote]+	-- Pairing request that is in progress.+	, pairingInProgress :: Maybe PairingInProgress+	-- Broadcasts notifications about all changes to the DaemonStatus+	, changeNotifier :: NotificationBroadcaster+	-- Broadcasts notifications when queued or current transfers change.+	, transferNotifier :: NotificationBroadcaster+	-- Broadcasts notifications when there's a change to the alerts+	, alertNotifier :: NotificationBroadcaster 	}-	deriving (Show) -type DaemonStatusHandle = MVar DaemonStatus+type TransferMap = M.Map Transfer TransferInfo -newDaemonStatus :: DaemonStatus+{- This TMVar is never left empty, so accessing it will never block. -}+type DaemonStatusHandle = TMVar DaemonStatus++newDaemonStatus :: IO DaemonStatus newDaemonStatus = DaemonStatus-	{ scanComplete = False-	, lastRunning = Nothing-	, sanityCheckRunning = False-	, lastSanityCheck = Nothing-	}+	<$> pure False+	<*> pure Nothing+	<*> pure False+	<*> pure Nothing+	<*> pure M.empty+	<*> pure M.empty+	<*> pure firstAlertId+	<*> pure []+	<*> pure Nothing+	<*> newNotificationBroadcaster+	<*> newNotificationBroadcaster+	<*> newNotificationBroadcaster -getDaemonStatus :: DaemonStatusHandle -> Annex DaemonStatus-getDaemonStatus = liftIO . readMVar+getDaemonStatus :: DaemonStatusHandle -> IO DaemonStatus+getDaemonStatus = atomically . readTMVar -modifyDaemonStatus :: DaemonStatusHandle -> (DaemonStatus -> DaemonStatus) -> Annex ()-modifyDaemonStatus handle a = liftIO $ modifyMVar_ handle (return . a)+modifyDaemonStatus_ :: DaemonStatusHandle -> (DaemonStatus -> DaemonStatus) -> IO ()+modifyDaemonStatus_ dstatus a = modifyDaemonStatus dstatus $ \s -> (a s, ()) -{- Load any previous daemon status file, and store it in the MVar for this- - process to use as its DaemonStatus. -}+modifyDaemonStatus :: DaemonStatusHandle -> (DaemonStatus -> (DaemonStatus, b)) -> IO b+modifyDaemonStatus dstatus a = do+	(s, b) <- atomically $ do+		r@(s, _) <- a <$> takeTMVar dstatus+		putTMVar dstatus s+		return r+	sendNotification $ changeNotifier s+	return b++{- Remotes ordered by cost, with dead ones thrown out. -}+calcKnownRemotes :: Annex [Remote]+calcKnownRemotes = do+	rs <- concat . Remote.byCost <$> Remote.enabledRemoteList+	alive <- snd <$> trustPartition DeadTrusted (map Remote.uuid rs)+	let good r = Remote.uuid r `elem` alive+	return $ filter good rs++{- Updates the cached ordered list of remotes from the list in Annex+ - state. -}+updateKnownRemotes :: DaemonStatusHandle -> Annex ()+updateKnownRemotes dstatus = do+	remotes <- calcKnownRemotes+	liftIO $ modifyDaemonStatus_ dstatus $+		\s -> s { knownRemotes = remotes }++{- Load any previous daemon status file, and store it in a MVar for this+ - process to use as its DaemonStatus. Also gets current transfer status. -} startDaemonStatus :: Annex DaemonStatusHandle startDaemonStatus = do 	file <- fromRepo gitAnnexDaemonStatusFile 	status <- liftIO $-		catchDefaultIO (readDaemonStatusFile file) newDaemonStatus-	liftIO $ newMVar status+		flip catchDefaultIO (readDaemonStatusFile file) =<< newDaemonStatus+	transfers <- M.fromList <$> getTransfers+	remotes <- calcKnownRemotes+	liftIO $ atomically $ newTMVar status 		{ scanComplete = False 		, sanityCheckRunning = False+		, currentTransfers = transfers+		, knownRemotes = remotes 		} -{- This thread wakes up periodically and writes the daemon status to disk. -}-daemonStatusThread :: ThreadState -> DaemonStatusHandle -> IO ()-daemonStatusThread st handle = do-	checkpoint-	runEvery (Seconds tenMinutes) checkpoint-	where-		checkpoint = runThreadState st $ do-			file <- fromRepo gitAnnexDaemonStatusFile-			status <- getDaemonStatus handle-			liftIO $ writeDaemonStatusFile file status- {- Don't just dump out the structure, because it will change over time,  - and parts of it are not relevant. -} writeDaemonStatusFile :: FilePath -> DaemonStatus -> IO ()@@ -81,9 +132,9 @@ 			]  readDaemonStatusFile :: FilePath -> IO DaemonStatus-readDaemonStatusFile file = parse <$> readFile file+readDaemonStatusFile file = parse <$> newDaemonStatus <*> readFile file 	where-		parse = foldr parseline newDaemonStatus . lines+		parse status = foldr parseline status . lines 		parseline line status 			| key == "lastRunning" = parseval readtime $ \v -> 				status { lastRunning = Just v }@@ -117,3 +168,102 @@  tenMinutes :: Int tenMinutes = 10 * 60++{- Mutates the transfer map. Runs in STM so that the transfer map can+ - be modified in the same transaction that modifies the transfer queue.+ - Note that this does not send a notification of the change; that's left+ - to the caller. -}+adjustTransfersSTM :: DaemonStatusHandle -> (TransferMap -> TransferMap) -> STM ()+adjustTransfersSTM dstatus a = do+	s <- takeTMVar dstatus+	putTMVar dstatus $ s { currentTransfers = a (currentTransfers s) }++{- Alters a transfer's info, if the transfer is in the map. -}+alterTransferInfo :: DaemonStatusHandle -> Transfer -> (TransferInfo -> TransferInfo) -> IO ()+alterTransferInfo dstatus t a = updateTransferInfo' dstatus $ M.adjust a t++{- Updates a transfer's info. Adds the transfer to the map if necessary,+ - or if already present, updates it while preserving the old transferTid,+ - transferPaused, and bytesComplete values, which are not written to disk. -}+updateTransferInfo :: DaemonStatusHandle -> Transfer -> TransferInfo -> IO ()+updateTransferInfo dstatus t info = updateTransferInfo' dstatus $+	M.insertWith' merge t info+	where+		merge new old = new+			{ transferTid = maybe (transferTid new) Just (transferTid old)+			, transferPaused = transferPaused new || transferPaused old+			, bytesComplete = maybe (bytesComplete new) Just (bytesComplete old)+			}++updateTransferInfo' :: DaemonStatusHandle -> (TransferMap -> TransferMap) -> IO ()+updateTransferInfo' dstatus a =+	notifyTransfer dstatus `after` modifyDaemonStatus_ dstatus go+	where+		go s = s { currentTransfers = a (currentTransfers s) }++{- Removes a transfer from the map, and returns its info. -}+removeTransfer :: DaemonStatusHandle -> Transfer -> IO (Maybe TransferInfo)+removeTransfer dstatus t = +	notifyTransfer dstatus `after` modifyDaemonStatus dstatus go+	where+		go s =+			let (info, ts) = M.updateLookupWithKey+				(\_k _v -> Nothing)+				t (currentTransfers s)+			in (s { currentTransfers = ts }, info)++{- Send a notification when a transfer is changed. -}+notifyTransfer :: DaemonStatusHandle -> IO ()+notifyTransfer dstatus = sendNotification+	=<< transferNotifier <$> atomically (readTMVar dstatus)++{- Send a notification when alerts are changed. -}+notifyAlert :: DaemonStatusHandle -> IO ()+notifyAlert dstatus = sendNotification+	=<< alertNotifier <$> atomically (readTMVar dstatus)++{- Returns the alert's identifier, which can be used to remove it. -}+addAlert :: DaemonStatusHandle -> Alert -> IO AlertId+addAlert dstatus alert = notifyAlert dstatus `after` modifyDaemonStatus dstatus go+	where+		go s = (s { lastAlertId = i, alertMap = m }, i)+			where+				i = nextAlertId $ lastAlertId s+				m = mergeAlert i alert (alertMap s)++removeAlert :: DaemonStatusHandle -> AlertId -> IO ()+removeAlert dstatus i = updateAlert dstatus i (const Nothing)++updateAlert :: DaemonStatusHandle -> AlertId -> (Alert -> Maybe Alert) -> IO ()+updateAlert dstatus i a = updateAlertMap dstatus $ \m -> M.update a i m++updateAlertMap :: DaemonStatusHandle -> (AlertMap -> AlertMap) -> IO ()+updateAlertMap dstatus a = notifyAlert dstatus `after` modifyDaemonStatus_ dstatus go+	where+		go s = s { alertMap = a (alertMap s) }++{- Displays an alert while performing an activity that returns True on+ - success.+ -+ - The alert is left visible afterwards, as filler.+ - Old filler is pruned, to prevent the map growing too large. -}+alertWhile :: DaemonStatusHandle -> Alert -> IO Bool -> IO Bool+alertWhile dstatus alert a = alertWhile' dstatus alert $ do+	r <- a+	return (r, r)++{- Like alertWhile, but allows the activity to return a value too. -}+alertWhile' :: DaemonStatusHandle -> Alert -> IO (Bool, a) -> IO a+alertWhile' dstatus alert a = do+	let alert' = alert { alertClass = Activity }+	i <- addAlert dstatus alert'+	(ok, r) <- a+	updateAlertMap dstatus $ mergeAlert i $ makeAlertFiller ok alert'+	return r++{- Displays an alert while performing an activity, then removes it. -}+alertDuring :: DaemonStatusHandle -> Alert -> IO a -> IO a+alertDuring dstatus alert a = do+	let alert' = alert { alertClass = Activity }+	i <- addAlert dstatus alert'+	removeAlert dstatus i `after` a
+ Assistant/MakeRemote.hs view
@@ -0,0 +1,107 @@+{- git-annex assistant remote creation utilities+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++module Assistant.MakeRemote where++import Assistant.Common+import Assistant.ThreadedMonad+import Assistant.DaemonStatus+import Assistant.ScanRemotes+import Assistant.Ssh+import Assistant.Sync+import qualified Types.Remote as R+import qualified Remote+import Remote.List+import qualified Remote.Rsync as Rsync+import qualified Git+import qualified Git.Command+import qualified Command.InitRemote+import Logs.UUID+import Logs.Remote++import qualified Data.Text as T+import qualified Data.Map as M++{- Sets up and begins syncing with a new ssh or rsync remote. -}+makeSshRemote :: ThreadState -> DaemonStatusHandle -> ScanRemoteMap -> Bool -> SshData -> IO ()+makeSshRemote st dstatus scanremotes forcersync sshdata = do+	r <- runThreadState st $+		addRemote $ maker (sshRepoName sshdata) sshurl+	syncNewRemote st dstatus scanremotes r+	where+		rsync = forcersync || rsyncOnly sshdata+		maker+			| rsync = makeRsyncRemote+			| otherwise = makeGitRemote+		sshurl = T.unpack $ T.concat $+			if rsync+				then [u, h, T.pack ":", sshDirectory sshdata, T.pack "/"]+				else [T.pack "ssh://", u, h, d, T.pack "/"]+			where+				u = maybe (T.pack "") (\v -> T.concat [v, T.pack "@"]) $ sshUserName sshdata+				h = sshHostName sshdata+				d+					| T.pack "/" `T.isPrefixOf` sshDirectory sshdata = d+					| otherwise = T.concat [T.pack "/~/", sshDirectory sshdata]+	+{- Runs an action that returns a name of the remote, and finishes adding it. -}+addRemote :: Annex String -> Annex Remote+addRemote a = do+	name <- a+	void remoteListRefresh+	maybe (error "failed to add remote") return =<< Remote.byName (Just name)++{- Inits a rsync special remote, and returns the name of the remote. -}+makeRsyncRemote :: String -> String -> Annex String+makeRsyncRemote name location = makeRemote name location $ const $ do+	(u, c) <- Command.InitRemote.findByName name+	c' <- R.setup Rsync.remote u $ M.union config c+	describeUUID u name+	configSet u c'+	where+		config = M.fromList+			[ ("encryption", "shared")+			, ("rsyncurl", location)+			, ("type", "rsync")+			]++{- Returns the name of the git remote it created. If there's already a+ - remote at the location, returns its name. -}+makeGitRemote :: String -> String -> Annex String+makeGitRemote basename location = makeRemote basename location $ \name ->+	void $ inRepo $+		Git.Command.runBool "remote"+			[Param "add", Param name, Param location]++{- If there's not already a remote at the location, adds it using the+ - action, which is passed the name of the remote to make.+ -+ - Returns the name of the remote. -}+makeRemote :: String -> String -> (String -> Annex ()) -> Annex String+makeRemote basename location a = do+	r <- fromRepo id+	if not (any samelocation $ Git.remotes r)+		then do+			let name = uniqueRemoteName r basename 0+			a name+			return name+		else return basename+	where+		samelocation x = Git.repoLocation x == location++{- Generate an unused name for a remote, adding a number if+ - necessary. -}+uniqueRemoteName :: Git.Repo -> String -> Int -> String+uniqueRemoteName r basename n+	| null namecollision = name+	| otherwise = uniqueRemoteName r basename (succ n)+	where+		namecollision = filter samename (Git.remotes r)+		samename x = Git.remoteName x == Just name+		name+			| n == 0 = basename+			| otherwise = basename ++ show n
+ Assistant/Pairing.hs view
@@ -0,0 +1,85 @@+{- git-annex assistant repo pairing, core data types+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++module Assistant.Pairing where++import Common.Annex+import Utility.Verifiable+import Assistant.Ssh++import Control.Concurrent+import Network.Socket+import Data.Char+import qualified Data.Text as T++data PairStage+	{- "I'll pair with anybody who shares the secret that can be used+	 - to verify this request." -}+	 = PairReq+	{- "I've verified your request, and you can verify this to see+	 - that I know the secret. I set up your ssh key already.+	 - Here's mine for you to set up." -}+	| PairAck+	{- "I saw your PairAck; you can stop sending them." -}+	| PairDone+	deriving (Eq, Read, Show, Ord)++newtype PairMsg = PairMsg (Verifiable (PairStage, PairData, SomeAddr))+	deriving (Eq, Read, Show)++verifiedPairMsg :: PairMsg -> PairingInProgress -> Bool+verifiedPairMsg (PairMsg m) pip = verify m $ inProgressSecret pip++fromPairMsg :: PairMsg -> Verifiable (PairStage, PairData, SomeAddr)+fromPairMsg (PairMsg m) = m++pairMsgStage :: PairMsg -> PairStage+pairMsgStage (PairMsg (Verifiable (s, _, _) _)) = s++pairMsgData :: PairMsg -> PairData+pairMsgData (PairMsg (Verifiable (_, d, _) _)) = d++pairMsgAddr :: PairMsg -> SomeAddr+pairMsgAddr (PairMsg (Verifiable (_, _, a) _)) = a++data PairData = PairData+	-- uname -n output, not a full domain name+	{ remoteHostName :: Maybe HostName+	, remoteUserName :: UserName+	, remoteDirectory :: FilePath+	, remoteSshPubKey :: SshPubKey+	, pairUUID :: UUID+	}+	deriving (Eq, Read, Show)++type UserName = String++{- A pairing that is in progress has a secret, a thread that is+ - broadcasting pairing messages, and a SshKeyPair that has not yet been+ - set up on disk. -}+data PairingInProgress = PairingInProgress+	{ inProgressSecret :: Secret+	, inProgressThreadId :: Maybe ThreadId+	, inProgressSshKeyPair :: SshKeyPair+	, inProgressPairData :: PairData+	, inProgressPairStage :: PairStage+	}+	deriving (Show)++data SomeAddr = IPv4Addr HostAddress | IPv6Addr HostAddress6+	deriving (Ord, Eq, Read, Show)++{- This contains the whole secret, just lightly obfuscated to make it not+ - too obvious. It's only displayed in the user's web browser. -}+newtype SecretReminder = SecretReminder [Int]+	deriving (Show, Eq, Ord, Read)++toSecretReminder :: T.Text -> SecretReminder+toSecretReminder = SecretReminder . map ord . T.unpack++fromSecretReminder :: SecretReminder -> T.Text+fromSecretReminder (SecretReminder s) = T.pack $ map chr s
+ Assistant/Pairing/MakeRemote.hs view
@@ -0,0 +1,93 @@+{- git-annex assistant pairing remote creation+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++module Assistant.Pairing.MakeRemote where++import Assistant.Common+import Assistant.ThreadedMonad+import Assistant.DaemonStatus+import Assistant.ScanRemotes+import Assistant.Ssh+import Assistant.Pairing+import Assistant.Pairing.Network+import Assistant.MakeRemote++import Network.Socket+import qualified Data.Text as T++{- Authorized keys are set up before pairing is complete, so that the other+ - side can immediately begin syncing. -}+setupAuthorizedKeys :: PairMsg -> IO ()+setupAuthorizedKeys msg = do+	validateSshPubKey pubkey+	unlessM (liftIO $ addAuthorizedKeys False pubkey) $+		error "failed setting up ssh authorized keys"+	where+		pubkey = remoteSshPubKey $ pairMsgData msg++{- When pairing is complete, this is used to set up the remote for the host+ - we paired with. -}+finishedPairing :: ThreadState -> DaemonStatusHandle -> ScanRemoteMap -> PairMsg -> SshKeyPair -> IO ()+finishedPairing st dstatus scanremotes msg keypair = do+	sshdata <- setupSshKeyPair keypair =<< pairMsgToSshData msg+	{- Ensure that we know+	 - the ssh host key for the host we paired with.+	 - If we don't, ssh over to get it. -}+	unlessM (knownHost $ sshHostName sshdata) $+		void $ sshTranscript+			[ sshOpt "StrictHostKeyChecking" "no"+			, sshOpt "NumberOfPasswordPrompts" "0"+			, "-n"+			, genSshHost (sshHostName sshdata) (sshUserName sshdata)+			, "git-annex-shell -c configlist " ++ T.unpack (sshDirectory sshdata)+			]+			""+	makeSshRemote st dstatus scanremotes False sshdata++{- Mostly a straightforward conversion.  Except:+ -  * Determine the best hostname to use to contact the host.+ -  * Strip leading ~/ from the directory name.+ -}+pairMsgToSshData :: PairMsg -> IO SshData+pairMsgToSshData msg = do+	let d = pairMsgData msg+	hostname <- liftIO $ bestHostName msg+	let dir = case remoteDirectory d of+		('~':'/':v) -> v+		v -> v+	return SshData+		{ sshHostName = T.pack hostname+		, sshUserName = Just (T.pack $ remoteUserName d)+		, sshDirectory = T.pack dir+		, sshRepoName = genSshRepoName hostname dir+		, needsPubKey = True+		, rsyncOnly = False+		}++{- Finds the best hostname to use for the host that sent the PairMsg.+ -+ - If remoteHostName is set, tries to use a .local address based on it.+ - That's the most robust, if this system supports .local.+ - Otherwise, looks up the hostname in the DNS for the remoteAddress,+ - if any. May fall back to remoteAddress if there's no DNS. Ugh. -}+bestHostName :: PairMsg -> IO HostName+bestHostName msg = case remoteHostName $ pairMsgData msg of+	Just h -> do+		let localname = h ++ ".local"+		addrs <- catchDefaultIO [] $+			getAddrInfo Nothing (Just localname) Nothing+		maybe fallback (const $ return localname) (headMaybe addrs)+	Nothing -> fallback+	where+		fallback = do+			let a = pairMsgAddr msg+			let sockaddr = case a of+				IPv4Addr addr -> SockAddrInet (PortNum 0) addr+				IPv6Addr addr -> SockAddrInet6 (PortNum 0) 0 addr 0+			fromMaybe (showAddr a)+				<$> catchDefaultIO Nothing+					(fst <$> getNameInfo [] True False sockaddr)
+ Assistant/Pairing/Network.hs view
@@ -0,0 +1,126 @@+{- git-annex assistant pairing network code+ -+ - All network traffic is sent over multicast UDP. For reliability,+ - each message is repeated until acknowledged. This is done using a+ - thread, that gets stopped before the next message is sent.+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++module Assistant.Pairing.Network where++import Assistant.Common+import Assistant.Pairing+import Assistant.DaemonStatus+import Utility.ThreadScheduler+import Utility.Verifiable++import Network.Multicast+import Network.Info+import Network.Socket+import Control.Exception (bracket)+import qualified Data.Map as M+import Control.Concurrent++{- This is an arbitrary port in the dynamic port range, that could+ - conceivably be used for some other broadcast messages.+ - If so, hope they ignore the garbage from us; we'll certianly+ - ignore garbage from them. Wild wild west. -}+pairingPort :: PortNumber+pairingPort = 55556++{- This is the All Hosts multicast group, which should reach all hosts+ - on the same network segment. -}+multicastAddress :: SomeAddr -> HostName+multicastAddress (IPv4Addr _) = "224.0.0.1"+multicastAddress (IPv6Addr _) = "ff02::1"++{- Multicasts a message repeatedly on all interfaces, with a 2 second+ - delay between each transmission. The message is repeated forever+ - unless a number of repeats is specified.+ -+ - The remoteHostAddress is set to the interface's IP address.+ -+ - Note that new sockets are opened each time. This is hardly efficient,+ - but it allows new network interfaces to be used as they come up.+ - On the other hand, the expensive DNS lookups are cached.+ -}+multicastPairMsg :: Maybe Int -> Secret -> PairData -> PairStage -> IO ()+multicastPairMsg repeats secret pairdata stage = go M.empty repeats+	where+		go _ (Just 0) = noop+		go cache n = do+			addrs <- activeNetworkAddresses+			let cache' = updatecache cache addrs+			mapM_ (sendinterface cache') addrs+			threadDelaySeconds (Seconds 2)+			go cache' $ pred <$> n+		{- The multicast library currently chokes on ipv6 addresses. -}+		sendinterface _ (IPv6Addr _) = noop+		sendinterface cache i = void $ catchMaybeIO $+			withSocketsDo $ bracket setup cleanup use+			where+				setup = multicastSender (multicastAddress i) pairingPort+				cleanup (sock, _) = sClose sock -- FIXME does not work+				use (sock, addr) = do+					setInterface sock (showAddr i)+					maybe noop (\s -> void $ sendTo sock s addr)+						(M.lookup i cache)+		updatecache cache [] = cache+		updatecache cache (i:is)+			| M.member i cache = updatecache cache is+			| otherwise = updatecache (M.insert i (show $ mkmsg i) cache) is+		mkmsg addr = PairMsg $+			mkVerifiable (stage, pairdata, addr) secret++startSending :: DaemonStatusHandle -> PairingInProgress -> PairStage -> (PairStage -> IO ()) -> IO ()+startSending dstatus pip stage sender = void $ forkIO $ do+	tid <- myThreadId+	let pip' = pip { inProgressPairStage = stage, inProgressThreadId = Just tid }+	oldpip <- modifyDaemonStatus dstatus $+		\s -> (s { pairingInProgress = Just pip' }, pairingInProgress s)+	maybe noop stopold oldpip+	sender stage+	where+		stopold = maybe noop killThread . inProgressThreadId++stopSending :: DaemonStatusHandle ->  PairingInProgress -> IO ()+stopSending dstatus pip = do+	maybe noop killThread $ inProgressThreadId pip+	modifyDaemonStatus_ dstatus $ \s -> s { pairingInProgress = Nothing }++class ToSomeAddr a where+	toSomeAddr :: a -> SomeAddr++instance ToSomeAddr IPv4 where+	toSomeAddr (IPv4 a) = IPv4Addr a++instance ToSomeAddr IPv6 where+	toSomeAddr (IPv6 o1 o2 o3 o4) = IPv6Addr (o1, o2, o3, o4)++showAddr :: SomeAddr -> HostName+showAddr (IPv4Addr a) = show $ IPv4 a+showAddr (IPv6Addr (o1, o2, o3, o4)) = show $ IPv6 o1 o2 o3 o4++activeNetworkAddresses :: IO [SomeAddr]+activeNetworkAddresses = filter (not . all (`elem` "0.:") . showAddr)+	. concatMap (\ni -> [toSomeAddr $ ipv4 ni, toSomeAddr $ ipv6 ni])+	<$> getNetworkInterfaces++{- A human-visible description of the repository being paired with.+ - Note that the repository's description is not shown to the user, because+ - it could be something like "my repo", which is confusing when pairing+ - with someone else's repo. However, this has the same format as the+ - default decription of a repo. -}+pairRepo :: PairMsg -> String+pairRepo msg = concat+	[ remoteUserName d+	, "@"+	, fromMaybe (showAddr $ pairMsgAddr msg) (remoteHostName d)+	, ":"+	, remoteDirectory d+	]+	where+		d = pairMsgData msg
+ Assistant/Pushes.hs view
@@ -0,0 +1,46 @@+{- git-annex assistant push tracking+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++module Assistant.Pushes where++import Common.Annex++import Control.Concurrent.STM+import Data.Time.Clock+import qualified Data.Map as M++{- Track the most recent push failure for each remote. -}+type PushMap = M.Map Remote UTCTime+type FailedPushMap = TMVar PushMap++{- The TMVar starts empty, and is left empty when there are no+ - failed pushes. This way we can block until there are some failed pushes.+ -}+newFailedPushMap :: IO FailedPushMap+newFailedPushMap = atomically newEmptyTMVar++{- Blocks until there are failed pushes.+ - Returns Remotes whose pushes failed a given time duration or more ago.+ - (This may be an empty list.) -}+getFailedPushesBefore :: FailedPushMap -> NominalDiffTime -> IO [Remote]+getFailedPushesBefore v duration = do+	m <- atomically $ readTMVar v+	now <- getCurrentTime+	return $ M.keys $ M.filter (not . toorecent now) m+	where+		toorecent now time = now `diffUTCTime` time < duration++{- Modifies the map. -}+changeFailedPushMap :: FailedPushMap -> (PushMap -> PushMap) -> IO ()+changeFailedPushMap v a = atomically $+	store . a . fromMaybe M.empty =<< tryTakeTMVar v+	where+ 		{- tryTakeTMVar empties the TMVar; refill it only if+		 - the modified map is not itself empty -}+		store m+			| m == M.empty = noop+			| otherwise = putTMVar v $! m
− Assistant/SanityChecker.hs
@@ -1,81 +0,0 @@-{- git-annex assistant sanity checker- -- - Copyright 2012 Joey Hess <joey@kitenet.net>- -}--module Assistant.SanityChecker (-	sanityCheckerThread-) where--import Common.Annex-import qualified Git.LsFiles-import Assistant.DaemonStatus-import Assistant.ThreadedMonad-import Assistant.Changes-import Utility.ThreadScheduler-import qualified Assistant.Watcher--import Data.Time.Clock.POSIX--{- This thread wakes up occasionally to make sure the tree is in good shape. -}-sanityCheckerThread :: ThreadState -> DaemonStatusHandle -> ChangeChan -> IO ()-sanityCheckerThread st status changechan = forever $ do-	waitForNextCheck st status--	runThreadState st $-		modifyDaemonStatus status $ \s -> s-				{ sanityCheckRunning = True }--	now <- getPOSIXTime -- before check started-	catchIO (check st status changechan)-		(runThreadState st . warning . show)--	runThreadState st $ do-		modifyDaemonStatus status $ \s -> s-			{ sanityCheckRunning = False-			, lastSanityCheck = Just now-			}--{- Only run one check per day, from the time of the last check. -}-waitForNextCheck :: ThreadState -> DaemonStatusHandle -> IO ()-waitForNextCheck st status = do-	v <- runThreadState st $-		lastSanityCheck <$> getDaemonStatus status-	now <- getPOSIXTime-	threadDelaySeconds $ Seconds $ calcdelay now v-	where-		calcdelay _ Nothing = oneDay-		calcdelay now (Just lastcheck)-			| lastcheck < now = max oneDay $-				oneDay - truncate (now - lastcheck)-			| otherwise = oneDay--oneDay :: Int-oneDay = 24 * 60 * 60--{- It's important to stay out of the Annex monad as much as possible while- - running potentially expensive parts of this check, since remaining in it- - will block the watcher. -}-check :: ThreadState -> DaemonStatusHandle -> ChangeChan -> IO () -check st status changechan = do-	g <- runThreadState st $ do-		showSideAction "Running daily check"-		fromRepo id-	-- Find old unstaged symlinks, and add them to git.-	unstaged <- Git.LsFiles.notInRepo False ["."] g-	now <- getPOSIXTime-	forM_ unstaged $ \file -> do-		ms <- catchMaybeIO $ getSymbolicLinkStatus file-		case ms of-			Just s	| toonew (statusChangeTime s) now -> noop-				| isSymbolicLink s ->-					addsymlink file ms-			_ -> noop-	where-		toonew timestamp now = now < (realToFrac (timestamp + slop) :: POSIXTime)-		slop = fromIntegral tenMinutes-		insanity m = runThreadState st $ warning m-		addsymlink file s = do-			insanity $ "found unstaged symlink: " ++ file-			Assistant.Watcher.runHandler st status changechan-				Assistant.Watcher.onAddSymlink file s
+ Assistant/ScanRemotes.hs view
@@ -0,0 +1,48 @@+{- git-annex assistant remotes needing scanning+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++module Assistant.ScanRemotes where++import Common.Annex+import qualified Types.Remote as Remote++import Data.Function+import Control.Concurrent.STM+import qualified Data.Map as M++data ScanInfo = ScanInfo+	{ scanPriority :: Int+	, fullScan :: Bool+	}++type ScanRemoteMap = TMVar (M.Map Remote ScanInfo)++{- The TMVar starts empty, and is left empty when there are no remotes+ - to scan. -}+newScanRemoteMap :: IO ScanRemoteMap+newScanRemoteMap = atomically newEmptyTMVar++{- Blocks until there is a remote or remotes that need to be scanned.+ -+ - The list has higher priority remotes listed first. -}+getScanRemote :: ScanRemoteMap -> IO [(Remote, ScanInfo)]+getScanRemote v = atomically $+	reverse . sortBy (compare `on` scanPriority . snd) . M.toList+		<$> takeTMVar v++{- Adds new remotes that need scanning. -}+addScanRemotes :: ScanRemoteMap -> Bool -> [Remote] -> IO ()+addScanRemotes _ _ [] = noop+addScanRemotes v full rs = atomically $ do+	m <- fromMaybe M.empty <$> tryTakeTMVar v+	putTMVar v $ M.unionWith merge (M.fromList $ zip rs (map info rs)) m+	where+		info r = ScanInfo (-1 * Remote.cost r) full+		merge x y = ScanInfo+			{ scanPriority = max (scanPriority x) (scanPriority y)+			, fullScan = fullScan x || fullScan y +			}
+ Assistant/Ssh.hs view
@@ -0,0 +1,210 @@+{- git-annex assistant ssh utilities+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++module Assistant.Ssh where++import Common.Annex+import Utility.TempFile++import Data.Text (Text)+import qualified Data.Text as T+import qualified Control.Exception as E+import System.Process (CreateProcess(..))+import Control.Concurrent+import Data.Char++data SshData = SshData+	{ sshHostName :: Text+	, sshUserName :: Maybe Text+	, sshDirectory :: Text+	, sshRepoName :: String+	, needsPubKey :: Bool+	, rsyncOnly :: Bool+	}+	deriving (Read, Show, Eq)++data SshKeyPair = SshKeyPair+	{ sshPubKey :: String+	, sshPrivKey :: String+	}++instance Show SshKeyPair where+	show = sshPubKey++type SshPubKey = String++{- ssh -ofoo=bar command-line option -}+sshOpt :: String -> String -> String+sshOpt k v = concat ["-o", k, "=", v]++sshDir :: IO FilePath+sshDir = do+	home <- myHomeDir+	return $ home </> ".ssh"++{- user@host or host -}+genSshHost :: Text -> Maybe Text -> String+genSshHost host user = maybe "" (\v -> T.unpack v ++ "@") user ++ T.unpack host++{- host_dir, with all / in dir replaced by _, and bad characters removed -}+genSshRepoName :: String -> FilePath -> String+genSshRepoName host dir+	| null dir = filter legal host+	| otherwise = filter legal $ host ++ "_" ++ replace "/" "_" dir+	where+		legal '_' = True+		legal c = isAlphaNum c++{- The output of ssh, including both stdout and stderr. -}+sshTranscript :: [String] -> String -> IO (String, Bool)+sshTranscript opts input = do+	(readf, writef) <- createPipe+	readh <- fdToHandle readf+	writeh <- fdToHandle writef+	(Just inh, _, _, pid) <- createProcess $+		(proc "ssh" opts)+			{ std_in = CreatePipe+			, std_out = UseHandle writeh+			, std_err = UseHandle writeh+			}+	hClose writeh++	-- fork off a thread to start consuming the output+	transcript <- hGetContents readh+	outMVar <- newEmptyMVar+	_ <- forkIO $ E.evaluate (length transcript) >> putMVar outMVar ()++	-- now write and flush any input+	unless (null input) $ do+		hPutStr inh input+		hFlush inh+	hClose inh -- done with stdin++	-- wait on the output+	takeMVar outMVar+	hClose readh++	ok <- checkSuccessProcess pid+	return ()+	return (transcript, ok)++{- Ensure that the ssh public key doesn't include any ssh options, like+ - command=foo, or other weirdness -}+validateSshPubKey :: SshPubKey -> IO ()+validateSshPubKey pubkey = do+	let ws = words pubkey+	when (length ws > 3 || length ws < 2) $+		error $ "wrong number of words in ssh public key " ++ pubkey+	let (ssh, keytype) = separate (== '-') (ws !! 0)+	unless (ssh == "ssh" && all isAlphaNum keytype) $+		error $ "bad ssh public key prefix " ++ ws !! 0+	when (length ws == 3) $+		unless (all (\c -> isAlphaNum c || c == '@') (ws !! 2)) $+			error $ "bad comment in ssh public key " ++ pubkey++addAuthorizedKeys :: Bool -> SshPubKey -> IO Bool+addAuthorizedKeys rsynconly pubkey = boolSystem "sh"+	[ Param "-c" , Param $ addAuthorizedKeysCommand rsynconly pubkey ]++removeAuthorizedKeys :: Bool -> SshPubKey -> IO ()+removeAuthorizedKeys rsynconly pubkey = do+	let keyline = authorizedKeysLine rsynconly pubkey+	sshdir <- sshDir+	let keyfile = sshdir </> ".authorized_keys"+	ls <- lines <$> readFileStrict keyfile+	writeFile keyfile $ unlines $ filter (/= keyline) ls++{- Implemented as a shell command, so it can be run on remote servers over+ - ssh. -}+addAuthorizedKeysCommand :: Bool -> SshPubKey -> String+addAuthorizedKeysCommand rsynconly pubkey = join "&&"+	[ "mkdir -p ~/.ssh"+	, "touch ~/.ssh/authorized_keys"+	, "chmod 600 ~/.ssh/authorized_keys"+	, unwords+		[ "echo"+		, shellEscape $ authorizedKeysLine rsynconly pubkey+		, ">>~/.ssh/authorized_keys"+		]+	]++authorizedKeysLine :: Bool -> SshPubKey -> String+authorizedKeysLine rsynconly pubkey+	{- TODO: Locking down rsync is difficult, requiring a rather+	 - long perl script. -}+	| rsynconly = pubkey+	| otherwise = limitcommand "git-annex-shell -c" ++ pubkey+	where+		limitcommand c = "command=\"perl -e 'exec qw(" ++ c ++ "), $ENV{SSH_ORIGINAL_COMMAND}'\",no-agent-forwarding,no-port-forwarding,no-X11-forwarding "++{- Generates a ssh key pair. -}+genSshKeyPair :: IO SshKeyPair+genSshKeyPair = withTempDir "git-annex-keygen" $ \dir -> do+	ok <- boolSystem "ssh-keygen"+		[ Param "-P", Param "" -- no password+		, Param "-f", File $ dir </> "key"+		]+	unless ok $+		error "ssh-keygen failed"+	SshKeyPair+		<$> readFile (dir </> "key.pub")+		<*> readFile (dir </> "key")++{- Installs a ssh key pair, and sets up ssh config with a mangled hostname+ - that will enable use of the key. This way we avoid changing the user's+ - regular ssh experience at all. Returns a modified SshData containing the+ - mangled hostname. -}+setupSshKeyPair :: SshKeyPair -> SshData -> IO SshData+setupSshKeyPair sshkeypair sshdata = do+	sshdir <- sshDir+	let configfile = sshdir </> "config"+	createDirectoryIfMissing True sshdir++	unlessM (doesFileExist $ sshdir </> sshprivkeyfile) $ do+		h <- fdToHandle =<<+			createFile (sshdir </> sshprivkeyfile)+				(unionFileModes ownerWriteMode ownerReadMode)+		hPutStr h (sshPrivKey sshkeypair)+		hClose h+	unlessM (doesFileExist $ sshdir </> sshpubkeyfile) $+		writeFile (sshdir </> sshpubkeyfile) (sshPubKey sshkeypair)++	unlessM (catchBoolIO $ isInfixOf mangledhost <$> readFile configfile) $+		appendFile configfile $ unlines+			[ ""+			, "# Added automatically by git-annex"+			, "Host " ++ mangledhost+			, "\tHostname " ++ T.unpack (sshHostName sshdata)+			, "\tIdentityFile ~/.ssh/" ++ sshprivkeyfile+			]++	return $ sshdata { sshHostName = T.pack mangledhost }+	where+		sshprivkeyfile = "key." ++ mangledhost+		sshpubkeyfile = sshprivkeyfile ++ ".pub"+		mangledhost = mangleSshHostName+			(T.unpack $ sshHostName sshdata)+			(T.unpack <$> sshUserName sshdata)++mangleSshHostName :: String -> Maybe String -> String+mangleSshHostName host user = "git-annex-" ++ host ++ (maybe "-" ('-':) user)++unMangleSshHostName :: String -> String+unMangleSshHostName h+	| "git-annex-" `isPrefixOf` h = join "-" (beginning $ drop 2 dashbits)+	| otherwise = h+	where+		dashbits = split "-" h++{- Does ssh have known_hosts data for a hostname? -}+knownHost :: Text -> IO Bool+knownHost hostname = do+	sshdir <- sshDir+	ifM (doesFileExist $ sshdir </> "known_hosts")+		( not . null <$> readProcess "ssh-keygen" ["-F", T.unpack hostname]+		, return False+		)
+ Assistant/Sync.hs view
@@ -0,0 +1,160 @@+{- git-annex assistant repo syncing+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++module Assistant.Sync where++import Assistant.Common+import Assistant.Pushes+import Assistant.Alert+import Assistant.ThreadedMonad+import Assistant.DaemonStatus+import Assistant.ScanRemotes+import qualified Command.Sync+import Utility.Parallel+import qualified Git+import qualified Git.Branch+import qualified Git.Ref+import qualified Git.Command+import qualified Remote+import qualified Types.Remote as Remote+import qualified Annex.Branch+import Annex.UUID++import Data.Time.Clock+import qualified Data.Map as M+import Control.Concurrent++{- Syncs with remotes that may have been disconnected for a while.+ - + - First gets git in sync, and then prepares any necessary file transfers.+ -+ - An expensive full scan is queued when the git-annex branches of some of+ - the remotes have diverged from the local git-annex branch. Otherwise,+ - it's sufficient to requeue failed transfers.+ -}+reconnectRemotes :: ThreadName -> ThreadState -> DaemonStatusHandle -> ScanRemoteMap -> [Remote] -> IO ()+reconnectRemotes _ _ _ _ [] = noop+reconnectRemotes threadname st dstatus scanremotes rs = void $+	alertWhile dstatus (syncAlert rs) $ do+		(ok, diverged) <- sync+			=<< runThreadState st (inRepo Git.Branch.current)+		addScanRemotes scanremotes diverged rs+		return ok+	where+		(gitremotes, _specialremotes) =+			partition (Git.repoIsUrl . Remote.repo) rs+		sync (Just branch) = do+			diverged <- manualPull st (Just branch) gitremotes+			now <- getCurrentTime+			ok <- pushToRemotes threadname now st Nothing gitremotes+			return (ok, diverged)+		{- No local branch exists yet, but we can try pulling. -}+		sync Nothing = do+			diverged <- manualPull st Nothing gitremotes+			return (True, diverged)++{- Updates the local sync branch, then pushes it to all remotes, in+ - parallel, along with the git-annex branch. This is the same+ - as "git annex sync", except in parallel, and will co-exist with use of+ - "git annex sync".+ -+ - Avoids running possibly long-duration commands in the Annex monad, so+ - as not to block other threads.+ -+ - This can fail, when the remote's sync branch (or git-annex branch) has+ - been updated by some other remote pushing into it, or by the remote+ - itself. To handle failure, a manual pull and merge is done, and the push+ - is retried.+ -+ - When there's a lot of activity, we may fail more than once.+ - On the other hand, we may fail because the remote is not available.+ - Rather than retrying indefinitely, after the first retry we enter a+ - fallback mode, where our push is guarenteed to succeed if the remote is+ - reachable. If the fallback fails, the push is queued to be retried+ - later.+ -+ - The fallback mode pushes to branches on the remote that have our uuid in+ - them. While ugly, those branches are reserved for pushing by us, and+ - so our pushes will succeed.+ -}+pushToRemotes :: ThreadName -> UTCTime -> ThreadState -> Maybe FailedPushMap -> [Remote] -> IO Bool+pushToRemotes threadname now st mpushmap remotes = do+	(g, branch, u) <- runThreadState st $ (,,)+		<$> fromRepo id+		<*> inRepo Git.Branch.current+		<*> getUUID+	go True branch g u remotes+	where+		go _ Nothing _ _ _ = return True -- no branch, so nothing to do+		go shouldretry (Just branch) g u rs =  do+			debug threadname+				[ "pushing to"+				, show rs+				]+			Command.Sync.updateBranch (Command.Sync.syncBranch branch) g+			(succeeded, failed) <- inParallel (push g branch) rs+			updatemap succeeded []+			let ok = null failed+			if ok+				then return ok+				else if shouldretry+					then retry branch g u failed+					else fallback branch g u failed++		updatemap succeeded failed = case mpushmap of+			Nothing -> noop+			Just pushmap -> changeFailedPushMap pushmap $ \m ->+				M.union (makemap failed) $+					M.difference m (makemap succeeded)+		makemap l = M.fromList $ zip l (repeat now)++		retry branch g u rs = do+			debug threadname [ "trying manual pull to resolve failed pushes" ]+			void $ manualPull st (Just branch) rs+			go False (Just branch) g u rs++		fallback branch g u rs = do+			debug threadname+				[ "fallback pushing to"+				, show rs+				]+			(succeeded, failed) <- inParallel (pushfallback g u branch) rs+			updatemap succeeded failed+			return $ null failed+			+		push g branch remote = Command.Sync.pushBranch remote branch g+		pushfallback g u branch remote = Git.Command.runBool "push"+			[ Param $ Remote.name remote+			, Param $ refspec Annex.Branch.name+			, Param $ refspec branch+			] g+			where+				{- Push to refs/synced/uuid/branch; this+				 - avoids cluttering up the branch display. -}+				refspec b = concat+					[ s+					, ":"+					, "refs/synced/" ++ fromUUID u ++ "/" ++ s+					]+					where s = show $ Git.Ref.base b++{- Manually pull from remotes and merge their branches. -}+manualPull :: ThreadState -> Maybe Git.Ref -> [Remote] -> IO Bool+manualPull st currentbranch remotes = do+	g <- runThreadState st $ fromRepo id+	forM_ remotes $ \r ->+		Git.Command.runBool "fetch" [Param $ Remote.name r] g+	haddiverged <- runThreadState st Annex.Branch.forceUpdate+	forM_ remotes $ \r ->+		runThreadState st $ Command.Sync.mergeRemote r currentbranch+	return haddiverged++{- Start syncing a newly added remote, using a background thread. -}+syncNewRemote :: ThreadState -> DaemonStatusHandle -> ScanRemoteMap -> Remote -> IO ()+syncNewRemote st dstatus scanremotes remote = do+	runThreadState st $ updateKnownRemotes dstatus+	void $ forkIO $ reconnectRemotes "SyncRemote" st dstatus scanremotes [remote]
Assistant/ThreadedMonad.hs view
@@ -1,17 +1,17 @@ {- making the Annex monad available across threads  -  - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.  -} -{-# LANGUAGE BangPatterns #-}- module Assistant.ThreadedMonad where  import Common.Annex import qualified Annex  import Control.Concurrent-import Control.Exception (throw)+import Data.Tuple  {- The Annex state is stored in a MVar, so that threaded actions can access  - it. -}@@ -32,13 +32,7 @@  {- Runs an Annex action, using the state from the MVar.   -- - This serializes calls by threads. -}+ - This serializes calls by threads; only one thread can run in Annex at a+ - time. -} runThreadState :: ThreadState -> Annex a -> IO a-runThreadState mvar a = do-	startstate <- takeMVar mvar-	-- catch IO errors and rethrow after restoring the MVar-	!(r, newstate) <- catchIO (Annex.run startstate a) $ \e -> do-		putMVar mvar startstate-		throw e-	putMVar mvar newstate-	return r+runThreadState mvar a = modifyMVar mvar $ \state -> swap <$> Annex.run state a
+ Assistant/Threads/Committer.hs view
@@ -0,0 +1,244 @@+{- git-annex assistant commit thread+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++module Assistant.Threads.Committer where++import Assistant.Common+import Assistant.Changes+import Assistant.Commits+import Assistant.Alert+import Assistant.ThreadedMonad+import Assistant.Threads.Watcher+import Assistant.TransferQueue+import Assistant.DaemonStatus+import Logs.Transfer+import qualified Annex+import qualified Annex.Queue+import qualified Git.Command+import qualified Git.HashObject+import qualified Git.Version+import Git.Types+import qualified Command.Add+import Utility.ThreadScheduler+import qualified Utility.Lsof as Lsof+import qualified Utility.DirWatcher as DirWatcher+import Types.KeySource++import Data.Time.Clock+import Data.Tuple.Utils+import qualified Data.Set as S+import Data.Either++thisThread :: ThreadName+thisThread = "Committer"++{- This thread makes git commits at appropriate times. -}+commitThread :: ThreadState -> ChangeChan -> CommitChan -> TransferQueue -> DaemonStatusHandle -> NamedThread+commitThread st changechan commitchan transferqueue dstatus = thread $ runEvery (Seconds 1) $ do+	-- We already waited one second as a simple rate limiter.+	-- Next, wait until at least one change is available for+	-- processing.+	changes <- getChanges changechan+	-- Now see if now's a good time to commit.+	time <- getCurrentTime+	if shouldCommit time changes+		then do+			readychanges <- handleAdds st changechan transferqueue dstatus changes+			if shouldCommit time readychanges+				then do+					debug thisThread+						[ "committing"+						, show (length readychanges)+						, "changes"+						]+					void $ alertWhile dstatus commitAlert $+						runThreadState st commitStaged+					recordCommit commitchan (Commit time)+				else refill readychanges+		else refill changes+	where+		thread = NamedThread thisThread+		refill [] = noop+		refill cs = do+			debug thisThread+				[ "delaying commit of"+				, show (length cs)+				, "changes"+				]+			refillChanges changechan cs+			++commitStaged :: Annex Bool+commitStaged = do+	Annex.Queue.flush+	void $ inRepo $ Git.Command.runBool "commit" $ nomessage+		[ Param "--quiet"+		{- Avoid running the usual git-annex pre-commit hook;+		 - watch does the same symlink fixing, and we don't want+		 - to deal with unlocked files in these commits. -}+		, Param "--no-verify"+		]+	{- Empty commits may be made if tree changes cancel+	 - each other out, etc. Git returns nonzero on those, so+	 - don't propigate out commit failures. -}+	return True+	where+		nomessage ps+			| Git.Version.older "1.7.2" = Param "-m"+				: Param "autocommit" : ps+			| otherwise = Param "--allow-empty-message" +				: Param "-m" : Param "" : ps++{- Decide if now is a good time to make a commit.+ - Note that the list of change times has an undefined order.+ -+ - Current strategy: If there have been 10 changes within the past second,+ - a batch activity is taking place, so wait for later.+ -}+shouldCommit :: UTCTime -> [Change] -> Bool+shouldCommit now changes+	| len == 0 = False+	| len > 10000 = True -- avoid bloating queue too much+	| length (filter thisSecond changes) < 10 = True+	| otherwise = False -- batch activity+	where+		len = length changes+		thisSecond c = now `diffUTCTime` changeTime c <= 1++{- If there are PendingAddChanges, the files have not yet actually been+ - added to the annex (probably), and that has to be done now, before+ - committing.+ -+ - Deferring the adds to this point causes batches to be bundled together,+ - which allows faster checking with lsof that the files are not still open+ - for write by some other process.+ -+ - When a file is added, Inotify will notice the new symlink. So this waits+ - for additional Changes to arrive, so that the symlink has hopefully been+ - staged before returning, and will be committed immediately.+ -+ - OTOH, for kqueue, eventsCoalesce, so instead the symlink is directly+ - created and staged.+ -+ - Returns a list of all changes that are ready to be committed.+ - Any pending adds that are not ready yet are put back into the ChangeChan,+ - where they will be retried later.+ -}+handleAdds :: ThreadState -> ChangeChan -> TransferQueue -> DaemonStatusHandle -> [Change] -> IO [Change]+handleAdds st changechan transferqueue dstatus cs = returnWhen (null pendingadds) $ do+	(postponed, toadd) <- partitionEithers <$>+		safeToAdd st pendingadds++	unless (null postponed) $+		refillChanges changechan postponed++	returnWhen (null toadd) $ do+		added <- catMaybes <$> forM toadd add+		if DirWatcher.eventsCoalesce || null added+			then return $ added ++ otherchanges+			else do+				r <- handleAdds st changechan transferqueue dstatus+					=<< getChanges changechan+				return $ r ++ added ++ otherchanges+	where+		(pendingadds, otherchanges) = partition isPendingAddChange cs++		returnWhen c a+			| c = return otherchanges+			| otherwise = a++		add :: Change -> IO (Maybe Change)+		add change@(PendingAddChange { keySource = ks }) =+			alertWhile' dstatus (addFileAlert $ keyFilename ks) $+				liftM ret $ catchMaybeIO $+					sanitycheck ks $ runThreadState st $ do+						showStart "add" $ keyFilename ks+						key <- Command.Add.ingest ks+						handle (finishedChange change) (keyFilename ks) key+			where+				{- Add errors tend to be transient and will+				 - be automatically dealt with, so don't+				 - pass to the alert code. -}+				ret (Just j@(Just _)) = (True, j)+				ret _ = (True, Nothing)+		add _ = return Nothing++		handle _ _ Nothing = do+			showEndFail+			return Nothing+		handle change file (Just key) = do+			link <- Command.Add.link file key True+			when DirWatcher.eventsCoalesce $ do+				sha <- inRepo $+					Git.HashObject.hashObject BlobObject link+				stageSymlink file sha+			queueTransfers Next transferqueue dstatus key (Just file) Upload+			showEndOk+			return $ Just change++		{- Check that the keysource's keyFilename still exists,+		 - and is still a hard link to its contentLocation,+		 - before ingesting it. -}+		sanitycheck keysource a = do+			fs <- getSymbolicLinkStatus $ keyFilename keysource+			ks <- getSymbolicLinkStatus $ contentLocation keysource+			if deviceID ks == deviceID fs && fileID ks == fileID fs+				then a+				else return Nothing++{- PendingAddChanges can Either be Right to be added now,+ - or are unsafe, and must be Left for later.+ -+ - Check by running lsof on the temp directory, which+ - the KeySources are locked down in.+ -}+safeToAdd :: ThreadState -> [Change] -> IO [Either Change Change]+safeToAdd st changes = runThreadState st $+	ifM (Annex.getState Annex.force)+		( allRight changes -- force bypasses lsof check+		, do+			tmpdir <- fromRepo gitAnnexTmpDir+			openfiles <- S.fromList . map fst3 . filter openwrite <$>+				liftIO (Lsof.queryDir tmpdir)++			-- TODO this is here for debugging a problem on+			-- OSX, and is pretty expensive, so remove later+			liftIO $ debug thisThread+				[ "checking changes:"+				, show changes+				, "vs open files:"+				, show openfiles+				]+			+			let checked = map (check openfiles) changes++			{- If new events are received when files are closed,+			 - there's no need to retry any changes that cannot+			 - be done now. -}+			if DirWatcher.closingTracked+				then do+					mapM_ canceladd $ lefts checked+					allRight $ rights checked+				else return checked+		)+	where+		check openfiles change@(PendingAddChange { keySource = ks })+			| S.member (contentLocation ks) openfiles = Left change+		check _ change = Right change++		canceladd (PendingAddChange { keySource = ks }) = do+			warning $ keyFilename ks+				++ " still has writers, not adding"+			-- remove the hard link+			void $ liftIO $ tryIO $+				removeFile $ contentLocation ks+		canceladd _ = noop++		openwrite (_file, mode, _pid) =+			mode == Lsof.OpenWriteOnly || mode == Lsof.OpenReadWrite++		allRight = return . map Right
+ Assistant/Threads/DaemonStatus.hs view
@@ -0,0 +1,36 @@+{- git-annex assistant daemon status thread+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++module Assistant.Threads.DaemonStatus where++import Assistant.Common+import Assistant.DaemonStatus+import Assistant.ThreadedMonad+import Utility.ThreadScheduler+import Utility.NotificationBroadcaster++thisThread :: ThreadName+thisThread = "DaemonStatus"++{- This writes the daemon status to disk, when it changes, but no more+ - frequently than once every ten minutes.+ -}+daemonStatusThread :: ThreadState -> DaemonStatusHandle -> NamedThread+daemonStatusThread st dstatus = thread $ do+	notifier <- newNotificationHandle+		=<< changeNotifier <$> getDaemonStatus dstatus+	checkpoint+	runEvery (Seconds tenMinutes) $ do+		waitNotification notifier+		checkpoint+	where+		thread = NamedThread thisThread+		checkpoint = do+			status <- getDaemonStatus dstatus+			file <- runThreadState st $ fromRepo gitAnnexDaemonStatusFile+			writeDaemonStatusFile file status+
+ Assistant/Threads/Merger.hs view
@@ -0,0 +1,104 @@+{- git-annex assistant git merge thread+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++module Assistant.Threads.Merger where++import Assistant.Common+import Assistant.ThreadedMonad+import Assistant.DaemonStatus+import Assistant.TransferQueue+import Utility.DirWatcher+import Utility.Types.DirWatcher+import qualified Annex.Branch+import qualified Git+import qualified Git.Merge+import qualified Git.Branch++thisThread :: ThreadName+thisThread = "Merger"++{- This thread watches for changes to .git/refs/, and handles incoming+ - pushes. -}+mergeThread :: ThreadState -> DaemonStatusHandle -> TransferQueue -> NamedThread+mergeThread st dstatus transferqueue = thread $ do+	g <- runThreadState st $ fromRepo id+	let dir = Git.localGitDir g </> "refs"+	createDirectoryIfMissing True dir+	let hook a = Just $ runHandler st dstatus transferqueue a+	let hooks = mkWatchHooks+		{ addHook = hook onAdd+		, errHook = hook onErr+		}+	void $ watchDir dir (const False) hooks id+	debug thisThread ["watching", dir]+	where+		thread = NamedThread thisThread++type Handler = ThreadState -> DaemonStatusHandle -> TransferQueue -> FilePath -> Maybe FileStatus -> IO ()++{- Runs an action handler.+ -+ - Exceptions are ignored, otherwise a whole thread could be crashed.+ -}+runHandler :: ThreadState -> DaemonStatusHandle -> TransferQueue -> Handler -> FilePath -> Maybe FileStatus -> IO ()+runHandler st dstatus transferqueue handler file filestatus = void $+        either print (const noop) =<< tryIO go+        where+                go = handler st dstatus transferqueue file filestatus++{- Called when there's an error with inotify. -}+onErr :: Handler+onErr _ _ _ msg _ = error msg++{- Called when a new branch ref is written.+ -+ - This relies on git's atomic method of updating branch ref files,+ - which is to first write the new file to .lock, and then rename it+ - over the old file. So, ignore .lock files, and the rename ensures+ - the watcher sees a new file being added on each update.+ -+ - At startup, synthetic add events fire, causing this to run, but that's+ - ok; it ensures that any changes pushed since the last time the assistant+ - ran are merged in.+ -}+onAdd :: Handler+onAdd st dstatus transferqueue file _+	| ".lock" `isSuffixOf` file = noop+	| isAnnexBranch file = runThreadState st $+		whenM Annex.Branch.forceUpdate $+			queueDeferredDownloads Later transferqueue dstatus+	| "/synced/" `isInfixOf` file = runThreadState st $ do+		mergecurrent =<< inRepo Git.Branch.current+	| otherwise = noop+	where+		changedbranch = fileToBranch file+		mergecurrent (Just current)+			| equivBranches changedbranch current = do+				liftIO $ debug thisThread+					[ "merging"+					, show changedbranch+					, "into"+					, show current+					]+				void $ inRepo $+					Git.Merge.mergeNonInteractive changedbranch+		mergecurrent _ = noop++equivBranches :: Git.Ref -> Git.Ref -> Bool+equivBranches x y = base x == base y+	where+		base = takeFileName . show++isAnnexBranch :: FilePath -> Bool+isAnnexBranch f = n `isSuffixOf` f+	where+		n = "/" ++ show Annex.Branch.name++fileToBranch :: FilePath -> Git.Ref+fileToBranch f = Git.Ref $ "refs" </> base+	where+		base = Prelude.last $ split "/refs/" f
+ Assistant/Threads/MountWatcher.hs view
@@ -0,0 +1,191 @@+{- git-annex assistant mount watcher, using either dbus or mtab polling+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++{-# LANGUAGE CPP #-}+{-# LANGUAGE OverloadedStrings #-}++module Assistant.Threads.MountWatcher where++import Assistant.Common+import Assistant.ThreadedMonad+import Assistant.DaemonStatus+import Assistant.ScanRemotes+import Assistant.Sync+import qualified Annex+import qualified Git+import Utility.ThreadScheduler+import Utility.Mounts+import Remote.List+import qualified Types.Remote as Remote++import Control.Concurrent+import qualified Control.Exception as E+import qualified Data.Set as S++#if WITH_DBUS+import Utility.DBus+import DBus.Client+import DBus+import Data.Word (Word32)+#else+#warning Building without dbus support; will use mtab polling+#endif++thisThread :: ThreadName+thisThread = "MountWatcher"++mountWatcherThread :: ThreadState -> DaemonStatusHandle -> ScanRemoteMap -> NamedThread+mountWatcherThread st handle scanremotes = thread $+#if WITH_DBUS+	dbusThread st handle scanremotes+#else+	pollingThread st handle scanremotes+#endif+	where+		thread = NamedThread thisThread++#if WITH_DBUS++dbusThread :: ThreadState -> DaemonStatusHandle -> ScanRemoteMap -> IO ()+dbusThread st dstatus scanremotes = E.catch (go =<< connectSession) onerr+	where+		go client = ifM (checkMountMonitor client)+			( do+				{- Store the current mount points in an mvar,+				 - to be compared later. We could in theory+				 - work out the mount point from the dbus+				 - message, but this is easier. -}+				mvar <- newMVar =<< currentMountPoints+				forM_ mountChanged $ \matcher ->+					listen client matcher $ \_event -> do+						nowmounted <- currentMountPoints+						wasmounted <- swapMVar mvar nowmounted+						handleMounts st dstatus scanremotes wasmounted nowmounted+			, do+				runThreadState st $+					warning "No known volume monitor available through dbus; falling back to mtab polling"+				pollinstead+			)+		onerr :: E.SomeException -> IO ()+		onerr e = do+			runThreadState st $+				warning $ "Failed to use dbus; falling back to mtab polling (" ++ show e ++ ")"+			pollinstead+		pollinstead = pollingThread st dstatus scanremotes++{- Examine the list of services connected to dbus, to see if there+ - are any we can use to monitor mounts. If not, will attempt to start one. -}+checkMountMonitor :: Client -> IO Bool+checkMountMonitor client = do+	running <- filter (`elem` usableservices)+		<$> listServiceNames client+	case running of+		[] -> startOneService client startableservices+		(service:_) -> do+			debug thisThread [ "Using running DBUS service"+				, service+				, "to monitor mount events."+				]+			return True+	where+		startableservices = [gvfs]+		usableservices = startableservices ++ [kde]+		gvfs = "org.gtk.Private.GduVolumeMonitor"+		kde = "org.kde.DeviceNotifications"++startOneService :: Client -> [ServiceName] -> IO Bool+startOneService _ [] = return False+startOneService client (x:xs) = do+	_ <- callDBus client "StartServiceByName"+		[toVariant x, toVariant (0 :: Word32)]+	ifM (elem x <$> listServiceNames client)+		( do+			debug thisThread [ "Started DBUS service"+				, x+				, "to monitor mount events."+				]+			return True+		, startOneService client xs+		)++{- Filter matching events recieved when drives are mounted and unmounted. -}	+mountChanged :: [MatchRule]+mountChanged = [gvfs True, gvfs False, kde, kdefallback]+	where+		{- gvfs reliably generates this event whenever a drive is mounted/unmounted,+		 - whether automatically, or manually -}+		gvfs mount = matchAny+			{ matchInterface = Just "org.gtk.Private.RemoteVolumeMonitor"+			, matchMember = Just $ if mount then "MountAdded" else "MountRemoved"+			}+		{- This event fires when KDE prompts the user what to do with a drive,+		 - but maybe not at other times. And it's not received -}+		kde = matchAny+			{ matchInterface = Just "org.kde.Solid.Device"+			, matchMember = Just "setupDone"+			}+		{- This event may not be closely related to mounting a drive, but it's+		 - observed reliably when a drive gets mounted or unmounted. -}+		kdefallback = matchAny+			{ matchInterface = Just "org.kde.KDirNotify"+			, matchMember = Just "enteredDirectory"+			}++#endif++pollingThread :: ThreadState -> DaemonStatusHandle -> ScanRemoteMap -> IO ()+pollingThread st dstatus scanremotes = go =<< currentMountPoints+	where+		go wasmounted = do+			threadDelaySeconds (Seconds 10)+			nowmounted <- currentMountPoints+			handleMounts st dstatus scanremotes wasmounted nowmounted+			go nowmounted++handleMounts :: ThreadState -> DaemonStatusHandle -> ScanRemoteMap -> MountPoints -> MountPoints -> IO ()+handleMounts st dstatus scanremotes wasmounted nowmounted =+	mapM_ (handleMount st dstatus scanremotes . mnt_dir) $+		S.toList $ newMountPoints wasmounted nowmounted++handleMount :: ThreadState -> DaemonStatusHandle -> ScanRemoteMap -> FilePath -> IO ()+handleMount st dstatus scanremotes dir = do+	debug thisThread ["detected mount of", dir]+	reconnectRemotes thisThread st dstatus scanremotes+		=<< filter (Git.repoIsLocal . Remote.repo)+			<$> remotesUnder st dstatus dir++{- Finds remotes located underneath the mount point.+ -+ - Updates state to include the remotes.+ -+ - The config of git remotes is re-read, as it may not have been available+ - at startup time, or may have changed (it could even be a different+ - repository at the same remote location..)+ -}+remotesUnder :: ThreadState -> DaemonStatusHandle -> FilePath -> IO [Remote]+remotesUnder st dstatus dir = runThreadState st $ do+	repotop <- fromRepo Git.repoPath+	rs <- remoteList+	pairs <- mapM (checkremote repotop) rs+	let (waschanged, rs') = unzip pairs+	when (any id waschanged) $ do+		Annex.changeState $ \s -> s { Annex.remotes = rs' }+		updateKnownRemotes dstatus+	return $ map snd $ filter fst pairs+	where+		checkremote repotop r = case Remote.localpath r of+			Just p | dirContains dir (absPathFrom repotop p) ->+				(,) <$> pure True <*> updateRemote r+			_ -> return (False, r)++type MountPoints = S.Set Mntent++currentMountPoints :: IO MountPoints+currentMountPoints = S.fromList <$> getMounts++newMountPoints :: MountPoints -> MountPoints -> MountPoints+newMountPoints old new = S.difference new old
+ Assistant/Threads/NetWatcher.hs view
@@ -0,0 +1,138 @@+{- git-annex assistant network connection watcher, using dbus+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++{-# LANGUAGE CPP #-}+{-# LANGUAGE OverloadedStrings #-}++module Assistant.Threads.NetWatcher where++import Assistant.Common+import Assistant.ThreadedMonad+import Assistant.DaemonStatus+import Assistant.ScanRemotes+import Assistant.Sync+import Utility.ThreadScheduler+import Remote.List+import qualified Types.Remote as Remote++import qualified Control.Exception as E++#if WITH_DBUS+import Utility.DBus+import DBus.Client+import DBus+import Data.Word (Word32)+#else+#warning Building without dbus support; will poll for network connection changes+#endif++thisThread :: ThreadName+thisThread = "NetWatcher"++netWatcherThread :: ThreadState -> DaemonStatusHandle -> ScanRemoteMap -> NamedThread+netWatcherThread st dstatus scanremotes = thread $+#if WITH_DBUS+	dbusThread st dstatus scanremotes+#else+	noop+#endif+	where+		thread = NamedThread thisThread++{- This is a fallback for when dbus cannot be used to detect+ - network connection changes, but it also ensures that+ - any networked remotes that may have not been routable for a+ - while (despite the local network staying up), are synced with+ - periodically. -}+netWatcherFallbackThread :: ThreadState -> DaemonStatusHandle -> ScanRemoteMap -> NamedThread+netWatcherFallbackThread st dstatus scanremotes = thread $+	runEvery (Seconds 3600) $+		handleConnection st dstatus scanremotes+	where+		thread = NamedThread thisThread++#if WITH_DBUS++dbusThread :: ThreadState -> DaemonStatusHandle -> ScanRemoteMap -> IO ()+dbusThread st dstatus scanremotes = E.catch (go =<< connectSystem) onerr+	where+		go client = ifM (checkNetMonitor client)+			( do+				listenNMConnections client handle+				listenWicdConnections client handle+			, do+				runThreadState st $+					warning "No known network monitor available through dbus; falling back to polling"+			)+		onerr :: E.SomeException -> IO ()+		onerr e = runThreadState st $+			warning $ "Failed to use dbus; falling back to polling (" ++ show e ++ ")"+		handle = do+			debug thisThread ["detected network connection"]+			handleConnection st dstatus scanremotes++{- Examine the list of services connected to dbus, to see if there+ - are any we can use to monitor network connections. -}+checkNetMonitor :: Client -> IO Bool+checkNetMonitor client = do+	running <- filter (`elem` [networkmanager, wicd])+		<$> listServiceNames client+	case running of+		[] -> return False+		(service:_) -> do+			debug thisThread [ "Using running DBUS service"+				, service+				, "to monitor network connection events."+				]+			return True+	where+		networkmanager = "org.freedesktop.NetworkManager"+		wicd = "org.wicd.daemon"++{- Listens for new NetworkManager connections. -}+listenNMConnections :: Client -> IO () -> IO ()+listenNMConnections client callback =+	listen client matcher $ \event ->+		when (Just True == anyM activeconnection (signalBody event)) $+			callback+	where+		matcher = matchAny+			{ matchInterface = Just "org.freedesktop.NetworkManager.Connection.Active"+			, matchMember = Just "PropertiesChanged"+			}+		nm_connection_activated = toVariant (2 :: Word32)+		nm_state_key = toVariant ("State" :: String)+		activeconnection v = do+			m <- fromVariant v+			vstate <- lookup nm_state_key $ dictionaryItems m+			state <- fromVariant vstate+			return $ state == nm_connection_activated++{- Listens for new Wicd connections. -}+listenWicdConnections :: Client -> IO () -> IO ()+listenWicdConnections client callback =+	listen client matcher $ \event ->+		when (any (== wicd_success) (signalBody event)) $+			callback+	where+		matcher = matchAny+			{ matchInterface = Just "org.wicd.daemon"+			, matchMember = Just "ConnectResultsSent"+			}+		wicd_success = toVariant ("success" :: String)++#endif++handleConnection :: ThreadState -> DaemonStatusHandle -> ScanRemoteMap -> IO ()+handleConnection st dstatus scanremotes =+	reconnectRemotes thisThread st dstatus scanremotes+		=<< networkRemotes st++{- Finds network remotes. -}+networkRemotes :: ThreadState -> IO [Remote]+networkRemotes st = runThreadState st $+	filter (isNothing . Remote.localpath) <$> remoteList
+ Assistant/Threads/PairListener.hs view
@@ -0,0 +1,153 @@+{- git-annex assistant thread to listen for incoming pairing traffic+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++module Assistant.Threads.PairListener where++import Assistant.Common+import Assistant.Pairing+import Assistant.Pairing.Network+import Assistant.Pairing.MakeRemote+import Assistant.ThreadedMonad+import Assistant.ScanRemotes+import Assistant.DaemonStatus+import Assistant.WebApp+import Assistant.WebApp.Types+import Assistant.Alert++import Network.Multicast+import Network.Socket+import qualified Data.Text as T+import Data.Char++thisThread :: ThreadName+thisThread = "PairListener"++pairListenerThread :: ThreadState -> DaemonStatusHandle -> ScanRemoteMap -> UrlRenderer -> NamedThread+pairListenerThread st dstatus scanremotes urlrenderer = thread $ withSocketsDo $ do+	sock <- multicastReceiver (multicastAddress $ IPv4Addr undefined) pairingPort+	go sock [] []+	where+		thread = NamedThread thisThread+		+		go sock reqs cache = getmsg sock [] >>= \msg -> case readish msg of+			Nothing -> go sock reqs cache+			Just m -> do+				sane <- checkSane msg+				(pip, verified) <- verificationCheck m+					=<< (pairingInProgress <$> getDaemonStatus dstatus)+				let wrongstage = maybe False (\p -> pairMsgStage m <= inProgressPairStage p) pip+				case (wrongstage, sane, pairMsgStage m) of+					-- ignore our own messages, and+					-- out of order messages+					(True, _, _) -> go sock reqs cache+					(_, False, _) -> go sock reqs cache+					(_, _, PairReq) -> if m `elem` reqs+						then go sock reqs (invalidateCache m cache)+						else do+							pairReqReceived verified dstatus urlrenderer m+							go sock (m:take 10 reqs) (invalidateCache m cache)+					(_, _, PairAck) ->+						pairAckReceived verified pip st dstatus scanremotes m cache+							>>= go sock reqs+					(_, _, PairDone) -> do+						pairDoneReceived verified pip st dstatus scanremotes m+						go sock	reqs cache++		{- As well as verifying the message using the shared secret,+		 - check its UUID against the UUID we have stored. If+		 - they're the same, someone is sending bogus messages,+		 - which could be an attempt to brute force the shared+		 - secret.+		 -}+		verificationCheck m (Just pip) = do+			let verified = verifiedPairMsg m pip+			let sameuuid = pairUUID (inProgressPairData pip) == pairUUID (pairMsgData m)+			if not verified && sameuuid+				then do+					runThreadState st $+						warning "detected possible pairing brute force attempt; disabled pairing"+					stopSending dstatus pip+					return (Nothing, False)+				else return (Just pip, verified && sameuuid)+		verificationCheck _ Nothing = return (Nothing, False)+		+		{- Various sanity checks on the content of the message. -}+		checkSane msg +			{- Control characters could be used in a+			 - console poisoning attack. -}+			| any isControl msg || any (`elem` "\r\n") msg = do+				runThreadState st $+					warning "illegal control characters in pairing message; ignoring"+				return False+			| otherwise = return True++		{- PairReqs invalidate the cache of recently finished pairings.+		 - This is so that, if a new pairing is started with the+		 - same secret used before, a bogus PairDone is not sent. -}+		invalidateCache msg = filter (not . verifiedPairMsg msg)++		getmsg sock c = do+			(msg, n, _) <- recvFrom sock chunksz+			if n < chunksz+				then return $ c ++ msg+				else getmsg sock $ c ++ msg+			where+				chunksz = 1024++{- Show an alert when a PairReq is seen. -}+pairReqReceived :: Bool -> DaemonStatusHandle -> UrlRenderer -> PairMsg -> IO ()+pairReqReceived True _ _ _ = noop -- ignore our own PairReq+pairReqReceived False dstatus urlrenderer msg = do+	url <- renderUrl urlrenderer (FinishPairR msg) []+	void $ addAlert dstatus $ pairRequestReceivedAlert repo+		AlertButton+			{ buttonUrl = url+			, buttonLabel = T.pack "Respond"+			, buttonAction = Just $ removeAlert dstatus+			}+	where+		repo = pairRepo msg++{- When a verified PairAck is seen, a host is ready to pair with us, and has+ - already configured our ssh key. Stop sending PairReqs, finish the pairing,+ - and send a single PairDone. + -}+pairAckReceived :: Bool -> Maybe PairingInProgress -> ThreadState -> DaemonStatusHandle -> ScanRemoteMap -> PairMsg -> [PairingInProgress] -> IO [PairingInProgress]+pairAckReceived True (Just pip) st dstatus scanremotes msg cache = do+	stopSending dstatus pip+	setupAuthorizedKeys msg+	finishedPairing st dstatus scanremotes msg (inProgressSshKeyPair pip)+	startSending dstatus pip PairDone $ multicastPairMsg+		(Just 1) (inProgressSecret pip) (inProgressPairData pip)+	return $ pip : take 10 cache+{- A stale PairAck might also be seen, after we've finished pairing.+ - Perhaps our PairDone was not received. To handle this, we keep+ - a cache of recently finished pairings, and re-send PairDone in+ - response to stale PairAcks for them. -}+pairAckReceived _ _ _ dstatus _ msg cache = do+	let pips = filter (verifiedPairMsg msg) cache+	unless (null pips) $+		forM_ pips $ \pip ->+			startSending dstatus pip PairDone $ multicastPairMsg+				(Just 1) (inProgressSecret pip) (inProgressPairData pip)+	return cache++{- If we get a verified PairDone, the host has accepted our PairAck, and+ - has paired with us. Stop sending PairAcks, and finish pairing with them.+ -+ - TODO: Should third-party hosts remove their pair request alert when they+ - see a PairDone?+ - Complication: The user could have already clicked on the alert and be+ - entering the secret. Would be better to start a fresh pair request in this+ - situation.+ -}+pairDoneReceived :: Bool -> Maybe PairingInProgress -> ThreadState -> DaemonStatusHandle -> ScanRemoteMap -> PairMsg -> IO ()+pairDoneReceived False _ _ _ _ _ = noop -- not verified+pairDoneReceived True Nothing _ _ _ _ = noop -- not in progress+pairDoneReceived True (Just pip) st dstatus scanremotes msg = do+	stopSending dstatus pip+	finishedPairing st dstatus scanremotes msg (inProgressSshKeyPair pip)
+ Assistant/Threads/Pusher.hs view
@@ -0,0 +1,83 @@+{- git-annex assistant git pushing thread+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++module Assistant.Threads.Pusher where++import Assistant.Common+import Assistant.Commits+import Assistant.Pushes+import Assistant.Alert+import Assistant.ThreadedMonad+import Assistant.DaemonStatus+import Assistant.Sync+import Utility.ThreadScheduler+import qualified Remote+import qualified Types.Remote as Remote++import Data.Time.Clock++thisThread :: ThreadName+thisThread = "Pusher"++{- This thread retries pushes that failed before. -}+pushRetryThread :: ThreadState -> DaemonStatusHandle -> FailedPushMap -> NamedThread+pushRetryThread st dstatus pushmap = thread $ runEvery (Seconds halfhour) $ do+	-- We already waited half an hour, now wait until there are failed+	-- pushes to retry.+	topush <- getFailedPushesBefore pushmap (fromIntegral halfhour)+	unless (null topush) $ do+		debug thisThread+			[ "retrying"+			, show (length topush)+			, "failed pushes"+			]+		now <- getCurrentTime+		void $ alertWhile dstatus (pushRetryAlert topush) $+			pushToRemotes thisThread now st (Just pushmap) topush+	where+		halfhour = 1800+		thread = NamedThread thisThread++{- This thread pushes git commits out to remotes soon after they are made. -}+pushThread :: ThreadState -> DaemonStatusHandle -> CommitChan -> FailedPushMap -> NamedThread+pushThread st dstatus commitchan pushmap = thread $ runEvery (Seconds 2) $ do+	-- We already waited two seconds as a simple rate limiter.+	-- Next, wait until at least one commit has been made+	commits <- getCommits commitchan+	-- Now see if now's a good time to push.+	now <- getCurrentTime+	if shouldPush now commits+		then do+			remotes <- filter pushable . knownRemotes+				<$> getDaemonStatus dstatus+			unless (null remotes) $ +				void $ alertWhile dstatus (pushAlert remotes) $+					pushToRemotes thisThread now st (Just pushmap) remotes+		else do+			debug thisThread+				[ "delaying push of"+				, show (length commits)+				, "commits"+				]+			refillCommits commitchan commits+	where+		thread = NamedThread thisThread+		pushable r+			| Remote.specialRemote r = False+			| Remote.readonly r = False+			| otherwise = True++{- Decide if now is a good time to push to remotes.+ -+ - Current strategy: Immediately push all commits. The commit machinery+ - already determines batches of changes, so we can't easily determine+ - batches better.+ -}+shouldPush :: UTCTime -> [Commit] -> Bool+shouldPush _now commits+	| not (null commits) = True+	| otherwise = False
+ Assistant/Threads/SanityChecker.hs view
@@ -0,0 +1,99 @@+{- git-annex assistant sanity checker+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++module Assistant.Threads.SanityChecker (+	sanityCheckerThread+) where++import Assistant.Common+import Assistant.DaemonStatus+import Assistant.ThreadedMonad+import Assistant.Changes+import Assistant.Alert+import Assistant.TransferQueue+import qualified Git.LsFiles+import Utility.ThreadScheduler+import qualified Assistant.Threads.Watcher as Watcher++import Data.Time.Clock.POSIX++thisThread :: ThreadName+thisThread = "SanityChecker"++{- This thread wakes up occasionally to make sure the tree is in good shape. -}+sanityCheckerThread :: ThreadState -> DaemonStatusHandle -> TransferQueue -> ChangeChan -> NamedThread+sanityCheckerThread st dstatus transferqueue changechan = thread $ forever $ do+	waitForNextCheck dstatus++	debug thisThread ["starting sanity check"]++	void $ alertWhile dstatus sanityCheckAlert go+	+	debug thisThread ["sanity check complete"]+	where+		thread = NamedThread thisThread+		go = do+			modifyDaemonStatus_ dstatus $ \s -> s+				{ sanityCheckRunning = True }++			now <- getPOSIXTime -- before check started+			r <- catchIO (check st dstatus transferqueue changechan)+				$ \e -> do+					runThreadState st $ warning $ show e+					return False++			modifyDaemonStatus_ dstatus $ \s -> s+				{ sanityCheckRunning = False+				, lastSanityCheck = Just now+				}++			return r++{- Only run one check per day, from the time of the last check. -}+waitForNextCheck :: DaemonStatusHandle -> IO ()+waitForNextCheck dstatus = do+	v <- lastSanityCheck <$> getDaemonStatus dstatus+	now <- getPOSIXTime+	threadDelaySeconds $ Seconds $ calcdelay now v+	where+		calcdelay _ Nothing = oneDay+		calcdelay now (Just lastcheck)+			| lastcheck < now = max oneDay $+				oneDay - truncate (now - lastcheck)+			| otherwise = oneDay++oneDay :: Int+oneDay = 24 * 60 * 60++{- It's important to stay out of the Annex monad as much as possible while+ - running potentially expensive parts of this check, since remaining in it+ - will block the watcher. -}+check :: ThreadState -> DaemonStatusHandle -> TransferQueue -> ChangeChan -> IO Bool+check st dstatus transferqueue changechan = do+	g <- runThreadState st $ fromRepo id+	-- Find old unstaged symlinks, and add them to git.+	unstaged <- Git.LsFiles.notInRepo False ["."] g+	now <- getPOSIXTime+	forM_ unstaged $ \file -> do+		ms <- catchMaybeIO $ getSymbolicLinkStatus file+		case ms of+			Just s	| toonew (statusChangeTime s) now -> noop+				| isSymbolicLink s ->+					addsymlink file ms+			_ -> noop+	return True+	where+		toonew timestamp now = now < (realToFrac (timestamp + slop) :: POSIXTime)+		slop = fromIntegral tenMinutes+		insanity msg = do+			runThreadState st $ warning msg+			void $ addAlert dstatus $ sanityCheckFixAlert msg+		addsymlink file s = do+			Watcher.runHandler thisThread Nothing st dstatus+				transferqueue changechan+				Watcher.onAddSymlink file s+			insanity $ "found unstaged symlink: " ++ file
+ Assistant/Threads/TransferPoller.hs view
@@ -0,0 +1,62 @@+{- git-annex assistant transfer polling thread+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++module Assistant.Threads.TransferPoller where++import Assistant.Common+import Assistant.ThreadedMonad+import Assistant.DaemonStatus+import Logs.Transfer+import Utility.NotificationBroadcaster+import qualified Assistant.Threads.TransferWatcher as TransferWatcher++import Control.Concurrent+import qualified Data.Map as M++thisThread :: ThreadName+thisThread = "TransferPoller"++{- This thread polls the status of ongoing transfers, determining how much+ - of each transfer is complete. -}+transferPollerThread :: ThreadState -> DaemonStatusHandle -> NamedThread+transferPollerThread st dstatus = thread $ do+	g <- runThreadState st $ fromRepo id+	tn <- newNotificationHandle =<<+		transferNotifier <$> getDaemonStatus dstatus+	forever $ do+		threadDelay 500000 -- 0.5 seconds+		ts <- currentTransfers <$> getDaemonStatus dstatus+		if M.null ts+			then waitNotification tn -- block until transfers running+			else mapM_ (poll g) $ M.toList ts+	where+		thread = NamedThread thisThread+		poll g (t, info)+			{- Downloads are polled by checking the size of the+			 - temp file being used for the transfer. -}+			| transferDirection t == Download = do+				let f = gitAnnexTmpLocation (transferKey t) g+				sz <- catchMaybeIO $+					fromIntegral . fileSize+						<$> getFileStatus f+				newsize t info sz+			{- Uploads don't need to be polled for when the+			 - TransferWatcher thread can track file+			 - modifications. -}+			| TransferWatcher.watchesTransferSize = noop+			{- Otherwise, this code polls the upload progress+			 - by reading the transfer info file. -}+			| otherwise = do+				let f = transferFile t g+				mi <- catchDefaultIO Nothing $+					readTransferInfoFile Nothing f+				maybe noop (newsize t info . bytesComplete) mi+		newsize t info sz+			| bytesComplete info /= sz && isJust sz = +				alterTransferInfo dstatus t $+					\i -> i { bytesComplete = sz }+			| otherwise = noop
+ Assistant/Threads/TransferScanner.hs view
@@ -0,0 +1,129 @@+{- git-annex assistant thread to scan remotes to find needed transfers+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++module Assistant.Threads.TransferScanner where++import Assistant.Common+import Assistant.ScanRemotes+import Assistant.TransferQueue+import Assistant.ThreadedMonad+import Assistant.DaemonStatus+import Assistant.Alert+import Logs.Transfer+import Logs.Location+import Logs.Web (webUUID)+import qualified Remote+import qualified Types.Remote as Remote+import Utility.ThreadScheduler+import qualified Git.LsFiles as LsFiles+import Command+import Annex.Content++import qualified Data.Set as S++thisThread :: ThreadName+thisThread = "TransferScanner"++{- This thread waits until a remote needs to be scanned, to find transfers+ - that need to be made, to keep data in sync.+ -}+transferScannerThread :: ThreadState -> DaemonStatusHandle -> ScanRemoteMap -> TransferQueue -> NamedThread+transferScannerThread st dstatus scanremotes transferqueue = thread $ do+	startupScan+	go S.empty+	where+		thread = NamedThread thisThread+		go scanned = do+			threadDelaySeconds (Seconds 2)+			(rs, infos) <- unzip <$> getScanRemote scanremotes+			if any fullScan infos || any (`S.notMember` scanned) rs+				then do+					expensiveScan st dstatus transferqueue rs+					go $ scanned `S.union` S.fromList rs+				else do+					mapM_ (failedTransferScan st dstatus transferqueue) rs+					go scanned+		{- All available remotes are scanned in full on startup,+		 - for multiple reasons, including:+		 -+		 - * This may be the first run, and there may be remotes+		 -   already in place, that need to be synced.+		 - * We may have run before, and scanned a remote, but+		 -   only been in a subdirectory of the git remote, and so+		 -   not synced it all.+		 - * We may have run before, and had transfers queued,+		 -   and then the system (or us) crashed, and that info was+		 -   lost.+		 -}+		startupScan = addScanRemotes scanremotes True+			=<< knownRemotes <$> getDaemonStatus dstatus++{- This is a cheap scan for failed transfers involving a remote. -}+failedTransferScan :: ThreadState -> DaemonStatusHandle -> TransferQueue -> Remote -> IO ()+failedTransferScan st dstatus transferqueue r = do+	failed <- runThreadState st $ getFailedTransfers (Remote.uuid r)+	runThreadState st $ mapM_ removeFailedTransfer $ map fst failed+	mapM_ retry failed+	where+		retry (t, info)+			| transferDirection t == Download = do+				{- Check if the remote still has the key.+				 - If not, relies on the expensiveScan to+				 - get it queued from some other remote. -}+				whenM (runThreadState st $ remoteHas r $ transferKey t) $+					requeue t info+			| otherwise = do+				{- The Transferrer checks when uploading+				 - that the remote doesn't already have the+				 - key, so it's not redundantly checked+				 - here. -}+				requeue t info+		requeue t info = queueTransferWhenSmall+			transferqueue dstatus (associatedFile info) t r++{- This is a expensive scan through the full git work tree, finding+ - files to download from or upload to any of the remotes.+ - + - The scan is blocked when the transfer queue gets too large. -}+expensiveScan :: ThreadState -> DaemonStatusHandle -> TransferQueue -> [Remote] -> IO ()+expensiveScan st dstatus transferqueue rs = unless onlyweb $ do+	liftIO $ debug thisThread ["starting scan of", show visiblers]+	void $ alertWhile dstatus (scanAlert visiblers) $ do+		g <- runThreadState st $ fromRepo id+		files <- LsFiles.inRepo [] g+		go files+		return True+	liftIO $ debug thisThread ["finished scan of", show visiblers]+	where+		onlyweb = all (== webUUID) $ map Remote.uuid rs+		visiblers = let rs' = filter (not . Remote.readonly) rs+			in if null rs' then rs else rs'+		go [] = noop+		go (f:fs) = do+			mapM_ (enqueue f) =<< catMaybes <$> runThreadState st+				(ifAnnexed f findtransfers $ return [])+			go fs+		enqueue f (r, t) = do+			debug thisThread ["queuing", show t]+			queueTransferWhenSmall transferqueue dstatus (Just f) t r+		findtransfers (key, _) = do+			locs <- loggedLocations key+			let use a = return $ map (a key locs) rs+			ifM (inAnnex key)+				( use $ check Upload False+				, use $ check Download True+				)+		check direction want key locs r+			| direction == Upload && Remote.readonly r = Nothing+			| (Remote.uuid r `elem` locs) == want = Just+				(r, Transfer direction (Remote.uuid r) key)+			| otherwise = Nothing++remoteHas :: Remote -> Key -> Annex Bool+remoteHas r key = elem+	<$> pure (Remote.uuid r)+	<*> loggedLocations key
+ Assistant/Threads/TransferWatcher.hs view
@@ -0,0 +1,117 @@+{- git-annex assistant transfer watching thread+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++module Assistant.Threads.TransferWatcher where++import Assistant.Common+import Assistant.ThreadedMonad+import Assistant.DaemonStatus+import Assistant.TransferQueue+import Annex.Content+import Logs.Transfer+import Utility.DirWatcher+import Utility.Types.DirWatcher+import qualified Remote++thisThread :: ThreadName+thisThread = "TransferWatcher"++{- This thread watches for changes to the gitAnnexTransferDir,+ - and updates the DaemonStatus's map of ongoing transfers. -}+transferWatcherThread :: ThreadState -> DaemonStatusHandle -> TransferQueue -> NamedThread+transferWatcherThread st dstatus transferqueue = thread $ do+	g <- runThreadState st $ fromRepo id+	let dir = gitAnnexTransferDir g+	createDirectoryIfMissing True dir+	let hook a = Just $ runHandler st dstatus transferqueue a+	let hooks = mkWatchHooks+		{ addHook = hook onAdd+		, delHook = hook onDel+		, modifyHook = hook onModify+		, errHook = hook onErr+		}+	void $ watchDir dir (const False) hooks id+	debug thisThread ["watching for transfers"]+	where+		thread = NamedThread thisThread++type Handler = ThreadState -> DaemonStatusHandle -> TransferQueue -> FilePath -> Maybe FileStatus -> IO ()++{- Runs an action handler.+ -+ - Exceptions are ignored, otherwise a whole thread could be crashed.+ -}+runHandler :: ThreadState -> DaemonStatusHandle -> TransferQueue -> Handler -> FilePath -> Maybe FileStatus -> IO ()+runHandler st dstatus transferqueue handler file filestatus = void $+        either print (const noop) =<< tryIO go+        where+                go = handler st dstatus transferqueue file filestatus++{- Called when there's an error with inotify. -}+onErr :: Handler+onErr _ _ _ msg _ = error msg++{- Called when a new transfer information file is written. -}+onAdd :: Handler+onAdd st dstatus _ file _ = case parseTransferFile file of+	Nothing -> noop+	Just t -> go t =<< runThreadState st (checkTransfer t)+	where+		go _ Nothing = noop -- transfer already finished+		go t (Just info) = do+			debug thisThread+				[ "transfer starting:"+				, show t+				]+			r <- headMaybe . filter (sameuuid t) . knownRemotes+				<$> getDaemonStatus dstatus+			updateTransferInfo dstatus t info+				{ transferRemote = r }+		sameuuid t r = Remote.uuid r == transferUUID t++{- Called when a transfer information file is updated.+ -+ - The only thing that should change in the transfer info is the+ - bytesComplete, so that's the only thing updated in the DaemonStatus. -}+onModify :: Handler+onModify _ dstatus _ file _ = do+	case parseTransferFile file of+		Nothing -> noop+		Just t -> go t =<< readTransferInfoFile Nothing file+	where+		go _ Nothing = noop+		go t (Just newinfo) = alterTransferInfo dstatus t $ \info ->+			info { bytesComplete = bytesComplete newinfo }++{- This thread can only watch transfer sizes when the DirWatcher supports+ - tracking modificatons to files. -}+watchesTransferSize :: Bool+watchesTransferSize = modifyTracked++{- Called when a transfer information file is removed. -}+onDel :: Handler+onDel st dstatus transferqueue file _ = case parseTransferFile file of+	Nothing -> noop+	Just t -> do+		debug thisThread+			[ "transfer finishing:"+			, show t+			]+		minfo <- removeTransfer dstatus t++		{- Queue uploads of files we successfully downloaded,+		 - spreading them out to other reachable remotes. -}+		case (minfo, transferDirection t) of+			(Just info, Download) -> runThreadState st $+				whenM (inAnnex $ transferKey t) $+					queueTransfersMatching +						(/= transferUUID t)+						Later transferqueue dstatus+						(transferKey t)+						(associatedFile info)+						Upload+			_ -> noop
+ Assistant/Threads/Transferrer.hs view
@@ -0,0 +1,104 @@+{- git-annex assistant data transferrer thread+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++module Assistant.Threads.Transferrer where++import Assistant.Common+import Assistant.ThreadedMonad+import Assistant.DaemonStatus+import Assistant.TransferQueue+import Assistant.TransferSlots+import Assistant.Alert+import Logs.Transfer+import Logs.Location+import Annex.Content+import qualified Remote+import Types.Key+import Locations.UserConfig++import System.Process (create_group)++thisThread :: ThreadName+thisThread = "Transferrer"++{- For now only one transfer is run at a time. -}+maxTransfers :: Int+maxTransfers = 1++{- Dispatches transfers from the queue. -}+transfererThread :: ThreadState -> DaemonStatusHandle -> TransferQueue -> TransferSlots -> NamedThread+transfererThread st dstatus transferqueue slots = thread $ go =<< readProgramFile+	where+		thread = NamedThread thisThread+		go program = forever $ inTransferSlot dstatus slots $+			maybe (return Nothing) (uncurry $ startTransfer st dstatus program)+				=<< getNextTransfer transferqueue dstatus notrunning+		{- Skip transfers that are already running. -}+		notrunning = isNothing . startedTime++{- By the time this is called, the daemonstatus's transfer map should+ - already have been updated to include the transfer. -}+startTransfer :: ThreadState -> DaemonStatusHandle -> FilePath -> Transfer -> TransferInfo -> TransferGenerator+startTransfer st dstatus program t info = case (transferRemote info, associatedFile info) of+	(Just remote, Just file) -> ifM (runThreadState st $ shouldTransfer t info)+		( do+			debug thisThread [ "Transferring:" , show t ]+			notifyTransfer dstatus+			return $ Just (t, info, transferprocess remote file)+		, do+			debug thisThread [ "Skipping unnecessary transfer:" , show t ]+			void $ removeTransfer dstatus t+			return Nothing+		)+	_ -> return Nothing+	where+		direction = transferDirection t+		isdownload = direction == Download++		transferprocess remote file = void $ do+			(_, _, _, pid)+				<- createProcess (proc program $ toCommand params)+					{ create_group = True }+			{- Alerts are only shown for successful transfers.+			 - Transfers can temporarily fail for many reasons,+			 - so there's no point in bothering the user about+			 - those. The assistant should recover. -}+			whenM ((==) ExitSuccess <$> waitForProcess pid) $ void $+				addAlert dstatus $+					makeAlertFiller True $+						transferFileAlert direction True file+			where+				params =+					[ Param "transferkey"+					, Param "--quiet"+					, Param $ key2file $ transferKey t+					, Param $ if isdownload+						then "--from"+						else "--to"+					, Param $ Remote.name remote+					, Param "--file"+					, File file+					]++{- Checks if the file to download is already present, or the remote+ - being uploaded to isn't known to have the file. -}+shouldTransfer :: Transfer -> TransferInfo -> Annex Bool+shouldTransfer t info+	| transferDirection t == Download =+		not <$> inAnnex key+	| transferDirection t == Upload =+		{- Trust the location log to check if the+		 - remote already has the key. This avoids+		 - a roundtrip to the remote. -}+		case transferRemote info of+			Nothing -> return False+			Just remote -> +				notElem (Remote.uuid remote)+					<$> loggedLocations key+	| otherwise = return False+	where+		key = transferKey t
+ Assistant/Threads/Watcher.hs view
@@ -0,0 +1,269 @@+{- git-annex assistant tree watcher+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++{-# LANGUAGE CPP #-}++module Assistant.Threads.Watcher (+	watchThread,+	checkCanWatch,+	needLsof,+	stageSymlink,+	onAddSymlink,+	runHandler,+) where++import Assistant.Common+import Assistant.ThreadedMonad+import Assistant.DaemonStatus+import Assistant.Changes+import Assistant.TransferQueue+import Assistant.Alert+import Logs.Transfer+import Utility.DirWatcher+import Utility.Types.DirWatcher+import qualified Annex+import qualified Annex.Queue+import qualified Git.Command+import qualified Git.UpdateIndex+import qualified Git.HashObject+import qualified Git.LsFiles+import qualified Backend+import qualified Command.Add+import Annex.Content+import Annex.CatFile+import Git.Types+import Config+import Utility.ThreadScheduler++import Data.Bits.Utils+import qualified Data.ByteString.Lazy as L++thisThread :: ThreadName+thisThread = "Watcher"++checkCanWatch :: Annex ()+checkCanWatch+	| canWatch = +		unlessM (liftIO (inPath "lsof") <||> Annex.getState Annex.force)+			needLsof+	| otherwise = error "watch mode is not available on this system"++needLsof :: Annex ()+needLsof = error $ unlines+	[ "The lsof command is needed for watch mode to be safe, and is not in PATH."+	, "To override lsof checks to ensure that files are not open for writing"+	, "when added to the annex, you can use --force"+	, "Be warned: This can corrupt data in the annex, and make fsck complain."+	]++{- OSX needs a short delay after a file is added before locking it down,+ - as pasting a file seems to try to set file permissions or otherwise+ - access the file after closing it. -}+delayaddDefault :: Maybe Seconds+#ifdef darwin_HOST_OS+delayaddDefault = Just $ Seconds 1+#else+delayaddDefault = Nothing+#endif++watchThread :: ThreadState -> DaemonStatusHandle -> TransferQueue -> ChangeChan -> NamedThread+watchThread st dstatus transferqueue changechan = NamedThread thisThread $ do+	delayadd <- runThreadState st $+		maybe delayaddDefault (Just . Seconds) . readish+			<$> getConfig (annexConfig "delayadd") "" +	void $ watchDir "." ignored (hooks delayadd) startup+	debug thisThread [ "watching", "."]+	where+		startup = startupScan st dstatus+		hook delay a = Just $ runHandler thisThread delay st dstatus transferqueue changechan a+		hooks delayadd = mkWatchHooks+			{ addHook = hook delayadd onAdd+			, delHook = hook Nothing onDel+			, addSymlinkHook = hook Nothing onAddSymlink+			, delDirHook = hook Nothing onDelDir+			, errHook = hook Nothing onErr+			}++{- Initial scartup scan. The action should return once the scan is complete. -}+startupScan :: ThreadState -> DaemonStatusHandle -> IO a -> IO a+startupScan st dstatus scanner = do+	runThreadState st $ showAction "scanning"+	alertWhile' dstatus startupScanAlert $ do+		r <- scanner++		-- Notice any files that were deleted before+		-- watching was started.+		runThreadState st $ do+			inRepo $ Git.Command.run "add" [Param "--update"]+			showAction "started"+		+		modifyDaemonStatus_ dstatus $ \s -> s { scanComplete = True }++		return (True, r)++ignored :: FilePath -> Bool+ignored = ig . takeFileName+	where+	ig ".git" = True+	ig ".gitignore" = True+	ig ".gitattributes" = True+	ig _ = False++type Handler = ThreadName -> Maybe Seconds -> FilePath -> Maybe FileStatus -> DaemonStatusHandle -> TransferQueue -> Annex (Maybe Change)++{- Runs an action handler, inside the Annex monad, and if there was a+ - change, adds it to the ChangeChan.+ -+ - Exceptions are ignored, otherwise a whole watcher thread could be crashed.+ -}+runHandler :: ThreadName -> Maybe Seconds -> ThreadState -> DaemonStatusHandle -> TransferQueue -> ChangeChan -> Handler -> FilePath -> Maybe FileStatus -> IO ()+runHandler threadname delay st dstatus transferqueue changechan handler file filestatus = void $ do+	r <- tryIO go+	case r of+		Left e -> print e+		Right Nothing -> noop+		Right (Just change) -> recordChange changechan change+	where+		go = runThreadState st $ handler threadname delay file filestatus dstatus transferqueue++{- During initial directory scan, this will be run for any regular files+ - that are already checked into git. We don't want to turn those into+ - symlinks, so do a check. This is rather expensive, but only happens+ - during startup.+ -+ - It's possible for the file to still be open for write by some process.+ - This can happen in a few ways; one is if two processes had the file open+ - and only one has just closed it. We want to avoid adding a file to the+ - annex that is open for write, to avoid anything being able to change it.+ -+ - We could run lsof on the file here to check for other writers.+ - But, that's slow, and even if there is currently a writer, we will want+ - to add the file *eventually*. Instead, the file is locked down as a hard+ - link in a temp directory, with its write bits disabled, for later+ - checking with lsof, and a Change is returned containing a KeySource+ - using that hard link. The committer handles running lsof and finishing+ - the add.+ -}+onAdd :: Handler+onAdd threadname delay file filestatus dstatus _+	| maybe False isRegularFile filestatus =+		ifM (scanComplete <$> liftIO (getDaemonStatus dstatus))+			( go+			, ifM (null <$> inRepo (Git.LsFiles.notInRepo False [file]))+				( noChange+				, go+				)+			)+	| otherwise = noChange+	where+		go = do+			liftIO $ do+				debug threadname ["file added", file]+				maybe noop threadDelaySeconds delay+			pendingAddChange =<< Command.Add.lockDown file++{- A symlink might be an arbitrary symlink, which is just added.+ - Or, if it is a git-annex symlink, ensure it points to the content+ - before adding it.+ -}+onAddSymlink :: Handler+onAddSymlink threadname _ file filestatus dstatus transferqueue = go =<< Backend.lookupFile file+	where+		go (Just (key, _)) = do+			link <- calcGitLink file key+			ifM ((==) link <$> liftIO (readSymbolicLink file))+				( do+					s <- liftIO $ getDaemonStatus dstatus+					checkcontent key s+					ensurestaged link s+				, do+					liftIO $ debug threadname ["fix symlink", file]+					liftIO $ removeFile file+					liftIO $ createSymbolicLink link file+					addlink link+				)+		go Nothing = do -- other symlink+			link <- liftIO (readSymbolicLink file)+			ensurestaged link =<< liftIO (getDaemonStatus dstatus)++		{- This is often called on symlinks that are already+		 - staged correctly. A symlink may have been deleted+		 - and being re-added, or added when the watcher was+		 - not running. So they're normally restaged to make sure.+		 -+		 - As an optimisation, during the status scan, avoid+		 - restaging everything. Only links that were created since+		 - the last time the daemon was running are staged.+		 - (If the daemon has never ran before, avoid staging+		 - links too.)+		 -}+		ensurestaged link daemonstatus+			| scanComplete daemonstatus = addlink link+			| otherwise = case filestatus of+				Just s+					| not (afterLastDaemonRun (statusChangeTime s) daemonstatus) -> noChange+				_ -> addlink link++		{- For speed, tries to reuse the existing blob for+		 - the symlink target. -}+		addlink link = do+			liftIO $ debug threadname ["add symlink", file]+			v <- catObjectDetails $ Ref $ ':':file+			case v of+				Just (currlink, sha)+					| s2w8 link == L.unpack currlink ->+						stageSymlink file sha+				_ -> do+					sha <- inRepo $+						Git.HashObject.hashObject BlobObject link+					stageSymlink file sha+			madeChange file LinkChange++		{- When a new link appears, after the startup scan,+		 - try to get the key's content. -}+		checkcontent key daemonstatus+			| scanComplete daemonstatus = unlessM (inAnnex key) $+				queueTransfers Next transferqueue dstatus+					key (Just file) Download+			| otherwise = noop++onDel :: Handler+onDel threadname _ file _ _dstatus _ = do+	liftIO $ debug threadname ["file deleted", file]+	Annex.Queue.addUpdateIndex =<<+		inRepo (Git.UpdateIndex.unstageFile file)+	madeChange file RmChange++{- A directory has been deleted, or moved, so tell git to remove anything+ - that was inside it from its cache. Since it could reappear at any time,+ - use --cached to only delete it from the index. + -+ - Note: This could use unstageFile, but would need to run another git+ - command to get the recursive list of files in the directory, so rm is+ - just as good. -}+onDelDir :: Handler+onDelDir threadname _ dir _ _dstatus _ = do+	liftIO $ debug threadname ["directory deleted", dir]+	Annex.Queue.addCommand "rm"+		[Params "--quiet -r --cached --ignore-unmatch --"] [dir]+	madeChange dir RmDirChange++{- Called when there's an error with inotify or kqueue. -}+onErr :: Handler+onErr _ _ msg _ dstatus _ = do+	warning msg+	void $ liftIO $ addAlert dstatus $ warningAlert "watcher" msg+	return Nothing++{- Adds a symlink to the index, without ever accessing the actual symlink+ - on disk. This avoids a race if git add is used, where the symlink is+ - changed to something else immediately after creation.+ -}+stageSymlink :: FilePath -> Sha -> Annex ()+stageSymlink file sha =+	Annex.Queue.addUpdateIndex =<<+		inRepo (Git.UpdateIndex.stageSymlink file sha)
+ Assistant/Threads/WebApp.hs view
@@ -0,0 +1,124 @@+{- git-annex assistant webapp thread+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++{-# LANGUAGE TypeFamilies, QuasiQuotes, MultiParamTypeClasses, TemplateHaskell, OverloadedStrings, RankNTypes #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}++module Assistant.Threads.WebApp where++import Assistant.Common+import Assistant.WebApp+import Assistant.WebApp.Types+import Assistant.WebApp.DashBoard+import Assistant.WebApp.SideBar+import Assistant.WebApp.Notifications+import Assistant.WebApp.Configurators+import Assistant.WebApp.Configurators.Local+import Assistant.WebApp.Configurators.Ssh+import Assistant.WebApp.Configurators.Pairing+import Assistant.WebApp.Documentation+import Assistant.WebApp.OtherRepos+import Assistant.ThreadedMonad+import Assistant.DaemonStatus+import Assistant.ScanRemotes+import Assistant.TransferQueue+import Assistant.TransferSlots+import Utility.WebApp+import Utility.FileMode+import Utility.TempFile+import Git++import Yesod+import Yesod.Static+import Network.Socket (PortNumber)+import Data.Text (pack, unpack)++thisThread :: String+thisThread = "WebApp"++mkYesodDispatch "WebApp" $(parseRoutesFile "Assistant/WebApp/routes")++type Url = String++webAppThread +	:: Maybe ThreadState+	-> DaemonStatusHandle+	-> ScanRemoteMap+	-> TransferQueue+	-> TransferSlots+	-> UrlRenderer+	-> Maybe (IO String)+	-> Maybe (Url -> FilePath -> IO ())+	-> NamedThread+webAppThread mst dstatus scanremotes transferqueue transferslots urlrenderer postfirstrun onstartup = thread $ do+	webapp <- WebApp+		<$> pure mst+		<*> pure dstatus+		<*> pure scanremotes+		<*> pure transferqueue+		<*> pure transferslots+		<*> (pack <$> genRandomToken)+		<*> getreldir mst+		<*> pure $(embed "static")+		<*> newWebAppState+		<*> pure postfirstrun+	setUrlRenderer urlrenderer $ yesodRender webapp (pack "")+	app <- toWaiAppPlain webapp+	app' <- ifM debugEnabled+		( return $ httpDebugLogger app+		, return app+		)+	runWebApp app' $ \port -> case mst of+		Nothing -> withTempFile "webapp.html" $ \tmpfile _ ->+			go port webapp tmpfile Nothing+		Just st -> do+			htmlshim <- runThreadState st $ fromRepo gitAnnexHtmlShim+			urlfile <- runThreadState st $ fromRepo gitAnnexUrlFile+			go port webapp htmlshim (Just urlfile)+	where+		thread = NamedThread thisThread+		getreldir Nothing = return Nothing+		getreldir (Just st) = Just <$>+			(relHome =<< absPath+				=<< runThreadState st (fromRepo repoPath))+		go port webapp htmlshim urlfile = do+			debug thisThread ["running on port", show port]+			let url = myUrl webapp port+			maybe noop (`writeFile` url) urlfile+			writeHtmlShim url htmlshim+			maybe noop (\a -> a url htmlshim) onstartup++{- Creates a html shim file that's used to redirect into the webapp,+ - to avoid exposing the secretToken when launching the web browser. -}+writeHtmlShim :: String -> FilePath -> IO ()+writeHtmlShim url file = viaTmp go file $ genHtmlShim url+	where+		go tmpfile content = do+			h <- openFile tmpfile WriteMode+			modifyFileMode tmpfile $ removeModes [groupReadMode, otherReadMode]+			hPutStr h content+			hClose h++{- TODO: generate this static file using Yesod. -}+genHtmlShim :: String -> String+genHtmlShim url = unlines+	[ "<html>"+	, "<head>"+	, "<title>Starting webapp...</title>"+	, "<meta http-equiv=\"refresh\" content=\"0; URL="++url++"\">"+	, "<body>"+	, "<p>"+	, "<a href=\"" ++ url ++ "\">Starting webapp...</a>"+	, "</p>"+	, "</body>"+	, "</html>"+	]++myUrl :: WebApp -> PortNumber -> Url+myUrl webapp port = unpack $ yesodRender webapp urlbase HomeR []+	where+		urlbase = pack $ "http://localhost:" ++ show port
+ Assistant/TransferQueue.hs view
@@ -0,0 +1,204 @@+{- git-annex assistant pending transfer queue+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++module Assistant.TransferQueue (+	TransferQueue,+	Schedule(..),+	newTransferQueue,+	getTransferQueue,+	queueTransfers,+	queueTransfersMatching,+	queueDeferredDownloads,+	queueTransfer,+	queueTransferAt,+	queueTransferWhenSmall,+	getNextTransfer,+	getMatchingTransfers,+	dequeueTransfers,+) where++import Common.Annex+import Assistant.DaemonStatus+import Logs.Transfer+import Types.Remote+import qualified Remote+import qualified Types.Remote as Remote++import Control.Concurrent.STM+import qualified Data.Map as M++data TransferQueue = TransferQueue+	{ queuesize :: TVar Int+	, queuelist :: TVar [(Transfer, TransferInfo)]+	, deferreddownloads :: TVar [(Key, AssociatedFile)]+	}++data Schedule = Next | Later+	deriving (Eq)++newTransferQueue :: IO TransferQueue+newTransferQueue = atomically $ TransferQueue+	<$> newTVar 0+	<*> newTVar []+	<*> newTVar []++{- Reads the queue's content without blocking or changing it. -}+getTransferQueue :: TransferQueue -> IO [(Transfer, TransferInfo)]+getTransferQueue q = atomically $ readTVar $ queuelist q++stubInfo :: AssociatedFile -> Remote -> TransferInfo+stubInfo f r = stubTransferInfo+	{ transferRemote = Just r+	, associatedFile = f+	}++{- Adds transfers to queue for some of the known remotes. -}+queueTransfers :: Schedule -> TransferQueue -> DaemonStatusHandle -> Key -> AssociatedFile -> Direction -> Annex ()+queueTransfers = queueTransfersMatching (const True)++{- Adds transfers to queue for some of the known remotes, that match a+ - condition. -}+queueTransfersMatching :: (UUID -> Bool) -> Schedule -> TransferQueue -> DaemonStatusHandle -> Key -> AssociatedFile -> Direction -> Annex ()+queueTransfersMatching matching schedule q dstatus k f direction = do+	rs <- sufficientremotes+		=<< knownRemotes <$> liftIO (getDaemonStatus dstatus)+	let matchingrs = filter (matching . Remote.uuid) rs+	if null matchingrs+		then defer+		else forM_ matchingrs $ \r -> liftIO $+			enqueue schedule q dstatus (gentransfer r) (stubInfo f r)+	where+		sufficientremotes rs+			{- Queue downloads from all remotes that+			 - have the key, with the cheapest ones first.+			 - More expensive ones will only be tried if+			 - downloading from a cheap one fails. -}+			| direction == Download = do+				uuids <- Remote.keyLocations k+				return $ filter (\r -> uuid r `elem` uuids) rs+			{- TODO: Determine a smaller set of remotes that+			 - can be uploaded to, in order to ensure all+			 - remotes can access the content. Currently,+			 - send to every remote we can. -}+			| otherwise = return $ filter (not . Remote.readonly) rs+		gentransfer r = Transfer+			{ transferDirection = direction+			, transferKey = k+			, transferUUID = Remote.uuid r+			}+		defer+			{- Defer this download, as no known remote has the key. -}+			| direction == Download = void $ liftIO $ atomically $+					modifyTVar' (deferreddownloads q) $+						\l -> (k, f):l+			| otherwise = noop++{- Queues any deferred downloads that can now be accomplished, leaving+ - any others in the list to try again later. -}+queueDeferredDownloads :: Schedule -> TransferQueue -> DaemonStatusHandle -> Annex ()+queueDeferredDownloads schedule q dstatus = do+	rs <- knownRemotes <$> liftIO (getDaemonStatus dstatus)+	l <- liftIO $ atomically $ swapTVar (deferreddownloads q) []+	left <- filterM (queue rs) l+	unless (null left) $+		liftIO $ atomically $ modifyTVar' (deferreddownloads q) $+			\new -> new ++ left+	where+		queue rs (k, f) = do+			uuids <- Remote.keyLocations k+			let sources = filter (\r -> uuid r `elem` uuids) rs+			unless (null sources) $+				forM_ sources $ \r -> liftIO $+					enqueue schedule q dstatus+						(gentransfer r) (stubInfo f r)+			return $ null sources+			where+				gentransfer r = Transfer+					{ transferDirection = Download+					, transferKey = k+					, transferUUID = Remote.uuid r+					}++enqueue :: Schedule -> TransferQueue -> DaemonStatusHandle -> Transfer -> TransferInfo -> IO ()+enqueue schedule q dstatus t info+	| schedule == Next = go (new:)+	| otherwise = go (\l -> l++[new])+	where+		new = (t, info)+		go modlist = do+			atomically $ do+				void $ modifyTVar' (queuesize q) succ+				void $ modifyTVar' (queuelist q) modlist+			void $ notifyTransfer dstatus++{- Adds a transfer to the queue. -}+queueTransfer :: Schedule -> TransferQueue -> DaemonStatusHandle -> AssociatedFile -> Transfer -> Remote -> IO ()+queueTransfer schedule q dstatus f t remote =+	enqueue schedule q dstatus t (stubInfo f remote)++{- Blocks until the queue is no larger than a given size, and then adds a+ - transfer to the queue. -}+queueTransferAt :: Int -> Schedule -> TransferQueue -> DaemonStatusHandle -> AssociatedFile -> Transfer -> Remote -> IO ()+queueTransferAt wantsz schedule q dstatus f t remote = do+	atomically $ do+		sz <- readTVar (queuesize q)+		unless (sz <= wantsz) $+			retry -- blocks until queuesize changes+	enqueue schedule q dstatus t (stubInfo f remote)++queueTransferWhenSmall :: TransferQueue -> DaemonStatusHandle -> AssociatedFile -> Transfer -> Remote -> IO ()+queueTransferWhenSmall = queueTransferAt 10 Later++{- Blocks until a pending transfer is available in the queue,+ - and removes it.+ -+ - Checks that it's acceptable, before adding it to the+ - the currentTransfers map. If it's not acceptable, it's discarded.+ -+ - This is done in a single STM transaction, so there is no window+ - where an observer sees an inconsistent status. -}+getNextTransfer :: TransferQueue -> DaemonStatusHandle -> (TransferInfo -> Bool) -> IO (Maybe (Transfer, TransferInfo))+getNextTransfer q dstatus acceptable = atomically $ do+	sz <- readTVar (queuesize q)+	if sz < 1+		then retry -- blocks until queuesize changes+		else do+			(r@(t,info):rest) <- readTVar (queuelist q)+			writeTVar (queuelist q) rest+			void $ modifyTVar' (queuesize q) pred+			if acceptable info+				then do+					adjustTransfersSTM dstatus $+						M.insertWith' const t info+					return $ Just r+				else return Nothing++{- Moves transfers matching a condition from the queue, to the+ - currentTransfers map. -}+getMatchingTransfers :: TransferQueue -> DaemonStatusHandle -> (Transfer -> Bool) -> IO [(Transfer, TransferInfo)]+getMatchingTransfers q dstatus c = atomically $ do+	ts <- dequeueTransfersSTM q c+	unless (null ts) $+		adjustTransfersSTM dstatus $ \m -> M.union m $ M.fromList ts+	return ts++{- Removes transfers matching a condition from the queue, and returns the+ - removed transfers. -}+dequeueTransfers :: TransferQueue -> DaemonStatusHandle -> (Transfer -> Bool) -> IO [(Transfer, TransferInfo)]+dequeueTransfers q dstatus c = do+	removed <- atomically $ dequeueTransfersSTM q c+	unless (null removed) $+		notifyTransfer dstatus+	return removed++dequeueTransfersSTM :: TransferQueue -> (Transfer -> Bool) -> STM [(Transfer, TransferInfo)]+dequeueTransfersSTM q c = do+	(removed, ts) <- partition (c . fst)+		<$> readTVar (queuelist q)+	void $ writeTVar (queuesize q) (length ts)+	void $ writeTVar (queuelist q) ts+	return removed
+ Assistant/TransferSlots.hs view
@@ -0,0 +1,89 @@+{- git-annex assistant transfer slots+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++{-# LANGUAGE DeriveDataTypeable #-}++module Assistant.TransferSlots where++import Common.Annex+import Utility.ThreadScheduler+import Assistant.DaemonStatus+import Logs.Transfer++import qualified Control.Exception as E+import Control.Concurrent+import Data.Typeable++type TransferSlots = QSemN++{- A special exception that can be thrown to pause or resume a transfer, while+ - keeping its slot in use. -}+data TransferException = PauseTransfer | ResumeTransfer+	deriving (Show, Eq, Typeable)++instance E.Exception TransferException++type TransferSlotRunner = DaemonStatusHandle -> TransferSlots -> TransferGenerator -> IO ()+type TransferGenerator = IO (Maybe (Transfer, TransferInfo, IO ()))++{- Number of concurrent transfers allowed to be run from the assistant.+ -+ - Transfers launched by other means, including by remote assistants,+ - do not currently take up slots.+ -}+numSlots :: Int+numSlots = 1++newTransferSlots :: IO TransferSlots+newTransferSlots = newQSemN numSlots++{- Waits until a transfer slot becomes available, then runs a+ - TransferGenerator, and then runs the transfer action in its own thread. + -}+inTransferSlot :: TransferSlotRunner+inTransferSlot dstatus s gen = do+	waitQSemN s 1+	runTransferThread dstatus s =<< gen++{- Runs a TransferGenerator, and its transfer action,+ - without waiting for a slot to become available. -}+inImmediateTransferSlot :: TransferSlotRunner+inImmediateTransferSlot dstatus s gen = do+	signalQSemN s (-1)+	runTransferThread dstatus s =<< gen++{- Runs a transfer action, in an already allocated transfer slot.+ - Once it finishes, frees the transfer slot.+ -+ - Note that the action is subject to being killed when the transfer+ - is canceled or paused.+ -+ - A PauseTransfer exception is handled by letting the action be killed,+ - then pausing the thread until a ResumeTransfer exception is raised,+ - then rerunning the action.+ -}+runTransferThread :: DaemonStatusHandle -> TransferSlots -> Maybe (Transfer, TransferInfo, IO ()) -> IO ()+runTransferThread _ s  Nothing = signalQSemN s 1+runTransferThread dstatus s (Just (t, info, a)) = do+	tid <- forkIO go+	updateTransferInfo dstatus t $ info { transferTid = Just tid }+	where+		go = catchPauseResume a+		pause = catchPauseResume $ runEvery (Seconds 86400) noop+		{- Note: This must use E.try, rather than E.catch.+		 - When E.catch is used, and has called go in its exception+		 - handler, Control.Concurrent.throwTo will block sometimes+		 - when signaling. Using E.try avoids the problem. -}+		catchPauseResume a' = do+			r <- E.try a' :: IO (Either E.SomeException ())+			case r of+				Left e -> case E.fromException e of+					Just PauseTransfer -> pause+					Just ResumeTransfer -> go+					_ -> done+				_ -> done+		done = signalQSemN s 1
− Assistant/Watcher.hs
@@ -1,220 +0,0 @@-{- git-annex assistant tree watcher- -- - Copyright 2012 Joey Hess <joey@kitenet.net>- -- - Licensed under the GNU GPL version 3 or higher.- -}--{-# LANGUAGE CPP #-}--module Assistant.Watcher where--import Common.Annex-import Assistant.ThreadedMonad-import Assistant.DaemonStatus-import Assistant.Changes-import Utility.DirWatcher-import Utility.Types.DirWatcher-import qualified Annex-import qualified Annex.Queue-import qualified Git.Command-import qualified Git.UpdateIndex-import qualified Git.HashObject-import qualified Git.LsFiles-import qualified Backend-import qualified Command.Add-import Annex.Content-import Annex.CatFile-import Git.Types--import Control.Concurrent.STM-import Data.Bits.Utils-import qualified Data.ByteString.Lazy as L--checkCanWatch :: Annex ()-checkCanWatch-	| canWatch = -		unlessM (liftIO (inPath "lsof") <||> Annex.getState Annex.force) $-			needLsof-	| otherwise = error "watch mode is not available on this system"--needLsof :: Annex ()-needLsof = error $ unlines-	[ "The lsof command is needed for watch mode to be safe, and is not in PATH."-	, "To override lsof checks to ensure that files are not open for writing"-	, "when added to the annex, you can use --force"-	, "Be warned: This can corrupt data in the annex, and make fsck complain."-	]--watchThread :: ThreadState -> DaemonStatusHandle -> ChangeChan -> IO ()-watchThread st dstatus changechan = watchDir "." ignored hooks startup-	where-		startup = statupScan st dstatus-		hook a = Just $ runHandler st dstatus changechan a-		hooks = WatchHooks-			{ addHook = hook onAdd-			, delHook = hook onDel-			, addSymlinkHook = hook onAddSymlink-			, delDirHook = hook onDelDir-			, errHook = hook onErr-			}--{- Initial scartup scan. The action should return once the scan is complete. -}-statupScan :: ThreadState -> DaemonStatusHandle -> IO a -> IO a-statupScan st dstatus scanner = do-	runThreadState st $-		showAction "scanning"-	r <- scanner-	runThreadState st $-		modifyDaemonStatus dstatus $ \s -> s { scanComplete = True }--	-- Notice any files that were deleted before watching was started.-	runThreadState st $ do-		inRepo $ Git.Command.run "add" [Param "--update"]-		showAction "started"--	return r--ignored :: FilePath -> Bool-ignored = ig . takeFileName-	where-	ig ".git" = True-	ig ".gitignore" = True-	ig ".gitattributes" = True-	ig _ = False--type Handler = FilePath -> Maybe FileStatus -> DaemonStatusHandle -> Annex (Maybe Change)--{- Runs an action handler, inside the Annex monad, and if there was a- - change, adds it to the ChangeChan.- -- - Exceptions are ignored, otherwise a whole watcher thread could be crashed.- -}-runHandler :: ThreadState -> DaemonStatusHandle -> ChangeChan -> Handler -> FilePath -> Maybe FileStatus -> IO ()-runHandler st dstatus changechan handler file filestatus = void $ do-	r <- tryIO go-	case r of-		Left e -> print e-		Right Nothing -> noop-		Right (Just change) -> void $-			runChangeChan $ writeTChan changechan change-	where-		go = runThreadState st $ handler file filestatus dstatus--{- During initial directory scan, this will be run for any regular files- - that are already checked into git. We don't want to turn those into- - symlinks, so do a check. This is rather expensive, but only happens- - during startup.- -- - It's possible for the file to still be open for write by some process.- - This can happen in a few ways; one is if two processes had the file open- - and only one has just closed it. We want to avoid adding a file to the- - annex that is open for write, to avoid anything being able to change it.- -- - We could run lsof on the file here to check for other writers.- - But, that's slow, and even if there is currently a writer, we will want- - to add the file *eventually*. Instead, the file is locked down as a hard- - link in a temp directory, with its write bits disabled, for later- - checking with lsof, and a Change is returned containing a KeySource- - using that hard link. The committer handles running lsof and finishing- - the add.- -}-onAdd :: Handler-onAdd file filestatus dstatus-	| maybe False isRegularFile filestatus = do-		ifM (scanComplete <$> getDaemonStatus dstatus)-			( go-			, ifM (null <$> inRepo (Git.LsFiles.notInRepo False [file]))-				( noChange-				, go-				)-			)-	| otherwise = noChange-	where-		go = pendingAddChange =<< Command.Add.lockDown file--{- A symlink might be an arbitrary symlink, which is just added.- - Or, if it is a git-annex symlink, ensure it points to the content- - before adding it.- -}-onAddSymlink :: Handler-onAddSymlink file filestatus dstatus = go =<< Backend.lookupFile file-	where-		go (Just (key, _)) = do-			link <- calcGitLink file key-			ifM ((==) link <$> liftIO (readSymbolicLink file))-				( ensurestaged link =<< getDaemonStatus dstatus-				, do-					liftIO $ removeFile file-					liftIO $ createSymbolicLink link file-					addlink link-				)-		go Nothing = do -- other symlink-			link <- liftIO (readSymbolicLink file)-			ensurestaged link =<< getDaemonStatus dstatus--		{- This is often called on symlinks that are already-		 - staged correctly. A symlink may have been deleted-		 - and being re-added, or added when the watcher was-		 - not running. So they're normally restaged to make sure.-		 --		 - As an optimisation, during the status scan, avoid-		 - restaging everything. Only links that were created since-		 - the last time the daemon was running are staged.-		 - (If the daemon has never ran before, avoid staging-		 - links too.)-		 -}-		ensurestaged link daemonstatus-			| scanComplete daemonstatus = addlink link-			| otherwise = case filestatus of-				Just s-					| not (afterLastDaemonRun (statusChangeTime s) daemonstatus) -> noChange-				_ -> addlink link--		{- For speed, tries to reuse the existing blob for-		 - the symlink target. -}-		addlink link = do-			v <- catObjectDetails $ Ref $ ':':file-			case v of-				Just (currlink, sha)-					| s2w8 link == L.unpack currlink ->-						stageSymlink file sha-				_ -> do-					sha <- inRepo $-						Git.HashObject.hashObject BlobObject link-					stageSymlink file sha-			madeChange file LinkChange--onDel :: Handler-onDel file _ _dstatus = do-	Annex.Queue.addUpdateIndex =<<-		inRepo (Git.UpdateIndex.unstageFile file)-	madeChange file RmChange--{- A directory has been deleted, or moved, so tell git to remove anything- - that was inside it from its cache. Since it could reappear at any time,- - use --cached to only delete it from the index. - -- - Note: This could use unstageFile, but would need to run another git- - command to get the recursive list of files in the directory, so rm is- - just as good. -}-onDelDir :: Handler-onDelDir dir _ _dstatus = do-	Annex.Queue.addCommand "rm"-		[Params "--quiet -r --cached --ignore-unmatch --"] [dir]-	madeChange dir RmDirChange--{- Called when there's an error with inotify. -}-onErr :: Handler-onErr msg _ _dstatus = do-	warning msg-	return Nothing--{- Adds a symlink to the index, without ever accessing the actual symlink- - on disk. This avoids a race if git add is used, where the symlink is- - changed to something else immediately after creation.- -}-stageSymlink :: FilePath -> Sha -> Annex ()-stageSymlink file sha =-	Annex.Queue.addUpdateIndex =<<-		inRepo (Git.UpdateIndex.stageSymlink file sha)
+ Assistant/WebApp.hs view
@@ -0,0 +1,158 @@+{- git-annex assistant webapp core+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU AGPL version 3 or higher.+ -}++{-# LANGUAGE TypeFamilies, QuasiQuotes, MultiParamTypeClasses, TemplateHaskell, OverloadedStrings, RankNTypes #-}++module Assistant.WebApp where++import Assistant.WebApp.Types+import Assistant.Common+import Assistant.ThreadedMonad+import Assistant.DaemonStatus+import Utility.NotificationBroadcaster+import Utility.Yesod+import Locations.UserConfig++import Yesod+import Text.Hamlet+import Data.Text (Text)+import Control.Concurrent.STM+import Control.Concurrent++data NavBarItem = DashBoard | Config | About+	deriving (Eq)++navBarName :: NavBarItem -> Text+navBarName DashBoard = "Dashboard"+navBarName Config = "Configuration"+navBarName About = "About"++navBarRoute :: NavBarItem -> Route WebApp+navBarRoute DashBoard = HomeR+navBarRoute Config = ConfigR+navBarRoute About = AboutR++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 . relDir <$> 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+		$(widgetFile "page")+	hamletToRepHtml $(hamletFile $ hamletTemplate "bootstrap")+	where+		navdetails i = (navBarName i, navBarRoute i, Just i == navbaritem)++newWebAppState :: IO (TMVar WebAppState)+newWebAppState = do+	otherrepos <- listOtherRepos+	atomically $ newTMVar $ WebAppState+		{ showIntro = True+		, otherRepos = otherrepos }++getWebAppState :: forall sub. GHandler sub WebApp WebAppState+getWebAppState = liftIO . atomically . readTMVar =<< webAppState <$> getYesod++modifyWebAppState :: forall sub. (WebAppState -> WebAppState) -> GHandler sub WebApp ()+modifyWebAppState a = go =<< webAppState <$> getYesod+	where+		go s = liftIO $ atomically $ do+			v <- takeTMVar s+			putTMVar s $ a v++{- Runs an Annex action from the webapp.+ -+ - When the webapp is run outside a git-annex repository, the fallback+ - value is returned.+ -}+runAnnex :: forall sub a. a -> Annex a -> GHandler sub WebApp a+runAnnex fallback a = maybe (return fallback) go =<< threadState <$> getYesod+	where+		go st = liftIO $ runThreadState st a++waitNotifier :: forall sub. (DaemonStatus -> NotificationBroadcaster) -> NotificationId -> GHandler sub WebApp ()+waitNotifier selector nid = do+	notifier <- getNotifier selector+	liftIO $ waitNotification $ notificationHandleFromId notifier nid++newNotifier :: forall sub. (DaemonStatus -> NotificationBroadcaster) -> GHandler sub WebApp NotificationId+newNotifier selector = do+	notifier <- getNotifier selector+	liftIO $ notificationHandleToId <$> newNotificationHandle notifier++getNotifier :: forall sub. (DaemonStatus -> NotificationBroadcaster) -> GHandler sub WebApp NotificationBroadcaster+getNotifier selector = do+	webapp <- getYesod+	liftIO $ selector <$> getDaemonStatus (daemonStatus webapp)++{- 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}">|]++{- A button with an icon, and maybe label, that can be clicked to perform+ - some action.+ - With javascript, clicking it POSTs the Route, and remains on the same+ - page.+ - With noscript, clicking it GETs the Route. -}+actionButton :: Route WebApp -> (Maybe String) -> String -> String -> Widget+actionButton route label buttonclass iconclass = $(widgetFile "actionbutton")++type UrlRenderFunc = Route WebApp -> [(Text, Text)] -> Text+type UrlRenderer = MVar (UrlRenderFunc)++newUrlRenderer :: IO UrlRenderer+newUrlRenderer = newEmptyMVar++setUrlRenderer :: UrlRenderer -> (UrlRenderFunc) -> IO ()+setUrlRenderer = putMVar++{- Blocks until the webapp is running and has called setUrlRenderer. -}+renderUrl :: UrlRenderer -> Route WebApp -> [(Text, Text)] -> IO Text+renderUrl urlrenderer route params = do+	r <- readMVar urlrenderer+	return $ r route params++{- Redirects back to the referring page, or if there's none, HomeR -}+redirectBack :: Handler ()+redirectBack = do+	clearUltDest+	setUltDestReferer+	redirectUltDest HomeR++{- List of other known repsitories, and link to add a new one. -}+otherReposWidget :: Widget+otherReposWidget = do+	repolist <- lift $ otherRepos <$> getWebAppState+	$(widgetFile "otherrepos")++listOtherRepos :: IO [(String, String)]+listOtherRepos = do+	f <- autoStartFile+	dirs <- ifM (doesFileExist f) ( lines <$> readFile f, return [])+	names <- mapM relHome dirs+	return $ sort $ zip names dirs
+ Assistant/WebApp/Configurators.hs view
@@ -0,0 +1,91 @@+{- git-annex assistant webapp configurators+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU AGPL version 3 or higher.+ -}++{-# LANGUAGE TypeFamilies, QuasiQuotes, MultiParamTypeClasses, TemplateHaskell, OverloadedStrings, RankNTypes #-}++module Assistant.WebApp.Configurators where++import Assistant.Common+import Assistant.WebApp+import Assistant.WebApp.Types+import Assistant.WebApp.SideBar+import Assistant.DaemonStatus+import Assistant.WebApp.Configurators.Local+import Utility.Yesod+import qualified Remote+import qualified Types.Remote as Remote+import Annex.UUID (getUUID)+import Logs.Remote+import Logs.Trust++import Yesod+import Data.Text (Text)+import qualified Data.Map as M++{- The main configuration screen. -}+getConfigR :: Handler RepHtml+getConfigR = ifM (inFirstRun)+	( getFirstRepositoryR+	, bootstrap (Just Config) $ do+		sideBarDisplay+		setTitle "Configuration"+		$(widgetFile "configurators/main")+	)++{- Lists known repositories, followed by options to add more. -}+getRepositoriesR :: Handler RepHtml+getRepositoriesR = bootstrap (Just Config) $ do+	sideBarDisplay+	setTitle "Repositories"+	repolist <- lift $ repoList False+	$(widgetFile "configurators/repositories")++{- A numbered list of known repositories, including the current one. -}+repoList :: Bool -> Handler [(String, String, Maybe (Route WebApp))]+repoList onlyconfigured+	| onlyconfigured = list =<< configured+	| otherwise = list =<< (++) <$> configured <*> unconfigured+	where+		configured = do+			rs <- filter (not . Remote.readonly) . knownRemotes <$>+				(liftIO . getDaemonStatus =<< daemonStatus <$> getYesod)+			runAnnex [] $ do+				u <- getUUID+				return $ zip (u : map Remote.uuid rs) (repeat Nothing)+		unconfigured = runAnnex [] $ do+			m <- readRemoteLog+			catMaybes . map (findtype m) . snd+				<$> (trustPartition DeadTrusted $ M.keys m)+		findtype m u = case M.lookup u m of+			Nothing -> Nothing+			Just c -> case M.lookup "type" c of+				Just "rsync" -> u `enableswith` EnableRsyncR+				Just "directory" -> u `enableswith` EnableDirectoryR+				_ -> Nothing+		u `enableswith` r = Just (u, Just $ r u)+		list l = runAnnex [] $ do+			let l' = nubBy (\x y -> fst x == fst y) l+			zip3+				<$> pure counter+				<*> Remote.prettyListUUIDs (map fst l')+				<*> pure (map snd l')+		counter = map show ([1..] :: [Int])++{- An intro message, list of repositories, and nudge to make more. -}+introDisplay :: Text -> Widget+introDisplay ident = do+	webapp <- lift getYesod+	repolist <- lift $ repoList True+	let n = length repolist+	let numrepos = show n+	let notenough = n < enough+	let barelyenough = n == enough+	let morethanenough = n > enough+	$(widgetFile "configurators/intro")+	lift $ modifyWebAppState $ \s -> s { showIntro = False }+	where+		enough = 2
+ Assistant/WebApp/Configurators/Local.hs view
@@ -0,0 +1,319 @@+{- git-annex assistant webapp configurators for making local repositories+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU AGPL version 3 or higher.+ -}++{-# LANGUAGE TypeFamilies, QuasiQuotes, MultiParamTypeClasses, TemplateHaskell, OverloadedStrings, RankNTypes #-}++module Assistant.WebApp.Configurators.Local where++import Assistant.Common+import Assistant.WebApp+import Assistant.WebApp.Types+import Assistant.WebApp.SideBar+import Assistant.Sync+import Assistant.MakeRemote+import Utility.Yesod+import Init+import qualified Git+import qualified Git.Construct+import qualified Git.Config+import qualified Annex+import Locations.UserConfig+import Utility.FreeDesktop+import Utility.Mounts+import Utility.DiskFree+import Utility.DataUnits+import Utility.Network+import Remote (prettyListUUIDs)++import Yesod+import Data.Text (Text)+import qualified Data.Text as T+import Data.Char+import System.Posix.Directory+import qualified Control.Exception as E++data RepositoryPath = RepositoryPath Text+	deriving Show++{- Custom field display for a RepositoryPath, with an icon etc.+ -+ - Validates that the path entered is not empty, and is a safe value+ - to use as a repository. -}+repositoryPathField :: forall sub. Bool -> Field sub WebApp Text+repositoryPathField autofocus = Field { fieldParse = parse, fieldView = view }+	where+		view idAttr nameAttr attrs val isReq =+			[whamlet|<input type="text" *{attrs} id="#{idAttr}" name="#{nameAttr}" :isReq:required :autofocus:autofocus value="#{either id id val}">|]++		parse [path]+			| T.null path = nopath+			| otherwise = liftIO $ checkRepositoryPath path+		parse [] = return $ Right Nothing+		parse _ = nopath++		nopath = return $ Left "Enter a location for the repository"++{- As well as checking the path for a lot of silly things, tilde is+ - expanded in the returned path. -}+checkRepositoryPath :: Text -> IO (Either (SomeMessage WebApp) (Maybe Text))+checkRepositoryPath p = do+	home <- myHomeDir+	let basepath = expandTilde home $ T.unpack p+	path <- absPath basepath+	let parent = parentDir path+	problems <- catMaybes <$> mapM runcheck+		[ (return $ path == "/", "Enter the full path to use for the repository.")+		, (return $ all isSpace basepath, "A blank path? Seems unlikely.")+		, (doesFileExist path, "A file already exists with that name.")+		, (return $ path == home, "Sorry, using git-annex for your whole home directory is not currently supported.")+		, (not <$> doesDirectoryExist parent, "Parent directory does not exist.")+		, (not <$> canWrite path, "Cannot write a repository there.")+		, (not <$> canMakeSymlink path, "That directory is on a filesystem that does not support symlinks. Try a different location.")+		]+	return $ +		case headMaybe problems of+			Nothing -> Right $ Just $ T.pack basepath+			Just prob -> Left prob+	where+		runcheck (chk, msg) = ifM (chk)+			( return $ Just msg+			, return Nothing+			)+		expandTilde home ('~':'/':path) = home </> path+		expandTilde _ path = path+		++{- On first run, if run in the home directory, default to putting it in+ - ~/Desktop/annex, when a Desktop directory exists, and ~/annex otherwise.+ -+ - If run in another directory, the user probably wants to put it there. -}+defaultRepositoryPath :: Bool -> IO FilePath+defaultRepositoryPath firstrun = do+	cwd <- liftIO $ getCurrentDirectory+	home <- myHomeDir+	if home == cwd && firstrun+		then do+			desktop <- userDesktopDir+			ifM (doesDirectoryExist desktop)+				( relHome $ desktop </> gitAnnexAssistantDefaultDir+				, return $ "~" </> gitAnnexAssistantDefaultDir+				)+		else return cwd++newRepositoryForm :: FilePath -> Form RepositoryPath+newRepositoryForm defpath msg = do+	(pathRes, pathView) <- mreq (repositoryPathField True) ""+		(Just $ T.pack $ addTrailingPathSeparator defpath)+	let (err, errmsg) = case pathRes of+		FormMissing -> (False, "")+		FormFailure l -> (True, concat $ map T.unpack l)+		FormSuccess _ -> (False, "")+	let form = do+		webAppFormAuthToken+		$(widgetFile "configurators/newrepository/form")+	return (RepositoryPath <$> pathRes, form)++{- Making the first repository, when starting the webapp for the first time. -}+getFirstRepositoryR :: Handler RepHtml+getFirstRepositoryR = bootstrap (Just Config) $ do+	sideBarDisplay+	setTitle "Getting started"	+	path <- liftIO . defaultRepositoryPath =<< lift inFirstRun+	((res, form), enctype) <- lift $ runFormGet $ newRepositoryForm path+	case res of+		FormSuccess (RepositoryPath p) -> lift $+			startFullAssistant $ T.unpack p+		_ -> $(widgetFile "configurators/newrepository/first")++{- Adding a new, separate repository. -}+getNewRepositoryR :: Handler RepHtml+getNewRepositoryR = bootstrap (Just Config) $ do+	sideBarDisplay+	setTitle "Add another repository"+	home <- liftIO myHomeDir+	((res, form), enctype) <- lift $ runFormGet $ newRepositoryForm home+	case res of+		FormSuccess (RepositoryPath p) -> lift $ do+			let path = T.unpack p+			liftIO $ do+				makeRepo path False+				initRepo path Nothing+				addAutoStart path+			redirect $ SwitchToRepositoryR path+		_ -> $(widgetFile "configurators/newrepository")++data RemovableDrive = RemovableDrive +	{ diskFree :: Maybe Integer+	, mountPoint :: Text+	}+	deriving (Show, Eq, Ord)++selectDriveForm :: [RemovableDrive] -> Maybe RemovableDrive -> Form RemovableDrive+selectDriveForm drives def = renderBootstrap $ RemovableDrive+	<$> pure Nothing+	<*> areq (selectFieldList pairs) "Select drive:" (mountPoint <$> def)+	where+		pairs = zip (map describe drives) (map mountPoint drives)+		describe drive = case diskFree drive of+			Nothing -> mountPoint drive+			Just free -> +				let sz = roughSize storageUnits True free+				in T.unwords+					[ mountPoint drive+					, T.concat ["(", T.pack sz]+					, "free)"+					]++{- Adding a removable drive. -}+getAddDriveR :: Handler RepHtml+getAddDriveR = bootstrap (Just Config) $ do+	sideBarDisplay+	setTitle "Add a removable drive"+	removabledrives <- liftIO $ driveList+	writabledrives <- liftIO $+		filterM (canWrite . T.unpack . mountPoint) removabledrives+	((res, form), enctype) <- lift $ runFormGet $+		selectDriveForm (sort writabledrives) Nothing+	case res of+		FormSuccess (RemovableDrive { mountPoint = d }) -> lift $ do+			go $ T.unpack d+			redirect RepositoriesR+		_ -> do+			let authtoken = webAppFormAuthToken+			$(widgetFile "configurators/adddrive")+	where+		go mountpoint = do+			liftIO $ makerepo dir+			liftIO $ initRepo dir $ Just remotename+			r <- addremote dir remotename+			syncRemote r+			where+				dir = mountpoint </> gitAnnexAssistantDefaultDir+				remotename = takeFileName mountpoint+		{- The repo may already exist, when adding removable media+		 - that has already been used elsewhere. -}+		makerepo dir = liftIO $ do+			r <- E.try (inDir dir $ return True) :: IO (Either E.SomeException Bool)+			case r of+				Right _ -> noop+				Left _e -> do+					createDirectoryIfMissing True dir+					bare <- not <$> canMakeSymlink dir+					makeRepo dir bare+		{- Each repository is made a remote of the other. -}+		addremote dir name = runAnnex undefined $ do+			hostname <- maybe "host" id <$> liftIO getHostname+			hostlocation <- fromRepo Git.repoLocation+			liftIO $ inDir dir $+				void $ makeGitRemote hostname hostlocation+			addRemote $ makeGitRemote name dir++getEnableDirectoryR :: UUID -> Handler RepHtml+getEnableDirectoryR uuid = bootstrap (Just Config) $ do+	sideBarDisplay+	setTitle "Enable a repository"+	description <- lift $ runAnnex "" $+		T.pack . concat <$> prettyListUUIDs [uuid]+	$(widgetFile "configurators/enabledirectory")++{- Start syncing a newly added remote, using a background thread. -}+syncRemote :: Remote -> Handler ()+syncRemote remote = do+	webapp <- getYesod+	liftIO $ syncNewRemote+		(fromJust $ threadState webapp)+		(daemonStatus webapp)+		(scanRemotes webapp)+		remote++{- List of removable drives. -}+driveList :: IO [RemovableDrive]+driveList = mapM (gen . mnt_dir) =<< filter sane <$> getMounts+	where+		gen dir = RemovableDrive+			<$> getDiskFree dir+			<*> pure (T.pack dir)+		-- filter out some things that are surely not removable drives+		sane Mntent { mnt_dir = dir, mnt_fsname = dev }+			{- We want real disks like /dev/foo, not+			 - dummy mount points like proc or tmpfs or+			 - gvfs-fuse-daemon. -}+			| not ('/' `elem` dev) = False+			{- Just in case: These mount points are surely not+			 - removable disks. -}+			| dir == "/" = False+			| dir == "/tmp" = False+			| dir == "/run/shm" = False+			| dir == "/run/lock" = False+			| otherwise = True++{- Bootstraps from first run mode to a fully running assistant in a+ - repository, by running the postFirstRun callback, which returns the+ - url to the new webapp. -}+startFullAssistant :: FilePath -> Handler ()+startFullAssistant path = do+	webapp <- getYesod+	url <- liftIO $ do+		makeRepo path False+		initRepo path Nothing+		addAutoStart path+		changeWorkingDirectory path+		fromJust $ postFirstRun webapp+	redirect $ T.pack url++{- Makes a new git-annex repository. -}+makeRepo :: FilePath -> Bool -> IO ()+makeRepo path bare = do+	unlessM (boolSystem "git" params) $+		error "git init failed!"+	where+		baseparams = [Param "init", Param "--quiet"]+		params+			| bare = baseparams ++ [Param "--bare", File path]+			| otherwise = baseparams ++ [File path]++{- Runs an action in the git-annex repository in the specified directory. -}+inDir :: FilePath -> Annex a -> IO a+inDir dir a = do+	state <- Annex.new =<< Git.Config.read =<< Git.Construct.fromPath dir+	Annex.eval state a++{- Initializes a git-annex repository in a directory with a description. -}+initRepo :: FilePath -> Maybe String -> IO ()+initRepo dir desc = inDir dir $+	unlessM isInitialized $+		initialize desc++{- Adds a directory to the autostart file. -}+addAutoStart :: FilePath -> IO ()+addAutoStart path = do+	autostart <- autoStartFile+	createDirectoryIfMissing True (parentDir autostart)+	appendFile autostart $ path ++ "\n"++{- Checks if the user can write to a directory.+ -+ - The directory may be in the process of being created; if so+ - the parent directory is checked instead. -}+canWrite :: FilePath -> IO Bool		+canWrite dir = do+	tocheck <- ifM (doesDirectoryExist dir)+		(return dir, return $ parentDir dir)+	catchBoolIO $ fileAccess tocheck False True False++{- Checks if a directory is on a filesystem that supports symlinks. -}+canMakeSymlink :: FilePath -> IO Bool+canMakeSymlink dir = ifM (doesDirectoryExist dir)+	( catchBoolIO $ test dir+	, canMakeSymlink (parentDir dir)+	)+	where+		test d = do+			let link = d </> "delete.me"+			createSymbolicLink link link+			removeLink link+			return True
+ Assistant/WebApp/Configurators/Pairing.hs view
@@ -0,0 +1,204 @@+{- git-annex assistant webapp configurator for pairing+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU AGPL version 3 or higher.+ -}++{-# LANGUAGE TypeFamilies, QuasiQuotes, MultiParamTypeClasses, TemplateHaskell, OverloadedStrings, RankNTypes #-}+{-# LANGUAGE CPP #-}++module Assistant.WebApp.Configurators.Pairing where++import Assistant.Pairing+import Assistant.WebApp+import Assistant.WebApp.Types+import Assistant.WebApp.SideBar+import Utility.Yesod+#ifdef WITH_PAIRING+import Assistant.Common+import Assistant.Pairing.Network+import Assistant.Pairing.MakeRemote+import Assistant.Ssh+import Assistant.Alert+import Assistant.DaemonStatus+import Utility.Verifiable+import Utility.Network+import Annex.UUID+#endif++import Yesod+import Data.Text (Text)+#ifdef WITH_PAIRING+import qualified Data.Text as T+import qualified Data.Text.Encoding as T+import qualified Data.ByteString.Lazy as B+import Data.Char+import System.Posix.User+import qualified Control.Exception as E+import Control.Concurrent+#endif++{- Starts sending out pair requests. -}+getStartPairR :: Handler RepHtml+#ifdef WITH_PAIRING+getStartPairR = promptSecret Nothing $ startPairing PairReq noop pairingAlert Nothing+#else+getStartPairR = noPairing+#endif++{- Runs on the system that responds to a pair request; sets up the ssh+ - authorized key first so that the originating host can immediately sync+ - with us. -}+getFinishPairR :: PairMsg -> Handler RepHtml+#ifdef WITH_PAIRING+getFinishPairR msg = promptSecret (Just msg) $ \_ secret -> do+	liftIO $ setup+	startPairing PairAck cleanup alert uuid "" secret+	where+		alert = pairRequestAcknowledgedAlert (pairRepo msg) . Just+		setup  = setupAuthorizedKeys msg+		cleanup = removeAuthorizedKeys False $+			remoteSshPubKey $ pairMsgData msg+		uuid = Just $ pairUUID $ pairMsgData msg+#else+getFinishPairR _ = noPairing+#endif++getInprogressPairR :: SecretReminder -> Handler RepHtml+#ifdef WITH_PAIRING+getInprogressPairR s = pairPage $ do+	let secret = fromSecretReminder s+	$(widgetFile "configurators/pairing/inprogress")+#else+getInprogressPairR _ = noPairing+#endif++#ifdef WITH_PAIRING++{- Starts pairing, at either the PairReq (initiating host) or + - PairAck (responding host) stage.+ -+ - Displays an alert, and starts a thread sending the pairing message,+ - which will continue running until the other host responds, or until+ - canceled by the user. If canceled by the user, runs the oncancel action.+ -+ - Redirects to the pairing in progress page.+ -}+startPairing :: PairStage -> IO () -> (AlertButton -> Alert) -> Maybe UUID -> Text -> Secret -> Widget+startPairing stage oncancel alert muuid displaysecret secret = do+	dstatus <- daemonStatus <$> lift getYesod+	urlrender <- lift getUrlRender+	reldir <- fromJust . relDir <$> lift getYesod++	{- Generating a ssh key pair can take a while, so do it in the+	 - background. -}+	void $ liftIO $ forkIO $ do+		keypair <- genSshKeyPair+		pairdata <- PairData+			<$> getHostname+			<*> getUserName+			<*> pure reldir+			<*> pure (sshPubKey keypair)+			<*> (maybe genUUID return muuid)+		let sender = multicastPairMsg Nothing secret pairdata+		let pip = PairingInProgress secret Nothing keypair pairdata stage+		startSending dstatus pip stage $ sendrequests sender dstatus urlrender++	lift $ redirect $ InprogressPairR $ toSecretReminder displaysecret+	where+		{- Sends pairing messages until the thread is killed,+		 - and shows an activity alert while doing it.+		 -+		 - The cancel button returns the user to the HomeR. This is+		 - not ideal, but they have to be sent somewhere, and could+		 - have been on a page specific to the in-process pairing+		 - that just stopped, so can't go back there.+		 -}+		sendrequests sender dstatus urlrender _stage = do+			tid <- myThreadId+			let selfdestruct = AlertButton+				{ buttonLabel = "Cancel"+				, buttonUrl = urlrender HomeR+				, buttonAction = Just $ const $ do+					oncancel+					killThread tid+				}+			alertDuring dstatus (alert selfdestruct) $ do+				_ <- E.try (sender stage) :: IO (Either E.SomeException ())+				return ()++data InputSecret = InputSecret { secretText :: Maybe Text }++{- If a PairMsg is passed in, ensures that the user enters a secret+ - that can validate it. -}+promptSecret :: Maybe PairMsg -> (Text -> Secret -> Widget) -> Handler RepHtml+promptSecret msg cont = pairPage $ do+	((result, form), enctype) <- lift $+		runFormGet $ renderBootstrap $+			InputSecret <$> aopt textField "Secret phrase" Nothing+        case result of+                FormSuccess v -> do+			let rawsecret = fromMaybe "" $ secretText v+			let secret = toSecret rawsecret+			case msg of+				Nothing -> case secretProblem secret of+					Nothing -> cont rawsecret secret+					Just problem ->+						showform form enctype $ Just problem+				Just m ->+					if verify (fromPairMsg m) secret+						then cont rawsecret secret+						else showform form enctype $ Just+							"That's not the right secret phrase."+                _ -> showform form enctype Nothing+        where+                showform form enctype mproblem = do+			let start = isNothing msg+			let badphrase = isJust mproblem+			let problem = fromMaybe "" mproblem+			let (username, hostname) = maybe ("", "")+				(\(_, v, a) -> (T.pack $ remoteUserName v, T.pack $ fromMaybe (showAddr a) (remoteHostName v)))+				(verifiableVal . fromPairMsg <$> msg)+			u <- T.pack <$> liftIO getUserName+			let sameusername = username == u+                        let authtoken = webAppFormAuthToken+                        $(widgetFile "configurators/pairing/prompt")++{- This counts unicode characters as more than one character,+ - but that's ok; they *do* provide additional entropy. -}+secretProblem :: Secret -> Maybe Text+secretProblem s+	| B.null s = Just "The secret phrase cannot be left empty. (Remember that punctuation and white space is ignored.)"+	| B.length s < 7 = Just "Enter a longer secret phrase, at least 6 characters, but really, a phrase is best! This is not a password you'll need to enter every day."+	| s == toSecret sampleQuote = Just "Speaking of foolishness, don't paste in the example I gave. Enter a different phrase, please!"+	| otherwise = Nothing++toSecret :: Text -> Secret+toSecret s = B.fromChunks [T.encodeUtf8 $ T.toLower $ T.filter isAlphaNum s]++getUserName :: IO String+getUserName = userName <$> (getUserEntryForID =<< getEffectiveUserID)++pairPage :: Widget -> Handler RepHtml+pairPage w = bootstrap (Just Config) $ do+	sideBarDisplay+	setTitle "Pairing"+	w++{- From Dickens -}+sampleQuote :: Text+sampleQuote = T.unwords+	[ "It was the best of times,"+	, "it was the worst of times,"+	, "it was the age of wisdom,"+	, "it was the age of foolishness."+	]++#else++noPairing :: Handler RepHtml+noPairing = pairPage $+	$(widgetFile "configurators/pairing/disabled")++#endif
+ Assistant/WebApp/Configurators/Ssh.hs view
@@ -0,0 +1,339 @@+{- git-annex assistant webapp configurator for ssh-based remotes+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU AGPL version 3 or higher.+ -}++{-# LANGUAGE TypeFamilies, QuasiQuotes, MultiParamTypeClasses, TemplateHaskell, OverloadedStrings, RankNTypes #-}++module Assistant.WebApp.Configurators.Ssh where++import Assistant.Common+import Assistant.Ssh+import Assistant.MakeRemote+import Assistant.WebApp+import Assistant.WebApp.Types+import Assistant.WebApp.SideBar+import Utility.Yesod+import Utility.Rsync (rsyncUrlIsShell)+import Logs.Remote+import Remote++import Yesod+import Data.Text (Text)+import qualified Data.Text as T+import qualified Data.Map as M+import Network.BSD+import System.Posix.User++sshConfigurator :: Widget -> Handler RepHtml+sshConfigurator a = bootstrap (Just Config) $ do+	sideBarDisplay+	setTitle "Add a remote server"+	a++data SshInput = SshInput+	{ hostname :: Maybe Text+	, username :: Maybe Text+	, directory :: Maybe Text+	}+	deriving (Show)++{- SshInput is only used for applicative form prompting, this converts+ - the result of such a form into a SshData. -}+mkSshData :: SshInput -> SshData+mkSshData s = SshData +	{ sshHostName = fromMaybe "" $ hostname s+	, sshUserName = username s+	, sshDirectory = fromMaybe "" $ directory s+	, sshRepoName = genSshRepoName+		(T.unpack $ fromJust $ hostname s)+		(maybe "" T.unpack $ directory s)+	, needsPubKey = False+	, rsyncOnly = False+	}++sshInputAForm :: SshInput -> AForm WebApp WebApp SshInput+sshInputAForm def = SshInput+	<$> aopt check_hostname "Host name" (Just $ hostname def)+	<*> aopt check_username "User name" (Just $ username def)+	<*> aopt textField "Directory" (Just $ Just $ fromMaybe (T.pack gitAnnexAssistantDefaultDir) $ directory def)+	where+		check_hostname = checkM (liftIO . checkdns) textField+		checkdns t = do+			let h = T.unpack t+			r <- catchMaybeIO $ getHostByName h+			return $ case r of+				-- canonicalize input hostname if it had no dot+				Just hostentry+					| '.' `elem` h -> Right t+					| otherwise -> Right $ T.pack $ hostName hostentry+				Nothing -> Left bad_hostname++		check_username = checkBool (all (`notElem` "/:@ \t") . T.unpack)+			bad_username textField+		+		bad_hostname = "cannot resolve host name" :: Text+		bad_username = "bad user name" :: Text++data ServerStatus+	= UntestedServer+	| UnusableServer Text -- reason why it's not usable+	| UsableRsyncServer+	| UsableSshInput+	deriving (Eq)++usable :: ServerStatus -> Bool+usable UntestedServer = False+usable (UnusableServer _) = False+usable UsableRsyncServer = True+usable UsableSshInput = True++getAddSshR :: Handler RepHtml+getAddSshR = sshConfigurator $ do+	u <- liftIO $ T.pack . userName+		<$> (getUserEntryForID =<< getEffectiveUserID)+	((result, form), enctype) <- lift $+		runFormGet $ renderBootstrap $ sshInputAForm $+			SshInput Nothing (Just u) Nothing+	case result of+		FormSuccess sshinput -> do+			s <- liftIO $ testServer sshinput+			case s of+				Left status -> showform form enctype status+				Right sshdata -> lift $ redirect $ ConfirmSshR sshdata+		_ -> showform form enctype UntestedServer+	where+		showform form enctype status = do+			let authtoken = webAppFormAuthToken+			$(widgetFile "configurators/ssh/add")++{- To enable an existing rsync special remote, parse the SshInput from+ - its rsyncurl, and display a form whose only real purpose is to check+ - if ssh public keys need to be set up. From there, we can proceed with+ - the usual repo setup; all that code is idempotent.+ -+ - Note that there's no EnableSshR because ssh remotes are not special+ - remotes, and so their configuration is not shared between repositories.+ -}+getEnableRsyncR :: UUID -> Handler RepHtml+getEnableRsyncR u = do+	m <- runAnnex M.empty readRemoteLog+	case parseSshRsyncUrl =<< M.lookup "rsyncurl" =<< M.lookup u m of+		Nothing -> redirect AddSshR+		Just sshinput -> sshConfigurator $ do+			((result, form), enctype) <- lift $+				runFormGet $ renderBootstrap $ sshInputAForm sshinput+			case result of+				FormSuccess sshinput'+					| isRsyncNet (hostname sshinput') ->+						void $ lift $ makeRsyncNet sshinput'+					| otherwise -> do+						s <- liftIO $ testServer sshinput'+						case s of+							Left status -> showform form enctype status+							Right sshdata -> enable sshdata+				_ -> showform form enctype UntestedServer+	where+		showform form enctype status = do+			description <- lift $ runAnnex "" $+				T.pack . concat <$> prettyListUUIDs [u]+			let authtoken = webAppFormAuthToken+			$(widgetFile "configurators/ssh/enable")+		enable sshdata = +			lift $ redirect $ ConfirmSshR $+				sshdata { rsyncOnly = True }++{- Converts a rsyncurl value to a SshInput. But only if it's a ssh rsync+ - url; rsync:// urls or bare path names are not supported.+ -+ - The hostname is stored mangled in the remote log for rsync special+ - remotes configured by this webapp. So that mangling has to reversed+ - here to get back the original hostname.+ -}+parseSshRsyncUrl :: String -> Maybe SshInput+parseSshRsyncUrl u+	| not (rsyncUrlIsShell u) = Nothing+	| otherwise = Just $ SshInput+			{ hostname = val $ unMangleSshHostName host+			, username = if null user then Nothing else val user+			, directory = val dir+			}+		where+			val = Just . T.pack+			(userhost, dir) = separate (== ':') u+			(user, host) = if '@' `elem` userhost+				then separate (== '@') userhost+				else (userhost, "")++{- Test if we can ssh into the server.+ -+ - Two probe attempts are made. First, try sshing in using the existing+ - configuration, but don't let ssh prompt for any password. If+ - passwordless login is already enabled, use it. Otherwise,+ - a special ssh key will need to be generated just for this server.+ -+ - Once logged into the server, probe to see if git-annex-shell is+ - available, or rsync.+ -}+testServer :: SshInput -> IO (Either ServerStatus SshData)+testServer (SshInput { hostname = Nothing }) = return $+	Left $ UnusableServer "Please enter a host name."+testServer sshinput@(SshInput { hostname = Just hn }) = do+	status <- probe [sshOpt "NumberOfPasswordPrompts" "0"]+	if usable status+		then ret status False+		else do+			status' <- probe []+			if usable status'+				then ret status' True+				else return $ Left status'+	where+		ret status needspubkey = return $ Right $+			(mkSshData sshinput)+				{ needsPubKey = needspubkey+				, rsyncOnly = status == UsableRsyncServer+				}+		probe extraopts = do+			let remotecommand = join ";"+				[ report "loggedin"+				, checkcommand "git-annex-shell"+				, checkcommand "rsync"+				]+			knownhost <- knownHost hn+			let sshopts = filter (not . null) $ extraopts +++				{- If this is an already known host, let+				 - ssh check it as usual.+				 - Otherwise, trust the host key. -}+				[ if knownhost then "" else sshOpt "StrictHostKeyChecking" "no"+				, "-n" -- don't read from stdin+				, genSshHost (fromJust $ hostname sshinput) (username sshinput)+				, remotecommand+				]+			parsetranscript . fst <$> sshTranscript sshopts ""+		parsetranscript s+			| reported "git-annex-shell" = UsableSshInput+			| reported "rsync" = UsableRsyncServer+			| reported "loggedin" = UnusableServer+				"Neither rsync nor git-annex are installed on the server. Perhaps you should go install them?"+			| otherwise = UnusableServer $ T.pack $+				"Failed to ssh to the server. Transcript: " ++ s+			where+				reported r = token r `isInfixOf` s+		checkcommand c = "if which " ++ c ++ "; then " ++ report c ++ "; fi"+		token r = "git-annex-probe " ++ r+		report r = "echo " ++ token r++{- Runs a ssh command; if it fails shows the user the transcript,+ - and if it succeeds, runs an action. -}+sshSetup :: [String] -> String -> Handler RepHtml -> Handler RepHtml+sshSetup opts input a = do+	(transcript, ok) <- liftIO $ sshTranscript opts input+	if ok+		then a+		else showSshErr transcript++showSshErr :: String -> Handler RepHtml+showSshErr msg = sshConfigurator $+	$(widgetFile "configurators/ssh/error")++getConfirmSshR :: SshData -> Handler RepHtml+getConfirmSshR sshdata = sshConfigurator $ do+	let authtoken = webAppFormAuthToken+	$(widgetFile "configurators/ssh/confirm")++getMakeSshGitR :: SshData -> Handler RepHtml+getMakeSshGitR = makeSsh False++getMakeSshRsyncR :: SshData -> Handler RepHtml+getMakeSshRsyncR = makeSsh True++makeSsh :: Bool -> SshData -> Handler RepHtml+makeSsh rsync sshdata+	| needsPubKey sshdata = do+		keypair <- liftIO genSshKeyPair+		sshdata' <- liftIO $ setupSshKeyPair keypair sshdata+		makeSsh' rsync sshdata' (Just keypair)+	| otherwise = makeSsh' rsync sshdata Nothing++makeSsh' :: Bool -> SshData -> Maybe SshKeyPair -> Handler RepHtml+makeSsh' rsync sshdata keypair =+	sshSetup [sshhost, remoteCommand] "" $+		makeSshRepo rsync sshdata+	where+		sshhost = genSshHost (sshHostName sshdata) (sshUserName sshdata)+		remotedir = T.unpack $ sshDirectory sshdata+		remoteCommand = join "&&" $ catMaybes+			[ Just $ "mkdir -p " ++ shellEscape remotedir+			, Just $ "cd " ++ shellEscape remotedir+			, if rsync then Nothing else Just "git init --bare --shared"+			, if rsync then Nothing else Just "git annex init"+			, if needsPubKey sshdata+				then addAuthorizedKeysCommand (rsyncOnly sshdata) . sshPubKey <$> keypair+				else Nothing+			]++makeSshRepo :: Bool -> SshData -> Handler RepHtml+makeSshRepo forcersync sshdata = do+	webapp <- getYesod+	liftIO $ makeSshRemote+		(fromJust $ threadState webapp)+		(daemonStatus webapp)+		(scanRemotes webapp)+		forcersync sshdata+	redirect RepositoriesR++getAddRsyncNetR :: Handler RepHtml+getAddRsyncNetR = do+	((result, form), enctype) <- runFormGet $+		renderBootstrap $ sshInputAForm $+			SshInput Nothing Nothing Nothing+	let showform status = bootstrap (Just Config) $ do+		sideBarDisplay+		setTitle "Add a Rsync.net repository"	+		let authtoken = webAppFormAuthToken+		$(widgetFile "configurators/addrsync.net")+	case result of+		FormSuccess sshinput+			| isRsyncNet (hostname sshinput) ->+				makeRsyncNet sshinput+			| otherwise ->+				showform $ UnusableServer+					"That is not a rsync.net host name."+		_ -> showform UntestedServer++makeRsyncNet :: SshInput -> Handler RepHtml+makeRsyncNet sshinput = do+	knownhost <- liftIO $ maybe (return False) knownHost (hostname sshinput)+	keypair <- liftIO $ genSshKeyPair+	sshdata <- liftIO $ setupSshKeyPair keypair $+		(mkSshData sshinput)+			{ sshRepoName = "rsync.net"+			, needsPubKey = True+			, rsyncOnly = True+			}+	{- I'd prefer to separate commands with && , but+	 - rsync.net's shell does not support that.+	 -+	 - The dd method of appending to the authorized_keys file is the+	 - one recommended by rsync.net documentation. I touch the file first+	 - to not need to use a different method to create it.+	 -}+	let remotecommand = join ";"+		[ "mkdir -p .ssh"+		, "touch .ssh/authorized_keys"+		, "dd of=.ssh/authorized_keys oflag=append conv=notrunc"+		, "mkdir -p " ++ T.unpack (sshDirectory sshdata)+		]+	let sshopts = filter (not . null)+		[ if knownhost then "" else sshOpt "StrictHostKeyChecking" "no"+		, genSshHost (sshHostName sshdata) (sshUserName sshdata)+		, remotecommand+		]+	sshSetup sshopts (sshPubKey keypair) $+		makeSshRepo True sshdata++isRsyncNet :: Maybe Text -> Bool+isRsyncNet Nothing = False+isRsyncNet (Just host) = ".rsync.net" `T.isSuffixOf` T.toLower host
+ Assistant/WebApp/DashBoard.hs view
@@ -0,0 +1,237 @@+{- git-annex assistant webapp dashboard+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU AGPL version 3 or higher.+ -}++{-# LANGUAGE CPP, TypeFamilies, QuasiQuotes, MultiParamTypeClasses, TemplateHaskell, OverloadedStrings, RankNTypes #-}++module Assistant.WebApp.DashBoard where++import Assistant.Common+import Assistant.WebApp+import Assistant.WebApp.Types+import Assistant.WebApp.SideBar+import Assistant.WebApp.Notifications+import Assistant.WebApp.Configurators+import Assistant.DaemonStatus+import Assistant.TransferQueue+import Assistant.TransferSlots+import qualified Assistant.Threads.Transferrer as Transferrer+import Utility.NotificationBroadcaster+import Utility.Yesod+import Logs.Transfer+import Utility.Percentage+import Utility.DataUnits+import Types.Key+import qualified Remote+import qualified Git+import Locations.UserConfig++import Yesod+import Text.Hamlet+import qualified Data.Map as M+import Control.Concurrent+import System.Posix.Signals (signalProcessGroup, sigTERM, sigKILL)+import System.Posix.Process (getProcessGroupIDOf)++{- A display of currently running and queued transfers.+ -+ - Or, if there have never been any this run, an intro display. -}+transfersDisplay :: Bool -> Widget+transfersDisplay warnNoScript = do+	webapp <- lift getYesod+	current <- lift $ M.toList <$> getCurrentTransfers+	queued <- liftIO $ getTransferQueue $ transferQueue webapp+	let ident = "transfers"+	autoUpdate ident NotifierTransfersR (10 :: Int) (10 :: Int)+	let transfers = simplifyTransfers $ current ++ queued+	if null transfers+		then ifM (lift $ showIntro <$> getWebAppState)+			( introDisplay ident+			, $(widgetFile "dashboard/transfers")+			)+		else $(widgetFile "dashboard/transfers")+	where+		isrunning info = not $+			transferPaused info || isNothing (startedTime info)++{- Simplifies a list of transfers, avoiding display of redundant+ - equivilant transfers. -}+simplifyTransfers :: [(Transfer, TransferInfo)] -> [(Transfer, TransferInfo)]+simplifyTransfers [] = []+simplifyTransfers (x:[]) = [x]+simplifyTransfers (v@(t1, _):r@((t2, _):l))+	| equivilantTransfer t1 t2 = simplifyTransfers (v:l)+	| otherwise = v : (simplifyTransfers r)++{- Called by client to get a display of currently in process transfers.+ -+ - Returns a div, which will be inserted into the calling page.+ -+ - Note that the head of the widget is not included, only its+ - body is. To get the widget head content, the widget is also + - inserted onto the getHomeR page.+ -}+getTransfersR :: NotificationId -> Handler RepHtml+getTransfersR nid = do+	waitNotifier transferNotifier nid++	page <- widgetToPageContent $ transfersDisplay False+	hamletToRepHtml $ [hamlet|^{pageBody page}|]++{- The main dashboard. -}+dashboard :: Bool -> Widget+dashboard warnNoScript = do+	sideBarDisplay+	let content = transfersDisplay warnNoScript+	$(widgetFile "dashboard/main")++getHomeR :: Handler RepHtml+getHomeR = ifM (inFirstRun)+	( redirect ConfigR+	, bootstrap (Just DashBoard) $ dashboard True+	)++{- Used to test if the webapp is running. -}+headHomeR :: Handler ()+headHomeR = noop++{- Same as HomeR, except no autorefresh at all (and no noscript warning). -}+getNoScriptR :: Handler RepHtml+getNoScriptR = bootstrap (Just DashBoard) $ dashboard False++{- Same as HomeR, except with autorefreshing via meta refresh. -}+getNoScriptAutoR :: Handler RepHtml+getNoScriptAutoR = bootstrap (Just DashBoard) $ do+	let ident = NoScriptR+	let delayseconds = 3 :: Int+	let this = NoScriptAutoR+	toWidgetHead $(hamletFile $ hamletTemplate "dashboard/metarefresh")+	dashboard False++{- The javascript code does a post. -}+postFileBrowserR :: Handler ()+postFileBrowserR = void openFileBrowser++{- Used by non-javascript browsers, where clicking on the link actually+ - opens this page, so we redirect back to the referrer. -}+getFileBrowserR :: Handler ()+getFileBrowserR = whenM openFileBrowser $ redirectBack++{- Opens the system file browser on the repo, or, as a fallback,+ - goes to a file:// url. Returns True if it's ok to redirect away+ - from the page (ie, the system file browser was opened). + -+ - Note that the command is opened using a different thread, to avoid+ - blocking the response to the browser on it. -}+openFileBrowser :: Handler Bool+openFileBrowser = do+	path <- runAnnex (error "no configured repository") $+		fromRepo Git.repoPath+	ifM (liftIO $ inPath cmd <&&> inPath cmd)+		( do+			void $ liftIO $ forkIO $ void $+				boolSystem cmd [Param path]+			return True+		, do+			clearUltDest+			setUltDest $ "file://" ++ path+			void $ redirectUltDest HomeR+			return False+		)+	where+#if OSX+		cmd = "open"+#else+		cmd = "xdg-open"+#endif++{- Transfer controls. The GET is done in noscript mode and redirects back+ - to the referring page. The POST is called by javascript. -}+getPauseTransferR :: Transfer -> Handler ()+getPauseTransferR t = pauseTransfer t >> redirectBack+postPauseTransferR :: Transfer -> Handler ()+postPauseTransferR t = pauseTransfer t+getStartTransferR :: Transfer -> Handler ()+getStartTransferR t = startTransfer t >> redirectBack+postStartTransferR :: Transfer -> Handler ()+postStartTransferR t = startTransfer t+getCancelTransferR :: Transfer -> Handler ()+getCancelTransferR t = cancelTransfer False t >> redirectBack+postCancelTransferR :: Transfer -> Handler ()+postCancelTransferR t = cancelTransfer False t++pauseTransfer :: Transfer -> Handler ()+pauseTransfer = cancelTransfer True++cancelTransfer :: Bool -> Transfer-> Handler ()+cancelTransfer pause t = do+	webapp <- getYesod+	let dstatus = daemonStatus webapp+	m <- getCurrentTransfers+	liftIO $ do+		unless pause $+			{- remove queued transfer -}+			void $ dequeueTransfers (transferQueue webapp) dstatus $+				equivilantTransfer t+		{- stop running transfer -}+		maybe noop (stop dstatus) (M.lookup t m)+	where+		stop dstatus info = do+			{- When there's a thread associated with the+			 - transfer, it's signaled first, to avoid it+			 - displaying any alert about the transfer having+			 - failed when the transfer process is killed. -}+			maybe noop signalthread $ transferTid info+			maybe noop killproc $ transferPid info+			if pause+				then void $+					alterTransferInfo dstatus t $ \i -> i+						{ transferPaused = True }+				else void $+					removeTransfer dstatus t+		signalthread tid+			| pause = throwTo tid PauseTransfer+			| otherwise = killThread tid+		{- In order to stop helper processes like rsync,+		 - kill the whole process group of the process running the +		 - transfer. -}+		killproc pid = do+			g <- getProcessGroupIDOf pid+			void $ tryIO $ signalProcessGroup sigTERM g+			threadDelay 50000 -- 0.05 second grace period+			void $ tryIO $ signalProcessGroup sigKILL g++startTransfer :: Transfer -> Handler ()+startTransfer t = do+	m <- getCurrentTransfers+	maybe startqueued go (M.lookup t m)+	where+		go info = maybe (start info) resume $ transferTid info+		startqueued = do+			webapp <- getYesod+			let dstatus = daemonStatus webapp+			let q = transferQueue webapp+			is <- liftIO $ map snd <$> getMatchingTransfers q dstatus (== t)+			maybe noop start $ headMaybe is+		resume tid = do+			webapp <- getYesod+			let dstatus = daemonStatus webapp+			liftIO $ do+				alterTransferInfo dstatus t $ \i -> i+					{ transferPaused = False }+				throwTo tid ResumeTransfer+		start info = do+			webapp <- getYesod+			let st = fromJust $ threadState webapp+			let dstatus = daemonStatus webapp+			let slots = transferSlots webapp+			liftIO $ inImmediateTransferSlot dstatus slots $ do+				program <- readProgramFile+				Transferrer.startTransfer st dstatus program t info++getCurrentTransfers :: Handler TransferMap+getCurrentTransfers = currentTransfers+	<$> (liftIO . getDaemonStatus =<< daemonStatus <$> getYesod)
+ Assistant/WebApp/Documentation.hs view
@@ -0,0 +1,23 @@+{- git-annex assistant webapp documentation+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU AGPL version 3 or higher.+ -}++{-# LANGUAGE TypeFamilies, QuasiQuotes, MultiParamTypeClasses, TemplateHaskell, OverloadedStrings, RankNTypes #-}++module Assistant.WebApp.Documentation where++import Assistant.WebApp+import Assistant.WebApp.Types+import Assistant.WebApp.SideBar+import Utility.Yesod++import Yesod++getAboutR :: Handler RepHtml+getAboutR = bootstrap (Just About) $ do+	sideBarDisplay+	setTitle "About git-annex"+	$(widgetFile "documentation/about")
+ Assistant/WebApp/Notifications.hs view
@@ -0,0 +1,59 @@+{- git-annex assistant webapp notifications+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU AGPL version 3 or higher.+ -}++{-# LANGUAGE TypeFamilies, QuasiQuotes, MultiParamTypeClasses, TemplateHaskell, OverloadedStrings, RankNTypes #-}++module Assistant.WebApp.Notifications where++import Assistant.Common+import Assistant.WebApp+import Assistant.WebApp.Types+import Assistant.DaemonStatus+import Utility.NotificationBroadcaster+import Utility.Yesod++import Yesod+import Data.Text (Text)+import qualified Data.Text as T++{- Add to any widget to make it auto-update using long polling.+ -+ - The widget should have a html element with an id=ident, which will be+ - replaced when it's updated.+ -+ - The geturl route should return the notifier url to use for polling.+ -+ - ms_delay is how long to delay between AJAX updates+ - ms_startdelay is how long to delay before updating with AJAX at the start+ -}+autoUpdate :: Text -> Route WebApp -> Int -> Int -> Widget+autoUpdate ident geturl ms_delay ms_startdelay = do+	let delay = show ms_delay+	let startdelay = show ms_startdelay+	addScript $ StaticR longpolling_js+	$(widgetFile "notifications/longpolling")++{- Notifier urls are requested by the javascript, to avoid allocation+ - of NotificationIds when noscript pages are loaded. This constructs a+ - notifier url for a given Route and NotificationBroadcaster.+ -}+notifierUrl :: (NotificationId -> Route WebApp) -> (DaemonStatus -> NotificationBroadcaster) -> Handler RepPlain+notifierUrl route selector = do+	(urlbits, _params) <- renderRoute . route <$> newNotifier selector+	webapp <- getYesod+	return $ RepPlain $ toContent $ T.concat+		[ "/"+		, T.intercalate "/" urlbits+		, "?auth="+		, secretToken webapp+		]++getNotifierTransfersR :: Handler RepPlain+getNotifierTransfersR = notifierUrl TransfersR transferNotifier++getNotifierSideBarR :: Handler RepPlain+getNotifierSideBarR = notifierUrl SideBarR alertNotifier
+ Assistant/WebApp/OtherRepos.hs view
@@ -0,0 +1,53 @@+{- git-annex assistant webapp switching to other repos+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU AGPL version 3 or higher.+ -}++{-# LANGUAGE CPP, TypeFamilies, QuasiQuotes, MultiParamTypeClasses, TemplateHaskell, OverloadedStrings, RankNTypes #-}++module Assistant.WebApp.OtherRepos where++import Assistant.Common+import Assistant.WebApp.Types+import qualified Git.Construct+import qualified Git.Config+import Locations.UserConfig+import qualified Utility.Url as Url++import Yesod+import Control.Concurrent+import System.Process (cwd)++{- Starts up the assistant in the repository, and waits for it to create+ - a gitAnnexUrlFile. Waits for the assistant to be up and listening for+ - connections by testing the url. Once it's running, redirect to it.+ -}+getSwitchToRepositoryR :: FilePath -> Handler RepHtml+getSwitchToRepositoryR repo = do+	liftIO startassistant+	url <- liftIO geturl+	redirect url+	where+		startassistant = do+			program <- readProgramFile+			void $ forkIO $ void $ createProcess $+				(proc program ["assistant"])+					{ cwd = Just repo }+		geturl = do+			r <- Git.Config.read =<< Git.Construct.fromPath repo+			waiturl $ gitAnnexUrlFile r+		waiturl urlfile = do+			v <- tryIO $ readFile urlfile+			case v of+				Left _ -> delayed $ waiturl urlfile+				Right url -> ifM (listening url)+					( return url+					, delayed $ waiturl urlfile+					)+		listening url = catchBoolIO $ +			fst <$> Url.exists url []+		delayed a = do+			threadDelay 100000 -- 1/10th of a second+			a
+ Assistant/WebApp/SideBar.hs view
@@ -0,0 +1,94 @@+{- git-annex assistant webapp sidebar+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU AGPL version 3 or higher.+ -}++{-# LANGUAGE TypeFamilies, QuasiQuotes, MultiParamTypeClasses, TemplateHaskell, OverloadedStrings, RankNTypes #-}++module Assistant.WebApp.SideBar where++import Assistant.Common+import Assistant.WebApp+import Assistant.WebApp.Types+import Assistant.WebApp.Notifications+import Assistant.DaemonStatus+import Assistant.Alert+import Utility.NotificationBroadcaster+import Utility.Yesod++import Yesod+import Data.Text (Text)+import qualified Data.Map as M+import Control.Concurrent++sideBarDisplay :: Widget+sideBarDisplay = do+	let content = do+		{- Add newest alerts to the sidebar. -}+		webapp <- lift getYesod+		alertpairs <- M.toList . alertMap+			<$> liftIO (getDaemonStatus $ daemonStatus webapp)+		mapM_ renderalert $+			take displayAlerts $ reverse $ sortAlertPairs alertpairs+	let ident = "sidebar"+	$(widgetFile "sidebar/main")+	autoUpdate ident NotifierSideBarR (10 :: Int) (10 :: Int)+	where+		bootstrapclass :: AlertClass -> Text+		bootstrapclass Activity = "alert-info"+		bootstrapclass Warning = "alert"+		bootstrapclass Error = "alert-error"+		bootstrapclass Success = "alert-success"+		bootstrapclass Message = "alert-info"++		renderalert (aid, alert) = do+			let alertid = show aid+			let closable = alertClosable alert+			let block = alertBlockDisplay alert+			let divclass = bootstrapclass $ alertClass alert+			$(widgetFile "sidebar/alert")++{- Called by client to get a sidebar display.+ -+ - Returns a div, which will be inserted into the calling page.+ -+ - Note that the head of the widget is not included, only its+ - body is. To get the widget head content, the widget is also + - inserted onto all pages.+ -}+getSideBarR :: NotificationId -> Handler RepHtml+getSideBarR nid = do+	waitNotifier alertNotifier nid++	{- This 0.1 second delay avoids very transient notifications from+	 - being displayed and churning the sidebar unnecesarily. +	 -+	 - This needs to be below the level perceptable by the user,+	 - to avoid slowing down user actions like closing alerts. -}+	liftIO $ threadDelay 100000++	page <- widgetToPageContent sideBarDisplay+	hamletToRepHtml $ [hamlet|^{pageBody page}|]++{- Called by the client to close an alert. -}+getCloseAlert :: AlertId -> Handler ()+getCloseAlert i = do+	webapp <- getYesod+	liftIO $ removeAlert (daemonStatus webapp) i++{- When an alert with a button is clicked on, the button takes us here. -}+getClickAlert :: AlertId -> Handler ()+getClickAlert i = do+	webapp <- getYesod+	m <- alertMap <$> liftIO (getDaemonStatus $ daemonStatus webapp)+	case M.lookup i m of+		Just (Alert { alertButton = Just b }) -> do+			{- Spawn a thread to run the action while redirecting. -}+			case buttonAction b of+				Nothing -> noop+				Just a -> liftIO $ void $ forkIO $ a i+			redirect $ buttonUrl b+		_ -> redirectBack+
+ Assistant/WebApp/Types.hs view
@@ -0,0 +1,98 @@+{- git-annex assistant webapp types+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU AGPL version 3 or higher.+ -}++{-# LANGUAGE TypeFamilies, QuasiQuotes, MultiParamTypeClasses, TemplateHaskell, OverloadedStrings, RankNTypes #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}++module Assistant.WebApp.Types where++import Assistant.Common+import Assistant.Ssh+import Assistant.ThreadedMonad+import Assistant.DaemonStatus+import Assistant.ScanRemotes+import Assistant.TransferQueue+import Assistant.TransferSlots+import Assistant.Alert+import Assistant.Pairing+import Utility.NotificationBroadcaster+import Utility.WebApp+import Logs.Transfer++import Yesod+import Yesod.Static+import Data.Text (Text, pack, unpack)+import Control.Concurrent.STM++staticFiles "static"++mkYesodData "WebApp" $(parseRoutesFile "Assistant/WebApp/routes")++data WebApp = WebApp+	{ threadState :: Maybe ThreadState+	, daemonStatus :: DaemonStatusHandle+	, scanRemotes :: ScanRemoteMap+	, transferQueue :: TransferQueue+	, transferSlots :: TransferSlots+	, secretToken :: Text+	, relDir :: Maybe FilePath+	, getStatic :: Static+	, webAppState :: TMVar WebAppState+	, postFirstRun :: Maybe (IO String)+	}++instance Yesod WebApp where+	{- Require an auth token be set when accessing any (non-static route) -}+	isAuthorized _ _ = checkAuthToken secretToken++	{- Add the auth token to every url generated, except static subsite+         - urls (which can show up in Permission Denied pages). -}+	joinPath = insertAuthToken secretToken excludeStatic+		where+			excludeStatic [] = True+			excludeStatic (p:_) = p /= "static"++	makeSessionBackend = webAppSessionBackend+	jsLoader _ = BottomOfHeadBlocking++instance RenderMessage WebApp FormMessage where+	renderMessage _ _ = defaultFormMessage++type Form x = Html -> MForm WebApp WebApp (FormResult x, Widget)++data WebAppState = WebAppState+	{ showIntro :: Bool -- should the into message be displayed?+	, otherRepos :: [(String, String)] -- name and path to other repos+	}++instance PathPiece SshData where+    toPathPiece = pack . show+    fromPathPiece = readish . unpack++instance PathPiece NotificationId where+    toPathPiece = pack . show+    fromPathPiece = readish . unpack++instance PathPiece AlertId where+    toPathPiece = pack . show+    fromPathPiece = readish . unpack++instance PathPiece Transfer where+    toPathPiece = pack . show+    fromPathPiece = readish . unpack++instance PathPiece PairMsg where+    toPathPiece = pack . show+    fromPathPiece = readish . unpack++instance PathPiece SecretReminder where+    toPathPiece = pack . show+    fromPathPiece = readish . unpack++instance PathPiece UUID where+    toPathPiece = pack . show+    fromPathPiece = readish . unpack
+ Assistant/WebApp/routes view
@@ -0,0 +1,39 @@+/ HomeR GET HEAD+/noscript NoScriptR GET+/noscript/auto NoScriptAutoR GET+/about AboutR GET++/config ConfigR GET+/config/repository RepositoriesR GET++/config/repository/new/first FirstRepositoryR GET+/config/repository/new NewRepositoryR GET+/config/repository/switchto/#FilePath SwitchToRepositoryR GET++/config/repository/add/drive AddDriveR GET+/config/repository/add/ssh AddSshR GET+/config/repository/add/ssh/confirm/#SshData ConfirmSshR GET+/config/repository/add/ssh/make/git/#SshData MakeSshGitR GET+/config/repository/add/ssh/make/rsync/#SshData MakeSshRsyncR GET+/config/repository/add/rsync.net AddRsyncNetR GET++/config/repository/pair/start StartPairR GET+/config/repository/pair/inprogress/#SecretReminder InprogressPairR GET+/config/repository/pair/finish/#PairMsg FinishPairR GET++/config/repository/enable/rsync/#UUID EnableRsyncR GET+/config/repository/enable/directory/#UUID EnableDirectoryR GET++/transfers/#NotificationId TransfersR GET+/sidebar/#NotificationId SideBarR GET+/notifier/transfers NotifierTransfersR GET+/notifier/sidebar NotifierSideBarR GET+/alert/close/#AlertId CloseAlert GET+/alert/click/#AlertId ClickAlert GET+/filebrowser FileBrowserR GET POST++/transfer/pause/#Transfer PauseTransferR GET POST+/transfer/start/#Transfer StartTransferR GET POST+/transfer/cancel/#Transfer CancelTransferR GET POST++/static StaticR Static getStatic
Backend/SHA.hs view
@@ -1,4 +1,4 @@-{- git-annex SHA backend+{- git-annex SHA backends  -  - Copyright 2011,2012 Joey Hess <joey@kitenet.net>  -@@ -16,16 +16,18 @@ import qualified Build.SysConfig as SysConfig import Data.Digest.Pure.SHA import qualified Data.ByteString.Lazy as L+import System.Process  type SHASize = Int --- order is slightly significant; want SHA256 first, and more general--- sizes earlier+{- Order is slightly significant; want SHA256 first, and more general+ - sizes earlier. -} sizes :: [Int] sizes = [256, 1, 512, 224, 384] +{- The SHA256E backend is the default. -} backends :: [Backend]-backends = catMaybes $ map genBackend sizes ++ map genBackendE sizes+backends = catMaybes $ map genBackendE sizes ++ map genBackend sizes  genBackend :: SHASize -> Maybe Backend genBackend size = Just $ Backend@@ -53,14 +55,26 @@ 	showAction "checksum" 	case shaCommand shasize filesize of 		Left sha -> liftIO $ sha <$> L.readFile file-		Right command -> liftIO $ runcommand command+		Right command -> liftIO $ parse command . lines <$>+			readsha command (toCommand [File file]) 	where-		runcommand command =-			pOpen ReadFromPipe command (toCommand [File file]) $ \h -> do-				sha <- fst . separate (== ' ') <$> hGetLine h-				if null sha-					then error $ command ++ " parse error"-					else return sha+		parse command [] = bad command+		parse command (l:_)+			| null sha = bad command+			| otherwise = sha+			where+				sha = fst $ separate (== ' ') l+		bad command = error $ command ++ " parse error"+		{- sha commands output the filename, so need to set fileEncoding -}+		readsha command args =+			withHandle StdoutHandle createProcessSuccess p $ \h -> do+				fileEncoding h+				output  <- hGetContentsStrict h+				hClose h+				return output+			where+				p = (proc command args)+					{ std_out = CreatePipe }  shaCommand :: SHASize -> Integer -> Either (L.ByteString -> String) String shaCommand shasize filesize
Build/Configure.hs view
@@ -4,7 +4,7 @@  import System.Directory import Data.List-import System.Cmd.Utils+import System.Process import Control.Applicative import System.FilePath @@ -71,7 +71,7 @@  getGitVersion :: Test getGitVersion = do-	(_, s) <- pipeFrom "git" ["--version"]+	s <- readProcess "git" ["--version"] "" 	let version = unwords $ drop 2 $ words $ head $ lines s 	return $ Config "gitversion" (StringConfig version) 
+ Build/InstallDesktopFile.hs view
@@ -0,0 +1,138 @@+{- Generating and installing a desktop menu entry file+ - and a desktop autostart file. (And OSX equivilants.)+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++{-# LANGUAGE CPP #-}++module Build.InstallDesktopFile where++import Utility.Exception+import Utility.FreeDesktop+import Utility.Path+import Utility.Monad+import Locations.UserConfig++import Control.Applicative+import Control.Monad+import System.Directory+import System.Environment+import System.Posix.User+import System.Posix.Types+import System.Posix.Files+import System.FilePath++{- The command can be either just "git-annex", or the full path to use+ - to run it. -}+desktop :: FilePath -> DesktopEntry+desktop command = genDesktopEntry+	"Git Annex"+	"Track and sync the files in your Git Annex"+	False+	(command ++ " webapp")+	["Network", "FileTransfer"]++autostart :: FilePath -> DesktopEntry+autostart command = genDesktopEntry+	"Git Annex Assistant"+	"Autostart"+	False+	(command ++ " assistant --autostart")+	[]++isRoot :: IO Bool+isRoot = do+	uid <- fromIntegral <$> getRealUserID+	return $ uid == 0++inDestDir :: FilePath -> IO FilePath+inDestDir f = do+	destdir <- catchDefaultIO "" (getEnv "DESTDIR")+	return $ destdir </> f++writeFDODesktop :: FilePath -> IO ()+writeFDODesktop command = do+	datadir <- ifM isRoot ( return systemDataDir, userDataDir )+	writeDesktopMenuFile (desktop command) +		=<< inDestDir (desktopMenuFilePath "git-annex" datadir)++	configdir <- ifM isRoot ( return systemConfigDir, userConfigDir )+	writeDesktopMenuFile (autostart command) +		=<< inDestDir (autoStartPath "git-annex" configdir)++	ifM isRoot+		( return ()+		, do+			programfile <- inDestDir =<< programFile+			createDirectoryIfMissing True (parentDir programfile)+			writeFile programfile command+		)++writeOSXDesktop :: FilePath -> IO ()+writeOSXDesktop command = do+	home <- myHomeDir++	let base = "Library" </> "LaunchAgents" </> label ++ ".plist"+	autostart <- ifM isRoot ( inDestDir $ "/" </> base , inDestDir $ home </> base)+	createDirectoryIfMissing True (parentDir autostart)+	writeFile autostart $ genOSXAutoStartFile label command++	let appdir = "git-annex.app"+	installOSXAppFile appdir "Contents/Info.plist" Nothing+	installOSXAppFile appdir "Contents/Resources/git-annex.icns" Nothing+	installOSXAppFile appdir "Contents/MacOS/git-annex" (Just webappscript)+	where+		label = "com.branchable.git-annex.assistant"+		webappscript = unlines+			[ "#!/bin/sh"+			, command ++ " webapp"+			]++installOSXAppFile :: FilePath -> FilePath -> Maybe String -> IO ()+installOSXAppFile appdir appfile mcontent = do+	let src = "ui-macos" </> appdir </> appfile+	home <- myHomeDir+	dest <- ifM isRoot+		( return $ "/Applications" </> appdir </> appfile+		, return $ home </> "Desktop" </> appdir </> appfile+		)+	createDirectoryIfMissing True (parentDir dest)+	case mcontent of+		Just content -> writeFile dest content+		Nothing -> copyFile src dest+	mode <- fileMode <$> getFileStatus src+	setFileMode dest mode++genOSXAutoStartFile :: String -> String -> String+genOSXAutoStartFile label command = unlines+	[ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+	, "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">"+	, "<plist version=\"1.0\">"+	, "<dict>"+	, "<key>Label</key>"+	, "<string>" ++ label ++ "</string>"+	, "<key>ProgramArguments</key>"+	, "<array>"+	, "<string>" ++ command ++ "</string>"+	, "<string>assistant</string>"+	, "<string>--autostart</string>"+	, "</array>"+	, "<key>RunAtLoad</key>"+	, "</dict>"+	, "</plist>"+	]++writeDesktop :: FilePath -> IO ()+#ifdef darwin_HOST_OS+writeDesktop = writeOSXDesktop+#else+writeDesktop = writeFDODesktop+#endif++main = getArgs >>= go+	where+		go [] = error "specify git-annex command"+		go (command:_) = writeDesktop command
+ Build/make-sdist.sh view
@@ -0,0 +1,21 @@+#!/bin/sh+#+# Workaround for `cabal sdist` requiring all included files to be listed+# in .cabal.++# Create target directory+sdist_dir=git-annex-$(grep '^Version:' git-annex.cabal | sed -re 's/Version: *//')+mkdir --parents dist/$sdist_dir++find . \( -name .git -or -name dist -or -name cabal-dev \) -prune \+	-or -not -name \\*.orig -not -type d -print \+| perl -ne "print unless length >= 100 - length q{$sdist_dir}" \+| xargs cp --parents --target-directory dist/$sdist_dir++cd dist+tar -caf $sdist_dir.tar.gz $sdist_dir++# Check that tarball can be unpacked by cabal.+# It's picky about tar longlinks etc.+rm -rf $sdist_dir+cabal unpack $sdist_dir.tar.gz
+ Build/mdwn2man view
@@ -0,0 +1,43 @@+#!/usr/bin/perl+# Warning: hack++my $prog=shift;+my $section=shift;++print ".TH $prog $section\n";++while (<>) {+	s{(\\?)\[\[([^\s\|\]]+)(\|[^\s\]]+)?\]\]}{$1 ? "[[$2]]" : $2}eg;+	s/\`//g;+	s/^\s*\./\\&./g;+	if (/^#\s/) {+		s/^#\s/.SH /;+		<>; # blank;+	}+	s/^[ \n]+//;+	s/^\t/ /;+	s/-/\\-/g;+	s/^Warning:.*//g;+	s/^$/.PP\n/;+	s/^\*\s+(.*)/.IP "$1"/;+	next if $_ eq ".PP\n" && $skippara;+	if (/^.IP /) {+		$inlist=1;+		$spippara=0;+	}+	elsif (/.SH/) {+		$skippara=0;+		$inlist=0;+	}+	elsif (/^\./) {+		$skippara=1;+	}+	else {+		$skippara=0;+	}+	if ($inlist && $_ eq ".PP\n") {+		$_=".IP\n";+	}++	print $_;+}
CHANGELOG view
@@ -1,3 +1,34 @@+git-annex (3.20120924) unstable; urgency=low++  * assistant: New command, a daemon which does everything watch does,+    as well as automatically syncing file contents between repositories.+  * webapp: An interface for managing and configuring the assistant.+  * The default backend used when adding files to the annex is changed+    from SHA256 to SHA256E, to simplify interoperability with OSX, media+    players, and various programs that needlessly look at symlink targets.+    To get old behavior, add a .gitattributes containing: * annex.backend=SHA256+  * init: If no description is provided for a new repository, one will+    automatically be generated, like "joey@gnu:~/foo"+  * test: Set a lot of git environment variables so testing works in strange+    environments that normally need git config to set names, etc.+    Closes: #682351 Thanks, gregor herrmann+  * Disable ssh connection caching if the path to the control socket would be+    too long (and use relative path to minimise path to the control socket).+  * migrate: Check content before generating the new key, to avoid generating+    a key for corrupt data.+  * Support repositories created with --separate-git-dir. Closes: #684405+  * reinject: When the provided file doesn't match, leave it where it is,+    rather than moving to .git/annex/bad/+  * Avoid crashing on encoding errors in filenames when writing transfer info+    files and reading from checksum commands.+  * sync: Pushes the git-annex branch to remote/synced/git-annex, rather+    than directly to remote/git-annex.+  * Now supports matchig files that are present on a number of remotes+    with a specified trust level. Example: --copies=trusted:2+    Thanks, Nicolas Pouillard++ -- Joey Hess <joeyh@debian.org>  Mon, 24 Sep 2012 13:47:48 -0400+ git-annex (3.20120825) unstable; urgency=low    * S3: Add fileprefix setting.
@@ -4,12 +4,771 @@ Files: * Copyright: © 2010-2012 Joey Hess <joey@kitenet.net> License: GPL-3+- The full text of version 3 of the GPL is distributed as doc/GPL in- this package's source, or in /usr/share/common-licenses/GPL-3 on- Debian systems. -Files: doc/logo* doc/favicon.png+Files: Assistant/WebApp.hs Assistant/WebApp/* templates/* static/*+Copyright: © 2012 Joey Hess <joey@kitenet.net>+License: AGPL-3+++Files: doc/logo* */favicon.ico ui-macos/git-annex.app/Contents/Resources/git-annex.icns Copyright: 2007 Henrik Nyh <http://henrik.nyh.se/>            2010 Joey Hess <joey@kitenet.net> License: other   Free to modify and redistribute with due credit, and obviously free to use.++Files: Utility/Mounts.hsc+Copyright: Volker Wysk <hsss@volker-wysk.de>+License: LGPL-2.1+++Files: Utility/libmounts.c+Copyright: 1980, 1989, 1993, 1994 The Regents of the University of California+           2001 David Rufino <daverufino@btinternet.com>+           2012 Joey Hess <joey@kitenet.net>+License: BSD-3-clause+ * Copyright (c) 1980, 1989, 1993, 1994+ *      The Regents of the University of California.  All rights reserved.+ * Copyright (c) 2001+ *      David Rufino <daverufino@btinternet.com>+ * Copyright 2012+ *      Joey Hess <joey@kitenet.net>+ *+ * Redistribution and use in source and binary forms, with or without+ * modification, are permitted provided that the following conditions+ * are met:+ * 1. Redistributions of source code must retain the above copyright+ *    notice, this list of conditions and the following disclaimer.+ * 2. Redistributions in binary form must reproduce the above copyright+ *    notice, this list of conditions and the following disclaimer in the+ *    documentation and/or other materials provided with the distribution.+ * 3. Neither the name of the University nor the names of its contributors+ *    may be used to endorse or promote products derived from this software+ *    without specific prior written permission.+ *+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF+ * SUCH DAMAGE.++Files: static/jquery*+Copyright: © 2005-2011 by John Resig, Branden Aaron & Jörn Zaefferer+           © 2011 The Dojo Foundation+License: MIT or GPL-2+ The full text of version 2 of the GPL is distributed in+ /usr/share/common-licenses/GPL-2 on Debian systems. The text of the MIT+ license follows:+ .+ Permission is hereby granted, free of charge, to any person obtaining+ a copy of this software and associated documentation files (the+ "Software"), to deal in the Software without restriction, including+ without limitation the rights to use, copy, modify, merge, publish,+ distribute, sublicense, and/or sell copies of the Software, and to+ permit persons to whom the Software is furnished to do so, subject to+ the following conditions:+ .+ The above copyright notice and this permission notice shall be+ included in all copies or substantial portions of the Software.+ .+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.++Files: static/*/bootstrap* static/img/glyphicons-halflings*+Copyright: 2012 Twitter, Inc.+License: Apache-2.0+ Licensed under the Apache License, Version 2.0 (the "License");+ you may not use this file except in compliance with the License.+ You may obtain a copy of the License at+ .+        http://www.apache.org/licenses/LICENSE-2.0+ .+ Unless required by applicable law or agreed to in writing, software+ distributed under the License is distributed on an "AS IS" BASIS,+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ See the License for the specific language governing permissions and+ limitations under the License.+ .+ The complete text of the Apache License is distributed in+ /usr/share/common-licenses/Apache-2.0 on Debian systems.++License: GPL-3++ The full text of version 3 of the GPL is distributed as doc/license/GPL in+ this package's source, or in /usr/share/common-licenses/GPL-3 on+ Debian systems.++License: LGPL-2.1++ The full text of version 2.1 of the LGPL is distributed as doc/license/LGPL+ in this package's source, or in /usr/share/common-licenses/LGPL-2.1+ on Debian systems.++License: AGPL-3++                      GNU AFFERO GENERAL PUBLIC LICENSE+                         Version 3, 19 November 2007+ .+   Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>+   Everyone is permitted to copy and distribute verbatim copies+   of this license document, but changing it is not allowed.+ .+                              Preamble+ .+    The GNU Affero General Public License is a free, copyleft license for+  software and other kinds of works, specifically designed to ensure+  cooperation with the community in the case of network server software.+ .+    The licenses for most software and other practical works are designed+  to take away your freedom to share and change the works.  By contrast,+  our General Public Licenses are intended to guarantee your freedom to+  share and change all versions of a program--to make sure it remains free+  software for all its users.+ .+    When we speak of free software, we are referring to freedom, not+  price.  Our General Public Licenses are designed to make sure that you+  have the freedom to distribute copies of free software (and charge for+  them if you wish), that you receive source code or can get it if you+  want it, that you can change the software or use pieces of it in new+  free programs, and that you know you can do these things.+ .+    Developers that use our General Public Licenses protect your rights+  with two steps: (1) assert copyright on the software, and (2) offer+  you this License which gives you legal permission to copy, distribute+  and/or modify the software.+ .+    A secondary benefit of defending all users' freedom is that+  improvements made in alternate versions of the program, if they+  receive widespread use, become available for other developers to+  incorporate.  Many developers of free software are heartened and+  encouraged by the resulting cooperation.  However, in the case of+  software used on network servers, this result may fail to come about.+  The GNU General Public License permits making a modified version and+  letting the public access it on a server without ever releasing its+  source code to the public.+ .+    The GNU Affero General Public License is designed specifically to+  ensure that, in such cases, the modified source code becomes available+  to the community.  It requires the operator of a network server to+  provide the source code of the modified version running there to the+  users of that server.  Therefore, public use of a modified version, on+  a publicly accessible server, gives the public access to the source+  code of the modified version.+ .+    An older license, called the Affero General Public License and+  published by Affero, was designed to accomplish similar goals.  This is+  a different license, not a version of the Affero GPL, but Affero has+  released a new version of the Affero GPL which permits relicensing under+  this license.+ .+    The precise terms and conditions for copying, distribution and+  modification follow.+ .+                         TERMS AND CONDITIONS+ .+    0. Definitions.+ .+    "This License" refers to version 3 of the GNU Affero General Public License.+ .+    "Copyright" also means copyright-like laws that apply to other kinds of+  works, such as semiconductor masks.+ .+    "The Program" refers to any copyrightable work licensed under this+  License.  Each licensee is addressed as "you".  "Licensees" and+  "recipients" may be individuals or organizations.+ .+    To "modify" a work means to copy from or adapt all or part of the work+  in a fashion requiring copyright permission, other than the making of an+  exact copy.  The resulting work is called a "modified version" of the+  earlier work or a work "based on" the earlier work.+ .+    A "covered work" means either the unmodified Program or a work based+  on the Program.+ .+    To "propagate" a work means to do anything with it that, without+  permission, would make you directly or secondarily liable for+  infringement under applicable copyright law, except executing it on a+  computer or modifying a private copy.  Propagation includes copying,+  distribution (with or without modification), making available to the+  public, and in some countries other activities as well.+ .+    To "convey" a work means any kind of propagation that enables other+  parties to make or receive copies.  Mere interaction with a user through+  a computer network, with no transfer of a copy, is not conveying.+ .+    An interactive user interface displays "Appropriate Legal Notices"+  to the extent that it includes a convenient and prominently visible+  feature that (1) displays an appropriate copyright notice, and (2)+  tells the user that there is no warranty for the work (except to the+  extent that warranties are provided), that licensees may convey the+  work under this License, and how to view a copy of this License.  If+  the interface presents a list of user commands or options, such as a+  menu, a prominent item in the list meets this criterion.+ .+    1. Source Code.+ .+    The "source code" for a work means the preferred form of the work+  for making modifications to it.  "Object code" means any non-source+  form of a work.+ .+    A "Standard Interface" means an interface that either is an official+  standard defined by a recognized standards body, or, in the case of+  interfaces specified for a particular programming language, one that+  is widely used among developers working in that language.+ .+    The "System Libraries" of an executable work include anything, other+  than the work as a whole, that (a) is included in the normal form of+  packaging a Major Component, but which is not part of that Major+  Component, and (b) serves only to enable use of the work with that+  Major Component, or to implement a Standard Interface for which an+  implementation is available to the public in source code form.  A+  "Major Component", in this context, means a major essential component+  (kernel, window system, and so on) of the specific operating system+  (if any) on which the executable work runs, or a compiler used to+  produce the work, or an object code interpreter used to run it.+ .+    The "Corresponding Source" for a work in object code form means all+  the source code needed to generate, install, and (for an executable+  work) run the object code and to modify the work, including scripts to+  control those activities.  However, it does not include the work's+  System Libraries, or general-purpose tools or generally available free+  programs which are used unmodified in performing those activities but+  which are not part of the work.  For example, Corresponding Source+  includes interface definition files associated with source files for+  the work, and the source code for shared libraries and dynamically+  linked subprograms that the work is specifically designed to require,+  such as by intimate data communication or control flow between those+  subprograms and other parts of the work.+ .+    The Corresponding Source need not include anything that users+  can regenerate automatically from other parts of the Corresponding+  Source.+ .+    The Corresponding Source for a work in source code form is that+  same work.+ .+    2. Basic Permissions.+ .+    All rights granted under this License are granted for the term of+  copyright on the Program, and are irrevocable provided the stated+  conditions are met.  This License explicitly affirms your unlimited+  permission to run the unmodified Program.  The output from running a+  covered work is covered by this License only if the output, given its+  content, constitutes a covered work.  This License acknowledges your+  rights of fair use or other equivalent, as provided by copyright law.+ .+    You may make, run and propagate covered works that you do not+  convey, without conditions so long as your license otherwise remains+  in force.  You may convey covered works to others for the sole purpose+  of having them make modifications exclusively for you, or provide you+  with facilities for running those works, provided that you comply with+  the terms of this License in conveying all material for which you do+  not control copyright.  Those thus making or running the covered works+  for you must do so exclusively on your behalf, under your direction+  and control, on terms that prohibit them from making any copies of+  your copyrighted material outside their relationship with you.+ .+    Conveying under any other circumstances is permitted solely under+  the conditions stated below.  Sublicensing is not allowed; section 10+  makes it unnecessary.+ .+    3. Protecting Users' Legal Rights From Anti-Circumvention Law.+ .+    No covered work shall be deemed part of an effective technological+  measure under any applicable law fulfilling obligations under article+  11 of the WIPO copyright treaty adopted on 20 December 1996, or+  similar laws prohibiting or restricting circumvention of such+  measures.+ .+    When you convey a covered work, you waive any legal power to forbid+  circumvention of technological measures to the extent such circumvention+  is effected by exercising rights under this License with respect to+  the covered work, and you disclaim any intention to limit operation or+  modification of the work as a means of enforcing, against the work's+  users, your or third parties' legal rights to forbid circumvention of+  technological measures.+ .+    4. Conveying Verbatim Copies.+ .+    You may convey verbatim copies of the Program's source code as you+  receive it, in any medium, provided that you conspicuously and+  appropriately publish on each copy an appropriate copyright notice;+  keep intact all notices stating that this License and any+  non-permissive terms added in accord with section 7 apply to the code;+  keep intact all notices of the absence of any warranty; and give all+  recipients a copy of this License along with the Program.+ .+    You may charge any price or no price for each copy that you convey,+  and you may offer support or warranty protection for a fee.+ .+    5. Conveying Modified Source Versions.+ .+    You may convey a work based on the Program, or the modifications to+  produce it from the Program, in the form of source code under the+  terms of section 4, provided that you also meet all of these conditions:+ .+      a) The work must carry prominent notices stating that you modified+      it, and giving a relevant date.+ .+      b) The work must carry prominent notices stating that it is+      released under this License and any conditions added under section+      7.  This requirement modifies the requirement in section 4 to+      "keep intact all notices".+ .+      c) You must license the entire work, as a whole, under this+      License to anyone who comes into possession of a copy.  This+      License will therefore apply, along with any applicable section 7+      additional terms, to the whole of the work, and all its parts,+      regardless of how they are packaged.  This License gives no+      permission to license the work in any other way, but it does not+      invalidate such permission if you have separately received it.+ .+      d) If the work has interactive user interfaces, each must display+      Appropriate Legal Notices; however, if the Program has interactive+      interfaces that do not display Appropriate Legal Notices, your+      work need not make them do so.+ .+    A compilation of a covered work with other separate and independent+  works, which are not by their nature extensions of the covered work,+  and which are not combined with it such as to form a larger program,+  in or on a volume of a storage or distribution medium, is called an+  "aggregate" if the compilation and its resulting copyright are not+  used to limit the access or legal rights of the compilation's users+  beyond what the individual works permit.  Inclusion of a covered work+  in an aggregate does not cause this License to apply to the other+  parts of the aggregate.+ .+    6. Conveying Non-Source Forms.+ .+    You may convey a covered work in object code form under the terms+  of sections 4 and 5, provided that you also convey the+  machine-readable Corresponding Source under the terms of this License,+  in one of these ways:+ .+      a) Convey the object code in, or embodied in, a physical product+      (including a physical distribution medium), accompanied by the+      Corresponding Source fixed on a durable physical medium+      customarily used for software interchange.+ .+      b) Convey the object code in, or embodied in, a physical product+      (including a physical distribution medium), accompanied by a+      written offer, valid for at least three years and valid for as+      long as you offer spare parts or customer support for that product+      model, to give anyone who possesses the object code either (1) a+      copy of the Corresponding Source for all the software in the+      product that is covered by this License, on a durable physical+      medium customarily used for software interchange, for a price no+      more than your reasonable cost of physically performing this+      conveying of source, or (2) access to copy the+      Corresponding Source from a network server at no charge.+ .+      c) Convey individual copies of the object code with a copy of the+      written offer to provide the Corresponding Source.  This+      alternative is allowed only occasionally and noncommercially, and+      only if you received the object code with such an offer, in accord+      with subsection 6b.+ .+      d) Convey the object code by offering access from a designated+      place (gratis or for a charge), and offer equivalent access to the+      Corresponding Source in the same way through the same place at no+      further charge.  You need not require recipients to copy the+      Corresponding Source along with the object code.  If the place to+      copy the object code is a network server, the Corresponding Source+      may be on a different server (operated by you or a third party)+      that supports equivalent copying facilities, provided you maintain+      clear directions next to the object code saying where to find the+      Corresponding Source.  Regardless of what server hosts the+      Corresponding Source, you remain obligated to ensure that it is+      available for as long as needed to satisfy these requirements.+ .+      e) Convey the object code using peer-to-peer transmission, provided+      you inform other peers where the object code and Corresponding+      Source of the work are being offered to the general public at no+      charge under subsection 6d.+ .+    A separable portion of the object code, whose source code is excluded+  from the Corresponding Source as a System Library, need not be+  included in conveying the object code work.+ .+    A "User Product" is either (1) a "consumer product", which means any+  tangible personal property which is normally used for personal, family,+  or household purposes, or (2) anything designed or sold for incorporation+  into a dwelling.  In determining whether a product is a consumer product,+  doubtful cases shall be resolved in favor of coverage.  For a particular+  product received by a particular user, "normally used" refers to a+  typical or common use of that class of product, regardless of the status+  of the particular user or of the way in which the particular user+  actually uses, or expects or is expected to use, the product.  A product+  is a consumer product regardless of whether the product has substantial+  commercial, industrial or non-consumer uses, unless such uses represent+  the only significant mode of use of the product.+ .+    "Installation Information" for a User Product means any methods,+  procedures, authorization keys, or other information required to install+  and execute modified versions of a covered work in that User Product from+  a modified version of its Corresponding Source.  The information must+  suffice to ensure that the continued functioning of the modified object+  code is in no case prevented or interfered with solely because+  modification has been made.+ .+    If you convey an object code work under this section in, or with, or+  specifically for use in, a User Product, and the conveying occurs as+  part of a transaction in which the right of possession and use of the+  User Product is transferred to the recipient in perpetuity or for a+  fixed term (regardless of how the transaction is characterized), the+  Corresponding Source conveyed under this section must be accompanied+  by the Installation Information.  But this requirement does not apply+  if neither you nor any third party retains the ability to install+  modified object code on the User Product (for example, the work has+  been installed in ROM).+ .+    The requirement to provide Installation Information does not include a+  requirement to continue to provide support service, warranty, or updates+  for a work that has been modified or installed by the recipient, or for+  the User Product in which it has been modified or installed.  Access to a+  network may be denied when the modification itself materially and+  adversely affects the operation of the network or violates the rules and+  protocols for communication across the network.+ .+    Corresponding Source conveyed, and Installation Information provided,+  in accord with this section must be in a format that is publicly+  documented (and with an implementation available to the public in+  source code form), and must require no special password or key for+  unpacking, reading or copying.+ .+    7. Additional Terms.+ .+    "Additional permissions" are terms that supplement the terms of this+  License by making exceptions from one or more of its conditions.+  Additional permissions that are applicable to the entire Program shall+  be treated as though they were included in this License, to the extent+  that they are valid under applicable law.  If additional permissions+  apply only to part of the Program, that part may be used separately+  under those permissions, but the entire Program remains governed by+  this License without regard to the additional permissions.+ .+    When you convey a copy of a covered work, you may at your option+  remove any additional permissions from that copy, or from any part of+  it.  (Additional permissions may be written to require their own+  removal in certain cases when you modify the work.)  You may place+  additional permissions on material, added by you to a covered work,+  for which you have or can give appropriate copyright permission.+ .+    Notwithstanding any other provision of this License, for material you+  add to a covered work, you may (if authorized by the copyright holders of+  that material) supplement the terms of this License with terms:+ .+      a) Disclaiming warranty or limiting liability differently from the+      terms of sections 15 and 16 of this License; or+ .+      b) Requiring preservation of specified reasonable legal notices or+      author attributions in that material or in the Appropriate Legal+      Notices displayed by works containing it; or+ .+      c) Prohibiting misrepresentation of the origin of that material, or+      requiring that modified versions of such material be marked in+      reasonable ways as different from the original version; or+ .+      d) Limiting the use for publicity purposes of names of licensors or+      authors of the material; or+ .+      e) Declining to grant rights under trademark law for use of some+      trade names, trademarks, or service marks; or+ .+      f) Requiring indemnification of licensors and authors of that+      material by anyone who conveys the material (or modified versions of+      it) with contractual assumptions of liability to the recipient, for+      any liability that these contractual assumptions directly impose on+      those licensors and authors.+ .+    All other non-permissive additional terms are considered "further+  restrictions" within the meaning of section 10.  If the Program as you+  received it, or any part of it, contains a notice stating that it is+  governed by this License along with a term that is a further+  restriction, you may remove that term.  If a license document contains+  a further restriction but permits relicensing or conveying under this+  License, you may add to a covered work material governed by the terms+  of that license document, provided that the further restriction does+  not survive such relicensing or conveying.+ .+    If you add terms to a covered work in accord with this section, you+  must place, in the relevant source files, a statement of the+  additional terms that apply to those files, or a notice indicating+  where to find the applicable terms.+ .+    Additional terms, permissive or non-permissive, may be stated in the+  form of a separately written license, or stated as exceptions;+  the above requirements apply either way.+ .+    8. Termination.+ .+    You may not propagate or modify a covered work except as expressly+  provided under this License.  Any attempt otherwise to propagate or+  modify it is void, and will automatically terminate your rights under+  this License (including any patent licenses granted under the third+  paragraph of section 11).+ .+    However, if you cease all violation of this License, then your+  license from a particular copyright holder is reinstated (a)+  provisionally, unless and until the copyright holder explicitly and+  finally terminates your license, and (b) permanently, if the copyright+  holder fails to notify you of the violation by some reasonable means+  prior to 60 days after the cessation.+ .+    Moreover, your license from a particular copyright holder is+  reinstated permanently if the copyright holder notifies you of the+  violation by some reasonable means, this is the first time you have+  received notice of violation of this License (for any work) from that+  copyright holder, and you cure the violation prior to 30 days after+  your receipt of the notice.+ .+    Termination of your rights under this section does not terminate the+  licenses of parties who have received copies or rights from you under+  this License.  If your rights have been terminated and not permanently+  reinstated, you do not qualify to receive new licenses for the same+  material under section 10.+ .+    9. Acceptance Not Required for Having Copies.+ .+    You are not required to accept this License in order to receive or+  run a copy of the Program.  Ancillary propagation of a covered work+  occurring solely as a consequence of using peer-to-peer transmission+  to receive a copy likewise does not require acceptance.  However,+  nothing other than this License grants you permission to propagate or+  modify any covered work.  These actions infringe copyright if you do+  not accept this License.  Therefore, by modifying or propagating a+  covered work, you indicate your acceptance of this License to do so.+ .+    10. Automatic Licensing of Downstream Recipients.+ .+    Each time you convey a covered work, the recipient automatically+  receives a license from the original licensors, to run, modify and+  propagate that work, subject to this License.  You are not responsible+  for enforcing compliance by third parties with this License.+ .+    An "entity transaction" is a transaction transferring control of an+  organization, or substantially all assets of one, or subdividing an+  organization, or merging organizations.  If propagation of a covered+  work results from an entity transaction, each party to that+  transaction who receives a copy of the work also receives whatever+  licenses to the work the party's predecessor in interest had or could+  give under the previous paragraph, plus a right to possession of the+  Corresponding Source of the work from the predecessor in interest, if+  the predecessor has it or can get it with reasonable efforts.+ .+    You may not impose any further restrictions on the exercise of the+  rights granted or affirmed under this License.  For example, you may+  not impose a license fee, royalty, or other charge for exercise of+  rights granted under this License, and you may not initiate litigation+  (including a cross-claim or counterclaim in a lawsuit) alleging that+  any patent claim is infringed by making, using, selling, offering for+  sale, or importing the Program or any portion of it.+ .+    11. Patents.+ .+    A "contributor" is a copyright holder who authorizes use under this+  License of the Program or a work on which the Program is based.  The+  work thus licensed is called the contributor's "contributor version".+ .+    A contributor's "essential patent claims" are all patent claims+  owned or controlled by the contributor, whether already acquired or+  hereafter acquired, that would be infringed by some manner, permitted+  by this License, of making, using, or selling its contributor version,+  but do not include claims that would be infringed only as a+  consequence of further modification of the contributor version.  For+  purposes of this definition, "control" includes the right to grant+  patent sublicenses in a manner consistent with the requirements of+  this License.+ .+    Each contributor grants you a non-exclusive, worldwide, royalty-free+  patent license under the contributor's essential patent claims, to+  make, use, sell, offer for sale, import and otherwise run, modify and+  propagate the contents of its contributor version.+ .+    In the following three paragraphs, a "patent license" is any express+  agreement or commitment, however denominated, not to enforce a patent+  (such as an express permission to practice a patent or covenant not to+  sue for patent infringement).  To "grant" such a patent license to a+  party means to make such an agreement or commitment not to enforce a+  patent against the party.+ .+    If you convey a covered work, knowingly relying on a patent license,+  and the Corresponding Source of the work is not available for anyone+  to copy, free of charge and under the terms of this License, through a+  publicly available network server or other readily accessible means,+  then you must either (1) cause the Corresponding Source to be so+  available, or (2) arrange to deprive yourself of the benefit of the+  patent license for this particular work, or (3) arrange, in a manner+  consistent with the requirements of this License, to extend the patent+  license to downstream recipients.  "Knowingly relying" means you have+  actual knowledge that, but for the patent license, your conveying the+  covered work in a country, or your recipient's use of the covered work+  in a country, would infringe one or more identifiable patents in that+  country that you have reason to believe are valid.+ .+    If, pursuant to or in connection with a single transaction or+  arrangement, you convey, or propagate by procuring conveyance of, a+  covered work, and grant a patent license to some of the parties+  receiving the covered work authorizing them to use, propagate, modify+  or convey a specific copy of the covered work, then the patent license+  you grant is automatically extended to all recipients of the covered+  work and works based on it.+ .+    A patent license is "discriminatory" if it does not include within+  the scope of its coverage, prohibits the exercise of, or is+  conditioned on the non-exercise of one or more of the rights that are+  specifically granted under this License.  You may not convey a covered+  work if you are a party to an arrangement with a third party that is+  in the business of distributing software, under which you make payment+  to the third party based on the extent of your activity of conveying+  the work, and under which the third party grants, to any of the+  parties who would receive the covered work from you, a discriminatory+  patent license (a) in connection with copies of the covered work+  conveyed by you (or copies made from those copies), or (b) primarily+  for and in connection with specific products or compilations that+  contain the covered work, unless you entered into that arrangement,+  or that patent license was granted, prior to 28 March 2007.+ .+    Nothing in this License shall be construed as excluding or limiting+  any implied license or other defenses to infringement that may+  otherwise be available to you under applicable patent law.+ .+    12. No Surrender of Others' Freedom.+ .+    If conditions are imposed on you (whether by court order, agreement or+  otherwise) that contradict the conditions of this License, they do not+  excuse you from the conditions of this License.  If you cannot convey a+  covered work so as to satisfy simultaneously your obligations under this+  License and any other pertinent obligations, then as a consequence you may+  not convey it at all.  For example, if you agree to terms that obligate you+  to collect a royalty for further conveying from those to whom you convey+  the Program, the only way you could satisfy both those terms and this+  License would be to refrain entirely from conveying the Program.+ .+    13. Remote Network Interaction; Use with the GNU General Public License.+ .+    Notwithstanding any other provision of this License, if you modify the+  Program, your modified version must prominently offer all users+  interacting with it remotely through a computer network (if your version+  supports such interaction) an opportunity to receive the Corresponding+  Source of your version by providing access to the Corresponding Source+  from a network server at no charge, through some standard or customary+  means of facilitating copying of software.  This Corresponding Source+  shall include the Corresponding Source for any work covered by version 3+  of the GNU General Public License that is incorporated pursuant to the+  following paragraph.+ .+    Notwithstanding any other provision of this License, you have+  permission to link or combine any covered work with a work licensed+  under version 3 of the GNU General Public License into a single+  combined work, and to convey the resulting work.  The terms of this+  License will continue to apply to the part which is the covered work,+  but the work with which it is combined will remain governed by version+  3 of the GNU General Public License.+ .+    14. Revised Versions of this License.+ .+    The Free Software Foundation may publish revised and/or new versions of+  the GNU Affero General Public License from time to time.  Such new versions+  will be similar in spirit to the present version, but may differ in detail to+  address new problems or concerns.+ .+    Each version is given a distinguishing version number.  If the+  Program specifies that a certain numbered version of the GNU Affero General+  Public License "or any later version" applies to it, you have the+  option of following the terms and conditions either of that numbered+  version or of any later version published by the Free Software+  Foundation.  If the Program does not specify a version number of the+  GNU Affero General Public License, you may choose any version ever published+  by the Free Software Foundation.+ .+    If the Program specifies that a proxy can decide which future+  versions of the GNU Affero General Public License can be used, that proxy's+  public statement of acceptance of a version permanently authorizes you+  to choose that version for the Program.+ .+    Later license versions may give you additional or different+  permissions.  However, no additional obligations are imposed on any+  author or copyright holder as a result of your choosing to follow a+  later version.+ .+    15. Disclaimer of Warranty.+ .+    THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY+  APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT+  HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY+  OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,+  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR+  PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM+  IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF+  ALL NECESSARY SERVICING, REPAIR OR CORRECTION.+ .+    16. Limitation of Liability.+ .+    IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING+  WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS+  THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY+  GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE+  USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF+  DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD+  PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),+  EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF+  SUCH DAMAGES.+ .+    17. Interpretation of Sections 15 and 16.+ .+    If the disclaimer of warranty and limitation of liability provided+  above cannot be given local legal effect according to their terms,+  reviewing courts shall apply local law that most closely approximates+  an absolute waiver of all civil liability in connection with the+  Program, unless a warranty or assumption of liability accompanies a+  copy of the Program in return for a fee.+ .+                       END OF TERMS AND CONDITIONS+ .+              How to Apply These Terms to Your New Programs+ .+    If you develop a new program, and you want it to be of the greatest+  possible use to the public, the best way to achieve this is to make it+  free software which everyone can redistribute and change under these terms.+ .+    To do so, attach the following notices to the program.  It is safest+  to attach them to the start of each source file to most effectively+  state the exclusion of warranty; and each file should have at least+  the "copyright" line and a pointer to where the full notice is found.+ .+      <one line to give the program's name and a brief idea of what it does.>+      Copyright (C) <year>  <name of author>+ .+      This program is free software: you can redistribute it and/or modify+      it under the terms of the GNU Affero General Public License as published by+      the Free Software Foundation, either version 3 of the License, or+      (at your option) any later version.+ .+      This program is distributed in the hope that it will be useful,+      but WITHOUT ANY WARRANTY; without even the implied warranty of+      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the+      GNU Affero General Public License for more details.+ .+      You should have received a copy of the GNU Affero General Public License+      along with this program.  If not, see <http://www.gnu.org/licenses/>.+ .+  Also add information on how to contact you by electronic and paper mail.+ .+    If your software can interact with users remotely through a computer+  network, you should also make sure that it provides a way for users to+  get its source.  For example, if your program is a web application, its+  interface could display a "Source" link that leads users to an archive+  of the code.  There are many ways you could offer source, and different+  solutions will be better for different programs; see section 13 for the+  specific requirements.+ .+    You should also get your employer (if you work as a programmer) or school,+  if any, to sign a "copyright disclaimer" for the program, if necessary.+  For more information on this, and how to apply and follow the GNU AGPL, see+  <http://www.gnu.org/licenses/>.
CmdLine.hs view
@@ -43,7 +43,7 @@ 				forM_ fields $ \(f, v) -> Annex.setField f v 				sequence_ flags 				prepCommand cmd params-		 	tryRun state' cmd $ [startup] ++ actions ++ [shutdown $ cmdoneshot cmd]+		 	tryRun state' cmd $ [startup] ++ actions ++ [shutdown $ cmdnocommit cmd] 	where 		err msg = msg ++ "\n\n" ++ usage header allcmds commonoptions 		cmd = Prelude.head cmds@@ -112,8 +112,8 @@  {- Cleanup actions. -} shutdown :: Bool -> Annex Bool-shutdown oneshot = do-	saveState oneshot+shutdown nocommit = do+	saveState nocommit 	sequence_ =<< M.elems <$> Annex.getState Annex.cleanup 	liftIO Git.Command.reap -- zombies from long-running git processes 	sshCleanup -- ssh connection caching
Command.hs view
@@ -8,7 +8,7 @@ module Command ( 	command, 	noRepo,-	oneShot,+	noCommit, 	withOptions, 	next, 	stop,@@ -43,9 +43,10 @@ command :: String -> String -> [CommandSeek] -> String -> Command command = Command [] Nothing commonChecks False -{- Makes a command run in oneshot mode. -}-oneShot :: Command -> Command-oneShot c = c { cmdoneshot = True }+{- Indicates that a command doesn't need to commit any changes to+ - the git-annex branch. -}+noCommit :: Command -> Command+noCommit c = c { cmdnocommit = True }  {- Adds a fallback action to a command, that will be run if it's used  - outside a git repository. -}
Command/AddUnused.hs view
@@ -11,6 +11,7 @@ import Logs.Unused import Command import qualified Command.Add+import Types.Key  def :: [Command] def = [command "addunused" (paramRepeating paramNumRange)@@ -25,7 +26,7 @@ perform :: Key -> CommandPerform perform key = next $ Command.Add.cleanup file key True 	where-		file = "unused." ++ show key+		file = "unused." ++ key2file key  {- The content is not in the annex, but in another directory, and  - it seems better to error out, rather than moving bad/tmp content into
+ Command/Assistant.hs view
@@ -0,0 +1,71 @@+{- git-annex assistant+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++module Command.Assistant where++import Common.Annex+import Command+import qualified Option+import qualified Command.Watch+import Init+import Locations.UserConfig++import System.Environment+import System.Posix.Directory++def :: [Command]+def = [noRepo checkAutoStart $ dontCheck repoExists $+	withOptions [Command.Watch.foregroundOption, Command.Watch.stopOption, autoStartOption] $ +	command "assistant" paramNothing seek "automatically handle changes"]++autoStartOption :: Option+autoStartOption = Option.flag [] "autostart" "start in known repositories"++seek :: [CommandSeek]+seek = [withFlag Command.Watch.stopOption $ \stopdaemon ->+	withFlag Command.Watch.foregroundOption $ \foreground ->+	withFlag autoStartOption $ \autostart ->+	withNothing $ start foreground stopdaemon autostart]++start :: Bool -> Bool -> Bool -> CommandStart+start foreground stopdaemon autostart+	| autostart = do+		liftIO autoStart+		stop+	| otherwise = do+		ensureInitialized+		Command.Watch.start True foreground stopdaemon++{- Run outside a git repository. Check to see if any parameter is+ - --autostart and enter autostart mode. -}+checkAutoStart :: IO ()+checkAutoStart = ifM (elem "--autostart" <$> getArgs)+	( autoStart+	, error "Not in a git repository."+	) ++autoStart :: IO ()+autoStart = do+	autostartfile <- autoStartFile+	let nothing = error $ "Nothing listed in " ++ autostartfile+	ifM (doesFileExist autostartfile)+		( do+			dirs <- lines <$> readFile autostartfile+			program <- readProgramFile+			when (null dirs) nothing+			forM_ dirs $ \d -> do+				putStrLn $ "git-annex autostart in " ++ d+				ifM (catchBoolIO $ go program d)+					( putStrLn "ok"+					, putStrLn "failed"+					)+		, nothing+		)+	where+		go program dir = do+			changeWorkingDirectory dir+			boolSystem program [Param "assistant"]
Command/ConfigList.hs view
@@ -12,7 +12,7 @@ import Annex.UUID  def :: [Command]-def = [oneShot $ command "configlist" paramNothing seek+def = [noCommit $ command "configlist" paramNothing seek 	"outputs relevant git configuration"]  seek :: [CommandSeek]
Command/DropKey.hs view
@@ -12,9 +12,10 @@ import qualified Annex import Logs.Location import Annex.Content+import Types.Key  def :: [Command]-def = [oneShot $ command "dropkey" (paramRepeating paramKey) seek+def = [noCommit $ command "dropkey" (paramRepeating paramKey) seek 	"drops annexed content for specified keys"]   seek :: [CommandSeek]@@ -24,7 +25,7 @@ start key = stopUnless (inAnnex key) $ do 	unlessM (Annex.getState Annex.force) $ 		error "dropkey can cause data loss; use --force if you're sure you want to do this"-	showStart "dropkey" (show key)+	showStart "dropkey" (key2file key) 	next $ perform key  perform :: Key -> CommandPerform
Command/Find.hs view
@@ -53,7 +53,7 @@ 	where 		vars = 			[ ("file", file)-			, ("key", show key)+			, ("key", key2file key) 			, ("backend", keyBackendName key) 			, ("bytesize", size show) 			, ("humansize", size $ roughSize storageUnits True)
Command/FromKey.hs view
@@ -22,7 +22,7 @@  start :: [String] -> CommandStart start (keyname:file:[]) = notBareRepo $ do-	let key = fromMaybe (error "bad key") $ readKey keyname+	let key = fromMaybe (error "bad key") $ file2key keyname 	inbackend <- inAnnex key 	unless inbackend $ error $ 		"key ("++ keyname ++") is not present in backend"
Command/Fsck.hs view
@@ -7,6 +7,8 @@  module Command.Fsck where +import System.Posix.Process (getProcessID)+ import Common.Annex import Command import qualified Annex@@ -24,6 +26,7 @@ import Utility.FileMode import Config import qualified Option+import Types.Key  def :: [Command] def = [withOptions options $ command "fsck" paramPaths seek@@ -112,7 +115,7 @@ startBare key = case Backend.maybeLookupBackendName (Types.Key.keyBackendName key) of 	Nothing -> stop 	Just backend -> do-		showStart "fsck" (show key)+		showStart "fsck" (key2file key) 		next $ performBare key backend  {- Note that numcopies cannot be checked in a bare repository, because@@ -120,7 +123,7 @@  - files. -} performBare :: Key -> Backend -> CommandPerform performBare key backend = check-	[ verifyLocationLog key (show key)+	[ verifyLocationLog key (key2file key) 	, checkKeySize key 	, checkBackend backend key 	]@@ -206,17 +209,17 @@ checkKeySize key = do 	file <- inRepo $ gitAnnexLocation key 	ifM (liftIO $ doesFileExist file)-		( checkKeySize' key file badContent+		( checkKeySizeOr badContent key file 		, return True 		)  checkKeySizeRemote :: Key -> Remote -> Maybe FilePath -> Annex Bool checkKeySizeRemote _ _ Nothing = return True-checkKeySizeRemote key remote (Just file) = checkKeySize' key file-	(badContentRemote remote)+checkKeySizeRemote key remote (Just file) =+	checkKeySizeOr (badContentRemote remote) key file -checkKeySize' :: Key -> FilePath -> (Key -> Annex String) -> Annex Bool-checkKeySize' key file bad = case Types.Key.keySize key of+checkKeySizeOr :: (Key -> Annex String) -> Key -> FilePath -> Annex Bool+checkKeySizeOr bad key file = case Types.Key.keySize key of 	Nothing -> return True 	Just size -> do 		size' <- fromIntegral . fileSize@@ -239,22 +242,23 @@ checkBackend :: Backend -> Key -> Annex Bool checkBackend backend key = do 	file <- inRepo (gitAnnexLocation key)-	checkBackend' backend key (Just file) badContent+	checkBackendOr badContent backend key file  checkBackendRemote :: Backend -> Key -> Remote -> Maybe FilePath -> Annex Bool-checkBackendRemote backend key remote localcopy =-	checkBackend' backend key localcopy (badContentRemote remote)+checkBackendRemote backend key remote = maybe (return True) go+	where+		go = checkBackendOr (badContentRemote remote) backend key -checkBackend' :: Backend -> Key -> Maybe FilePath -> (Key -> Annex String) -> Annex Bool-checkBackend' _ _ Nothing _ = return True-checkBackend' backend key (Just file) bad = case Types.Backend.fsckKey backend of-	Nothing -> return True-	Just a -> do-		ok <- a key file-		unless ok $ do-			msg <- bad key-			warning $ "Bad file content; " ++ msg-		return ok+checkBackendOr :: (Key -> Annex String) -> Backend -> Key -> FilePath -> Annex Bool+checkBackendOr bad backend key file =+	case Types.Backend.fsckKey backend of+		Nothing -> return True+		Just a -> do+			ok <- a key file+			unless ok $ do+				msg <- bad key+				warning $ "Bad file content; " ++ msg+			return ok  checkKeyNumCopies :: Key -> FilePath -> Maybe Int -> Annex Bool checkKeyNumCopies key file numcopies = do
Command/Get.hs view
@@ -66,7 +66,7 @@ 				either (const False) id <$> Remote.hasKey r key 			| otherwise = return True 		docopy r continue = do-			ok <- download (Remote.uuid r) key (Just file) $ do+			ok <- download (Remote.uuid r) key (Just file) noRetry $ do 				showAction $ "from " ++ Remote.name r 				Remote.retrieveKeyFile r key (Just file) dest 			if ok then return ok else continue
Command/InAnnex.hs view
@@ -12,7 +12,7 @@ import Annex.Content  def :: [Command]-def = [oneShot $ command "inannex" (paramRepeating paramKey) seek+def = [noCommit $ command "inannex" (paramRepeating paramKey) seek 	"checks if keys are present in the annex"]  seek :: [CommandSeek]
Command/Map.hs view
@@ -199,8 +199,10 @@ 				Left _ -> return Nothing 				Right r' -> return $ Just r' 		pipedconfig cmd params = safely $-			pOpen ReadFromPipe cmd (toCommand params) $+			withHandle StdoutHandle createProcessSuccess p $ 				Git.Config.hRead r+			where+				p = proc cmd $ toCommand params  		configlist = 			onRemote r (pipedconfig, Nothing) "configlist" [] []
Command/Migrate.hs view
@@ -14,6 +14,7 @@ import Types.KeySource import Annex.Content import qualified Command.ReKey+import qualified Command.Fsck  def :: [Command] def = [command "migrate" paramPaths seek "switch data to different backend"]@@ -28,7 +29,7 @@ 	if (newbackend /= oldbackend || upgradableKey key) && exists 		then do 			showStart "migrate" file-			next $ perform file key newbackend+			next $ perform file key oldbackend newbackend 		else stop 	where 		choosebackend Nothing = Prelude.head <$> orderedList@@ -42,8 +43,12 @@ {- Store the old backend's key in the new backend  - The old backend's key is not dropped from it, because there may  - be other files still pointing at that key. -}-perform :: FilePath -> Key -> Backend -> CommandPerform-perform file oldkey newbackend = maybe stop go =<< genkey+perform :: FilePath -> Key -> Backend -> Backend -> CommandPerform+perform file oldkey oldbackend newbackend = do+	ifM (Command.Fsck.checkBackend oldbackend oldkey)+		( maybe stop go =<< genkey+		, stop+		) 	where 		go newkey = stopUnless (Command.ReKey.linkKey oldkey newkey) $ 			next $ Command.ReKey.cleanup file oldkey newkey
Command/Move.hs view
@@ -89,7 +89,7 @@ 			stop 		Right False -> do 			showAction $ "to " ++ Remote.name dest-			ok <- upload (Remote.uuid dest) key (Just file) $+			ok <- upload (Remote.uuid dest) key (Just file) noRetry $ 				Remote.storeKey dest key (Just file) 			if ok 				then finish@@ -135,13 +135,12 @@ fromPerform src move key file = moveLock move key $ 	ifM (inAnnex key) 		( handle move True-		, download (Remote.uuid src) key (Just file) $ do-			showAction $ "from " ++ Remote.name src-			ok <- getViaTmp key $-				Remote.retrieveKeyFile src key (Just file)-			handle move ok+		, handle move =<< go 		) 	where+		go = download (Remote.uuid src) key (Just file) noRetry $ do+			showAction $ "from " ++ Remote.name src+			getViaTmp key $ Remote.retrieveKeyFile src key (Just file) 		handle _ False = stop -- failed 		handle False True = next $ return True -- copy complete 		handle True True = do -- finish moving
Command/ReKey.hs view
@@ -26,7 +26,7 @@ start :: (FilePath, String) -> CommandStart start (file, keyname) = ifAnnexed file go stop 	where-		newkey = fromMaybe (error "bad key") $ readKey keyname+		newkey = fromMaybe (error "bad key") $ file2key keyname 		go (oldkey, _) 			| oldkey == newkey = stop 			| otherwise = do
Command/RecvKey.hs view
@@ -11,11 +11,12 @@ import Command import CmdLine import Annex.Content-import Utility.RsyncFile+import Utility.Rsync import Logs.Transfer+import Command.SendKey (fieldTransfer)  def :: [Command]-def = [oneShot $ command "recvkey" paramKey seek+def = [noCommit $ command "recvkey" paramKey seek 	"runs rsync in server mode to receive content"]  seek :: [CommandSeek]@@ -24,13 +25,13 @@ start :: Key -> CommandStart start key = ifM (inAnnex key) 	( error "key is already present in annex"-	, fieldTransfer Download key $ do+	, fieldTransfer Download key $ \_p -> do 		ifM (getViaTmp key $ liftIO . rsyncServerReceive) 			( do 				-- forcibly quit after receiving one key, 				-- and shutdown cleanly 				_ <- shutdown True-				liftIO exitSuccess-			, liftIO exitFailure+				return True+			, return False 			) 	)
Command/Reinject.hs view
@@ -35,8 +35,14 @@  perform :: FilePath -> FilePath -> (Key, Backend) -> CommandPerform perform src _dest (key, backend) = do-	unlessM move $ error "mv failed!"-	next $ cleanup key backend+	{- Check the content before accepting it. -}+	ifM (Command.Fsck.checkKeySizeOr reject key src+		<&&> Command.Fsck.checkBackendOr reject backend key src)+		( do+			unlessM move $ error "mv failed!"+			next $ cleanup key+		, error "not reinjecting"+		) 	where 		-- the file might be on a different filesystem, 		-- so mv is used rather than simply calling@@ -44,13 +50,9 @@ 		-- checked this way. 		move = getViaTmp key $ \tmp -> 			liftIO $ boolSystem "mv" [File src, File tmp]+		reject = const $ return "wrong file?" -cleanup :: Key -> Backend -> CommandCleanup-cleanup key backend = do+cleanup :: Key -> CommandCleanup+cleanup key = do 	logStatus key InfoPresent--	-- fsck the new content-	size_ok <- Command.Fsck.checkKeySize key-	backend_ok <- Command.Fsck.checkBackend backend key--	return $ size_ok && backend_ok+	return True
Command/SendKey.hs view
@@ -10,11 +10,13 @@ import Common.Annex import Command import Annex.Content-import Utility.RsyncFile+import Utility.Rsync import Logs.Transfer+import Types.Remote+import qualified Fields  def :: [Command]-def = [oneShot $ command "sendkey" paramKey seek+def = [noCommit $ command "sendkey" paramKey seek 	"runs rsync in server mode to send content"]  seek :: [CommandSeek]@@ -22,11 +24,20 @@  start :: Key -> CommandStart start key = ifM (inAnnex key)-	( fieldTransfer Upload key $ do+	( fieldTransfer Upload key $ \_p -> do 		file <- inRepo $ gitAnnexLocation key-		liftIO $ ifM (rsyncServerSend file)-			( exitSuccess , exitFailure )+		liftIO $ rsyncServerSend file 	, do 		warning "requested key is not present" 		liftIO exitFailure 	)++fieldTransfer :: Direction -> Key -> (MeterUpdate -> Annex Bool) -> CommandStart+fieldTransfer direction key a = do+	afile <- Fields.getField Fields.associatedFile+	ok <- maybe (a $ const noop)+		(\u -> runTransfer (Transfer direction (toUUID u) key) afile noRetry a)+		=<< Fields.getField Fields.remoteUUID+	if ok+		then liftIO exitSuccess+		else liftIO exitFailure
Command/Status.hs view
@@ -183,8 +183,8 @@ 		pp _ c [] = c 		pp uuidmap c ((t, i):xs) = "\n\t" ++ line uuidmap t i ++ pp uuidmap c xs 		line uuidmap t i = unwords-			[ show (transferDirection t) ++ "ing"-			, fromMaybe (show $ transferKey t) (associatedFile i)+			[ showLcDirection (transferDirection t) ++ "ing"+			, fromMaybe (key2file $ transferKey t) (associatedFile i) 			, if transferDirection t == Upload then "to" else "from" 			, maybe (fromUUID $ transferUUID t) Remote.name $ 				M.lookup (transferUUID t) uuidmap
Command/Sync.hs view
@@ -6,8 +6,6 @@  - Licensed under the GNU GPL version 3 or higher.  -} -{-# LANGUAGE BangPatterns #-}- module Command.Sync where  import Common.Annex@@ -27,8 +25,8 @@ import Git.Types (BlobType(..)) import qualified Types.Remote import qualified Remote.Git+import Types.Key -import qualified Data.Map as M import qualified Data.ByteString.Lazy as L import Data.Hash.MD5 @@ -39,7 +37,7 @@ -- syncing involves several operations, any of which can independently fail seek :: CommandSeek seek rs = do-	!branch <- fromMaybe nobranch <$> inRepo Git.Branch.current+	branch <- fromMaybe nobranch <$> inRepo Git.Branch.current 	remotes <- syncRemotes rs 	return $ concat 		[ [ commit ]@@ -63,23 +61,19 @@ 	where 		pickfast = (++) <$> listed <*> (good =<< fastest <$> available) 		wanted-			| null rs = good =<< concat . byspeed <$> available+			| null rs = good =<< concat . Remote.byCost <$> available 			| otherwise = listed 		listed = do 			l <- catMaybes <$> mapM (Remote.byName . Just) rs-			let s = filter special l+			let s = filter Remote.specialRemote l 			unless (null s) $ 				error $ "cannot sync special remotes: " ++ 					unwords (map Types.Remote.name s) 			return l-		available = filter nonspecial <$> Remote.enabledRemoteList+		available = filter (not . Remote.specialRemote)+			<$> Remote.enabledRemoteList 		good = filterM $ Remote.Git.repoAvail . Types.Remote.repo-		nonspecial r = Types.Remote.remotetype r == Remote.Git.remote-		special = not . nonspecial-		fastest = fromMaybe [] . headMaybe . byspeed-		byspeed = map snd . sort . M.toList . costmap-		costmap = M.fromListWith (++) . map costpair-		costpair r = (Types.Remote.cost r, [r])+		fastest = fromMaybe [] . headMaybe . Remote.byCost  commit :: CommandStart commit = do@@ -98,7 +92,7 @@ 		syncbranch = syncBranch branch 		needmerge = do 			unlessM (inRepo $ Git.Ref.exists syncbranch) $-				updateBranch syncbranch+				inRepo $ updateBranch syncbranch 			inRepo $ Git.Branch.changed branch syncbranch 		go False = stop 		go True = do@@ -107,17 +101,17 @@  pushLocal :: Git.Ref -> CommandStart pushLocal branch = do-	updateBranch $ syncBranch branch+	inRepo $ updateBranch $ syncBranch branch 	stop -updateBranch :: Git.Ref -> Annex ()-updateBranch syncbranch = +updateBranch :: Git.Ref -> Git.Repo -> IO ()+updateBranch syncbranch g =  	unlessM go $ error $ "failed to update " ++ show syncbranch 	where-		go = inRepo $ Git.Command.runBool "branch"+		go = Git.Command.runBool "branch" 			[ Param "-f" 			, Param $ show $ Git.Ref.base syncbranch-			]+			] g  pullRemote :: Remote -> Git.Ref -> CommandStart pullRemote remote branch = do@@ -125,7 +119,7 @@ 	next $ do 		showOutput 		stopUnless fetch $-			next $ mergeRemote remote branch+			next $ mergeRemote remote (Just branch) 	where 		fetch = inRepo $ Git.Command.runBool "fetch" 			[Param $ Remote.name remote]@@ -134,32 +128,46 @@  - Which to merge from? Well, the master has whatever latest changes  - were committed, while the synced/master may have changes that some  - other remote synced to this remote. So, merge them both. -}-mergeRemote :: Remote -> Git.Ref -> CommandCleanup-mergeRemote remote branch = all id <$> (mapM merge =<< tomerge)+mergeRemote :: Remote -> (Maybe Git.Ref) -> CommandCleanup+mergeRemote remote b = case b of+	Nothing -> do+		branch <- inRepo Git.Branch.currentUnsafe+		all id <$> (mapM merge $ branchlist branch)+	Just _ -> all id <$> (mapM merge =<< tomerge (branchlist b)) 	where 		merge = mergeFrom . remoteBranch remote-		tomerge = filterM (changed remote) [branch, syncBranch branch]+		tomerge branches = filterM (changed remote) branches+		branchlist Nothing = []+		branchlist (Just branch) = [branch, syncBranch branch]  pushRemote :: Remote -> Git.Ref -> CommandStart pushRemote remote branch = go =<< needpush 	where-		needpush = anyM (newer remote) [syncbranch, Annex.Branch.name]+		needpush = anyM (newer remote) [syncBranch branch, Annex.Branch.name] 		go False = stop 		go True = do 			showStart "push" (Remote.name remote) 			next $ next $ do 				showOutput-				inRepo $ Git.Command.runBool "push"-					[ Param (Remote.name remote)-					, Param (show Annex.Branch.name)-					, Param refspec-					]-		refspec = show (Git.Ref.base branch) ++ ":" ++ show (Git.Ref.base syncbranch)-		syncbranch = syncBranch branch+				inRepo $ pushBranch remote branch +pushBranch :: Remote -> Git.Ref -> Git.Repo -> IO Bool+pushBranch remote branch g =+	Git.Command.runBool "push"+		[ Param $ Remote.name remote+		, Param $ refspec Annex.Branch.name+		, Param $ refspec branch+		] g+	where+		refspec b = concat +			[ show $ Git.Ref.base b+			,  ":"+			, show $ Git.Ref.base $ syncBranch b+			]+ mergeAnnex :: CommandStart mergeAnnex = do-	Annex.Branch.forceUpdate+	void $ Annex.Branch.forceUpdate 	stop  mergeFrom :: Git.Ref -> Annex Bool@@ -248,8 +256,8 @@  -} mergeFile :: FilePath -> Key -> FilePath mergeFile file key-	| doubleconflict = go $ show key-	| otherwise = go $ shortHash $ show key+	| doubleconflict = go $ key2file key+	| otherwise = go $ shortHash $ key2file key 	where 		varmarker = ".variant-" 		doubleconflict = varmarker `isSuffixOf` (dropExtension file)@@ -259,7 +267,7 @@ 			++ takeExtension file 		 shortHash :: String -> String-shortHash = take 4 . md5s . encodeFilePath+shortHash = take 4 . md5s . md5FilePath  changed :: Remote -> Git.Ref -> Annex Bool changed remote b = do
+ Command/TransferInfo.hs view
@@ -0,0 +1,59 @@+{- git-annex command+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++module Command.TransferInfo where++import Common.Annex+import Command+import Annex.Content+import Logs.Transfer+import Types.Key+import qualified Fields++def :: [Command]+def = [noCommit $ command "transferinfo" paramKey seek+	"updates sender on number of bytes of content received"]++seek :: [CommandSeek]+seek = [withWords start]++{- Security:+ - + - The transfer info file contains the user-supplied key, but+ - the built-in guards prevent slashes in it from showing up in the filename.+ - It also contains the UUID of the remote. But slashes are also filtered+ - out of that when generating the filename.+ - + - Checks that the key being transferred is inAnnex, to prevent+ - malicious spamming of bogus keys. Does not check that a transfer+ - of the key is actually in progress, because this could be started+ - concurrently with sendkey, and win the race.+ -}+start :: [String] -> CommandStart+start (k:[]) = do+	case (file2key k) of+		Nothing -> error "bad key"+		(Just key) -> whenM (inAnnex key) $ do+			file <- Fields.getField Fields.associatedFile+			u <- maybe (error "missing remoteuuid") toUUID+				<$> Fields.getField Fields.remoteUUID+			let t = Transfer+				{ transferDirection = Upload+				, transferUUID = u+				, transferKey = key+				}+			info <- liftIO $ startTransferInfo file+			(update, tfile, _) <- mkProgressUpdater t info+			liftIO $ mapM_ void+				[ tryIO $ forever $ do+					bytes <- readish <$> getLine+					maybe (error "transferinfo protocol error") update bytes+				, tryIO $ removeFile tfile+				, exitSuccess+				]+	stop+start _ = error "wrong number of parameters"
+ Command/TransferKey.hs view
@@ -0,0 +1,58 @@+{- git-annex command, used internally by assistant+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++module Command.TransferKey where++import Common.Annex+import Command+import Annex.Content+import Logs.Location+import Logs.Transfer+import qualified Remote+import Types.Remote+import qualified Command.Move+import qualified Option++def :: [Command]+def = [withOptions options $+	noCommit $ command "transferkey" paramKey seek+		"transfers a key from or to a remote"]++options :: [Option]+options = fileOption : Command.Move.options++fileOption :: Option+fileOption = Option.field [] "file" paramFile "the associated file"++seek :: [CommandSeek]+seek = [withField Command.Move.toOption Remote.byName $ \to ->+	withField Command.Move.fromOption Remote.byName $ \from ->+	withField fileOption return $ \file ->+		withKeys $ start to from file]++start :: Maybe Remote -> Maybe Remote -> AssociatedFile -> Key -> CommandStart+start to from file key =+	case (from, to) of+		(Nothing, Just dest) -> next $ toPerform dest key file+		(Just src, Nothing) -> next $ fromPerform src key file+		_ -> error "specify either --from or --to"++toPerform :: Remote -> Key -> AssociatedFile -> CommandPerform+toPerform remote key file = go $+	upload (uuid remote) key file forwardRetry $ \p -> do+		ok <- Remote.storeKey remote key file p+		when ok $+			Remote.logStatus remote key InfoPresent+		return ok++fromPerform :: Remote -> Key -> AssociatedFile -> CommandPerform+fromPerform remote key file = go $+	download (uuid remote) key file forwardRetry $+		getViaTmp key $ Remote.retrieveKeyFile remote key file++go :: Annex Bool -> CommandPerform+go a = ifM a ( liftIO exitSuccess,  liftIO exitFailure)
Command/Unused.hs view
@@ -34,6 +34,7 @@ import qualified Annex.Branch import qualified Option import Annex.CatFile+import Types.Key  def :: [Command] def = [withOptions [fromOption] $ command "unused" paramNothing seek@@ -100,7 +101,7 @@ table :: [(Int, Key)] -> [String] table l = "  NUMBER  KEY" : map cols l 	where-		cols (n,k) = "  " ++ pad 6 (show n) ++ "  " ++ show k+		cols (n,k) = "  " ++ pad 6 (show n) ++ "  " ++ key2file k 		pad n s = s ++ replicate (n - length s) ' '  staleTmpMsg :: [(Int, Key)] -> String@@ -257,7 +258,8 @@ 			map (separate (== ' ')) . lines 		uniqref (x, _) (y, _) = x == y 		ourbranchend = '/' : show Annex.Branch.name-		ourbranches (_, b) = not $ ourbranchend `isSuffixOf` b+		ourbranches (_, b) = not (ourbranchend `isSuffixOf` b)+			&& not ("refs/synced/" `isPrefixOf` b)  withKeysReferencedInGitRef :: (Key -> Annex ()) -> Git.Ref -> Annex () withKeysReferencedInGitRef a ref = do
Command/Version.hs view
@@ -13,7 +13,7 @@ import Annex.Version  def :: [Command]-def = [oneShot $ noRepo showPackageVersion $ dontCheck repoExists $+def = [noCommit $ noRepo showPackageVersion $ dontCheck repoExists $ 	command "version" paramNothing seek "show version info"]  seek :: [CommandSeek]
Command/Watch.hs view
@@ -1,6 +1,3 @@-{-# LANGUAGE CPP #-}-{-# LANGUAGE BangPatterns #-}- {- git-annex watch command  -  - Copyright 2012 Joey Hess <joey@kitenet.net>@@ -22,7 +19,7 @@ seek :: [CommandSeek] seek = [withFlag stopOption $ \stopdaemon ->  	withFlag foregroundOption $ \foreground ->-	withNothing $ start foreground stopdaemon]+	withNothing $ start False foreground stopdaemon]  foregroundOption :: Option foregroundOption = Option.flag [] "foreground" "do not daemonize"@@ -30,9 +27,9 @@ stopOption :: Option stopOption = Option.flag [] "stop" "stop daemon" -start :: Bool -> Bool -> CommandStart-start foreground stopdaemon = notBareRepo $ do+start :: Bool -> Bool -> Bool -> CommandStart+start assistant foreground stopdaemon = notBareRepo $ do 	if stopdaemon 		then stopDaemon-		else startDaemon foreground -- does not return+		else startDaemon assistant foreground Nothing -- does not return 	stop
+ Command/WebApp.hs view
@@ -0,0 +1,135 @@+{- git-annex webapp launcher+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++module Command.WebApp where++import Common.Annex+import Command+import Assistant+import Assistant.Common+import Assistant.DaemonStatus+import Assistant.ScanRemotes+import Assistant.TransferQueue+import Assistant.TransferSlots+import Assistant.Threads.WebApp+import Assistant.WebApp+import Utility.WebApp+import Utility.Daemon (checkDaemon, lockPidFile)+import Init+import qualified Git+import qualified Git.Config+import qualified Git.CurrentRepo+import qualified Annex+import Locations.UserConfig++import System.Posix.Directory+import Control.Concurrent+import Control.Concurrent.STM++def :: [Command]+def = [noCommit $ noRepo startNoRepo $ dontCheck repoExists $+        command "webapp" paramNothing seek "launch webapp"]++seek :: [CommandSeek]+seek = [withNothing start]++start :: CommandStart+start = notBareRepo $ do+	ifM isInitialized ( go , liftIO startNoRepo )+	stop+	where+		go = do+			browser <- fromRepo webBrowser+			f <- liftIO . absPath =<< fromRepo gitAnnexHtmlShim+			ifM (checkpid <&&> checkshim f)+				( liftIO $ openBrowser browser f +				, startDaemon True True $ Just $+					const $ openBrowser browser+				)+		checkpid = do+			pidfile <- fromRepo gitAnnexPidFile+			liftIO $ isJust <$> checkDaemon pidfile+		checkshim f = liftIO $ doesFileExist f++{- When run without a repo, see if there is an autoStartFile,+ - and if so, start the first available listed repository.+ - If not, it's our first time being run! -}+startNoRepo :: IO ()+startNoRepo = do+	autostartfile <- autoStartFile+	ifM (doesFileExist autostartfile) ( autoStart autostartfile , firstRun )++autoStart :: FilePath -> IO ()+autoStart autostartfile = do+	dirs <- lines <$> readFile autostartfile+	edirs <- filterM doesDirectoryExist dirs+	case edirs of+		[] -> firstRun -- what else can I do? Nothing works..+		(d:_) -> do+			changeWorkingDirectory d+			state <- Annex.new =<< Git.CurrentRepo.get+			void $ Annex.eval state $ doCommand start++{- Run the webapp without a repository, which prompts the user, makes one,+ - changes to it, starts the regular assistant, and redirects the+ - browser to its url.+ -+ - This is a very tricky dance -- The first webapp calls the signaler,+ - which signals the main thread when it's ok to continue by writing to a+ - MVar. The main thread starts the second webapp, and uses its callback+ - to write its url back to the MVar, from where the signaler retrieves it,+ - returning it to the first webapp, which does the redirect.+ -+ - Note that it's important that mainthread never terminates! Much+ - of this complication is due to needing to keep the mainthread running.+ -}+firstRun :: IO ()+firstRun = do+	dstatus <- atomically . newTMVar =<< newDaemonStatus+	scanremotes <- newScanRemoteMap+	transferqueue <- newTransferQueue+	transferslots <- newTransferSlots+	urlrenderer <- newUrlRenderer+	v <- newEmptyMVar+	let callback a = Just $ a v+	void $ runNamedThread dstatus $+		webAppThread Nothing dstatus scanremotes+			transferqueue transferslots urlrenderer+			(callback signaler) (callback mainthread)+	where+		signaler v = do+			putMVar v ""+			takeMVar v+		mainthread v _url htmlshim = do+			browser <- maybe Nothing webBrowser <$> Git.Config.global+			openBrowser browser htmlshim++			_wait <- takeMVar v++			state <- Annex.new =<< Git.CurrentRepo.get+			Annex.eval state $ do+				dummydaemonize+				startAssistant True id $ Just $ sendurlback v+		sendurlback v url _htmlshim = putMVar v url+		{- Set up the pid file in the new repo. -}+		dummydaemonize =+			liftIO . lockPidFile =<< fromRepo gitAnnexPidFile++openBrowser :: Maybe FilePath -> FilePath -> IO ()+openBrowser cmd htmlshim = go $ maybe runBrowser runCustomBrowser cmd+	where+		url = fileUrl htmlshim+		go a = unlessM (a url) $+			error $ "failed to start web browser on url " ++ url+		runCustomBrowser c u = boolSystem c [Param u]++{- web.browser is a generic git config setting for a web browser program -}+webBrowser :: Git.Repo -> Maybe FilePath+webBrowser = Git.Config.getMaybe "web.browser"++fileUrl :: FilePath -> String+fileUrl file = "file://" ++ file
Command/Whereis.hs view
@@ -15,7 +15,7 @@ import Logs.Trust  def :: [Command]-def = [command "whereis" paramPaths seek+def = [noCommit $ command "whereis" paramPaths seek 	"lists repositories that have file content"]  seek :: [CommandSeek]
Common.hs view
@@ -13,16 +13,15 @@ import System.Path as X import System.FilePath as X import System.Directory as X-import System.Cmd.Utils as X hiding (safeSystem) import System.IO as X hiding (FilePath) import System.Posix.Files as X import System.Posix.IO as X-import System.Posix.Process as X hiding (executeFile) import System.Exit as X  import Utility.Misc as X import Utility.Exception as X import Utility.SafeCommand as X+import Utility.Process as X import Utility.Path as X import Utility.Directory as X import Utility.Monad as X
Config.hs view
@@ -56,7 +56,7 @@ 	cmd <- getRemoteConfig r "cost-command" "" 	(fromMaybe def . readish) <$> 		if not $ null cmd-			then liftIO $ snd <$> pipeFrom "sh" ["-c", cmd]+			then liftIO $ readProcess "sh" ["-c", cmd] 			else getRemoteConfig r "cost" ""  cheapRemoteCost :: Int@@ -116,4 +116,4 @@ 	cmd <- getConfig (annexConfig "http-headers-command") "" 	if null cmd 		then fromRepo $ Git.Config.getList "annex.http-headers"-		else lines . snd <$> liftIO (pipeFrom "sh" ["-c", cmd])+		else lines <$> liftIO (readProcess "sh" ["-c", cmd])
Crypto.hs view
@@ -112,7 +112,7 @@  - on content. It does need to be repeatable. -} encryptKey :: Cipher -> Key -> Key encryptKey c k = Key-	{ keyName = hmacWithCipher c (show k)+	{ keyName = hmacWithCipher c (key2file k) 	, keyBackendName = "GPGHMACSHA1" 	, keySize = Nothing -- size and mtime omitted 	, keyMtime = Nothing -- to avoid leaking data
Fields.hs view
@@ -18,6 +18,9 @@ 	, fieldCheck :: String -> Bool 	} +getField :: Field -> Annex (Maybe String)+getField = Annex.getField . fieldName+ remoteUUID :: Field remoteUUID = Field "remoteuuid" $ 	-- does it look like a UUID?@@ -27,6 +30,3 @@ associatedFile = Field "associatedfile" $ \f -> 	-- is the file a safe relative filename? 	not (isAbsolute f) && not ("../" `isPrefixOf` f)--getField :: Field -> Annex (Maybe String)-getField = Annex.getField . fieldName
− GPL
@@ -1,674 +0,0 @@-                    GNU GENERAL PUBLIC LICENSE-                       Version 3, 29 June 2007-- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>- Everyone is permitted to copy and distribute verbatim copies- of this license document, but changing it is not allowed.--                            Preamble--  The GNU General Public License is a free, copyleft license for-software and other kinds of works.--  The licenses for most software and other practical works are designed-to take away your freedom to share and change the works.  By contrast,-the GNU General Public License is intended to guarantee your freedom to-share and change all versions of a program--to make sure it remains free-software for all its users.  We, the Free Software Foundation, use the-GNU General Public License for most of our software; it applies also to-any other work released this way by its authors.  You can apply it to-your programs, too.--  When we speak of free software, we are referring to freedom, not-price.  Our General Public Licenses are designed to make sure that you-have the freedom to distribute copies of free software (and charge for-them if you wish), that you receive source code or can get it if you-want it, that you can change the software or use pieces of it in new-free programs, and that you know you can do these things.--  To protect your rights, we need to prevent others from denying you-these rights or asking you to surrender the rights.  Therefore, you have-certain responsibilities if you distribute copies of the software, or if-you modify it: responsibilities to respect the freedom of others.--  For example, if you distribute copies of such a program, whether-gratis or for a fee, you must pass on to the recipients the same-freedoms that you received.  You must make sure that they, too, receive-or can get the source code.  And you must show them these terms so they-know their rights.--  Developers that use the GNU GPL protect your rights with two steps:-(1) assert copyright on the software, and (2) offer you this License-giving you legal permission to copy, distribute and/or modify it.--  For the developers' and authors' protection, the GPL clearly explains-that there is no warranty for this free software.  For both users' and-authors' sake, the GPL requires that modified versions be marked as-changed, so that their problems will not be attributed erroneously to-authors of previous versions.--  Some devices are designed to deny users access to install or run-modified versions of the software inside them, although the manufacturer-can do so.  This is fundamentally incompatible with the aim of-protecting users' freedom to change the software.  The systematic-pattern of such abuse occurs in the area of products for individuals to-use, which is precisely where it is most unacceptable.  Therefore, we-have designed this version of the GPL to prohibit the practice for those-products.  If such problems arise substantially in other domains, we-stand ready to extend this provision to those domains in future versions-of the GPL, as needed to protect the freedom of users.--  Finally, every program is threatened constantly by software patents.-States should not allow patents to restrict development and use of-software on general-purpose computers, but in those that do, we wish to-avoid the special danger that patents applied to a free program could-make it effectively proprietary.  To prevent this, the GPL assures that-patents cannot be used to render the program non-free.--  The precise terms and conditions for copying, distribution and-modification follow.--                       TERMS AND CONDITIONS--  0. Definitions.--  "This License" refers to version 3 of the GNU General Public License.--  "Copyright" also means copyright-like laws that apply to other kinds of-works, such as semiconductor masks.--  "The Program" refers to any copyrightable work licensed under this-License.  Each licensee is addressed as "you".  "Licensees" and-"recipients" may be individuals or organizations.--  To "modify" a work means to copy from or adapt all or part of the work-in a fashion requiring copyright permission, other than the making of an-exact copy.  The resulting work is called a "modified version" of the-earlier work or a work "based on" the earlier work.--  A "covered work" means either the unmodified Program or a work based-on the Program.--  To "propagate" a work means to do anything with it that, without-permission, would make you directly or secondarily liable for-infringement under applicable copyright law, except executing it on a-computer or modifying a private copy.  Propagation includes copying,-distribution (with or without modification), making available to the-public, and in some countries other activities as well.--  To "convey" a work means any kind of propagation that enables other-parties to make or receive copies.  Mere interaction with a user through-a computer network, with no transfer of a copy, is not conveying.--  An interactive user interface displays "Appropriate Legal Notices"-to the extent that it includes a convenient and prominently visible-feature that (1) displays an appropriate copyright notice, and (2)-tells the user that there is no warranty for the work (except to the-extent that warranties are provided), that licensees may convey the-work under this License, and how to view a copy of this License.  If-the interface presents a list of user commands or options, such as a-menu, a prominent item in the list meets this criterion.--  1. Source Code.--  The "source code" for a work means the preferred form of the work-for making modifications to it.  "Object code" means any non-source-form of a work.--  A "Standard Interface" means an interface that either is an official-standard defined by a recognized standards body, or, in the case of-interfaces specified for a particular programming language, one that-is widely used among developers working in that language.--  The "System Libraries" of an executable work include anything, other-than the work as a whole, that (a) is included in the normal form of-packaging a Major Component, but which is not part of that Major-Component, and (b) serves only to enable use of the work with that-Major Component, or to implement a Standard Interface for which an-implementation is available to the public in source code form.  A-"Major Component", in this context, means a major essential component-(kernel, window system, and so on) of the specific operating system-(if any) on which the executable work runs, or a compiler used to-produce the work, or an object code interpreter used to run it.--  The "Corresponding Source" for a work in object code form means all-the source code needed to generate, install, and (for an executable-work) run the object code and to modify the work, including scripts to-control those activities.  However, it does not include the work's-System Libraries, or general-purpose tools or generally available free-programs which are used unmodified in performing those activities but-which are not part of the work.  For example, Corresponding Source-includes interface definition files associated with source files for-the work, and the source code for shared libraries and dynamically-linked subprograms that the work is specifically designed to require,-such as by intimate data communication or control flow between those-subprograms and other parts of the work.--  The Corresponding Source need not include anything that users-can regenerate automatically from other parts of the Corresponding-Source.--  The Corresponding Source for a work in source code form is that-same work.--  2. Basic Permissions.--  All rights granted under this License are granted for the term of-copyright on the Program, and are irrevocable provided the stated-conditions are met.  This License explicitly affirms your unlimited-permission to run the unmodified Program.  The output from running a-covered work is covered by this License only if the output, given its-content, constitutes a covered work.  This License acknowledges your-rights of fair use or other equivalent, as provided by copyright law.--  You may make, run and propagate covered works that you do not-convey, without conditions so long as your license otherwise remains-in force.  You may convey covered works to others for the sole purpose-of having them make modifications exclusively for you, or provide you-with facilities for running those works, provided that you comply with-the terms of this License in conveying all material for which you do-not control copyright.  Those thus making or running the covered works-for you must do so exclusively on your behalf, under your direction-and control, on terms that prohibit them from making any copies of-your copyrighted material outside their relationship with you.--  Conveying under any other circumstances is permitted solely under-the conditions stated below.  Sublicensing is not allowed; section 10-makes it unnecessary.--  3. Protecting Users' Legal Rights From Anti-Circumvention Law.--  No covered work shall be deemed part of an effective technological-measure under any applicable law fulfilling obligations under article-11 of the WIPO copyright treaty adopted on 20 December 1996, or-similar laws prohibiting or restricting circumvention of such-measures.--  When you convey a covered work, you waive any legal power to forbid-circumvention of technological measures to the extent such circumvention-is effected by exercising rights under this License with respect to-the covered work, and you disclaim any intention to limit operation or-modification of the work as a means of enforcing, against the work's-users, your or third parties' legal rights to forbid circumvention of-technological measures.--  4. Conveying Verbatim Copies.--  You may convey verbatim copies of the Program's source code as you-receive it, in any medium, provided that you conspicuously and-appropriately publish on each copy an appropriate copyright notice;-keep intact all notices stating that this License and any-non-permissive terms added in accord with section 7 apply to the code;-keep intact all notices of the absence of any warranty; and give all-recipients a copy of this License along with the Program.--  You may charge any price or no price for each copy that you convey,-and you may offer support or warranty protection for a fee.--  5. Conveying Modified Source Versions.--  You may convey a work based on the Program, or the modifications to-produce it from the Program, in the form of source code under the-terms of section 4, provided that you also meet all of these conditions:--    a) The work must carry prominent notices stating that you modified-    it, and giving a relevant date.--    b) The work must carry prominent notices stating that it is-    released under this License and any conditions added under section-    7.  This requirement modifies the requirement in section 4 to-    "keep intact all notices".--    c) You must license the entire work, as a whole, under this-    License to anyone who comes into possession of a copy.  This-    License will therefore apply, along with any applicable section 7-    additional terms, to the whole of the work, and all its parts,-    regardless of how they are packaged.  This License gives no-    permission to license the work in any other way, but it does not-    invalidate such permission if you have separately received it.--    d) If the work has interactive user interfaces, each must display-    Appropriate Legal Notices; however, if the Program has interactive-    interfaces that do not display Appropriate Legal Notices, your-    work need not make them do so.--  A compilation of a covered work with other separate and independent-works, which are not by their nature extensions of the covered work,-and which are not combined with it such as to form a larger program,-in or on a volume of a storage or distribution medium, is called an-"aggregate" if the compilation and its resulting copyright are not-used to limit the access or legal rights of the compilation's users-beyond what the individual works permit.  Inclusion of a covered work-in an aggregate does not cause this License to apply to the other-parts of the aggregate.--  6. Conveying Non-Source Forms.--  You may convey a covered work in object code form under the terms-of sections 4 and 5, provided that you also convey the-machine-readable Corresponding Source under the terms of this License,-in one of these ways:--    a) Convey the object code in, or embodied in, a physical product-    (including a physical distribution medium), accompanied by the-    Corresponding Source fixed on a durable physical medium-    customarily used for software interchange.--    b) Convey the object code in, or embodied in, a physical product-    (including a physical distribution medium), accompanied by a-    written offer, valid for at least three years and valid for as-    long as you offer spare parts or customer support for that product-    model, to give anyone who possesses the object code either (1) a-    copy of the Corresponding Source for all the software in the-    product that is covered by this License, on a durable physical-    medium customarily used for software interchange, for a price no-    more than your reasonable cost of physically performing this-    conveying of source, or (2) access to copy the-    Corresponding Source from a network server at no charge.--    c) Convey individual copies of the object code with a copy of the-    written offer to provide the Corresponding Source.  This-    alternative is allowed only occasionally and noncommercially, and-    only if you received the object code with such an offer, in accord-    with subsection 6b.--    d) Convey the object code by offering access from a designated-    place (gratis or for a charge), and offer equivalent access to the-    Corresponding Source in the same way through the same place at no-    further charge.  You need not require recipients to copy the-    Corresponding Source along with the object code.  If the place to-    copy the object code is a network server, the Corresponding Source-    may be on a different server (operated by you or a third party)-    that supports equivalent copying facilities, provided you maintain-    clear directions next to the object code saying where to find the-    Corresponding Source.  Regardless of what server hosts the-    Corresponding Source, you remain obligated to ensure that it is-    available for as long as needed to satisfy these requirements.--    e) Convey the object code using peer-to-peer transmission, provided-    you inform other peers where the object code and Corresponding-    Source of the work are being offered to the general public at no-    charge under subsection 6d.--  A separable portion of the object code, whose source code is excluded-from the Corresponding Source as a System Library, need not be-included in conveying the object code work.--  A "User Product" is either (1) a "consumer product", which means any-tangible personal property which is normally used for personal, family,-or household purposes, or (2) anything designed or sold for incorporation-into a dwelling.  In determining whether a product is a consumer product,-doubtful cases shall be resolved in favor of coverage.  For a particular-product received by a particular user, "normally used" refers to a-typical or common use of that class of product, regardless of the status-of the particular user or of the way in which the particular user-actually uses, or expects or is expected to use, the product.  A product-is a consumer product regardless of whether the product has substantial-commercial, industrial or non-consumer uses, unless such uses represent-the only significant mode of use of the product.--  "Installation Information" for a User Product means any methods,-procedures, authorization keys, or other information required to install-and execute modified versions of a covered work in that User Product from-a modified version of its Corresponding Source.  The information must-suffice to ensure that the continued functioning of the modified object-code is in no case prevented or interfered with solely because-modification has been made.--  If you convey an object code work under this section in, or with, or-specifically for use in, a User Product, and the conveying occurs as-part of a transaction in which the right of possession and use of the-User Product is transferred to the recipient in perpetuity or for a-fixed term (regardless of how the transaction is characterized), the-Corresponding Source conveyed under this section must be accompanied-by the Installation Information.  But this requirement does not apply-if neither you nor any third party retains the ability to install-modified object code on the User Product (for example, the work has-been installed in ROM).--  The requirement to provide Installation Information does not include a-requirement to continue to provide support service, warranty, or updates-for a work that has been modified or installed by the recipient, or for-the User Product in which it has been modified or installed.  Access to a-network may be denied when the modification itself materially and-adversely affects the operation of the network or violates the rules and-protocols for communication across the network.--  Corresponding Source conveyed, and Installation Information provided,-in accord with this section must be in a format that is publicly-documented (and with an implementation available to the public in-source code form), and must require no special password or key for-unpacking, reading or copying.--  7. Additional Terms.--  "Additional permissions" are terms that supplement the terms of this-License by making exceptions from one or more of its conditions.-Additional permissions that are applicable to the entire Program shall-be treated as though they were included in this License, to the extent-that they are valid under applicable law.  If additional permissions-apply only to part of the Program, that part may be used separately-under those permissions, but the entire Program remains governed by-this License without regard to the additional permissions.--  When you convey a copy of a covered work, you may at your option-remove any additional permissions from that copy, or from any part of-it.  (Additional permissions may be written to require their own-removal in certain cases when you modify the work.)  You may place-additional permissions on material, added by you to a covered work,-for which you have or can give appropriate copyright permission.--  Notwithstanding any other provision of this License, for material you-add to a covered work, you may (if authorized by the copyright holders of-that material) supplement the terms of this License with terms:--    a) Disclaiming warranty or limiting liability differently from the-    terms of sections 15 and 16 of this License; or--    b) Requiring preservation of specified reasonable legal notices or-    author attributions in that material or in the Appropriate Legal-    Notices displayed by works containing it; or--    c) Prohibiting misrepresentation of the origin of that material, or-    requiring that modified versions of such material be marked in-    reasonable ways as different from the original version; or--    d) Limiting the use for publicity purposes of names of licensors or-    authors of the material; or--    e) Declining to grant rights under trademark law for use of some-    trade names, trademarks, or service marks; or--    f) Requiring indemnification of licensors and authors of that-    material by anyone who conveys the material (or modified versions of-    it) with contractual assumptions of liability to the recipient, for-    any liability that these contractual assumptions directly impose on-    those licensors and authors.--  All other non-permissive additional terms are considered "further-restrictions" within the meaning of section 10.  If the Program as you-received it, or any part of it, contains a notice stating that it is-governed by this License along with a term that is a further-restriction, you may remove that term.  If a license document contains-a further restriction but permits relicensing or conveying under this-License, you may add to a covered work material governed by the terms-of that license document, provided that the further restriction does-not survive such relicensing or conveying.--  If you add terms to a covered work in accord with this section, you-must place, in the relevant source files, a statement of the-additional terms that apply to those files, or a notice indicating-where to find the applicable terms.--  Additional terms, permissive or non-permissive, may be stated in the-form of a separately written license, or stated as exceptions;-the above requirements apply either way.--  8. Termination.--  You may not propagate or modify a covered work except as expressly-provided under this License.  Any attempt otherwise to propagate or-modify it is void, and will automatically terminate your rights under-this License (including any patent licenses granted under the third-paragraph of section 11).--  However, if you cease all violation of this License, then your-license from a particular copyright holder is reinstated (a)-provisionally, unless and until the copyright holder explicitly and-finally terminates your license, and (b) permanently, if the copyright-holder fails to notify you of the violation by some reasonable means-prior to 60 days after the cessation.--  Moreover, your license from a particular copyright holder is-reinstated permanently if the copyright holder notifies you of the-violation by some reasonable means, this is the first time you have-received notice of violation of this License (for any work) from that-copyright holder, and you cure the violation prior to 30 days after-your receipt of the notice.--  Termination of your rights under this section does not terminate the-licenses of parties who have received copies or rights from you under-this License.  If your rights have been terminated and not permanently-reinstated, you do not qualify to receive new licenses for the same-material under section 10.--  9. Acceptance Not Required for Having Copies.--  You are not required to accept this License in order to receive or-run a copy of the Program.  Ancillary propagation of a covered work-occurring solely as a consequence of using peer-to-peer transmission-to receive a copy likewise does not require acceptance.  However,-nothing other than this License grants you permission to propagate or-modify any covered work.  These actions infringe copyright if you do-not accept this License.  Therefore, by modifying or propagating a-covered work, you indicate your acceptance of this License to do so.--  10. Automatic Licensing of Downstream Recipients.--  Each time you convey a covered work, the recipient automatically-receives a license from the original licensors, to run, modify and-propagate that work, subject to this License.  You are not responsible-for enforcing compliance by third parties with this License.--  An "entity transaction" is a transaction transferring control of an-organization, or substantially all assets of one, or subdividing an-organization, or merging organizations.  If propagation of a covered-work results from an entity transaction, each party to that-transaction who receives a copy of the work also receives whatever-licenses to the work the party's predecessor in interest had or could-give under the previous paragraph, plus a right to possession of the-Corresponding Source of the work from the predecessor in interest, if-the predecessor has it or can get it with reasonable efforts.--  You may not impose any further restrictions on the exercise of the-rights granted or affirmed under this License.  For example, you may-not impose a license fee, royalty, or other charge for exercise of-rights granted under this License, and you may not initiate litigation-(including a cross-claim or counterclaim in a lawsuit) alleging that-any patent claim is infringed by making, using, selling, offering for-sale, or importing the Program or any portion of it.--  11. Patents.--  A "contributor" is a copyright holder who authorizes use under this-License of the Program or a work on which the Program is based.  The-work thus licensed is called the contributor's "contributor version".--  A contributor's "essential patent claims" are all patent claims-owned or controlled by the contributor, whether already acquired or-hereafter acquired, that would be infringed by some manner, permitted-by this License, of making, using, or selling its contributor version,-but do not include claims that would be infringed only as a-consequence of further modification of the contributor version.  For-purposes of this definition, "control" includes the right to grant-patent sublicenses in a manner consistent with the requirements of-this License.--  Each contributor grants you a non-exclusive, worldwide, royalty-free-patent license under the contributor's essential patent claims, to-make, use, sell, offer for sale, import and otherwise run, modify and-propagate the contents of its contributor version.--  In the following three paragraphs, a "patent license" is any express-agreement or commitment, however denominated, not to enforce a patent-(such as an express permission to practice a patent or covenant not to-sue for patent infringement).  To "grant" such a patent license to a-party means to make such an agreement or commitment not to enforce a-patent against the party.--  If you convey a covered work, knowingly relying on a patent license,-and the Corresponding Source of the work is not available for anyone-to copy, free of charge and under the terms of this License, through a-publicly available network server or other readily accessible means,-then you must either (1) cause the Corresponding Source to be so-available, or (2) arrange to deprive yourself of the benefit of the-patent license for this particular work, or (3) arrange, in a manner-consistent with the requirements of this License, to extend the patent-license to downstream recipients.  "Knowingly relying" means you have-actual knowledge that, but for the patent license, your conveying the-covered work in a country, or your recipient's use of the covered work-in a country, would infringe one or more identifiable patents in that-country that you have reason to believe are valid.--  If, pursuant to or in connection with a single transaction or-arrangement, you convey, or propagate by procuring conveyance of, a-covered work, and grant a patent license to some of the parties-receiving the covered work authorizing them to use, propagate, modify-or convey a specific copy of the covered work, then the patent license-you grant is automatically extended to all recipients of the covered-work and works based on it.--  A patent license is "discriminatory" if it does not include within-the scope of its coverage, prohibits the exercise of, or is-conditioned on the non-exercise of one or more of the rights that are-specifically granted under this License.  You may not convey a covered-work if you are a party to an arrangement with a third party that is-in the business of distributing software, under which you make payment-to the third party based on the extent of your activity of conveying-the work, and under which the third party grants, to any of the-parties who would receive the covered work from you, a discriminatory-patent license (a) in connection with copies of the covered work-conveyed by you (or copies made from those copies), or (b) primarily-for and in connection with specific products or compilations that-contain the covered work, unless you entered into that arrangement,-or that patent license was granted, prior to 28 March 2007.--  Nothing in this License shall be construed as excluding or limiting-any implied license or other defenses to infringement that may-otherwise be available to you under applicable patent law.--  12. No Surrender of Others' Freedom.--  If conditions are imposed on you (whether by court order, agreement or-otherwise) that contradict the conditions of this License, they do not-excuse you from the conditions of this License.  If you cannot convey a-covered work so as to satisfy simultaneously your obligations under this-License and any other pertinent obligations, then as a consequence you may-not convey it at all.  For example, if you agree to terms that obligate you-to collect a royalty for further conveying from those to whom you convey-the Program, the only way you could satisfy both those terms and this-License would be to refrain entirely from conveying the Program.--  13. Use with the GNU Affero General Public License.--  Notwithstanding any other provision of this License, you have-permission to link or combine any covered work with a work licensed-under version 3 of the GNU Affero General Public License into a single-combined work, and to convey the resulting work.  The terms of this-License will continue to apply to the part which is the covered work,-but the special requirements of the GNU Affero General Public License,-section 13, concerning interaction through a network will apply to the-combination as such.--  14. Revised Versions of this License.--  The Free Software Foundation may publish revised and/or new versions of-the GNU General Public License from time to time.  Such new versions will-be similar in spirit to the present version, but may differ in detail to-address new problems or concerns.--  Each version is given a distinguishing version number.  If the-Program specifies that a certain numbered version of the GNU General-Public License "or any later version" applies to it, you have the-option of following the terms and conditions either of that numbered-version or of any later version published by the Free Software-Foundation.  If the Program does not specify a version number of the-GNU General Public License, you may choose any version ever published-by the Free Software Foundation.--  If the Program specifies that a proxy can decide which future-versions of the GNU General Public License can be used, that proxy's-public statement of acceptance of a version permanently authorizes you-to choose that version for the Program.--  Later license versions may give you additional or different-permissions.  However, no additional obligations are imposed on any-author or copyright holder as a result of your choosing to follow a-later version.--  15. Disclaimer of Warranty.--  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY-APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR-PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM-IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.--  16. Limitation of Liability.--  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF-SUCH DAMAGES.--  17. Interpretation of Sections 15 and 16.--  If the disclaimer of warranty and limitation of liability provided-above cannot be given local legal effect according to their terms,-reviewing courts shall apply local law that most closely approximates-an absolute waiver of all civil liability in connection with the-Program, unless a warranty or assumption of liability accompanies a-copy of the Program in return for a fee.--                     END OF TERMS AND CONDITIONS--            How to Apply These Terms to Your New Programs--  If you develop a new program, and you want it to be of the greatest-possible use to the public, the best way to achieve this is to make it-free software which everyone can redistribute and change under these terms.--  To do so, attach the following notices to the program.  It is safest-to attach them to the start of each source file to most effectively-state the exclusion of warranty; and each file should have at least-the "copyright" line and a pointer to where the full notice is found.--    <one line to give the program's name and a brief idea of what it does.>-    Copyright (C) <year>  <name of author>--    This program is free software: you can redistribute it and/or modify-    it under the terms of the GNU General Public License as published by-    the Free Software Foundation, either version 3 of the License, or-    (at your option) any later version.--    This program is distributed in the hope that it will be useful,-    but WITHOUT ANY WARRANTY; without even the implied warranty of-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the-    GNU General Public License for more details.--    You should have received a copy of the GNU General Public License-    along with this program.  If not, see <http://www.gnu.org/licenses/>.--Also add information on how to contact you by electronic and paper mail.--  If the program does terminal interaction, make it output a short-notice like this when it starts in an interactive mode:--    <program>  Copyright (C) <year>  <name of author>-    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.-    This is free software, and you are welcome to redistribute it-    under certain conditions; type `show c' for details.--The hypothetical commands `show w' and `show c' should show the appropriate-parts of the General Public License.  Of course, your program's commands-might be different; for a GUI interface, you would use an "about box".--  You should also get your employer (if you work as a programmer) or school,-if any, to sign a "copyright disclaimer" for the program, if necessary.-For more information on this, and how to apply and follow the GNU GPL, see-<http://www.gnu.org/licenses/>.--  The GNU General Public License does not permit incorporating your program-into proprietary programs.  If your program is a subroutine library, you-may consider it more useful to permit linking proprietary applications with-the library.  If this is what you want to do, use the GNU Lesser General-Public License instead of this License.  But first, please read-<http://www.gnu.org/philosophy/why-not-lgpl.html>.
Git/Branch.hs view
@@ -5,6 +5,8 @@  - Licensed under the GNU GPL version 3 or higher.  -} +{-# LANGUAGE BangPatterns #-}+ module Git.Branch where  import Common@@ -12,13 +14,32 @@ import Git.Sha import Git.Command -{- The currently checked out branch. -}+{- The currently checked out branch.+ -+ - In a just initialized git repo before the first commit,+ - symbolic-ref will show the master branch, even though that+ - branch is not created yet. So, this also looks at show-ref HEAD+ - to double-check.+ -} current :: Repo -> IO (Maybe Git.Ref)-current r = parse <$> pipeRead [Param "symbolic-ref", Param "HEAD"] r+current r = do+	v <- currentUnsafe r+	case v of+		Nothing -> return Nothing+		Just branch -> +			ifM (null <$> pipeRead [Param "show-ref", Param $ show branch] r)+				( return Nothing+				, return v+				)++{- The current branch, which may not really exist yet. -}+currentUnsafe :: Repo -> IO (Maybe Git.Ref)+currentUnsafe r = parse . firstLine+	<$> pipeRead [Param "symbolic-ref", Param "HEAD"] r 	where-		parse v-			| null v = Nothing-			| otherwise = Just $ Git.Ref $ firstLine v+		parse l+			| null l = Nothing+			| otherwise = Just $ Git.Ref l  {- Checks if the second branch has any commits not present on the first  - branch. -}@@ -73,12 +94,10 @@ commit message branch parentrefs repo = do 	tree <- getSha "write-tree" $ 		pipeRead [Param "write-tree"] repo-	sha <- getSha "commit-tree" $-		ignorehandle $ pipeWriteRead-			(map Param $ ["commit-tree", show tree] ++ ps)-			message repo+	sha <- getSha "commit-tree" $ pipeWriteRead+		(map Param $ ["commit-tree", show tree] ++ ps)+		message repo 	run "update-ref" [Param $ show branch, Param $ show sha] repo 	return sha 	where-		ignorehandle a = snd <$> a 		ps = concatMap (\r -> ["-p", show r]) parentrefs
Git/CatFile.hs view
@@ -28,7 +28,7 @@ type CatFileHandle = CoProcess.CoProcessHandle  catFileStart :: Repo -> IO CatFileHandle-catFileStart = CoProcess.start "git" . toCommand . gitCommandLine+catFileStart = gitCoProcessStart 	[ Param "cat-file" 	, Param "--batch" 	]
Git/CheckAttr.hs view
@@ -22,7 +22,7 @@ checkAttrStart :: [Attr] -> Repo -> IO CheckAttrHandle checkAttrStart attrs repo = do 	cwd <- getCurrentDirectory-	h <- CoProcess.start "git" $ toCommand $ gitCommandLine params repo+	h <- gitCoProcessStart params repo 	return (h, attrs, cwd) 	where 		params =
Git/Command.hs view
@@ -7,14 +7,13 @@  module Git.Command where -import qualified Data.Text.Lazy as L-import qualified Data.Text.Lazy.IO as L-import Control.Concurrent-import Control.Exception (finally)+import System.Posix.Process (getAnyProcessStatus)+import System.Process  import Common import Git import Git.Types+import qualified Utility.CoProcess as CoProcess  {- Constructs a git command line operating on the specified repo. -} gitCommandLine :: [CommandParam] -> Repo -> [CommandParam]@@ -29,7 +28,9 @@ {- Runs git in the specified repo. -} runBool :: String -> [CommandParam] -> Repo -> IO Bool runBool subcommand params repo = assertLocal repo $-	boolSystem "git" $ gitCommandLine (Param subcommand : params) repo+	boolSystemEnv "git"+		(gitCommandLine (Param subcommand : params) repo)+		(gitEnv repo)  {- Runs git in the specified repo, throwing an error if it fails. -} run :: String -> [CommandParam] -> Repo -> IO ()@@ -43,30 +44,28 @@  - result unless reap is called.  -} pipeRead :: [CommandParam] -> Repo -> IO String-pipeRead params repo = assertLocal repo $ do-	(_, h) <- hPipeFrom "git" $ toCommand $ gitCommandLine params repo-	fileEncoding h-	hGetContents h+pipeRead params repo = assertLocal repo $+	withHandle StdoutHandle createBackgroundProcess p $ \h -> do+		fileEncoding h+		hGetContents h+	where+		p  = (proc "git" $ toCommand $ gitCommandLine params repo)+			{ env = gitEnv repo } -{- Runs a git subcommand, feeding it input.- - You should call either getProcessStatus or forceSuccess on the PipeHandle. -}-pipeWrite :: [CommandParam] -> L.Text -> Repo -> IO PipeHandle-pipeWrite params s repo = assertLocal repo $ do-	(p, h) <- hPipeTo "git" (toCommand $ gitCommandLine params repo)-	L.hPutStr h s-	hClose h-	return p+{- Runs a git subcommand, feeding it input, and returning its output,+ - which is expected to be fairly small, since it's all read into memory+ - strictly. -}+pipeWriteRead :: [CommandParam] -> String -> Repo -> IO String+pipeWriteRead params s repo = assertLocal repo $+	writeReadProcessEnv "git" (toCommand $ gitCommandLine params repo) +		(gitEnv repo) s -{- Runs a git subcommand, feeding it input, and returning its output.- - You should call either getProcessStatus or forceSuccess on the PipeHandle. -}-pipeWriteRead :: [CommandParam] -> String -> Repo -> IO (PipeHandle, String)-pipeWriteRead params s repo = assertLocal repo $ do-	(p, from, to) <- hPipeBoth "git" (toCommand $ gitCommandLine params repo)-	fileEncoding to-	fileEncoding from-	_ <- forkIO $ finally (hPutStr to s) (hClose to)-	c <- hGetContents from-	return (p, c)+{- Runs a git subcommand, feeding it input on a handle with an action. -}+pipeWrite :: [CommandParam] -> Repo -> (Handle -> IO ()) -> IO ()+pipeWrite params repo = withHandle StdinHandle createProcessSuccess p+	where+		p = (proc "git" $ toCommand $ gitCommandLine params repo)+			{ env = gitEnv repo }  {- Reads null terminated output of a git command (as enabled by the -z   - parameter), and splits it. -}@@ -80,5 +79,9 @@ reap :: IO () reap = do 	-- throws an exception when there are no child processes-	catchDefaultIO (getAnyProcessStatus False True) Nothing+	catchDefaultIO Nothing (getAnyProcessStatus False True) 		>>= maybe noop (const reap)++{- Runs a git command as a coprocess. -}+gitCoProcessStart :: [CommandParam] -> Repo -> IO CoProcess.CoProcessHandle+gitCoProcessStart params repo = CoProcess.start "git" (toCommand $ gitCommandLine params repo) (gitEnv repo)
Git/Config.hs view
@@ -9,6 +9,7 @@  import qualified Data.Map as M import Data.Char+import System.Process (cwd, env)  import Common import Git@@ -39,7 +40,7 @@ reRead = read'  {- Cannot use pipeRead because it relies on the config having been already- - read. Instead, chdir to the repo.+ - read. Instead, chdir to the repo and run git config.  -} read' :: Repo -> IO Repo read' repo = go repo@@ -47,9 +48,30 @@ 		go Repo { location = Local { gitdir = d } } = git_config d 		go Repo { location = LocalUnknown d } = git_config d 		go _ = assertLocal repo $ error "internal"-		git_config d = bracketCd d $-			pOpen ReadFromPipe "git" ["config", "--null", "--list"] $+		git_config d = withHandle StdoutHandle createProcessSuccess p $+			hRead repo+			where+				params = ["config", "--null", "--list"]+				p = (proc "git" params)+					{ cwd = Just d+					, env = gitEnv repo+					}++{- Gets the global git config, returning a dummy Repo containing it. -}+global :: IO (Maybe Repo)+global = do+	home <- myHomeDir+	ifM (doesFileExist $ home </> ".gitconfig")+		( do+			repo <- Git.Construct.fromUnknown+			repo' <- withHandle StdoutHandle createProcessSuccess p $ 				hRead repo+			return $ Just repo'+		, return Nothing+		)+	where+		params = ["config", "--null", "--list", "--global"]+		p = (proc "git" params)  {- Reads git config from a handle and populates a repo with it. -} hRead :: Repo -> Handle -> IO Repo
Git/Construct.hs view
@@ -28,13 +28,19 @@ import Git import qualified Git.Url as Url -{- Finds the git repository used for the Cwd, which may be in a parent+{- Finds the git repository used for the cwd, which may be in a parent  - directory. -} fromCwd :: IO Repo-fromCwd = getCurrentDirectory >>= seekUp isRepoTop >>= maybe norepo makerepo+fromCwd = getCurrentDirectory >>= seekUp checkForRepo 	where-		makerepo = newFrom . LocalUnknown 		norepo = error "Not in a git repository."+		seekUp check dir = do+			r <- check dir+			case r of+				Nothing -> case parentDir dir of+					"" -> norepo+					d -> seekUp check d+				Just loc -> newFrom loc  {- Local Repo constructor, accepts a relative or absolute path. -} fromPath :: FilePath -> IO Repo@@ -201,22 +207,33 @@ 			| c == '/' = (n, cs) 			| otherwise = findname (n++[c]) cs -seekUp :: (FilePath -> IO Bool) -> FilePath -> IO (Maybe FilePath)-seekUp want dir =-	ifM (want dir)-		( return $ Just dir-		, case parentDir dir of-			"" -> return Nothing-			d -> seekUp want d-		)--isRepoTop :: FilePath -> IO Bool-isRepoTop dir = ifM isRepo ( return True , isBareRepo )+checkForRepo :: FilePath -> IO (Maybe RepoLocation)+checkForRepo dir = +	check isRepo $+		check gitDirFile $+			check isBareRepo $+				return Nothing 	where-		isRepo = gitSignature (".git" </> "config")-		isBareRepo = ifM (doesDirectoryExist $ dir </> "objects")-			( gitSignature "config" , return False )-		gitSignature file = doesFileExist (dir </> file)+		check test cont = maybe cont (return . Just) =<< test+		checkdir c = ifM c+			( return $ Just $ LocalUnknown dir+			, return Nothing+			)+		isRepo = checkdir $ gitSignature $ ".git" </> "config"+		isBareRepo = checkdir $ gitSignature "config"+			<&&> doesDirectoryExist (dir </> "objects")+		gitDirFile = do+			c <- firstLine <$>+				catchDefaultIO "" (readFile $ dir </> ".git")+			return $ if gitdirprefix `isPrefixOf` c+				then Just $ Local +					{ gitdir = drop (length gitdirprefix) c+					, worktree = Just dir+					}+				else Nothing+			where+				gitdirprefix = "gitdir: "+		gitSignature file = doesFileExist $ dir </> file  newFrom :: RepoLocation -> IO Repo newFrom l = return Repo@@ -225,6 +242,7 @@ 	, fullconfig = M.empty 	, remotes = [] 	, remoteName = Nothing+	, gitEnv = Nothing 	}  
Git/HashObject.hs view
@@ -17,7 +17,7 @@ type HashObjectHandle = CoProcess.CoProcessHandle  hashObjectStart :: Repo -> IO HashObjectHandle-hashObjectStart = CoProcess.start "git" . toCommand . gitCommandLine+hashObjectStart = gitCoProcessStart 	[ Param "hash-object" 	, Param "-w" 	, Param "--stdin-paths"@@ -38,11 +38,9 @@ {- Injects some content into git, returning its Sha. -} hashObject :: ObjectType -> String -> Repo -> IO Sha hashObject objtype content repo = getSha subcmd $ do-	(h, s) <- pipeWriteRead (map Param params) content repo-	length s `seq` do-		forceSuccess h-		reap -- XXX unsure why this is needed-		return s+	s <- pipeWriteRead (map Param params) content repo+	reap -- XXX unsure why this is needed, of if it is anymore+	return s 	where 		subcmd = "hash-object" 		params = [subcmd, "-t", show objtype, "-w", "--stdin"]
Git/Index.hs view
@@ -12,7 +12,10 @@ {- Forces git to use the specified index file.  -  - Returns an action that will reset back to the default- - index file. -}+ - index file.+ -+ - Warning: Not thread safe.+ -} override :: FilePath -> IO (IO ()) override index = do 	res <- getEnv var
Git/Queue.hs view
@@ -19,7 +19,7 @@  import qualified Data.Map as M import System.IO-import System.Cmd.Utils+import System.Process import Data.String.Utils  import Utility.SafeCommand@@ -149,10 +149,12 @@ 	-- list is stored in reverse order 	Git.UpdateIndex.streamUpdateIndex repo $ reverse streamers runAction repo action@(CommandAction {}) =-	pOpen WriteToPipe "xargs" ("-0":"git":params) feedxargs+	withHandle StdinHandle createProcessSuccess p $ \h -> do+		fileEncoding h+		hPutStr h $ join "\0" $ getFiles action+		hClose h 	where-		params = toCommand $ gitCommandLine+		p = (proc "xargs" params) { env = gitEnv repo }+		params = "-0":"git":baseparams+		baseparams = toCommand $ gitCommandLine 			(Param (getSubcommand action):getParams action) repo-		feedxargs h = do-			fileEncoding h-			hPutStr h $ join "\0" $ getFiles action
Git/Ref.hs view
@@ -26,7 +26,6 @@ 			| prefix `isPrefixOf` s = drop (length prefix) s 			| otherwise = s - {- Given a directory such as "refs/remotes/origin", and a ref such as  - refs/heads/master, yields a version of that ref under the directory,  - such as refs/remotes/origin/master. -}@@ -50,9 +49,8 @@  {- List of (refs, branches) matching a given ref spec. -} matching :: Ref -> Repo -> IO [(Ref, Branch)]-matching ref repo = do-	r <- pipeRead [Param "show-ref", Param $ show ref] repo-	return $ map gen (lines r)+matching ref repo = map gen . lines <$> +	pipeRead [Param "show-ref", Param $ show ref] repo 	where 		gen l = let (r, b) = separate (== ' ') l in 			(Ref r, Ref b)
Git/Types.hs view
@@ -27,15 +27,17 @@ 	| Unknown 	deriving (Show, Eq) -data Repo = Repo {-	location :: RepoLocation,-	config :: M.Map String String,+data Repo = Repo+	{ location :: RepoLocation+	, config :: M.Map String String 	-- a given git config key can actually have multiple values-	fullconfig :: M.Map String [String],-	remotes :: [Repo],+	, fullconfig :: M.Map String [String]+	, remotes :: [Repo] 	-- remoteName holds the name used for this repo in remotes-	remoteName :: Maybe String -} deriving (Show, Eq)+	, remoteName :: Maybe String+	-- alternate environment to use when running git commands+	, gitEnv :: Maybe [(String, String)]+	} deriving (Show, Eq)  {- A git ref. Can be a sha1, or a branch or tag name. -} newtype Ref = Ref String
Git/UpdateIndex.hs view
@@ -17,8 +17,6 @@ 	stageSymlink ) where -import System.Cmd.Utils- import Common import Git import Git.Types@@ -36,12 +34,10 @@  {- Streams content into update-index from a list of Streamers. -} streamUpdateIndex :: Repo -> [Streamer] -> IO ()-streamUpdateIndex repo as = do-	(p, h) <- hPipeTo "git" (toCommand $ gitCommandLine params repo)+streamUpdateIndex repo as = pipeWrite params repo $ \h -> do 	fileEncoding h 	forM_ as (stream h) 	hClose h-	forceSuccess p 	where 		params = map Param ["update-index", "-z", "--index-info"] 		stream h a = a (streamer h)
GitAnnex.hs view
@@ -30,6 +30,7 @@ import qualified Command.Get import qualified Command.FromKey import qualified Command.DropKey+import qualified Command.TransferKey import qualified Command.ReKey import qualified Command.Reinject import qualified Command.Fix@@ -62,7 +63,11 @@ import qualified Command.Version #ifdef WITH_ASSISTANT import qualified Command.Watch+import qualified Command.Assistant+#ifdef WITH_WEBAPP+import qualified Command.WebApp #endif+#endif  cmds :: [Command] cmds = concat@@ -89,6 +94,7 @@ 	, Command.Dead.def 	, Command.FromKey.def 	, Command.DropKey.def+	, Command.TransferKey.def 	, Command.ReKey.def 	, Command.Fix.def 	, Command.Fsck.def@@ -106,6 +112,10 @@ 	, Command.Version.def #ifdef WITH_ASSISTANT 	, Command.Watch.def+	, Command.Assistant.def+#ifdef WITH_WEBAPP+	, Command.WebApp.def+#endif #endif 	] 
GitAnnexShell.hs view
@@ -23,6 +23,7 @@ import qualified Command.DropKey import qualified Command.RecvKey import qualified Command.SendKey+import qualified Command.TransferInfo import qualified Command.Commit  cmds_readonly :: [Command]@@ -30,6 +31,7 @@ 	[ Command.ConfigList.def 	, Command.InAnnex.def 	, Command.SendKey.def+	, Command.TransferInfo.def 	]  cmds_notreadonly :: [Command]@@ -132,5 +134,5 @@  checkEnv :: String -> IO () checkEnv var =-	whenM (not . null <$> catchDefaultIO (getEnv var) "") $+	whenM (not . null <$> catchDefaultIO "" (getEnv var)) $ 		error $ "Action blocked by " ++ var
INSTALL view
@@ -23,7 +23,8 @@  ## Installation by hand -To build and use git-annex, you will need:+This is not recommended, it's easier to let cabal pull in the many haskell+libraries. To build and use git-annex by hand, you will need:  * Haskell stuff   * [The Haskell Platform](http://haskell.org/platform/) (GHC 7.4 or newer)@@ -42,10 +43,29 @@   * [bloomfilter](http://hackage.haskell.org/package/bloomfilter)   * [edit-distance](http://hackage.haskell.org/package/edit-distance)   * [hS3](http://hackage.haskell.org/package/hS3) (optional)+* Optional haskell stuff, used by the [[assistant]] and its webapp (edit Makefile to disable)   * [stm](http://hackage.haskell.org/package/stm)-    (optional; version 2.3 or newer)+    (version 2.3 or newer)   * [hinotify](http://hackage.haskell.org/package/hinotify)-    (optional; Linux only)+    (Linux only)+  * [dbus](http://hackage.haskell.org/package/dbus)+  * [yesod](http://hackage.haskell.org/package/yesod)+  * [yesod-static](http://hackage.haskell.org/package/yesod-static)+  * [yesod-default](http://hackage.haskell.org/package/yesod-default)+  * [data-default](http://hackage.haskell.org/package/data-default)+  * [case-insensitive](http://hackage.haskell.org/package/case-insensitive)+  * [http-types](http://hackage.haskell.org/package/http-types)+  * [transformers](http://hackage.haskell.org/package/transformers)+  * [wai](http://hackage.haskell.org/package/wai)+  * [wai-logger](http://hackage.haskell.org/package/wai-logger)+  * [warp](http://hackage.haskell.org/package/warp)+  * [blaze-builder](http://hackage.haskell.org/package/blaze-builder)+  * [blaze-html](http://hackage.haskell.org/package/blaze-html)+  * [crypto-api](http://hackage.haskell.org/package/crypto-api)+  * [hamlet](http://hackage.haskell.org/package/hamlet)+  * [clientsession](http://hackage.haskell.org/package/clientsession)+  * [network-multicast](http://hackage.haskell.org/package/network-multicast)+  * [network-info](http://hackage.haskell.org/package/network-info) * Shell commands   * [git](http://git-scm.com/)   * [uuid](http://www.ossp.org/pkg/lib/uuid/)@@ -58,6 +78,8 @@   * [gpg](http://gnupg.org/) (optional; needed for encryption)   * [lsof](ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/)     (optional; recommended for watch mode)+  * multicast DNS support, provided on linux by [nss-mdns](http://www.0pointer.de/lennart/projects/nss-mdns/)+    (optional; recommended for the assistant to support pairing well)   * [ikiwiki](http://ikiwiki.info) (optional; used to build the docs)  Then just [[download]] git-annex and run: `make; make install`
Init.hs view
@@ -7,18 +7,34 @@  module Init ( 	ensureInitialized,+	isInitialized, 	initialize, 	uninitialize ) where  import Common.Annex import Utility.TempFile+import Utility.Network import qualified Git import qualified Annex.Branch import Logs.UUID import Annex.Version import Annex.UUID +import System.Posix.User++genDescription :: Maybe String -> Annex String+genDescription (Just d) = return d+genDescription Nothing = do+	hostname <- maybe "" id <$> liftIO getHostname+	let at = if null hostname then "" else "@"+	username <- clicketyclickety+	reldir <- liftIO . relHome =<< fromRepo Git.repoPath+	return $ concat [username, at, hostname, ":", reldir]+	where+		clicketyclickety = liftIO $ userName <$>+			(getUserEntryForID =<< getEffectiveUserID)+ initialize :: Maybe String -> Annex () initialize mdescription = do 	prepUUID@@ -26,7 +42,7 @@ 	setVersion 	gitPreCommitHookWrite 	u <- getUUID-	maybe (recordUUID u) (describeUUID u) mdescription+	describeUUID u =<< genDescription mdescription  uninitialize :: Annex () uninitialize = do@@ -44,6 +60,10 @@ 				( initialize Nothing 				, error "First run: git-annex init" 				)++{- Checks if a repository is initialized. Does not check version for ugrade. -}+isInitialized :: Annex Bool+isInitialized = maybe Annex.Branch.hasSibling (const $ return True) =<< getVersion  {- set up a git pre-commit hook, if one is not already present -} gitPreCommitHookWrite :: Annex ()
Limit.hs view
@@ -16,6 +16,7 @@ import qualified Remote import qualified Backend import Annex.Content+import Logs.Trust  type Limit = Utility.Matcher.Token (FilePath -> Annex Bool) @@ -83,16 +84,21 @@ {- Adds a limit to skip files not believed to have the specified number  - of copies. -} addCopies :: String -> Annex ()-addCopies num =-	case readish num :: Maybe Int of-		Nothing -> error "bad number for --copies"-		Just n -> addLimit $ check n+addCopies trust_num = addLimit . check $ readnum num 	where+		(num, mayCheckTrust) = case split ":" trust_num of+			[trust, num'] -> (num', checkTrust (readtrust trust))+			[num'] -> (num', const (return True))+			_ -> bad+		readnum = maybe bad id . readish+		readtrust = maybe bad id . readTrust 		check n = Backend.lookupFile >=> handle n 		handle _ Nothing = return False 		handle n (Just (key, _)) = do-			us <- Remote.keyLocations key+			us <- filterM mayCheckTrust =<< Remote.keyLocations key 			return $ length us >= n+		checkTrust t u = (== t) <$> lookupTrust u+		bad = error "bad number or trust:number for --copies"  {- Adds a limit to skip files not using a specified key-value backend. -} addInBackend :: String -> Annex ()
Locations.hs view
@@ -23,12 +23,14 @@ 	gitAnnexJournalLock, 	gitAnnexIndex, 	gitAnnexIndexLock,-	gitAnnexIndexDirty, 	gitAnnexPidFile, 	gitAnnexDaemonStatusFile, 	gitAnnexLogFile,+	gitAnnexHtmlShim,+	gitAnnexUrlFile, 	gitAnnexSshDir, 	gitAnnexRemotesDir,+	gitAnnexAssistantDefaultDir, 	isLinkToAnnex, 	annexHashes, 	hashDirMixed,@@ -129,7 +131,7 @@ gitAnnexUnusedLog prefix r = gitAnnexDir r </> (prefix ++ "unused")  {- .git/annex/transfer/ is used is used to record keys currently- - being transferred. -}+ - being transferred, and other transfer bookkeeping info. -} gitAnnexTransferDir :: Git.Repo -> FilePath gitAnnexTransferDir r = addTrailingPathSeparator $ gitAnnexDir r </> "transfer" @@ -150,10 +152,6 @@ gitAnnexIndexLock :: Git.Repo -> FilePath gitAnnexIndexLock r = gitAnnexDir r </> "index.lck" -{- Flag file for .git/annex/index. -}-gitAnnexIndexDirty :: Git.Repo -> FilePath-gitAnnexIndexDirty r = gitAnnexDir r </> "index.dirty"- {- Pid file for daemon mode. -} gitAnnexPidFile :: Git.Repo -> FilePath gitAnnexPidFile r = gitAnnexDir r </> "daemon.pid"@@ -166,6 +164,14 @@ gitAnnexLogFile :: Git.Repo -> FilePath gitAnnexLogFile r = gitAnnexDir r </> "daemon.log" +{- Html shim file used to launch the webapp. -}+gitAnnexHtmlShim :: Git.Repo -> FilePath+gitAnnexHtmlShim r = gitAnnexDir r </> "webapp.html"++{- File containing the url to the webapp. -}+gitAnnexUrlFile :: Git.Repo -> FilePath+gitAnnexUrlFile r = gitAnnexDir r </> "url"+ {- .git/annex/ssh/ is used for ssh connection caching -} gitAnnexSshDir :: Git.Repo -> FilePath gitAnnexSshDir r = addTrailingPathSeparator $ gitAnnexDir r </> "ssh"@@ -174,6 +180,11 @@ gitAnnexRemotesDir :: Git.Repo -> FilePath gitAnnexRemotesDir r = addTrailingPathSeparator $ gitAnnexDir r </> "remotes" +{- This is the base directory name used by the assistant when making+ - repositories, by default. -}+gitAnnexAssistantDefaultDir :: FilePath+gitAnnexAssistantDefaultDir = "annex"+ {- Checks a symlink target to see if it appears to point to annexed content. -} isLinkToAnnex :: FilePath -> Bool isLinkToAnnex s = ('/':d) `isInfixOf` s || d `isPrefixOf` s@@ -194,7 +205,7 @@  -} keyFile :: Key -> FilePath keyFile key = replace "/" "%" $ replace ":" "&c" $-	replace "%" "&s" $ replace "&" "&a"  $ show key+	replace "%" "&s" $ replace "&" "&a"  $ key2file key  {- A location to store a key on the filesystem. A directory hash is used,  - to protect against filesystems that dislike having many items in a@@ -215,7 +226,7 @@ {- Reverses keyFile, converting a filename fragment (ie, the basename of  - the symlink target) into a key. -} fileKey :: FilePath -> Maybe Key-fileKey file = readKey $+fileKey file = file2key $ 	replace "&a" "&" $ replace "&s" "%" $ 		replace "&c" ":" $ replace "%" "/" file @@ -237,12 +248,12 @@ hashDirMixed k = addTrailingPathSeparator $ take 2 dir </> drop 2 dir 	where 		dir = take 4 $ display_32bits_as_dir =<< [a,b,c,d]-		ABCD (a,b,c,d) = md5 $ encodeFilePath $ show k+		ABCD (a,b,c,d) = md5 $ md5FilePath $ key2file k  hashDirLower :: Hasher hashDirLower k = addTrailingPathSeparator $ take 3 dir </> drop 3 dir 	where-		dir = take 6 $ md5s $ encodeFilePath $ show k+		dir = take 6 $ md5s $ md5FilePath $ key2file k  {- modified version of display_32bits_as_hex from Data.Hash.MD5  -   Copyright (C) 2001 Ian Lynagh 
+ Locations/UserConfig.hs view
@@ -0,0 +1,31 @@+{- git-annex user config files+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++module Locations.UserConfig where++import Common+import Utility.FreeDesktop++{- ~/.config/git-annex/file -}+userConfigFile :: FilePath -> IO FilePath+userConfigFile file = do+	dir <- userConfigDir+	return $ dir </> "git-annex" </> file++autoStartFile :: IO FilePath+autoStartFile = userConfigFile "autostart"++{- The path to git-annex is written here; which is useful when cabal+ - has installed it to some aweful non-PATH location. -}+programFile :: IO FilePath+programFile = userConfigFile "program"++{- Returns a command to run for git-annex. -}+readProgramFile :: IO FilePath+readProgramFile = do+	programfile <- programFile+	catchDefaultIO "git-annex" $ readFile programfile
Logs/Transfer.hs view
@@ -12,7 +12,8 @@ import Annex.Exception import qualified Git import Types.Remote-import qualified Fields+import Types.Key+import Utility.Percentage  import System.Posix.Types import Data.Time.Clock@@ -28,7 +29,7 @@ 	, transferUUID :: UUID 	, transferKey :: Key 	}-	deriving (Show, Eq, Ord)+	deriving (Eq, Ord, Read, Show)  {- Information about a Transfer, stored in the transfer information file.  -@@ -43,50 +44,68 @@ 	, transferRemote :: Maybe Remote 	, bytesComplete :: Maybe Integer 	, associatedFile :: Maybe FilePath+	, transferPaused :: Bool 	} 	deriving (Show, Eq, Ord) +stubTransferInfo :: TransferInfo+stubTransferInfo = TransferInfo Nothing Nothing Nothing Nothing Nothing Nothing False+ data Direction = Upload | Download-	deriving (Eq, Ord)+	deriving (Eq, Ord, Read, Show) -instance Show Direction where-	show Upload = "upload"-	show Download = "download"+showLcDirection :: Direction -> String+showLcDirection Upload = "upload"+showLcDirection Download = "download" -readDirection :: String -> Maybe Direction-readDirection "upload" = Just Upload-readDirection "download" = Just Download-readDirection _ = Nothing+readLcDirection :: String -> Maybe Direction+readLcDirection "upload" = Just Upload+readLcDirection "download" = Just Download+readLcDirection _ = Nothing -upload :: UUID -> Key -> AssociatedFile -> Annex a -> Annex a-upload u key file a = transfer (Transfer Upload u key) file a+{- Transfers that will accomplish the same task. -}+equivilantTransfer :: Transfer -> Transfer -> Bool+equivilantTransfer t1 t2+	| transferDirection t1 == Download && transferDirection t2 == Download &&+	  transferKey t1 == transferKey t2 = True+	| otherwise = t1 == t2 -download :: UUID -> Key -> AssociatedFile -> Annex a -> Annex a-download u key file a = transfer (Transfer Download u key) file a+percentComplete :: Transfer -> TransferInfo -> Maybe Percentage+percentComplete (Transfer { transferKey = key }) info =+	percentage <$> keySize key <*> Just (fromMaybe 0 $ bytesComplete info) -fieldTransfer :: Direction -> Key -> Annex a -> Annex a-fieldTransfer direction key a = do-	afile <- Fields.getField Fields.associatedFile-	maybe a (\u -> transfer (Transfer direction (toUUID u) key) afile a)-		=<< Fields.getField Fields.remoteUUID+type RetryDecider = TransferInfo -> TransferInfo -> Bool +noRetry :: RetryDecider+noRetry _ _ = False++{- Retries a transfer when it fails, as long as the failed transfer managed+ - to send some data. -}+forwardRetry :: RetryDecider+forwardRetry old new = bytesComplete old < bytesComplete new++upload :: UUID -> Key -> AssociatedFile -> RetryDecider -> (MeterUpdate -> Annex Bool) -> Annex Bool+upload u key = runTransfer (Transfer Upload u key)++download :: UUID -> Key -> AssociatedFile -> RetryDecider -> Annex Bool -> Annex Bool+download u key file shouldretry a = runTransfer (Transfer Download u key) file shouldretry (const a)+ {- Runs a transfer action. Creates and locks the lock file while the  - action is running, and stores info in the transfer information  - file. Will throw an error if the transfer is already in progress.+ -+ - If the transfer action returns False, the transfer info is + - left in the failedTransferDir.  -}-transfer :: Transfer -> Maybe FilePath -> Annex a -> Annex a-transfer t file a = do-	tfile <- fromRepo $ transferFile t-	createAnnexDirectory $ takeDirectory tfile+runTransfer :: Transfer -> Maybe FilePath -> RetryDecider -> (MeterUpdate -> Annex Bool) -> Annex Bool+runTransfer t file shouldretry a = do+	info <- liftIO $ startTransferInfo file+	(meter, tfile, metervar) <- mkProgressUpdater t info 	mode <- annexFileMode-	info <- liftIO $ TransferInfo-		<$> (Just . utcTimeToPOSIXSeconds <$> getCurrentTime)-		<*> pure Nothing -- pid not stored in file, so omitted for speed-		<*> pure Nothing -- tid ditto-		<*> pure Nothing -- not 0; transfer may be resuming-		<*> pure Nothing-		<*> pure file-	bracketIO (prep tfile mode info) (cleanup tfile) a+	ok <- retry info metervar $+		bracketIO (prep tfile mode info) (cleanup tfile) (a meter)+	unless ok $ failed info+	return ok 	where 		prep tfile mode info = do 			fd <- openFd (transferLockFile tfile) ReadWrite (Just mode)@@ -95,13 +114,69 @@ 				setLock fd (WriteLock, AbsoluteSeek, 0, 0) 			when (locked == Nothing) $ 				error $ "transfer already in progress"-			writeFile tfile $ writeTransferInfo info+			writeTransferInfoFile info tfile 			return fd 		cleanup tfile fd = do 			void $ tryIO $ removeFile tfile 			void $ tryIO $ removeFile $ transferLockFile tfile 			closeFd fd+		failed info = do+			failedtfile <- fromRepo $ failedTransferFile t+			createAnnexDirectory $ takeDirectory failedtfile+			liftIO $ writeTransferInfoFile info failedtfile+		retry oldinfo metervar run = do+			v <- tryAnnex run+			case v of+				Right b -> return b+				Left _ -> do+					b <- getbytescomplete metervar+					let newinfo = oldinfo { bytesComplete = Just b }+					if shouldretry oldinfo newinfo+						then retry newinfo metervar run+						else return False+		getbytescomplete metervar+			| transferDirection t == Upload =+				liftIO $ readMVar metervar+			| otherwise = do+				f <- fromRepo $ gitAnnexTmpLocation (transferKey t)+				liftIO $ catchDefaultIO 0 $+					fromIntegral . fileSize+						<$> getFileStatus f +{- Generates a callback that can be called as transfer progresses to update+ - the transfer info file. Also returns the file it'll be updating, and a+ - MVar that can be used to read the number of bytesComplete. -}+mkProgressUpdater :: Transfer -> TransferInfo -> Annex (MeterUpdate, FilePath, MVar Integer)+mkProgressUpdater t info = do+	tfile <- fromRepo $ transferFile t+	createAnnexDirectory $ takeDirectory tfile+	mvar <- liftIO $ newMVar 0+	return (liftIO . updater tfile mvar, tfile, mvar)+	where+		updater tfile mvar bytes = modifyMVar_ mvar $ \oldbytes -> do+			if (bytes - oldbytes >= mindelta)+				then do+					let info' = info { bytesComplete = Just bytes }+					writeTransferInfoFile info' tfile+					return bytes+				else return oldbytes+		{- The minimum change in bytesComplete that is worth+		 - updating a transfer info file for is 1% of the total+		 - keySize, rounded down. -}+		mindelta = case keySize (transferKey t) of+			Just sz -> sz `div` 100+			Nothing -> 100 * 1024 -- arbitrarily, 100 kb++startTransferInfo :: Maybe FilePath -> IO TransferInfo+startTransferInfo file = TransferInfo+	<$> (Just . utcTimeToPOSIXSeconds <$> getCurrentTime)+	<*> pure Nothing -- pid not stored in file, so omitted for speed+	<*> pure Nothing -- tid ditto+	<*> pure Nothing -- not 0; transfer may be resuming+	<*> pure Nothing+	<*> pure file+	<*> pure False+ {- If a transfer is still running, returns its TransferInfo. -} checkTransfer :: Transfer -> Annex (Maybe TransferInfo) checkTransfer t = do@@ -117,30 +192,52 @@ 			liftIO $ closeFd fd 			case locked of 				Nothing -> return Nothing-				Just (pid, _) -> liftIO $-					flip catchDefaultIO Nothing $ do-						readTransferInfo pid -							<$> readFile tfile+				Just (pid, _) -> liftIO $ catchDefaultIO Nothing $+					readTransferInfoFile (Just pid) tfile  {- Gets all currently running transfers. -} getTransfers :: Annex [(Transfer, TransferInfo)] getTransfers = do-	transfers <- catMaybes . map parseTransferFile <$> findfiles+	transfers <- catMaybes . map parseTransferFile . concat <$> findfiles 	infos <- mapM checkTransfer transfers 	return $ map (\(t, Just i) -> (t, i)) $ 		filter running $ zip transfers infos 	where-		findfiles = liftIO . dirContentsRecursive-			=<< fromRepo gitAnnexTransferDir+		findfiles = liftIO . mapM dirContentsRecursive+			=<< mapM (fromRepo . transferDir)+				[Download, Upload] 		running (_, i) = isJust i +{- Gets failed transfers for a given remote UUID. -}+getFailedTransfers :: UUID -> Annex [(Transfer, TransferInfo)]+getFailedTransfers u = catMaybes <$> (liftIO . getpairs =<< concat <$> findfiles)+	where+		getpairs = mapM $ \f -> do+			let mt = parseTransferFile f+			mi <- readTransferInfoFile Nothing f+			return $ case (mt, mi) of+				(Just t, Just i) -> Just (t, i)+				_ -> Nothing+		findfiles = liftIO . mapM dirContentsRecursive+			=<< mapM (fromRepo . failedTransferDir u)+				[Download, Upload]++removeFailedTransfer :: Transfer -> Annex ()+removeFailedTransfer t = do+	f <- fromRepo $ failedTransferFile t+	liftIO $ void $ tryIO $ removeFile f+ {- The transfer information file to use for a given Transfer. -} transferFile :: Transfer -> Git.Repo -> FilePath-transferFile (Transfer direction u key) r = gitAnnexTransferDir r-	</> show direction -	</> fromUUID u+transferFile (Transfer direction u key) r = transferDir direction r+	</> filter (/= '/') (fromUUID u) 	</> keyFile key +{- The transfer information file to use to record a failed Transfer -}+failedTransferFile :: Transfer -> Git.Repo -> FilePath+failedTransferFile (Transfer direction u key) r = failedTransferDir u direction r+	</> keyFile key+ {- The transfer lock file corresponding to a given transfer info file. -} transferLockFile :: FilePath -> FilePath transferLockFile infofile = let (d,f) = splitFileName infofile in@@ -152,37 +249,71 @@ 	| "lck." `isPrefixOf` (takeFileName file) = Nothing 	| otherwise = case drop (length bits - 3) bits of 		[direction, u, key] -> Transfer-			<$> readDirection direction+			<$> readLcDirection direction 			<*> pure (toUUID u) 			<*> fileKey key 		_ -> Nothing 	where 		bits = splitDirectories file +writeTransferInfoFile :: TransferInfo -> FilePath -> IO ()+writeTransferInfoFile info tfile = do+	h <- openFile tfile WriteMode+	fileEncoding h+	hPutStr h $ writeTransferInfo info+	hClose h++{- File format is a header line containing the startedTime and any+ - bytesComplete value. Followed by a newline and the associatedFile.+ -+ - The transferPid is not included; instead it is obtained by looking+ - at the process that locks the file.+ -} writeTransferInfo :: TransferInfo -> String writeTransferInfo info = unlines-	-- transferPid is not included; instead obtained by looking at-	-- the process that locks the file.-	[ maybe "" show $ startedTime info-	-- bytesComplete is not included; changes too fast +	[ (maybe "" show $ startedTime info) +++	  (maybe "" (\b -> " " ++ show b) $ bytesComplete info) 	, fromMaybe "" $ associatedFile info -- comes last; arbitrary content 	] -readTransferInfo :: ProcessID -> String -> Maybe TransferInfo-readTransferInfo pid s =-	case bits of-		[time] -> TransferInfo-			<$> (Just <$> parsePOSIXTime time)-			<*> pure (Just pid)-			<*> pure Nothing-			<*> pure Nothing-			<*> pure Nothing-			<*> pure (if null filename then Nothing else Just filename)-		_ -> Nothing+readTransferInfoFile :: (Maybe ProcessID) -> FilePath -> IO (Maybe TransferInfo)+readTransferInfoFile mpid tfile = catchDefaultIO Nothing $ do+	h <- openFile tfile ReadMode+	fileEncoding h+	hClose h `after` (readTransferInfo mpid <$> hGetContentsStrict h)++readTransferInfo :: (Maybe ProcessID) -> String -> Maybe TransferInfo+readTransferInfo mpid s = TransferInfo+	<$> time+	<*> pure mpid+	<*> pure Nothing+	<*> pure Nothing+	<*> bytes+	<*> pure (if null filename then Nothing else Just filename)+	<*> pure False 	where-		(bits, filebits) = splitAt 1 $ lines s -		filename = join "\n" filebits+		(firstline, filename) = separate (== '\n') s+		bits = split " " firstline+		numbits = length bits+		time = if numbits > 0+			then Just <$> parsePOSIXTime (bits !! 0)+			else pure Nothing+		bytes = if numbits > 1+			then Just <$> readish (bits !! 1)+			else pure Nothing  parsePOSIXTime :: String -> Maybe POSIXTime parsePOSIXTime s = utcTimeToPOSIXSeconds 	<$> parseTime defaultTimeLocale "%s%Qs" s++{- The directory holding transfer information files for a given Direction. -}+transferDir :: Direction -> Git.Repo -> FilePath+transferDir direction r = gitAnnexTransferDir r </> showLcDirection direction++{- The directory holding failed transfer information files for a given+ - Direction and UUID -}+failedTransferDir :: UUID -> Direction -> Git.Repo -> FilePath+failedTransferDir u direction r = gitAnnexTransferDir r+	</> "failed"+	</> showLcDirection direction+	</> filter (/= '/') (fromUUID u)
Logs/Trust.hs view
@@ -10,6 +10,8 @@ 	trustGet, 	trustSet, 	trustPartition,+	readTrust,+	lookupTrust, ) where  import qualified Data.Map as M@@ -44,6 +46,10 @@ 	Annex.changeState $ \s -> s { Annex.trustmap = Nothing } trustSet NoUUID _ = error "unknown UUID; cannot modify trust level" +{- Returns the TrustLevel of a given repo UUID. -}+lookupTrust :: UUID -> Annex TrustLevel+lookupTrust u = (fromMaybe SemiTrusted . M.lookup u) <$> trustMap+ {- Partitions a list of UUIDs to those matching a TrustLevel and not. -} trustPartition :: TrustLevel -> [UUID] -> Annex ([UUID], [UUID]) trustPartition level ls@@ -76,12 +82,15 @@ 	where 		configuredtrust r = 			maybe Nothing (\l -> Just (Types.Remote.uuid r, l)) <$>-				maybe Nothing convert <$>+				maybe Nothing readTrust <$> 					getTrustLevel (Types.Remote.repo r)-		convert "trusted" = Just Trusted-		convert "untrusted" = Just UnTrusted-		convert "semitrusted" = Just SemiTrusted-		convert _ = Nothing++readTrust :: String -> Maybe TrustLevel+readTrust "trusted" = Just Trusted+readTrust "untrusted" = Just UnTrusted+readTrust "semitrusted" = Just SemiTrusted+readTrust "dead" = Just DeadTrusted+readTrust _ = Nothing  {- The trust.log used to only list trusted repos, without a field for the  - trust status, which is why this defaults to Trusted. -}
Logs/Unused.hs view
@@ -25,7 +25,7 @@ writeUnusedLog prefix l = do 	logfile <- fromRepo $ gitAnnexUnusedLog prefix 	liftIO $ viaTmp writeFile logfile $-		unlines $ map (\(n, k) -> show n ++ " " ++ show k) l+		unlines $ map (\(n, k) -> show n ++ " " ++ key2file k) l  readUnusedLog :: FilePath -> Annex UnusedMap readUnusedLog prefix = do@@ -37,7 +37,7 @@ 		) 	where 		parse line =-			case (readish tag, readKey rest) of+			case (readish tag, file2key rest) of 				(Just num, Just key) -> Just (num, key) 				_ -> Nothing 			where
Logs/Web.hs view
@@ -16,6 +16,7 @@ import Common.Annex import Logs.Presence import Logs.Location+import Types.Key  type URLString = String @@ -29,7 +30,7 @@ {- Used to store the urls elsewhere. -} oldurlLogs :: Key -> [FilePath] oldurlLogs key = -	[ "remote/web" </> hashDirLower key </> show key ++ ".log"+	[ "remote/web" </> hashDirLower key </> key2file key ++ ".log" 	, "remote/web" </> hashDirLower key </> keyFile key ++ ".log" 	] 
Makefile view
@@ -1,19 +1,27 @@+CFLAGS=-Wall+GIT_ANNEX_TMP_BUILD_DIR?=tmp+IGNORE=-ignore-package monads-fd -ignore-package monads-tf+BASEFLAGS=-threaded -Wall $(IGNORE) -outputdir $(GIT_ANNEX_TMP_BUILD_DIR) -IUtility++# If you get build failures due to missing haskell libraries,+# you can turn off some of these features.+FEATURES=-DWITH_ASSISTANT -DWITH_S3 -DWITH_WEBAPP -DWITH_OLD_YESOD -DWITH_PAIRING+ bins=git-annex mans=git-annex.1 git-annex-shell.1-sources=Build/SysConfig.hs Utility/Touch.hs+sources=Build/SysConfig.hs Utility/Touch.hs Utility/Mounts.hs all=$(bins) $(mans) docs -CFLAGS=-Wall- OS:=$(shell uname | sed 's/[-_].*//') ifeq ($(OS),Linux)-BASEFLAGS_OPTS=-DWITH_INOTIFY-clibs=Utility/libdiskfree.o+OPTFLAGS=-DWITH_INOTIFY -DWITH_DBUS+clibs=Utility/libdiskfree.o Utility/libmounts.o else # BSD system-BASEFLAGS_OPTS=-DWITH_KQUEUE-clibs=Utility/libdiskfree.o Utility/libkqueue.o+OPTFLAGS=-DWITH_KQUEUE+clibs=Utility/libdiskfree.o Utility/libmounts.o Utility/libkqueue.o ifeq ($(OS),Darwin)+OPTFLAGS=-DWITH_KQUEUE -DOSX # Ensure OSX compiler builds for 32 bit when using 32 bit ghc GHCARCH:=$(shell ghc -e 'print System.Info.arch') ifeq ($(GHCARCH),i386)@@ -23,12 +31,10 @@ endif  PREFIX=/usr-IGNORE=-ignore-package monads-fd -ignore-package monads-tf-BASEFLAGS=-Wall $(IGNORE) -outputdir tmp -IUtility -DWITH_ASSISTANT -DWITH_S3 $(BASEFLAGS_OPTS)-GHCFLAGS=-O2 $(BASEFLAGS)+GHCFLAGS=-O2 $(BASEFLAGS) $(FEATURES) $(OPTFLAGS)  ifdef PROFILE-GHCFLAGS=-prof -auto-all -rtsopts -caf-all -fforce-recomp $(BASEFLAGS)+GHCFLAGS=-prof -auto-all -rtsopts -caf-all -fforce-recomp $(BASEFLAGS) $(FEATURES) $(OPTFLAGS) endif  GHCMAKE=ghc $(GHCFLAGS) --make@@ -44,7 +50,7 @@ sources: $(sources)  # Disables optimisation. Not for production use.-fast: GHCFLAGS=$(BASEFLAGS)+fast: GHCFLAGS=$(BASEFLAGS) $(FEATURES) $(OPTFLAGS) fast: $(bins)  Build/SysConfig.hs: configure.hs Build/TestConfig.hs Build/Configure.hs@@ -54,16 +60,17 @@ %.hs: %.hsc 	hsc2hs $< - git-annex: $(sources) $(clibs)-	$(GHCMAKE) $@ $(clibs)+	install -d $(GIT_ANNEX_TMP_BUILD_DIR)+	$(GHCMAKE) $@ -o $(GIT_ANNEX_TMP_BUILD_DIR)/git-annex $(clibs)+	ln -sf $(GIT_ANNEX_TMP_BUILD_DIR)/git-annex git-annex  git-annex.1: doc/git-annex.mdwn-	./mdwn2man git-annex 1 doc/git-annex.mdwn > git-annex.1+	./Build/mdwn2man git-annex 1 doc/git-annex.mdwn > git-annex.1 git-annex-shell.1: doc/git-annex-shell.mdwn-	./mdwn2man git-annex-shell 1 doc/git-annex-shell.mdwn > git-annex-shell.1+	./Build/mdwn2man git-annex-shell 1 doc/git-annex-shell.mdwn > git-annex-shell.1 git-union-merge.1: doc/git-union-merge.mdwn-	./mdwn2man git-union-merge 1 doc/git-union-merge.mdwn > git-union-merge.1+	./Build/mdwn2man git-union-merge 1 doc/git-union-merge.mdwn > git-union-merge.1  install-mans: $(mans) 	install -d $(DESTDIR)$(PREFIX)/share/man/man1@@ -79,6 +86,7 @@ 	install -d $(DESTDIR)$(PREFIX)/bin 	install $(bins) $(DESTDIR)$(PREFIX)/bin 	ln -sf git-annex $(DESTDIR)$(PREFIX)/bin/git-annex-shell+	runghc Build/InstallDesktopFile.hs $(PREFIX)/bin/git-annex || true  test: $(sources) $(clibs) 	@if ! $(GHCMAKE) -O0 test $(clibs); then \@@ -91,7 +99,7 @@  testcoverage: 	rm -f test.tix test-	ghc $(GHCFLAGS) -outputdir tmp/testcoverage --make -fhpc test+	ghc $(GHCFLAGS) -outputdir $(GIT_ANNEX_TMP_BUILD_DIR)/testcoverage --make -fhpc test 	./test 	@echo "" 	@hpc report test --exclude=Main --exclude=QC@@ -115,11 +123,11 @@ 		--exclude='news/.*'  clean:-	rm -rf tmp $(bins) $(mans) test configure  *.tix .hpc $(sources) \+	rm -rf $(GIT_ANNEX_TMP_BUILD_DIR) $(bins) $(mans) test configure  *.tix .hpc $(sources) \ 		doc/.ikiwiki html dist $(clibs) build-stamp  sdist: clean $(mans)-	./make-sdist.sh+	./Build/make-sdist.sh  # Upload to hackage. hackage: sdist
Messages.hs view
@@ -11,7 +11,6 @@ 	showAction, 	showProgress, 	metered,-	MeterUpdate, 	showSideAction, 	doSideAction, 	doQuietSideAction,@@ -42,6 +41,7 @@ import Types import Types.Messages import Types.Key+import Types.Remote import qualified Annex import qualified Messages.JSON as JSON @@ -63,9 +63,8 @@  {- Shows a progress meter while performing a transfer of a key.  - The action is passed a callback to use to update the meter. -}-type MeterUpdate = Integer -> IO ()-metered :: Key -> (MeterUpdate -> Annex a) -> Annex a-metered key a = withOutputType $ go (keySize key)+metered :: (Maybe MeterUpdate) -> Key -> (MeterUpdate -> Annex a) -> Annex a+metered combinemeterupdate key a = withOutputType $ go (keySize key) 	where 		go (Just size) NormalOutput = do 			progress <- liftIO $ newProgress "" size@@ -75,6 +74,7 @@ 			r <- a $ \n -> liftIO $ do 				incrP progress n 				displayMeter stdout meter+				maybe noop (\m -> m n) combinemeterupdate 			liftIO $ clearMeter stdout meter 			return r                 go _ _ = a (const noop)
Option.hs view
@@ -17,6 +17,9 @@  import System.Console.GetOpt import System.Log.Logger+import System.Log.Formatter+import System.Log.Handler (setFormatter, LogHandler)+import System.Log.Handler.Simple  import Common.Annex import qualified Annex@@ -48,8 +51,13 @@ 		setfast v = Annex.changeState $ \s -> s { Annex.fast = v } 		setauto v = Annex.changeState $ \s -> s { Annex.auto = v } 		setforcebackend v = Annex.changeState $ \s -> s { Annex.forcebackend = Just v }-		setdebug = liftIO $ updateGlobalLogger rootLoggerName $-			setLevel DEBUG+		setdebug = liftIO $ do+			s <- simpledebug+			updateGlobalLogger rootLoggerName+				(setLevel DEBUG . setHandlers [s])+		simpledebug = setFormatter+			<$> streamHandler stderr DEBUG+			<*> pure (simpleLogFormatter "[$time] $msg")  matcher :: [Option] matcher =
Remote.hs view
@@ -20,10 +20,13 @@ 	remoteTypes, 	remoteList, 	enabledRemoteList,+	specialRemote, 	remoteMap, 	uuidDescriptions, 	byName,+	byCost, 	prettyPrintUUIDs,+	prettyListUUIDs, 	remotesWithUUID, 	remotesWithoutUUID, 	keyLocations,@@ -128,6 +131,20 @@ 			, ("here", toJSON $ hereu == u) 			] +{- List of remote names and/or descriptions, for human display.  -}+prettyListUUIDs :: [UUID] -> Annex [String]+prettyListUUIDs uuids = do+	hereu <- getUUID+	m <- uuidDescriptions+	return $ map (\u -> prettify m hereu u) uuids+	where+		finddescription m u = M.findWithDefault "" u m+		prettify m hereu u+			| u == hereu = addName n "here"+			| otherwise = n+			where+				n = finddescription m u+ {- Filters a list of remotes to ones that have the listed uuids. -} remotesWithUUID :: [Remote] -> [UUID] -> [Remote] remotesWithUUID rs us = filter (\r -> uuid r `elem` us) rs@@ -208,3 +225,10 @@  - on the remote, but this cannot always be relied on. -} logStatus :: Remote -> Key -> LogStatus -> Annex () logStatus remote key = logChange key (uuid remote)++{- Orders remotes by cost, with ones with the lowest cost grouped together. -}+byCost :: [Remote] -> [[Remote]]+byCost = map snd . sort . M.toList . costmap+	where+		costmap = M.fromListWith (++) . map costpair+		costpair r = (cost r, [r])
Remote/Bup.hs view
@@ -13,6 +13,7 @@  import Common.Annex import Types.Remote+import Types.Key import qualified Git import qualified Git.Command import qualified Git.Config@@ -46,21 +47,25 @@ 	return $ encryptableRemote c 		(storeEncrypted r buprepo) 		(retrieveEncrypted buprepo)-		Remote {-			uuid = u',-			cost = cst,-			name = Git.repoDescribe r,- 			storeKey = store r buprepo,-			retrieveKeyFile = retrieve buprepo,-			retrieveKeyFileCheap = retrieveCheap buprepo,-			removeKey = remove,-			hasKey = checkPresent r bupr',-			hasKeyCheap = bupLocal buprepo,-			whereisKey = Nothing,-			config = c,-			repo = r,-			remotetype = remote-		}+		Remote+			{ uuid = u'+			, cost = cst+			, name = Git.repoDescribe r+ 			, storeKey = store r buprepo+			, retrieveKeyFile = retrieve buprepo+			, retrieveKeyFileCheap = retrieveCheap buprepo+			, removeKey = remove+			, hasKey = checkPresent r bupr'+			, hasKeyCheap = bupLocal buprepo+			, whereisKey = Nothing+			, config = c+			, repo = r+			, localpath = if bupLocal buprepo && not (null buprepo)+				then Just buprepo+				else Nothing+			, remotetype = remote+			, readonly = False+			}  bupSetup :: UUID -> RemoteConfig -> Annex RemoteConfig bupSetup u c = do@@ -108,14 +113,14 @@ 	return $ bupParams "split" buprepo  		(os ++ [Param "-n", Param (bupRef k), src]) -store :: Git.Repo -> BupRepo -> Key -> AssociatedFile -> Annex Bool-store r buprepo k _f = do+store :: Git.Repo -> BupRepo -> Key -> AssociatedFile -> MeterUpdate -> Annex Bool+store r buprepo k _f _p = do 	src <- inRepo $ gitAnnexLocation k 	params <- bupSplitParams r buprepo k (File src) 	liftIO $ boolSystem "bup" params -storeEncrypted :: Git.Repo -> BupRepo -> (Cipher, Key) -> Key -> Annex Bool-storeEncrypted r buprepo (cipher, enck) k = do+storeEncrypted :: Git.Repo -> BupRepo -> (Cipher, Key) -> Key -> MeterUpdate -> Annex Bool+storeEncrypted r buprepo (cipher, enck) k _p = do 	src <- inRepo $ gitAnnexLocation k 	params <- bupSplitParams r buprepo enck (Param "-") 	liftIO $ catchBoolIO $@@ -133,13 +138,13 @@ retrieveCheap _ _ _ = return False  retrieveEncrypted :: BupRepo -> (Cipher, Key) -> Key -> FilePath -> Annex Bool-retrieveEncrypted buprepo (cipher, enck) _ f = do-	let params = bupParams "join" buprepo [Param $ bupRef enck]-	liftIO $ catchBoolIO $ do-		(pid, h) <- hPipeFrom "bup" $ toCommand params+retrieveEncrypted buprepo (cipher, enck) _ f = liftIO $ catchBoolIO $+	withHandle StdoutHandle createProcessSuccess p $ \h -> do 		withDecryptedContent cipher (L.hGetContents h) $ L.writeFile f-		forceSuccess pid 		return True+	where+		params = bupParams "join" buprepo [Param $ bupRef enck]+		p = proc "bup" $ toCommand params  remove :: Key -> Annex Bool remove _ = do@@ -240,7 +245,7 @@ 	| Git.Ref.legal True shown = shown 	| otherwise = "git-annex-" ++ showDigest (sha256 (fromString shown)) 	where-		shown = show k+		shown = key2file k  bupLocal :: BupRepo -> Bool bupLocal = notElem ':'
Remote/Directory.hs view
@@ -53,6 +53,8 @@ 			whereisKey = Nothing, 			config = Nothing, 			repo = r,+			localpath = Just dir,+			readonly = False, 			remotetype = remote 		} 	where@@ -122,10 +124,10 @@ withStoredFiles :: ChunkSize -> FilePath -> Key -> ([FilePath] -> IO Bool) -> IO Bool withStoredFiles = withCheckedFiles doesFileExist -store :: FilePath -> ChunkSize -> Key -> AssociatedFile -> Annex Bool-store d chunksize k _f = do+store :: FilePath -> ChunkSize -> Key -> AssociatedFile -> MeterUpdate -> Annex Bool+store d chunksize k _f p = do 	src <- inRepo $ gitAnnexLocation k-	metered k $ \meterupdate -> +	metered (Just p) k $ \meterupdate ->  		storeHelper d chunksize k $ \dests -> 			case chunksize of 				Nothing -> do@@ -137,10 +139,10 @@ 					storeSplit meterupdate chunksize dests 						=<< L.readFile src -storeEncrypted :: FilePath -> ChunkSize -> (Cipher, Key) -> Key -> Annex Bool-storeEncrypted d chunksize (cipher, enck) k = do+storeEncrypted :: FilePath -> ChunkSize -> (Cipher, Key) -> Key -> MeterUpdate -> Annex Bool+storeEncrypted d chunksize (cipher, enck) k p = do 	src <- inRepo $ gitAnnexLocation k-	metered k $ \meterupdate ->+	metered (Just p) k $ \meterupdate -> 		storeHelper d chunksize enck $ \dests -> 			withEncryptedContent cipher (L.readFile src) $ \s -> 				case chunksize of@@ -243,7 +245,7 @@ 			return (not $ null stored)  retrieve :: FilePath -> ChunkSize -> Key -> AssociatedFile -> FilePath -> Annex Bool-retrieve d chunksize k _ f = metered k $ \meterupdate ->+retrieve d chunksize k _ f = metered Nothing k $ \meterupdate -> 	liftIO $ withStoredFiles chunksize d k $ \files -> 		catchBoolIO $ do 			meteredWriteFile' meterupdate f files feeder@@ -255,7 +257,7 @@ 			return (xs, chunks)  retrieveEncrypted :: FilePath -> ChunkSize -> (Cipher, Key) -> Key -> FilePath -> Annex Bool-retrieveEncrypted d chunksize (cipher, enck) k f = metered k $ \meterupdate ->+retrieveEncrypted d chunksize (cipher, enck) k f = metered Nothing k $ \meterupdate -> 	liftIO $ withStoredFiles chunksize d enck $ \files -> 		catchBoolIO $ do 			withDecryptedContent cipher (L.concat <$> mapM L.readFile files) $
Remote/Git.hs view
@@ -5,14 +5,18 @@  - Licensed under the GNU GPL version 3 or higher.  -} -module Remote.Git (remote, repoAvail) where+module Remote.Git (+	remote,+	configRead,+	repoAvail,+) where  import qualified Data.Map as M import Control.Exception.Extensible  import Common.Annex import Utility.CopyFile-import Utility.RsyncFile+import Utility.Rsync import Remote.Helper.Ssh import Types.Remote import qualified Git@@ -23,6 +27,7 @@ import Logs.Presence import Logs.Transfer import Annex.UUID+import Annex.Exception import qualified Annex.Content import qualified Annex.BranchState import qualified Annex.Branch@@ -33,6 +38,9 @@ import Types.Key import qualified Fields +import Control.Concurrent+import System.Process (std_in, std_err)+ remote :: RemoteType remote = RemoteType { 	typename = "git",@@ -45,7 +53,7 @@ list = do 	c <- fromRepo Git.config 	rs <- mapM (tweakurl c) =<< fromRepo Git.remotes-	mapM configread rs+	mapM configRead rs 	where 		annexurl n = "remote." ++ n ++ ".annexurl" 		tweakurl c r = do@@ -55,20 +63,22 @@ 				Just url -> inRepo $ \g -> 					Git.Construct.remoteNamed n $ 						Git.Construct.fromRemoteLocation url g-		{- It's assumed to be cheap to read the config of non-URL-		 - remotes, so this is done each time git-annex is run-		 - in a way that uses remotes.-		 - Conversely, the config of an URL remote is only read-		 - when there is no cached UUID value. -}-		configread r = do-			notignored <- repoNotIgnored r-			u <- getRepoUUID r-			case (repoCheap r, notignored, u) of-				(_, False, _) -> return r-				(True, _, _) -> tryGitConfigRead r-				(False, _, NoUUID) -> tryGitConfigRead r-				_ -> return r +{- It's assumed to be cheap to read the config of non-URL remotes, so this is+ - done each time git-annex is run in a way that uses remotes.+ -+ - Conversely, the config of an URL remote is only read when there is no+ - cached UUID value. -}+configRead :: Git.Repo -> Annex Git.Repo+configRead r = do+	notignored <- repoNotIgnored r+	u <- getRepoUUID r+	case (repoCheap r, notignored, u) of+		(_, False, _) -> return r+		(True, _, _) -> tryGitConfigRead r+		(False, _, NoUUID) -> tryGitConfigRead r+		_ -> return r+ repoCheap :: Git.Repo -> Bool repoCheap = not . Git.repoIsUrl @@ -76,21 +86,26 @@ gen r u _ = new <$> remoteCost r defcst 	where 		defcst = if repoCheap r then cheapRemoteCost else expensiveRemoteCost-		new cst = Remote {-			uuid = u,-			cost = cst,-			name = Git.repoDescribe r,-			storeKey = copyToRemote r,-			retrieveKeyFile = copyFromRemote r,-			retrieveKeyFileCheap = copyFromRemoteCheap r,-			removeKey = dropKey r,-			hasKey = inAnnex r,-			hasKeyCheap = repoCheap r,-			whereisKey = Nothing,-			config = Nothing,-			repo = r,-			remotetype = remote-		}+		new cst = Remote +			{ uuid = u+			, cost = cst+			, name = Git.repoDescribe r+			, storeKey = copyToRemote r+			, retrieveKeyFile = copyFromRemote r+			, retrieveKeyFileCheap = copyFromRemoteCheap r+			, removeKey = dropKey r+			, hasKey = inAnnex r+			, hasKeyCheap = repoCheap r+			, whereisKey = Nothing+			, config = Nothing+			, localpath = if Git.repoIsLocal r || Git.repoIsLocalUnknown r+				then Just $ Git.repoPath r+				else Nothing+			, repo = r+			, readonly = Git.repoIsHttp r+			, remotetype = remote+			}+		  {- Checks relatively inexpensively if a repository is available for use. -} repoAvail :: Git.Repo -> Annex Bool@@ -127,16 +142,17 @@ 				=<< liftIO (try a :: IO (Either SomeException Git.Repo))  		pipedconfig cmd params = safely $-			pOpen ReadFromPipe cmd (toCommand params) $+			withHandle StdoutHandle createProcessSuccess p $ 				Git.Config.hRead r+			where+				p = proc cmd $ toCommand params  		geturlconfig headers = do 			s <- Url.get (Git.repoLocation r ++ "/config") headers 			withTempFile "git-annex.tmp" $ \tmpfile h -> do 				hPutStr h s 				hClose h-				pOpen ReadFromPipe "git" ["config", "--null", "--list", "--file", tmpfile] $-					Git.Config.hRead r+				pipedconfig "git" [Param "config", Param "--null", Param "--list", Param "--file", File tmpfile]  		store = observe $ \r' -> do 			g <- gitRepo@@ -172,7 +188,7 @@ 						v -> return v 		checkremote = do 			showAction $ "checking " ++ Git.repoDescribe r-			onRemote r (check, unknown) "inannex" [Param (show key)] []+			onRemote r (check, unknown) "inannex" [Param (key2file key)] [] 			where 				check c p = dispatch <$> safeSystem c p 				dispatch ExitSuccess = Right True@@ -217,7 +233,7 @@ 	| Git.repoIsHttp r = error "dropping from http repo not supported" 	| otherwise = commitOnCleanup r $ onRemote r (boolSystem, False) "dropkey" 		[ Params "--quiet --force"-		, Param $ show key+		, Param $ key2file key 		] 		[] @@ -231,11 +247,51 @@ 		liftIO $ onLocal r $ do 			ensureInitialized 			loc <- inRepo $ gitAnnexLocation key-			upload u key file $+			upload u key file noRetry $ 				rsyncOrCopyFile params loc dest-	| Git.repoIsSsh r = rsyncHelper =<< rsyncParamsRemote r True key dest file+	| Git.repoIsSsh r = feedprogressback $ \feeder -> +		rsyncHelper (Just feeder) +			=<< rsyncParamsRemote r True key dest file 	| Git.repoIsHttp r = Annex.Content.downloadUrl (keyUrls r key) dest 	| otherwise = error "copying from non-ssh, non-http repo not supported"+	where+		{- Feed local rsync's progress info back to the remote,+		 - by forking a feeder thread that runs+		 - git-annex-shell transferinfo at the same time+		 - git-annex-shell sendkey is running.+		 -+		 - Note that it actually waits for rsync to indicate+		 - progress before starting transferinfo, in order+		 - to ensure ssh connection caching works and reuses +		 - the connection set up for the sendkey.+		 -+		 - Also note that older git-annex-shell does not support+		 - transferinfo, so stderr is dropped and failure ignored.+		 -}+		feedprogressback a = do+			u <- getUUID+			let fields = (Fields.remoteUUID, fromUUID u)+				: maybe [] (\f -> [(Fields.associatedFile, f)]) file+			Just (cmd, params) <- git_annex_shell r "transferinfo" +				[Param $ key2file key] fields+			v <- liftIO $ newEmptySampleVar+			tid <- liftIO $ forkIO $ void $ tryIO $ do+				bytes <- readSampleVar v+				p <- createProcess $+					 (proc cmd (toCommand params))+						{ std_in = CreatePipe+						, std_err = CreatePipe+						}+				hClose $ stderrHandle p+				let h = stdinHandle p+				let send b = do+					hPutStrLn h $ show b+					hFlush h+				send bytes+				forever $+					send =<< readSampleVar v+			let feeder = writeSampleVar v+			bracketIO noop (const $ tryIO $ killThread tid) (a feeder)  copyFromRemoteCheap :: Git.Repo -> Key -> FilePath -> Annex Bool copyFromRemoteCheap r key file@@ -250,28 +306,31 @@ 	| otherwise = return False  {- Tries to copy a key's content to a remote's annex. -}-copyToRemote :: Git.Repo -> Key -> AssociatedFile -> Annex Bool-copyToRemote r key file+copyToRemote :: Git.Repo -> Key -> AssociatedFile -> MeterUpdate -> Annex Bool+copyToRemote r key file p 	| not $ Git.repoIsUrl r = guardUsable r False $ commitOnCleanup r $ do 		keysrc <- inRepo $ gitAnnexLocation key 		params <- rsyncParams r 		u <- getUUID 		-- run copy from perspective of remote-		liftIO $ onLocal r $ do-			ensureInitialized-			download u key file $-				Annex.Content.saveState True `after`-					Annex.Content.getViaTmp key-						(rsyncOrCopyFile params keysrc)+		liftIO $ onLocal r $ ifM (Annex.Content.inAnnex key)+			( return False+			, do+				ensureInitialized+				download u key file noRetry $+					Annex.Content.saveState True `after`+						Annex.Content.getViaTmp key+							(\d -> rsyncOrCopyFile params keysrc d p)+			) 	| Git.repoIsSsh r = commitOnCleanup r $ do 		keysrc <- inRepo $ gitAnnexLocation key-		rsyncHelper =<< rsyncParamsRemote r False key keysrc file+		rsyncHelper (Just p) =<< rsyncParamsRemote r False key keysrc file 	| otherwise = error "copying to non-ssh repo not supported" -rsyncHelper :: [CommandParam] -> Annex Bool-rsyncHelper p = do+rsyncHelper :: Maybe MeterUpdate -> [CommandParam] -> Annex Bool+rsyncHelper callback params = do 	showOutput -- make way for progress bar-	ifM (liftIO $ rsync p)+	ifM (liftIO $ (maybe rsync rsyncProgress callback) params) 		( return True 		, do 			showLongNote "rsync failed -- run git annex again to resume file transfer"@@ -280,15 +339,29 @@  {- Copys a file with rsync unless both locations are on the same  - filesystem. Then cp could be faster. -}-rsyncOrCopyFile :: [CommandParam] -> FilePath -> FilePath -> Annex Bool-rsyncOrCopyFile rsyncparams src dest =-	ifM (sameDeviceIds src dest)-		( liftIO $ copyFileExternal src dest-		, rsyncHelper $ rsyncparams ++ [Param src, Param dest]-		)+rsyncOrCopyFile :: [CommandParam] -> FilePath -> FilePath -> MeterUpdate -> Annex Bool+rsyncOrCopyFile rsyncparams src dest p =+	ifM (sameDeviceIds src dest) (docopy, dorsync) 	where 		sameDeviceIds a b = (==) <$> (getDeviceId a) <*> (getDeviceId b) 		getDeviceId f = deviceID <$> liftIO (getFileStatus $ parentDir f)+		dorsync = rsyncHelper (Just p) $+			rsyncparams ++ [Param src, Param dest]+		docopy = liftIO $ bracket+			(forkIO $ watchfilesize 0)+			(void . tryIO . killThread)+			(const $ copyFileExternal src dest)+		watchfilesize oldsz = do+			threadDelay 500000 -- 0.5 seconds+			v <- catchMaybeIO $+				fromIntegral . fileSize+					<$> getFileStatus dest+			case v of+				Just sz+					| sz /= oldsz -> do+						p sz+						watchfilesize sz+				_ -> watchfilesize oldsz  {- Generates rsync parameters that ssh to the remote and asks it  - to either receive or send the key's content. -}@@ -299,7 +372,7 @@ 		: maybe [] (\f -> [(Fields.associatedFile, f)]) afile 	Just (shellcmd, shellparams) <- git_annex_shell r 		(if sending then "sendkey" else "recvkey")-		[ Param $ show key ]+		[ Param $ key2file key ] 		fields 	-- Convert the ssh command into rsync command line. 	let eparam = rsyncShell (Param shellcmd:shellparams)
Remote/Helper/Encryptable.hs view
@@ -45,7 +45,7 @@  - to support storing and retrieving encrypted content. -} encryptableRemote 	:: Maybe RemoteConfig-	-> ((Cipher, Key) -> Key -> Annex Bool)+	-> ((Cipher, Key) -> Key -> MeterUpdate -> Annex Bool) 	-> ((Cipher, Key) -> Key -> FilePath -> Annex Bool) 	-> Remote 	-> Remote@@ -59,9 +59,9 @@ 		cost = cost r + encryptedRemoteCostAdj 	} 	where-		store k f = cip k >>= maybe-			(storeKey r k f)-			(`storeKeyEncrypted` k)+		store k f p = cip k >>= maybe+			(storeKey r k f p)+			(\enck -> storeKeyEncrypted enck k p) 		retrieve k f d = cip k >>= maybe 			(retrieveKeyFile r k f d) 			(\enck -> retrieveKeyFileEncrypted enck k d)
Remote/Helper/Hooks.hs view
@@ -27,7 +27,7 @@ addHooks' r starthook stophook = r' 	where 		r' = r-			{ storeKey = \k f -> wrapper $ storeKey r k f+			{ storeKey = \k f p -> wrapper $ storeKey r k f p 			, retrieveKeyFile = \k f d -> wrapper $ retrieveKeyFile r k f d 			, retrieveKeyFileCheap = \k f -> wrapper $ retrieveKeyFileCheap r k f 			, removeKey = \k -> wrapper $ removeKey r k
Remote/Hook.hs view
@@ -9,11 +9,11 @@  import qualified Data.ByteString.Lazy as L import qualified Data.Map as M-import System.Exit import System.Environment  import Common.Annex import Types.Remote+import Types.Key import qualified Git import Config import Annex.Content@@ -48,7 +48,9 @@ 			hasKeyCheap = False, 			whereisKey = Nothing, 			config = Nothing,+			localpath = Nothing, 			repo = r,+			readonly = False, 			remotetype = remote 		} @@ -68,7 +70,7 @@ 				<$> M.fromList <$> getEnvironment 		env s v = ("ANNEX_" ++ s, v) 		keyenv =-			[ env "KEY" (show k)+			[ env "KEY" (key2file k) 			, env "HASH_1" (hashbits !! 0) 			, env "HASH_2" (hashbits !! 1) 			]@@ -101,13 +103,13 @@ 					return False 				) -store :: String -> Key -> AssociatedFile -> Annex Bool-store h k _f = do+store :: String -> Key -> AssociatedFile -> MeterUpdate -> Annex Bool+store h k _f _p = do 	src <- inRepo $ gitAnnexLocation k 	runHook h "store" k (Just src) $ return True -storeEncrypted :: String -> (Cipher, Key) -> Key -> Annex Bool-storeEncrypted h (cipher, enck) k = withTmp enck $ \tmp -> do+storeEncrypted :: String -> (Cipher, Key) -> Key -> MeterUpdate -> Annex Bool+storeEncrypted h (cipher, enck) k _p = withTmp enck $ \tmp -> do 	src <- inRepo $ gitAnnexLocation k 	liftIO $ withEncryptedContent cipher (L.readFile src) $ L.writeFile tmp 	runHook h "store" enck (Just tmp) $ return True@@ -133,20 +135,8 @@ 	v <- lookupHook h "checkpresent" 	liftIO $ catchMsgIO $ check v 	where-		findkey s = show k `elem` lines s+		findkey s = key2file k `elem` lines s 		check Nothing = error "checkpresent hook misconfigured" 		check (Just hook) = do-			(frompipe, topipe) <- createPipe-			pid <- forkProcess $ do-				_ <- dupTo topipe stdOutput-				closeFd frompipe-				executeFile "sh" True ["-c", hook]-					=<< hookEnv k Nothing-			closeFd topipe-			fromh <- fdToHandle frompipe-			reply <- hGetContentsStrict fromh-			hClose fromh-			s <- getProcessStatus True False pid-			case s of-				Just (Exited ExitSuccess) -> return $ findkey reply-				_ -> error "checkpresent hook failed"+			env <- hookEnv k Nothing+			findkey <$> readProcessEnv "sh" ["-c", hook] env
Remote/List.hs view
@@ -2,7 +2,7 @@  {- git-annex remote list  -- - Copyright 2011 Joey Hess <joey@kitenet.net>+ - Copyright 2011,2012 Joey Hess <joey@kitenet.net>  -  - Licensed under the GNU GPL version 3 or higher.  -}@@ -18,6 +18,8 @@ import Annex.UUID import Config import Remote.Helper.Hooks+import qualified Git+import qualified Git.Config  import qualified Remote.Git #ifdef WITH_S3@@ -55,11 +57,40 @@ 			return rs' 		else return rs 	where-		process m t = enumerate t >>= mapM (gen m t)-		gen m t r = do-			u <- getRepoUUID r-			addHooks =<< generate t r u (M.lookup u m)+		process m t = enumerate t >>= mapM (remoteGen m t) +{- Forces the remoteList to be re-generated, re-reading the git config. -}+remoteListRefresh :: Annex [Remote]+remoteListRefresh = do+	newg <- inRepo Git.Config.reRead+	Annex.changeState $ \s -> s +		{ Annex.remotes = []+		, Annex.repo = newg+		}+	remoteList++{- Generates a Remote. -}+remoteGen :: (M.Map UUID RemoteConfig) -> RemoteType -> Git.Repo -> Annex Remote+remoteGen m t r = do+	u <- getRepoUUID r+	addHooks =<< generate t r u (M.lookup u m)++{- Updates a local git Remote, re-reading its git config. -}+updateRemote :: Remote -> Annex Remote+updateRemote remote = do+	m <- readRemoteLog+	remote' <- updaterepo $ repo remote+	remoteGen m (remotetype remote) remote'+	where+		updaterepo r+			| Git.repoIsLocal r || Git.repoIsLocalUnknown r =+				Remote.Git.configRead r+			| otherwise = return r+ {- All remotes that are not ignored. -} enabledRemoteList :: Annex [Remote] enabledRemoteList = filterM (repoNotIgnored . repo) =<< remoteList++{- Checks if a remote is a special remote -}+specialRemote :: Remote -> Bool+specialRemote r = remotetype r /= Remote.Git.remote
Remote/Rsync.hs view
@@ -9,6 +9,7 @@  import qualified Data.ByteString.Lazy as L import qualified Data.Map as M+import System.Posix.Process (getProcessID)  import Common.Annex import Types.Remote@@ -18,7 +19,7 @@ import Remote.Helper.Special import Remote.Helper.Encryptable import Crypto-import Utility.RsyncFile+import Utility.Rsync import Annex.Perms  type RsyncUrl = String@@ -44,21 +45,25 @@ 	return $ encryptableRemote c 		(storeEncrypted o) 		(retrieveEncrypted o)-		Remote {-			uuid = u,-			cost = cst,-			name = Git.repoDescribe r,- 			storeKey = store o,-			retrieveKeyFile = retrieve o,-			retrieveKeyFileCheap = retrieveCheap o,-			removeKey = remove o,-			hasKey = checkPresent r o,-			hasKeyCheap = False,-			whereisKey = Nothing,-			config = Nothing,-			repo = r,-			remotetype = remote-		}+		Remote+			{ uuid = u+			, cost = cst+			, name = Git.repoDescribe r+ 			, storeKey = store o+			, retrieveKeyFile = retrieve o+			, retrieveKeyFileCheap = retrieveCheap o+			, removeKey = remove o+			, hasKey = checkPresent r o+			, hasKeyCheap = False+			, whereisKey = Nothing+			, config = Nothing+			, repo = r+			, localpath = if rsyncUrlIsPath $ rsyncUrl o+				then Just $ rsyncUrl o+				else Nothing+			, readonly = False+			, remotetype = remote+			}  genRsyncOpts :: Git.Repo -> Maybe RemoteConfig -> Annex RsyncOpts genRsyncOpts r c = do@@ -99,17 +104,17 @@ 		use h = rsyncUrl o </> h k </> rsyncEscape o (f </> f)                 f = keyFile k -store :: RsyncOpts -> Key -> AssociatedFile -> Annex Bool-store o k _f = rsyncSend o k <=< inRepo $ gitAnnexLocation k+store :: RsyncOpts -> Key -> AssociatedFile -> MeterUpdate -> Annex Bool+store o k _f p = rsyncSend o p k <=< inRepo $ gitAnnexLocation k -storeEncrypted :: RsyncOpts -> (Cipher, Key) -> Key -> Annex Bool-storeEncrypted o (cipher, enck) k = withTmp enck $ \tmp -> do+storeEncrypted :: RsyncOpts -> (Cipher, Key) -> Key -> MeterUpdate -> Annex Bool+storeEncrypted o (cipher, enck) k p = withTmp enck $ \tmp -> do 	src <- inRepo $ gitAnnexLocation k 	liftIO $ withEncryptedContent cipher (L.readFile src) $ L.writeFile tmp-	rsyncSend o enck tmp+	rsyncSend o p enck tmp  retrieve :: RsyncOpts -> Key -> AssociatedFile -> FilePath -> Annex Bool-retrieve o k _ f = untilTrue (rsyncUrls o k) $ \u -> rsyncRemote o+retrieve o k _ f = untilTrue (rsyncUrls o k) $ \u -> rsyncRemote o Nothing 	-- use inplace when retrieving to support resuming 	[ Param "--inplace" 	, Param u@@ -186,10 +191,10 @@ 		nuke d = liftIO $ whenM (doesDirectoryExist d) $ 			removeDirectoryRecursive d -rsyncRemote :: RsyncOpts -> [CommandParam] -> Annex Bool-rsyncRemote o params = do+rsyncRemote :: RsyncOpts -> (Maybe MeterUpdate) -> [CommandParam] -> Annex Bool+rsyncRemote o callback params = do 	showOutput -- make way for progress bar-	ifM (liftIO $ rsync $ rsyncOptions o ++ defaultParams ++ params)+	ifM (liftIO $ (maybe rsync rsyncProgress callback) ps) 		( return True 		, do 			showLongNote "rsync failed -- run git annex again to resume file transfer"@@ -197,16 +202,17 @@ 		) 	where 		defaultParams = [Params "--progress"]+		ps = rsyncOptions o ++ defaultParams ++ params  {- To send a single key is slightly tricky; need to build up a temporary    directory structure to pass to rsync so it can create the hash    directories. -}-rsyncSend :: RsyncOpts -> Key -> FilePath -> Annex Bool-rsyncSend o k src = withRsyncScratchDir $ \tmp -> do+rsyncSend :: RsyncOpts -> MeterUpdate -> Key -> FilePath -> Annex Bool+rsyncSend o callback k src = withRsyncScratchDir $ \tmp -> do 	let dest = tmp </> Prelude.head (keyPaths k) 	liftIO $ createDirectoryIfMissing True $ parentDir dest 	liftIO $ createLink src dest-	rsyncRemote o+	rsyncRemote o (Just callback) 		[ Param "--recursive" 		, partialParams  		  -- tmp/ to send contents of tmp dir
Remote/S3.hs view
@@ -60,6 +60,8 @@ 			whereisKey = Nothing, 			config = c, 			repo = r,+			localpath = Nothing,+			readonly = False, 			remotetype = remote 		} @@ -113,14 +115,14 @@ 					-- be human-readable 					M.delete "bucket" defaults -store :: Remote -> Key -> AssociatedFile -> Annex Bool-store r k _f = s3Action r False $ \(conn, bucket) -> do+store :: Remote -> Key -> AssociatedFile -> MeterUpdate -> Annex Bool+store r k _f _p = s3Action r False $ \(conn, bucket) -> do 	dest <- inRepo $ gitAnnexLocation k 	res <- liftIO $ storeHelper (conn, bucket) r k dest 	s3Bool res -storeEncrypted :: Remote -> (Cipher, Key) -> Key -> Annex Bool-storeEncrypted r (cipher, enck) k = s3Action r False $ \(conn, bucket) -> +storeEncrypted :: Remote -> (Cipher, Key) -> Key -> MeterUpdate -> Annex Bool+storeEncrypted r (cipher, enck) k _p = s3Action r False $ \(conn, bucket) ->  	-- To get file size of the encrypted content, have to use a temp file. 	-- (An alternative would be chunking to to a constant size.) 	withTmp enck $ \tmp -> do@@ -210,12 +212,12 @@ 		_ -> return noconn  bucketFile :: Remote -> Key -> FilePath-bucketFile r = munge . show+bucketFile r = munge . key2file 	where 		munge s = case M.lookup "mungekeys" c of-			Just "ia" -> iaMunge $ prefix ++ s-			_ -> prefix ++ s-		prefix = M.findWithDefault "" "fileprefix" c+			Just "ia" -> iaMunge $ fileprefix ++ s+			_ -> fileprefix ++ s+		fileprefix = M.findWithDefault "" "fileprefix" c 		c = fromJust $ config r  bucketKey :: Remote -> String -> Key -> S3Object
Remote/Web.hs view
@@ -47,7 +47,9 @@ 		hasKeyCheap = False, 		whereisKey = Just getUrls, 		config = Nothing,+		localpath = Nothing, 		repo = r,+		readonly = True, 		remotetype = remote 	} @@ -64,8 +66,8 @@ downloadKeyCheap :: Key -> FilePath -> Annex Bool downloadKeyCheap _ _ = return False -uploadKey :: Key -> AssociatedFile -> Annex Bool-uploadKey _ _ = do+uploadKey :: Key -> AssociatedFile -> MeterUpdate -> Annex Bool+uploadKey _ _ _ = do 	warning "upload to web not supported" 	return False 
Seek.hs view
@@ -82,7 +82,7 @@ withKeys :: (Key -> CommandStart) -> CommandSeek withKeys a params = return $ map (a . parse) params 	where-		parse p = fromMaybe (error "bad key") $ readKey p+		parse p = fromMaybe (error "bad key") $ file2key p  withValue :: Annex v -> (v -> CommandSeek) -> CommandSeek withValue v a params = do@@ -108,9 +108,9 @@ prepFiltered :: (FilePath -> CommandStart) -> Annex [FilePath] -> Annex [CommandStart] prepFiltered a fs = do 	matcher <- Limit.getMatcher-	map (proc matcher) <$> fs+	map (process matcher) <$> fs 	where-		proc matcher f = do+		process matcher f = do 			ok <- matcher f 			if ok then a f else return Nothing 
Setup.hs view
@@ -9,7 +9,11 @@ import Distribution.PackageDescription (PackageDescription(..)) import Distribution.Verbosity (Verbosity) import System.FilePath+import Control.Applicative+import Control.Monad+import System.Directory +import qualified Build.InstallDesktopFile as InstallDesktopFile import qualified Build.Configure as Configure  main = defaultMainWithHooks simpleUserHooks@@ -25,6 +29,7 @@ myPostInst _ (InstallFlags { installVerbosity }) pkg lbi = do 	installGitAnnexShell dest verbosity pkg lbi 	installManpages      dest verbosity pkg lbi+	installDesktopFile   dest verbosity pkg lbi 	where 		dest      = NoCopyDest 		verbosity = fromFlag installVerbosity@@ -36,14 +41,23 @@ 	where 		dstBinDir = bindir $ absoluteInstallDirs pkg lbi copyDest --- See http://www.haskell.org/haskellwiki/Cabal/Developer-FAQ#Installing_manpages.------ Based on pandoc's Setup.hs.+{- See http://www.haskell.org/haskellwiki/Cabal/Developer-FAQ#Installing_manpages+ -+ - Man pages are provided prebuilt in the tarball in cabal,+ - but may not be available otherwise, in which case, skip installing them.+ -} installManpages :: CopyDest -> Verbosity -> PackageDescription -> LocalBuildInfo -> IO () installManpages copyDest verbosity pkg lbi =-	installOrdinaryFiles verbosity dstManDir srcManpages+	installOrdinaryFiles verbosity dstManDir =<< srcManpages 	where 		dstManDir   = mandir (absoluteInstallDirs pkg lbi copyDest) </> "man1"-		srcManpages = zip (repeat srcManDir) manpages+		srcManpages = zip (repeat srcManDir)+			<$> filterM doesFileExist manpages 		srcManDir   = "" 		manpages    = ["git-annex.1", "git-annex-shell.1"]++installDesktopFile :: CopyDest -> Verbosity -> PackageDescription -> LocalBuildInfo -> IO ()+installDesktopFile copyDest verbosity pkg lbi =+	InstallDesktopFile.writeDesktop $ dstBinDir </> "git-annex"+	where+		dstBinDir = bindir $ absoluteInstallDirs pkg lbi copyDest
Types/Command.hs view
@@ -38,7 +38,7 @@ 	{ cmdoptions :: [Option]     -- command-specific options 	, cmdnorepo :: Maybe (IO ()) -- an action to run when not in a repo 	, cmdcheck :: [CommandCheck] -- check stage-	, cmdoneshot :: Bool         -- don't save state after running+	, cmdnocommit :: Bool        -- don't commit journalled state changes 	, cmdname :: String 	, cmdparamdesc :: String     -- description of params for usage 	, cmdseek :: [CommandSeek]   -- seek stage
Types/Key.hs view
@@ -10,9 +10,10 @@ module Types.Key ( 	Key(..), 	stubKey,-	readKey,+	key2file,+	file2key, -	prop_idempotent_key_read_show+	prop_idempotent_key_encode ) where  import System.Posix.Types@@ -26,7 +27,7 @@ 	keyBackendName :: String, 	keySize :: Maybe Integer, 	keyMtime :: Maybe EpochTime-} deriving (Eq, Ord)+} deriving (Eq, Ord, Read, Show)  stubKey :: Key stubKey = Key {@@ -39,21 +40,21 @@ fieldSep :: Char fieldSep = '-' -{- Keys show as strings that are suitable for use as filenames.+{- Converts a key to a string that is suitable for use as a filename.  - The name field is always shown last, separated by doubled fieldSeps,  - and is the only field allowed to contain the fieldSep. -}-instance Show Key where-	show Key { keyBackendName = b, keySize = s, keyMtime = m, keyName = n } =-		b +++ ('s' ?: s) +++ ('m' ?: m) +++ (fieldSep : n)-		where-			"" +++ y = y-			x +++ "" = x-			x +++ y = x ++ fieldSep:y-			c ?: (Just v) = c : show v-			_ ?: _ = ""+key2file :: Key -> FilePath+key2file Key { keyBackendName = b, keySize = s, keyMtime = m, keyName = n } =+	b +++ ('s' ?: s) +++ ('m' ?: m) +++ (fieldSep : n)+	where+		"" +++ y = y+		x +++ "" = x+		x +++ y = x ++ fieldSep:y+		c ?: (Just v) = c : show v+		_ ?: _ = "" -readKey :: String -> Maybe Key-readKey s = if key == Just stubKey then Nothing else key+file2key :: FilePath -> Maybe Key+file2key s = if key == Just stubKey then Nothing else key 	where 		key = startbackend stubKey s @@ -73,5 +74,5 @@ 		addfield 'm' k v = Just k { keyMtime = readish v } 		addfield _ _ _ = Nothing -prop_idempotent_key_read_show :: Key -> Bool-prop_idempotent_key_read_show k = Just k == (readKey . show) k+prop_idempotent_key_encode :: Key -> Bool+prop_idempotent_key_encode k = Just k == (file2key . key2file) k
Types/Remote.hs view
@@ -36,6 +36,10 @@ {- A filename associated with a Key, for display to user. -} type AssociatedFile = Maybe FilePath +{- An action that can be run repeatedly, feeding it the number of+ - bytes sent or retrieved so far. -}+type MeterUpdate = (Integer -> IO ())+ {- An individual remote. -} data RemoteA a = Remote { 	-- each Remote has a unique uuid@@ -45,7 +49,7 @@ 	-- Remotes have a use cost; higher is more expensive 	cost :: Int, 	-- Transfers a key to the remote.-	storeKey :: Key -> AssociatedFile -> a Bool,+	storeKey :: Key -> AssociatedFile -> MeterUpdate -> a Bool, 	-- retrieves a key's contents to a file 	retrieveKeyFile :: Key -> AssociatedFile -> FilePath -> a Bool, 	-- retrieves a key's contents to a tmp file, if it can be done cheaply@@ -64,6 +68,10 @@ 	config :: Maybe RemoteConfig, 	-- git configuration for the remote 	repo :: Git.Repo,+	-- a Remote can be assocated with a specific local filesystem path+	localpath :: Maybe FilePath,+	-- a Remote can be known to be readonly+	readonly :: Bool, 	-- the type of the remote 	remotetype :: RemoteTypeA a }
Types/UUID.hs view
@@ -9,7 +9,7 @@  -- A UUID is either an arbitrary opaque string, or UUID info may be missing. data UUID = NoUUID | UUID String-	deriving (Eq, Ord, Show)+	deriving (Eq, Ord, Show, Read)  fromUUID :: UUID -> String fromUUID (UUID u) = u
Upgrade/V1.hs view
@@ -142,7 +142,7 @@ -- as the v2 key that it is. readKey1 :: String -> Key readKey1 v-	| mixup = fromJust $ readKey $ join ":" $ Prelude.tail bits+	| mixup = fromJust $ file2key $ join ":" $ Prelude.tail bits 	| otherwise = Key 		{ keyName = n 		, keyBackendName = b@@ -180,7 +180,8 @@ writeLog1 file ls = viaTmp writeFile file (showLog ls)  readLog1 :: FilePath -> IO [LogLine]-readLog1 file = catchDefaultIO (parseLog <$> readFileStrict file) []+readLog1 file = catchDefaultIO [] $+	parseLog <$> readFileStrict file  lookupFile1 :: FilePath -> Annex (Maybe (Key, Backend)) lookupFile1 file = do
Upgrade/V2.hs view
@@ -71,7 +71,7 @@ 		files <- mapM tryDirContents (concat levelb) 		return $ mapMaybe islogfile (concat files) 	where-		tryDirContents d = catchDefaultIO (dirContents d) []+		tryDirContents d = catchDefaultIO [] $ dirContents d 		islogfile f = maybe Nothing (\k -> Just (k, f)) $ 				logFileKey $ takeFileName f 
Utility/CoProcess.hs view
@@ -13,23 +13,23 @@ 	query ) where -import System.Cmd.Utils- import Common -type CoProcessHandle = (PipeHandle, Handle, Handle)+type CoProcessHandle = (ProcessHandle, Handle, Handle, CreateProcess) -start :: FilePath -> [String] -> IO CoProcessHandle-start command params = hPipeBoth command params+start :: FilePath -> [String] -> Maybe [(String, String)] -> IO CoProcessHandle+start command params env = do+	(from, to, _err, pid) <- runInteractiveProcess command params Nothing env+	return (pid, to, from, proc command params)  stop :: CoProcessHandle -> IO ()-stop (pid, from, to) = do+stop (pid, from, to, p) = do 	hClose to 	hClose from-	forceSuccess pid+	forceSuccessProcess p pid  query :: CoProcessHandle -> (Handle -> IO a) -> (Handle -> IO b) -> IO b-query (_, from, to) send receive = do+query (_, from, to, _) send receive = do 	_ <- send to 	hFlush to 	receive from
+ Utility/DBus.hs view
@@ -0,0 +1,28 @@+{- DBus utilities+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++{-# LANGUAGE OverloadedStrings #-}++module Utility.DBus where++import DBus.Client+import DBus+import Data.Maybe++type ServiceName = String++listServiceNames :: Client -> IO [ServiceName]+listServiceNames client = do+	reply <- callDBus client "ListNames" []+	return $ fromMaybe [] $ fromVariant (methodReturnBody reply !! 0)++callDBus :: Client -> MemberName -> [Variant] -> IO MethodReturn+callDBus client name params = call_ client $+	(methodCall "/org/freedesktop/DBus" "org.freedesktop.DBus" name)+		{ methodCallDestination = Just "org.freedesktop.DBus"+		, methodCallBody = params+		}
Utility/Daemon.hs view
@@ -27,7 +27,7 @@ 			_ <- forkProcess child2 			out 		child2 = do-			maybe noop (lockPidFile alreadyrunning) pidfile +			maybe noop lockPidFile pidfile  			when changedirectory $ 				setCurrentDirectory "/" 			nullfd <- openFd "/dev/null" ReadOnly Nothing defaultFileFlags@@ -39,47 +39,57 @@ 		redir newh h = do 			closeFd h 			dupTo newh h-		alreadyrunning = error "Daemon is already running." 		out = exitImmediately ExitSuccess  {- Locks the pid file, with an exclusive, non-blocking lock.- - Runs an action on failure. On success, writes the pid to the file,- - fully atomically. -}-lockPidFile :: IO () -> FilePath -> IO ()-lockPidFile onfailure file = do+ - Writes the pid to the file, fully atomically.+ - Fails if the pid file is already locked by another process. -}+lockPidFile :: FilePath -> IO ()+lockPidFile file = do+	createDirectoryIfMissing True (parentDir file) 	fd <- openFd file ReadWrite (Just stdFileMode) defaultFileFlags 	locked <- catchMaybeIO $ setLock fd (WriteLock, AbsoluteSeek, 0, 0) 	fd' <- openFd newfile ReadWrite (Just stdFileMode) defaultFileFlags 		{ trunc = True } 	locked' <- catchMaybeIO $ setLock fd' (WriteLock, AbsoluteSeek, 0, 0) 	case (locked, locked') of-		(Nothing, _) -> onfailure-		(_, Nothing) -> onfailure+		(Nothing, _) -> alreadyrunning+		(_, Nothing) -> alreadyrunning 		_ -> do 			_ <- fdWrite fd' =<< show <$> getProcessID 			renameFile newfile file 			closeFd fd 	where 		newfile = file ++ ".new"+		alreadyrunning = error "Daemon is already running." -{- Stops the daemon.- -- - The pid file is used to get the daemon's pid.+{- Checks if the daemon is running, by checking that the pid file+ - is locked by the same process that is listed in the pid file.  -- - To guard against a stale pid, check the lock of the pid file,- - and compare the process that has it locked with the file content.- -}-stopDaemon :: FilePath -> IO ()-stopDaemon pidfile = do-	fd <- openFd pidfile ReadOnly (Just stdFileMode) defaultFileFlags-	locked <- getLock fd (ReadLock, AbsoluteSeek, 0, 0)-	p <- readish <$> readFile pidfile-	case (locked, p) of-		(Nothing, _) -> noop-		(_, Nothing) -> noop-		(Just (pid, _), Just pid')-			| pid == pid' -> signalProcess sigTERM pid-			| otherwise -> error $+ - If it's running, returns its pid. -}+checkDaemon :: FilePath -> IO (Maybe ProcessID)+checkDaemon pidfile = do+	v <- catchMaybeIO $+		openFd pidfile ReadOnly (Just stdFileMode) defaultFileFlags+	case v of+		Just fd -> do+			locked <- getLock fd (ReadLock, AbsoluteSeek, 0, 0)+			p <- readish <$> readFile pidfile+			return $ check locked p+		Nothing -> return Nothing+	where+		check Nothing _ = Nothing+		check _ Nothing = Nothing+		check (Just (pid, _)) (Just pid')+			| pid == pid' = Just pid+			| otherwise = error $ 				"stale pid in " ++ pidfile ++  				" (got " ++ show pid' ++ -				"; expected" ++ show pid ++ " )"+				"; expected " ++ show pid ++ " )"++{- Stops the daemon, safely. -}+stopDaemon :: FilePath -> IO ()+stopDaemon pidfile = go =<< checkDaemon pidfile+	where+		go Nothing = noop+		go (Just pid) = signalProcess sigTERM pid
Utility/DirWatcher.hs view
@@ -17,10 +17,10 @@ #if WITH_INOTIFY import qualified Utility.INotify as INotify import qualified System.INotify as INotify-import Utility.ThreadScheduler #endif #if WITH_KQUEUE import qualified Utility.Kqueue as Kqueue+import Control.Concurrent #endif  type Pruner = FilePath -> Bool@@ -72,19 +72,55 @@ #endif #endif +/* With inotify, modifications to existing files can be tracked.+ * Kqueue does not support this.+ */+modifyTracked :: Bool #if WITH_INOTIFY-watchDir :: FilePath -> Pruner -> WatchHooks -> (IO () -> IO ()) -> IO ()-watchDir dir prune hooks runstartup = INotify.withINotify $ \i -> do+modifyTracked = True+#else+#if WITH_KQUEUE+modifyTracked = False+#else+modifyTracked = undefined+#endif+#endif++/* Starts a watcher thread. The runStartup action is passed a scanner action+ * to run, that will return once the initial directory scan is complete.+ * Once runStartup returns, the watcher thread continues running,+ * and processing events. Returns a DirWatcherHandle that can be used+ * to shutdown later.  */+#if WITH_INOTIFY+type DirWatcherHandle = INotify.INotify+watchDir :: FilePath -> Pruner -> WatchHooks -> (IO () -> IO ()) -> IO DirWatcherHandle+watchDir dir prune hooks runstartup = do+	i <- INotify.initINotify 	runstartup $ INotify.watchDir i dir prune hooks-	waitForTermination -- Let the inotify thread run.+	return i #else #if WITH_KQUEUE-watchDir :: FilePath -> Pruner -> WatchHooks -> (IO Kqueue.Kqueue -> IO Kqueue.Kqueue) -> IO ()+type DirWatcherHandle = ThreadId+watchDir :: FilePath -> Pruner -> WatchHooks -> (IO Kqueue.Kqueue -> IO Kqueue.Kqueue) -> IO DirWatcherHandle watchDir dir ignored hooks runstartup = do 	kq <- runstartup $ Kqueue.initKqueue dir ignored-	Kqueue.runHooks kq hooks+	forkIO $ Kqueue.runHooks kq hooks #else-watchDir :: FilePath -> Pruner -> WatchHooks -> (IO () -> IO ()) -> IO ()+type DirWatcherHandle = ()+watchDir :: FilePath -> Pruner -> WatchHooks -> (IO () -> IO ()) -> IO DirWatcherHandle watchDir = undefined+#endif+#endif++#if WITH_INOTIFY+stopWatchDir :: DirWatcherHandle -> IO ()+stopWatchDir = INotify.killINotify+#else+#if WITH_KQUEUE+stopWatchDir :: DirWatcherHandle -> IO ()+stopWatchDir = killThread+#else+stopWatchDir :: DirWatcherHandle -> IO ()+stopWatchDir = undefined #endif #endif
Utility/Directory.hs view
@@ -43,7 +43,7 @@ dirContentsRecursive' :: FilePath -> [FilePath] -> IO [FilePath] dirContentsRecursive' _ [] = return [] dirContentsRecursive' topdir (dir:dirs) = unsafeInterleaveIO $ do-	(files, dirs') <- collect [] [] =<< catchDefaultIO (dirContents (topdir </> dir)) []+	(files, dirs') <- collect [] [] =<< catchDefaultIO [] (dirContents (topdir </> dir)) 	files' <- dirContentsRecursive' topdir (dirs' ++ dirs) 	return (files ++ files') 	where
Utility/DiskFree.hs view
@@ -15,7 +15,7 @@ import Foreign.C.String import Foreign.C.Error -foreign import ccall unsafe "libdiskfree.h diskfree" c_diskfree+foreign import ccall safe "libdiskfree.h diskfree" c_diskfree 	:: CString -> IO CULLong  getDiskFree :: FilePath -> IO (Maybe Integer)
Utility/Exception.hs view
@@ -13,15 +13,15 @@  {- Catches IO errors and returns a Bool -} catchBoolIO :: IO Bool -> IO Bool-catchBoolIO a = catchDefaultIO a False+catchBoolIO a = catchDefaultIO False a  {- Catches IO errors and returns a Maybe -} catchMaybeIO :: IO a -> IO (Maybe a)-catchMaybeIO a = catchDefaultIO (Just <$> a) Nothing+catchMaybeIO a = catchDefaultIO Nothing $ Just <$> a  {- Catches IO errors and returns a default value. -}-catchDefaultIO :: IO a -> a -> IO a-catchDefaultIO a def = catchIO a (const $ return def)+catchDefaultIO :: a -> IO a -> IO a+catchDefaultIO def a = catchIO a (const $ return def)  {- Catches IO errors and returns the error message. -} catchMsgIO :: IO a -> IO (Either String a)
Utility/FileSystemEncoding.hs view
@@ -5,7 +5,13 @@  - Licensed under the GNU GPL version 3 or higher.  -} -module Utility.FileSystemEncoding where+module Utility.FileSystemEncoding (+	fileEncoding,+	withFilePath,+	md5FilePath,+	decodeW8,+	encodeW8	+) where  import qualified GHC.Foreign as GHC import qualified GHC.IO.Encoding as Encoding@@ -31,19 +37,28 @@ withFilePath fp f = Encoding.getFileSystemEncoding 	>>= \enc -> GHC.withCString enc fp f -{- Encodes a FilePath into a Md5.Str, applying the filesystem encoding.+{- Encodes a FilePath into a String, applying the filesystem encoding.  -+ - There are very few things it makes sense to do with such an encoded+ - string. It's not a legal filename; it should not be displayed.+ - So this function is not exported, but instead used by the few functions+ - that can usefully consume it.+ -  - This use of unsafePerformIO is belived to be safe; GHC's interface  - only allows doing this conversion with CStrings, and the CString buffer  - is allocated, used, and deallocated within the call, with no side  - effects.  -}-{-# NOINLINE encodeFilePath #-}-encodeFilePath :: FilePath -> MD5.Str-encodeFilePath fp = MD5.Str $ unsafePerformIO $ do+{-# NOINLINE _encodeFilePath #-}+_encodeFilePath :: FilePath -> String+_encodeFilePath fp = unsafePerformIO $ do 	enc <- Encoding.getFileSystemEncoding 	GHC.withCString enc fp $ GHC.peekCString Encoding.char8 +{- Encodes a FilePath into a Md5.Str, applying the filesystem encoding. -}+md5FilePath :: FilePath -> MD5.Str+md5FilePath = MD5.Str . _encodeFilePath+ {- Converts a [Word8] to a FilePath, encoding using the filesystem encoding.  -  - w82c produces a String, which may contain Chars that are invalid@@ -55,3 +70,8 @@ encodeW8 w8 = unsafePerformIO $ do 	enc <- Encoding.getFileSystemEncoding 	GHC.withCString Encoding.char8 (w82s w8) $ GHC.peekCString enc++{- Useful when you want the actual number of bytes that will be used to+ - represent the FilePath on disk. -}+decodeW8 :: FilePath -> [Word8]+decodeW8 = s2w8 . _encodeFilePath
+ Utility/FreeDesktop.hs view
@@ -0,0 +1,127 @@+{- Freedesktop.org specifications+ -+ - http://standards.freedesktop.org/basedir-spec/latest/+ - http://standards.freedesktop.org/desktop-entry-spec/latest/+ - http://standards.freedesktop.org/menu-spec/latest/+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++module Utility.FreeDesktop (+	DesktopEntry,	+	genDesktopEntry,+	buildDesktopMenuFile,+	writeDesktopMenuFile,+	desktopMenuFilePath,+	autoStartPath,+	systemDataDir,+	systemConfigDir,+	userDataDir,+	userConfigDir,+	userDesktopDir+) where++import Utility.Exception+import Utility.Path+import Utility.Process+import Utility.PartialPrelude++import System.Environment+import System.Directory+import System.FilePath+import Data.List+import Data.String.Utils+import Control.Applicative++type DesktopEntry = [(Key, Value)]++type Key = String++data Value = StringV String | BoolV Bool | NumericV Float | ListV [Value]++toString :: Value -> String+toString (StringV s) = s+toString (BoolV b)+	| b = "true"+	| otherwise = "false"+toString(NumericV f) = show f+toString (ListV l)+	| null l = ""+	| otherwise = (intercalate ";" $ map (escapesemi . toString) l) ++ ";"+	where+		escapesemi = join "\\;" . split ";"++genDesktopEntry :: String -> String -> Bool -> FilePath -> [String] -> DesktopEntry+genDesktopEntry name comment terminal program categories =+	[ item "Type" StringV "Application"+	, item "Version" NumericV 1.0+	, item "Name" StringV name+	, item "Comment" StringV comment+	, item "Terminal" BoolV terminal+	, item "Exec" StringV program+	, item "Categories" ListV (map StringV categories)+	]+	where+		item x c y = (x, c y)++buildDesktopMenuFile :: DesktopEntry -> String+buildDesktopMenuFile d = unlines ("[Desktop Entry]" : map keyvalue d) ++ "\n"+	where+		keyvalue (k, v) = k ++ "=" ++ toString v++writeDesktopMenuFile :: DesktopEntry -> String -> IO ()+writeDesktopMenuFile d file = do+	createDirectoryIfMissing True (parentDir file)+	writeFile file $ buildDesktopMenuFile d++{- Path to use for a desktop menu file, in either the systemDataDir or+ - the userDataDir -}+desktopMenuFilePath :: String -> FilePath -> FilePath+desktopMenuFilePath basename datadir = +	datadir </> "applications" </> desktopfile basename++{- Path to use for a desktop autostart file, in either the systemDataDir+ - or the userDataDir -}+autoStartPath :: String -> FilePath -> FilePath+autoStartPath basename configdir =+	configdir </> "autostart" </> desktopfile basename++desktopfile :: FilePath -> FilePath+desktopfile f = f ++ ".desktop"++{- Directory used for installation of system wide data files.. -}+systemDataDir :: FilePath+systemDataDir = "/usr/share"++{- Directory used for installation of system wide config files. -}+systemConfigDir :: FilePath+systemConfigDir = "/etc/xdg"++{- Directory for user data files. -}+userDataDir :: IO FilePath+userDataDir = xdgEnvHome "DATA_HOME" ".local/share"++{- Directory for user config files. -}+userConfigDir :: IO FilePath+userConfigDir = xdgEnvHome "CONFIG_HOME" ".config"++{- Directory for the user's Desktop, may be localized. + -+ - This is not looked up very fast; the config file is in a shell format+ - that is best parsed by shell, so xdg-user-dir is used, with a fallback+ - to ~/Desktop. -}+userDesktopDir :: IO FilePath+userDesktopDir = maybe fallback return =<< (parse <$> xdg_user_dir)+	where+		parse = maybe Nothing (headMaybe . lines)+		xdg_user_dir = catchMaybeIO $+			readProcess "xdg-user-dir" ["DESKTOP"]+		fallback = xdgEnvHome "DESKTOP_DIR" "Desktop"++xdgEnvHome :: String -> String -> IO String+xdgEnvHome envbase homedef = do+	home <- myHomeDir+	catchDefaultIO (home </> homedef) $+		getEnv $ "XDG_" ++ envbase
Utility/Gpg.hs view
@@ -11,8 +11,7 @@ import System.Posix.Types import Control.Applicative import Control.Concurrent-import Control.Exception (finally, bracket)-import System.Exit+import Control.Exception (bracket) import System.Posix.Env (setEnv, unsetEnv, getEnv)	  import Common@@ -39,18 +38,21 @@ readStrict :: [CommandParam] -> IO String readStrict params = do 	params' <- stdParams params-	pOpen ReadFromPipe "gpg" params' hGetContentsStrict+	withHandle StdoutHandle createProcessSuccess (proc "gpg" params') $ \h -> do+		hSetBinaryMode h True+		hGetContentsStrict h  {- Runs gpg, piping an input value to it, and returning its stdout,  - strictly. -} pipeStrict :: [CommandParam] -> String -> IO String pipeStrict params input = do 	params' <- stdParams params-	(pid, fromh, toh) <- hPipeBoth "gpg" params'-	_ <- forkIO $ finally (hPutStr toh input) (hClose toh)-	output <- hGetContentsStrict fromh-	forceSuccess pid-	return output+	withBothHandles createProcessSuccess (proc "gpg" params') $ \(to, from) -> do+		hSetBinaryMode to True+		hSetBinaryMode from True+		hPutStr to input+		hClose to+		hGetContentsStrict from  {- Runs gpg with some parameters, first feeding it a passphrase via  - --passphrase-fd, then feeding it an input, and passing a handle@@ -62,7 +64,7 @@ passphraseHandle params passphrase a b = do 	-- pipe the passphrase into gpg on a fd 	(frompipe, topipe) <- createPipe-	_ <- forkIO $ do+	void $ forkIO $ do 		toh <- fdToHandle topipe 		hPutStrLn toh passphrase 		hClose toh@@ -70,19 +72,14 @@ 	let passphrasefd = [Param "--passphrase-fd", Param $ show pfd]  	params' <- stdParams $ passphrasefd ++ params-	(pid, fromh, toh) <- hPipeBoth "gpg" params'-	pid2 <- forkProcess $ do-		L.hPut toh =<< a-		hClose toh-		exitSuccess-	hClose toh-	ret <- b fromh--	-- cleanup-	forceSuccess pid-	_ <- getProcessStatus True False pid2-	closeFd frompipe-	return ret+	closeFd frompipe `after`+		withBothHandles createProcessSuccess (proc "gpg" params') go+	where+		go (to, from) = do+			void $ forkIO $ do+				L.hPut to =<< a+				hClose to+			b from  {- Finds gpg public keys matching some string. (Could be an email address,  - a key id, or a name. -}
Utility/INotify.hs view
@@ -38,9 +38,8 @@  - Note: Moving a file will cause events deleting it from its old location  - and adding it to the new location.   - - - Note: Modification of files is not detected, and it's assumed that when- - a file that was open for write is closed, it's finished being written- - to, and can be added.+ - Note: It's assumed that when a file that was open for write is closed, + - it's finished being written to, and can be added.  -  - Note: inotify has a limit to the number of watches allowed,  - /proc/sys/fs/inotify/max_user_watches (default 8192).@@ -66,13 +65,16 @@ 		-- Select only inotify events required by the enabled 		-- hooks, but always include Create so new directories can 		-- be scanned.-		watchevents = Create : addevents ++ delevents+		watchevents = Create : addevents ++ delevents ++ modifyevents 		addevents 			| hashook addHook || hashook addSymlinkHook = [MoveIn, CloseWrite] 			| otherwise = [] 		delevents 			| hashook delHook || hashook delDirHook = [MoveOut, Delete] 			| otherwise = []+		modifyevents+			| hashook modifyHook = [Modify]+			| otherwise = []  		scan f = unless (ignored f) $ do 			ms <- getstatus f@@ -114,6 +116,9 @@ 			| otherwise = guarded $ runhook delHook f Nothing 			where 				guarded = unlessM (filetype (const True) f)+		go (Modified { isDirectory = isd, maybeFilePath = Just f })+			| isd = noop+			| otherwise = runhook modifyHook f Nothing 		go _ = noop  		hashook h = isJust $ h hooks@@ -160,12 +165,9 @@  querySysctl :: Read a => [CommandParam] -> IO (Maybe a) querySysctl ps = do-	v <- catchMaybeIO $ hPipeFrom "sysctl" $ toCommand ps+	v <- catchMaybeIO $ readProcess "sysctl" (toCommand ps) 	case v of 		Nothing -> return Nothing-		Just (pid, h) -> do-			val <- parsesysctl <$> hGetContentsStrict h-			void $ getProcessStatus True False $ processID pid-			return val+		Just s -> return $ parsesysctl s 	where 		parsesysctl s = readish =<< lastMaybe (words s)
Utility/Kqueue.hs view
@@ -14,8 +14,6 @@ 	waitChange, 	Change(..), 	changedFile,-	isAdd,-	isDelete, 	runHooks, ) where @@ -34,19 +32,19 @@  data Change 	= Deleted FilePath+	| DeletedDir FilePath 	| Added FilePath 	deriving (Show)  isAdd :: Change -> Bool isAdd (Added _) = True isAdd (Deleted _) = False--isDelete :: Change -> Bool-isDelete = not . isAdd+isAdd (DeletedDir _) = False  changedFile :: Change -> FilePath changedFile (Added f) = f changedFile (Deleted f) = f+changedFile (DeletedDir f) = f  data Kqueue = Kqueue  	{ kqueueFd :: Fd@@ -59,27 +57,43 @@  type DirMap = M.Map Fd DirInfo -{- A directory, and its last known contents (with filenames relative to it) -}+{- Enough information to uniquely identify a file in a directory,+ - but not too much. -}+data DirEnt = DirEnt+	{ dirEnt :: FilePath -- relative to the parent directory+	, _dirInode :: FileID -- included to notice file replacements+	, isSubDir :: Bool+	}+	deriving (Eq, Ord, Show)++{- A directory, and its last known contents. -} data DirInfo = DirInfo 	{ dirName :: FilePath-	, dirCache :: S.Set FilePath+	, dirCache :: S.Set DirEnt 	} 	deriving (Show)  getDirInfo :: FilePath -> IO DirInfo getDirInfo dir = do-	contents <- S.fromList . filter (not . dirCruft)-		<$> getDirectoryContents dir+	l <- filter (not . dirCruft) <$> getDirectoryContents dir+	contents <- S.fromList . catMaybes <$> mapM getDirEnt l 	return $ DirInfo dir contents+	where+		getDirEnt f = catchMaybeIO $ do+			s <- getFileStatus (dir </> f)+			return $ DirEnt f (fileID s) (isDirectory s)  {- Difference between the dirCaches of two DirInfos. -} (//) :: DirInfo -> DirInfo -> [Change] oldc // newc = deleted ++ added 	where-		deleted = calc Deleted oldc newc-		added   = calc Added newc oldc-		calc a x y = map a . map (dirName x </>) $-			S.toList $ S.difference (dirCache x) (dirCache y)+		deleted = calc gendel oldc newc+		added   = calc genadd newc oldc+		gendel x = (if isSubDir x then DeletedDir else Deleted) $+			dirName oldc </> dirEnt x+		genadd x = Added $ dirName newc </> dirEnt x+		calc a x y = map a $ S.toList $+			S.difference (dirCache x) (dirCache y)  {- Builds a map of directories in a tree, possibly pruning some.  - Opens each directory in the tree, and records its current contents. -}@@ -99,7 +113,7 @@ 						case mfd of 							Nothing -> walk c rest 							Just fd -> do-								let subdirs = map (dir </>) $+								let subdirs = map (dir </>) . map dirEnt $ 									S.toList $ dirCache info 								walk ((fd, info):c) (subdirs ++ rest) @@ -123,15 +137,16 @@ findDirContents :: DirMap -> FilePath -> [FilePath] findDirContents dirmap dir = concatMap absolutecontents $ search 	where-		absolutecontents i = map (dirName i </>) (S.toList $ dirCache i)+		absolutecontents i = map (dirName i </>)+			(map dirEnt $ S.toList $ dirCache i) 		search = map snd $ M.toList $ 			M.filter (\i -> dirName i == dir) dirmap -foreign import ccall unsafe "libkqueue.h init_kqueue" c_init_kqueue+foreign import ccall safe "libkqueue.h init_kqueue" c_init_kqueue 	:: IO Fd-foreign import ccall unsafe "libkqueue.h addfds_kqueue" c_addfds_kqueue+foreign import ccall safe "libkqueue.h addfds_kqueue" c_addfds_kqueue 	:: Fd -> CInt -> Ptr Fd -> IO ()-foreign import ccall unsafe "libkqueue.h waitchange_kqueue" c_waitchange_kqueue+foreign import ccall safe "libkqueue.h waitchange_kqueue" c_waitchange_kqueue 	:: Fd -> IO Fd  {- Initializes a Kqueue to watch a directory, and all its subdirectories. -}@@ -224,12 +239,14 @@ 			(q', changes) <- waitChange q 			forM_ changes $ dispatch (kqueueMap q') 			loop q'-		-- Kqueue returns changes for both whole directories-		-- being added and deleted, and individual files being-		-- added and deleted.-		dispatch dirmap change-			| isAdd change = withstatus change $ dispatchadd dirmap-			| otherwise = callhook delDirHook Nothing change++		dispatch _ change@(Deleted _) = +			callhook delHook Nothing change+		dispatch _ change@(DeletedDir _) =+			callhook delDirHook Nothing change+		dispatch dirmap change@(Added _) =+			withstatus change $ dispatchadd dirmap+		 		dispatchadd dirmap change s 			| Files.isSymbolicLink s = 				callhook addSymlinkHook (Just s) change@@ -237,12 +254,15 @@ 			| Files.isRegularFile s = 				callhook addHook (Just s) change 			| otherwise = noop+ 		recursiveadd dirmap change = do 			let contents = findDirContents dirmap $ changedFile change 			forM_ contents $ \f -> 				withstatus (Added f) $ dispatchadd dirmap+ 		callhook h s change = case h hooks of 			Nothing -> noop 			Just a -> a (changedFile change) s+ 		withstatus change a = maybe noop (a change) =<< 			(catchMaybeIO (getSymbolicLinkStatus (changedFile change)))
Utility/Lsof.hs view
@@ -33,11 +33,11 @@  - Note: If lsof is not available, this always returns [] !  -} query :: [String] -> IO [(FilePath, LsofOpenMode, ProcessInfo)]-query opts = do-	(pid, s) <- pipeFrom "lsof" ("-F0can" : opts)-	let !r = parse s-	void $ getProcessStatus True False $ processID pid-	return r+query opts =+	withHandle StdoutHandle (createProcessChecked checkSuccessProcess) p $ \h -> do+		parse <$> hGetContentsStrict h+	where+		p = proc "lsof" ("-F0can" : opts)  {- Parsing null-delimited output like:  -
Utility/Misc.hs view
@@ -9,6 +9,9 @@  import System.IO import Control.Monad+import Foreign+import Data.Char+import Control.Applicative  {- A version of hgetContents that is not lazy. Ensures file is   - all read before it gets closed. -}@@ -33,7 +36,7 @@ 			| otherwise = (a, tail b)  {- Breaks out the first line. -}-firstLine :: String-> String+firstLine :: String -> String firstLine = takeWhile (/= '\n')  {- Splits a list into segments that are delimited by items matching@@ -45,3 +48,33 @@ 		go c r (i:is) 			| p i = go [] (c:r) is 			| otherwise = go (i:c) r is++{- Given two orderings, returns the second if the first is EQ and returns+ - the first otherwise.+ -+ - Example use:+ -+ - compare lname1 lname2 `thenOrd` compare fname1 fname2+ -}+thenOrd :: Ordering -> Ordering -> Ordering+thenOrd EQ x = x+thenOrd x _ = x+{-# INLINE thenOrd #-}++{- Wrapper around hGetBufSome that returns a String.+ -+ - The null string is returned on eof, otherwise returns whatever+ - data is currently available to read from the handle, or waits for+ - data to be written to it if none is currently available.+ - + - Note on encodings: The normal encoding of the Handle is ignored;+ - each byte is converted to a Char. Not unicode clean!+ -}+hGetSomeString :: Handle -> Int -> IO String+hGetSomeString h sz = do+	fp <- mallocForeignPtrBytes sz+	len <- withForeignPtr fp $ \buf -> hGetBufSome h buf sz+	map (chr . fromIntegral) <$> withForeignPtr fp (peekbytes len)+	where+		peekbytes :: Int -> Ptr Word8 -> IO [Word8]+		peekbytes len buf = mapM (peekElemOff buf) [0..pred len]
+ Utility/Mounts.hsc view
@@ -0,0 +1,69 @@+{- Interface to mtab (and fstab)+ - + - Derived from hsshellscript, originally written by+ - Volker Wysk <hsss@volker-wysk.de>+ - + - Modified to support BSD and Mac OS X by+ - Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU LGPL version 2.1 or higher.+ -}++{-# LANGUAGE ForeignFunctionInterface #-}++module Utility.Mounts (+	Mntent(..),+	getMounts+) where++import Control.Monad+import Foreign+import Foreign.C+import GHC.IO hiding (finally, bracket)+import Prelude hiding (catch)++#include "libmounts.h"++{- This is a stripped down mntent, containing only+ - fields available everywhere. -}+data Mntent = Mntent+	{ mnt_fsname :: String+	, mnt_dir :: FilePath+	, mnt_type :: String+	} deriving (Read, Show, Eq, Ord)++getMounts :: IO [Mntent]+getMounts = do+	h <- c_mounts_start+	when (h == nullPtr) $+		throwErrno "getMounts"+	mntent <- getmntent h []+	_ <- c_mounts_end h+	return mntent++	where+		getmntent h c = do+			ptr <- c_mounts_next h+			if (ptr == nullPtr)+				then return $ reverse c+				else do+					mnt_fsname_str <- #{peek struct mntent, mnt_fsname} ptr >>= peekCString+					mnt_dir_str <- #{peek struct mntent, mnt_dir} ptr >>= peekCString+					mnt_type_str <- #{peek struct mntent, mnt_type} ptr >>= peekCString+					let ent = Mntent+						{ mnt_fsname = mnt_fsname_str+						, mnt_dir = mnt_dir_str+						, mnt_type = mnt_type_str+						}+					getmntent h (ent:c)++{- Using unsafe imports because the C functions are belived to never block.+ - Note that getmntinfo is called with MNT_NOWAIT to avoid possibly blocking;+ - while getmntent only accesses a file in /etc (or /proc) that should not+ - block. -}+foreign import ccall unsafe "libmounts.h mounts_start" c_mounts_start+        :: IO (Ptr ())+foreign import ccall unsafe "libmounts.h mounts_next" c_mounts_next+        :: Ptr () -> IO (Ptr ())+foreign import ccall unsafe "libmounts.h mounts_end" c_mounts_end+        :: Ptr () -> IO CInt
+ Utility/Network.hs view
@@ -0,0 +1,22 @@+{- network functions+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++module Utility.Network where++import Utility.Process+import Utility.Exception++import Control.Applicative++{- Haskell lacks uname(2) bindings, except in the+ - Bindings.Uname addon. Rather than depend on that,+ - use uname -n when available. -}+getHostname :: IO (Maybe String)+getHostname = catchMaybeIO uname_node+	where+		uname_node = takeWhile (/= '\n') <$>+			readProcess "uname" ["-n"]	
+ Utility/NotificationBroadcaster.hs view
@@ -0,0 +1,77 @@+{- notification broadcaster+ -+ - This is used to allow clients to block until there is a new notification+ - that some thing occurred. It does not communicate what the change is,+ - it only provides blocking reads to wait on notifications.+ -+ - Multiple clients are supported. Each has a unique id.+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++module Utility.NotificationBroadcaster (+	NotificationBroadcaster,+	NotificationHandle,+	NotificationId,+	newNotificationBroadcaster,+	newNotificationHandle,+	notificationHandleToId,+	notificationHandleFromId,+	sendNotification,+	waitNotification,+) where++import Common++import Control.Concurrent.STM+import Control.Concurrent.SampleVar++{- One SampleVar per client. The TMVar is never empty, so never blocks. -}+type NotificationBroadcaster = TMVar [SampleVar ()]++newtype NotificationId = NotificationId Int+	deriving (Read, Show, Eq, Ord)++{- Handle given out to an individual client. -}+data NotificationHandle = NotificationHandle NotificationBroadcaster NotificationId++newNotificationBroadcaster :: IO NotificationBroadcaster+newNotificationBroadcaster = atomically $ newTMVar []++{- Allocates a notification handle for a client to use. -}+newNotificationHandle :: NotificationBroadcaster -> IO NotificationHandle+newNotificationHandle b = NotificationHandle+	<$> pure b+	<*> addclient+	where+		addclient = do+			s <- newEmptySampleVar+			atomically $ do+				l <- takeTMVar b+				putTMVar b $ l ++ [s]+				return $ NotificationId $ length l++{- Extracts the identifier from a notification handle.+ - This can be used to eg, pass the identifier through to a WebApp. -}+notificationHandleToId :: NotificationHandle -> NotificationId+notificationHandleToId (NotificationHandle _ i) = i++notificationHandleFromId :: NotificationBroadcaster -> NotificationId -> NotificationHandle+notificationHandleFromId = NotificationHandle++{- Sends a notification to all clients. -}+sendNotification :: NotificationBroadcaster -> IO ()+sendNotification b = do+	l <- atomically $ readTMVar b+	mapM_ notify l+	where+		notify s = writeSampleVar s ()++{- Used by a client to block until a new notification is available since+ - the last time it tried. -}+waitNotification :: NotificationHandle -> IO ()+waitNotification (NotificationHandle b (NotificationId i)) = do+	l <- atomically $ readTMVar b+	readSampleVar (l !! i)
+ Utility/Parallel.hs view
@@ -0,0 +1,35 @@+{- parallel processing via threads+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++module Utility.Parallel where++import Common++import Control.Concurrent+import Control.Exception++{- Runs an action in parallel with a set of values, in a set of threads.+ - In order for the actions to truely run in parallel, requires GHC's+ - threaded runtime, + -+ - Returns the values partitioned into ones with which the action succeeded,+ - and ones with which it failed. -}+inParallel :: (v -> IO Bool) -> [v] -> IO ([v], [v])+inParallel a l = do+	mvars <- mapM thread l+	statuses <- mapM takeMVar mvars+	return $ reduce $ partition snd $ zip l statuses+	where+		reduce (x,y) = (map fst x, map fst y)+		thread v = do+			mvar <- newEmptyMVar+			_ <- forkIO $ do+				r <- try (a v) :: IO (Either SomeException Bool)+				case r of+					Left _ -> putMVar mvar False+					Right b -> putMVar mvar b+			return mvar
Utility/Path.hs view
@@ -132,6 +132,14 @@ myHomeDir :: IO FilePath myHomeDir = homeDirectory <$> (getUserEntryForID =<< getEffectiveUserID) +{- Converts paths in the home directory to use ~/ -}+relHome :: FilePath -> IO String+relHome path = do+	home <- myHomeDir+	return $ if dirContains home path+		then "~/" ++ relPathDirToFile home path+		else path+ {- Checks if a command is available in PATH. -} inPath :: String -> IO Bool inPath command = getSearchPath >>= anyM indir
+ Utility/Process.hs view
@@ -0,0 +1,245 @@+{- System.Process enhancements, including additional ways of running+ - processes, and logging.+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++{-# LANGUAGE Rank2Types #-}++module Utility.Process (+	module X,+	CreateProcess,+	StdHandle(..),+	readProcess,+	readProcessEnv,+	writeReadProcessEnv,+	forceSuccessProcess,+	checkSuccessProcess,+	ignoreFailureProcess,+	createProcessSuccess,+	createProcessChecked,+	createBackgroundProcess,+	withHandle,+	withBothHandles,+	createProcess,+	runInteractiveProcess,+	stdinHandle,+	stdoutHandle,+	stderrHandle,+) where++import qualified System.Process+import System.Process as X hiding (CreateProcess(..), createProcess, runInteractiveProcess, readProcess, readProcessWithExitCode, system, rawSystem, runInteractiveCommand, runProcess)+import System.Process hiding (createProcess, runInteractiveProcess, readProcess)+import System.Exit+import System.IO+import System.Log.Logger+import Control.Concurrent+import qualified Control.Exception as E+import Control.Monad++import Utility.Misc++type CreateProcessRunner = forall a. CreateProcess -> ((Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle) -> IO a) -> IO a++data StdHandle = StdinHandle | StdoutHandle | StderrHandle+	deriving (Eq)++{- Normally, when reading from a process, it does not need to be fed any+ - standard input. -}+readProcess :: FilePath	-> [String] -> IO String+readProcess cmd args = readProcessEnv cmd args Nothing++readProcessEnv :: FilePath -> [String] -> Maybe [(String, String)] -> IO String+readProcessEnv cmd args environ =+	withHandle StdoutHandle createProcessSuccess p $ \h -> do+		output  <- hGetContentsStrict h+		hClose h+		return output+	where+		p = (proc cmd args)+			{ std_out = CreatePipe+			, env = environ+			}++{- Writes stdout to a process, returns its output, and also allows specifying+ - the environment. -}+writeReadProcessEnv+	:: FilePath+	-> [String]+	-> Maybe [(String, String)]+	-> String	+	-> IO String+writeReadProcessEnv cmd args environ input = do+	(Just inh, Just outh, _, pid) <- createProcess p++	-- fork off a thread to start consuming the output+	output  <- hGetContents outh+	outMVar <- newEmptyMVar+	_ <- forkIO $ E.evaluate (length output) >> putMVar outMVar ()++	-- now write and flush any input+	when (not (null input)) $ do hPutStr inh input; hFlush inh+	hClose inh -- done with stdin++	-- wait on the output+	takeMVar outMVar+	hClose outh++	-- wait on the process+	forceSuccessProcess p pid++	return output++	where+		p = (proc cmd args)+			{ std_in = CreatePipe+			, std_out = CreatePipe+			, std_err = Inherit+			, env = environ+			}++{- Waits for a ProcessHandle, and throws an exception if the process+ - did not exit successfully. -}+forceSuccessProcess :: CreateProcess -> ProcessHandle -> IO ()+forceSuccessProcess p pid = do+	code <- waitForProcess pid+	case code of+		ExitSuccess -> return ()+		ExitFailure n -> error $ showCmd p ++ " exited " ++ show n++{- Waits for a ProcessHandle and returns True if it exited successfully. -}+checkSuccessProcess :: ProcessHandle -> IO Bool+checkSuccessProcess pid = do+	code <- waitForProcess pid+	return $ code == ExitSuccess++ignoreFailureProcess :: ProcessHandle -> IO ()+ignoreFailureProcess = void . waitForProcess++{- Runs createProcess, then an action on its handles, and then+ - forceSuccessProcess. -}+createProcessSuccess :: CreateProcessRunner+createProcessSuccess p a = createProcessChecked (forceSuccessProcess p) p a++{- Runs createProcess, then an action on its handles, and then+ - an action on its exit code. -}+createProcessChecked :: (ProcessHandle -> IO b) -> CreateProcessRunner+createProcessChecked checker p a = do+	t@(_, _, _, pid) <- createProcess p+	r <- a t+	_ <- checker pid+	return r++{- Leaves the process running, suitable for lazy streaming.+ - Note: Zombies will result, and must be waited on. -}+createBackgroundProcess :: CreateProcessRunner+createBackgroundProcess p a = a =<< createProcess p++{- Runs a CreateProcessRunner, on a CreateProcess structure, that+ - is adjusted to pipe only from/to a single StdHandle, and passes+ - the resulting Handle to an action. -}+withHandle+	:: StdHandle+	-> CreateProcessRunner+	-> CreateProcess+	-> (Handle -> IO a)+	-> IO a+withHandle h creator p a = creator p' $ a . select+	where+		base = p+			{ std_in = Inherit+			, std_out = Inherit+			, std_err = Inherit+			}+		(select, p')+			| h == StdinHandle  =+				(stdinHandle, base { std_in = CreatePipe })+			| h == StdoutHandle =+				(stdoutHandle, base { std_out = CreatePipe })+			| h == StderrHandle =+				(stderrHandle, base { std_err = CreatePipe })++{- Like withHandle, but passes (stdin, stdout) handles to the action. -}+withBothHandles+	:: CreateProcessRunner+	-> CreateProcess+	-> ((Handle, Handle) -> IO a)+	-> IO a+withBothHandles creator p a = creator p' $ a . bothHandles+	where+		p' = p+			{ std_in = CreatePipe+			, std_out = CreatePipe+			, std_err = Inherit+			}++{- Extract a desired handle from createProcess's tuple.+ - These partial functions are safe as long as createProcess is run+ - with appropriate parameters to set up the desired handle.+ - Get it wrong and the runtime crash will always happen, so should be+ - easily noticed. -}+type HandleExtractor = (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle) -> Handle+stdinHandle :: HandleExtractor+stdinHandle (Just h, _, _, _) = h+stdinHandle _ = error "expected stdinHandle"+stdoutHandle :: HandleExtractor+stdoutHandle (_, Just h, _, _) = h+stdoutHandle _ = error "expected stdoutHandle"+stderrHandle :: HandleExtractor+stderrHandle (_, _, Just h, _) = h+stderrHandle _ = error "expected stderrHandle"+bothHandles :: (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle) -> (Handle, Handle)+bothHandles (Just hin, Just hout, _, _) = (hin, hout)+bothHandles _ = error "expected bothHandles"++{- Debugging trace for a CreateProcess. -}+debugProcess :: CreateProcess -> IO ()+debugProcess p = do+	debugM "Utility.Process" $ unwords+		[ action ++ ":"+		, showCmd p+		, maybe "" show (env p)+		]+	where+		action+			| piped (std_in p) && piped (std_out p) = "chat"+			| piped (std_in p)                      = "feed"+			| piped (std_out p)                     = "read"+			| otherwise                             = "call"+		piped Inherit = False+		piped _ = True++{- Shows the command that a CreateProcess will run. -}+showCmd :: CreateProcess -> String+showCmd = go . cmdspec+	where+		go (ShellCommand s) = s+		go (RawCommand c ps) = c ++ " " ++ show ps++{- Wrappers for System.Process functions that do debug logging.+ - + - More could be added, but these are the only ones I usually need.+ -}++createProcess :: CreateProcess -> IO (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle)+createProcess p = do+	debugProcess p+	System.Process.createProcess p++runInteractiveProcess+	:: FilePath	+	-> [String]	+	-> Maybe FilePath	+	-> Maybe [(String, String)]	+	-> IO (Handle, Handle, Handle, ProcessHandle)+runInteractiveProcess f args c e = do+	debugProcess $ (proc f args)+			{ std_in = CreatePipe+			, std_out = CreatePipe+			, std_err = CreatePipe+			, env = e+			}+	System.Process.runInteractiveProcess f args c e
+ Utility/Rsync.hs view
@@ -0,0 +1,126 @@+{- various rsync stuff+ -+ - Copyright 2010-2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++module Utility.Rsync where++import Common++import Data.Char++{- Generates parameters to make rsync use a specified command as its remote+ - shell. -}+rsyncShell :: [CommandParam] -> [CommandParam]+rsyncShell command = [Param "-e", Param $ unwords $ map escape (toCommand command)]+	where+		{- rsync requires some weird, non-shell like quoting in+                 - here. A doubled single quote inside the single quoted+                 - string is a single quote. -}+		escape s = "'" ++  join "''" (split "'" s) ++ "'"++{- Runs rsync in server mode to send a file. -}+rsyncServerSend :: FilePath -> IO Bool+rsyncServerSend file = rsync $+	rsyncServerParams ++ [Param "--sender", File file]++{- Runs rsync in server mode to receive a file. -}+rsyncServerReceive :: FilePath -> IO Bool+rsyncServerReceive file = rsync $ rsyncServerParams ++ [File file]++rsyncServerParams :: [CommandParam]+rsyncServerParams =+	[ Param "--server"+	-- preserve permissions+	, Param "-p"+	-- preserve timestamps+	, Param "-t"+	-- allow resuming of transfers of big files+	, Param "--inplace"+	-- other options rsync normally uses in server mode+	, Params "-e.Lsf ."+	]++rsync :: [CommandParam] -> IO Bool+rsync = boolSystem "rsync"++{- Runs rsync, but intercepts its progress output and feeds bytes+ - complete values into the callback. The progress output is also output+ - to stdout. + -+ - The params must enable rsync's --progress mode for this to work.+ -}+rsyncProgress :: (Integer -> IO ()) -> [CommandParam] -> IO Bool+rsyncProgress callback params = catchBoolIO $+	withHandle StdoutHandle createProcessSuccess p (feedprogress 0 [])+	where+		p = proc "rsync" (toCommand params)+		feedprogress prev buf h = do+			s <- hGetSomeString h 80+			if null s+				then return True+				else do+					putStr s+					hFlush stdout+					let (mbytes, buf') = parseRsyncProgress (buf++s)+					case mbytes of+						Nothing -> feedprogress prev buf' h+						(Just bytes) -> do+							when (bytes /= prev) $+								callback bytes+							feedprogress bytes buf' h++{- Checks if an rsync url involves the remote shell (ssh or rsh).+ - Use of such urls with rsync requires additional shell+ - escaping. -}+rsyncUrlIsShell :: String -> Bool+rsyncUrlIsShell s+	| "rsync://" `isPrefixOf` s = False+	| otherwise = go s+	where+		-- host::dir is rsync protocol, while host:dir is ssh/rsh+		go [] = False+		go (c:cs)+			| c == '/' = False -- got to directory with no colon+			| c == ':' = not $ ":" `isPrefixOf` cs+			| otherwise = go cs++{- Checks if a rsync url is really just a local path. -}+rsyncUrlIsPath :: String -> Bool+rsyncUrlIsPath s+	| rsyncUrlIsShell s = False+	| otherwise = ':' `notElem` s++{- Parses the String looking for rsync progress output, and returns+ - Maybe the number of bytes rsynced so far, and any any remainder of the+ - string that could be an incomplete progress output. That remainder+ - should be prepended to future output, and fed back in. This interface+ - allows the output to be read in any desired size chunk, or even one+ - character at a time.+ -+ - Strategy: Look for chunks prefixed with \r (rsync writes a \r before+ - the first progress output, and each thereafter). The first number+ - after the \r is the number of bytes processed. After the number,+ - there must appear some whitespace, or we didn't get the whole number,+ - and return the \r and part we did get, for later processing.+ -}+parseRsyncProgress :: String -> (Maybe Integer, String)+parseRsyncProgress = go [] . reverse . progresschunks+	where+		go remainder [] = (Nothing, remainder)+		go remainder (x:xs) = case parsebytes (findbytesstart x) of+			Nothing -> go (delim:x++remainder) xs+			Just b -> (Just b, remainder)++		delim = '\r'+		{- Find chunks that each start with delim.+		 - The first chunk doesn't start with it+		 - (it's empty when delim is at the start of the string). -}+		progresschunks = drop 1 . split [delim]+		findbytesstart s = dropWhile isSpace s+		parsebytes s = case break isSpace s of+			([], _) -> Nothing+			(_, []) -> Nothing+			(b, _) -> readish b
− Utility/RsyncFile.hs
@@ -1,63 +0,0 @@-{- file copying with rsync- -- - Copyright 2010 Joey Hess <joey@kitenet.net>- -- - Licensed under the GNU GPL version 3 or higher.- -}--module Utility.RsyncFile where--import Data.String.Utils-import Data.List--import Utility.SafeCommand--{- Generates parameters to make rsync use a specified command as its remote- - shell. -}-rsyncShell :: [CommandParam] -> [CommandParam]-rsyncShell command = [Param "-e", Param $ unwords $ map escape (toCommand command)]-	where-		{- rsync requires some weird, non-shell like quoting in-                 - here. A doubled single quote inside the single quoted-                 - string is a single quote. -}-		escape s = "'" ++  join "''" (split "'" s) ++ "'"--{- Runs rsync in server mode to send a file. -}-rsyncServerSend :: FilePath -> IO Bool-rsyncServerSend file = rsync $-	rsyncServerParams ++ [Param "--sender", File file]--{- Runs rsync in server mode to receive a file. -}-rsyncServerReceive :: FilePath -> IO Bool-rsyncServerReceive file = rsync $ rsyncServerParams ++ [File file]--rsyncServerParams :: [CommandParam]-rsyncServerParams =-	[ Param "--server"-	-- preserve permissions-	, Param "-p"-	-- preserve timestamps-	, Param "-t"-	-- allow resuming of transfers of big files-	, Param "--inplace"-	-- other options rsync normally uses in server mode-	, Params "-e.Lsf ."-	]--rsync :: [CommandParam] -> IO Bool-rsync = boolSystem "rsync"--{- Checks if an rsync url involves the remote shell (ssh or rsh).- - Use of such urls with rsync requires additional shell- - escaping. -}-rsyncUrlIsShell :: String -> Bool-rsyncUrlIsShell s-	| "rsync://" `isPrefixOf` s = False-	| otherwise = go s-	where-		-- host::dir is rsync protocol, while host:dir is ssh/rsh-		go [] = False-		go (c:cs)-			| c == '/' = False -- got to directory with no colon-			| c == ':' = not $ ":" `isPrefixOf` cs-			| otherwise = go cs
Utility/SafeCommand.hs view
@@ -1,6 +1,6 @@ {- safely running shell commands  -- - Copyright 2010-2011 Joey Hess <joey@kitenet.net>+ - Copyright 2010-2012 Joey Hess <joey@kitenet.net>  -  - Licensed under the GNU GPL version 3 or higher.  -}@@ -8,11 +8,9 @@ module Utility.SafeCommand where  import System.Exit-import qualified System.Posix.Process-import System.Posix.Process hiding (executeFile)-import System.Posix.Signals+import Utility.Process+import System.Process (env) import Data.String.Utils-import System.Log.Logger import Control.Applicative  {- A type for parameters passed to a shell command. A command can@@ -42,7 +40,7 @@ boolSystem command params = boolSystemEnv command params Nothing  boolSystemEnv :: FilePath -> [CommandParam] -> Maybe [(String, String)] -> IO Bool-boolSystemEnv command params env = dispatch <$> safeSystemEnv command params env+boolSystemEnv command params environ = dispatch <$> safeSystemEnv command params environ 	where 		dispatch ExitSuccess = True 		dispatch _ = False@@ -51,36 +49,13 @@ safeSystem :: FilePath -> [CommandParam] -> IO ExitCode safeSystem command params = safeSystemEnv command params Nothing -{- SIGINT(ctrl-c) is allowed to propigate and will terminate the program. -}+{- Unlike many implementations of system, SIGINT(ctrl-c) is allowed+ - to propigate and will terminate the program. -} safeSystemEnv :: FilePath -> [CommandParam] -> Maybe [(String, String)] -> IO ExitCode-safeSystemEnv command params env = do-	-- Going low-level because all the high-level system functions-	-- block SIGINT etc. We need to block SIGCHLD, but allow-	-- SIGINT to do its default program termination.-	let sigset = addSignal sigCHLD emptySignalSet-	oldint <- installHandler sigINT Default Nothing-	oldset <- getSignalMask-	blockSignals sigset-	childpid <- forkProcess $ childaction oldint oldset-	mps <- getProcessStatus True False childpid-	restoresignals oldint oldset-	case mps of-		Just (Exited code) -> return code-		_ -> error $ "unknown error running " ++ command-	where-		restoresignals oldint oldset = do-			_ <- installHandler sigINT oldint Nothing-			setSignalMask oldset-		childaction oldint oldset = do-			restoresignals oldint oldset-			executeFile command True (toCommand params) env--{- executeFile with debug logging -}-executeFile :: FilePath -> Bool -> [String] -> Maybe [(String, String)] -> IO ()-executeFile c path p e = do-	debugM "Utility.SafeCommand.executeFile" $-		"Running: " ++ c ++ " " ++ show p ++ " " ++ maybe "" show e-	System.Posix.Process.executeFile c path p e+safeSystemEnv command params environ = do+	(_, _, _, pid) <- createProcess (proc command $ toCommand params)+		{ env = environ }+	waitForProcess pid  {- Escapes a filename or other parameter to be safely able to be exposed to  - the shell. -}
+ Utility/TSet.hs view
@@ -0,0 +1,39 @@+{- Transactional sets+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -}++module Utility.TSet where++import Common++import Control.Concurrent.STM++type TSet = TChan++runTSet :: STM a -> IO a+runTSet = atomically++newTSet :: IO (TSet a)+newTSet = atomically newTChan++{- Gets the contents of the TSet. Blocks until at least one item is+ - present. -}+getTSet :: TSet a -> IO [a]+getTSet tset = runTSet $ do+	c <- readTChan tset+	go [c]+	where+		go l = do+			v <- tryReadTChan tset+			case v of+				Nothing -> return l+				Just c -> go (c:l)++{- Puts items into a TSet. -}+putTSet :: TSet a -> [a] -> IO ()+putTSet tset vs = runTSet $ mapM_ (writeTChan tset) vs++{- Put a single item into a TSet. -}+putTSet1 :: TSet a -> a -> IO ()+putTSet1 tset v = void $ runTSet $ writeTChan tset v
Utility/TempFile.hs view
@@ -9,11 +9,12 @@  import Control.Exception (bracket) import System.IO-import System.Posix.Process hiding (executeFile)+import System.Posix.Process import System.Directory  import Utility.Exception import Utility.Path+import System.FilePath  {- Runs an action like writeFile, writing to a temp file first and  - then moving it into place. The temp file is stored in the same@@ -33,9 +34,25 @@ withTempFile template a = bracket create remove use 	where 		create = do-			tmpdir <- catchDefaultIO getTemporaryDirectory "."+			tmpdir <- catchDefaultIO "." getTemporaryDirectory 			openTempFile tmpdir template 		remove (name, handle) = do 			hClose handle 			catchBoolIO (removeFile name >> return True) 		use (name, handle) = a name handle++{- Runs an action with a temp directory, then removes the directory and+ - all its contents. -}+withTempDir :: Template -> (FilePath -> IO a) -> IO a+withTempDir template = bracket create remove+	where+		remove = removeDirectoryRecursive+		create = do+			tmpdir <- catchDefaultIO "." getTemporaryDirectory+			createDirectoryIfMissing True tmpdir+			pid <- getProcessID+			makedir tmpdir (template ++ show pid) (0 :: Int)+		makedir tmpdir t n = do+			let dir = tmpdir </> t ++ "." ++ show n+			r <- tryIO $ createDirectory dir+			either (const $ makedir tmpdir t $ n + 1) (const $ return dir) r
+ Utility/Tense.hs view
@@ -0,0 +1,57 @@+{- Past and present tense text.+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++{-# LANGUAGE OverloadedStrings #-}++module Utility.Tense where++import qualified Data.Text as T+import Data.Text (Text)+import GHC.Exts( IsString(..) )++data Tense = Present | Past+	deriving (Eq)++data TenseChunk = Tensed Text Text | UnTensed Text+	deriving (Eq, Ord, Show)++newtype TenseText = TenseText [TenseChunk]+	deriving (Eq, Ord)++{- Allows OverloadedStrings to be used, to build UnTensed chunks. -}+instance IsString TenseChunk where+	fromString = UnTensed . T.pack++{- Allows OverloadedStrings to be used, to provide UnTensed TenseText. -}+instance IsString TenseText where+	fromString s = TenseText [fromString s]++renderTense :: Tense -> TenseText -> Text+renderTense tense (TenseText chunks) = T.concat $ map render chunks+	where+		render (Tensed present past)+			| tense == Present = present+			| otherwise = past+		render (UnTensed s) = s++{- Builds up a TenseText, separating chunks with spaces.+ -+ - However, rather than just intersperse new chunks for the spaces,+ - the spaces are appended to the end of the chunks.+ -}+tenseWords :: [TenseChunk] -> TenseText+tenseWords = TenseText . go []+	where+		go c [] = reverse c+		go c (w:[]) = reverse (w:c)+		go c ((UnTensed w):ws) = go (UnTensed (addspace w) : c) ws+		go c ((Tensed w1 w2):ws) =+			go (Tensed (addspace w1) (addspace w2) : c) ws+		addspace w = T.append w " "++unTensed :: Text -> TenseText+unTensed t = TenseText [UnTensed t]
Utility/Types/DirWatcher.hs view
@@ -19,4 +19,8 @@ 	, delHook :: Hook FilePath 	, delDirHook :: Hook FilePath 	, errHook :: Hook String -- error message+	, modifyHook :: Hook FilePath 	}++mkWatchHooks :: WatchHooks+mkWatchHooks = WatchHooks Nothing Nothing Nothing Nothing Nothing Nothing
+ Utility/Verifiable.hs view
@@ -0,0 +1,37 @@+{- values verified using a shared secret+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++module Utility.Verifiable where++import Data.Digest.Pure.SHA+import Data.ByteString.Lazy.UTF8 (fromString)+import qualified Data.ByteString.Lazy as L++type Secret = L.ByteString+type HMACDigest = String++{- A value, verifiable using a HMAC digest and a secret. -}+data Verifiable a = Verifiable+	{ verifiableVal :: a+	, verifiableDigest :: HMACDigest+	}+	deriving (Eq, Read, Show)++mkVerifiable :: Show a => a -> Secret -> Verifiable a+mkVerifiable a secret = Verifiable a (calcDigest (show a) secret)++verify :: (Eq a, Show a) => Verifiable a -> Secret -> Bool+verify v secret = v == mkVerifiable (verifiableVal v) secret++calcDigest :: String -> Secret -> HMACDigest+calcDigest v secret = showDigest $ hmacSha1 secret $ fromString v++{- for quickcheck -}+prop_verifiable_sane :: String -> String -> Bool+prop_verifiable_sane a s = verify (mkVerifiable a secret) secret+	where+		secret = fromString s
+ Utility/WebApp.hs view
@@ -0,0 +1,184 @@+{- Yesod webapp+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++{-# LANGUAGE OverloadedStrings, CPP, RankNTypes #-}++module Utility.WebApp where++import Common++import qualified Yesod+import qualified Network.Wai as Wai+import Network.Wai.Handler.Warp+import Network.Wai.Logger+import Control.Monad.IO.Class+import Network.HTTP.Types+import System.Log.Logger+import Data.ByteString.Lazy.UTF8+import qualified Data.CaseInsensitive as CI+import Network.Socket+import Control.Exception+import Crypto.Random+import Data.Digest.Pure.SHA+import qualified Web.ClientSession as CS+import qualified Data.ByteString.Lazy as L+import qualified Data.ByteString as B+import qualified Data.Text as T+import qualified Data.Text.Encoding as TE+import Blaze.ByteString.Builder.Char.Utf8 (fromText)+import Blaze.ByteString.Builder (Builder)+import Data.Monoid+import Control.Arrow ((***))+import Control.Concurrent++localhost :: String+localhost = "localhost"++{- Runs a web browser on a given url.+ -+ - Note: The url *will* be visible to an attacker. -}+runBrowser :: String -> IO Bool+runBrowser url = boolSystem cmd [Param url]+	where+#if OSX+		cmd = "open"+#else+		cmd = "xdg-open"+#endif++{- Binds to a socket on localhost, and runs a webapp on it.+ -+ - An IO action can also be run, to do something with the port number,+ - such as start a web browser to view the webapp.+ -}+runWebApp :: Wai.Application -> (PortNumber -> IO ()) -> IO ()+runWebApp app observer = do+	sock <- localSocket+	void $ forkIO $ runSettingsSocket defaultSettings sock app+	observer =<< socketPort sock++{- Binds to a local socket, selecting any free port.+ -+ - Prefers to bind to the ipv4 address rather than the ipv6 address+ - of localhost, if it's available.+ -+ - As a (very weak) form of security, only connections from + - localhost are accepted. -}+localSocket :: IO Socket+localSocket = do+	addrs <- getAddrInfo (Just hints) (Just localhost) Nothing+	case (partition (\a -> addrFamily a == AF_INET) addrs) of+		(v4addr:_, _) -> go v4addr+		(_, v6addr:_) -> go v6addr+		_ -> error "unable to bind to a local socket"+	where+		hints = defaultHints+			{ addrFlags = [AI_ADDRCONFIG]+			, addrSocketType = Stream+			}+		go addr = bracketOnError (open addr) close (use addr)+		open addr = socket (addrFamily addr) (addrSocketType addr) (addrProtocol addr)+		close = sClose+		use addr sock = do+			setSocketOption sock ReuseAddr 1+			bindSocket sock (addrAddress addr)+			listen sock maxListenQueue+			return sock++{- Checks if debugging is actually enabled. -}+debugEnabled :: IO Bool+debugEnabled = do+	l <- getRootLogger+	return $ getLevel l <= Just DEBUG++{- WAI middleware that logs using System.Log.Logger at debug level.+ -+ - Recommend only inserting this middleware when debugging is actually+ - enabled, as it's not optimised at all.+ -}+httpDebugLogger :: Wai.Middleware+httpDebugLogger waiApp req = do+	logRequest req+	waiApp req++logRequest :: MonadIO m => Wai.Request -> m ()+logRequest req = do+	liftIO $ debugM "WebApp" $ unwords+		[ showSockAddr $ Wai.remoteHost req+		, frombs $ Wai.requestMethod req+		, frombs $ Wai.rawPathInfo req+		--, show $ Wai.httpVersion req+		--, frombs $ lookupRequestField "referer" req+		, frombs $ lookupRequestField "user-agent" req+		]+	where+		frombs v = toString $ L.fromChunks [v]++lookupRequestField :: CI.CI B.ByteString -> Wai.Request -> B.ByteString+lookupRequestField k req = fromMaybe "" . lookup k $ Wai.requestHeaders req++{- Rather than storing a session key on disk, use a random key+ - that will only be valid for this run of the webapp. -}+webAppSessionBackend :: Yesod.Yesod y => y -> IO (Maybe (Yesod.SessionBackend y))+webAppSessionBackend _ = do+	g <- newGenIO :: IO SystemRandom+	case genBytes 96 g of+		Left e -> error $ "failed to generate random key: " ++ show e+		Right (s, _) -> case CS.initKey s of+			Left e -> error $ "failed to initialize key: " ++ show e+			Right key -> return $ Just $+				Yesod.clientSessionBackend key 120++{- Generates a random sha512 string, suitable to be used for an+ - authentication secret. -}+genRandomToken :: IO String+genRandomToken = do+	g <- newGenIO :: IO SystemRandom+	return $+		case genBytes 512 g of+			Left e -> error $ "failed to generate secret token: " ++ show e+			Right (s, _) -> showDigest $ sha512 $ L.fromChunks [s]++{- A Yesod isAuthorized method, which checks the auth cgi parameter+ - against a token extracted from the Yesod application.+ -+ - Note that the usual Yesod error page is bypassed on error, to avoid+ - possibly leaking the auth token in urls on that page!+ -}+checkAuthToken :: forall t sub. (t -> T.Text) -> Yesod.GHandler sub t Yesod.AuthResult+checkAuthToken extractToken = do+	webapp <- Yesod.getYesod+	req <- Yesod.getRequest+	let params = Yesod.reqGetParams req+	if lookup "auth" params == Just (extractToken webapp)+		then return Yesod.Authorized+		else Yesod.sendResponseStatus unauthorized401 ()++{- A Yesod joinPath method, which adds an auth cgi parameter to every+ - url matching a predicate, containing a token extracted from the+ - Yesod application.+ - + - A typical predicate would exclude files under /static.+ -}+insertAuthToken :: forall y. (y -> T.Text)+	-> ([T.Text] -> Bool)+	-> y+	-> T.Text+	-> [T.Text]+	-> [(T.Text, T.Text)]+	-> Builder+insertAuthToken extractToken predicate webapp root pathbits params =+	fromText root `mappend` encodePath pathbits' encodedparams+	where+		pathbits' = if null pathbits then [T.empty] else pathbits+		encodedparams = map (TE.encodeUtf8 *** go) params'+		go "" = Nothing+		go x = Just $ TE.encodeUtf8 x+		authparam = (T.pack "auth", extractToken webapp)+		params'+			| predicate pathbits = authparam:params+			| otherwise = params
+ Utility/Yesod.hs view
@@ -0,0 +1,31 @@+{- Yesod stuff, that's typically found in the scaffolded site.+ -+ - Copyright 2012 Joey Hess <joey@kitenet.net>+ -+ - Licensed under the GNU GPL version 3 or higher.+ -}++{-# LANGUAGE CPP #-}++module Utility.Yesod where++import Yesod.Default.Util+import Language.Haskell.TH.Syntax+#ifndef WITH_OLD_YESOD+import Data.Default (def)+import Text.Hamlet+#endif++widgetFile :: String -> Q Exp+#ifdef WITH_OLD_YESOD+widgetFile = widgetFileNoReload+#else+widgetFile = widgetFileNoReload $ def+	{ wfsHamletSettings = defaultHamletSettings+		{ hamletNewlines = AlwaysNewlines+		}+	}+#endif++hamletTemplate :: FilePath -> FilePath+hamletTemplate f = globFile "hamlet" f
+ Utility/libmounts.c view
@@ -0,0 +1,103 @@+/* mounted filesystems, C mini-library+ *+ * Copyright (c) 1980, 1989, 1993, 1994+ *      The Regents of the University of California.  All rights reserved.+ * Copyright (c) 2001+ *      David Rufino <daverufino@btinternet.com>+ * Copyright 2012+ *      Joey Hess <joey@kitenet.net>+ *+ * Redistribution and use in source and binary forms, with or without+ * modification, are permitted provided that the following conditions+ * are met:+ * 1. Redistributions of source code must retain the above copyright+ *    notice, this list of conditions and the following disclaimer.+ * 2. Redistributions in binary form must reproduce the above copyright+ *    notice, this list of conditions and the following disclaimer in the+ *    documentation and/or other materials provided with the distribution.+ * 3. Neither the name of the University nor the names of its contributors+ *    may be used to endorse or promote products derived from this software+ *    without specific prior written permission.+ *+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF+ * SUCH DAMAGE.+ */++#include "libmounts.h"++#ifdef GETMNTENT+/* direct passthrough the getmntent */+FILE *mounts_start (void) {+	return setmntent("/etc/mtab", "r");+}+int mounts_end (FILE *fp) {+	return endmntent(fp);+}+struct mntent *mounts_next (FILE *fp) {+	return getmntent(fp);+}+#endif++#ifdef GETMNTINFO+/* getmntent emulation using getmntinfo */+FILE *mounts_start (void) {+	return ((FILE *)0x1); /* dummy non-NULL FILE pointer, not used */+}+int mounts_end (FILE *fp) {+	return 1;+}++static struct mntent _mntent;++static struct mntent *statfs_to_mntent (struct statfs *mntbuf) {+	_mntent.mnt_fsname = mntbuf->f_mntfromname;+	_mntent.mnt_dir = mntbuf->f_mntonname;+	_mntent.mnt_type = mntbuf->f_fstypename;++	_mntent.mnt_opts = '\0';+	_mntent.mnt_freq = 0;+	_mntent.mnt_passno = 0;++	return (&_mntent);+}++static int pos = -1;+static int mntsize = -1;+struct statfs *mntbuf = NULL;++struct mntent *mounts_next (FILE *fp) {++	if (pos == -1 || mntsize == -1)+		mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);+	++pos;+	if (pos == mntsize) {+		pos = mntsize = -1;+		mntbuf = NULL;+		return NULL;+	}++	return (statfs_to_mntent(&mntbuf[pos]));+}+#endif++#ifdef UNKNOWN+/* dummy, do-nothing version */+FILE *mounts_start (void) {+	return ((FILE *)0x1);+}+int mounts_end (FILE *fp) {+	return 1;+}+struct mntent *mounts_next (FILE *fp) {+	return NULL;+}+#endif
+ Utility/libmounts.h view
@@ -0,0 +1,33 @@+/* Include appropriate headers for the OS, and define what will be used. */+#if defined (__FreeBSD__) || defined (__APPLE__)+# include <sys/param.h>+# include <sys/ucred.h>+# include <sys/mount.h>+# define GETMNTINFO+#else+#if defined (__linux__) || defined (__FreeBSD_kernel__)+/* Linux or Debian kFreeBSD */+#include <mntent.h>+# define GETMNTENT+#else+# warning mounts listing code not available for this OS+# define UNKNOWN+#endif+#endif++#include <stdio.h>++#ifndef GETMNTENT+struct mntent {+	char *mnt_fsname;+	char *mnt_dir;+	char *mnt_type;+	char *mnt_opts; /* not filled in */+	int mnt_freq; /* not filled in */+	int mnt_passno; /* not filled in */+};+#endif++FILE *mounts_start (void);+int mounts_end (FILE *fp);+struct mntent *mounts_next (FILE *fp);
− Utility/libmounts.o

binary file changed (1284 → absent bytes)

debian/changelog view
@@ -1,3 +1,34 @@+git-annex (3.20120924) unstable; urgency=low++  * assistant: New command, a daemon which does everything watch does,+    as well as automatically syncing file contents between repositories.+  * webapp: An interface for managing and configuring the assistant.+  * The default backend used when adding files to the annex is changed+    from SHA256 to SHA256E, to simplify interoperability with OSX, media+    players, and various programs that needlessly look at symlink targets.+    To get old behavior, add a .gitattributes containing: * annex.backend=SHA256+  * init: If no description is provided for a new repository, one will+    automatically be generated, like "joey@gnu:~/foo"+  * test: Set a lot of git environment variables so testing works in strange+    environments that normally need git config to set names, etc.+    Closes: #682351 Thanks, gregor herrmann+  * Disable ssh connection caching if the path to the control socket would be+    too long (and use relative path to minimise path to the control socket).+  * migrate: Check content before generating the new key, to avoid generating+    a key for corrupt data.+  * Support repositories created with --separate-git-dir. Closes: #684405+  * reinject: When the provided file doesn't match, leave it where it is,+    rather than moving to .git/annex/bad/+  * Avoid crashing on encoding errors in filenames when writing transfer info+    files and reading from checksum commands.+  * sync: Pushes the git-annex branch to remote/synced/git-annex, rather+    than directly to remote/git-annex.+  * Now supports matchig files that are present on a number of remotes+    with a specified trust level. Example: --copies=trusted:2+    Thanks, Nicolas Pouillard++ -- Joey Hess <joeyh@debian.org>  Mon, 24 Sep 2012 13:47:48 -0400+ git-annex (3.20120825) unstable; urgency=low    * S3: Add fileprefix setting.
debian/control view
@@ -22,6 +22,23 @@ 	libghc-edit-distance-dev, 	libghc-hinotify-dev [linux-any], 	libghc-stm-dev (>= 2.3),+	libghc-dbus-dev,+	libghc-yesod-dev,+	libghc-yesod-static-dev,+	libghc-yesod-default-dev,+	libghc-case-insensitive-dev,+	libghc-http-types-dev,+	libghc-transformers-dev,+	libghc-wai-dev,+	libghc-wai-logger-dev,+	libghc-warp-dev,+	libghc-blaze-builder-dev,+	libghc-blaze-html-dev,+	libghc-crypto-api-dev,+	libghc-hamlet-dev,+	libghc-clientsession-dev,+	libghc-network-multicast-dev,+	libghc-network-info-dev, 	ikiwiki, 	perlmagick, 	git,@@ -42,8 +59,8 @@ 	rsync, 	wget | curl, 	openssh-client (>= 1:5.6p1)-Recommends: lsof-Suggests: graphviz, bup, gnupg+Recommends: lsof, libnss-mdns, gnupg+Suggests: graphviz, bup Description: manage files with git, without checking their contents into git  git-annex allows managing files with git, without checking the file  contents into git. While that may seem paradoxical, it is useful when
debian/copyright view
@@ -4,12 +4,771 @@ Files: * Copyright: © 2010-2012 Joey Hess <joey@kitenet.net> License: GPL-3+- The full text of version 3 of the GPL is distributed as doc/GPL in- this package's source, or in /usr/share/common-licenses/GPL-3 on- Debian systems. -Files: doc/logo* doc/favicon.png+Files: Assistant/WebApp.hs Assistant/WebApp/* templates/* static/*+Copyright: © 2012 Joey Hess <joey@kitenet.net>+License: AGPL-3+++Files: doc/logo* */favicon.ico ui-macos/git-annex.app/Contents/Resources/git-annex.icns Copyright: 2007 Henrik Nyh <http://henrik.nyh.se/>            2010 Joey Hess <joey@kitenet.net> License: other   Free to modify and redistribute with due credit, and obviously free to use.++Files: Utility/Mounts.hsc+Copyright: Volker Wysk <hsss@volker-wysk.de>+License: LGPL-2.1+++Files: Utility/libmounts.c+Copyright: 1980, 1989, 1993, 1994 The Regents of the University of California+           2001 David Rufino <daverufino@btinternet.com>+           2012 Joey Hess <joey@kitenet.net>+License: BSD-3-clause+ * Copyright (c) 1980, 1989, 1993, 1994+ *      The Regents of the University of California.  All rights reserved.+ * Copyright (c) 2001+ *      David Rufino <daverufino@btinternet.com>+ * Copyright 2012+ *      Joey Hess <joey@kitenet.net>+ *+ * Redistribution and use in source and binary forms, with or without+ * modification, are permitted provided that the following conditions+ * are met:+ * 1. Redistributions of source code must retain the above copyright+ *    notice, this list of conditions and the following disclaimer.+ * 2. Redistributions in binary form must reproduce the above copyright+ *    notice, this list of conditions and the following disclaimer in the+ *    documentation and/or other materials provided with the distribution.+ * 3. Neither the name of the University nor the names of its contributors+ *    may be used to endorse or promote products derived from this software+ *    without specific prior written permission.+ *+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF+ * SUCH DAMAGE.++Files: static/jquery*+Copyright: © 2005-2011 by John Resig, Branden Aaron & Jörn Zaefferer+           © 2011 The Dojo Foundation+License: MIT or GPL-2+ The full text of version 2 of the GPL is distributed in+ /usr/share/common-licenses/GPL-2 on Debian systems. The text of the MIT+ license follows:+ .+ Permission is hereby granted, free of charge, to any person obtaining+ a copy of this software and associated documentation files (the+ "Software"), to deal in the Software without restriction, including+ without limitation the rights to use, copy, modify, merge, publish,+ distribute, sublicense, and/or sell copies of the Software, and to+ permit persons to whom the Software is furnished to do so, subject to+ the following conditions:+ .+ The above copyright notice and this permission notice shall be+ included in all copies or substantial portions of the Software.+ .+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.++Files: static/*/bootstrap* static/img/glyphicons-halflings*+Copyright: 2012 Twitter, Inc.+License: Apache-2.0+ Licensed under the Apache License, Version 2.0 (the "License");+ you may not use this file except in compliance with the License.+ You may obtain a copy of the License at+ .+        http://www.apache.org/licenses/LICENSE-2.0+ .+ Unless required by applicable law or agreed to in writing, software+ distributed under the License is distributed on an "AS IS" BASIS,+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ See the License for the specific language governing permissions and+ limitations under the License.+ .+ The complete text of the Apache License is distributed in+ /usr/share/common-licenses/Apache-2.0 on Debian systems.++License: GPL-3++ The full text of version 3 of the GPL is distributed as doc/license/GPL in+ this package's source, or in /usr/share/common-licenses/GPL-3 on+ Debian systems.++License: LGPL-2.1++ The full text of version 2.1 of the LGPL is distributed as doc/license/LGPL+ in this package's source, or in /usr/share/common-licenses/LGPL-2.1+ on Debian systems.++License: AGPL-3++                      GNU AFFERO GENERAL PUBLIC LICENSE+                         Version 3, 19 November 2007+ .+   Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>+   Everyone is permitted to copy and distribute verbatim copies+   of this license document, but changing it is not allowed.+ .+                              Preamble+ .+    The GNU Affero General Public License is a free, copyleft license for+  software and other kinds of works, specifically designed to ensure+  cooperation with the community in the case of network server software.+ .+    The licenses for most software and other practical works are designed+  to take away your freedom to share and change the works.  By contrast,+  our General Public Licenses are intended to guarantee your freedom to+  share and change all versions of a program--to make sure it remains free+  software for all its users.+ .+    When we speak of free software, we are referring to freedom, not+  price.  Our General Public Licenses are designed to make sure that you+  have the freedom to distribute copies of free software (and charge for+  them if you wish), that you receive source code or can get it if you+  want it, that you can change the software or use pieces of it in new+  free programs, and that you know you can do these things.+ .+    Developers that use our General Public Licenses protect your rights+  with two steps: (1) assert copyright on the software, and (2) offer+  you this License which gives you legal permission to copy, distribute+  and/or modify the software.+ .+    A secondary benefit of defending all users' freedom is that+  improvements made in alternate versions of the program, if they+  receive widespread use, become available for other developers to+  incorporate.  Many developers of free software are heartened and+  encouraged by the resulting cooperation.  However, in the case of+  software used on network servers, this result may fail to come about.+  The GNU General Public License permits making a modified version and+  letting the public access it on a server without ever releasing its+  source code to the public.+ .+    The GNU Affero General Public License is designed specifically to+  ensure that, in such cases, the modified source code becomes available+  to the community.  It requires the operator of a network server to+  provide the source code of the modified version running there to the+  users of that server.  Therefore, public use of a modified version, on+  a publicly accessible server, gives the public access to the source+  code of the modified version.+ .+    An older license, called the Affero General Public License and+  published by Affero, was designed to accomplish similar goals.  This is+  a different license, not a version of the Affero GPL, but Affero has+  released a new version of the Affero GPL which permits relicensing under+  this license.+ .+    The precise terms and conditions for copying, distribution and+  modification follow.+ .+                         TERMS AND CONDITIONS+ .+    0. Definitions.+ .+    "This License" refers to version 3 of the GNU Affero General Public License.+ .+    "Copyright" also means copyright-like laws that apply to other kinds of+  works, such as semiconductor masks.+ .+    "The Program" refers to any copyrightable work licensed under this+  License.  Each licensee is addressed as "you".  "Licensees" and+  "recipients" may be individuals or organizations.+ .+    To "modify" a work means to copy from or adapt all or part of the work+  in a fashion requiring copyright permission, other than the making of an+  exact copy.  The resulting work is called a "modified version" of the+  earlier work or a work "based on" the earlier work.+ .+    A "covered work" means either the unmodified Program or a work based+  on the Program.+ .+    To "propagate" a work means to do anything with it that, without+  permission, would make you directly or secondarily liable for+  infringement under applicable copyright law, except executing it on a+  computer or modifying a private copy.  Propagation includes copying,+  distribution (with or without modification), making available to the+  public, and in some countries other activities as well.+ .+    To "convey" a work means any kind of propagation that enables other+  parties to make or receive copies.  Mere interaction with a user through+  a computer network, with no transfer of a copy, is not conveying.+ .+    An interactive user interface displays "Appropriate Legal Notices"+  to the extent that it includes a convenient and prominently visible+  feature that (1) displays an appropriate copyright notice, and (2)+  tells the user that there is no warranty for the work (except to the+  extent that warranties are provided), that licensees may convey the+  work under this License, and how to view a copy of this License.  If+  the interface presents a list of user commands or options, such as a+  menu, a prominent item in the list meets this criterion.+ .+    1. Source Code.+ .+    The "source code" for a work means the preferred form of the work+  for making modifications to it.  "Object code" means any non-source+  form of a work.+ .+    A "Standard Interface" means an interface that either is an official+  standard defined by a recognized standards body, or, in the case of+  interfaces specified for a particular programming language, one that+  is widely used among developers working in that language.+ .+    The "System Libraries" of an executable work include anything, other+  than the work as a whole, that (a) is included in the normal form of+  packaging a Major Component, but which is not part of that Major+  Component, and (b) serves only to enable use of the work with that+  Major Component, or to implement a Standard Interface for which an+  implementation is available to the public in source code form.  A+  "Major Component", in this context, means a major essential component+  (kernel, window system, and so on) of the specific operating system+  (if any) on which the executable work runs, or a compiler used to+  produce the work, or an object code interpreter used to run it.+ .+    The "Corresponding Source" for a work in object code form means all+  the source code needed to generate, install, and (for an executable+  work) run the object code and to modify the work, including scripts to+  control those activities.  However, it does not include the work's+  System Libraries, or general-purpose tools or generally available free+  programs which are used unmodified in performing those activities but+  which are not part of the work.  For example, Corresponding Source+  includes interface definition files associated with source files for+  the work, and the source code for shared libraries and dynamically+  linked subprograms that the work is specifically designed to require,+  such as by intimate data communication or control flow between those+  subprograms and other parts of the work.+ .+    The Corresponding Source need not include anything that users+  can regenerate automatically from other parts of the Corresponding+  Source.+ .+    The Corresponding Source for a work in source code form is that+  same work.+ .+    2. Basic Permissions.+ .+    All rights granted under this License are granted for the term of+  copyright on the Program, and are irrevocable provided the stated+  conditions are met.  This License explicitly affirms your unlimited+  permission to run the unmodified Program.  The output from running a+  covered work is covered by this License only if the output, given its+  content, constitutes a covered work.  This License acknowledges your+  rights of fair use or other equivalent, as provided by copyright law.+ .+    You may make, run and propagate covered works that you do not+  convey, without conditions so long as your license otherwise remains+  in force.  You may convey covered works to others for the sole purpose+  of having them make modifications exclusively for you, or provide you+  with facilities for running those works, provided that you comply with+  the terms of this License in conveying all material for which you do+  not control copyright.  Those thus making or running the covered works+  for you must do so exclusively on your behalf, under your direction+  and control, on terms that prohibit them from making any copies of+  your copyrighted material outside their relationship with you.+ .+    Conveying under any other circumstances is permitted solely under+  the conditions stated below.  Sublicensing is not allowed; section 10+  makes it unnecessary.+ .+    3. Protecting Users' Legal Rights From Anti-Circumvention Law.+ .+    No covered work shall be deemed part of an effective technological+  measure under any applicable law fulfilling obligations under article+  11 of the WIPO copyright treaty adopted on 20 December 1996, or+  similar laws prohibiting or restricting circumvention of such+  measures.+ .+    When you convey a covered work, you waive any legal power to forbid+  circumvention of technological measures to the extent such circumvention+  is effected by exercising rights under this License with respect to+  the covered work, and you disclaim any intention to limit operation or+  modification of the work as a means of enforcing, against the work's+  users, your or third parties' legal rights to forbid circumvention of+  technological measures.+ .+    4. Conveying Verbatim Copies.+ .+    You may convey verbatim copies of the Program's source code as you+  receive it, in any medium, provided that you conspicuously and+  appropriately publish on each copy an appropriate copyright notice;+  keep intact all notices stating that this License and any+  non-permissive terms added in accord with section 7 apply to the code;+  keep intact all notices of the absence of any warranty; and give all+  recipients a copy of this License along with the Program.+ .+    You may charge any price or no price for each copy that you convey,+  and you may offer support or warranty protection for a fee.+ .+    5. Conveying Modified Source Versions.+ .+    You may convey a work based on the Program, or the modifications to+  produce it from the Program, in the form of source code under the+  terms of section 4, provided that you also meet all of these conditions:+ .+      a) The work must carry prominent notices stating that you modified+      it, and giving a relevant date.+ .+      b) The work must carry prominent notices stating that it is+      released under this License and any conditions added under section+      7.  This requirement modifies the requirement in section 4 to+      "keep intact all notices".+ .+      c) You must license the entire work, as a whole, under this+      License to anyone who comes into possession of a copy.  This+      License will therefore apply, along with any applicable section 7+      additional terms, to the whole of the work, and all its parts,+      regardless of how they are packaged.  This License gives no+      permission to license the work in any other way, but it does not+      invalidate such permission if you have separately received it.+ .+      d) If the work has interactive user interfaces, each must display+      Appropriate Legal Notices; however, if the Program has interactive+      interfaces that do not display Appropriate Legal Notices, your+      work need not make them do so.+ .+    A compilation of a covered work with other separate and independent+  works, which are not by their nature extensions of the covered work,+  and which are not combined with it such as to form a larger program,+  in or on a volume of a storage or distribution medium, is called an+  "aggregate" if the compilation and its resulting copyright are not+  used to limit the access or legal rights of the compilation's users+  beyond what the individual works permit.  Inclusion of a covered work+  in an aggregate does not cause this License to apply to the other+  parts of the aggregate.+ .+    6. Conveying Non-Source Forms.+ .+    You may convey a covered work in object code form under the terms+  of sections 4 and 5, provided that you also convey the+  machine-readable Corresponding Source under the terms of this License,+  in one of these ways:+ .+      a) Convey the object code in, or embodied in, a physical product+      (including a physical distribution medium), accompanied by the+      Corresponding Source fixed on a durable physical medium+      customarily used for software interchange.+ .+      b) Convey the object code in, or embodied in, a physical product+      (including a physical distribution medium), accompanied by a+      written offer, valid for at least three years and valid for as+      long as you offer spare parts or customer support for that product+      model, to give anyone who possesses the object code either (1) a+      copy of the Corresponding Source for all the software in the+      product that is covered by this License, on a durable physical+      medium customarily used for software interchange, for a price no+      more than your reasonable cost of physically performing this+      conveying of source, or (2) access to copy the+      Corresponding Source from a network server at no charge.+ .+      c) Convey individual copies of the object code with a copy of the+      written offer to provide the Corresponding Source.  This+      alternative is allowed only occasionally and noncommercially, and+      only if you received the object code with such an offer, in accord+      with subsection 6b.+ .+      d) Convey the object code by offering access from a designated+      place (gratis or for a charge), and offer equivalent access to the+      Corresponding Source in the same way through the same place at no+      further charge.  You need not require recipients to copy the+      Corresponding Source along with the object code.  If the place to+      copy the object code is a network server, the Corresponding Source+      may be on a different server (operated by you or a third party)+      that supports equivalent copying facilities, provided you maintain+      clear directions next to the object code saying where to find the+      Corresponding Source.  Regardless of what server hosts the+      Corresponding Source, you remain obligated to ensure that it is+      available for as long as needed to satisfy these requirements.+ .+      e) Convey the object code using peer-to-peer transmission, provided+      you inform other peers where the object code and Corresponding+      Source of the work are being offered to the general public at no+      charge under subsection 6d.+ .+    A separable portion of the object code, whose source code is excluded+  from the Corresponding Source as a System Library, need not be+  included in conveying the object code work.+ .+    A "User Product" is either (1) a "consumer product", which means any+  tangible personal property which is normally used for personal, family,+  or household purposes, or (2) anything designed or sold for incorporation+  into a dwelling.  In determining whether a product is a consumer product,+  doubtful cases shall be resolved in favor of coverage.  For a particular+  product received by a particular user, "normally used" refers to a+  typical or common use of that class of product, regardless of the status+  of the particular user or of the way in which the particular user+  actually uses, or expects or is expected to use, the product.  A product+  is a consumer product regardless of whether the product has substantial+  commercial, industrial or non-consumer uses, unless such uses represent+  the only significant mode of use of the product.+ .+    "Installation Information" for a User Product means any methods,+  procedures, authorization keys, or other information required to install+  and execute modified versions of a covered work in that User Product from+  a modified version of its Corresponding Source.  The information must+  suffice to ensure that the continued functioning of the modified object+  code is in no case prevented or interfered with solely because+  modification has been made.+ .+    If you convey an object code work under this section in, or with, or+  specifically for use in, a User Product, and the conveying occurs as+  part of a transaction in which the right of possession and use of the+  User Product is transferred to the recipient in perpetuity or for a+  fixed term (regardless of how the transaction is characterized), the+  Corresponding Source conveyed under this section must be accompanied+  by the Installation Information.  But this requirement does not apply+  if neither you nor any third party retains the ability to install+  modified object code on the User Product (for example, the work has+  been installed in ROM).+ .+    The requirement to provide Installation Information does not include a+  requirement to continue to provide support service, warranty, or updates+  for a work that has been modified or installed by the recipient, or for+  the User Product in which it has been modified or installed.  Access to a+  network may be denied when the modification itself materially and+  adversely affects the operation of the network or violates the rules and+  protocols for communication across the network.+ .+    Corresponding Source conveyed, and Installation Information provided,+  in accord with this section must be in a format that is publicly+  documented (and with an implementation available to the public in+  source code form), and must require no special password or key for+  unpacking, reading or copying.+ .+    7. Additional Terms.+ .+    "Additional permissions" are terms that supplement the terms of this+  License by making exceptions from one or more of its conditions.+  Additional permissions that are applicable to the entire Program shall+  be treated as though they were included in this License, to the extent+  that they are valid under applicable law.  If additional permissions+  apply only to part of the Program, that part may be used separately+  under those permissions, but the entire Program remains governed by+  this License without regard to the additional permissions.+ .+    When you convey a copy of a covered work, you may at your option+  remove any additional permissions from that copy, or from any part of+  it.  (Additional permissions may be written to require their own+  removal in certain cases when you modify the work.)  You may place+  additional permissions on material, added by you to a covered work,+  for which you have or can give appropriate copyright permission.+ .+    Notwithstanding any other provision of this License, for material you+  add to a covered work, you may (if authorized by the copyright holders of+  that material) supplement the terms of this License with terms:+ .+      a) Disclaiming warranty or limiting liability differently from the+      terms of sections 15 and 16 of this License; or+ .+      b) Requiring preservation of specified reasonable legal notices or+      author attributions in that material or in the Appropriate Legal+      Notices displayed by works containing it; or+ .+      c) Prohibiting misrepresentation of the origin of that material, or+      requiring that modified versions of such material be marked in+      reasonable ways as different from the original version; or+ .+      d) Limiting the use for publicity purposes of names of licensors or+      authors of the material; or+ .+      e) Declining to grant rights under trademark law for use of some+      trade names, trademarks, or service marks; or+ .+      f) Requiring indemnification of licensors and authors of that+      material by anyone who conveys the material (or modified versions of+      it) with contractual assumptions of liability to the recipient, for+      any liability that these contractual assumptions directly impose on+      those licensors and authors.+ .+    All other non-permissive additional terms are considered "further+  restrictions" within the meaning of section 10.  If the Program as you+  received it, or any part of it, contains a notice stating that it is+  governed by this License along with a term that is a further+  restriction, you may remove that term.  If a license document contains+  a further restriction but permits relicensing or conveying under this+  License, you may add to a covered work material governed by the terms+  of that license document, provided that the further restriction does+  not survive such relicensing or conveying.+ .+    If you add terms to a covered work in accord with this section, you+  must place, in the relevant source files, a statement of the+  additional terms that apply to those files, or a notice indicating+  where to find the applicable terms.+ .+    Additional terms, permissive or non-permissive, may be stated in the+  form of a separately written license, or stated as exceptions;+  the above requirements apply either way.+ .+    8. Termination.+ .+    You may not propagate or modify a covered work except as expressly+  provided under this License.  Any attempt otherwise to propagate or+  modify it is void, and will automatically terminate your rights under+  this License (including any patent licenses granted under the third+  paragraph of section 11).+ .+    However, if you cease all violation of this License, then your+  license from a particular copyright holder is reinstated (a)+  provisionally, unless and until the copyright holder explicitly and+  finally terminates your license, and (b) permanently, if the copyright+  holder fails to notify you of the violation by some reasonable means+  prior to 60 days after the cessation.+ .+    Moreover, your license from a particular copyright holder is+  reinstated permanently if the copyright holder notifies you of the+  violation by some reasonable means, this is the first time you have+  received notice of violation of this License (for any work) from that+  copyright holder, and you cure the violation prior to 30 days after+  your receipt of the notice.+ .+    Termination of your rights under this section does not terminate the+  licenses of parties who have received copies or rights from you under+  this License.  If your rights have been terminated and not permanently+  reinstated, you do not qualify to receive new licenses for the same+  material under section 10.+ .+    9. Acceptance Not Required for Having Copies.+ .+    You are not required to accept this License in order to receive or+  run a copy of the Program.  Ancillary propagation of a covered work+  occurring solely as a consequence of using peer-to-peer transmission+  to receive a copy likewise does not require acceptance.  However,+  nothing other than this License grants you permission to propagate or+  modify any covered work.  These actions infringe copyright if you do+  not accept this License.  Therefore, by modifying or propagating a+  covered work, you indicate your acceptance of this License to do so.+ .+    10. Automatic Licensing of Downstream Recipients.+ .+    Each time you convey a covered work, the recipient automatically+  receives a license from the original licensors, to run, modify and+  propagate that work, subject to this License.  You are not responsible+  for enforcing compliance by third parties with this License.+ .+    An "entity transaction" is a transaction transferring control of an+  organization, or substantially all assets of one, or subdividing an+  organization, or merging organizations.  If propagation of a covered+  work results from an entity transaction, each party to that+  transaction who receives a copy of the work also receives whatever+  licenses to the work the party's predecessor in interest had or could+  give under the previous paragraph, plus a right to possession of the+  Corresponding Source of the work from the predecessor in interest, if+  the predecessor has it or can get it with reasonable efforts.+ .+    You may not impose any further restrictions on the exercise of the+  rights granted or affirmed under this License.  For example, you may+  not impose a license fee, royalty, or other charge for exercise of+  rights granted under this License, and you may not initiate litigation+  (including a cross-claim or counterclaim in a lawsuit) alleging that+  any patent claim is infringed by making, using, selling, offering for+  sale, or importing the Program or any portion of it.+ .+    11. Patents.+ .+    A "contributor" is a copyright holder who authorizes use under this+  License of the Program or a work on which the Program is based.  The+  work thus licensed is called the contributor's "contributor version".+ .+    A contributor's "essential patent claims" are all patent claims+  owned or controlled by the contributor, whether already acquired or+  hereafter acquired, that would be infringed by some manner, permitted+  by this License, of making, using, or selling its contributor version,+  but do not include claims that would be infringed only as a+  consequence of further modification of the contributor version.  For+  purposes of this definition, "control" includes the right to grant+  patent sublicenses in a manner consistent with the requirements of+  this License.+ .+    Each contributor grants you a non-exclusive, worldwide, royalty-free+  patent license under the contributor's essential patent claims, to+  make, use, sell, offer for sale, import and otherwise run, modify and+  propagate the contents of its contributor version.+ .+    In the following three paragraphs, a "patent license" is any express+  agreement or commitment, however denominated, not to enforce a patent+  (such as an express permission to practice a patent or covenant not to+  sue for patent infringement).  To "grant" such a patent license to a+  party means to make such an agreement or commitment not to enforce a+  patent against the party.+ .+    If you convey a covered work, knowingly relying on a patent license,+  and the Corresponding Source of the work is not available for anyone+  to copy, free of charge and under the terms of this License, through a+  publicly available network server or other readily accessible means,+  then you must either (1) cause the Corresponding Source to be so+  available, or (2) arrange to deprive yourself of the benefit of the+  patent license for this particular work, or (3) arrange, in a manner+  consistent with the requirements of this License, to extend the patent+  license to downstream recipients.  "Knowingly relying" means you have+  actual knowledge that, but for the patent license, your conveying the+  covered work in a country, or your recipient's use of the covered work+  in a country, would infringe one or more identifiable patents in that+  country that you have reason to believe are valid.+ .+    If, pursuant to or in connection with a single transaction or+  arrangement, you convey, or propagate by procuring conveyance of, a+  covered work, and grant a patent license to some of the parties+  receiving the covered work authorizing them to use, propagate, modify+  or convey a specific copy of the covered work, then the patent license+  you grant is automatically extended to all recipients of the covered+  work and works based on it.+ .+    A patent license is "discriminatory" if it does not include within+  the scope of its coverage, prohibits the exercise of, or is+  conditioned on the non-exercise of one or more of the rights that are+  specifically granted under this License.  You may not convey a covered+  work if you are a party to an arrangement with a third party that is+  in the business of distributing software, under which you make payment+  to the third party based on the extent of your activity of conveying+  the work, and under which the third party grants, to any of the+  parties who would receive the covered work from you, a discriminatory+  patent license (a) in connection with copies of the covered work+  conveyed by you (or copies made from those copies), or (b) primarily+  for and in connection with specific products or compilations that+  contain the covered work, unless you entered into that arrangement,+  or that patent license was granted, prior to 28 March 2007.+ .+    Nothing in this License shall be construed as excluding or limiting+  any implied license or other defenses to infringement that may+  otherwise be available to you under applicable patent law.+ .+    12. No Surrender of Others' Freedom.+ .+    If conditions are imposed on you (whether by court order, agreement or+  otherwise) that contradict the conditions of this License, they do not+  excuse you from the conditions of this License.  If you cannot convey a+  covered work so as to satisfy simultaneously your obligations under this+  License and any other pertinent obligations, then as a consequence you may+  not convey it at all.  For example, if you agree to terms that obligate you+  to collect a royalty for further conveying from those to whom you convey+  the Program, the only way you could satisfy both those terms and this+  License would be to refrain entirely from conveying the Program.+ .+    13. Remote Network Interaction; Use with the GNU General Public License.+ .+    Notwithstanding any other provision of this License, if you modify the+  Program, your modified version must prominently offer all users+  interacting with it remotely through a computer network (if your version+  supports such interaction) an opportunity to receive the Corresponding+  Source of your version by providing access to the Corresponding Source+  from a network server at no charge, through some standard or customary+  means of facilitating copying of software.  This Corresponding Source+  shall include the Corresponding Source for any work covered by version 3+  of the GNU General Public License that is incorporated pursuant to the+  following paragraph.+ .+    Notwithstanding any other provision of this License, you have+  permission to link or combine any covered work with a work licensed+  under version 3 of the GNU General Public License into a single+  combined work, and to convey the resulting work.  The terms of this+  License will continue to apply to the part which is the covered work,+  but the work with which it is combined will remain governed by version+  3 of the GNU General Public License.+ .+    14. Revised Versions of this License.+ .+    The Free Software Foundation may publish revised and/or new versions of+  the GNU Affero General Public License from time to time.  Such new versions+  will be similar in spirit to the present version, but may differ in detail to+  address new problems or concerns.+ .+    Each version is given a distinguishing version number.  If the+  Program specifies that a certain numbered version of the GNU Affero General+  Public License "or any later version" applies to it, you have the+  option of following the terms and conditions either of that numbered+  version or of any later version published by the Free Software+  Foundation.  If the Program does not specify a version number of the+  GNU Affero General Public License, you may choose any version ever published+  by the Free Software Foundation.+ .+    If the Program specifies that a proxy can decide which future+  versions of the GNU Affero General Public License can be used, that proxy's+  public statement of acceptance of a version permanently authorizes you+  to choose that version for the Program.+ .+    Later license versions may give you additional or different+  permissions.  However, no additional obligations are imposed on any+  author or copyright holder as a result of your choosing to follow a+  later version.+ .+    15. Disclaimer of Warranty.+ .+    THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY+  APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT+  HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY+  OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,+  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR+  PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM+  IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF+  ALL NECESSARY SERVICING, REPAIR OR CORRECTION.+ .+    16. Limitation of Liability.+ .+    IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING+  WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS+  THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY+  GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE+  USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF+  DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD+  PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),+  EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF+  SUCH DAMAGES.+ .+    17. Interpretation of Sections 15 and 16.+ .+    If the disclaimer of warranty and limitation of liability provided+  above cannot be given local legal effect according to their terms,+  reviewing courts shall apply local law that most closely approximates+  an absolute waiver of all civil liability in connection with the+  Program, unless a warranty or assumption of liability accompanies a+  copy of the Program in return for a fee.+ .+                       END OF TERMS AND CONDITIONS+ .+              How to Apply These Terms to Your New Programs+ .+    If you develop a new program, and you want it to be of the greatest+  possible use to the public, the best way to achieve this is to make it+  free software which everyone can redistribute and change under these terms.+ .+    To do so, attach the following notices to the program.  It is safest+  to attach them to the start of each source file to most effectively+  state the exclusion of warranty; and each file should have at least+  the "copyright" line and a pointer to where the full notice is found.+ .+      <one line to give the program's name and a brief idea of what it does.>+      Copyright (C) <year>  <name of author>+ .+      This program is free software: you can redistribute it and/or modify+      it under the terms of the GNU Affero General Public License as published by+      the Free Software Foundation, either version 3 of the License, or+      (at your option) any later version.+ .+      This program is distributed in the hope that it will be useful,+      but WITHOUT ANY WARRANTY; without even the implied warranty of+      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the+      GNU Affero General Public License for more details.+ .+      You should have received a copy of the GNU Affero General Public License+      along with this program.  If not, see <http://www.gnu.org/licenses/>.+ .+  Also add information on how to contact you by electronic and paper mail.+ .+    If your software can interact with users remotely through a computer+  network, you should also make sure that it provides a way for users to+  get its source.  For example, if your program is a web application, its+  interface could display a "Source" link that leads users to an archive+  of the code.  There are many ways you could offer source, and different+  solutions will be better for different programs; see section 13 for the+  specific requirements.+ .+    You should also get your employer (if you work as a programmer) or school,+  if any, to sign a "copyright disclaimer" for the program, if necessary.+  For more information on this, and how to apply and follow the GNU AGPL, see+  <http://www.gnu.org/licenses/>.
− doc/GPL
@@ -1,674 +0,0 @@-                    GNU GENERAL PUBLIC LICENSE-                       Version 3, 29 June 2007-- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>- Everyone is permitted to copy and distribute verbatim copies- of this license document, but changing it is not allowed.--                            Preamble--  The GNU General Public License is a free, copyleft license for-software and other kinds of works.--  The licenses for most software and other practical works are designed-to take away your freedom to share and change the works.  By contrast,-the GNU General Public License is intended to guarantee your freedom to-share and change all versions of a program--to make sure it remains free-software for all its users.  We, the Free Software Foundation, use the-GNU General Public License for most of our software; it applies also to-any other work released this way by its authors.  You can apply it to-your programs, too.--  When we speak of free software, we are referring to freedom, not-price.  Our General Public Licenses are designed to make sure that you-have the freedom to distribute copies of free software (and charge for-them if you wish), that you receive source code or can get it if you-want it, that you can change the software or use pieces of it in new-free programs, and that you know you can do these things.--  To protect your rights, we need to prevent others from denying you-these rights or asking you to surrender the rights.  Therefore, you have-certain responsibilities if you distribute copies of the software, or if-you modify it: responsibilities to respect the freedom of others.--  For example, if you distribute copies of such a program, whether-gratis or for a fee, you must pass on to the recipients the same-freedoms that you received.  You must make sure that they, too, receive-or can get the source code.  And you must show them these terms so they-know their rights.--  Developers that use the GNU GPL protect your rights with two steps:-(1) assert copyright on the software, and (2) offer you this License-giving you legal permission to copy, distribute and/or modify it.--  For the developers' and authors' protection, the GPL clearly explains-that there is no warranty for this free software.  For both users' and-authors' sake, the GPL requires that modified versions be marked as-changed, so that their problems will not be attributed erroneously to-authors of previous versions.--  Some devices are designed to deny users access to install or run-modified versions of the software inside them, although the manufacturer-can do so.  This is fundamentally incompatible with the aim of-protecting users' freedom to change the software.  The systematic-pattern of such abuse occurs in the area of products for individuals to-use, which is precisely where it is most unacceptable.  Therefore, we-have designed this version of the GPL to prohibit the practice for those-products.  If such problems arise substantially in other domains, we-stand ready to extend this provision to those domains in future versions-of the GPL, as needed to protect the freedom of users.--  Finally, every program is threatened constantly by software patents.-States should not allow patents to restrict development and use of-software on general-purpose computers, but in those that do, we wish to-avoid the special danger that patents applied to a free program could-make it effectively proprietary.  To prevent this, the GPL assures that-patents cannot be used to render the program non-free.--  The precise terms and conditions for copying, distribution and-modification follow.--                       TERMS AND CONDITIONS--  0. Definitions.--  "This License" refers to version 3 of the GNU General Public License.--  "Copyright" also means copyright-like laws that apply to other kinds of-works, such as semiconductor masks.--  "The Program" refers to any copyrightable work licensed under this-License.  Each licensee is addressed as "you".  "Licensees" and-"recipients" may be individuals or organizations.--  To "modify" a work means to copy from or adapt all or part of the work-in a fashion requiring copyright permission, other than the making of an-exact copy.  The resulting work is called a "modified version" of the-earlier work or a work "based on" the earlier work.--  A "covered work" means either the unmodified Program or a work based-on the Program.--  To "propagate" a work means to do anything with it that, without-permission, would make you directly or secondarily liable for-infringement under applicable copyright law, except executing it on a-computer or modifying a private copy.  Propagation includes copying,-distribution (with or without modification), making available to the-public, and in some countries other activities as well.--  To "convey" a work means any kind of propagation that enables other-parties to make or receive copies.  Mere interaction with a user through-a computer network, with no transfer of a copy, is not conveying.--  An interactive user interface displays "Appropriate Legal Notices"-to the extent that it includes a convenient and prominently visible-feature that (1) displays an appropriate copyright notice, and (2)-tells the user that there is no warranty for the work (except to the-extent that warranties are provided), that licensees may convey the-work under this License, and how to view a copy of this License.  If-the interface presents a list of user commands or options, such as a-menu, a prominent item in the list meets this criterion.--  1. Source Code.--  The "source code" for a work means the preferred form of the work-for making modifications to it.  "Object code" means any non-source-form of a work.--  A "Standard Interface" means an interface that either is an official-standard defined by a recognized standards body, or, in the case of-interfaces specified for a particular programming language, one that-is widely used among developers working in that language.--  The "System Libraries" of an executable work include anything, other-than the work as a whole, that (a) is included in the normal form of-packaging a Major Component, but which is not part of that Major-Component, and (b) serves only to enable use of the work with that-Major Component, or to implement a Standard Interface for which an-implementation is available to the public in source code form.  A-"Major Component", in this context, means a major essential component-(kernel, window system, and so on) of the specific operating system-(if any) on which the executable work runs, or a compiler used to-produce the work, or an object code interpreter used to run it.--  The "Corresponding Source" for a work in object code form means all-the source code needed to generate, install, and (for an executable-work) run the object code and to modify the work, including scripts to-control those activities.  However, it does not include the work's-System Libraries, or general-purpose tools or generally available free-programs which are used unmodified in performing those activities but-which are not part of the work.  For example, Corresponding Source-includes interface definition files associated with source files for-the work, and the source code for shared libraries and dynamically-linked subprograms that the work is specifically designed to require,-such as by intimate data communication or control flow between those-subprograms and other parts of the work.--  The Corresponding Source need not include anything that users-can regenerate automatically from other parts of the Corresponding-Source.--  The Corresponding Source for a work in source code form is that-same work.--  2. Basic Permissions.--  All rights granted under this License are granted for the term of-copyright on the Program, and are irrevocable provided the stated-conditions are met.  This License explicitly affirms your unlimited-permission to run the unmodified Program.  The output from running a-covered work is covered by this License only if the output, given its-content, constitutes a covered work.  This License acknowledges your-rights of fair use or other equivalent, as provided by copyright law.--  You may make, run and propagate covered works that you do not-convey, without conditions so long as your license otherwise remains-in force.  You may convey covered works to others for the sole purpose-of having them make modifications exclusively for you, or provide you-with facilities for running those works, provided that you comply with-the terms of this License in conveying all material for which you do-not control copyright.  Those thus making or running the covered works-for you must do so exclusively on your behalf, under your direction-and control, on terms that prohibit them from making any copies of-your copyrighted material outside their relationship with you.--  Conveying under any other circumstances is permitted solely under-the conditions stated below.  Sublicensing is not allowed; section 10-makes it unnecessary.--  3. Protecting Users' Legal Rights From Anti-Circumvention Law.--  No covered work shall be deemed part of an effective technological-measure under any applicable law fulfilling obligations under article-11 of the WIPO copyright treaty adopted on 20 December 1996, or-similar laws prohibiting or restricting circumvention of such-measures.--  When you convey a covered work, you waive any legal power to forbid-circumvention of technological measures to the extent such circumvention-is effected by exercising rights under this License with respect to-the covered work, and you disclaim any intention to limit operation or-modification of the work as a means of enforcing, against the work's-users, your or third parties' legal rights to forbid circumvention of-technological measures.--  4. Conveying Verbatim Copies.--  You may convey verbatim copies of the Program's source code as you-receive it, in any medium, provided that you conspicuously and-appropriately publish on each copy an appropriate copyright notice;-keep intact all notices stating that this License and any-non-permissive terms added in accord with section 7 apply to the code;-keep intact all notices of the absence of any warranty; and give all-recipients a copy of this License along with the Program.--  You may charge any price or no price for each copy that you convey,-and you may offer support or warranty protection for a fee.--  5. Conveying Modified Source Versions.--  You may convey a work based on the Program, or the modifications to-produce it from the Program, in the form of source code under the-terms of section 4, provided that you also meet all of these conditions:--    a) The work must carry prominent notices stating that you modified-    it, and giving a relevant date.--    b) The work must carry prominent notices stating that it is-    released under this License and any conditions added under section-    7.  This requirement modifies the requirement in section 4 to-    "keep intact all notices".--    c) You must license the entire work, as a whole, under this-    License to anyone who comes into possession of a copy.  This-    License will therefore apply, along with any applicable section 7-    additional terms, to the whole of the work, and all its parts,-    regardless of how they are packaged.  This License gives no-    permission to license the work in any other way, but it does not-    invalidate such permission if you have separately received it.--    d) If the work has interactive user interfaces, each must display-    Appropriate Legal Notices; however, if the Program has interactive-    interfaces that do not display Appropriate Legal Notices, your-    work need not make them do so.--  A compilation of a covered work with other separate and independent-works, which are not by their nature extensions of the covered work,-and which are not combined with it such as to form a larger program,-in or on a volume of a storage or distribution medium, is called an-"aggregate" if the compilation and its resulting copyright are not-used to limit the access or legal rights of the compilation's users-beyond what the individual works permit.  Inclusion of a covered work-in an aggregate does not cause this License to apply to the other-parts of the aggregate.--  6. Conveying Non-Source Forms.--  You may convey a covered work in object code form under the terms-of sections 4 and 5, provided that you also convey the-machine-readable Corresponding Source under the terms of this License,-in one of these ways:--    a) Convey the object code in, or embodied in, a physical product-    (including a physical distribution medium), accompanied by the-    Corresponding Source fixed on a durable physical medium-    customarily used for software interchange.--    b) Convey the object code in, or embodied in, a physical product-    (including a physical distribution medium), accompanied by a-    written offer, valid for at least three years and valid for as-    long as you offer spare parts or customer support for that product-    model, to give anyone who possesses the object code either (1) a-    copy of the Corresponding Source for all the software in the-    product that is covered by this License, on a durable physical-    medium customarily used for software interchange, for a price no-    more than your reasonable cost of physically performing this-    conveying of source, or (2) access to copy the-    Corresponding Source from a network server at no charge.--    c) Convey individual copies of the object code with a copy of the-    written offer to provide the Corresponding Source.  This-    alternative is allowed only occasionally and noncommercially, and-    only if you received the object code with such an offer, in accord-    with subsection 6b.--    d) Convey the object code by offering access from a designated-    place (gratis or for a charge), and offer equivalent access to the-    Corresponding Source in the same way through the same place at no-    further charge.  You need not require recipients to copy the-    Corresponding Source along with the object code.  If the place to-    copy the object code is a network server, the Corresponding Source-    may be on a different server (operated by you or a third party)-    that supports equivalent copying facilities, provided you maintain-    clear directions next to the object code saying where to find the-    Corresponding Source.  Regardless of what server hosts the-    Corresponding Source, you remain obligated to ensure that it is-    available for as long as needed to satisfy these requirements.--    e) Convey the object code using peer-to-peer transmission, provided-    you inform other peers where the object code and Corresponding-    Source of the work are being offered to the general public at no-    charge under subsection 6d.--  A separable portion of the object code, whose source code is excluded-from the Corresponding Source as a System Library, need not be-included in conveying the object code work.--  A "User Product" is either (1) a "consumer product", which means any-tangible personal property which is normally used for personal, family,-or household purposes, or (2) anything designed or sold for incorporation-into a dwelling.  In determining whether a product is a consumer product,-doubtful cases shall be resolved in favor of coverage.  For a particular-product received by a particular user, "normally used" refers to a-typical or common use of that class of product, regardless of the status-of the particular user or of the way in which the particular user-actually uses, or expects or is expected to use, the product.  A product-is a consumer product regardless of whether the product has substantial-commercial, industrial or non-consumer uses, unless such uses represent-the only significant mode of use of the product.--  "Installation Information" for a User Product means any methods,-procedures, authorization keys, or other information required to install-and execute modified versions of a covered work in that User Product from-a modified version of its Corresponding Source.  The information must-suffice to ensure that the continued functioning of the modified object-code is in no case prevented or interfered with solely because-modification has been made.--  If you convey an object code work under this section in, or with, or-specifically for use in, a User Product, and the conveying occurs as-part of a transaction in which the right of possession and use of the-User Product is transferred to the recipient in perpetuity or for a-fixed term (regardless of how the transaction is characterized), the-Corresponding Source conveyed under this section must be accompanied-by the Installation Information.  But this requirement does not apply-if neither you nor any third party retains the ability to install-modified object code on the User Product (for example, the work has-been installed in ROM).--  The requirement to provide Installation Information does not include a-requirement to continue to provide support service, warranty, or updates-for a work that has been modified or installed by the recipient, or for-the User Product in which it has been modified or installed.  Access to a-network may be denied when the modification itself materially and-adversely affects the operation of the network or violates the rules and-protocols for communication across the network.--  Corresponding Source conveyed, and Installation Information provided,-in accord with this section must be in a format that is publicly-documented (and with an implementation available to the public in-source code form), and must require no special password or key for-unpacking, reading or copying.--  7. Additional Terms.--  "Additional permissions" are terms that supplement the terms of this-License by making exceptions from one or more of its conditions.-Additional permissions that are applicable to the entire Program shall-be treated as though they were included in this License, to the extent-that they are valid under applicable law.  If additional permissions-apply only to part of the Program, that part may be used separately-under those permissions, but the entire Program remains governed by-this License without regard to the additional permissions.--  When you convey a copy of a covered work, you may at your option-remove any additional permissions from that copy, or from any part of-it.  (Additional permissions may be written to require their own-removal in certain cases when you modify the work.)  You may place-additional permissions on material, added by you to a covered work,-for which you have or can give appropriate copyright permission.--  Notwithstanding any other provision of this License, for material you-add to a covered work, you may (if authorized by the copyright holders of-that material) supplement the terms of this License with terms:--    a) Disclaiming warranty or limiting liability differently from the-    terms of sections 15 and 16 of this License; or--    b) Requiring preservation of specified reasonable legal notices or-    author attributions in that material or in the Appropriate Legal-    Notices displayed by works containing it; or--    c) Prohibiting misrepresentation of the origin of that material, or-    requiring that modified versions of such material be marked in-    reasonable ways as different from the original version; or--    d) Limiting the use for publicity purposes of names of licensors or-    authors of the material; or--    e) Declining to grant rights under trademark law for use of some-    trade names, trademarks, or service marks; or--    f) Requiring indemnification of licensors and authors of that-    material by anyone who conveys the material (or modified versions of-    it) with contractual assumptions of liability to the recipient, for-    any liability that these contractual assumptions directly impose on-    those licensors and authors.--  All other non-permissive additional terms are considered "further-restrictions" within the meaning of section 10.  If the Program as you-received it, or any part of it, contains a notice stating that it is-governed by this License along with a term that is a further-restriction, you may remove that term.  If a license document contains-a further restriction but permits relicensing or conveying under this-License, you may add to a covered work material governed by the terms-of that license document, provided that the further restriction does-not survive such relicensing or conveying.--  If you add terms to a covered work in accord with this section, you-must place, in the relevant source files, a statement of the-additional terms that apply to those files, or a notice indicating-where to find the applicable terms.--  Additional terms, permissive or non-permissive, may be stated in the-form of a separately written license, or stated as exceptions;-the above requirements apply either way.--  8. Termination.--  You may not propagate or modify a covered work except as expressly-provided under this License.  Any attempt otherwise to propagate or-modify it is void, and will automatically terminate your rights under-this License (including any patent licenses granted under the third-paragraph of section 11).--  However, if you cease all violation of this License, then your-license from a particular copyright holder is reinstated (a)-provisionally, unless and until the copyright holder explicitly and-finally terminates your license, and (b) permanently, if the copyright-holder fails to notify you of the violation by some reasonable means-prior to 60 days after the cessation.--  Moreover, your license from a particular copyright holder is-reinstated permanently if the copyright holder notifies you of the-violation by some reasonable means, this is the first time you have-received notice of violation of this License (for any work) from that-copyright holder, and you cure the violation prior to 30 days after-your receipt of the notice.--  Termination of your rights under this section does not terminate the-licenses of parties who have received copies or rights from you under-this License.  If your rights have been terminated and not permanently-reinstated, you do not qualify to receive new licenses for the same-material under section 10.--  9. Acceptance Not Required for Having Copies.--  You are not required to accept this License in order to receive or-run a copy of the Program.  Ancillary propagation of a covered work-occurring solely as a consequence of using peer-to-peer transmission-to receive a copy likewise does not require acceptance.  However,-nothing other than this License grants you permission to propagate or-modify any covered work.  These actions infringe copyright if you do-not accept this License.  Therefore, by modifying or propagating a-covered work, you indicate your acceptance of this License to do so.--  10. Automatic Licensing of Downstream Recipients.--  Each time you convey a covered work, the recipient automatically-receives a license from the original licensors, to run, modify and-propagate that work, subject to this License.  You are not responsible-for enforcing compliance by third parties with this License.--  An "entity transaction" is a transaction transferring control of an-organization, or substantially all assets of one, or subdividing an-organization, or merging organizations.  If propagation of a covered-work results from an entity transaction, each party to that-transaction who receives a copy of the work also receives whatever-licenses to the work the party's predecessor in interest had or could-give under the previous paragraph, plus a right to possession of the-Corresponding Source of the work from the predecessor in interest, if-the predecessor has it or can get it with reasonable efforts.--  You may not impose any further restrictions on the exercise of the-rights granted or affirmed under this License.  For example, you may-not impose a license fee, royalty, or other charge for exercise of-rights granted under this License, and you may not initiate litigation-(including a cross-claim or counterclaim in a lawsuit) alleging that-any patent claim is infringed by making, using, selling, offering for-sale, or importing the Program or any portion of it.--  11. Patents.--  A "contributor" is a copyright holder who authorizes use under this-License of the Program or a work on which the Program is based.  The-work thus licensed is called the contributor's "contributor version".--  A contributor's "essential patent claims" are all patent claims-owned or controlled by the contributor, whether already acquired or-hereafter acquired, that would be infringed by some manner, permitted-by this License, of making, using, or selling its contributor version,-but do not include claims that would be infringed only as a-consequence of further modification of the contributor version.  For-purposes of this definition, "control" includes the right to grant-patent sublicenses in a manner consistent with the requirements of-this License.--  Each contributor grants you a non-exclusive, worldwide, royalty-free-patent license under the contributor's essential patent claims, to-make, use, sell, offer for sale, import and otherwise run, modify and-propagate the contents of its contributor version.--  In the following three paragraphs, a "patent license" is any express-agreement or commitment, however denominated, not to enforce a patent-(such as an express permission to practice a patent or covenant not to-sue for patent infringement).  To "grant" such a patent license to a-party means to make such an agreement or commitment not to enforce a-patent against the party.--  If you convey a covered work, knowingly relying on a patent license,-and the Corresponding Source of the work is not available for anyone-to copy, free of charge and under the terms of this License, through a-publicly available network server or other readily accessible means,-then you must either (1) cause the Corresponding Source to be so-available, or (2) arrange to deprive yourself of the benefit of the-patent license for this particular work, or (3) arrange, in a manner-consistent with the requirements of this License, to extend the patent-license to downstream recipients.  "Knowingly relying" means you have-actual knowledge that, but for the patent license, your conveying the-covered work in a country, or your recipient's use of the covered work-in a country, would infringe one or more identifiable patents in that-country that you have reason to believe are valid.--  If, pursuant to or in connection with a single transaction or-arrangement, you convey, or propagate by procuring conveyance of, a-covered work, and grant a patent license to some of the parties-receiving the covered work authorizing them to use, propagate, modify-or convey a specific copy of the covered work, then the patent license-you grant is automatically extended to all recipients of the covered-work and works based on it.--  A patent license is "discriminatory" if it does not include within-the scope of its coverage, prohibits the exercise of, or is-conditioned on the non-exercise of one or more of the rights that are-specifically granted under this License.  You may not convey a covered-work if you are a party to an arrangement with a third party that is-in the business of distributing software, under which you make payment-to the third party based on the extent of your activity of conveying-the work, and under which the third party grants, to any of the-parties who would receive the covered work from you, a discriminatory-patent license (a) in connection with copies of the covered work-conveyed by you (or copies made from those copies), or (b) primarily-for and in connection with specific products or compilations that-contain the covered work, unless you entered into that arrangement,-or that patent license was granted, prior to 28 March 2007.--  Nothing in this License shall be construed as excluding or limiting-any implied license or other defenses to infringement that may-otherwise be available to you under applicable patent law.--  12. No Surrender of Others' Freedom.--  If conditions are imposed on you (whether by court order, agreement or-otherwise) that contradict the conditions of this License, they do not-excuse you from the conditions of this License.  If you cannot convey a-covered work so as to satisfy simultaneously your obligations under this-License and any other pertinent obligations, then as a consequence you may-not convey it at all.  For example, if you agree to terms that obligate you-to collect a royalty for further conveying from those to whom you convey-the Program, the only way you could satisfy both those terms and this-License would be to refrain entirely from conveying the Program.--  13. Use with the GNU Affero General Public License.--  Notwithstanding any other provision of this License, you have-permission to link or combine any covered work with a work licensed-under version 3 of the GNU Affero General Public License into a single-combined work, and to convey the resulting work.  The terms of this-License will continue to apply to the part which is the covered work,-but the special requirements of the GNU Affero General Public License,-section 13, concerning interaction through a network will apply to the-combination as such.--  14. Revised Versions of this License.--  The Free Software Foundation may publish revised and/or new versions of-the GNU General Public License from time to time.  Such new versions will-be similar in spirit to the present version, but may differ in detail to-address new problems or concerns.--  Each version is given a distinguishing version number.  If the-Program specifies that a certain numbered version of the GNU General-Public License "or any later version" applies to it, you have the-option of following the terms and conditions either of that numbered-version or of any later version published by the Free Software-Foundation.  If the Program does not specify a version number of the-GNU General Public License, you may choose any version ever published-by the Free Software Foundation.--  If the Program specifies that a proxy can decide which future-versions of the GNU General Public License can be used, that proxy's-public statement of acceptance of a version permanently authorizes you-to choose that version for the Program.--  Later license versions may give you additional or different-permissions.  However, no additional obligations are imposed on any-author or copyright holder as a result of your choosing to follow a-later version.--  15. Disclaimer of Warranty.--  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY-APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR-PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM-IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.--  16. Limitation of Liability.--  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF-SUCH DAMAGES.--  17. Interpretation of Sections 15 and 16.--  If the disclaimer of warranty and limitation of liability provided-above cannot be given local legal effect according to their terms,-reviewing courts shall apply local law that most closely approximates-an absolute waiver of all civil liability in connection with the-Program, unless a warranty or assumption of liability accompanies a-copy of the Program in return for a fee.--                     END OF TERMS AND CONDITIONS--            How to Apply These Terms to Your New Programs--  If you develop a new program, and you want it to be of the greatest-possible use to the public, the best way to achieve this is to make it-free software which everyone can redistribute and change under these terms.--  To do so, attach the following notices to the program.  It is safest-to attach them to the start of each source file to most effectively-state the exclusion of warranty; and each file should have at least-the "copyright" line and a pointer to where the full notice is found.--    <one line to give the program's name and a brief idea of what it does.>-    Copyright (C) <year>  <name of author>--    This program is free software: you can redistribute it and/or modify-    it under the terms of the GNU General Public License as published by-    the Free Software Foundation, either version 3 of the License, or-    (at your option) any later version.--    This program is distributed in the hope that it will be useful,-    but WITHOUT ANY WARRANTY; without even the implied warranty of-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the-    GNU General Public License for more details.--    You should have received a copy of the GNU General Public License-    along with this program.  If not, see <http://www.gnu.org/licenses/>.--Also add information on how to contact you by electronic and paper mail.--  If the program does terminal interaction, make it output a short-notice like this when it starts in an interactive mode:--    <program>  Copyright (C) <year>  <name of author>-    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.-    This is free software, and you are welcome to redistribute it-    under certain conditions; type `show c' for details.--The hypothetical commands `show w' and `show c' should show the appropriate-parts of the General Public License.  Of course, your program's commands-might be different; for a GUI interface, you would use an "about box".--  You should also get your employer (if you work as a programmer) or school,-if any, to sign a "copyright disclaimer" for the program, if necessary.-For more information on this, and how to apply and follow the GNU GPL, see-<http://www.gnu.org/licenses/>.--  The GNU General Public License does not permit incorporating your program-into proprietary programs.  If your program is a subroutine library, you-may consider it more useful to permit linking proprietary applications with-the library.  If this is what you want to do, use the GNU Lesser General-Public License instead of this License.  But first, please read-<http://www.gnu.org/philosophy/why-not-lgpl.html>.
doc/assistant.mdwn view
@@ -1,6 +1,53 @@-The git-annex assistant makes git-annex easy to use by providing a-automatic management and syncing of your files, and a friendly web frontend-for configuration.+The git-annex assistant creates a folder on each of your computers,+removable drives, and cloud services, which+it keeps synchronised, so its contents are the same everywhere.+It's very easy to use, and has all the power of git and git-annex.++Note that the git-annex assistant is still beta quality code. See+[[the_errata]] for known infelicities.++## installation++The git-annex assistant comes as part of git-annex, starting with version+3.20120924. See [[install]] to get it installed.++## quick start++To get started with the git-annex assistant, just pick it from+your system's list of applications.++[[!img assistant/menu.png]]+[[!img assistant/osx-app.png]]++It'll prompt you to set up a folder:++[[!img assistant/makerepo.png]]++Then any changes you make to its folder will automatically be committed to+git, and synced to repositories on other computers. You can use the+interface to add repositories and control the git-annex assistant.++[[!img assistant/running.png]]++## documentation++* Want to make two nearby computers share the same synchronised folder?+  Follow the [[pairing_walkthrough]].++## command line startup++The git-annex assistant will automatically be started when you log in to+desktop environments like Mac OS X, Gnome, XFCE, and KDE, and the menu item+shown above can be used to open the webapp. On other systems, you may need+to start it by hand.++To start the webapp, run `git annex webapp` at the command line.++To start the assistant without opening the webapp, +you can run the command "git annex assistant --autostart". This is a+good thing to configure your system to run automatically when you log in.++## colophon  The git-annex assistant is being [crowd funded on
+ doc/assistant/addsshserver.png view

binary file changed (absent → 31740 bytes)

+ doc/assistant/errata.mdwn view
@@ -0,0 +1,37 @@+## version 3.20120924++This is the first beta release of the git-annex assistant.++In general, anything you can configure with the assistant's web app+will work. Some examples of use cases supported by this release include:++* [[Pairing|pairing_walkthrough]] two computers that are on the same local+  network (or VPN) and automatically keeping the files in the annex in+  sync as changes are made to them.+* Cloning your repository to removable drives, USB keys, etc. The assistant+  will notice when the drive is mounted and keep it in sync.+  Such a drive can be stored as an offline backup, or transported between+  computers to keep them in sync.+* Cloning your repository to a remote server, running ssh, and uploading+  changes made to your files to the server. There is special support+  for using the rsync.net cloud provider this way, or any shell account+  on a typical unix server, such as a Linode VPS can be used.++The following are known limitations of this release of the git-annex+assistant:++* On Mac OSX and BSD operating systems, the assistant uses kqueue to watch+  files. Kqueue has to open every directory it watches, so too many+  directories will run it out of the max number of open files (typically+  1024), and fail. See [[bugs/Issue_on_OSX_with_some_system_limits]]+  for a workaround.+* In order to ensure that all multiple repositories are kept in sync,+  each computer with a repository must be running the git-annex assistant.+* The assistant does not yet always manage to keep repositories in sync+  when some are hidden from others behind firewalls.+* If a file is checked into git as a normal file and gets modified+  (or merged, etc), it will be converted into an annexed file. So you+  should not mix use of the assistant with normal git files in the same+  repository yet.+* If you `git annex unlock` a file, it will immediately be re-locked.+  See [[bugs/watcher_commits_unlocked_files]].
+ doc/assistant/makerepo.png view

binary file changed (absent → 32061 bytes)

+ doc/assistant/menu.png view

binary file changed (absent → 22921 bytes)

+ doc/assistant/osx-app.png view

binary file changed (absent → 2604 bytes)

+ doc/assistant/pairing_walkthrough.mdwn view
@@ -0,0 +1,50 @@+So you have two computers in the same building, and you want them to share+the same synchronised folder, communicating directly with each other.++This is incredibly easy to set up with the git annex assistant.++Let's say the two computers are your computer and your friend's computer.+We'll start on your computer, where you open up your git annex dashboard.++[[!img addrepository.png alt="Add another repository button"]]++`*click*`++[[!img pairing.png alt="Pair with local computer"]]++Now the hard bit. You have to think up a secret phrase, and type it in,+(and perhaps get the spelling correct).++[[!img secret.png alt="Enter secret phrase"]]++Now your computer is in pairing mode. When your friend looks at her git+annex dashboard, she sees something like this.++[[!img pairrequest.png alt="Pair request"]]++`*click*`++[[!img secretempty.png alt="Enter same secret phrase"]]++Now it's up to you to let her know what the secret is. As soon as she+enters it, both your computers will be paired, and will begin to sync their+git-annex folders. Just like that you can share files.++----++Something to keep in mind, especially if pairing doesn't seem to be+working, is that the two computers need to be on the same network for this+pairing process to work. Sometimes a building will have more than one+network inside it, and you'll need to connect them both to the same one.+Make sure the wireless network name is the same, or that they're both+plugged into the same router.++Also, the file sharing set up by this pairing only works when both+computers are on the same network. If you go on a trip, any files you+edit will not be visible to your friend until you get back. **But**,+you can get around this by hooking both computers up to a server on the+internet, which they can use to exchange files while disconnected. The+git annex assistant makes that easy too.++And also, you can pair with as many other computers as you like, not just+one!
+ doc/assistant/pairing_walkthrough/addrepository.png view

binary file changed (absent → 2259 bytes)

+ doc/assistant/pairing_walkthrough/pairing.png view

binary file changed (absent → 6771 bytes)

+ doc/assistant/pairing_walkthrough/pairrequest.png view

binary file changed (absent → 5383 bytes)

+ doc/assistant/pairing_walkthrough/secret.png view

binary file changed (absent → 5132 bytes)

+ doc/assistant/pairing_walkthrough/secretempty.png view

binary file changed (absent → 9575 bytes)

+ doc/assistant/repositories.png view

binary file changed (absent → 63405 bytes)

+ doc/assistant/rsync.net.png view

binary file changed (absent → 61465 bytes)

+ doc/assistant/running.png view

binary file changed (absent → 24664 bytes)

+ doc/assistant/thumbnail.png view

binary file changed (absent → 3491 bytes)

doc/backends.mdwn view
@@ -5,21 +5,21 @@ Multiple pluggable key-value backends are supported, and a single repository can use different ones for different files. -* `SHA256` -- The default backend for new files. This allows+* `SHA256E` -- The default backend for new files. This allows   verifying that the file content is right, and can avoid duplicates of   files with the same content. Its need to generate checksums   can make it slower for large files. +* `SHA256` -- Does not include the file extension in the key, which can+  lead to better deduplication. * `WORM` ("Write Once, Read Many") This assumes that any file with   the same basename, size, and modification time has the same content.   This is the the least expensive backend, recommended for really large   files or slow systems.-* `SHA512` -- Best currently available hash, for the very paranoid.-* `SHA1` -- Smaller hash than `SHA256` for those who want a checksum+* `SHA512`, `SHA512E` -- Best currently available hash, for the very paranoid.+* `SHA1`, `SHA1E` -- Smaller hash than `SHA256` for those who want a checksum    but are not concerned about security.-* `SHA384`, `SHA224` -- Hashes for people who like unusual sizes.-* `SHA256E`, `SHA1E`, etc -- Variants that preserve filename extension as-  part of the key. Useful for archival tasks where the filename extension-  contains metadata that should be preserved.+* `SHA384`, `SHA384E`, `SHA224`, `SHA224E` -- Hashes for people who like+  unusual sizes.  The `annex.backends` git-config setting can be used to list the backends git-annex should use. The first one listed will be used by default when@@ -29,11 +29,11 @@ files, the `.gitattributes` file can be used. The `annex.backend` attribute can be set to the name of the backend to use for matching files. -For example, to use the SHA256 backend for sound files, which tend to be+For example, to use the SHA256E backend for sound files, which tend to be smallish and might be modified or copied over time, while using the WORM backend for everything else, you could set in `.gitattributes`:  	* annex.backend=WORM-	*.mp3 annex.backend=SHA256-	*.ogg annex.backend=SHA256+	*.mp3 annex.backend=SHA256E+	*.ogg annex.backend=SHA256E
+ doc/bugs/ControlPath_too_long_for_Unix_domain_socket.mdwn view
@@ -0,0 +1,50 @@+What steps will reproduce the problem?+Pairing an existing git annex repository with a fresh repository on another computer in the git-annex webapp+++What is the expected output? What do you see instead?+Expected result is that the two machines sync correctly.++What i see are some "ControlPath <data>  too long for unix domain socket" errors from ssh, but the computers do actually sync properly. ++Even though the data is synced properly, either the sender(or both of the clients) don't actually realize this. And the queue circles, all the transfers are being redone constantly(On every start of git-annex webapp on the original repository at least).+++What version of git-annex are you using? On what operating system?+Latest git master as of this post. Debian sid and Ubuntu 12.04+++Please provide any additional information below.+++stdout snippet from git-annex webapp:+++    ControlPath "/home/alansmithee/Desktop/annex/.git/annex/ssh/alansmithee@git-annex-debbook.local-alansmithee.dxpXHVCkLhsxvWaH" too long for Unix domain socket+    SHA256-s51233--0b4c59b3ab03b1ca6d95d4084fa6ff7220cf26695b6e3dd575f78af3dec6b701+           51233 100%    5.43MB/s    0:00:00 (xfer#1, to-check=0/1)++    sent 30 bytes  received 51385 bytes  102830.00 bytes/sec+    total size is 51233  speedup is 1.00+    ok+    (Recording state in git...)++    ControlPath "/home/alansmithee/Desktop/annex/.git/annex/ssh/alansmithee@git-annex-debbook.local-alansmithee.9ZQwEjraTxi20B6W" too long for Unix domain socket+    SHA256-s47883982--4b7cbb49506dcdd223a9db7b400cc41fc2e3ebbf5b2b17b75c9334bb949b6754+        47883982 100%    1.34MB/s    0:00:34 (xfer#1, to-check=0/1)++    sent 30 bytes  received 47889978 bytes  1388116.17 bytes/sec+    total size is 47883982  speedup is 1.00+    ok+    (Recording state in git...)+++This data appears on both the sending and receiving git-annex stdout. At least for the initial sync. For later syncs it only appears on the sender, though the client system is using a lot of resources.++> I've made git-annex detect if the control path would be too long,+> and disable ssh connection caching. It also tries a relative path+> to the file, which tends to make it shorter, and I think would+> keep ssh connection caching working in your example.+> +> Please test and see if it works, and also if the "looping" problem+> still happens. --[[Joey]]
+ doc/bugs/Could_not_find_module_Data.Default.mdwn view
@@ -0,0 +1,33 @@+**What steps will reproduce the problem?**++Manually building git-annex from git.++**What is the expected output? What do you see instead?**++    $ cabal update+    ...+    $ cabal install --only-dependencies+    ...+    $ cabal configure+    ...+    $ cabal build+    Building git-annex-3.20120826...+    Preprocessing executable 'git-annex' for git-annex-3.20120826...+    +    Utility/Yesod.hs:15:8:+        Could not find module `Data.Default'+        It is a member of the hidden package `data-default-0.5.0'.+        Perhaps you need to add `data-default' to the build-depends in your .cabal file.+        Use -v to see a list of the files searched for.+    $++**What version of git-annex are you using? On what operating system?**++commit e7d728672a5fc923be9ab1d6fe4b65f2058b49c7+Arch Linux++**Please provide any additional information below.**++When I add data-default to git-annex.cabal's Build-Deps it works fine.++> Thanks, [[done]]. --[[Joey]]
+ doc/bugs/Using_Github_as_remote_throws_proxy_errors.mdwn view
@@ -0,0 +1,25 @@+What steps will reproduce the problem?++1. cd to an already existing git repository that uses Github as a remote, with the remote format similar to git@github.com:user/repo.git+2. git annex init+3. git annex status++What is the expected output? What do you see instead?++    $ git annex status+    supported backends: SHA256 SHA1 SHA512 SHA224 SHA384 SHA256E SHA1E SHA512E SHA224E SHA384E WORM URL+    supported remote types: git S3 bup directory rsync web hook+    trusted repositories: Invalid command: 'git-annex-shell 'configlist' '/~/dlo/objectifier.git''+      You appear to be using ssh to clone a git:// URL.+      Make sure your core.gitProxy config option and the+      GIT_PROXY_COMMAND environment variable are NOT set.+    Command ssh ["-S","/Users/dan/Documents/Web/objectifier/.git/annex/ssh/git@github.com","-o","ControlMaster=auto","-o","ControlPersist=yes","git@github.com","git-annex-shell 'configlist' '/~/dlo/objectifier.git'"] failed; exit code 1+    0+    # ... other stuff that isn't relevant+++What version of git-annex are you using? On what operating system?++git-annex-3.20120825++Max OS X 10.8.1
doc/bugs/commitBuffer:_invalid_argument___40__invalid_character__41__.mdwn view
@@ -223,3 +223,6 @@     failed     (Recording state in git...)     git-annex: copy: 1 failed++> [[Fixed|done]]. Sorry this took so long, I was at a very busy point when+> you filed this and am only just getting caught up. --[[Joey]]
+ doc/bugs/fatal:_empty_ident_name.mdwn view
@@ -0,0 +1,48 @@+**What steps will reproduce the problem?**++    stone@skynet ~/annex $ git init+    Initialized empty Git repository in /home/stone/annex/.git/+    stone@skynet ~/annex $ git annex init "work"+    init work +    *** Please tell me who you are.+    +    Run+    +      git config --global user.email "you@example.com"+      git config --global user.name "Your Name"+    +    to set your account's default identity.+    Omit --global to set the identity only in this repository.+    +    fatal: empty ident name (for <stone@skynet>) not allowed+    git-annex: git ["--git-dir=/home/stone/annex/.git","--work-tree=/home/stone/annex","commit-tree","4b825dc652cb6eb9a060e64bf8d69288fbee4904"] exited 128+    stone@skynet ~/annex $ git config -l+    user.email=stone@nospam.hu+    user.name=Stone+    core.editor=nano+    color.ui=auto+    core.repositoryformatversion=0+    core.filemode=true+    core.bare=false+    core.logallrefupdates=true+    annex.uuid=499fb545-0b98-4bfc-816c-fb3704f3aaa0+    stone@skynet ~/annex $ cat ~/.gitconfig +    [user]+    	email = stone@nospam.hu+    	name = Stone+    [core]+    	editor = nano+    [color]+    	ui = auto+    stone@skynet ~/annex $ ++**What is the expected output? What do you see instead?**+++**What version of git-annex are you using? On what operating system?**++commit 56c037c69e75def74d6ea90de8aa8a1954c52178 Arch Linux++**Please provide any additional information below.**++> [[done]] by adding name to the user, in /etc/passwd. --Stone
+ doc/bugs/git-annex_sync_broken_on_squeeze_backports.mdwn view
@@ -0,0 +1,20 @@+What steps will reproduce the problem?++    git-annex sync++What is the expected output? What do you see instead?++The following error is mixed in with the output, took me a while to notice it:++    Running: git ["--git-dir=/spare/annex/.git","--work-tree=/spare/annex","merge","--no-edit","refs/remotes/pip/synced/master"] +    error: unknown option `no-edit'++What version of git-annex are you using? On what operating system?++3.20120629~bpo60+1 on debian squeeze++Please provide any additional information below.++Installing git from backports as well cleared up the problem.++> Uploading a fix for this now. [[done]] Thanks for reporting. --[[Joey]] 
doc/bugs/git_annex_does_nothing_useful.mdwn view
@@ -58,3 +58,5 @@     $  Alright, it didn't fail with an error, that's very strange. What is going on here?++[[!meta title="v1 file is ignored"]]
+ doc/bugs/git_defunct_processes___40__child_of_git-annex_assistant__41__.mdwn view
@@ -0,0 +1,32 @@+What steps will reproduce the problem?++run git annex assistant, add a file, which is picked up and pushed by the assistant.  ++What is the expected output? What do you see instead?++a ps -ef shows a large number of defunct git processes.. for example:+<pre>+nelg      9622     1  0 02:01 ?        00:00:01 git-annex assistant+nelg      9637  9622  0 02:01 ?        00:00:00 git --git-dir=/home/nelg/Downloads/test2/.git --work-tree=/home/nelg/Downloads/test2 cat-file --batch+nelg     12080  9622  0 02:19 ?        00:00:00 [git] &lt;defunct&gt;+nelg     12082  9622  0 02:19 ?        00:00:00 [git] &lt;defunct&gt;+nelg     12083  9622  0 02:19 ?        00:00:00 [git] &lt;defunct&gt;+nelg     12084  9622  0 02:19 ?        00:00:00 [git] &lt;defunct&gt;+-----+</pre>++What version of git-annex are you using? On what operating system?++Compiled git annex from git (cbcd208d158f8e42dda03a5eeaf1bac21045a140), on Mandriva 2010.2, 32 bit, using ghc-7.4.1.+ git version 1.7.1+++Please provide any additional information below.++I also found that the version of git I have does not support the option: --allow-empty-message+So, suggest that if the version of git installed is an older version, that the params in  Assistant/Threads/Committer.hs+are changed to  [ Param "-m", Param "git assistant".... or something like that.++I have done this on my copy for testing it.++For testing, I am also using two repositories on the same computer.  I set this up from the command line, as the web app does not seem to support syncing to two different git folders on the same computer.
doc/bugs/lsof__47__committer_thread_loops_occassionally.mdwn view
@@ -47,3 +47,5 @@ </pre>  I ran " git annex watch -d --foreground" to watch what was going one, and just created a .gitignore file and the the commiter/lsof thread just loops over and over.... I only noticed as my laptop battery had drained at somepoint when git-annex was running in the background.++[[!meta title="assistant: lsof/committer thread loops occassionally"]]
+ doc/bugs/pasting_into_annex_on_OSX.mdwn view
@@ -0,0 +1,18 @@+What steps will reproduce the problem?++Try pasting file into annex directory while assistant is running.+++What is the expected output? What do you see instead?++Expect file to successfully paste into directory, then be annexed. Instead, see a permissions error, and file disappears.+++What version of git-annex are you using? On what operating system?++OSX - 10.6. zsh. git-annex version: 3.20120826++Please provide any additional information below.++> Ok, I've put in the one second delay to adding by default on OSX.+> I consider this bug [[done]], at least for now..
doc/bugs/reinject_should_leave_file_in_place_on_checksum_mismatch.mdwn view
@@ -11,3 +11,5 @@ git-annex version: 3.20120807 Ubuntu 12.04 updated on Aug 20th annex was installed via cabal on Aug 20th, all other packages are from ubuntu.++> [[done]] --[[Joey]] 
+ doc/bugs/rsync_remote_shows_no_progress.mdwn view
@@ -0,0 +1,15 @@+What steps will reproduce the problem?+Init a annex, add rsync remote (with or without encryption, does not matter), launch annex assistant++What is the expected output? What do you see instead?+In the dashboard, no progress is recorded for the transfer. Each file stays at 0% and then disappears as it is fully transfered. I expect the progressbar to move and show the actual transfer progress.++What version of git-annex are you using? On what operating system?+git head of today, Ubuntu 12.04++Please provide any additional information below.+I looked in the source code and found some hints that the rsync progress should actually be evaluated and shown, I'm opening a bug report for this reason.++[[!meta title="assistant: No progress bars for file uploads"]]++> now upload progress bars work! [[done]] --[[Joey]]
+ doc/bugs/transferkey_fails_due_to_gpg.mdwn view
@@ -0,0 +1,51 @@+What steps will reproduce the problem?+Create a new annex, add a new repository:++  git annex initremote vserver2 type=rsync rsyncurl=vserver.dbruhn.de:/annex encryption=dominik@dbruhn.de++Add some files, add them to annex, try to transfer them:+  git annex transferkey SHA256-s6486446--df84b11a0e9543134224d0ac1e0f2567bcd79d86605117c5af008a1b133cee3a --to vserver2 --file MKBD/OB.mp3 --debug++What is the expected output? What do you see instead?++I expect the file to be transfered to my remote server. Instead I see a 'gpg>' prompt with nothing happening. When pressing CTRL+C, the following mesage is shown:++gpg: Interrupt caught ... exiting++There must be some faults when interfacing gpg. The other console-output is:++-----+    [2012-09-08 18:50:12 CEST] read: git ["--git-dir=/home/dominik/Annex/.git","--work-tree=/home/dominik/Annex","show-ref","git-annex"] +    [2012-09-08 18:50:12 CEST] read: git ["--git-dir=/home/dominik/Annex/.git","--work-tree=/home/dominik/Annex","show-ref","--hash","refs/heads/git-annex"] +    [2012-09-08 18:50:12 CEST] read: git ["--git-dir=/home/dominik/Annex/.git","--work-tree=/home/dominik/Annex","log","refs/heads/gitannex..245fa80db6733dbbeff6c40d46bd65ed00811548","--oneline","-n1"] +    [2012-09-08 18:50:12 CEST] chat: git ["--git-dir=/home/dominik/Annex/.git","--work-tree=/home/dominik/Annex","cat-file","--batch"] +    (gpg) [2012-09-08 18:50:12 CEST] chat: gpg ["--batch","--no-tty","--use-agent","--quiet","--trust-model","always","--decrypt"] +    [2012-09-08 18:50:12 CEST] chat: gpg ["--batch","--no-tty","--use-agent","--quiet","--trust-model","always","--passphrase-fd","8","--symmetric","--force-mdc"] +    sdgdg+    dsgdgs+    ^C+    gpg: Interrupt caught ... exiting+-----++What version of git-annex are you using? On what operating system?+git-annex version: 3.20120826+Ubuntu 12.04, GHC 7.4.1+gpg is 'gpg (GnuPG) 1.4.11'++Please provide any additional information below.++The key which is used for the remote is password protected. The GnuPG Agent asks me for the password, so this seems to work. I do not know what content the gpg expects but does not recieve. The .git/config entry for the remote looks reasonable:++    [remote "vserver2"]+        annex-rsyncurl = vserver.dbruhn.de:/annex+        annex-uuid = ea3d6acc-716c-48e8-9b6b-993b90dcc1db++When adding a new rsync-remote with encryption set to 'none' (therefore disabled), everything works, so it really seems a gpg issue.++How can I help debugging?++> Thanks, I reproduced a deadlock in the gpg code, which was introduced+> with some of my earlier changes to use threading. No released version of+> git-annex was affected, and I have developed a fix, which works for me+> and is now committed to master. Marking this [[done]]; please do check+> that my fix works for you! --[[Joey]]
doc/bugs/unannex_command_doesn__39__t_all_files.mdwn view
@@ -24,3 +24,7 @@ > [[annex_unannex__47__uninit_should_handle_copies]] and `unannex --fast` > added to leave contents behind in the annex, which allows handling > copies. But needs manual cleanup later with dropunused. --[[Joey]] ++> This is basically a dup of [[Large unannex operations result in stale symlinks and data loss]],+> or at least the ideas in there will also deal with this. Closing as dupe.+> [[done]] --[[Joey]] 
doc/bugs/watcher_commits_unlocked_files.mdwn view
@@ -26,3 +26,5 @@   events when files are moved out of the repository (well, I do, but it   just says "file moved", with no forwarding address, so I don't know    how to find the file to unlock it.++[[!meta title="assistant: watcher_commits_unlocked_files"]]
doc/design/assistant.mdwn view
@@ -8,15 +8,24 @@ * Month 1 "like dropbox": [[!traillink inotify]] [[!traillink syncing]] * Month 2 "shiny webapp": [[!traillink webapp]] [[!traillink progressbars]] * Month 3 "easy setup": [[!traillink configurators]] [[!traillink pairing]]-* Month 4 "polishing": [[!traillink cloud]] [[!traillink leftovers]]-* Months 5-6 "9k bonus round": [[!traillink Android]] [[!traillink partial_content]]-* Months 7-11: user-driven features and polishing++We are, approximately, here:++* Month 4 "cloud": [[!traillink cloud]] [[!traillink transfer_control]]+* Month 5 user-driven features (see [[polls]])+* Months 6-7 "9k bonus round": [[!traillink Android]] [[!traillink partial_content]] [[!traillink leftovers]]+* Months 8-11: more user-driven features and polishing (see remaining TODO items in all pages above) * Month 12: "Windows purgatory" [[Windows]] +## porting++* [[OSX]] port is in fairly good shape, but still has some room for improvement+ ## not yet on the map:  * [[desymlink]] * [[deltas]]+* [[!traillink leftovers]]  ## blog 
+ doc/design/assistant/OSX.mdwn view
@@ -0,0 +1,13 @@+Misc OSX porting things:++* autostart the assistant on OSX, using launchd **done**+* icon to start webapp **done**+* Use OSX's "network reachability functionality" to detect when on a network+  <http://developer.apple.com/library/mac/#documentation/Networking/Conceptual/SystemConfigFrameworks/SC_Intro/SC_Intro.html#//apple_ref/doc/uid/TP40001065>++Gripes:++* The assistant has to wait a second when a new file is created,+  to work around some bad behavior when pasting a file into the annex.+  [[details|bugs/pasting_into_annex_on_OSX]]. That's one more second+  before the file is synced out.
+ doc/design/assistant/OSX/comment_1_9290f6e6f265e906b08631224392b7bf._comment view
@@ -0,0 +1,14 @@+[[!comment format=mdwn+ username="https://www.google.com/accounts/o8/id?id=AItOawlu-fdXIt_RF9ggvg4zP0yBbtjWQwHAMS4"+ nickname="Jörn"+ subject="Mount detection"+ date="2012-09-21T09:23:34Z"+ content="""+regarding the current mount polling on OSX: why not use the NSNotificationCenter for being notified on mount events on OSX?++Details see:++1. <http://stackoverflow.com/questions/12409458/detect-when-a-volume-is-mounted-on-os-x>+2. <http://stackoverflow.com/questions/6062299/how-to-add-an-observer-to-nsnotificationcenter-in-a-c-class-using-objective-c>+3. <https://developer.apple.com/library/mac/#documentation/CoreFoundation/Reference/CFNotificationCenterRef/Reference/reference.html#//apple_ref/doc/uid/20001438>+"""]]
doc/design/assistant/blog/day_49__first_run_experience.mdwn view
@@ -35,3 +35,5 @@  (Note: This is a wiki. You can edit this page to add your own [[ikiwiki/directive/poll]] options!)++[[!tag polls]]
+ doc/design/assistant/blog/day_65__transfer_polish.mdwn view
@@ -0,0 +1,33 @@+Almost done with the data transfer code.. Today I filled in some bits and+peices.++Made the expensive transfer scan handle multiple remotes in one pass.+So on startup, it only runs once, not N times. And when reconnecting to the+network, when a remote has changed, it scans all network remotes in one+pass, rather than making M redundant passes.++Got syncing with special remotes all working. Pretty easy actually. Just+had to avoid doing any git repo push/pull with them, while still queueing+data transfers.++It'll even download anything it can from the web special remote. To support+that, I added generic support for readonly remotes; it'll only download from+those and not try to upload to them.++(Oh, and I properly fixed the nasty `GIT_INDEX_FILE` environment variable+problem I had the other day.)++I feel I'm very close to being able to merge the assistant branch into+master now. I'm reasonably confident the data transfer code will work+well now, and manage to get things in sync eventually in all circumstances.+(Unless there are bugs.) All the other core functionality of the assistant+and webapp is working. The only think I might delay because of is the+missing [[progressbars]] in the webapp .. but that's a silly thing to+block the merge on. ++Still, I might spend a day and get a dumb implementation of progress bars+for downloads working first (progress bars for uploads are probably rather+harder). I'd spend longer on progress bars, but there are so many more+exciting things I'm now ready to develop, like automatic configurators+for using your git annex with Amazon S3, rsync.net, and the computer across+the room..!
+ doc/design/assistant/blog/day_66__the_merge.mdwn view
@@ -0,0 +1,19 @@+It's done! The assistant branch is merged into master.++Updated the [[assistant]] page with some screenshots and instructions for+using it.++Made some cosmetic fixes to the webapp.++Fixed the transferrer to use `~/.config/git-annex/program`+to find the path to git-annex when running it. (There are ways to find the+path of the currently running program in unux, but they all suck, so I'm+avoiding them this way.)++Read some OSX launchd documentation, and it seems it'd be pretty easy to+get the assistant to autostart on login on OSX. If someone would like to+test launchd files for me, get in touch.++-----++AKA: Procrastinating really hard on those progress bars. ;)
+ doc/design/assistant/blog/day_67__progress_bars.mdwn view
@@ -0,0 +1,10 @@+Got the webapp's progress bars updating for downloads. Updated+[[progressbars]] with all the options for ways to get progress info. For+downloads, it currently uses the easy, and not very expensive, approach of+periodically polling the sizes of files that are being downloaded.++For uploads, something more sophisticated will be called for..++---++The webapp really feels alive now that it has progress bars!
+ doc/design/assistant/blog/day_68__transfers.mdwn view
@@ -0,0 +1,15 @@+More work on the display and control of transfers.++* Hide redundant downloads from the transfer display. It seemed simplest+  to keep the behavior of queuing downloads from every remote that has a+  file, rather than going to some other data structure, but it's clutter+  to display those to the user, especially when you often have 7 copies+  of each file, like I do.+* When canceling a download, cancel all other queued downloads of that+  key too.+* Fixed unsettting of the paused flag when resuming a paused transfer.+* Implemented starting queued transfers by clicking on the start button.+* Spent a long time debugging why pausing, then resuming, and then pausing+  a transfer doesn't successfully pause it the second time. I see where+  the code is seemingly locking up in a `throwTo`, but I don't understand+  why that blocks forever. Urgh..
+ doc/design/assistant/blog/day_69__build_fixes.mdwn view
@@ -0,0 +1,7 @@+Short day today.++* Worked on fixing a number of build failures people reported.+* Solved the problem that was making transfer pause/resume not always work.+  Although there is another bug where pausing a transfer sometimes lets+  another queued transfer start running. +* Worked on getting the assistant to start on login on OSX.
+ doc/design/assistant/blog/day_70__adding_ssh_remotes.mdwn view
@@ -0,0 +1,66 @@+Today I built the UI in the webapp to set up a ssh or rsync remote.++This is the most generic type of remote, and so it's surely got the most+complex description. I've tried to word it as clearly as I can; suggestions+most appreciated. Perhaps I should put in a diagram?++[[!img /assistant/addsshserver.png]]++The idea is that this will probe the server, using ssh. If `git-annex-shell`+is available there, it'll go on to set up a full git remote. If not, it'll+fall back to setting up a rsync special remote. It'll even fall all the way+back to using `rsync://` protocol if it can't connect by ssh. So the user+can just point it at a server and let it take care of the details,+generally.++The trickiest part of this will be authentication, of course. I'm relying+on ssh using `ssh-askpass` to prompt for any passwords, etc, when there's+no controlling terminal. But beyond passwords, this has to deal with ssh+keys.++I'm planning to make it check if you have a ssh key configured already. If+you do, it doesn't touch your ssh configuration. I don't want to get in the+way of people who have a manual configuration or are using MonkeySphere.++But for a user who has never set up a ssh key, it will prompt asking if+they'd like a key to be set up. If so, it'll generate a key and configure+ssh to only use it with the server.. and as part of its ssh probe, that key+will be added to `authorized_keys`.++(Obviously, advanced users can skip this entirely; `git remote add+ssh://...` still works..)++----++Also today, fixed more UI glitches in the transfer display. I think+I have them all fixed now, except for the one that needs lots of javascript+to be written to fix it.++Amusingly, while I was working on UI glitches, it turned out that all the+fixes involved 100% pure code that has nothing to do with UI. The UI was+actually just exposing bugs.++For example, closing a running transfer+had a bug that weirdly reordered the queue. This turned out to be+due to the transfer queue actually maintaining two versions of the queue,+one in a TChan and one a list. Some unknown bugs caused these to get out of+sync. That was fixed very handily by deleting the TChan, so there's only+one copy of the data.++I had only been using that TChan because I wanted a way to block while the+queue was empty. But now that I'm more comfortable with STM, I know how+to do that easily using a list:++[[!format haskell """+	getQueuedTransfer q = atomically $ do+		sz <- readTVar (queuesize q)+		if sz < 1+			then retry -- blocks until size changes+			else ...+"""]]++Ah, the times before [STM](http://en.wikipedia.org/wiki/Software_transactional_memory)+were dark times indeed. I'm writing more and more STM code lately, building+up more and more complicated and useful transactions. If you use threads and+don't know about STM, it's a great thing to learn, to get out of the dark ages+of dealing with priority inversions, deadlocks, and races.
+ doc/design/assistant/blog/day_71__ssh_probing.mdwn view
@@ -0,0 +1,26 @@+Got ssh probing implemented. It checks if it can connect to the server, and+probes the server to see how it should be used. ++Turned out to need two ssh probes. The first uses the system's existing ssh+configuration, but disables password prompts. If that's able to get in+without prompting for a password, then the user must have set that up,+and doesn't want to be bothered with password prompts, and it'll respect+that configuration.++Otherwise, it sets up a per-host ssh key, and configures a hostname alias+in `~/.ssh/config` to use that key, and probes using that. +Configuring ssh this way is nice because it avoids changing ssh's+behavior except when git-annex uses it, and it does not open up the server+to arbitrary commands being run without password.++--++Next up will be creating the repositories. When there's a per-host key,+this will also involve setting up `authorized_keys`, locking down the ssh+key to only allow running git-annex-shell or rsync.++I decided to keep that separate from the ssh probing, even though it means+the user will be prompted twice for their ssh password. It's cleaner and+allows the probing to do other checks -- maybe it'll later check the amount+of free disk space -- and the user should be able to decide after the probe+whether or not to proceed with making the repository.
+ doc/design/assistant/blog/day_73__rsync.net_configurator.mdwn view
@@ -0,0 +1,17 @@+Now finished building a special configurator for rsync.net. While+this is just a rsync remote to git-annex, there are some tricky bits to+setting up the ssh key using rsync.net's restricted shell. The configurator+automates that nicely. It took about 3 hours of work, and 49 lines of+rsync.net specific code to build this.++[[!img /assistant/rsync.net.png]]++Thanks to rsync.net who heard of my Kickstarter and gave me a really+nice free lifetime account. BTW guys, I wish your restricted shell+supported '&&' in between commands, and returned a nonzero exit status when+the command fails. This would make my error handling work better.++I've also reworked the repository management page. Nice to see those+configurators start to fill in!++[[!img /assistant/repositories.png]]
+ doc/design/assistant/blog/day_74__bits_and_peices.mdwn view
@@ -0,0 +1,7 @@+* On OSX, install a launcher plist file, to run the assistant on login,+  and a `git-annex-webapp.command` file in the desktop. This is not tested+  yet.+* Made the webapp display alerts when the inotify/kqueue layer has a+  warning message.+* Handle any crashes of each of the 15 or so named threads by displaying+  an alert. (Of course, this should never happen.)
+ doc/design/assistant/blog/day_75__zeromq_and_pairing.mdwn view
@@ -0,0 +1,50 @@+Started reading about ZeroMQ with the hope that it could do some firewall+traversal thing, to connect mutually-unroutable nodes. Well, it could, but+it'd need a proxy to run on a server both can contact, and lots of+users won't have a server to run that on. The XMPP approach used by+dvcs-autosync is looking like the likeliest way for git-annex to handle+that use case.++However, ZeroMQ did point in promising directions to handle another use+case I need to support: Local [[pairing]]. In fairly short order, I got+ZeroMQ working over IP Multicast (PGM), with multiple publishers sending+messages that were all seen by multiple clients on the LAN (actually the+WAN; works over OpenVPN too). I had been thinking about using+Avahi/ZeroConf for discovery of systems to pair with, but ZeroMQ is rather+more portable and easy to work with.++Unfortunatly, I wasn't able to get ZeroMQ to behave reliably enough.+It seems to have some timeout issues the way I'm trying to use it,+or perhaps its haskell bindings are buggy? Anyway, it's really overkill+to use PGM when all I need for git-annex pairing discovery is lossy+UDP Multicast. Haskell has a simple `network-multicast` library for that,+and it works great.++With discovery out of the way (theoretically), the hard part about+[[pairing]] is going to be verifying that the desired repository is being+paired with, and not some imposter. My plan to deal with this involves a+shared secret, that can be communicated out of band, and HMAC. The webapp+will prompt both parties to enter the same agreed upon secret (which could+be any phrase, ideally with 64 bytes of entropy), and will then use it as+the key for HMAC on the ssh public key. The digest will be sent over the+wire, along with the ssh public key, and the other side can use the shared+secret to verifiy the key is correct.++The other hard part about [[pairing]] will be finding the best address to+use for git, etc to connect to the other host. If MDNS is available, it's+ideal, but if not the pair may have to rely on local DNS, or even+hard-coded IPs, which will be much less robust. Or, the assistant could+broadcast queries for a peer's current IP address itself, as a poor man's+MDNS.++All right then! That looks like a good week's worth of work to embark on.++---++Slight detour to package the haskell network-multicast library and upload+to Debian unstable.++Roughed out a data type that models the whole pairing conversation,+and can be serialized to implement it. And a state machine to run+that conversation. Not yet hooked up to any transport such as multicast+UDP.
+ doc/design/assistant/blog/day_76__pairing.mdwn view
@@ -0,0 +1,16 @@+About half way done with implementing [[pairing]]. The webapp's interface+to prompt for a secret and start pairing is done; the protocol is+implemented; broadcasting of pairing requests is working; added Yet Another+Thread to listen for incoming pairing traffic.++Very happy with how this came together; starting with defining the protocol+with data types let me rapidly iterate until I had designed a simple, clean,+robust protocol. The implementation works well too; it's even possible to+start pairing, and only then bring up the network interface to the machine+you intended to pair with, and it'll detect the new interface and start+sending requests to it.++Next, I need to make alerts have a button that performs a stored+IO action. So that the incoming pair request alert can have a button to+respond to the pair request. And then I need to write the code to actually+perform the pairing, including ssh key setup.
+ doc/design/assistant/blog/day_77_alert_buttons.mdwn view
@@ -0,0 +1,21 @@+Alerts can now have buttons, that go to some url when clicked. Yay.++Implementing that was a PITA, because Yesod really only wants its type-safe+urls to be rendered from within its Handler monad. Which most things that+create alerts are not. I managed to work around Yesod's insistence on this+only by using a MVar to store the pure function that Yesod uses internally.+That function can only be obtained once the webapp is running.++----++Fixed a nasty bug where using gpg would cause hangs. I introduced this back+when I was reworking all the code in git-annex that runs processes, so it+would work with threading. In the process a place that had forked a process+to feed input to gpg was lost. Fixed it by spawning a thread to feed gpg.+Luckily I have never released a version of git-annex with that bug, but+the many users who are building from the master branch should update.++----++Made alerts be displayed while pairing is going on, with buttons to cancel+pairing or respond to a pairing request.
+ doc/design/assistant/blog/day_78__pairing_continued.mdwn view
@@ -0,0 +1,8 @@+Worked on [[pairing]] all day. It's complicated and I was close to being in+the weeds at times. I think it probably works now, but I have not tested it+at all. Tomorrow, testing, and cleaning up known problems.++----++Also ordered 1.5 terabytes of USB keys and a thousand git-annex stickers+today.
+ doc/design/assistant/blog/day_79__pairing_finished.mdwn view
@@ -0,0 +1,33 @@+Tons of pairing work, which culminated today in pairing fully working for+the very first time. And it works great! Type something like "my+hovercraft is full of eels" into two git annex webapps on the same LAN+and the two will find each other, automatically set up ssh keys, and sync+up, like magic. Magic based on math.++* Revert changes made to `authorized_keys` when the user cancels+  a pairing response. Which could happen if the machine that sent the+  pairing request originally is no longer on the network.+* Some fixes to handle lossy UDP better. Particularly tricky at the end+  of the conversation -- how do both sides reliably know when a+  conversation is over when it's over a lossy wire? My solution is just+  to remember some conversatons we think are over, and keep saying+  "this conversation is over" if we see messages in that conversation.+  Works.+* Added a UUID that must be the same in related pairing messages.+  This has a nice security feature: It allows detection of brute-force+  attacks to guess the shared secret, after the first wrong guess! +  In which case the pairing is canceled and a warning printed.+* That led to a thorough security overview, which I've added to+  the [[pairing]] page. Added some guards against unusual attacks,+  like console poisioning attacks. I feel happy with the security+  of pairing now, with the caveats that only I have reviewed it (and+  reviewing your own security designs is never ideal), and that the+  out-of-band shared secret communication between users is only as good+  as they make it.+* Found [a bug](https://github.com/yesodweb/yesod/issues/421) +  in Yesod's type safe urls. At least, I think it's a bug. Worked around it.+* Got very stuck trying to close the sockets that are opened to send+  multicast pairing messages. Nothing works, down to and including calling+  C `close()`. At the moment I have a socket leak. :(+  I need to understand the details of multicast sockets better to fix this.+  Emailed the author of the library I'm using for help.
+ doc/design/assistant/blog/day_80__default_backend.mdwn view
@@ -0,0 +1,14 @@+I've changed the default backend used by git-annex from SHA256 to SHA256E.+Including the filename extension in the key is known to make repositories+more usable on things like MP3 players, and I've recently learned it also+avoids [[forum/Weird_behavior_with_OS_X_Finder_and_Preview.app]]. ++I thought about only changing the default in repositories set up by the+assistant, but it seemed simpler to change the main default. The old+backend is really only better if you might have multiple copies of files+with the same content that have different extensions.++Fixed the socket leak in pairing that eluded me earlier.++I've made a new [[polls]] page, and posted a poll:+[[polls/prioritizing_special_remotes]]
+ doc/design/assistant/blog/day_81__enabling_pre-existing_special_remotes.mdwn view
@@ -0,0 +1,34 @@+It's possible for one git annex repository to configure a special remote+that it makes sense for other repositories to also be able to use. Today I+added the UI to support that; in the list of repositories, such+repositories have a "enable" link.++To enable pre-existing rsync special remotes, the webapp has to do the same+probing and ssh key setup that it does when initially creating them.+Rsync.net is also handled as a special case in that code. There was one+ugly part to this.. When a rsync remote is configured in the webapp,+it uses a mangled hostname like "git-annex-example.com-user", to+make ssh use the key it sets up. That gets stored in the `remote.log`, and so+the enabling code has to unmangle it to get back to the real hostname.++---++Based on the still-running [[prioritizing_special_remotes]] poll, a lot+of people want special remote support for their phone or mp3 player.+(As opposed to running git-annex on an Android phone, which comes later..)+It'd be easy enough to make the webapp set up a directory special remote+on such a device, but that makes consuming some types of content on the+phone difficult (mp3 players seem to handle them ok based on what people tell+me). I need to think more about some of the ideas mentioned in [[android]]+for more suitable ways of storing files.++One thing's for sure: You won't want the assistant to sync all your files+to your phone! So I also need to start coming up with partial syncing+controls. One idea is for each remote to have a configurable matcher for files+it likes to receive. That could be only mp3 files, or all files inside a+given subdirectory, or all files *not* in a given subdirectory. That means+that when the assistant detects a file has been moved, it'll need to add+(or remove) a queued transfer. Lots of other things could be matched on,+like file size, number of copies, etc. Oh look, I have a+[beautiful library I wrote earlier](http://joeyh.name/blog/entry/happy_haskell_hacker)+that I can reuse!
+ doc/design/assistant/blog/day_82__git-annex_branch_work.mdwn view
@@ -0,0 +1,26 @@+Started today doing testing of [[syncing]], and found some bugs and things+it needs to do better. But was quickly sidetracked when I noticed that+`transferkey` was making a commit to the git-annex branch for every file it+transferred, which is too slow and bloats history too much.++To fix that actually involved fixing a long-standing annoyance; that+read-only git-annex commands like `whereis` sometimes start off with+"(Recording state in git)", when the journal contains some not yet+committed changes to the git-annex branch. I had to carefully think+through the cases to avoid those commits.++As I was working on that, I found a real nasty lurking bug in the git-annex+branch handling. It's unlikely to happen unless `annex.autocommit=false` is+set, but it could occur when two git-annex processes race one another just+right too. The root of the bug is that `git cat-file --batch` does not+always show changes made to the index after it started. I think it does+in enough cases to have tricked me before, but in general it can't be+trusted to report the current state of the index, but only some past state.++I was able to fix the bug, by ensuring that changes being made to the+branch are always visible in either the journal or the branch -- never in+the index alone.++----++Hopefully something less low-level tomorrow..!
+ doc/design/assistant/blog/day_83__3-way.mdwn view
@@ -0,0 +1,73 @@+Syncing works well when the graph of repositories is strongly connected.+Now I'm working on making it work reliably with less connected graphs.++I've been focusing on and testing a doubly-connected list of repositories,+such as: `A <-> B <-> C`++----++I was seeing a lot of git-annex branch push failures occuring in+this line of repositories topology. Sometimes was is able to recover from+these, but when two repositories were trying to push to one-another at the+same time, and both failed, both would pull and merge, which actually keeps+the git-annex branch still diverged. (The two merge commits differ.)++A large part of the problem was that it pushed directly into the git-annex+branch on the remote; the same branch the remote modifies. I changed it to+push to `synced/git-annex` on the remote, which avoids most push failures.+Only when A and C are both trying to push into `B/synced/git-annex` at the+same time would one fail, and need to pull, merge, and retry.++-----++With that change, git syncing always succeeded in my tests, and without+needing any retries. But with more complex sets of repositories, or more+traffic, it could still fail.++I want to avoid repeated retries, exponential backoffs, and that kind of+thing. It'd probably be good enough, but I'm not happy with it because+it could take arbitrarily long to get git in sync.++I've settled on letting it retry once to push to the synced/git-annex+and synced/master branches. If the retry fails, it enters a fallback mode,+which is guaranteed to succeed, as long as the remote is accessible.++The problem with the fallback mode is it uses really ugly branch names.+Which is why Joachim Breitner and I originally decided on making `git annex+sync` use the single `synced/master` branch, despite the potential for+failed syncs. But in the assistant, the requirements are different,+and I'm ok with the uglier names.++It does seem to make sense to only use the uglier names as a fallback,+rather than by default. This preserves compatability with `git annex sync`,+and it allows the assistant to delete fallback sync branches after it's+merged them, so the ugliness is temporary.++---++Also worked some today on a bug that prevents C from receiving files+added to A.++The problem is that file contents and git metadata sync independantly. So C+will probably receive the git metadata from B before B has finished+downloading the file from A. C would normally queue a download of the+content when it sees the file appear, but at this point it has nowhere to+get it from.++My first stab at this was a failure. I made each download of a file result+in uploads of the file being queued to every remote that doesn't have it+yet. So rather than C downloading from B, B uploads to C. Which works fine,+but then C sees this download from B has finished, and proceeds to try to+re-upload to B. Which rejects it, but notices that this download has+finished, so re-uploads it to C...++The problem with that approach is that I don't have an event when a download+succeeds, just an event when a download ends.  Of course, C could skip+uploading back to the same place it just downloaded from, but loops are+still possible with other network topologies (ie, if D is connected to both+B and C, there would be an upload loop 'B -> C -> D -> B`). So unless I can+find a better event to hook into, this idea is doomed.++I do have another idea to fix the same problem. C could certianly remember+that it saw a file and didn't know where to get the content from, and then+when it receives a git push of a git-annex branch, try again.
+ doc/design/assistant/blog/day_84__deferred_downloads.mdwn view
@@ -0,0 +1,33 @@+Implemented deferred downloads. So my example from yesterday of three+repositories in a line keep fully in sync now!++I punted on one problem while doing it. It might be possible to get a really+big list of deferred downloads in some situation. That all lives in memory.+I aim for git-annex to always have a constant upper bound on memory use,+so that's not really acceptable. I have TODOed a reminder to do something+about limiting the size of this list.++----++I also ran into a nasty crash while implementing this, where two threads+were trying to do things to git HEAD at the same time, and so one crashed,+and in a way I don't entirely understand, that crash took down another+thread with a BlockedIndefinitelyOnSTM exception. I think I've fixed+this, but it's bothersome that this is the second time that modifications+to the Merger thread have led to a concurrency related crash that I+have not fully understood. ++My guess is that STM can get confused when it's+retrying, and the thread that was preventing it from completing a+transaction crashes, because it suddenly does not see any other+references to the TVar(s) involved in the transaction. Any GHC STM gurus+out there?++---++Still work to be done on making data transfers to keep fully in sync in all+circumstances. One case I've realized needs work occurs when a USB drive is+plugged in. Files are downloaded from it to keep the repo in sync, but the+repo neglects to queue uploads of those files it just got out to other+repositories it's in contact with. Seems I still need to do something to+detecting when a successful download is done, and queue uploads.
+ doc/design/assistant/blog/day_85__more_foundation_work.mdwn view
@@ -0,0 +1,17 @@+Turns out I was able to easily avoid the potential upload loops that would+occur if each time a repo receives a download, it queues uploads to the+repos it's connected to. With that done. I suspect, but have not proven,+that the assistant is able to keep repos arranged in any shape of graph in+sync, as long as it's connected (of course) and each connection is+bi-directional. That's a good start .. or at least a nice improvement from+only strongly connected graphs being kept in sync.++Eliminated some empty commits that would be made sometimes, which is a nice+optimisation.++------++I wanted to get back to some UI work after this week's deep dive into the+internals. So I filled in a missing piece, the repository switcher in the+upper right corner. Now the webapp's UI allows setting up different+repositories for different purposes, and switching between them.
+ doc/design/assistant/blog/day_86__towards_the_beta.mdwn view
@@ -0,0 +1,33 @@+Putting together a shortlist of things I want to sort out before the beta.++* [[Progress bars|progressbars]] for file uploads.+* No mocked up parts in the webapp's UI. Think I implemented the last of+  those yesterday, although there are some unlinked repository configuration+  options.+* The basic watching functionality, should work reliably.+  There are some known scalability issues with eg,+  [[kqueue on OSX|bugs/Issue_on_OSX_with_some_system_limits]] that+  need to be dealt with, but needn't block a beta.+* Should keep any configuration of repositories that can be set up using+  the webapp in sync whenever it's possible to do so. I think that'll work+  after the past few days work.+* Should be easy to install and get running. Of course part of the point+  of the beta release is to get it out there, on Hackage, in Debian+  unstable, and in the other places that git-annex packagers put it.+  As to getting it running, the autostart files and menu items look good+  on Linux. The OSX equivilants still need work and testing.+* No howlingly bad bugs. [[This bug|bugs/pasting_into_annex_on_OSX]] is+  the one I'm most concerned with currently. OTOH, +  [[bugs/watcher_commits_unlocked_files]] can be listed in the errata.++----++So I worked on progress bars for uploads today. Wrote a nice little+parser for rsync's progress output, that parses arbitrary size chunks,+returning any unparsable part. Added a ProgressCallback parameter to+all the backends' upload methods. Wrote a nasty thing that intercepts+rsync's output, currently a character at a time (horrible, but rsync+doesn't output that much, so surprisingly acceptable), and outputs it and+parses it. Hooked all this up, and got it working for uploads to+git remotes. That's 1/10th of the total ways uploads can happen that+have working progress bars. It'll take a while to fill in the rest..
+ doc/design/assistant/blog/day_87__more_progress_progress.mdwn view
@@ -0,0 +1,28 @@+Worked more on upload progress tracking. I'm fairly happy with its state+now:++* It's fully implemented for rsync special remotes.++* Git remotes also fully support it, with the+  notable exception of file uploads run by `git-annex-shell recvkey`. That+  runs `rsync --server --sender`, and in that mode, rsync refuses to output+  progress info. Not sure what to do about this case. Maybe I should+  write a parser for the rsync wire protocol that can tell what chunk of the+  file is being sent, and shim it in front of the rsync server? That's+  rather hardcore, but it seems the best of a bad grab bag of options that+  include things like `LD_PRELOAD` hacks.++* Also optimised the rsync progress bar reader to read whole+  chunks of data rather than one byte at a time.++* Also got progress bars to actually update in the webapp for uploads.++  This turned out to be tricky because kqueue cannot be used to detect when+  existing files have been modified. (One of kqueue's worst shortcomings vs+  inotify.) Currently on kqueue systems it has to poll.++I will probably upload add progress tracking to the directory special remote,+which should be very easy (it already implements its own progress bars),+and leave the other special remotes for later. I can add upload progress+tracking to each special remote when I add support for configuring it in+the webapp.
+ doc/design/assistant/blog/day_88__progressbars_still_progressing.mdwn view
@@ -0,0 +1,18 @@+Short day today, but I again worked only on progress bars.++* Added upload progress tracking for the directory special remote.+* Some optimisations.+* Added a `git annex-shell transferkey` command. This isn't used yet,+  but the plan is to use it to feed back information about how much+  of a file has been sent when downloading it. So that the uploader+  can display a progress bar. This method avoids needing to parse the rsync+  protocol, which is approximately impossible without copying half of rsync.+  Happily, git-annex's automatic ssh connection caching will make the small+  amount of data this needs to send be efficiently pipelined over the same+  ssh connection that rsync is using.++I probably have less than 10 lines of code to write to finish up+[[progressbars]] for now. Looking forward to getting that behind me, and on+to something more interesting. Even doing mail merge to print labels to+mail out Kickstarter rewards is more interesting than progress bars at this+point. :)
+ doc/design/assistant/blog/day_89__final_polish.mdwn view
@@ -0,0 +1,24 @@+Finally wrapped up progress bars; upload progress is now reported in all+situations. ++After all that, I was pleased to find a use for the progress info, beyond+displaying it to the user. Now the assistant uses it to decide whether it+makes sense to immediately retry a failed transfer. This should make it+work nicely, or at least better, with flaky network or drives.++The webapp crashed on startup when there was no `~/.gitconfig`.+Guess all of us who have tried it so far are actual git users,+but I'm glad I caught this before releasing the beta.++Jimmy Tang kindly took on making a OS X .app directory for git-annex.+So it now has an icon that will launch the webapp. +[[!img /assistant/osx-app.png]]++I'm getting lots of contributors to git-annex all of a sudden. I've had 3+patches this weekend, and 2 of them have been to Haskell code.+Justin Azoff is working on [[todo/incremental_fsck]], and Robie Basak+has [gotten Amazon Glacier working](https://github.com/basak/glacier-cli)+using the hook special remote.++Started doing some design for [[transfer_control]]. I will start+work on this after releasing the first beta.
+ doc/design/assistant/blog/day_90__beta.mdwn view
@@ -0,0 +1,16 @@+Just released git-annex 3.20120924, which includes beta versions of+the assistant and webapp. Read the [[/assistant/errata]], then give it a+try!++I've uploaded it to Haskell's cabal, and to Debian unstable, and hope my+helpers for other distributions will update them soon. (Although the+additional dependencies to build the webapp may take a while on some.)+I also hope something can be done to make a prebuilt version available on+OSX soonish.++I've decided to license the webapp under the+[AGPL](http://www.gnu.org/licenses/agpl-3.0.html). This should not impact+normal users of it, and git-annex can be built without the webapp as a pure+GPL licensed program. This is just insurance to prevent someone turning the+webapp into a propritary web-only service, by requiring that anyone who+does so provide the source of the webapp.
doc/design/assistant/cloud.mdwn view
@@ -13,23 +13,20 @@ * 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) * Dropbox? That would be ironic.. Via its API, presumably.-* Amazon Glacier--## limited space--When syncing via the cloud, space there is probably limited, so-users with more files than cloud space will want to be able to use the-cloud as a temporary transfer point, which files are removed from after-they've propigated out.+* [[Amazon Glacier|todo/special_remote_for_amazon_glacier]]+* [nimbus.io](https://nimbus.io/) Fairly low prices ($0.06/GB);+  REST API; free software -Other users will want to use the cloud as the canonical or backup location-of their data, and would want a copy of all their files to be kept there.-That's also ok.+## The cloud notification problem -git-annex will need a way to tell the difference between these, either-heuristically, or via configuration.+Alice and Bob have repos, and there is a cloud remote they both share.+Alice adds a file; the assistant transfers it to the cloud remote.+How does Bob find out about it? -Also needed for USB keys and Android gadgets.+There are two parts to this problem. Bob needs to find out that there's+been a change to Alice's git repo. Then he needs to pull from Alice's git repo,+or some other repo in the cloud she pushed to. Once both steps are done,+the assistant will transfer the file from the cloud to Bob.  ## storing git repos in the cloud 
+ doc/design/assistant/comment_12_5e991177d6577384f39a36ae02f5f574._comment view
@@ -0,0 +1,13 @@+[[!comment format=mdwn+ username="https://www.google.com/accounts/o8/id?id=AItOawlu-fdXIt_RF9ggvg4zP0yBbtjWQwHAMS4"+ nickname="Jörn"+ subject="Multiple annexes?"+ date="2012-09-20T16:10:29Z"+ content="""+Thank you for this great piece of software which is now becoming even better with the assistant.++Just one question: will one instance of the assistant be able to track multiple git annex repositories each building up their own network of annexes OR would I need to run multiple instances of the assistant?++Thanks,+Jörn+"""]]
+ doc/design/assistant/comment_13_f8625c6f43b58847840df338a73b7972._comment view
@@ -0,0 +1,7 @@+[[!comment format=mdwn+ username="http://joeyh.name/"+ subject="comment 13"+ date="2012-09-20T16:21:11Z"+ content="""+@Jörn, two days ago I added support in the webapp for multiple independent repositories. So you can create independent repos using it, and switch between them from a menu. Under the hood there are multiple git-annex assistant daemons running, but this is an implementation detail; it's not like these use any more memory or other resources than would a single daemon that managed multiple repositories.+"""]]
+ doc/design/assistant/comment_14_c37ef5931b0f5c1f808083e0d636a208._comment view
@@ -0,0 +1,11 @@+[[!comment format=mdwn+ username="https://id.koumbit.net/anarcat"+ subject="you rock! & roadmap update?"+ date="2012-09-21T04:25:58Z"+ content="""+joey, you rock. I just want to push on that point - it doesn't seem like there's that many tools that do what git-annex is trying to do out there, and you seem to be doing an incredible job at doing it, so this is great, keep going!++i was wondering - i am glad to see the progress, but it is unclear to me where you actually are in the roadmap. are things going according to plan? are we at month 3? 4? or 1-4? :) just little updates on that roadmap section above would be quite useful!++thanks again!+"""]]
+ doc/design/assistant/comment_15_68c98a27083567f20c2e6bc2a760991b._comment view
@@ -0,0 +1,9 @@+[[!comment format=mdwn+ username="http://joeyh.name/"+ subject="comment 15"+ date="2012-09-21T05:25:53Z"+ content="""+We're on month 4 of work, and most of months 1-3 is done well enough for a first pass. Very little of what's listed in month 4 has happened yet, due to my being maybe 2 weeks behind schedule, but bits of [[cloud]] are being planned.++I've made a small adjustment, I think it'll make sense to spend a month on user-driven features before getting into Android.+"""]]
doc/design/assistant/configurators.mdwn view
@@ -10,9 +10,11 @@ * Create a repository (run when the web app is started without a configured   repository too). * Clone this repo to a USB drive or other removable drive. **done**-* Clone this repo to another host. (Needs [[pairing]])+* Make a bare repo on a remote ssh server **done**+* Clone this repo to another host. (Needs [[pairing]]) **done** * Set up Amazon S3.-* Set up rsync remote.-* Set up encryption.+* Set up encrypted rsync remote. **done**+* Rsync.net special case **done**+* Set up gpg encryption key; gpg key distribution. * I lost my USB drive! * etc -- many more possibilities
doc/design/assistant/leftovers.mdwn view
@@ -1,6 +1,7 @@ Things that don't fit anywhere else: -* Automatically start daemon on boot or when user logs in. **done**+* Automatically start daemon on boot or when user logs in, using+  freedesktop autostart file. **done** * Somehow get content that is unavailable. This is problematic with inotify,   since we only get an event once the user has tried (and failed) to read   from the file. This is only needed if all the files in the directory 
doc/design/assistant/pairing.mdwn view
@@ -1,13 +1,83 @@ For git-annex to be able to clone its repo to another host, it'd be good to have some way of pairing devices. -It could work like this:+## security -1. Prompt for the hostname (or do avahi local machine discovery). -2. Enable the two hosts to ssh to one-another and run git-annex shell.-   (A tricky problem, if ssh keys need to be added to do that.)-3. Push over a clone of the repository. (Using git-annex-shell?)-4. Start [[syncing]].+Pairing uses its own network protocol, built on top of multicast UDP. -Also look into the method used by-<https://support.mozilla.org/en-US/kb/add-a-device-to-firefox-sync>+It's important that pairing securely verifies that the right host is being+paired with. This is accomplied by having a shared secret be entered on+both the hosts that will be paired. Hopefully that secret is communicated+securely out of band. ++(In practice, the security of that communication will vary. To guard against+interception, each pairing session pairs exactly two hosts and then forgets+the shared secret. So an attacker who tries to reuse an intercepted secret+will not succeed in pairing. This does not guard against an intercepted+secret that is used before the legitimate parties finish pairing.)++Each host can construct messages that the other host can verify using the+shared secret, and so know that, for example, the ssh public key it+received belongs to the right host and has not been altered by a man in the+middle.++The verification works like this: Take a HMAC SHA1 checksum of the message,+using the shared secret as the HMAC key. Include this checksum after the+message. The other host can then do the same calculation and verify the+checksum.++Additionally, a UUID is included in the message. Messages that are part of+the same pairing session all share a UUID. And all such messages should+be verifiable as described above. If a message has the same UUID but is+not verifiable, then someone on the network is up to no good. Perhaps+they are trying to brute-force the shared secret. When this is detected,+the pairing session is shut down. (Which would still let an attacker+DOS pairing, but that's not a very interesting attack.)++The protocol used for pairing consists of 3 messages, a PairReq, and+PairAck, and a PairDone. Let's consider what an attacker could accomplish+by replaying these:++* PairReq: This would make the webapp pop up an alert about an incoming+  pair request. If the user thought it was real and for some reason+  entered the right shared secret used in the real one earlier, the+  ssh key inside the PairReq would be added to `authorized_keys`. Which+  allows the host that originally sent the PairReq to access its git+  repository, but doesn't seem to do the attacker any good.+* PairAck:  If the host that originally sent+  the PairReq is still pairing, it'll add the ssh key from the PairAck,+  and start syncing, which again does the attacker no good.+* PairDone: If the host that sent the PairAck is still syncing, it'll+  add the ssh key from the PairDone, and start syncing, and stop+  sending PairAcks. But probably, it's not syncing, because it would have+  seen the original PairDone.. and anyway, this seems to do the attacker no+  good.++So replay attacks don't seem to be a problem.++So far I've considered security from a third-party attacker, but either the+first or second parties in pairing could also be attackers. Presumably they+trust each other with access to their files as mediated by+[[git-annex-shell]]. However, one could try to get shell access to the+other's computer by sending malicious data in a pairing message. So the+pairing code always checks every data field's content, for example the ssh+public key is rejected if it looks at all unusual. Any control characters+in the pairing message cause it to be rejected, to guard against console+poisoning attacks. Furthermore, git-annex is careful not to expose data to+the shell, and the webapp uses Yesod's type safety to ensure all user input+is escaped before going to the browser.++## TODO++* pairing over IPV6 only networks does not work. Haskell's+  `network-multicast` library complains "inet_addr: Malformed address: ff02::1"+  .. seems it just doesn't support IPv6. The pairing code in git-annex+  does support ipv6, apart from this, it's just broadcasting the messages+  that fails. (Pairing over mixed networks is fine.)+* If there are three assistants on the network, and 2 pair, the third is+  left displaying a "Pair request from foo" alert, until it's close. +  Or, if the user clicks the button to pair, it'll get to the +  "Pairing in progress" alert, which will show forever (until canceled).++  It should be possible for third parties to tell when pairing is done,+  but it's actually rather hard since they don't necessarily share the secret.
+ doc/design/assistant/polls.mdwn view
@@ -0,0 +1,1 @@+[[!inline pages="(page(design/assistant/blog/*) and tagged(design/assistant/polls)) or page(design/assistant/polls/*)" show=0]]
+ doc/design/assistant/polls/prioritizing_special_remotes.mdwn view
@@ -0,0 +1,16 @@+Background: git-annex supports storing data in various [[special remotes]].+The git-annex assistant will make it easy to configure these, and easy+configurators have already been built for a few: removable drives, rsync.net,+locally paired systems, and remote servers with rsync.++Help me prioritize my work: What special remote would you most like+to use with the git-annex assistant?++[[!poll open=yes 14 "Amazon S3" 8 "Amazon Glacier" 6 "Box.com" 44 "My phone (or MP3 player)" 4 "Tahoe-LAFS" 3 "OpenStack SWIFT" 12 "Google Drive"]]++This poll is ordered with the options I consider easiest to build+listed first. Mostly because git-annex already supports them and they+only need an easy configurator. The ones at the bottom are likely to need+significant work. See [[cloud]] for detailed discussion.++Have another idea? Absolutely need two or more? Post comments..
doc/design/assistant/progressbars.mdwn view
@@ -5,10 +5,31 @@ Something better is needed for the [[webapp]]. There needs to be a way for the web app to know what the current progress is of all transfers. -To get this info for downloads, git-annex can watch the file as it arrives-and use its size.+This is one of those potentially hidden but time consuming problems. -TODO: What about uploads? Will i have to parse rsync's progresss output?-Feed it via a named pipe? Ugh. Check into librsync.+## downloads -This is one of those potentially hidden but time consuming problems.+* Watch temp file as it's coming in and use its size.+  This is the only option for some special remotes (ie, non-rsync).+  Can either poll every .5 seconds or so to check file size, or+  could use inotify. **done**++## uploads++Each individual remote type needs to implement its own support for calling+the MeterUpdate callback as the upload progresses.++* git: **done**+* rsync: **done**+* directory: **done**+* web: Not applicable; does not upload +* S3: TODO+* bup: TODO+* hook: Would require the hook interface to somehow do this, which seems+  too complicated. So skipping.++## communication++It may be worth using a better communication channel than files on disk for+the transfer progress. Shared memory could be used, or http posts to the+webapp.
doc/design/assistant/syncing.mdwn view
@@ -1,27 +1,16 @@ Once files are added (or removed or moved), need to send those changes to all the other git clones, at both the git level and the key/value level. -## immediate action items+## bugs -* The syncing code currently doesn't run for special remotes. While-  transfering the git info about special remotes could be a complication,-  if we assume that's synced between existing git remotes, it should be-  possible for them to do file transfers to/from special remotes.-* Often several remotes will be queued for full TransferScanner scans,-  and the scan does the same thing for each .. so it would be better to-  combine them into one scan in such a case.-* Sometimes a Download gets queued from a slow remote, and then a fast-  remote becomes available, and a Download is queued from it. Would be-  good to sort the transfer queue to run fast Downloads (and Uploads) first.-* Ensure that when a remote receives content, and updates its location log,-  it syncs that update back out. Prerequisite for:-* After git sync, identify new content that we don't have that is now available-  on remotes, and transfer. (Needed when we have a uni-directional connection-  to a remote, so it won't be uploading content to us.) Note: Does not-  need to use the TransferScanner, if we get and check a list of the changed-  files.+* Running the assistant in a fresh clone of a repository, it sometimes+  skips downloading a file, while successfully downloading all the rest.+  There does not seem to be an error message. This will sometimes reproduce+  (in a fresh clone each time) several times in a row, but then stops happening,+  which has prevented me from debugging it.+  This could possibly have been caused by the bug fixed in 750c4ac6c282d14d19f79e0711f858367da145e4. -## longer-term TODO+## TODO  * Test MountWatcher on LXDE. * git-annex needs a simple speed control knob, which can be plumbed@@ -52,6 +41,19 @@   working copy and checks each file. That probably needs to be done once,   but further calls to the TransferScanner could eg, look at the delta   between the last scan and the current one in the git-annex branch.+* Ensure that when a remote receives content, and updates its location log,+  it syncs that update back out. Currently, it does not, unless the master+  branch also changed. Prerequisite for:+* After git sync, identify new content that we don't have that is now available+  on remotes, and transfer. (Needed when we have a uni-directional connection+  to a remote, so it won't be uploading content to us.) Note: Does not+  need to use the TransferScanner, if we get and check a list of the changed+  files.+* [[use multiple transfer slots|todo/Slow_transfer_for_a_lot_of_small_files.]]+* The TransferQueue's list of deferred downloads could theoretically+  grow without bounds in memory. Limit it to a given number of entries,+  and fall back to some other method -- either storing deferred downloads+  on disk, or perhaps scheduling a TransferScanner run to get back into sync.  ## data syncing @@ -206,3 +208,49 @@   log when queuing a failed Upload too.) **done** * Fix MountWatcher to notice umounts and remounts of drives. **done** * Run transfer scan on startup. **done**+* Often several remotes will be queued for full TransferScanner scans,+  and the scan does the same thing for each .. so it would be better to+  combine them into one scan in such a case. **done**+* The syncing code currently doesn't run for special remotes. While+  transfering the git info about special remotes could be a complication,+  if we assume that's synced between existing git remotes, it should be+  possible for them to do file transfers to/from special remotes.+  **done**++* The transfer code doesn't always manage to transfer file contents.++  Besides reconnection events, there are two places where transfers get queued:++  1. When the committer commits a file, it queues uploads.+  2. When the watcher sees a broken symlink be created, it queues downloads.++  Consider a doubly-linked chain of three repositories, A B and C.+  (C and A do not directly communicate.)+  +  * File is added to A.+  * A uploads its content to B.+  * At the same time, A git syncs to B.+  * Once B gets the git sync, it git syncs to C.+  * When C's watcher sees the file appear, it tries to download it. But if+    B had not finished receiving the file from A, C doesn't know B has it,+    and cannot download it from anywhere.++  Possible solution: After B receives content, it could queue uploads of it +  to all remotes that it doesn't know have it yet, which would include C. +  **done**+  +  In practice, this had the problem that when C receives the content,+  it will queue uploads of it, which can send back to B (or to some other repo+  that already has the content) and loop, until the git-annex branches catch+  up and break the cycle.++  To avoid that problem, incoming uploads should not result in a transfer+  info file being written when the key is already present. **done**++  Possible solution: C could record a deferred download. (Similar to a failed+  download, but with an unknown source.) When C next receives a git-annex+  branch push, it could try to queue deferred downloads. **done**++  Note that this solution won't cover use cases the other does. For example,+  connect a USB drive A; B syncs files from it, and then should pass them to C.+  If the files are not new, C won't immediatly request them from B.
+ doc/design/assistant/transfer_control.mdwn view
@@ -0,0 +1,66 @@+Some remotes are too small to sync everything to them.++The case of a small remote on a gadget that the user interacts with,+such as a phone, where they may want to request it get content+it doesn't currently have, is covered by the [[partial_content]] page.++But often the remote is just a removable drive or a cloud remote,+that has a limited size. This page is about making the assistant do+something smart with such remotes.++## specifying what data belongs on a remote++Imagine a per-remote `annex-accept` setting, that matches things that+should be stored on the remote.++For example, a MP3 player might use:+`smallerthan(10mb) and filename(*.mp3) and (not filename(junk/*))`++Adding that as a filter to files sent to a remote should be+straightforward.++A USB drive that is carried between three laptops and used to sync data+between them might use: `not (in=laptop1 and in=laptop2 and in=laptop3)`++In this case, transferring data from the usb repo should+check if `annex-accept` then rejects the data, and if so, drop it+from the repo. So once all three laptops have the data, it is+pruned from the transfer drive.++It may make sense to have annex-accept info also be stored in the git-annex+branch, for settings that should apply to a repo globally. Does it make+sense to have local configuration too?++## repo classes++Seems like git-annex needs a way to know the classes of repos. Some+classes:++* enduser: The user interacts with this repo directly.+* archival: This repo accumulates stuff, and once it's in enough archives,+  it tends to get removed from other places.+* transfer: This repo is used to transfer data between enduser repos,+  it does not hold data for long periods of time, and tends to have a+  limited size.++Add a class.log that can assign repos to these or other classes.+(Should a repo be allowed to be in multiple classes?)++Some examples of using classes:++* Want to remove content from a repo, if it's not an archival repo,+  and the content has reached at least one archival repo:++  `(not class=archival) and (not copies=archival:1)`++  That would make send to configure on all repos, or even set+  a global `annex.accept` to it.++* Make a cloud repo only hold data until all known clients have a copy:++  `not inall(enduser)`++## configuration++The above is all well and good for those who enjoy boolean algebra, but+how to configure these sorts of expressions in the webapp?
doc/design/assistant/webapp.mdwn view
@@ -1,10 +1,19 @@ The webapp is a web server that displays a shiny interface. +## bugs++* At least in chromium, clicking on the transfer pause or cancel button+  sometimes fails. Seen in javascript console:+  500 error code from web server.+  This is quite likely because of how the div containing transfers is refereshed.+  If instead javascript was used to update the progress bar etc for transfers+  with json data, the buttons would work better.+ ## interface  * list of files uploading and downloading **done** * button to open file browser on repo (`xdg-open $DIR`) **done**-* progress bars for each file (see [[progressbars]])+* progress bars for each file (see [[progressbars]]) **done** * drag and drop to reorder * cancel, pause, and resume **done** * keep it usable w/o javascript **done**@@ -14,13 +23,8 @@  * there could be a UI to export a file, which would make it be served up   over http by the web app-* Display any relevant warning messages. One is the `inotify max_user_watches`-  exceeded message.-* possibly add a desktop file to the top of the repository that can be used-  to open the webapp (rather than using the menus). Would be complicated-  some by the path to git-annex sometimes needing to be hardcoded and varying-  across systems, so it would need to be a symlink to `.git/annex/desktop`-  which would be per-system.+* Display the `inotify max_user_watches` exceeded message. **done**+* Display something sane when kqueue runs out of file descriptors.  ## first start **done** 
doc/download.mdwn view
@@ -18,7 +18,6 @@  The git repository has some branches: -* `assistant` contains the new change-tracking daemon * `ghc7.0` supports versions of ghc older than 7.4, which   had a major change to filename encoding. * `old-monad-control` is for systems that don't have a newer monad-control
+ doc/forum/Cabal:_Could_not_resolve_dependencies___40__yesod__41__.mdwn view
@@ -0,0 +1,19 @@+Hi,++I try to install git-annex master with cabal, so I cloned the git repo and run "cabal install --only-dependencies". This gives me the following error:++    Resolving dependencies...+    cabal: Could not resolve dependencies:+    trying: git-annex-3.20120826 (user goal)+    trying: git-annex-3.20120826:+oldyesod+    trying: git-annex-3.20120826:+currentyesod+    next goal: yesod-default (dependency of git-annex-3.20120826:+oldyesod)+    rejecting: yesod-default-1.1.0 (conflict: git-annex-3.20120826:oldyesod =>+    yesod-default(<=1.0.1.1))+    rejecting: yesod-default-1.0.1.1, 1.0.1, 1.0.0, 0.6.1, 0.5.0, 0.4.1, 0.4.0,+    0.3.1 (conflict: git-annex-3.20120826:currentyesod => yesod-default(>=1.1.0))++Any idea how to fix this? (PS: I'm running Kubuntu 12.04)++Cheers,+Tobias
+ doc/forum/Don__39__t_understand_how_to_delete__47__recover_files.mdwn view
@@ -0,0 +1,25 @@+My Use Case:++I try basicly to use annex as a raid-like tool (at least thats the first step)++so I added some big files to it, and then I synced it to a usb-remote. So far all did go well...++No I startet annex watch daemon... because I thought it would then watch the files and checkin and out at least for the "origin" copy of the files.++Then I thought lets delete some files I dont need anymore... so... rm.... ^^++Maybe I just wanted to see what happens or if that would magicly do what I wanted him to do... ok I knew that it would not delete the file on the usb-drive (backup...) ok... but maybe at least localy...+++Now what did happen instead of that... the links are gone yes... the files it self are in the .git objects tree, so they did not get deleted, so ok not the way I wanted... have to unlock it first, would make maybe sense...++So I tried first to get the links back... tried fix, tried unused, tried get... but the links doesnt show up again...++is there a way to first bring back the links?+is it save or the right way to just git rebase HEAD~3 to bring the links back?++and then when I want to delete files from all places whats the way to do that... annex unlock -> then delete? or git drop filex --copies=0 or something?++like I said I try to use is like a more flexible raid thing, this files are to big to really back em up with history... I watch them... and then soon I will often delete them (from everywhere). but other parts stay... I dont delete them then... ^^++So maybe I missuse annex for that usecase... try to find that out ;)
+ doc/forum/Error_adding_ssh_remote_in_assistant.mdwn view
@@ -0,0 +1,15 @@+I'm trying to add a ssh remote in the web app, but I receive the following error:++    Internal Server Error++    ssh-keygen ["-F","router.eisenacher81.org"] exited 1++The console complains about the known_hosts file:++   /home/michael/.ssh/known_hosts is not a valid known_hosts file.+   line 44 missing key:  AAAAB3NzaC1yc2EAAAABIwAAAIEAtnX75Qa8YVR...+   key_read: uudecode AAAAB3NzaC1|1|veTakKhYY3OSqCepiq7WAUK8cxQ=|suoi0YU/lgg781Vz9O7yTao5exY= ssh-rsa                            AAAAB3NzaC1yc2EAAAABIwAAAIEA4bTnEFFiKz4+i3S9DWHJVoV8CD1DsVRJRodWdTA86+x58S0l0rUyJgXbGwScMI+xFCrqzpd4Hgoc4ElRykj5SL+7IuB5ZAe+4ILQPeiL9ck/1Q7uoh7vWiURXr92Hz5tjuEe3QI9H   iKauXj5yj5mGq1VVXLN1CdfQ99G4zSxK7c= failed+   line 73 invalid key: |1|k9vzo7Ftuxf235It5LbrX36p2f0=|rNHdygip...+   line 93: invalid hashed name: |1||1|aptgcuUg4ITWhZQLxzRHH8gUIOQ=|Qe2JAlAw++SZosE9ZhQW+fA3twE=...   +   line 120 missing key:  AAAAB3NzaC1yc2EAAAABIwAAAQEAsHa75NfjyB1...+   /home/michael/.ssh/known_hosts is not a valid known_hosts file.
+ doc/forum/First_attempt_at_an_OSX_launcher___40__.app__41__.mdwn view
@@ -0,0 +1,3 @@+I've made a first attempt at a .app launcher for git-annex webapp for OSX, please see <https://github.com/jcftang/git-annex/commits/master> the icon needs to be resized and made to look nicer at somepoint, the launcher assumes that git-annex is in the run time path.++I would imagine it might be possible to fiddle with the paths and get all the needed components into the .app file for OSX users.
+ doc/forum/Problem_compiling_current_master.mdwn view
@@ -0,0 +1,12 @@+While trying to compile the current master I run in the following error:++    Utility/Yesod.hs:21:14:+        Couldn't match expected type `String'+                    with actual type `WidgetFileSettings'+        Expected type: String -> Q Exp+          Actual type: WidgetFileSettings -> FilePath -> Q Exp+        In the expression: widgetFileNoReload+        In an equation for `widgetFile': widgetFile = widgetFileNoReload+    make: *** [git-annex] Fehler 1++I installed all dependencies from the INSTALL document. What is wrong?
+ doc/forum/Weird_behavior_with_OS_X_Finder_and_Preview.app.mdwn view
@@ -0,0 +1,12 @@+I am having some weird issues with git annex under OS X.  I am new to git annex, and am generally familiar with git.  I really like the concept of git-annex and am trying to lean how to fit it into my workflow, but Im running into problems.  ++I have a folder that I would like to keep in sync across multiple computers and thumb drives.  Right now this folder consists of other folders and PDF files.  After initializing git and git-annex, all of the files turn into symlinks, as expected.  ++Looking at this folder in OSX's finder, none of the symlinks have preview images unfortunately, as expected.  Also, when trying to open the file (or symlink, and in this case PDFs) in finder, it opens the console which outputs a bunch of crap and then nothing happens.  Right clicking on the symlink in finder and using Open with... the default application to open the symlink to the PDF is OSX's Preview.app, as expected, however for some reason this isn't being used when simple double clicking.  If you click on the Preview.app option under the right click menu, Preview.app launches, but never opens the file.  Selecting an alternative such as the Skim.app pdf viewer (if installed) successfully launches the application and opens the file.  ++My questions are:+1. What is the cause of not being able to launch the file in the correct app by simply double clicking it?  Do I have something mis-configued?  Is it a bug with git-annex?  Is git-annex simply not set up to work with finder yet?+2. How come preview can't open the file but skim can?  This might be directly related to the above question, but maybe not.+3. Is it possible to get file previews for the symlinks in your annex folder?  Are there plans to enable this kind of thing in the future, if even possible? ++Details about my setup.  I am running on a 32-bit Core Duo Macbook pro from 2006, so enviably I have to run 10.6.8 and its the highest OS version I can reach right now.  All my CLI packages are installed and up to date with Mac Homebrew.  I am running git version 1.7.12.  I freshly installed haskell-platform: stable 2012.2.0.0 via homebrew.  From there I installed git-annex-3.20120825.
@@ -0,0 +1,11 @@+I saw a cool page talking about "tagging" photos by using symlinks: http://www.trueelena.org/computers/articles/photo_management_with_git-annex_and_bash.html++so say I have a photo in git annex, called DSC_3285.JPG, which of course is really a symlink to ../.git/annex/objects/Zk/kj/WORM-s5296770-m1338516288--DSC_3285.JPG/WORM-s5296770-m1338516288--DSC_3285.JPG.++I want to make an additional link to that photo in a directory called tags/.++should I link to the symlink (DSC_3285.JPG), or to the annexed file? (../.git/annex/objects/Zk/kj/WORM-s5296770-m1338516288--DSC_3285.JPG/WORM-s5296770-m1338516288--DSC_3285.JPG)++I might occasionally rename DSC_3285.JPG or edit the photo itself. will the git annex commit hooks update both links, or should I prepare a script to update links in tags/ after I change DSC_3285 or the annexed data? ++thank you.
+ doc/forum/one_annex_versus_many_annexes__63__.mdwn view
@@ -0,0 +1,10 @@+I'm curious how other people are using git-annex:++ * A single annex containing everything they want to keep track of (albeit with some files only available in some remotes).+ * Several annexes for different purposes.++I'm mostly asking because I don't want to get too far into using git-annex without thinking clearly about which is the most suitable choice for me.  At present I have things split into two annexes, one for things I really wouldn't want to lose (and some of which are somewhat private), and another for comparatively throwaway items.  However, given the possibility of setting different annex.numcopies on different file globs or directories, it seems like it might be kind of silly to make my life more complicated by having more than one annex.++Primarily, I'm curious if there are some implications of the decision that I haven't considered.  It seems like an obvious point that one would want different annexes is if they're used in distinctly different security-level environments (e.g. I'm happy to copy my FLAC (music) files over to my work computer which lives at the office, but I wouldn't want to copy personal financial documents - or even the filenames - there.)++-Mike
doc/git-annex-shell.mdwn view
@@ -46,6 +46,15 @@    This runs rsync in server mode to transfer out the content of a key. +* transferinfo directory key++  This is typically run at the same time as sendkey is sending a key+  to the remote. Using it is optional, but is used to update+  progress information for the transfer of the key.++  It reads lines from standard input, each giving the number of bytes+  that have been received so far. + * commit directory    This commits any staged changes to the git-annex branch.
doc/git-annex.mdwn view
@@ -185,6 +185,16 @@   To not daemonize, run with --foreground ; to stop a running daemon,   run with --stop +* assistant++  Like watch, but also automatically syncs changes to other remotes.+  Typically started at boot, or when you log in.++* webapp++  Runs a web app, that allows easy setup of a git-annex repository,+  and control of the git-annex assistant.+ # REPOSITORY SETUP COMMANDS  * init [description]@@ -194,7 +204,8 @@   using it in a repository that was not intended to have an annex.    It's useful, but not mandatory, to initialize each new clone-  of a repository with its own description.+  of a repository with its own description. If you don't provide one,+  one will be generated.  * describe repository description @@ -432,6 +443,10 @@  	git annex dropkey SHA1-s10-7da006579dd64330eb2456001fd01948430572f2 +* transferkey key++  This plumbing-level command is used by the assistant to transfer data.+ * rekey [file key ...]      This plumbing-level command is similar to migrate, but you specify@@ -664,6 +679,14 @@   set to `false`. Then data will only be committed when   running `git annex merge` (or by automatic merges) or `git annex sync`. +* `annex.delayadd`++  Makes the watch and assistant commands delay for the specified number of+  seconds before adding a newly created file to the annex. Normally this+  is not needed, because they already wait for all writers of the file+  to close it. On Mac OSX, this defaults to 1 second, to work around+  a bad interaction with software there.+ * `remote.<name>.annex-cost`    When determining which repository to@@ -786,10 +809,10 @@ configured on a per-file-type basis via `.gitattributes` files. In the file, the `annex.backend` attribute can be set to the name of the backend to use. For example, this here's how to use the WORM backend by default,-but the SHA1 backend for ogg files:+but the SHA256E backend for ogg files:  	* annex.backend=WORM-	*.ogg annex.backend=SHA1+	*.ogg annex.backend=SHA256E  The numcopies setting can also be configured on a per-file-type basis via the `annex.numcopies` attribute in `.gitattributes` files.@@ -799,10 +822,17 @@  # FILES -These files are used by git-annex, in your git repository:+These files are used by git-annex: -`.git/annex/objects/` contains the annexed file contents that are currently-available. Annexed files in your git repository symlink to that content.+`.git/annex/objects/` in your git repository contains the annexed file+contents that are currently available. Annexed files in your git+repository symlink to that content.++`.git/annex/` in your git repository contains other run-time information+used by git-annex.++`~/.config/git-annex/autostart` is a list of git repositories+to start the git-annex assistant in.  # SEE ALSO 
doc/index.mdwn view
@@ -1,12 +1,13 @@ [[!inline raw=yes pages="summary"]] -To get a feel for it, see the [[walkthrough]] or read about [[how_it_works]].+To get a feel for git-annex, see the [[walkthrough]] or read about [[how_it_works]].  [[!sidebar content=""" [[!img logo_small.png link=no]]  * **[[download]]** * [[install]]+* [[assistant]] * [[tips]] * [[bugs]] * [[todo]]@@ -64,7 +65,7 @@  ---- -git-annex is Free Software, licensed under the [[GPL]].+git-annex is [[Free Software|license]]  git-annex's wiki is powered by [Ikiwiki](http://ikiwiki.info/) and hosted by [Branchable](http://branchable.com/).
doc/install.mdwn view
@@ -23,7 +23,8 @@  ## Installation by hand -To build and use git-annex, you will need:+This is not recommended, it's easier to let cabal pull in the many haskell+libraries. To build and use git-annex by hand, you will need:  * Haskell stuff   * [The Haskell Platform](http://haskell.org/platform/) (GHC 7.4 or newer)@@ -42,10 +43,29 @@   * [bloomfilter](http://hackage.haskell.org/package/bloomfilter)   * [edit-distance](http://hackage.haskell.org/package/edit-distance)   * [hS3](http://hackage.haskell.org/package/hS3) (optional)+* Optional haskell stuff, used by the [[assistant]] and its webapp (edit Makefile to disable)   * [stm](http://hackage.haskell.org/package/stm)-    (optional; version 2.3 or newer)+    (version 2.3 or newer)   * [hinotify](http://hackage.haskell.org/package/hinotify)-    (optional; Linux only)+    (Linux only)+  * [dbus](http://hackage.haskell.org/package/dbus)+  * [yesod](http://hackage.haskell.org/package/yesod)+  * [yesod-static](http://hackage.haskell.org/package/yesod-static)+  * [yesod-default](http://hackage.haskell.org/package/yesod-default)+  * [data-default](http://hackage.haskell.org/package/data-default)+  * [case-insensitive](http://hackage.haskell.org/package/case-insensitive)+  * [http-types](http://hackage.haskell.org/package/http-types)+  * [transformers](http://hackage.haskell.org/package/transformers)+  * [wai](http://hackage.haskell.org/package/wai)+  * [wai-logger](http://hackage.haskell.org/package/wai-logger)+  * [warp](http://hackage.haskell.org/package/warp)+  * [blaze-builder](http://hackage.haskell.org/package/blaze-builder)+  * [blaze-html](http://hackage.haskell.org/package/blaze-html)+  * [crypto-api](http://hackage.haskell.org/package/crypto-api)+  * [hamlet](http://hackage.haskell.org/package/hamlet)+  * [clientsession](http://hackage.haskell.org/package/clientsession)+  * [network-multicast](http://hackage.haskell.org/package/network-multicast)+  * [network-info](http://hackage.haskell.org/package/network-info) * Shell commands   * [git](http://git-scm.com/)   * [uuid](http://www.ossp.org/pkg/lib/uuid/)@@ -58,6 +78,8 @@   * [gpg](http://gnupg.org/) (optional; needed for encryption)   * [lsof](ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/)     (optional; recommended for watch mode)+  * multicast DNS support, provided on linux by [nss-mdns](http://www.0pointer.de/lennart/projects/nss-mdns/)+    (optional; recommended for the assistant to support pairing well)   * [ikiwiki](http://ikiwiki.info) (optional; used to build the docs)  Then just [[download]] git-annex and run: `make; make install`
+ doc/install/OSX/comment_4_d513e21512a9b207983d38abf348d00f._comment view
@@ -0,0 +1,16 @@+[[!comment format=mdwn+ username="https://www.google.com/accounts/o8/id?id=AItOawm_-2XlXNyd6cCLI4n_jaBNqVUOWwJquko"+ nickname="David"+ subject="installing via homebrew"+ date="2012-09-05T11:11:55Z"+ content="""+I had to:++    cabal update++before:++    cabal install git-annex+++"""]]
+ doc/license.mdwn view
@@ -0,0 +1,14 @@+git-annex is Free Software.++The majority of git-annex is licensed under the [[GPL]], version 3 or+higher.++The git-annex webapp is licensed under the [[AGPL]], version 3 or higher.+Note that builds of git-annex that include the webapp may be licensed+under the AGPL as a whole. git-annex built without the webapp does+not include this code, so remains GPLed.++git-annex contains a variety of other code, artwork, etc copyright by+others, under a variety of licences, including the [[LGPL]], BSD,+MIT, and Apache 2.0 license. For a detailed overview, and pointers to the+full licenses of these components, see the COPYRIGHT file in the source.
+ doc/license/AGPL view
@@ -0,0 +1,661 @@+                    GNU AFFERO GENERAL PUBLIC LICENSE+                       Version 3, 19 November 2007++ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>+ Everyone is permitted to copy and distribute verbatim copies+ of this license document, but changing it is not allowed.++                            Preamble++  The GNU Affero General Public License is a free, copyleft license for+software and other kinds of works, specifically designed to ensure+cooperation with the community in the case of network server software.++  The licenses for most software and other practical works are designed+to take away your freedom to share and change the works.  By contrast,+our General Public Licenses are intended to guarantee your freedom to+share and change all versions of a program--to make sure it remains free+software for all its users.++  When we speak of free software, we are referring to freedom, not+price.  Our General Public Licenses are designed to make sure that you+have the freedom to distribute copies of free software (and charge for+them if you wish), that you receive source code or can get it if you+want it, that you can change the software or use pieces of it in new+free programs, and that you know you can do these things.++  Developers that use our General Public Licenses protect your rights+with two steps: (1) assert copyright on the software, and (2) offer+you this License which gives you legal permission to copy, distribute+and/or modify the software.++  A secondary benefit of defending all users' freedom is that+improvements made in alternate versions of the program, if they+receive widespread use, become available for other developers to+incorporate.  Many developers of free software are heartened and+encouraged by the resulting cooperation.  However, in the case of+software used on network servers, this result may fail to come about.+The GNU General Public License permits making a modified version and+letting the public access it on a server without ever releasing its+source code to the public.++  The GNU Affero General Public License is designed specifically to+ensure that, in such cases, the modified source code becomes available+to the community.  It requires the operator of a network server to+provide the source code of the modified version running there to the+users of that server.  Therefore, public use of a modified version, on+a publicly accessible server, gives the public access to the source+code of the modified version.++  An older license, called the Affero General Public License and+published by Affero, was designed to accomplish similar goals.  This is+a different license, not a version of the Affero GPL, but Affero has+released a new version of the Affero GPL which permits relicensing under+this license.++  The precise terms and conditions for copying, distribution and+modification follow.++                       TERMS AND CONDITIONS++  0. Definitions.++  "This License" refers to version 3 of the GNU Affero General Public License.++  "Copyright" also means copyright-like laws that apply to other kinds of+works, such as semiconductor masks.++  "The Program" refers to any copyrightable work licensed under this+License.  Each licensee is addressed as "you".  "Licensees" and+"recipients" may be individuals or organizations.++  To "modify" a work means to copy from or adapt all or part of the work+in a fashion requiring copyright permission, other than the making of an+exact copy.  The resulting work is called a "modified version" of the+earlier work or a work "based on" the earlier work.++  A "covered work" means either the unmodified Program or a work based+on the Program.++  To "propagate" a work means to do anything with it that, without+permission, would make you directly or secondarily liable for+infringement under applicable copyright law, except executing it on a+computer or modifying a private copy.  Propagation includes copying,+distribution (with or without modification), making available to the+public, and in some countries other activities as well.++  To "convey" a work means any kind of propagation that enables other+parties to make or receive copies.  Mere interaction with a user through+a computer network, with no transfer of a copy, is not conveying.++  An interactive user interface displays "Appropriate Legal Notices"+to the extent that it includes a convenient and prominently visible+feature that (1) displays an appropriate copyright notice, and (2)+tells the user that there is no warranty for the work (except to the+extent that warranties are provided), that licensees may convey the+work under this License, and how to view a copy of this License.  If+the interface presents a list of user commands or options, such as a+menu, a prominent item in the list meets this criterion.++  1. Source Code.++  The "source code" for a work means the preferred form of the work+for making modifications to it.  "Object code" means any non-source+form of a work.++  A "Standard Interface" means an interface that either is an official+standard defined by a recognized standards body, or, in the case of+interfaces specified for a particular programming language, one that+is widely used among developers working in that language.++  The "System Libraries" of an executable work include anything, other+than the work as a whole, that (a) is included in the normal form of+packaging a Major Component, but which is not part of that Major+Component, and (b) serves only to enable use of the work with that+Major Component, or to implement a Standard Interface for which an+implementation is available to the public in source code form.  A+"Major Component", in this context, means a major essential component+(kernel, window system, and so on) of the specific operating system+(if any) on which the executable work runs, or a compiler used to+produce the work, or an object code interpreter used to run it.++  The "Corresponding Source" for a work in object code form means all+the source code needed to generate, install, and (for an executable+work) run the object code and to modify the work, including scripts to+control those activities.  However, it does not include the work's+System Libraries, or general-purpose tools or generally available free+programs which are used unmodified in performing those activities but+which are not part of the work.  For example, Corresponding Source+includes interface definition files associated with source files for+the work, and the source code for shared libraries and dynamically+linked subprograms that the work is specifically designed to require,+such as by intimate data communication or control flow between those+subprograms and other parts of the work.++  The Corresponding Source need not include anything that users+can regenerate automatically from other parts of the Corresponding+Source.++  The Corresponding Source for a work in source code form is that+same work.++  2. Basic Permissions.++  All rights granted under this License are granted for the term of+copyright on the Program, and are irrevocable provided the stated+conditions are met.  This License explicitly affirms your unlimited+permission to run the unmodified Program.  The output from running a+covered work is covered by this License only if the output, given its+content, constitutes a covered work.  This License acknowledges your+rights of fair use or other equivalent, as provided by copyright law.++  You may make, run and propagate covered works that you do not+convey, without conditions so long as your license otherwise remains+in force.  You may convey covered works to others for the sole purpose+of having them make modifications exclusively for you, or provide you+with facilities for running those works, provided that you comply with+the terms of this License in conveying all material for which you do+not control copyright.  Those thus making or running the covered works+for you must do so exclusively on your behalf, under your direction+and control, on terms that prohibit them from making any copies of+your copyrighted material outside their relationship with you.++  Conveying under any other circumstances is permitted solely under+the conditions stated below.  Sublicensing is not allowed; section 10+makes it unnecessary.++  3. Protecting Users' Legal Rights From Anti-Circumvention Law.++  No covered work shall be deemed part of an effective technological+measure under any applicable law fulfilling obligations under article+11 of the WIPO copyright treaty adopted on 20 December 1996, or+similar laws prohibiting or restricting circumvention of such+measures.++  When you convey a covered work, you waive any legal power to forbid+circumvention of technological measures to the extent such circumvention+is effected by exercising rights under this License with respect to+the covered work, and you disclaim any intention to limit operation or+modification of the work as a means of enforcing, against the work's+users, your or third parties' legal rights to forbid circumvention of+technological measures.++  4. Conveying Verbatim Copies.++  You may convey verbatim copies of the Program's source code as you+receive it, in any medium, provided that you conspicuously and+appropriately publish on each copy an appropriate copyright notice;+keep intact all notices stating that this License and any+non-permissive terms added in accord with section 7 apply to the code;+keep intact all notices of the absence of any warranty; and give all+recipients a copy of this License along with the Program.++  You may charge any price or no price for each copy that you convey,+and you may offer support or warranty protection for a fee.++  5. Conveying Modified Source Versions.++  You may convey a work based on the Program, or the modifications to+produce it from the Program, in the form of source code under the+terms of section 4, provided that you also meet all of these conditions:++    a) The work must carry prominent notices stating that you modified+    it, and giving a relevant date.++    b) The work must carry prominent notices stating that it is+    released under this License and any conditions added under section+    7.  This requirement modifies the requirement in section 4 to+    "keep intact all notices".++    c) You must license the entire work, as a whole, under this+    License to anyone who comes into possession of a copy.  This+    License will therefore apply, along with any applicable section 7+    additional terms, to the whole of the work, and all its parts,+    regardless of how they are packaged.  This License gives no+    permission to license the work in any other way, but it does not+    invalidate such permission if you have separately received it.++    d) If the work has interactive user interfaces, each must display+    Appropriate Legal Notices; however, if the Program has interactive+    interfaces that do not display Appropriate Legal Notices, your+    work need not make them do so.++  A compilation of a covered work with other separate and independent+works, which are not by their nature extensions of the covered work,+and which are not combined with it such as to form a larger program,+in or on a volume of a storage or distribution medium, is called an+"aggregate" if the compilation and its resulting copyright are not+used to limit the access or legal rights of the compilation's users+beyond what the individual works permit.  Inclusion of a covered work+in an aggregate does not cause this License to apply to the other+parts of the aggregate.++  6. Conveying Non-Source Forms.++  You may convey a covered work in object code form under the terms+of sections 4 and 5, provided that you also convey the+machine-readable Corresponding Source under the terms of this License,+in one of these ways:++    a) Convey the object code in, or embodied in, a physical product+    (including a physical distribution medium), accompanied by the+    Corresponding Source fixed on a durable physical medium+    customarily used for software interchange.++    b) Convey the object code in, or embodied in, a physical product+    (including a physical distribution medium), accompanied by a+    written offer, valid for at least three years and valid for as+    long as you offer spare parts or customer support for that product+    model, to give anyone who possesses the object code either (1) a+    copy of the Corresponding Source for all the software in the+    product that is covered by this License, on a durable physical+    medium customarily used for software interchange, for a price no+    more than your reasonable cost of physically performing this+    conveying of source, or (2) access to copy the+    Corresponding Source from a network server at no charge.++    c) Convey individual copies of the object code with a copy of the+    written offer to provide the Corresponding Source.  This+    alternative is allowed only occasionally and noncommercially, and+    only if you received the object code with such an offer, in accord+    with subsection 6b.++    d) Convey the object code by offering access from a designated+    place (gratis or for a charge), and offer equivalent access to the+    Corresponding Source in the same way through the same place at no+    further charge.  You need not require recipients to copy the+    Corresponding Source along with the object code.  If the place to+    copy the object code is a network server, the Corresponding Source+    may be on a different server (operated by you or a third party)+    that supports equivalent copying facilities, provided you maintain+    clear directions next to the object code saying where to find the+    Corresponding Source.  Regardless of what server hosts the+    Corresponding Source, you remain obligated to ensure that it is+    available for as long as needed to satisfy these requirements.++    e) Convey the object code using peer-to-peer transmission, provided+    you inform other peers where the object code and Corresponding+    Source of the work are being offered to the general public at no+    charge under subsection 6d.++  A separable portion of the object code, whose source code is excluded+from the Corresponding Source as a System Library, need not be+included in conveying the object code work.++  A "User Product" is either (1) a "consumer product", which means any+tangible personal property which is normally used for personal, family,+or household purposes, or (2) anything designed or sold for incorporation+into a dwelling.  In determining whether a product is a consumer product,+doubtful cases shall be resolved in favor of coverage.  For a particular+product received by a particular user, "normally used" refers to a+typical or common use of that class of product, regardless of the status+of the particular user or of the way in which the particular user+actually uses, or expects or is expected to use, the product.  A product+is a consumer product regardless of whether the product has substantial+commercial, industrial or non-consumer uses, unless such uses represent+the only significant mode of use of the product.++  "Installation Information" for a User Product means any methods,+procedures, authorization keys, or other information required to install+and execute modified versions of a covered work in that User Product from+a modified version of its Corresponding Source.  The information must+suffice to ensure that the continued functioning of the modified object+code is in no case prevented or interfered with solely because+modification has been made.++  If you convey an object code work under this section in, or with, or+specifically for use in, a User Product, and the conveying occurs as+part of a transaction in which the right of possession and use of the+User Product is transferred to the recipient in perpetuity or for a+fixed term (regardless of how the transaction is characterized), the+Corresponding Source conveyed under this section must be accompanied+by the Installation Information.  But this requirement does not apply+if neither you nor any third party retains the ability to install+modified object code on the User Product (for example, the work has+been installed in ROM).++  The requirement to provide Installation Information does not include a+requirement to continue to provide support service, warranty, or updates+for a work that has been modified or installed by the recipient, or for+the User Product in which it has been modified or installed.  Access to a+network may be denied when the modification itself materially and+adversely affects the operation of the network or violates the rules and+protocols for communication across the network.++  Corresponding Source conveyed, and Installation Information provided,+in accord with this section must be in a format that is publicly+documented (and with an implementation available to the public in+source code form), and must require no special password or key for+unpacking, reading or copying.++  7. Additional Terms.++  "Additional permissions" are terms that supplement the terms of this+License by making exceptions from one or more of its conditions.+Additional permissions that are applicable to the entire Program shall+be treated as though they were included in this License, to the extent+that they are valid under applicable law.  If additional permissions+apply only to part of the Program, that part may be used separately+under those permissions, but the entire Program remains governed by+this License without regard to the additional permissions.++  When you convey a copy of a covered work, you may at your option+remove any additional permissions from that copy, or from any part of+it.  (Additional permissions may be written to require their own+removal in certain cases when you modify the work.)  You may place+additional permissions on material, added by you to a covered work,+for which you have or can give appropriate copyright permission.++  Notwithstanding any other provision of this License, for material you+add to a covered work, you may (if authorized by the copyright holders of+that material) supplement the terms of this License with terms:++    a) Disclaiming warranty or limiting liability differently from the+    terms of sections 15 and 16 of this License; or++    b) Requiring preservation of specified reasonable legal notices or+    author attributions in that material or in the Appropriate Legal+    Notices displayed by works containing it; or++    c) Prohibiting misrepresentation of the origin of that material, or+    requiring that modified versions of such material be marked in+    reasonable ways as different from the original version; or++    d) Limiting the use for publicity purposes of names of licensors or+    authors of the material; or++    e) Declining to grant rights under trademark law for use of some+    trade names, trademarks, or service marks; or++    f) Requiring indemnification of licensors and authors of that+    material by anyone who conveys the material (or modified versions of+    it) with contractual assumptions of liability to the recipient, for+    any liability that these contractual assumptions directly impose on+    those licensors and authors.++  All other non-permissive additional terms are considered "further+restrictions" within the meaning of section 10.  If the Program as you+received it, or any part of it, contains a notice stating that it is+governed by this License along with a term that is a further+restriction, you may remove that term.  If a license document contains+a further restriction but permits relicensing or conveying under this+License, you may add to a covered work material governed by the terms+of that license document, provided that the further restriction does+not survive such relicensing or conveying.++  If you add terms to a covered work in accord with this section, you+must place, in the relevant source files, a statement of the+additional terms that apply to those files, or a notice indicating+where to find the applicable terms.++  Additional terms, permissive or non-permissive, may be stated in the+form of a separately written license, or stated as exceptions;+the above requirements apply either way.++  8. Termination.++  You may not propagate or modify a covered work except as expressly+provided under this License.  Any attempt otherwise to propagate or+modify it is void, and will automatically terminate your rights under+this License (including any patent licenses granted under the third+paragraph of section 11).++  However, if you cease all violation of this License, then your+license from a particular copyright holder is reinstated (a)+provisionally, unless and until the copyright holder explicitly and+finally terminates your license, and (b) permanently, if the copyright+holder fails to notify you of the violation by some reasonable means+prior to 60 days after the cessation.++  Moreover, your license from a particular copyright holder is+reinstated permanently if the copyright holder notifies you of the+violation by some reasonable means, this is the first time you have+received notice of violation of this License (for any work) from that+copyright holder, and you cure the violation prior to 30 days after+your receipt of the notice.++  Termination of your rights under this section does not terminate the+licenses of parties who have received copies or rights from you under+this License.  If your rights have been terminated and not permanently+reinstated, you do not qualify to receive new licenses for the same+material under section 10.++  9. Acceptance Not Required for Having Copies.++  You are not required to accept this License in order to receive or+run a copy of the Program.  Ancillary propagation of a covered work+occurring solely as a consequence of using peer-to-peer transmission+to receive a copy likewise does not require acceptance.  However,+nothing other than this License grants you permission to propagate or+modify any covered work.  These actions infringe copyright if you do+not accept this License.  Therefore, by modifying or propagating a+covered work, you indicate your acceptance of this License to do so.++  10. Automatic Licensing of Downstream Recipients.++  Each time you convey a covered work, the recipient automatically+receives a license from the original licensors, to run, modify and+propagate that work, subject to this License.  You are not responsible+for enforcing compliance by third parties with this License.++  An "entity transaction" is a transaction transferring control of an+organization, or substantially all assets of one, or subdividing an+organization, or merging organizations.  If propagation of a covered+work results from an entity transaction, each party to that+transaction who receives a copy of the work also receives whatever+licenses to the work the party's predecessor in interest had or could+give under the previous paragraph, plus a right to possession of the+Corresponding Source of the work from the predecessor in interest, if+the predecessor has it or can get it with reasonable efforts.++  You may not impose any further restrictions on the exercise of the+rights granted or affirmed under this License.  For example, you may+not impose a license fee, royalty, or other charge for exercise of+rights granted under this License, and you may not initiate litigation+(including a cross-claim or counterclaim in a lawsuit) alleging that+any patent claim is infringed by making, using, selling, offering for+sale, or importing the Program or any portion of it.++  11. Patents.++  A "contributor" is a copyright holder who authorizes use under this+License of the Program or a work on which the Program is based.  The+work thus licensed is called the contributor's "contributor version".++  A contributor's "essential patent claims" are all patent claims+owned or controlled by the contributor, whether already acquired or+hereafter acquired, that would be infringed by some manner, permitted+by this License, of making, using, or selling its contributor version,+but do not include claims that would be infringed only as a+consequence of further modification of the contributor version.  For+purposes of this definition, "control" includes the right to grant+patent sublicenses in a manner consistent with the requirements of+this License.++  Each contributor grants you a non-exclusive, worldwide, royalty-free+patent license under the contributor's essential patent claims, to+make, use, sell, offer for sale, import and otherwise run, modify and+propagate the contents of its contributor version.++  In the following three paragraphs, a "patent license" is any express+agreement or commitment, however denominated, not to enforce a patent+(such as an express permission to practice a patent or covenant not to+sue for patent infringement).  To "grant" such a patent license to a+party means to make such an agreement or commitment not to enforce a+patent against the party.++  If you convey a covered work, knowingly relying on a patent license,+and the Corresponding Source of the work is not available for anyone+to copy, free of charge and under the terms of this License, through a+publicly available network server or other readily accessible means,+then you must either (1) cause the Corresponding Source to be so+available, or (2) arrange to deprive yourself of the benefit of the+patent license for this particular work, or (3) arrange, in a manner+consistent with the requirements of this License, to extend the patent+license to downstream recipients.  "Knowingly relying" means you have+actual knowledge that, but for the patent license, your conveying the+covered work in a country, or your recipient's use of the covered work+in a country, would infringe one or more identifiable patents in that+country that you have reason to believe are valid.++  If, pursuant to or in connection with a single transaction or+arrangement, you convey, or propagate by procuring conveyance of, a+covered work, and grant a patent license to some of the parties+receiving the covered work authorizing them to use, propagate, modify+or convey a specific copy of the covered work, then the patent license+you grant is automatically extended to all recipients of the covered+work and works based on it.++  A patent license is "discriminatory" if it does not include within+the scope of its coverage, prohibits the exercise of, or is+conditioned on the non-exercise of one or more of the rights that are+specifically granted under this License.  You may not convey a covered+work if you are a party to an arrangement with a third party that is+in the business of distributing software, under which you make payment+to the third party based on the extent of your activity of conveying+the work, and under which the third party grants, to any of the+parties who would receive the covered work from you, a discriminatory+patent license (a) in connection with copies of the covered work+conveyed by you (or copies made from those copies), or (b) primarily+for and in connection with specific products or compilations that+contain the covered work, unless you entered into that arrangement,+or that patent license was granted, prior to 28 March 2007.++  Nothing in this License shall be construed as excluding or limiting+any implied license or other defenses to infringement that may+otherwise be available to you under applicable patent law.++  12. No Surrender of Others' Freedom.++  If conditions are imposed on you (whether by court order, agreement or+otherwise) that contradict the conditions of this License, they do not+excuse you from the conditions of this License.  If you cannot convey a+covered work so as to satisfy simultaneously your obligations under this+License and any other pertinent obligations, then as a consequence you may+not convey it at all.  For example, if you agree to terms that obligate you+to collect a royalty for further conveying from those to whom you convey+the Program, the only way you could satisfy both those terms and this+License would be to refrain entirely from conveying the Program.++  13. Remote Network Interaction; Use with the GNU General Public License.++  Notwithstanding any other provision of this License, if you modify the+Program, your modified version must prominently offer all users+interacting with it remotely through a computer network (if your version+supports such interaction) an opportunity to receive the Corresponding+Source of your version by providing access to the Corresponding Source+from a network server at no charge, through some standard or customary+means of facilitating copying of software.  This Corresponding Source+shall include the Corresponding Source for any work covered by version 3+of the GNU General Public License that is incorporated pursuant to the+following paragraph.++  Notwithstanding any other provision of this License, you have+permission to link or combine any covered work with a work licensed+under version 3 of the GNU General Public License into a single+combined work, and to convey the resulting work.  The terms of this+License will continue to apply to the part which is the covered work,+but the work with which it is combined will remain governed by version+3 of the GNU General Public License.++  14. Revised Versions of this License.++  The Free Software Foundation may publish revised and/or new versions of+the GNU Affero General Public License from time to time.  Such new versions+will be similar in spirit to the present version, but may differ in detail to+address new problems or concerns.++  Each version is given a distinguishing version number.  If the+Program specifies that a certain numbered version of the GNU Affero General+Public License "or any later version" applies to it, you have the+option of following the terms and conditions either of that numbered+version or of any later version published by the Free Software+Foundation.  If the Program does not specify a version number of the+GNU Affero General Public License, you may choose any version ever published+by the Free Software Foundation.++  If the Program specifies that a proxy can decide which future+versions of the GNU Affero General Public License can be used, that proxy's+public statement of acceptance of a version permanently authorizes you+to choose that version for the Program.++  Later license versions may give you additional or different+permissions.  However, no additional obligations are imposed on any+author or copyright holder as a result of your choosing to follow a+later version.++  15. Disclaimer of Warranty.++  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY+APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM+IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.++  16. Limitation of Liability.++  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF+SUCH DAMAGES.++  17. Interpretation of Sections 15 and 16.++  If the disclaimer of warranty and limitation of liability provided+above cannot be given local legal effect according to their terms,+reviewing courts shall apply local law that most closely approximates+an absolute waiver of all civil liability in connection with the+Program, unless a warranty or assumption of liability accompanies a+copy of the Program in return for a fee.++                     END OF TERMS AND CONDITIONS++            How to Apply These Terms to Your New Programs++  If you develop a new program, and you want it to be of the greatest+possible use to the public, the best way to achieve this is to make it+free software which everyone can redistribute and change under these terms.++  To do so, attach the following notices to the program.  It is safest+to attach them to the start of each source file to most effectively+state the exclusion of warranty; and each file should have at least+the "copyright" line and a pointer to where the full notice is found.++    <one line to give the program's name and a brief idea of what it does.>+    Copyright (C) <year>  <name of author>++    This program is free software: you can redistribute it and/or modify+    it under the terms of the GNU Affero General Public License as published by+    the Free Software Foundation, either version 3 of the License, or+    (at your option) any later version.++    This program is distributed in the hope that it will be useful,+    but WITHOUT ANY WARRANTY; without even the implied warranty of+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the+    GNU Affero General Public License for more details.++    You should have received a copy of the GNU Affero General Public License+    along with this program.  If not, see <http://www.gnu.org/licenses/>.++Also add information on how to contact you by electronic and paper mail.++  If your software can interact with users remotely through a computer+network, you should also make sure that it provides a way for users to+get its source.  For example, if your program is a web application, its+interface could display a "Source" link that leads users to an archive+of the code.  There are many ways you could offer source, and different+solutions will be better for different programs; see section 13 for the+specific requirements.++  You should also get your employer (if you work as a programmer) or school,+if any, to sign a "copyright disclaimer" for the program, if necessary.+For more information on this, and how to apply and follow the GNU AGPL, see+<http://www.gnu.org/licenses/>.
+ doc/license/GPL view
@@ -0,0 +1,674 @@+                    GNU GENERAL PUBLIC LICENSE+                       Version 3, 29 June 2007++ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>+ Everyone is permitted to copy and distribute verbatim copies+ of this license document, but changing it is not allowed.++                            Preamble++  The GNU General Public License is a free, copyleft license for+software and other kinds of works.++  The licenses for most software and other practical works are designed+to take away your freedom to share and change the works.  By contrast,+the GNU General Public License is intended to guarantee your freedom to+share and change all versions of a program--to make sure it remains free+software for all its users.  We, the Free Software Foundation, use the+GNU General Public License for most of our software; it applies also to+any other work released this way by its authors.  You can apply it to+your programs, too.++  When we speak of free software, we are referring to freedom, not+price.  Our General Public Licenses are designed to make sure that you+have the freedom to distribute copies of free software (and charge for+them if you wish), that you receive source code or can get it if you+want it, that you can change the software or use pieces of it in new+free programs, and that you know you can do these things.++  To protect your rights, we need to prevent others from denying you+these rights or asking you to surrender the rights.  Therefore, you have+certain responsibilities if you distribute copies of the software, or if+you modify it: responsibilities to respect the freedom of others.++  For example, if you distribute copies of such a program, whether+gratis or for a fee, you must pass on to the recipients the same+freedoms that you received.  You must make sure that they, too, receive+or can get the source code.  And you must show them these terms so they+know their rights.++  Developers that use the GNU GPL protect your rights with two steps:+(1) assert copyright on the software, and (2) offer you this License+giving you legal permission to copy, distribute and/or modify it.++  For the developers' and authors' protection, the GPL clearly explains+that there is no warranty for this free software.  For both users' and+authors' sake, the GPL requires that modified versions be marked as+changed, so that their problems will not be attributed erroneously to+authors of previous versions.++  Some devices are designed to deny users access to install or run+modified versions of the software inside them, although the manufacturer+can do so.  This is fundamentally incompatible with the aim of+protecting users' freedom to change the software.  The systematic+pattern of such abuse occurs in the area of products for individuals to+use, which is precisely where it is most unacceptable.  Therefore, we+have designed this version of the GPL to prohibit the practice for those+products.  If such problems arise substantially in other domains, we+stand ready to extend this provision to those domains in future versions+of the GPL, as needed to protect the freedom of users.++  Finally, every program is threatened constantly by software patents.+States should not allow patents to restrict development and use of+software on general-purpose computers, but in those that do, we wish to+avoid the special danger that patents applied to a free program could+make it effectively proprietary.  To prevent this, the GPL assures that+patents cannot be used to render the program non-free.++  The precise terms and conditions for copying, distribution and+modification follow.++                       TERMS AND CONDITIONS++  0. Definitions.++  "This License" refers to version 3 of the GNU General Public License.++  "Copyright" also means copyright-like laws that apply to other kinds of+works, such as semiconductor masks.++  "The Program" refers to any copyrightable work licensed under this+License.  Each licensee is addressed as "you".  "Licensees" and+"recipients" may be individuals or organizations.++  To "modify" a work means to copy from or adapt all or part of the work+in a fashion requiring copyright permission, other than the making of an+exact copy.  The resulting work is called a "modified version" of the+earlier work or a work "based on" the earlier work.++  A "covered work" means either the unmodified Program or a work based+on the Program.++  To "propagate" a work means to do anything with it that, without+permission, would make you directly or secondarily liable for+infringement under applicable copyright law, except executing it on a+computer or modifying a private copy.  Propagation includes copying,+distribution (with or without modification), making available to the+public, and in some countries other activities as well.++  To "convey" a work means any kind of propagation that enables other+parties to make or receive copies.  Mere interaction with a user through+a computer network, with no transfer of a copy, is not conveying.++  An interactive user interface displays "Appropriate Legal Notices"+to the extent that it includes a convenient and prominently visible+feature that (1) displays an appropriate copyright notice, and (2)+tells the user that there is no warranty for the work (except to the+extent that warranties are provided), that licensees may convey the+work under this License, and how to view a copy of this License.  If+the interface presents a list of user commands or options, such as a+menu, a prominent item in the list meets this criterion.++  1. Source Code.++  The "source code" for a work means the preferred form of the work+for making modifications to it.  "Object code" means any non-source+form of a work.++  A "Standard Interface" means an interface that either is an official+standard defined by a recognized standards body, or, in the case of+interfaces specified for a particular programming language, one that+is widely used among developers working in that language.++  The "System Libraries" of an executable work include anything, other+than the work as a whole, that (a) is included in the normal form of+packaging a Major Component, but which is not part of that Major+Component, and (b) serves only to enable use of the work with that+Major Component, or to implement a Standard Interface for which an+implementation is available to the public in source code form.  A+"Major Component", in this context, means a major essential component+(kernel, window system, and so on) of the specific operating system+(if any) on which the executable work runs, or a compiler used to+produce the work, or an object code interpreter used to run it.++  The "Corresponding Source" for a work in object code form means all+the source code needed to generate, install, and (for an executable+work) run the object code and to modify the work, including scripts to+control those activities.  However, it does not include the work's+System Libraries, or general-purpose tools or generally available free+programs which are used unmodified in performing those activities but+which are not part of the work.  For example, Corresponding Source+includes interface definition files associated with source files for+the work, and the source code for shared libraries and dynamically+linked subprograms that the work is specifically designed to require,+such as by intimate data communication or control flow between those+subprograms and other parts of the work.++  The Corresponding Source need not include anything that users+can regenerate automatically from other parts of the Corresponding+Source.++  The Corresponding Source for a work in source code form is that+same work.++  2. Basic Permissions.++  All rights granted under this License are granted for the term of+copyright on the Program, and are irrevocable provided the stated+conditions are met.  This License explicitly affirms your unlimited+permission to run the unmodified Program.  The output from running a+covered work is covered by this License only if the output, given its+content, constitutes a covered work.  This License acknowledges your+rights of fair use or other equivalent, as provided by copyright law.++  You may make, run and propagate covered works that you do not+convey, without conditions so long as your license otherwise remains+in force.  You may convey covered works to others for the sole purpose+of having them make modifications exclusively for you, or provide you+with facilities for running those works, provided that you comply with+the terms of this License in conveying all material for which you do+not control copyright.  Those thus making or running the covered works+for you must do so exclusively on your behalf, under your direction+and control, on terms that prohibit them from making any copies of+your copyrighted material outside their relationship with you.++  Conveying under any other circumstances is permitted solely under+the conditions stated below.  Sublicensing is not allowed; section 10+makes it unnecessary.++  3. Protecting Users' Legal Rights From Anti-Circumvention Law.++  No covered work shall be deemed part of an effective technological+measure under any applicable law fulfilling obligations under article+11 of the WIPO copyright treaty adopted on 20 December 1996, or+similar laws prohibiting or restricting circumvention of such+measures.++  When you convey a covered work, you waive any legal power to forbid+circumvention of technological measures to the extent such circumvention+is effected by exercising rights under this License with respect to+the covered work, and you disclaim any intention to limit operation or+modification of the work as a means of enforcing, against the work's+users, your or third parties' legal rights to forbid circumvention of+technological measures.++  4. Conveying Verbatim Copies.++  You may convey verbatim copies of the Program's source code as you+receive it, in any medium, provided that you conspicuously and+appropriately publish on each copy an appropriate copyright notice;+keep intact all notices stating that this License and any+non-permissive terms added in accord with section 7 apply to the code;+keep intact all notices of the absence of any warranty; and give all+recipients a copy of this License along with the Program.++  You may charge any price or no price for each copy that you convey,+and you may offer support or warranty protection for a fee.++  5. Conveying Modified Source Versions.++  You may convey a work based on the Program, or the modifications to+produce it from the Program, in the form of source code under the+terms of section 4, provided that you also meet all of these conditions:++    a) The work must carry prominent notices stating that you modified+    it, and giving a relevant date.++    b) The work must carry prominent notices stating that it is+    released under this License and any conditions added under section+    7.  This requirement modifies the requirement in section 4 to+    "keep intact all notices".++    c) You must license the entire work, as a whole, under this+    License to anyone who comes into possession of a copy.  This+    License will therefore apply, along with any applicable section 7+    additional terms, to the whole of the work, and all its parts,+    regardless of how they are packaged.  This License gives no+    permission to license the work in any other way, but it does not+    invalidate such permission if you have separately received it.++    d) If the work has interactive user interfaces, each must display+    Appropriate Legal Notices; however, if the Program has interactive+    interfaces that do not display Appropriate Legal Notices, your+    work need not make them do so.++  A compilation of a covered work with other separate and independent+works, which are not by their nature extensions of the covered work,+and which are not combined with it such as to form a larger program,+in or on a volume of a storage or distribution medium, is called an+"aggregate" if the compilation and its resulting copyright are not+used to limit the access or legal rights of the compilation's users+beyond what the individual works permit.  Inclusion of a covered work+in an aggregate does not cause this License to apply to the other+parts of the aggregate.++  6. Conveying Non-Source Forms.++  You may convey a covered work in object code form under the terms+of sections 4 and 5, provided that you also convey the+machine-readable Corresponding Source under the terms of this License,+in one of these ways:++    a) Convey the object code in, or embodied in, a physical product+    (including a physical distribution medium), accompanied by the+    Corresponding Source fixed on a durable physical medium+    customarily used for software interchange.++    b) Convey the object code in, or embodied in, a physical product+    (including a physical distribution medium), accompanied by a+    written offer, valid for at least three years and valid for as+    long as you offer spare parts or customer support for that product+    model, to give anyone who possesses the object code either (1) a+    copy of the Corresponding Source for all the software in the+    product that is covered by this License, on a durable physical+    medium customarily used for software interchange, for a price no+    more than your reasonable cost of physically performing this+    conveying of source, or (2) access to copy the+    Corresponding Source from a network server at no charge.++    c) Convey individual copies of the object code with a copy of the+    written offer to provide the Corresponding Source.  This+    alternative is allowed only occasionally and noncommercially, and+    only if you received the object code with such an offer, in accord+    with subsection 6b.++    d) Convey the object code by offering access from a designated+    place (gratis or for a charge), and offer equivalent access to the+    Corresponding Source in the same way through the same place at no+    further charge.  You need not require recipients to copy the+    Corresponding Source along with the object code.  If the place to+    copy the object code is a network server, the Corresponding Source+    may be on a different server (operated by you or a third party)+    that supports equivalent copying facilities, provided you maintain+    clear directions next to the object code saying where to find the+    Corresponding Source.  Regardless of what server hosts the+    Corresponding Source, you remain obligated to ensure that it is+    available for as long as needed to satisfy these requirements.++    e) Convey the object code using peer-to-peer transmission, provided+    you inform other peers where the object code and Corresponding+    Source of the work are being offered to the general public at no+    charge under subsection 6d.++  A separable portion of the object code, whose source code is excluded+from the Corresponding Source as a System Library, need not be+included in conveying the object code work.++  A "User Product" is either (1) a "consumer product", which means any+tangible personal property which is normally used for personal, family,+or household purposes, or (2) anything designed or sold for incorporation+into a dwelling.  In determining whether a product is a consumer product,+doubtful cases shall be resolved in favor of coverage.  For a particular+product received by a particular user, "normally used" refers to a+typical or common use of that class of product, regardless of the status+of the particular user or of the way in which the particular user+actually uses, or expects or is expected to use, the product.  A product+is a consumer product regardless of whether the product has substantial+commercial, industrial or non-consumer uses, unless such uses represent+the only significant mode of use of the product.++  "Installation Information" for a User Product means any methods,+procedures, authorization keys, or other information required to install+and execute modified versions of a covered work in that User Product from+a modified version of its Corresponding Source.  The information must+suffice to ensure that the continued functioning of the modified object+code is in no case prevented or interfered with solely because+modification has been made.++  If you convey an object code work under this section in, or with, or+specifically for use in, a User Product, and the conveying occurs as+part of a transaction in which the right of possession and use of the+User Product is transferred to the recipient in perpetuity or for a+fixed term (regardless of how the transaction is characterized), the+Corresponding Source conveyed under this section must be accompanied+by the Installation Information.  But this requirement does not apply+if neither you nor any third party retains the ability to install+modified object code on the User Product (for example, the work has+been installed in ROM).++  The requirement to provide Installation Information does not include a+requirement to continue to provide support service, warranty, or updates+for a work that has been modified or installed by the recipient, or for+the User Product in which it has been modified or installed.  Access to a+network may be denied when the modification itself materially and+adversely affects the operation of the network or violates the rules and+protocols for communication across the network.++  Corresponding Source conveyed, and Installation Information provided,+in accord with this section must be in a format that is publicly+documented (and with an implementation available to the public in+source code form), and must require no special password or key for+unpacking, reading or copying.++  7. Additional Terms.++  "Additional permissions" are terms that supplement the terms of this+License by making exceptions from one or more of its conditions.+Additional permissions that are applicable to the entire Program shall+be treated as though they were included in this License, to the extent+that they are valid under applicable law.  If additional permissions+apply only to part of the Program, that part may be used separately+under those permissions, but the entire Program remains governed by+this License without regard to the additional permissions.++  When you convey a copy of a covered work, you may at your option+remove any additional permissions from that copy, or from any part of+it.  (Additional permissions may be written to require their own+removal in certain cases when you modify the work.)  You may place+additional permissions on material, added by you to a covered work,+for which you have or can give appropriate copyright permission.++  Notwithstanding any other provision of this License, for material you+add to a covered work, you may (if authorized by the copyright holders of+that material) supplement the terms of this License with terms:++    a) Disclaiming warranty or limiting liability differently from the+    terms of sections 15 and 16 of this License; or++    b) Requiring preservation of specified reasonable legal notices or+    author attributions in that material or in the Appropriate Legal+    Notices displayed by works containing it; or++    c) Prohibiting misrepresentation of the origin of that material, or+    requiring that modified versions of such material be marked in+    reasonable ways as different from the original version; or++    d) Limiting the use for publicity purposes of names of licensors or+    authors of the material; or++    e) Declining to grant rights under trademark law for use of some+    trade names, trademarks, or service marks; or++    f) Requiring indemnification of licensors and authors of that+    material by anyone who conveys the material (or modified versions of+    it) with contractual assumptions of liability to the recipient, for+    any liability that these contractual assumptions directly impose on+    those licensors and authors.++  All other non-permissive additional terms are considered "further+restrictions" within the meaning of section 10.  If the Program as you+received it, or any part of it, contains a notice stating that it is+governed by this License along with a term that is a further+restriction, you may remove that term.  If a license document contains+a further restriction but permits relicensing or conveying under this+License, you may add to a covered work material governed by the terms+of that license document, provided that the further restriction does+not survive such relicensing or conveying.++  If you add terms to a covered work in accord with this section, you+must place, in the relevant source files, a statement of the+additional terms that apply to those files, or a notice indicating+where to find the applicable terms.++  Additional terms, permissive or non-permissive, may be stated in the+form of a separately written license, or stated as exceptions;+the above requirements apply either way.++  8. Termination.++  You may not propagate or modify a covered work except as expressly+provided under this License.  Any attempt otherwise to propagate or+modify it is void, and will automatically terminate your rights under+this License (including any patent licenses granted under the third+paragraph of section 11).++  However, if you cease all violation of this License, then your+license from a particular copyright holder is reinstated (a)+provisionally, unless and until the copyright holder explicitly and+finally terminates your license, and (b) permanently, if the copyright+holder fails to notify you of the violation by some reasonable means+prior to 60 days after the cessation.++  Moreover, your license from a particular copyright holder is+reinstated permanently if the copyright holder notifies you of the+violation by some reasonable means, this is the first time you have+received notice of violation of this License (for any work) from that+copyright holder, and you cure the violation prior to 30 days after+your receipt of the notice.++  Termination of your rights under this section does not terminate the+licenses of parties who have received copies or rights from you under+this License.  If your rights have been terminated and not permanently+reinstated, you do not qualify to receive new licenses for the same+material under section 10.++  9. Acceptance Not Required for Having Copies.++  You are not required to accept this License in order to receive or+run a copy of the Program.  Ancillary propagation of a covered work+occurring solely as a consequence of using peer-to-peer transmission+to receive a copy likewise does not require acceptance.  However,+nothing other than this License grants you permission to propagate or+modify any covered work.  These actions infringe copyright if you do+not accept this License.  Therefore, by modifying or propagating a+covered work, you indicate your acceptance of this License to do so.++  10. Automatic Licensing of Downstream Recipients.++  Each time you convey a covered work, the recipient automatically+receives a license from the original licensors, to run, modify and+propagate that work, subject to this License.  You are not responsible+for enforcing compliance by third parties with this License.++  An "entity transaction" is a transaction transferring control of an+organization, or substantially all assets of one, or subdividing an+organization, or merging organizations.  If propagation of a covered+work results from an entity transaction, each party to that+transaction who receives a copy of the work also receives whatever+licenses to the work the party's predecessor in interest had or could+give under the previous paragraph, plus a right to possession of the+Corresponding Source of the work from the predecessor in interest, if+the predecessor has it or can get it with reasonable efforts.++  You may not impose any further restrictions on the exercise of the+rights granted or affirmed under this License.  For example, you may+not impose a license fee, royalty, or other charge for exercise of+rights granted under this License, and you may not initiate litigation+(including a cross-claim or counterclaim in a lawsuit) alleging that+any patent claim is infringed by making, using, selling, offering for+sale, or importing the Program or any portion of it.++  11. Patents.++  A "contributor" is a copyright holder who authorizes use under this+License of the Program or a work on which the Program is based.  The+work thus licensed is called the contributor's "contributor version".++  A contributor's "essential patent claims" are all patent claims+owned or controlled by the contributor, whether already acquired or+hereafter acquired, that would be infringed by some manner, permitted+by this License, of making, using, or selling its contributor version,+but do not include claims that would be infringed only as a+consequence of further modification of the contributor version.  For+purposes of this definition, "control" includes the right to grant+patent sublicenses in a manner consistent with the requirements of+this License.++  Each contributor grants you a non-exclusive, worldwide, royalty-free+patent license under the contributor's essential patent claims, to+make, use, sell, offer for sale, import and otherwise run, modify and+propagate the contents of its contributor version.++  In the following three paragraphs, a "patent license" is any express+agreement or commitment, however denominated, not to enforce a patent+(such as an express permission to practice a patent or covenant not to+sue for patent infringement).  To "grant" such a patent license to a+party means to make such an agreement or commitment not to enforce a+patent against the party.++  If you convey a covered work, knowingly relying on a patent license,+and the Corresponding Source of the work is not available for anyone+to copy, free of charge and under the terms of this License, through a+publicly available network server or other readily accessible means,+then you must either (1) cause the Corresponding Source to be so+available, or (2) arrange to deprive yourself of the benefit of the+patent license for this particular work, or (3) arrange, in a manner+consistent with the requirements of this License, to extend the patent+license to downstream recipients.  "Knowingly relying" means you have+actual knowledge that, but for the patent license, your conveying the+covered work in a country, or your recipient's use of the covered work+in a country, would infringe one or more identifiable patents in that+country that you have reason to believe are valid.++  If, pursuant to or in connection with a single transaction or+arrangement, you convey, or propagate by procuring conveyance of, a+covered work, and grant a patent license to some of the parties+receiving the covered work authorizing them to use, propagate, modify+or convey a specific copy of the covered work, then the patent license+you grant is automatically extended to all recipients of the covered+work and works based on it.++  A patent license is "discriminatory" if it does not include within+the scope of its coverage, prohibits the exercise of, or is+conditioned on the non-exercise of one or more of the rights that are+specifically granted under this License.  You may not convey a covered+work if you are a party to an arrangement with a third party that is+in the business of distributing software, under which you make payment+to the third party based on the extent of your activity of conveying+the work, and under which the third party grants, to any of the+parties who would receive the covered work from you, a discriminatory+patent license (a) in connection with copies of the covered work+conveyed by you (or copies made from those copies), or (b) primarily+for and in connection with specific products or compilations that+contain the covered work, unless you entered into that arrangement,+or that patent license was granted, prior to 28 March 2007.++  Nothing in this License shall be construed as excluding or limiting+any implied license or other defenses to infringement that may+otherwise be available to you under applicable patent law.++  12. No Surrender of Others' Freedom.++  If conditions are imposed on you (whether by court order, agreement or+otherwise) that contradict the conditions of this License, they do not+excuse you from the conditions of this License.  If you cannot convey a+covered work so as to satisfy simultaneously your obligations under this+License and any other pertinent obligations, then as a consequence you may+not convey it at all.  For example, if you agree to terms that obligate you+to collect a royalty for further conveying from those to whom you convey+the Program, the only way you could satisfy both those terms and this+License would be to refrain entirely from conveying the Program.++  13. Use with the GNU Affero General Public License.++  Notwithstanding any other provision of this License, you have+permission to link or combine any covered work with a work licensed+under version 3 of the GNU Affero General Public License into a single+combined work, and to convey the resulting work.  The terms of this+License will continue to apply to the part which is the covered work,+but the special requirements of the GNU Affero General Public License,+section 13, concerning interaction through a network will apply to the+combination as such.++  14. Revised Versions of this License.++  The Free Software Foundation may publish revised and/or new versions of+the GNU General Public License from time to time.  Such new versions will+be similar in spirit to the present version, but may differ in detail to+address new problems or concerns.++  Each version is given a distinguishing version number.  If the+Program specifies that a certain numbered version of the GNU General+Public License "or any later version" applies to it, you have the+option of following the terms and conditions either of that numbered+version or of any later version published by the Free Software+Foundation.  If the Program does not specify a version number of the+GNU General Public License, you may choose any version ever published+by the Free Software Foundation.++  If the Program specifies that a proxy can decide which future+versions of the GNU General Public License can be used, that proxy's+public statement of acceptance of a version permanently authorizes you+to choose that version for the Program.++  Later license versions may give you additional or different+permissions.  However, no additional obligations are imposed on any+author or copyright holder as a result of your choosing to follow a+later version.++  15. Disclaimer of Warranty.++  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY+APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM+IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.++  16. Limitation of Liability.++  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF+SUCH DAMAGES.++  17. Interpretation of Sections 15 and 16.++  If the disclaimer of warranty and limitation of liability provided+above cannot be given local legal effect according to their terms,+reviewing courts shall apply local law that most closely approximates+an absolute waiver of all civil liability in connection with the+Program, unless a warranty or assumption of liability accompanies a+copy of the Program in return for a fee.++                     END OF TERMS AND CONDITIONS++            How to Apply These Terms to Your New Programs++  If you develop a new program, and you want it to be of the greatest+possible use to the public, the best way to achieve this is to make it+free software which everyone can redistribute and change under these terms.++  To do so, attach the following notices to the program.  It is safest+to attach them to the start of each source file to most effectively+state the exclusion of warranty; and each file should have at least+the "copyright" line and a pointer to where the full notice is found.++    <one line to give the program's name and a brief idea of what it does.>+    Copyright (C) <year>  <name of author>++    This program is free software: you can redistribute it and/or modify+    it under the terms of the GNU General Public License as published by+    the Free Software Foundation, either version 3 of the License, or+    (at your option) any later version.++    This program is distributed in the hope that it will be useful,+    but WITHOUT ANY WARRANTY; without even the implied warranty of+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the+    GNU General Public License for more details.++    You should have received a copy of the GNU General Public License+    along with this program.  If not, see <http://www.gnu.org/licenses/>.++Also add information on how to contact you by electronic and paper mail.++  If the program does terminal interaction, make it output a short+notice like this when it starts in an interactive mode:++    <program>  Copyright (C) <year>  <name of author>+    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.+    This is free software, and you are welcome to redistribute it+    under certain conditions; type `show c' for details.++The hypothetical commands `show w' and `show c' should show the appropriate+parts of the General Public License.  Of course, your program's commands+might be different; for a GUI interface, you would use an "about box".++  You should also get your employer (if you work as a programmer) or school,+if any, to sign a "copyright disclaimer" for the program, if necessary.+For more information on this, and how to apply and follow the GNU GPL, see+<http://www.gnu.org/licenses/>.++  The GNU General Public License does not permit incorporating your program+into proprietary programs.  If your program is a subroutine library, you+may consider it more useful to permit linking proprietary applications with+the library.  If this is what you want to do, use the GNU Lesser General+Public License instead of this License.  But first, please read+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
+ doc/license/LGPL view
@@ -0,0 +1,502 @@+                  GNU LESSER GENERAL PUBLIC LICENSE+                       Version 2.1, February 1999++ Copyright (C) 1991, 1999 Free Software Foundation, Inc.+ 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA+ Everyone is permitted to copy and distribute verbatim copies+ of this license document, but changing it is not allowed.++[This is the first released version of the Lesser GPL.  It also counts+ as the successor of the GNU Library Public License, version 2, hence+ the version number 2.1.]++                            Preamble++  The licenses for most software are designed to take away your+freedom to share and change it.  By contrast, the GNU General Public+Licenses are intended to guarantee your freedom to share and change+free software--to make sure the software is free for all its users.++  This license, the Lesser General Public License, applies to some+specially designated software packages--typically libraries--of the+Free Software Foundation and other authors who decide to use it.  You+can use it too, but we suggest you first think carefully about whether+this license or the ordinary General Public License is the better+strategy to use in any particular case, based on the explanations below.++  When we speak of free software, we are referring to freedom of use,+not price.  Our General Public Licenses are designed to make sure that+you have the freedom to distribute copies of free software (and charge+for this service if you wish); that you receive source code or can get+it if you want it; that you can change the software and use pieces of+it in new free programs; and that you are informed that you can do+these things.++  To protect your rights, we need to make restrictions that forbid+distributors to deny you these rights or to ask you to surrender these+rights.  These restrictions translate to certain responsibilities for+you if you distribute copies of the library or if you modify it.++  For example, if you distribute copies of the library, whether gratis+or for a fee, you must give the recipients all the rights that we gave+you.  You must make sure that they, too, receive or can get the source+code.  If you link other code with the library, you must provide+complete object files to the recipients, so that they can relink them+with the library after making changes to the library and recompiling+it.  And you must show them these terms so they know their rights.++  We protect your rights with a two-step method: (1) we copyright the+library, and (2) we offer you this license, which gives you legal+permission to copy, distribute and/or modify the library.++  To protect each distributor, we want to make it very clear that+there is no warranty for the free library.  Also, if the library is+modified by someone else and passed on, the recipients should know+that what they have is not the original version, so that the original+author's reputation will not be affected by problems that might be+introduced by others.++  Finally, software patents pose a constant threat to the existence of+any free program.  We wish to make sure that a company cannot+effectively restrict the users of a free program by obtaining a+restrictive license from a patent holder.  Therefore, we insist that+any patent license obtained for a version of the library must be+consistent with the full freedom of use specified in this license.++  Most GNU software, including some libraries, is covered by the+ordinary GNU General Public License.  This license, the GNU Lesser+General Public License, applies to certain designated libraries, and+is quite different from the ordinary General Public License.  We use+this license for certain libraries in order to permit linking those+libraries into non-free programs.++  When a program is linked with a library, whether statically or using+a shared library, the combination of the two is legally speaking a+combined work, a derivative of the original library.  The ordinary+General Public License therefore permits such linking only if the+entire combination fits its criteria of freedom.  The Lesser General+Public License permits more lax criteria for linking other code with+the library.++  We call this license the "Lesser" General Public License because it+does Less to protect the user's freedom than the ordinary General+Public License.  It also provides other free software developers Less+of an advantage over competing non-free programs.  These disadvantages+are the reason we use the ordinary General Public License for many+libraries.  However, the Lesser license provides advantages in certain+special circumstances.++  For example, on rare occasions, there may be a special need to+encourage the widest possible use of a certain library, so that it becomes+a de-facto standard.  To achieve this, non-free programs must be+allowed to use the library.  A more frequent case is that a free+library does the same job as widely used non-free libraries.  In this+case, there is little to gain by limiting the free library to free+software only, so we use the Lesser General Public License.++  In other cases, permission to use a particular library in non-free+programs enables a greater number of people to use a large body of+free software.  For example, permission to use the GNU C Library in+non-free programs enables many more people to use the whole GNU+operating system, as well as its variant, the GNU/Linux operating+system.++  Although the Lesser General Public License is Less protective of the+users' freedom, it does ensure that the user of a program that is+linked with the Library has the freedom and the wherewithal to run+that program using a modified version of the Library.++  The precise terms and conditions for copying, distribution and+modification follow.  Pay close attention to the difference between a+"work based on the library" and a "work that uses the library".  The+former contains code derived from the library, whereas the latter must+be combined with the library in order to run.++                  GNU LESSER GENERAL PUBLIC LICENSE+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION++  0. This License Agreement applies to any software library or other+program which contains a notice placed by the copyright holder or+other authorized party saying it may be distributed under the terms of+this Lesser General Public License (also called "this License").+Each licensee is addressed as "you".++  A "library" means a collection of software functions and/or data+prepared so as to be conveniently linked with application programs+(which use some of those functions and data) to form executables.++  The "Library", below, refers to any such software library or work+which has been distributed under these terms.  A "work based on the+Library" means either the Library or any derivative work under+copyright law: that is to say, a work containing the Library or a+portion of it, either verbatim or with modifications and/or translated+straightforwardly into another language.  (Hereinafter, translation is+included without limitation in the term "modification".)++  "Source code" for a work means the preferred form of the work for+making modifications to it.  For a library, complete source code means+all the source code for all modules it contains, plus any associated+interface definition files, plus the scripts used to control compilation+and installation of the library.++  Activities other than copying, distribution and modification are not+covered by this License; they are outside its scope.  The act of+running a program using the Library is not restricted, and output from+such a program is covered only if its contents constitute a work based+on the Library (independent of the use of the Library in a tool for+writing it).  Whether that is true depends on what the Library does+and what the program that uses the Library does.++  1. You may copy and distribute verbatim copies of the Library's+complete source code as you receive it, in any medium, provided that+you conspicuously and appropriately publish on each copy an+appropriate copyright notice and disclaimer of warranty; keep intact+all the notices that refer to this License and to the absence of any+warranty; and distribute a copy of this License along with the+Library.++  You may charge a fee for the physical act of transferring a copy,+and you may at your option offer warranty protection in exchange for a+fee.++  2. You may modify your copy or copies of the Library or any portion+of it, thus forming a work based on the Library, and copy and+distribute such modifications or work under the terms of Section 1+above, provided that you also meet all of these conditions:++    a) The modified work must itself be a software library.++    b) You must cause the files modified to carry prominent notices+    stating that you changed the files and the date of any change.++    c) You must cause the whole of the work to be licensed at no+    charge to all third parties under the terms of this License.++    d) If a facility in the modified Library refers to a function or a+    table of data to be supplied by an application program that uses+    the facility, other than as an argument passed when the facility+    is invoked, then you must make a good faith effort to ensure that,+    in the event an application does not supply such function or+    table, the facility still operates, and performs whatever part of+    its purpose remains meaningful.++    (For example, a function in a library to compute square roots has+    a purpose that is entirely well-defined independent of the+    application.  Therefore, Subsection 2d requires that any+    application-supplied function or table used by this function must+    be optional: if the application does not supply it, the square+    root function must still compute square roots.)++These requirements apply to the modified work as a whole.  If+identifiable sections of that work are not derived from the Library,+and can be reasonably considered independent and separate works in+themselves, then this License, and its terms, do not apply to those+sections when you distribute them as separate works.  But when you+distribute the same sections as part of a whole which is a work based+on the Library, the distribution of the whole must be on the terms of+this License, whose permissions for other licensees extend to the+entire whole, and thus to each and every part regardless of who wrote+it.++Thus, it is not the intent of this section to claim rights or contest+your rights to work written entirely by you; rather, the intent is to+exercise the right to control the distribution of derivative or+collective works based on the Library.++In addition, mere aggregation of another work not based on the Library+with the Library (or with a work based on the Library) on a volume of+a storage or distribution medium does not bring the other work under+the scope of this License.++  3. You may opt to apply the terms of the ordinary GNU General Public+License instead of this License to a given copy of the Library.  To do+this, you must alter all the notices that refer to this License, so+that they refer to the ordinary GNU General Public License, version 2,+instead of to this License.  (If a newer version than version 2 of the+ordinary GNU General Public License has appeared, then you can specify+that version instead if you wish.)  Do not make any other change in+these notices.++  Once this change is made in a given copy, it is irreversible for+that copy, so the ordinary GNU General Public License applies to all+subsequent copies and derivative works made from that copy.++  This option is useful when you wish to copy part of the code of+the Library into a program that is not a library.++  4. You may copy and distribute the Library (or a portion or+derivative of it, under Section 2) in object code or executable form+under the terms of Sections 1 and 2 above provided that you accompany+it with the complete corresponding machine-readable source code, which+must be distributed under the terms of Sections 1 and 2 above on a+medium customarily used for software interchange.++  If distribution of object code is made by offering access to copy+from a designated place, then offering equivalent access to copy the+source code from the same place satisfies the requirement to+distribute the source code, even though third parties are not+compelled to copy the source along with the object code.++  5. A program that contains no derivative of any portion of the+Library, but is designed to work with the Library by being compiled or+linked with it, is called a "work that uses the Library".  Such a+work, in isolation, is not a derivative work of the Library, and+therefore falls outside the scope of this License.++  However, linking a "work that uses the Library" with the Library+creates an executable that is a derivative of the Library (because it+contains portions of the Library), rather than a "work that uses the+library".  The executable is therefore covered by this License.+Section 6 states terms for distribution of such executables.++  When a "work that uses the Library" uses material from a header file+that is part of the Library, the object code for the work may be a+derivative work of the Library even though the source code is not.+Whether this is true is especially significant if the work can be+linked without the Library, or if the work is itself a library.  The+threshold for this to be true is not precisely defined by law.++  If such an object file uses only numerical parameters, data+structure layouts and accessors, and small macros and small inline+functions (ten lines or less in length), then the use of the object+file is unrestricted, regardless of whether it is legally a derivative+work.  (Executables containing this object code plus portions of the+Library will still fall under Section 6.)++  Otherwise, if the work is a derivative of the Library, you may+distribute the object code for the work under the terms of Section 6.+Any executables containing that work also fall under Section 6,+whether or not they are linked directly with the Library itself.++  6. As an exception to the Sections above, you may also combine or+link a "work that uses the Library" with the Library to produce a+work containing portions of the Library, and distribute that work+under terms of your choice, provided that the terms permit+modification of the work for the customer's own use and reverse+engineering for debugging such modifications.++  You must give prominent notice with each copy of the work that the+Library is used in it and that the Library and its use are covered by+this License.  You must supply a copy of this License.  If the work+during execution displays copyright notices, you must include the+copyright notice for the Library among them, as well as a reference+directing the user to the copy of this License.  Also, you must do one+of these things:++    a) Accompany the work with the complete corresponding+    machine-readable source code for the Library including whatever+    changes were used in the work (which must be distributed under+    Sections 1 and 2 above); and, if the work is an executable linked+    with the Library, with the complete machine-readable "work that+    uses the Library", as object code and/or source code, so that the+    user can modify the Library and then relink to produce a modified+    executable containing the modified Library.  (It is understood+    that the user who changes the contents of definitions files in the+    Library will not necessarily be able to recompile the application+    to use the modified definitions.)++    b) Use a suitable shared library mechanism for linking with the+    Library.  A suitable mechanism is one that (1) uses at run time a+    copy of the library already present on the user's computer system,+    rather than copying library functions into the executable, and (2)+    will operate properly with a modified version of the library, if+    the user installs one, as long as the modified version is+    interface-compatible with the version that the work was made with.++    c) Accompany the work with a written offer, valid for at+    least three years, to give the same user the materials+    specified in Subsection 6a, above, for a charge no more+    than the cost of performing this distribution.++    d) If distribution of the work is made by offering access to copy+    from a designated place, offer equivalent access to copy the above+    specified materials from the same place.++    e) Verify that the user has already received a copy of these+    materials or that you have already sent this user a copy.++  For an executable, the required form of the "work that uses the+Library" must include any data and utility programs needed for+reproducing the executable from it.  However, as a special exception,+the materials to be distributed need not include anything that is+normally distributed (in either source or binary form) with the major+components (compiler, kernel, and so on) of the operating system on+which the executable runs, unless that component itself accompanies+the executable.++  It may happen that this requirement contradicts the license+restrictions of other proprietary libraries that do not normally+accompany the operating system.  Such a contradiction means you cannot+use both them and the Library together in an executable that you+distribute.++  7. You may place library facilities that are a work based on the+Library side-by-side in a single library together with other library+facilities not covered by this License, and distribute such a combined+library, provided that the separate distribution of the work based on+the Library and of the other library facilities is otherwise+permitted, and provided that you do these two things:++    a) Accompany the combined library with a copy of the same work+    based on the Library, uncombined with any other library+    facilities.  This must be distributed under the terms of the+    Sections above.++    b) Give prominent notice with the combined library of the fact+    that part of it is a work based on the Library, and explaining+    where to find the accompanying uncombined form of the same work.++  8. You may not copy, modify, sublicense, link with, or distribute+the Library except as expressly provided under this License.  Any+attempt otherwise to copy, modify, sublicense, link with, or+distribute the Library is void, and will automatically terminate your+rights under this License.  However, parties who have received copies,+or rights, from you under this License will not have their licenses+terminated so long as such parties remain in full compliance.++  9. You are not required to accept this License, since you have not+signed it.  However, nothing else grants you permission to modify or+distribute the Library or its derivative works.  These actions are+prohibited by law if you do not accept this License.  Therefore, by+modifying or distributing the Library (or any work based on the+Library), you indicate your acceptance of this License to do so, and+all its terms and conditions for copying, distributing or modifying+the Library or works based on it.++  10. Each time you redistribute the Library (or any work based on the+Library), the recipient automatically receives a license from the+original licensor to copy, distribute, link with or modify the Library+subject to these terms and conditions.  You may not impose any further+restrictions on the recipients' exercise of the rights granted herein.+You are not responsible for enforcing compliance by third parties with+this License.++  11. If, as a consequence of a court judgment or allegation of patent+infringement or for any other reason (not limited to patent issues),+conditions are imposed on you (whether by court order, agreement or+otherwise) that contradict the conditions of this License, they do not+excuse you from the conditions of this License.  If you cannot+distribute so as to satisfy simultaneously your obligations under this+License and any other pertinent obligations, then as a consequence you+may not distribute the Library at all.  For example, if a patent+license would not permit royalty-free redistribution of the Library by+all those who receive copies directly or indirectly through you, then+the only way you could satisfy both it and this License would be to+refrain entirely from distribution of the Library.++If any portion of this section is held invalid or unenforceable under any+particular circumstance, the balance of the section is intended to apply,+and the section as a whole is intended to apply in other circumstances.++It is not the purpose of this section to induce you to infringe any+patents or other property right claims or to contest validity of any+such claims; this section has the sole purpose of protecting the+integrity of the free software distribution system which is+implemented by public license practices.  Many people have made+generous contributions to the wide range of software distributed+through that system in reliance on consistent application of that+system; it is up to the author/donor to decide if he or she is willing+to distribute software through any other system and a licensee cannot+impose that choice.++This section is intended to make thoroughly clear what is believed to+be a consequence of the rest of this License.++  12. If the distribution and/or use of the Library is restricted in+certain countries either by patents or by copyrighted interfaces, the+original copyright holder who places the Library under this License may add+an explicit geographical distribution limitation excluding those countries,+so that distribution is permitted only in or among countries not thus+excluded.  In such case, this License incorporates the limitation as if+written in the body of this License.++  13. The Free Software Foundation may publish revised and/or new+versions of the Lesser General Public License from time to time.+Such new versions will be similar in spirit to the present version,+but may differ in detail to address new problems or concerns.++Each version is given a distinguishing version number.  If the Library+specifies a version number of this License which applies to it and+"any later version", you have the option of following the terms and+conditions either of that version or of any later version published by+the Free Software Foundation.  If the Library does not specify a+license version number, you may choose any version ever published by+the Free Software Foundation.++  14. If you wish to incorporate parts of the Library into other free+programs whose distribution conditions are incompatible with these,+write to the author to ask for permission.  For software which is+copyrighted by the Free Software Foundation, write to the Free+Software Foundation; we sometimes make exceptions for this.  Our+decision will be guided by the two goals of preserving the free status+of all derivatives of our free software and of promoting the sharing+and reuse of software generally.++                            NO WARRANTY++  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.++  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH+DAMAGES.++                     END OF TERMS AND CONDITIONS++           How to Apply These Terms to Your New Libraries++  If you develop a new library, and you want it to be of the greatest+possible use to the public, we recommend making it free software that+everyone can redistribute and change.  You can do so by permitting+redistribution under these terms (or, alternatively, under the terms of the+ordinary General Public License).++  To apply these terms, attach the following notices to the library.  It is+safest to attach them to the start of each source file to most effectively+convey the exclusion of warranty; and each file should have at least the+"copyright" line and a pointer to where the full notice is found.++    <one line to give the library's name and a brief idea of what it does.>+    Copyright (C) <year>  <name of author>++    This library is free software; you can redistribute it and/or+    modify it under the terms of the GNU Lesser General Public+    License as published by the Free Software Foundation; either+    version 2.1 of the License, or (at your option) any later version.++    This library is distributed in the hope that it will be useful,+    but WITHOUT ANY WARRANTY; without even the implied warranty of+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU+    Lesser General Public License for more details.++    You should have received a copy of the GNU Lesser General Public+    License along with this library; if not, write to the Free Software+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA++Also add information on how to contact you by electronic and paper mail.++You should also get your employer (if you work as a programmer) or your+school, if any, to sign a "copyright disclaimer" for the library, if+necessary.  Here is a sample; alter the names:++  Yoyodyne, Inc., hereby disclaims all copyright interest in the+  library `Frob' (a library for tweaking knobs) written by James Random Hacker.++  <signature of Ty Coon>, 1 April 1990+  Ty Coon, President of Vice++That's all there is to it!
+ doc/news/.version_3.20120924.mdwn.swp view

binary file changed (absent → 4096 bytes)

− doc/news/version_3.20120624.mdwn
@@ -1,9 +0,0 @@-git-annex 3.20120624 released with [[!toggle text="these changes"]]-[[!toggleable text="""-   * watch: New subcommand, a daemon which notices changes to-     files and automatically annexes new files, etc, so you don't-     need to manually run git commands when manipulating files.-     Available on Linux, BSDs, and OSX!-   * Enable diskfree on kfreebsd, using kqueue.-   * unused: Fix crash when key names contain invalid utf8.-   * sync: Avoid recent git's interactive merge."""]]
+ doc/news/version_3.20120924.mdwn view
@@ -0,0 +1,28 @@+git-annex 3.20120924 released with [[!toggle text="these changes"]]+[[!toggleable text="""+   * assistant: New command, a daemon which does everything watch does,+     as well as automatically syncing file contents between repositories.+   * webapp: An interface for managing and configuring the assistant.+   * The default backend used when adding files to the annex is changed+     from SHA256 to SHA256E, to simplify interoperability with OSX, media+     players, and various programs that needlessly look at symlink targets.+     To get old behavior, add a .gitattributes containing: * annex.backend=SHA256+   * init: If no description is provided for a new repository, one will+     automatically be generated, like "joey@gnu:~/foo"+   * test: Set a lot of git environment variables so testing works in strange+     environments that normally need git config to set names, etc.+     Closes: #[682351](http://bugs.debian.org/682351) Thanks, gregor herrmann+   * Disable ssh connection caching if the path to the control socket would be+     too long (and use relative path to minimise path to the control socket).+   * migrate: Check content before generating the new key, to avoid generating+     a key for corrupt data.+   * Support repositories created with --separate-git-dir. Closes: #[684405](http://bugs.debian.org/684405)+   * reinject: When the provided file doesn't match, leave it where it is,+     rather than moving to .git/annex/bad/+   * Avoid crashing on encoding errors in filenames when writing transfer info+     files and reading from checksum commands.+   * sync: Pushes the git-annex branch to remote/synced/git-annex, rather+     than directly to remote/git-annex.+   * Now supports matchig files that are present on a number of remotes+     with a specified trust level. Example: --copies=trusted:2+     Thanks, Nicolas Pouillard"""]]
+ doc/not/comment_2_0e19ff7deb5ed65f2bc685d4c516d816._comment view
@@ -0,0 +1,8 @@+[[!comment format=mdwn+ username="https://www.google.com/accounts/o8/id?id=AItOawkurjhi0CRJvgm7QNaZDWS9hitBtavqIpc"+ nickname="Bret"+ subject="Sparkleshare"+ date="2012-09-06T08:09:17Z"+ content="""+How does [sparkleshare](http://sparkleshare.org/) and git-annex (and git-annex assistant) compare? +"""]]
+ doc/not/comment_3_bab9584c41a25dda934ad230e3eb732d._comment view
@@ -0,0 +1,8 @@+[[!comment format=mdwn+ username="http://joeyh.name/"+ ip="4.152.108.236"+ subject="comment 3"+ date="2012-09-06T14:50:43Z"+ content="""+My understanding of sparkleshare (I've not used it) is that it uses a regular git repository, so has git's problems with large files and will not support partial checkouts. However, you might want to try it out and see if it works for you.+"""]]
+ doc/not/comment_4_b2a0d5a45ab8ddd66c29dde9412d7a12._comment view
@@ -0,0 +1,51 @@+[[!comment format=mdwn+ username="https://www.google.com/accounts/o8/id?id=AItOawn4bbuawnh-nSo9pAh8irYAcV4MQCcfdHo"+ nickname="Stefan"+ subject="Sparkleshare"+ date="2012-09-15T01:28:05Z"+ content="""+Hi,++I used sparkleshare lately in a project involving 3 computers and 2 people. and for ascii texts and even a few smaller binary things it works ok.++But it does \"to much\" for media. at least at the moment, it just uses git for saving the data. That has a possitive and a negative aspect.++possitive:++1. you have a full history, if you delete a file its not gone for ever, so if you change it, the older version is still recoverable.+2. if you would as example use it from a laptop in a train without internet and you use a git server in the internet for the central server, and would change some files, then you or somebody else would write on the same txt file as example (html or something... latex...) you would be able to merge this files.+3. its not totaly bad for backup, because you can restore old files even if you delete it localy, because it will hold all history+++negative:++1. for bigger data its cracy. if you use it for movies as example, you would in git annex delete some stuff you want not to see anytime again, so you would delete it everywhere. and its really away, not beeing still there in the history+2. git as it is has issues with saving/transfairing very big files, and its slow on even mid-sized files lets say 100 5mb big files it would be slow. because at the moment sparkleshare uses git all this disatvantages are there.+3. as many clients you use lets say a projekt with 10 people, each of them have all files and all the history of this projekt/directory on their pc.+4. you need a central data-store git folder you can use a seperate pc for that or save it on a client, if you use a client for that you have to save the data double on this pc.++(so you see for big files even if git would handle them faster you would waste massivly hard disk space) but again for pdfs a few pictures text files even some office files and stuff <100mb its great and easy to do.+++I try it in a few words, sparkleshare is like dropbox but with file history ( I think dropbox dont have that???) but because git is not designed (yet) for big files it works somewhat ok for < 100mb stuff if you go very much higher > 1GB it will not be optimal.++git annex dont saves the data itself in git but only the locations and the checksums. so its more like a adress book of your data. its a abstraction layer to your data, you can see on as many devises as you want even without no netzwerk internet connection active and only a very small hd see all your 5 Terrabyte of Data you might have, and move around directories sort around them... delete stuff you dont want if you can deside that by the name... and then  when you come back to the connection you sync your actions and it does it to the files.++And one big feature like joey said is that you cannot partialy load files from the repos to your device if it has as example only enough space for 1/10 of it.++There is another thing, but because it is \"only\" a abstraction layer, it is theoreticaly easy to implement extentions to save your data on anything not only git repositories...++Sparkleshare will switch to something else than git, maybe but then it will switch to this single protocol and stick to that. because it does not abstract stuff so hard.++btw there is a alternative out there it forces you not to use git as vcs but you have to use a vcs (like git) and you dont have to use the client written in mono but only a smaller python script:++http://www.mayrhofer.eu.org/dvcs-autosync++but the idea behind it is the same except this 2 points ;)+++but many free software developers dont like mono, so the change that it gets more love from more people is not totaly unlikely.+++So way to long post but hope that helps somebody ;)+"""]]
+ doc/not/comment_5_f2829ecbe80a61aa9a8411d2403de69e._comment view
@@ -0,0 +1,14 @@+[[!comment format=mdwn+ username="https://www.google.com/accounts/o8/id?id=AItOawn4bbuawnh-nSo9pAh8irYAcV4MQCcfdHo"+ nickname="Stefan"+ subject="comment 5"+ date="2012-09-15T01:35:06Z"+ content="""+or to make it more simple ;)++sparkleshare is for proejects and maybe backup your documents folder++annex is for managing big binary files that not get modified most of the time and only added/synced or deleted.++hope thats on the point, try to start using it also now, but am a bit blowen away what it all can do and what not... and how to get a good use case, and mixing media-management with backup of home and thinking on solving that all with annex without having it used ever ;)+"""]]
doc/summary.mdwn view
@@ -3,10 +3,7 @@ dealing with files larger than git can currently easily handle, whether due to limitations in memory, time, or disk space. -Even without file content tracking, being able to manage files with git,-move files around and delete files with versioned directory trees, and use-branches and distributed clones, are all very handy reasons to use git. And-annexed files can co-exist in the same git repository with regularly-versioned files, which is convenient for maintaining documents, Makefiles,-etc that are associated with annexed files but that benefit from full-revision control.+[[!img assistant/thumbnail.png link=assistant align=right]]+git-annex is designed for git users who love the command line.+For everyone else, the [[git-annex assistant|assistant]] turns+git-annex into an easy to use folder synchroniser.
+ doc/tips/emacs_integration.mdwn view
@@ -0,0 +1,7 @@+bergey has developed an emacs mode for browsing git-annex repositories,+dired style.++<https://gitorious.org/emacs-contrib/annex-mode>++Locally available files are colored differently, and pressing g runs+`git annex get` on the file at point.
+ doc/tips/finding_duplicate_files/comment_3._comment view
@@ -0,0 +1,39 @@+[[!comment format=mdwn+ username="mhameed"+ ip="82.32.202.53"+ subject="problems with spaces in filenames"+ date="Wed Sep  5 09:38:56 BST 2012"+ content="""++Spaces, and other special chars can make filename handeling ugly.+If you don't have a restriction on keeping the exact filenames, then +it might be easiest just to get rid of the problematic chars.++    #!/bin/bash++    function process() {+        dir="$1"+        echo "processing $dir"+        pushd $dir >/dev/null 2>&1++        for fileOrDir in *; do+            nfileOrDir=`echo "$fileOrDir" | sed -e 's/\[//g' -e 's/\]//g' -e 's/ /_/g' -e "s/'//g" `+            if [ "$fileOrDir" != "$nfileOrDir" ]; then+                echo renaming $fileOrDir to $nfileOrDir+                git mv "$fileOrDir" "$nfileOrDir"+            else+                echo "skipping $fileOrDir, no need to rename."+            fi+        done++        find ./ -mindepth 1 -maxdepth 1 -type d | while read d; do+        process "$d"+        done+        popd >/dev/null 2>&1+    }++    process .++Maybe you can run something like this before checking for duplicates.++"""]]
+ doc/todo/Slow_transfer_for_a_lot_of_small_files..mdwn view
@@ -0,0 +1,20 @@+What steps will reproduce the problem?+Sync a lot of small files.++What is the expected output? What do you see instead?+The expected output is hopefully a fast transfer.++But currently it seems like git-annex is only using one thread to transfer(per host or total?)++An option to select number of transfer threads to use(possibly per host) would be very nice.++> Opening a lot of connections to a single host is probably not desirable.+> +> I do want to do something to allow slow hosts to not hold up transfers to+> other hosts, which might involve running multiple queued transfers at+> once. The webapp already allows the user to force a given transfer to+> happen immediately. --[[Joey]] ++And maybe also an option to limit how long a queue the browser should show, it can become quite resource intensive with a long queue.++> The queue is limited to 20 items for this reason. --[[Joey]]
doc/todo/assistant_git_sync_laddering.mdwn view
@@ -5,4 +5,6 @@ This seems similar to the laddering problem described in this old bug: [[bugs/making_annex-merge_try_a_fast-forward]] ---[[Joey]] +--[[Joey]]++Think I've fixed this. [[done]] --[[Joey]]
doc/todo/assistant_threaded_runtime.mdwn view
@@ -28,6 +28,9 @@ > I've spent a lot of time debugging this, and trying to fix it, in the > "threaded" branch. There are still deadlocks. --[[Joey]] +>> Fixed, by switching from `System.Cmd.Utils` to `System.Process`+>> --[[Joey]] + ---  It would be possible to not use the threaded runtime. Instead, we could
+ doc/todo/incremental_fsck.mdwn view
@@ -0,0 +1,11 @@+Justin Azoff realized git-annex should have an incremental fsck.++This requires storing the last fsck time of each object.++I would not be strongly opposed to sqlite, but I think there are other+places the data could be stored. One possible place is the mode or mtime+of the .git/annex/objects/xx/yy/$key directories (the parent directories+of where the content is stored). Perhaps the sticky bit could be used to+indicate the content has been fsked, and the mtime indicate the time+of last fsck. Anything that dropped or put in content would need to+clear the sticky bit. --[[Joey]] 
+ doc/todo/special_remote_for_amazon_glacier.mdwn view
@@ -0,0 +1,25 @@+Amazon's new glacier service would be a nice special remote to support for+long-term archival.++The main difficulty is that glacier is organized into vaults, and accessing+a file in a vault takes ~4 hours. A naive implementation would make `git+annex get` wait for 4 hours, which is certianly not reasonable.++One approach I am pondering is to make each glacier vault a separate+special remote. You could then request git-annex to spin up a remote, and+come back later, and be able to access the data stored in it (need to check+if glacier would also allow adding new data to it then). This is+conceptually similar to using git-annex with offline removable drives,+except with glacier, you have a controllable robot to get them plugged in. :)++Ideally, git-annex would arrange for glacier to send it a message when the+vault becomes available, and the user could queue a list of commands to+run, or files to transfer, at that point.++--[[Joey]]++-----++> In the coming months, Amazon S3 will introduce an option that will allow customers to seamlessly move data between Amazon S3 and Amazon Glacier based on data lifecycle policies.++-- <http://aws.amazon.com/glacier/faqs/#How_should_I_choose_between_Amazon_Glacier_and_Amazon_S3>
+ doc/todo/windows_support/comment_5_444fc7251f57db241b6e80abae41851c._comment view
@@ -0,0 +1,10 @@+[[!comment format=mdwn+ username="https://me.yahoo.com/a/dASECLNzvckz4VwqUGYsvthiplY.#d2c27"+ nickname="A. D. Sicks"+ subject="comment 5"+ date="2012-09-09T23:48:21Z"+ content="""+Haskell has C++ binding, so it should be possible to port it to .net/Mono with a VB GUI for Windows users.  Windows has a primitive form of symlinks called shortcuts.  Perhaps shortcut support in Windows could replace the use of symlinks.  I've used shortcuts since XP to put my home Windows directory on another partition and never had a hitch...++If anyone is interested in working on this, hit me up.  I would like to use this in my XP vbox to have access to files on my host OS...I have a student edition of Visual Studio 2005 to do an open source port...+"""]]
git-annex-shell.1 view
@@ -38,6 +38,14 @@ .IP "sendkey directory key" This runs rsync in server mode to transfer out the content of a key. .IP+.IP "transferinfo directory key"+This is typically run at the same time as sendkey is sending a key+to the remote. Using it is optional, but is used to update+progress information for the transfer of the key.+.IP+It reads lines from standard input, each giving the number of bytes+that have been received so far. +.IP .IP "commit directory" This commits any staged changes to the git\-annex branch. It also runs the annex\-content hook.
git-annex.1 view
@@ -169,6 +169,14 @@ To not daemonize, run with \-\-foreground ; to stop a running daemon, run with \-\-stop .IP+.IP "assistant"+Like watch, but also automatically syncs changes to other remotes.+Typically started at boot, or when you log in.+.IP+.IP "webapp"+Runs a web app, that allows easy setup of a git\-annex repository,+and control of the git\-annex assistant.+.IP .SH REPOSITORY SETUP COMMANDS .IP "init [description]" .IP@@ -177,7 +185,8 @@ using it in a repository that was not intended to have an annex. .IP It's useful, but not mandatory, to initialize each new clone-of a repository with its own description.+of a repository with its own description. If you don't provide one,+one will be generated. .IP .IP "describe repository description" Changes the description of a repository.@@ -389,6 +398,9 @@ .IP  git annex dropkey SHA1\-s10\-7da006579dd64330eb2456001fd01948430572f2 .PP+.IP "transferkey key"+This plumbing\-level command is used by the assistant to transfer data.+.IP .IP "rekey [file key ...]" This plumbing\-level command is similar to migrate, but you specify both the file, and the new key to use for it.@@ -584,6 +596,13 @@ set to false. Then data will only be committed when running git annex merge (or by automatic merges) or git annex sync. .IP+.IP "annex.delayadd"+Makes the watch and assistant commands delay for the specified number of+seconds before adding a newly created file to the annex. Normally this+is not needed, because they already wait for all writers of the file+to close it. On Mac OSX, this defaults to 1 second, to work around+a bad interaction with software there.+.IP .IP "remote.<name>.annex\-cost" When determining which repository to transfer annexed files from or to, ones with lower costs are preferred.@@ -686,10 +705,10 @@ configured on a per\-file\-type basis via .gitattributes files. In the file, the annex.backend attribute can be set to the name of the backend to use. For example, this here's how to use the WORM backend by default,-but the SHA1 backend for ogg files:+but the SHA256E backend for ogg files: .PP  * annex.backend=WORM- *.ogg annex.backend=SHA1+ *.ogg annex.backend=SHA256E .PP The numcopies setting can also be configured on a per\-file\-type basis via the annex.numcopies attribute in .gitattributes files.@@ -698,10 +717,17 @@  *.wav annex.numcopies=2 .PP .SH FILES-These files are used by git\-annex, in your git repository:+These files are used by git\-annex: .PP-\&.git/annex/objects/ contains the annexed file contents that are currently-available. Annexed files in your git repository symlink to that content.+\&.git/annex/objects/ in your git repository contains the annexed file+contents that are currently available. Annexed files in your git+repository symlink to that content.+.PP+\&.git/annex/ in your git repository contains other run\-time information+used by git\-annex.+.PP+~/.config/git\-annex/autostart is a list of git repositories+to start the git\-annex assistant in. .PP .SH SEE ALSO Most of git\-annex's documentation is available on its web site, 
git-annex.cabal view
@@ -1,12 +1,12 @@ Name: git-annex-Version: 3.20120825+Version: 3.20120924 Cabal-Version: >= 1.8 License: GPL Maintainer: Joey Hess <joey@kitenet.net> Author: Joey Hess Stability: Stable Copyright: 2010-2012 Joey Hess-License-File: GPL+License-File: COPYRIGHT Homepage: http://git-annex.branchable.com/ Build-type: Custom Category: Utility@@ -31,20 +31,33 @@ Flag Inotify   Description: Enable inotify support +Flag Dbus+  Description: Enable dbus support+ Flag Assistant   Description: Enable git-annex assistant and watch command +Flag Webapp+  Description: Enable git-annex webapp++Flag Pairing+  Description: Enable pairing+ Executable git-annex   Main-Is: git-annex.hs   Build-Depends: MissingH, hslogger, directory, filepath,    unix, containers, utf8-string, network, mtl, bytestring, old-locale, time,    pcre-light, extensible-exceptions, dataenc, SHA, process, json, HTTP,    base == 4.5.*, monad-control, transformers-base, lifted-base,-   IfElse, text, QuickCheck >= 2.1, bloomfilter, edit-distance-  -- Need to list this because it's generated from a .hsc file.-  Other-Modules: Utility.Touch-  C-Sources: Utility/libdiskfree.c+   IfElse, text, QuickCheck >= 2.1, bloomfilter, edit-distance, process+  -- Need to list these because they're generated from .hsc files.+  Other-Modules: Utility.Touch Utility.Mounts+  Include-Dirs: Utility+  C-Sources: Utility/libdiskfree.c Utility/libmounts.c+  if (! os(linux))+    C-Sources: Utility/libkqueue.c   Extensions: CPP+  GHC-Options: -threaded    if flag(S3)     Build-Depends: hS3@@ -57,7 +70,28 @@   if os(linux) && flag(Inotify)     Build-Depends: hinotify     CPP-Options: -DWITH_INOTIFY+  else+    if (! os(windows))+      CPP-Options: -DWITH_KQUEUE +  if os(linux) && flag(Dbus)+    Build-Depends: dbus+    CPP-Options: -DWITH_DBUS++  if flag(Webapp) && flag(Assistant)+    Build-Depends: yesod, yesod-static, case-insensitive,+     http-types, transformers, wai, wai-logger, warp, blaze-builder,+     blaze-html, crypto-api, hamlet, clientsession,+     template-haskell, yesod-default (>= 1.1.0), data-default+    CPP-Options: -DWITH_WEBAPP++  if flag(Pairing) && flag(Webapp)+    Build-Depends: network-multicast, network-info+    CPP-Options: -DWITH_PAIRING++  if os(darwin)+    CPP-Options: -DOSX+ Test-Suite test   Type: exitcode-stdio-1.0   Main-Is: test.hs@@ -65,10 +99,12 @@    unix, containers, utf8-string, network, mtl, bytestring, old-locale, time,    pcre-light, extensible-exceptions, dataenc, SHA, process, json, HTTP,    base == 4.5.*, monad-control, transformers-base, lifted-base,-   IfElse, text, QuickCheck >= 2.1, bloomfilter, edit-distance+   IfElse, text, QuickCheck >= 2.1, bloomfilter, edit-distance, process   Other-Modules: Utility.Touch+  Include-Dirs: Utility   C-Sources: Utility/libdiskfree.c   Extensions: CPP+  GHC-Options: -threaded  source-repository head   type: git
− make-sdist.sh
@@ -1,21 +0,0 @@-#!/bin/sh-#-# Workaround for `cabal sdist` requiring all included files to be listed-# in .cabal.--# Create target directory-sdist_dir=git-annex-$(grep '^Version:' git-annex.cabal | sed -re 's/Version: *//')-mkdir --parents dist/$sdist_dir--find . \( -name .git -or -name dist -or -name cabal-dev \) -prune \-	-or -not -name \\*.orig -not -type d -print \-| perl -ne "print unless length >= 100 - length q{$sdist_dir}" \-| xargs cp --parents --target-directory dist/$sdist_dir--cd dist-tar -caf $sdist_dir.tar.gz $sdist_dir--# Check that tarball can be unpacked by cabal.-# It's picky about tar longlinks etc.-rm -rf $sdist_dir-cabal unpack $sdist_dir.tar.gz
− mdwn2man
@@ -1,43 +0,0 @@-#!/usr/bin/perl-# Warning: hack--my $prog=shift;-my $section=shift;--print ".TH $prog $section\n";--while (<>) {-	s{(\\?)\[\[([^\s\|\]]+)(\|[^\s\]]+)?\]\]}{$1 ? "[[$2]]" : $2}eg;-	s/\`//g;-	s/^\s*\./\\&./g;-	if (/^#\s/) {-		s/^#\s/.SH /;-		<>; # blank;-	}-	s/^[ \n]+//;-	s/^\t/ /;-	s/-/\\-/g;-	s/^Warning:.*//g;-	s/^$/.PP\n/;-	s/^\*\s+(.*)/.IP "$1"/;-	next if $_ eq ".PP\n" && $skippara;-	if (/^.IP /) {-		$inlist=1;-		$spippara=0;-	}-	elsif (/.SH/) {-		$skippara=0;-		$inlist=0;-	}-	elsif (/^\./) {-		$skippara=1;-	}-	else {-		$skippara=0;-	}-	if ($inlist && $_ eq ".PP\n") {-		$_=".IP\n";-	}--	print $_;-}
+ static/css/bootstrap-responsive.css view
@@ -0,0 +1,815 @@+/*!+ * Bootstrap Responsive v2.0.4+ *+ * Copyright 2012 Twitter, Inc+ * Licensed under the Apache License v2.0+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Designed and built with all the love in the world @twitter by @mdo and @fat.+ */++.clearfix {+  *zoom: 1;+}++.clearfix:before,+.clearfix:after {+  display: table;+  content: "";+}++.clearfix:after {+  clear: both;+}++.hide-text {+  font: 0/0 a;+  color: transparent;+  text-shadow: none;+  background-color: transparent;+  border: 0;+}++.input-block-level {+  display: block;+  width: 100%;+  min-height: 28px;+  -webkit-box-sizing: border-box;+     -moz-box-sizing: border-box;+      -ms-box-sizing: border-box;+          box-sizing: border-box;+}++.hidden {+  display: none;+  visibility: hidden;+}++.visible-phone {+  display: none !important;+}++.visible-tablet {+  display: none !important;+}++.hidden-desktop {+  display: none !important;+}++@media (max-width: 767px) {+  .visible-phone {+    display: inherit !important;+  }+  .hidden-phone {+    display: none !important;+  }+  .hidden-desktop {+    display: inherit !important;+  }+  .visible-desktop {+    display: none !important;+  }+}++@media (min-width: 768px) and (max-width: 979px) {+  .visible-tablet {+    display: inherit !important;+  }+  .hidden-tablet {+    display: none !important;+  }+  .hidden-desktop {+    display: inherit !important;+  }+  .visible-desktop {+    display: none !important ;+  }+}++@media (max-width: 480px) {+  .nav-collapse {+    -webkit-transform: translate3d(0, 0, 0);+  }+  .page-header h1 small {+    display: block;+    line-height: 18px;+  }+  input[type="checkbox"],+  input[type="radio"] {+    border: 1px solid #ccc;+  }+  .form-horizontal .control-group > label {+    float: none;+    width: auto;+    padding-top: 0;+    text-align: left;+  }+  .form-horizontal .controls {+    margin-left: 0;+  }+  .form-horizontal .control-list {+    padding-top: 0;+  }+  .form-horizontal .form-actions {+    padding-right: 10px;+    padding-left: 10px;+  }+  .modal {+    position: absolute;+    top: 10px;+    right: 10px;+    left: 10px;+    width: auto;+    margin: 0;+  }+  .modal.fade.in {+    top: auto;+  }+  .modal-header .close {+    padding: 10px;+    margin: -10px;+  }+  .carousel-caption {+    position: static;+  }+}++@media (max-width: 767px) {+  body {+    padding-right: 20px;+    padding-left: 20px;+  }+  .navbar-fixed-top,+  .navbar-fixed-bottom {+    margin-right: -20px;+    margin-left: -20px;+  }+  .container-fluid {+    padding: 0;+  }+  .dl-horizontal dt {+    float: none;+    width: auto;+    clear: none;+    text-align: left;+  }+  .dl-horizontal dd {+    margin-left: 0;+  }+  .container {+    width: auto;+  }+  .row-fluid {+    width: 100%;+  }+  .row,+  .thumbnails {+    margin-left: 0;+  }+  [class*="span"],+  .row-fluid [class*="span"] {+    display: block;+    float: none;+    width: auto;+    margin-left: 0;+  }+  .input-large,+  .input-xlarge,+  .input-xxlarge,+  input[class*="span"],+  select[class*="span"],+  textarea[class*="span"],+  .uneditable-input {+    display: block;+    width: 100%;+    min-height: 28px;+    -webkit-box-sizing: border-box;+       -moz-box-sizing: border-box;+        -ms-box-sizing: border-box;+            box-sizing: border-box;+  }+  .input-prepend input,+  .input-append input,+  .input-prepend input[class*="span"],+  .input-append input[class*="span"] {+    display: inline-block;+    width: auto;+  }+}++@media (min-width: 768px) and (max-width: 979px) {+  .row {+    margin-left: -20px;+    *zoom: 1;+  }+  .row:before,+  .row:after {+    display: table;+    content: "";+  }+  .row:after {+    clear: both;+  }+  [class*="span"] {+    float: left;+    margin-left: 20px;+  }+  .container,+  .navbar-fixed-top .container,+  .navbar-fixed-bottom .container {+    width: 724px;+  }+  .span12 {+    width: 724px;+  }+  .span11 {+    width: 662px;+  }+  .span10 {+    width: 600px;+  }+  .span9 {+    width: 538px;+  }+  .span8 {+    width: 476px;+  }+  .span7 {+    width: 414px;+  }+  .span6 {+    width: 352px;+  }+  .span5 {+    width: 290px;+  }+  .span4 {+    width: 228px;+  }+  .span3 {+    width: 166px;+  }+  .span2 {+    width: 104px;+  }+  .span1 {+    width: 42px;+  }+  .offset12 {+    margin-left: 764px;+  }+  .offset11 {+    margin-left: 702px;+  }+  .offset10 {+    margin-left: 640px;+  }+  .offset9 {+    margin-left: 578px;+  }+  .offset8 {+    margin-left: 516px;+  }+  .offset7 {+    margin-left: 454px;+  }+  .offset6 {+    margin-left: 392px;+  }+  .offset5 {+    margin-left: 330px;+  }+  .offset4 {+    margin-left: 268px;+  }+  .offset3 {+    margin-left: 206px;+  }+  .offset2 {+    margin-left: 144px;+  }+  .offset1 {+    margin-left: 82px;+  }+  .row-fluid {+    width: 100%;+    *zoom: 1;+  }+  .row-fluid:before,+  .row-fluid:after {+    display: table;+    content: "";+  }+  .row-fluid:after {+    clear: both;+  }+  .row-fluid [class*="span"] {+    display: block;+    float: left;+    width: 100%;+    min-height: 28px;+    margin-left: 2.762430939%;+    *margin-left: 2.709239449638298%;+    -webkit-box-sizing: border-box;+       -moz-box-sizing: border-box;+        -ms-box-sizing: border-box;+            box-sizing: border-box;+  }+  .row-fluid [class*="span"]:first-child {+    margin-left: 0;+  }+  .row-fluid .span12 {+    width: 99.999999993%;+    *width: 99.9468085036383%;+  }+  .row-fluid .span11 {+    width: 91.436464082%;+    *width: 91.38327259263829%;+  }+  .row-fluid .span10 {+    width: 82.87292817100001%;+    *width: 82.8197366816383%;+  }+  .row-fluid .span9 {+    width: 74.30939226%;+    *width: 74.25620077063829%;+  }+  .row-fluid .span8 {+    width: 65.74585634900001%;+    *width: 65.6926648596383%;+  }+  .row-fluid .span7 {+    width: 57.182320438000005%;+    *width: 57.129128948638304%;+  }+  .row-fluid .span6 {+    width: 48.618784527%;+    *width: 48.5655930376383%;+  }+  .row-fluid .span5 {+    width: 40.055248616%;+    *width: 40.0020571266383%;+  }+  .row-fluid .span4 {+    width: 31.491712705%;+    *width: 31.4385212156383%;+  }+  .row-fluid .span3 {+    width: 22.928176794%;+    *width: 22.874985304638297%;+  }+  .row-fluid .span2 {+    width: 14.364640883%;+    *width: 14.311449393638298%;+  }+  .row-fluid .span1 {+    width: 5.801104972%;+    *width: 5.747913482638298%;+  }+  input,+  textarea,+  .uneditable-input {+    margin-left: 0;+  }+  input.span12,+  textarea.span12,+  .uneditable-input.span12 {+    width: 714px;+  }+  input.span11,+  textarea.span11,+  .uneditable-input.span11 {+    width: 652px;+  }+  input.span10,+  textarea.span10,+  .uneditable-input.span10 {+    width: 590px;+  }+  input.span9,+  textarea.span9,+  .uneditable-input.span9 {+    width: 528px;+  }+  input.span8,+  textarea.span8,+  .uneditable-input.span8 {+    width: 466px;+  }+  input.span7,+  textarea.span7,+  .uneditable-input.span7 {+    width: 404px;+  }+  input.span6,+  textarea.span6,+  .uneditable-input.span6 {+    width: 342px;+  }+  input.span5,+  textarea.span5,+  .uneditable-input.span5 {+    width: 280px;+  }+  input.span4,+  textarea.span4,+  .uneditable-input.span4 {+    width: 218px;+  }+  input.span3,+  textarea.span3,+  .uneditable-input.span3 {+    width: 156px;+  }+  input.span2,+  textarea.span2,+  .uneditable-input.span2 {+    width: 94px;+  }+  input.span1,+  textarea.span1,+  .uneditable-input.span1 {+    width: 32px;+  }+}++@media (min-width: 1200px) {+  .row {+    margin-left: -30px;+    *zoom: 1;+  }+  .row:before,+  .row:after {+    display: table;+    content: "";+  }+  .row:after {+    clear: both;+  }+  [class*="span"] {+    float: left;+    margin-left: 30px;+  }+  .container,+  .navbar-fixed-top .container,+  .navbar-fixed-bottom .container {+    width: 1170px;+  }+  .span12 {+    width: 1170px;+  }+  .span11 {+    width: 1070px;+  }+  .span10 {+    width: 970px;+  }+  .span9 {+    width: 870px;+  }+  .span8 {+    width: 770px;+  }+  .span7 {+    width: 670px;+  }+  .span6 {+    width: 570px;+  }+  .span5 {+    width: 470px;+  }+  .span4 {+    width: 370px;+  }+  .span3 {+    width: 270px;+  }+  .span2 {+    width: 170px;+  }+  .span1 {+    width: 70px;+  }+  .offset12 {+    margin-left: 1230px;+  }+  .offset11 {+    margin-left: 1130px;+  }+  .offset10 {+    margin-left: 1030px;+  }+  .offset9 {+    margin-left: 930px;+  }+  .offset8 {+    margin-left: 830px;+  }+  .offset7 {+    margin-left: 730px;+  }+  .offset6 {+    margin-left: 630px;+  }+  .offset5 {+    margin-left: 530px;+  }+  .offset4 {+    margin-left: 430px;+  }+  .offset3 {+    margin-left: 330px;+  }+  .offset2 {+    margin-left: 230px;+  }+  .offset1 {+    margin-left: 130px;+  }+  .row-fluid {+    width: 100%;+    *zoom: 1;+  }+  .row-fluid:before,+  .row-fluid:after {+    display: table;+    content: "";+  }+  .row-fluid:after {+    clear: both;+  }+  .row-fluid [class*="span"] {+    display: block;+    float: left;+    width: 100%;+    min-height: 28px;+    margin-left: 2.564102564%;+    *margin-left: 2.510911074638298%;+    -webkit-box-sizing: border-box;+       -moz-box-sizing: border-box;+        -ms-box-sizing: border-box;+            box-sizing: border-box;+  }+  .row-fluid [class*="span"]:first-child {+    margin-left: 0;+  }+  .row-fluid .span12 {+    width: 100%;+    *width: 99.94680851063829%;+  }+  .row-fluid .span11 {+    width: 91.45299145300001%;+    *width: 91.3997999636383%;+  }+  .row-fluid .span10 {+    width: 82.905982906%;+    *width: 82.8527914166383%;+  }+  .row-fluid .span9 {+    width: 74.358974359%;+    *width: 74.30578286963829%;+  }+  .row-fluid .span8 {+    width: 65.81196581200001%;+    *width: 65.7587743226383%;+  }+  .row-fluid .span7 {+    width: 57.264957265%;+    *width: 57.2117657756383%;+  }+  .row-fluid .span6 {+    width: 48.717948718%;+    *width: 48.6647572286383%;+  }+  .row-fluid .span5 {+    width: 40.170940171000005%;+    *width: 40.117748681638304%;+  }+  .row-fluid .span4 {+    width: 31.623931624%;+    *width: 31.5707401346383%;+  }+  .row-fluid .span3 {+    width: 23.076923077%;+    *width: 23.0237315876383%;+  }+  .row-fluid .span2 {+    width: 14.529914530000001%;+    *width: 14.4767230406383%;+  }+  .row-fluid .span1 {+    width: 5.982905983%;+    *width: 5.929714493638298%;+  }+  input,+  textarea,+  .uneditable-input {+    margin-left: 0;+  }+  input.span12,+  textarea.span12,+  .uneditable-input.span12 {+    width: 1160px;+  }+  input.span11,+  textarea.span11,+  .uneditable-input.span11 {+    width: 1060px;+  }+  input.span10,+  textarea.span10,+  .uneditable-input.span10 {+    width: 960px;+  }+  input.span9,+  textarea.span9,+  .uneditable-input.span9 {+    width: 860px;+  }+  input.span8,+  textarea.span8,+  .uneditable-input.span8 {+    width: 760px;+  }+  input.span7,+  textarea.span7,+  .uneditable-input.span7 {+    width: 660px;+  }+  input.span6,+  textarea.span6,+  .uneditable-input.span6 {+    width: 560px;+  }+  input.span5,+  textarea.span5,+  .uneditable-input.span5 {+    width: 460px;+  }+  input.span4,+  textarea.span4,+  .uneditable-input.span4 {+    width: 360px;+  }+  input.span3,+  textarea.span3,+  .uneditable-input.span3 {+    width: 260px;+  }+  input.span2,+  textarea.span2,+  .uneditable-input.span2 {+    width: 160px;+  }+  input.span1,+  textarea.span1,+  .uneditable-input.span1 {+    width: 60px;+  }+  .thumbnails {+    margin-left: -30px;+  }+  .thumbnails > li {+    margin-left: 30px;+  }+  .row-fluid .thumbnails {+    margin-left: 0;+  }+}++@media (max-width: 979px) {+  body {+    padding-top: 0;+  }+  .navbar-fixed-top,+  .navbar-fixed-bottom {+    position: static;+  }+  .navbar-fixed-top {+    margin-bottom: 18px;+  }+  .navbar-fixed-bottom {+    margin-top: 18px;+  }+  .navbar-fixed-top .navbar-inner,+  .navbar-fixed-bottom .navbar-inner {+    padding: 5px;+  }+  .navbar .container {+    width: auto;+    padding: 0;+  }+  .navbar .brand {+    padding-right: 10px;+    padding-left: 10px;+    margin: 0 0 0 -5px;+  }+  .nav-collapse {+    clear: both;+  }+  .nav-collapse .nav {+    float: none;+    margin: 0 0 9px;+  }+  .nav-collapse .nav > li {+    float: none;+  }+  .nav-collapse .nav > li > a {+    margin-bottom: 2px;+  }+  .nav-collapse .nav > .divider-vertical {+    display: none;+  }+  .nav-collapse .nav .nav-header {+    color: #999999;+    text-shadow: none;+  }+  .nav-collapse .nav > li > a,+  .nav-collapse .dropdown-menu a {+    padding: 6px 15px;+    font-weight: bold;+    color: #999999;+    -webkit-border-radius: 3px;+       -moz-border-radius: 3px;+            border-radius: 3px;+  }+  .nav-collapse .btn {+    padding: 4px 10px 4px;+    font-weight: normal;+    -webkit-border-radius: 4px;+       -moz-border-radius: 4px;+            border-radius: 4px;+  }+  .nav-collapse .dropdown-menu li + li a {+    margin-bottom: 2px;+  }+  .nav-collapse .nav > li > a:hover,+  .nav-collapse .dropdown-menu a:hover {+    background-color: #222222;+  }+  .nav-collapse.in .btn-group {+    padding: 0;+    margin-top: 5px;+  }+  .nav-collapse .dropdown-menu {+    position: static;+    top: auto;+    left: auto;+    display: block;+    float: none;+    max-width: none;+    padding: 0;+    margin: 0 15px;+    background-color: transparent;+    border: none;+    -webkit-border-radius: 0;+       -moz-border-radius: 0;+            border-radius: 0;+    -webkit-box-shadow: none;+       -moz-box-shadow: none;+            box-shadow: none;+  }+  .nav-collapse .dropdown-menu:before,+  .nav-collapse .dropdown-menu:after {+    display: none;+  }+  .nav-collapse .dropdown-menu .divider {+    display: none;+  }+  .nav-collapse .navbar-form,+  .nav-collapse .navbar-search {+    float: none;+    padding: 9px 15px;+    margin: 9px 0;+    border-top: 1px solid #222222;+    border-bottom: 1px solid #222222;+    -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.1);+       -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.1);+            box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.1);+  }+  .navbar .nav-collapse .nav.pull-right {+    float: none;+    margin-left: 0;+  }+  .nav-collapse,+  .nav-collapse.collapse {+    height: 0;+    overflow: hidden;+  }+  .navbar .btn-navbar {+    display: block;+  }+  .navbar-static .navbar-inner {+    padding-right: 10px;+    padding-left: 10px;+  }+}++@media (min-width: 980px) {+  .nav-collapse.collapse {+    height: auto !important;+    overflow: visible !important;+  }+}
+ static/css/bootstrap.css view
@@ -0,0 +1,4983 @@+/*!+ * Bootstrap v2.0.4+ *+ * Copyright 2012 Twitter, Inc+ * Licensed under the Apache License v2.0+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Designed and built with all the love in the world @twitter by @mdo and @fat.+ */++article,+aside,+details,+figcaption,+figure,+footer,+header,+hgroup,+nav,+section {+  display: block;+}++audio,+canvas,+video {+  display: inline-block;+  *display: inline;+  *zoom: 1;+}++audio:not([controls]) {+  display: none;+}++html {+  font-size: 100%;+  -webkit-text-size-adjust: 100%;+      -ms-text-size-adjust: 100%;+}++a:focus {+  outline: thin dotted #333;+  outline: 5px auto -webkit-focus-ring-color;+  outline-offset: -2px;+}++a:hover,+a:active {+  outline: 0;+}++sub,+sup {+  position: relative;+  font-size: 75%;+  line-height: 0;+  vertical-align: baseline;+}++sup {+  top: -0.5em;+}++sub {+  bottom: -0.25em;+}++img {+  max-width: 100%;+  vertical-align: middle;+  border: 0;+  -ms-interpolation-mode: bicubic;+}++#map_canvas img {+  max-width: none;+}++button,+input,+select,+textarea {+  margin: 0;+  font-size: 100%;+  vertical-align: middle;+}++button,+input {+  *overflow: visible;+  line-height: normal;+}++button::-moz-focus-inner,+input::-moz-focus-inner {+  padding: 0;+  border: 0;+}++button,+input[type="button"],+input[type="reset"],+input[type="submit"] {+  cursor: pointer;+  -webkit-appearance: button;+}++input[type="search"] {+  -webkit-box-sizing: content-box;+     -moz-box-sizing: content-box;+          box-sizing: content-box;+  -webkit-appearance: textfield;+}++input[type="search"]::-webkit-search-decoration,+input[type="search"]::-webkit-search-cancel-button {+  -webkit-appearance: none;+}++textarea {+  overflow: auto;+  vertical-align: top;+}++.clearfix {+  *zoom: 1;+}++.clearfix:before,+.clearfix:after {+  display: table;+  content: "";+}++.clearfix:after {+  clear: both;+}++.hide-text {+  font: 0/0 a;+  color: transparent;+  text-shadow: none;+  background-color: transparent;+  border: 0;+}++.input-block-level {+  display: block;+  width: 100%;+  min-height: 28px;+  -webkit-box-sizing: border-box;+     -moz-box-sizing: border-box;+      -ms-box-sizing: border-box;+          box-sizing: border-box;+}++body {+  margin: 0;+  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;+  font-size: 13px;+  line-height: 18px;+  color: #333333;+  background-color: #ffffff;+}++a {+  color: #0088cc;+  text-decoration: none;+}++a:hover {+  color: #005580;+  text-decoration: underline;+}++.row {+  margin-left: -20px;+  *zoom: 1;+}++.row:before,+.row:after {+  display: table;+  content: "";+}++.row:after {+  clear: both;+}++[class*="span"] {+  float: left;+  margin-left: 20px;+}++.container,+.navbar-fixed-top .container,+.navbar-fixed-bottom .container {+  width: 940px;+}++.span12 {+  width: 940px;+}++.span11 {+  width: 860px;+}++.span10 {+  width: 780px;+}++.span9 {+  width: 700px;+}++.span8 {+  width: 620px;+}++.span7 {+  width: 540px;+}++.span6 {+  width: 460px;+}++.span5 {+  width: 380px;+}++.span4 {+  width: 300px;+}++.span3 {+  width: 220px;+}++.span2 {+  width: 140px;+}++.span1 {+  width: 60px;+}++.offset12 {+  margin-left: 980px;+}++.offset11 {+  margin-left: 900px;+}++.offset10 {+  margin-left: 820px;+}++.offset9 {+  margin-left: 740px;+}++.offset8 {+  margin-left: 660px;+}++.offset7 {+  margin-left: 580px;+}++.offset6 {+  margin-left: 500px;+}++.offset5 {+  margin-left: 420px;+}++.offset4 {+  margin-left: 340px;+}++.offset3 {+  margin-left: 260px;+}++.offset2 {+  margin-left: 180px;+}++.offset1 {+  margin-left: 100px;+}++.row-fluid {+  width: 100%;+  *zoom: 1;+}++.row-fluid:before,+.row-fluid:after {+  display: table;+  content: "";+}++.row-fluid:after {+  clear: both;+}++.row-fluid [class*="span"] {+  display: block;+  float: left;+  width: 100%;+  min-height: 28px;+  margin-left: 2.127659574%;+  *margin-left: 2.0744680846382977%;+  -webkit-box-sizing: border-box;+     -moz-box-sizing: border-box;+      -ms-box-sizing: border-box;+          box-sizing: border-box;+}++.row-fluid [class*="span"]:first-child {+  margin-left: 0;+}++.row-fluid .span12 {+  width: 99.99999998999999%;+  *width: 99.94680850063828%;+}++.row-fluid .span11 {+  width: 91.489361693%;+  *width: 91.4361702036383%;+}++.row-fluid .span10 {+  width: 82.97872339599999%;+  *width: 82.92553190663828%;+}++.row-fluid .span9 {+  width: 74.468085099%;+  *width: 74.4148936096383%;+}++.row-fluid .span8 {+  width: 65.95744680199999%;+  *width: 65.90425531263828%;+}++.row-fluid .span7 {+  width: 57.446808505%;+  *width: 57.3936170156383%;+}++.row-fluid .span6 {+  width: 48.93617020799999%;+  *width: 48.88297871863829%;+}++.row-fluid .span5 {+  width: 40.425531911%;+  *width: 40.3723404216383%;+}++.row-fluid .span4 {+  width: 31.914893614%;+  *width: 31.8617021246383%;+}++.row-fluid .span3 {+  width: 23.404255317%;+  *width: 23.3510638276383%;+}++.row-fluid .span2 {+  width: 14.89361702%;+  *width: 14.8404255306383%;+}++.row-fluid .span1 {+  width: 6.382978723%;+  *width: 6.329787233638298%;+}++.container {+  margin-right: auto;+  margin-left: auto;+  *zoom: 1;+}++.container:before,+.container:after {+  display: table;+  content: "";+}++.container:after {+  clear: both;+}++.container-fluid {+  padding-right: 20px;+  padding-left: 20px;+  *zoom: 1;+}++.container-fluid:before,+.container-fluid:after {+  display: table;+  content: "";+}++.container-fluid:after {+  clear: both;+}++p {+  margin: 0 0 9px;+}++p small {+  font-size: 11px;+  color: #999999;+}++.lead {+  margin-bottom: 18px;+  font-size: 20px;+  font-weight: 200;+  line-height: 27px;+}++h1,+h2,+h3,+h4,+h5,+h6 {+  margin: 0;+  font-family: inherit;+  font-weight: bold;+  color: inherit;+  text-rendering: optimizelegibility;+}++h1 small,+h2 small,+h3 small,+h4 small,+h5 small,+h6 small {+  font-weight: normal;+  color: #999999;+}++h1 {+  font-size: 30px;+  line-height: 36px;+}++h1 small {+  font-size: 18px;+}++h2 {+  font-size: 24px;+  line-height: 36px;+}++h2 small {+  font-size: 18px;+}++h3 {+  font-size: 18px;+  line-height: 27px;+}++h3 small {+  font-size: 14px;+}++h4,+h5,+h6 {+  line-height: 18px;+}++h4 {+  font-size: 14px;+}++h4 small {+  font-size: 12px;+}++h5 {+  font-size: 12px;+}++h6 {+  font-size: 11px;+  color: #999999;+  text-transform: uppercase;+}++.page-header {+  padding-bottom: 17px;+  margin: 18px 0;+  border-bottom: 1px solid #eeeeee;+}++.page-header h1 {+  line-height: 1;+}++ul,+ol {+  padding: 0;+  margin: 0 0 9px 25px;+}++ul ul,+ul ol,+ol ol,+ol ul {+  margin-bottom: 0;+}++ul {+  list-style: disc;+}++ol {+  list-style: decimal;+}++li {+  line-height: 18px;+}++ul.unstyled,+ol.unstyled {+  margin-left: 0;+  list-style: none;+}++dl {+  margin-bottom: 18px;+}++dt,+dd {+  line-height: 18px;+}++dt {+  font-weight: bold;+  line-height: 17px;+}++dd {+  margin-left: 9px;+}++.dl-horizontal dt {+  float: left;+  width: 120px;+  overflow: hidden;+  clear: left;+  text-align: right;+  text-overflow: ellipsis;+  white-space: nowrap;+}++.dl-horizontal dd {+  margin-left: 130px;+}++hr {+  margin: 18px 0;+  border: 0;+  border-top: 1px solid #eeeeee;+  border-bottom: 1px solid #ffffff;+}++strong {+  font-weight: bold;+}++em {+  font-style: italic;+}++.muted {+  color: #999999;+}++abbr[title] {+  cursor: help;+  border-bottom: 1px dotted #999999;+}++abbr.initialism {+  font-size: 90%;+  text-transform: uppercase;+}++blockquote {+  padding: 0 0 0 15px;+  margin: 0 0 18px;+  border-left: 5px solid #eeeeee;+}++blockquote p {+  margin-bottom: 0;+  font-size: 16px;+  font-weight: 300;+  line-height: 22.5px;+}++blockquote small {+  display: block;+  line-height: 18px;+  color: #999999;+}++blockquote small:before {+  content: '\2014 \00A0';+}++blockquote.pull-right {+  float: right;+  padding-right: 15px;+  padding-left: 0;+  border-right: 5px solid #eeeeee;+  border-left: 0;+}++blockquote.pull-right p,+blockquote.pull-right small {+  text-align: right;+}++q:before,+q:after,+blockquote:before,+blockquote:after {+  content: "";+}++address {+  display: block;+  margin-bottom: 18px;+  font-style: normal;+  line-height: 18px;+}++small {+  font-size: 100%;+}++cite {+  font-style: normal;+}++code,+pre {+  padding: 0 3px 2px;+  font-family: Menlo, Monaco, Consolas, "Courier New", monospace;+  font-size: 12px;+  color: #333333;+  -webkit-border-radius: 3px;+     -moz-border-radius: 3px;+          border-radius: 3px;+}++code {+  padding: 2px 4px;+  color: #d14;+  background-color: #f7f7f9;+  border: 1px solid #e1e1e8;+}++pre {+  display: block;+  padding: 8.5px;+  margin: 0 0 9px;+  font-size: 12.025px;+  line-height: 18px;+  word-break: break-all;+  word-wrap: break-word;+  white-space: pre;+  white-space: pre-wrap;+  background-color: #f5f5f5;+  border: 1px solid #ccc;+  border: 1px solid rgba(0, 0, 0, 0.15);+  -webkit-border-radius: 4px;+     -moz-border-radius: 4px;+          border-radius: 4px;+}++pre.prettyprint {+  margin-bottom: 18px;+}++pre code {+  padding: 0;+  color: inherit;+  background-color: transparent;+  border: 0;+}++.pre-scrollable {+  max-height: 340px;+  overflow-y: scroll;+}++form {+  margin: 0 0 18px;+}++fieldset {+  padding: 0;+  margin: 0;+  border: 0;+}++legend {+  display: block;+  width: 100%;+  padding: 0;+  margin-bottom: 27px;+  font-size: 19.5px;+  line-height: 36px;+  color: #333333;+  border: 0;+  border-bottom: 1px solid #e5e5e5;+}++legend small {+  font-size: 13.5px;+  color: #999999;+}++label,+input,+button,+select,+textarea {+  font-size: 13px;+  font-weight: normal;+  line-height: 18px;+}++input,+button,+select,+textarea {+  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;+}++label {+  display: block;+  margin-bottom: 5px;+}++select,+textarea,+input[type="text"],+input[type="password"],+input[type="datetime"],+input[type="datetime-local"],+input[type="date"],+input[type="month"],+input[type="time"],+input[type="week"],+input[type="number"],+input[type="email"],+input[type="url"],+input[type="search"],+input[type="tel"],+input[type="color"],+.uneditable-input {+  display: inline-block;+  height: 18px;+  padding: 4px;+  margin-bottom: 9px;+  font-size: 13px;+  line-height: 18px;+  color: #555555;+}++input,+textarea {+  width: 210px;+}++textarea {+  height: auto;+}++textarea,+input[type="text"],+input[type="password"],+input[type="datetime"],+input[type="datetime-local"],+input[type="date"],+input[type="month"],+input[type="time"],+input[type="week"],+input[type="number"],+input[type="email"],+input[type="url"],+input[type="search"],+input[type="tel"],+input[type="color"],+.uneditable-input {+  background-color: #ffffff;+  border: 1px solid #cccccc;+  -webkit-border-radius: 3px;+     -moz-border-radius: 3px;+          border-radius: 3px;+  -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);+     -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);+          box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);+  -webkit-transition: border linear 0.2s, box-shadow linear 0.2s;+     -moz-transition: border linear 0.2s, box-shadow linear 0.2s;+      -ms-transition: border linear 0.2s, box-shadow linear 0.2s;+       -o-transition: border linear 0.2s, box-shadow linear 0.2s;+          transition: border linear 0.2s, box-shadow linear 0.2s;+}++textarea:focus,+input[type="text"]:focus,+input[type="password"]:focus,+input[type="datetime"]:focus,+input[type="datetime-local"]:focus,+input[type="date"]:focus,+input[type="month"]:focus,+input[type="time"]:focus,+input[type="week"]:focus,+input[type="number"]:focus,+input[type="email"]:focus,+input[type="url"]:focus,+input[type="search"]:focus,+input[type="tel"]:focus,+input[type="color"]:focus,+.uneditable-input:focus {+  border-color: rgba(82, 168, 236, 0.8);+  outline: 0;+  outline: thin dotted \9;+  /* IE6-9 */++  -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);+     -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);+          box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);+}++input[type="radio"],+input[type="checkbox"] {+  margin: 3px 0;+  *margin-top: 0;+  /* IE7 */++  line-height: normal;+  cursor: pointer;+}++input[type="submit"],+input[type="reset"],+input[type="button"],+input[type="radio"],+input[type="checkbox"] {+  width: auto;+}++.uneditable-textarea {+  width: auto;+  height: auto;+}++select,+input[type="file"] {+  height: 28px;+  /* In IE7, the height of the select element cannot be changed by height, only font-size */++  *margin-top: 4px;+  /* For IE7, add top margin to align select with labels */++  line-height: 28px;+}++select {+  width: 220px;+  border: 1px solid #bbb;+}++select[multiple],+select[size] {+  height: auto;+}++select:focus,+input[type="file"]:focus,+input[type="radio"]:focus,+input[type="checkbox"]:focus {+  outline: thin dotted #333;+  outline: 5px auto -webkit-focus-ring-color;+  outline-offset: -2px;+}++.radio,+.checkbox {+  min-height: 18px;+  padding-left: 18px;+}++.radio input[type="radio"],+.checkbox input[type="checkbox"] {+  float: left;+  margin-left: -18px;+}++.controls > .radio:first-child,+.controls > .checkbox:first-child {+  padding-top: 5px;+}++.radio.inline,+.checkbox.inline {+  display: inline-block;+  padding-top: 5px;+  margin-bottom: 0;+  vertical-align: middle;+}++.radio.inline + .radio.inline,+.checkbox.inline + .checkbox.inline {+  margin-left: 10px;+}++.input-mini {+  width: 60px;+}++.input-small {+  width: 90px;+}++.input-medium {+  width: 150px;+}++.input-large {+  width: 210px;+}++.input-xlarge {+  width: 270px;+}++.input-xxlarge {+  width: 530px;+}++input[class*="span"],+select[class*="span"],+textarea[class*="span"],+.uneditable-input[class*="span"],+.row-fluid input[class*="span"],+.row-fluid select[class*="span"],+.row-fluid textarea[class*="span"],+.row-fluid .uneditable-input[class*="span"] {+  float: none;+  margin-left: 0;+}++.input-append input[class*="span"],+.input-append .uneditable-input[class*="span"],+.input-prepend input[class*="span"],+.input-prepend .uneditable-input[class*="span"],+.row-fluid .input-prepend [class*="span"],+.row-fluid .input-append [class*="span"] {+  display: inline-block;+}++input,+textarea,+.uneditable-input {+  margin-left: 0;+}++input.span12,+textarea.span12,+.uneditable-input.span12 {+  width: 930px;+}++input.span11,+textarea.span11,+.uneditable-input.span11 {+  width: 850px;+}++input.span10,+textarea.span10,+.uneditable-input.span10 {+  width: 770px;+}++input.span9,+textarea.span9,+.uneditable-input.span9 {+  width: 690px;+}++input.span8,+textarea.span8,+.uneditable-input.span8 {+  width: 610px;+}++input.span7,+textarea.span7,+.uneditable-input.span7 {+  width: 530px;+}++input.span6,+textarea.span6,+.uneditable-input.span6 {+  width: 450px;+}++input.span5,+textarea.span5,+.uneditable-input.span5 {+  width: 370px;+}++input.span4,+textarea.span4,+.uneditable-input.span4 {+  width: 290px;+}++input.span3,+textarea.span3,+.uneditable-input.span3 {+  width: 210px;+}++input.span2,+textarea.span2,+.uneditable-input.span2 {+  width: 130px;+}++input.span1,+textarea.span1,+.uneditable-input.span1 {+  width: 50px;+}++input[disabled],+select[disabled],+textarea[disabled],+input[readonly],+select[readonly],+textarea[readonly] {+  cursor: not-allowed;+  background-color: #eeeeee;+  border-color: #ddd;+}++input[type="radio"][disabled],+input[type="checkbox"][disabled],+input[type="radio"][readonly],+input[type="checkbox"][readonly] {+  background-color: transparent;+}++.control-group.warning > label,+.control-group.warning .help-block,+.control-group.warning .help-inline {+  color: #c09853;+}++.control-group.warning .checkbox,+.control-group.warning .radio,+.control-group.warning input,+.control-group.warning select,+.control-group.warning textarea {+  color: #c09853;+  border-color: #c09853;+}++.control-group.warning .checkbox:focus,+.control-group.warning .radio:focus,+.control-group.warning input:focus,+.control-group.warning select:focus,+.control-group.warning textarea:focus {+  border-color: #a47e3c;+  -webkit-box-shadow: 0 0 6px #dbc59e;+     -moz-box-shadow: 0 0 6px #dbc59e;+          box-shadow: 0 0 6px #dbc59e;+}++.control-group.warning .input-prepend .add-on,+.control-group.warning .input-append .add-on {+  color: #c09853;+  background-color: #fcf8e3;+  border-color: #c09853;+}++.control-group.error > label,+.control-group.error .help-block,+.control-group.error .help-inline {+  color: #b94a48;+}++.control-group.error .checkbox,+.control-group.error .radio,+.control-group.error input,+.control-group.error select,+.control-group.error textarea {+  color: #b94a48;+  border-color: #b94a48;+}++.control-group.error .checkbox:focus,+.control-group.error .radio:focus,+.control-group.error input:focus,+.control-group.error select:focus,+.control-group.error textarea:focus {+  border-color: #953b39;+  -webkit-box-shadow: 0 0 6px #d59392;+     -moz-box-shadow: 0 0 6px #d59392;+          box-shadow: 0 0 6px #d59392;+}++.control-group.error .input-prepend .add-on,+.control-group.error .input-append .add-on {+  color: #b94a48;+  background-color: #f2dede;+  border-color: #b94a48;+}++.control-group.success > label,+.control-group.success .help-block,+.control-group.success .help-inline {+  color: #468847;+}++.control-group.success .checkbox,+.control-group.success .radio,+.control-group.success input,+.control-group.success select,+.control-group.success textarea {+  color: #468847;+  border-color: #468847;+}++.control-group.success .checkbox:focus,+.control-group.success .radio:focus,+.control-group.success input:focus,+.control-group.success select:focus,+.control-group.success textarea:focus {+  border-color: #356635;+  -webkit-box-shadow: 0 0 6px #7aba7b;+     -moz-box-shadow: 0 0 6px #7aba7b;+          box-shadow: 0 0 6px #7aba7b;+}++.control-group.success .input-prepend .add-on,+.control-group.success .input-append .add-on {+  color: #468847;+  background-color: #dff0d8;+  border-color: #468847;+}++input:focus:required:invalid,+textarea:focus:required:invalid,+select:focus:required:invalid {+  color: #b94a48;+  border-color: #ee5f5b;+}++input:focus:required:invalid:focus,+textarea:focus:required:invalid:focus,+select:focus:required:invalid:focus {+  border-color: #e9322d;+  -webkit-box-shadow: 0 0 6px #f8b9b7;+     -moz-box-shadow: 0 0 6px #f8b9b7;+          box-shadow: 0 0 6px #f8b9b7;+}++.form-actions {+  padding: 17px 20px 18px;+  margin-top: 18px;+  margin-bottom: 18px;+  background-color: #f5f5f5;+  border-top: 1px solid #e5e5e5;+  *zoom: 1;+}++.form-actions:before,+.form-actions:after {+  display: table;+  content: "";+}++.form-actions:after {+  clear: both;+}++.uneditable-input {+  overflow: hidden;+  white-space: nowrap;+  cursor: not-allowed;+  background-color: #ffffff;+  border-color: #eee;+  -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.025);+     -moz-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.025);+          box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.025);+}++:-moz-placeholder {+  color: #999999;+}++:-ms-input-placeholder {+  color: #999999;+}++::-webkit-input-placeholder {+  color: #999999;+}++.help-block,+.help-inline {+  color: #555555;+}++.help-block {+  display: block;+  margin-bottom: 9px;+}++.help-inline {+  display: inline-block;+  *display: inline;+  padding-left: 5px;+  vertical-align: middle;+  *zoom: 1;+}++.input-prepend,+.input-append {+  margin-bottom: 5px;+}++.input-prepend input,+.input-append input,+.input-prepend select,+.input-append select,+.input-prepend .uneditable-input,+.input-append .uneditable-input {+  position: relative;+  margin-bottom: 0;+  *margin-left: 0;+  vertical-align: middle;+  -webkit-border-radius: 0 3px 3px 0;+     -moz-border-radius: 0 3px 3px 0;+          border-radius: 0 3px 3px 0;+}++.input-prepend input:focus,+.input-append input:focus,+.input-prepend select:focus,+.input-append select:focus,+.input-prepend .uneditable-input:focus,+.input-append .uneditable-input:focus {+  z-index: 2;+}++.input-prepend .uneditable-input,+.input-append .uneditable-input {+  border-left-color: #ccc;+}++.input-prepend .add-on,+.input-append .add-on {+  display: inline-block;+  width: auto;+  height: 18px;+  min-width: 16px;+  padding: 4px 5px;+  font-weight: normal;+  line-height: 18px;+  text-align: center;+  text-shadow: 0 1px 0 #ffffff;+  vertical-align: middle;+  background-color: #eeeeee;+  border: 1px solid #ccc;+}++.input-prepend .add-on,+.input-append .add-on,+.input-prepend .btn,+.input-append .btn {+  margin-left: -1px;+  -webkit-border-radius: 0;+     -moz-border-radius: 0;+          border-radius: 0;+}++.input-prepend .active,+.input-append .active {+  background-color: #a9dba9;+  border-color: #46a546;+}++.input-prepend .add-on,+.input-prepend .btn {+  margin-right: -1px;+}++.input-prepend .add-on:first-child,+.input-prepend .btn:first-child {+  -webkit-border-radius: 3px 0 0 3px;+     -moz-border-radius: 3px 0 0 3px;+          border-radius: 3px 0 0 3px;+}++.input-append input,+.input-append select,+.input-append .uneditable-input {+  -webkit-border-radius: 3px 0 0 3px;+     -moz-border-radius: 3px 0 0 3px;+          border-radius: 3px 0 0 3px;+}++.input-append .uneditable-input {+  border-right-color: #ccc;+  border-left-color: #eee;+}++.input-append .add-on:last-child,+.input-append .btn:last-child {+  -webkit-border-radius: 0 3px 3px 0;+     -moz-border-radius: 0 3px 3px 0;+          border-radius: 0 3px 3px 0;+}++.input-prepend.input-append input,+.input-prepend.input-append select,+.input-prepend.input-append .uneditable-input {+  -webkit-border-radius: 0;+     -moz-border-radius: 0;+          border-radius: 0;+}++.input-prepend.input-append .add-on:first-child,+.input-prepend.input-append .btn:first-child {+  margin-right: -1px;+  -webkit-border-radius: 3px 0 0 3px;+     -moz-border-radius: 3px 0 0 3px;+          border-radius: 3px 0 0 3px;+}++.input-prepend.input-append .add-on:last-child,+.input-prepend.input-append .btn:last-child {+  margin-left: -1px;+  -webkit-border-radius: 0 3px 3px 0;+     -moz-border-radius: 0 3px 3px 0;+          border-radius: 0 3px 3px 0;+}++.search-query {+  padding-right: 14px;+  padding-right: 4px \9;+  padding-left: 14px;+  padding-left: 4px \9;+  /* IE7-8 doesn't have border-radius, so don't indent the padding */++  margin-bottom: 0;+  -webkit-border-radius: 14px;+     -moz-border-radius: 14px;+          border-radius: 14px;+}++.form-search input,+.form-inline input,+.form-horizontal input,+.form-search textarea,+.form-inline textarea,+.form-horizontal textarea,+.form-search select,+.form-inline select,+.form-horizontal select,+.form-search .help-inline,+.form-inline .help-inline,+.form-horizontal .help-inline,+.form-search .uneditable-input,+.form-inline .uneditable-input,+.form-horizontal .uneditable-input,+.form-search .input-prepend,+.form-inline .input-prepend,+.form-horizontal .input-prepend,+.form-search .input-append,+.form-inline .input-append,+.form-horizontal .input-append {+  display: inline-block;+  *display: inline;+  margin-bottom: 0;+  *zoom: 1;+}++.form-search .hide,+.form-inline .hide,+.form-horizontal .hide {+  display: none;+}++.form-search label,+.form-inline label {+  display: inline-block;+}++.form-search .input-append,+.form-inline .input-append,+.form-search .input-prepend,+.form-inline .input-prepend {+  margin-bottom: 0;+}++.form-search .radio,+.form-search .checkbox,+.form-inline .radio,+.form-inline .checkbox {+  padding-left: 0;+  margin-bottom: 0;+  vertical-align: middle;+}++.form-search .radio input[type="radio"],+.form-search .checkbox input[type="checkbox"],+.form-inline .radio input[type="radio"],+.form-inline .checkbox input[type="checkbox"] {+  float: left;+  margin-right: 3px;+  margin-left: 0;+}++.control-group {+  margin-bottom: 9px;+}++legend + .control-group {+  margin-top: 18px;+  -webkit-margin-top-collapse: separate;+}++.form-horizontal .control-group {+  margin-bottom: 18px;+  *zoom: 1;+}++.form-horizontal .control-group:before,+.form-horizontal .control-group:after {+  display: table;+  content: "";+}++.form-horizontal .control-group:after {+  clear: both;+}++.form-horizontal .control-label {+  float: left;+  width: 140px;+  padding-top: 5px;+  text-align: right;+}++.form-horizontal .controls {+  *display: inline-block;+  *padding-left: 20px;+  margin-left: 160px;+  *margin-left: 0;+}++.form-horizontal .controls:first-child {+  *padding-left: 160px;+}++.form-horizontal .help-block {+  margin-top: 9px;+  margin-bottom: 0;+}++.form-horizontal .form-actions {+  padding-left: 160px;+}++table {+  max-width: 100%;+  background-color: transparent;+  border-collapse: collapse;+  border-spacing: 0;+}++.table {+  width: 100%;+  margin-bottom: 18px;+}++.table th,+.table td {+  padding: 8px;+  line-height: 18px;+  text-align: left;+  vertical-align: top;+  border-top: 1px solid #dddddd;+}++.table th {+  font-weight: bold;+}++.table thead th {+  vertical-align: bottom;+}++.table caption + thead tr:first-child th,+.table caption + thead tr:first-child td,+.table colgroup + thead tr:first-child th,+.table colgroup + thead tr:first-child td,+.table thead:first-child tr:first-child th,+.table thead:first-child tr:first-child td {+  border-top: 0;+}++.table tbody + tbody {+  border-top: 2px solid #dddddd;+}++.table-condensed th,+.table-condensed td {+  padding: 4px 5px;+}++.table-bordered {+  border: 1px solid #dddddd;+  border-collapse: separate;+  *border-collapse: collapsed;+  border-left: 0;+  -webkit-border-radius: 4px;+     -moz-border-radius: 4px;+          border-radius: 4px;+}++.table-bordered th,+.table-bordered td {+  border-left: 1px solid #dddddd;+}++.table-bordered caption + thead tr:first-child th,+.table-bordered caption + tbody tr:first-child th,+.table-bordered caption + tbody tr:first-child td,+.table-bordered colgroup + thead tr:first-child th,+.table-bordered colgroup + tbody tr:first-child th,+.table-bordered colgroup + tbody tr:first-child td,+.table-bordered thead:first-child tr:first-child th,+.table-bordered tbody:first-child tr:first-child th,+.table-bordered tbody:first-child tr:first-child td {+  border-top: 0;+}++.table-bordered thead:first-child tr:first-child th:first-child,+.table-bordered tbody:first-child tr:first-child td:first-child {+  -webkit-border-top-left-radius: 4px;+          border-top-left-radius: 4px;+  -moz-border-radius-topleft: 4px;+}++.table-bordered thead:first-child tr:first-child th:last-child,+.table-bordered tbody:first-child tr:first-child td:last-child {+  -webkit-border-top-right-radius: 4px;+          border-top-right-radius: 4px;+  -moz-border-radius-topright: 4px;+}++.table-bordered thead:last-child tr:last-child th:first-child,+.table-bordered tbody:last-child tr:last-child td:first-child {+  -webkit-border-radius: 0 0 0 4px;+     -moz-border-radius: 0 0 0 4px;+          border-radius: 0 0 0 4px;+  -webkit-border-bottom-left-radius: 4px;+          border-bottom-left-radius: 4px;+  -moz-border-radius-bottomleft: 4px;+}++.table-bordered thead:last-child tr:last-child th:last-child,+.table-bordered tbody:last-child tr:last-child td:last-child {+  -webkit-border-bottom-right-radius: 4px;+          border-bottom-right-radius: 4px;+  -moz-border-radius-bottomright: 4px;+}++.table-striped tbody tr:nth-child(odd) td,+.table-striped tbody tr:nth-child(odd) th {+  background-color: #f9f9f9;+}++.table tbody tr:hover td,+.table tbody tr:hover th {+  background-color: #f5f5f5;+}++table .span1 {+  float: none;+  width: 44px;+  margin-left: 0;+}++table .span2 {+  float: none;+  width: 124px;+  margin-left: 0;+}++table .span3 {+  float: none;+  width: 204px;+  margin-left: 0;+}++table .span4 {+  float: none;+  width: 284px;+  margin-left: 0;+}++table .span5 {+  float: none;+  width: 364px;+  margin-left: 0;+}++table .span6 {+  float: none;+  width: 444px;+  margin-left: 0;+}++table .span7 {+  float: none;+  width: 524px;+  margin-left: 0;+}++table .span8 {+  float: none;+  width: 604px;+  margin-left: 0;+}++table .span9 {+  float: none;+  width: 684px;+  margin-left: 0;+}++table .span10 {+  float: none;+  width: 764px;+  margin-left: 0;+}++table .span11 {+  float: none;+  width: 844px;+  margin-left: 0;+}++table .span12 {+  float: none;+  width: 924px;+  margin-left: 0;+}++table .span13 {+  float: none;+  width: 1004px;+  margin-left: 0;+}++table .span14 {+  float: none;+  width: 1084px;+  margin-left: 0;+}++table .span15 {+  float: none;+  width: 1164px;+  margin-left: 0;+}++table .span16 {+  float: none;+  width: 1244px;+  margin-left: 0;+}++table .span17 {+  float: none;+  width: 1324px;+  margin-left: 0;+}++table .span18 {+  float: none;+  width: 1404px;+  margin-left: 0;+}++table .span19 {+  float: none;+  width: 1484px;+  margin-left: 0;+}++table .span20 {+  float: none;+  width: 1564px;+  margin-left: 0;+}++table .span21 {+  float: none;+  width: 1644px;+  margin-left: 0;+}++table .span22 {+  float: none;+  width: 1724px;+  margin-left: 0;+}++table .span23 {+  float: none;+  width: 1804px;+  margin-left: 0;+}++table .span24 {+  float: none;+  width: 1884px;+  margin-left: 0;+}++[class^="icon-"],+[class*=" icon-"] {+  display: inline-block;+  width: 14px;+  height: 14px;+  *margin-right: .3em;+  line-height: 14px;+  vertical-align: text-top;+  background-image: url("../img/glyphicons-halflings.png");+  background-position: 14px 14px;+  background-repeat: no-repeat;+}++[class^="icon-"]:last-child,+[class*=" icon-"]:last-child {+  *margin-left: 0;+}++.icon-white {+  background-image: url("../img/glyphicons-halflings-white.png");+}++.icon-glass {+  background-position: 0      0;+}++.icon-music {+  background-position: -24px 0;+}++.icon-search {+  background-position: -48px 0;+}++.icon-envelope {+  background-position: -72px 0;+}++.icon-heart {+  background-position: -96px 0;+}++.icon-star {+  background-position: -120px 0;+}++.icon-star-empty {+  background-position: -144px 0;+}++.icon-user {+  background-position: -168px 0;+}++.icon-film {+  background-position: -192px 0;+}++.icon-th-large {+  background-position: -216px 0;+}++.icon-th {+  background-position: -240px 0;+}++.icon-th-list {+  background-position: -264px 0;+}++.icon-ok {+  background-position: -288px 0;+}++.icon-remove {+  background-position: -312px 0;+}++.icon-zoom-in {+  background-position: -336px 0;+}++.icon-zoom-out {+  background-position: -360px 0;+}++.icon-off {+  background-position: -384px 0;+}++.icon-signal {+  background-position: -408px 0;+}++.icon-cog {+  background-position: -432px 0;+}++.icon-trash {+  background-position: -456px 0;+}++.icon-home {+  background-position: 0 -24px;+}++.icon-file {+  background-position: -24px -24px;+}++.icon-time {+  background-position: -48px -24px;+}++.icon-road {+  background-position: -72px -24px;+}++.icon-download-alt {+  background-position: -96px -24px;+}++.icon-download {+  background-position: -120px -24px;+}++.icon-upload {+  background-position: -144px -24px;+}++.icon-inbox {+  background-position: -168px -24px;+}++.icon-play-circle {+  background-position: -192px -24px;+}++.icon-repeat {+  background-position: -216px -24px;+}++.icon-refresh {+  background-position: -240px -24px;+}++.icon-list-alt {+  background-position: -264px -24px;+}++.icon-lock {+  background-position: -287px -24px;+}++.icon-flag {+  background-position: -312px -24px;+}++.icon-headphones {+  background-position: -336px -24px;+}++.icon-volume-off {+  background-position: -360px -24px;+}++.icon-volume-down {+  background-position: -384px -24px;+}++.icon-volume-up {+  background-position: -408px -24px;+}++.icon-qrcode {+  background-position: -432px -24px;+}++.icon-barcode {+  background-position: -456px -24px;+}++.icon-tag {+  background-position: 0 -48px;+}++.icon-tags {+  background-position: -25px -48px;+}++.icon-book {+  background-position: -48px -48px;+}++.icon-bookmark {+  background-position: -72px -48px;+}++.icon-print {+  background-position: -96px -48px;+}++.icon-camera {+  background-position: -120px -48px;+}++.icon-font {+  background-position: -144px -48px;+}++.icon-bold {+  background-position: -167px -48px;+}++.icon-italic {+  background-position: -192px -48px;+}++.icon-text-height {+  background-position: -216px -48px;+}++.icon-text-width {+  background-position: -240px -48px;+}++.icon-align-left {+  background-position: -264px -48px;+}++.icon-align-center {+  background-position: -288px -48px;+}++.icon-align-right {+  background-position: -312px -48px;+}++.icon-align-justify {+  background-position: -336px -48px;+}++.icon-list {+  background-position: -360px -48px;+}++.icon-indent-left {+  background-position: -384px -48px;+}++.icon-indent-right {+  background-position: -408px -48px;+}++.icon-facetime-video {+  background-position: -432px -48px;+}++.icon-picture {+  background-position: -456px -48px;+}++.icon-pencil {+  background-position: 0 -72px;+}++.icon-map-marker {+  background-position: -24px -72px;+}++.icon-adjust {+  background-position: -48px -72px;+}++.icon-tint {+  background-position: -72px -72px;+}++.icon-edit {+  background-position: -96px -72px;+}++.icon-share {+  background-position: -120px -72px;+}++.icon-check {+  background-position: -144px -72px;+}++.icon-move {+  background-position: -168px -72px;+}++.icon-step-backward {+  background-position: -192px -72px;+}++.icon-fast-backward {+  background-position: -216px -72px;+}++.icon-backward {+  background-position: -240px -72px;+}++.icon-play {+  background-position: -264px -72px;+}++.icon-pause {+  background-position: -288px -72px;+}++.icon-stop {+  background-position: -312px -72px;+}++.icon-forward {+  background-position: -336px -72px;+}++.icon-fast-forward {+  background-position: -360px -72px;+}++.icon-step-forward {+  background-position: -384px -72px;+}++.icon-eject {+  background-position: -408px -72px;+}++.icon-chevron-left {+  background-position: -432px -72px;+}++.icon-chevron-right {+  background-position: -456px -72px;+}++.icon-plus-sign {+  background-position: 0 -96px;+}++.icon-minus-sign {+  background-position: -24px -96px;+}++.icon-remove-sign {+  background-position: -48px -96px;+}++.icon-ok-sign {+  background-position: -72px -96px;+}++.icon-question-sign {+  background-position: -96px -96px;+}++.icon-info-sign {+  background-position: -120px -96px;+}++.icon-screenshot {+  background-position: -144px -96px;+}++.icon-remove-circle {+  background-position: -168px -96px;+}++.icon-ok-circle {+  background-position: -192px -96px;+}++.icon-ban-circle {+  background-position: -216px -96px;+}++.icon-arrow-left {+  background-position: -240px -96px;+}++.icon-arrow-right {+  background-position: -264px -96px;+}++.icon-arrow-up {+  background-position: -289px -96px;+}++.icon-arrow-down {+  background-position: -312px -96px;+}++.icon-share-alt {+  background-position: -336px -96px;+}++.icon-resize-full {+  background-position: -360px -96px;+}++.icon-resize-small {+  background-position: -384px -96px;+}++.icon-plus {+  background-position: -408px -96px;+}++.icon-minus {+  background-position: -433px -96px;+}++.icon-asterisk {+  background-position: -456px -96px;+}++.icon-exclamation-sign {+  background-position: 0 -120px;+}++.icon-gift {+  background-position: -24px -120px;+}++.icon-leaf {+  background-position: -48px -120px;+}++.icon-fire {+  background-position: -72px -120px;+}++.icon-eye-open {+  background-position: -96px -120px;+}++.icon-eye-close {+  background-position: -120px -120px;+}++.icon-warning-sign {+  background-position: -144px -120px;+}++.icon-plane {+  background-position: -168px -120px;+}++.icon-calendar {+  background-position: -192px -120px;+}++.icon-random {+  background-position: -216px -120px;+}++.icon-comment {+  background-position: -240px -120px;+}++.icon-magnet {+  background-position: -264px -120px;+}++.icon-chevron-up {+  background-position: -288px -120px;+}++.icon-chevron-down {+  background-position: -313px -119px;+}++.icon-retweet {+  background-position: -336px -120px;+}++.icon-shopping-cart {+  background-position: -360px -120px;+}++.icon-folder-close {+  background-position: -384px -120px;+}++.icon-folder-open {+  background-position: -408px -120px;+}++.icon-resize-vertical {+  background-position: -432px -119px;+}++.icon-resize-horizontal {+  background-position: -456px -118px;+}++.icon-hdd {+  background-position: 0 -144px;+}++.icon-bullhorn {+  background-position: -24px -144px;+}++.icon-bell {+  background-position: -48px -144px;+}++.icon-certificate {+  background-position: -72px -144px;+}++.icon-thumbs-up {+  background-position: -96px -144px;+}++.icon-thumbs-down {+  background-position: -120px -144px;+}++.icon-hand-right {+  background-position: -144px -144px;+}++.icon-hand-left {+  background-position: -168px -144px;+}++.icon-hand-up {+  background-position: -192px -144px;+}++.icon-hand-down {+  background-position: -216px -144px;+}++.icon-circle-arrow-right {+  background-position: -240px -144px;+}++.icon-circle-arrow-left {+  background-position: -264px -144px;+}++.icon-circle-arrow-up {+  background-position: -288px -144px;+}++.icon-circle-arrow-down {+  background-position: -312px -144px;+}++.icon-globe {+  background-position: -336px -144px;+}++.icon-wrench {+  background-position: -360px -144px;+}++.icon-tasks {+  background-position: -384px -144px;+}++.icon-filter {+  background-position: -408px -144px;+}++.icon-briefcase {+  background-position: -432px -144px;+}++.icon-fullscreen {+  background-position: -456px -144px;+}++.dropup,+.dropdown {+  position: relative;+}++.dropdown-toggle {+  *margin-bottom: -3px;+}++.dropdown-toggle:active,+.open .dropdown-toggle {+  outline: 0;+}++.caret {+  display: inline-block;+  width: 0;+  height: 0;+  vertical-align: top;+  border-top: 4px solid #000000;+  border-right: 4px solid transparent;+  border-left: 4px solid transparent;+  content: "";+  opacity: 0.3;+  filter: alpha(opacity=30);+}++.dropdown .caret {+  margin-top: 8px;+  margin-left: 2px;+}++.dropdown:hover .caret,+.open .caret {+  opacity: 1;+  filter: alpha(opacity=100);+}++.dropdown-menu {+  position: absolute;+  top: 100%;+  left: 0;+  z-index: 1000;+  display: none;+  float: left;+  min-width: 160px;+  padding: 4px 0;+  margin: 1px 0 0;+  list-style: none;+  background-color: #ffffff;+  border: 1px solid #ccc;+  border: 1px solid rgba(0, 0, 0, 0.2);+  *border-right-width: 2px;+  *border-bottom-width: 2px;+  -webkit-border-radius: 5px;+     -moz-border-radius: 5px;+          border-radius: 5px;+  -webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);+     -moz-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);+          box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);+  -webkit-background-clip: padding-box;+     -moz-background-clip: padding;+          background-clip: padding-box;+}++.dropdown-menu.pull-right {+  right: 0;+  left: auto;+}++.dropdown-menu .divider {+  *width: 100%;+  height: 1px;+  margin: 8px 1px;+  *margin: -5px 0 5px;+  overflow: hidden;+  background-color: #e5e5e5;+  border-bottom: 1px solid #ffffff;+}++.dropdown-menu a {+  display: block;+  padding: 3px 15px;+  clear: both;+  font-weight: normal;+  line-height: 18px;+  color: #333333;+  white-space: nowrap;+}++.dropdown-menu li > a:hover,+.dropdown-menu .active > a,+.dropdown-menu .active > a:hover {+  color: #ffffff;+  text-decoration: none;+  background-color: #0088cc;+}++.open {+  *z-index: 1000;+}++.open > .dropdown-menu {+  display: block;+}++.pull-right > .dropdown-menu {+  right: 0;+  left: auto;+}++.dropup .caret,+.navbar-fixed-bottom .dropdown .caret {+  border-top: 0;+  border-bottom: 4px solid #000000;+  content: "\2191";+}++.dropup .dropdown-menu,+.navbar-fixed-bottom .dropdown .dropdown-menu {+  top: auto;+  bottom: 100%;+  margin-bottom: 1px;+}++.typeahead {+  margin-top: 2px;+  -webkit-border-radius: 4px;+     -moz-border-radius: 4px;+          border-radius: 4px;+}++.well {+  min-height: 20px;+  padding: 19px;+  margin-bottom: 20px;+  background-color: #f5f5f5;+  border: 1px solid #eee;+  border: 1px solid rgba(0, 0, 0, 0.05);+  -webkit-border-radius: 4px;+     -moz-border-radius: 4px;+          border-radius: 4px;+  -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);+     -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);+          box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);+}++.well blockquote {+  border-color: #ddd;+  border-color: rgba(0, 0, 0, 0.15);+}++.well-large {+  padding: 24px;+  -webkit-border-radius: 6px;+     -moz-border-radius: 6px;+          border-radius: 6px;+}++.well-small {+  padding: 9px;+  -webkit-border-radius: 3px;+     -moz-border-radius: 3px;+          border-radius: 3px;+}++.fade {+  opacity: 0;+  -webkit-transition: opacity 0.15s linear;+     -moz-transition: opacity 0.15s linear;+      -ms-transition: opacity 0.15s linear;+       -o-transition: opacity 0.15s linear;+          transition: opacity 0.15s linear;+}++.fade.in {+  opacity: 1;+}++.collapse {+  position: relative;+  height: 0;+  overflow: hidden;+  -webkit-transition: height 0.35s ease;+     -moz-transition: height 0.35s ease;+      -ms-transition: height 0.35s ease;+       -o-transition: height 0.35s ease;+          transition: height 0.35s ease;+}++.collapse.in {+  height: auto;+}++.close {+  float: right;+  font-size: 20px;+  font-weight: bold;+  line-height: 18px;+  color: #000000;+  text-shadow: 0 1px 0 #ffffff;+  opacity: 0.2;+  filter: alpha(opacity=20);+}++.close:hover {+  color: #000000;+  text-decoration: none;+  cursor: pointer;+  opacity: 0.4;+  filter: alpha(opacity=40);+}++button.close {+  padding: 0;+  cursor: pointer;+  background: transparent;+  border: 0;+  -webkit-appearance: none;+}++.btn {+  display: inline-block;+  *display: inline;+  padding: 4px 10px 4px;+  margin-bottom: 0;+  *margin-left: .3em;+  font-size: 13px;+  line-height: 18px;+  *line-height: 20px;+  color: #333333;+  text-align: center;+  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);+  vertical-align: middle;+  cursor: pointer;+  background-color: #f5f5f5;+  *background-color: #e6e6e6;+  background-image: -ms-linear-gradient(top, #ffffff, #e6e6e6);+  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6));+  background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6);+  background-image: -o-linear-gradient(top, #ffffff, #e6e6e6);+  background-image: linear-gradient(top, #ffffff, #e6e6e6);+  background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6);+  background-repeat: repeat-x;+  border: 1px solid #cccccc;+  *border: 0;+  border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);+  border-color: #e6e6e6 #e6e6e6 #bfbfbf;+  border-bottom-color: #b3b3b3;+  -webkit-border-radius: 4px;+     -moz-border-radius: 4px;+          border-radius: 4px;+  filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ffffff', endColorstr='#e6e6e6', GradientType=0);+  filter: progid:dximagetransform.microsoft.gradient(enabled=false);+  *zoom: 1;+  -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);+     -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);+          box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);+}++.btn:hover,+.btn:active,+.btn.active,+.btn.disabled,+.btn[disabled] {+  background-color: #e6e6e6;+  *background-color: #d9d9d9;+}++.btn:active,+.btn.active {+  background-color: #cccccc \9;+}++.btn:first-child {+  *margin-left: 0;+}++.btn:hover {+  color: #333333;+  text-decoration: none;+  background-color: #e6e6e6;+  *background-color: #d9d9d9;+  /* Buttons in IE7 don't get borders, so darken on hover */++  background-position: 0 -15px;+  -webkit-transition: background-position 0.1s linear;+     -moz-transition: background-position 0.1s linear;+      -ms-transition: background-position 0.1s linear;+       -o-transition: background-position 0.1s linear;+          transition: background-position 0.1s linear;+}++.btn:focus {+  outline: thin dotted #333;+  outline: 5px auto -webkit-focus-ring-color;+  outline-offset: -2px;+}++.btn.active,+.btn:active {+  background-color: #e6e6e6;+  background-color: #d9d9d9 \9;+  background-image: none;+  outline: 0;+  -webkit-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);+     -moz-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);+          box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);+}++.btn.disabled,+.btn[disabled] {+  cursor: default;+  background-color: #e6e6e6;+  background-image: none;+  opacity: 0.65;+  filter: alpha(opacity=65);+  -webkit-box-shadow: none;+     -moz-box-shadow: none;+          box-shadow: none;+}++.btn-large {+  padding: 9px 14px;+  font-size: 15px;+  line-height: normal;+  -webkit-border-radius: 5px;+     -moz-border-radius: 5px;+          border-radius: 5px;+}++.btn-large [class^="icon-"] {+  margin-top: 1px;+}++.btn-small {+  padding: 5px 9px;+  font-size: 11px;+  line-height: 16px;+}++.btn-small [class^="icon-"] {+  margin-top: -1px;+}++.btn-mini {+  padding: 2px 6px;+  font-size: 11px;+  line-height: 14px;+}++.btn-primary,+.btn-primary:hover,+.btn-warning,+.btn-warning:hover,+.btn-danger,+.btn-danger:hover,+.btn-success,+.btn-success:hover,+.btn-info,+.btn-info:hover,+.btn-inverse,+.btn-inverse:hover {+  color: #ffffff;+  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);+}++.btn-primary.active,+.btn-warning.active,+.btn-danger.active,+.btn-success.active,+.btn-info.active,+.btn-inverse.active {+  color: rgba(255, 255, 255, 0.75);+}++.btn {+  border-color: #ccc;+  border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);+}++.btn-primary {+  background-color: #0074cc;+  *background-color: #0055cc;+  background-image: -ms-linear-gradient(top, #0088cc, #0055cc);+  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0055cc));+  background-image: -webkit-linear-gradient(top, #0088cc, #0055cc);+  background-image: -o-linear-gradient(top, #0088cc, #0055cc);+  background-image: -moz-linear-gradient(top, #0088cc, #0055cc);+  background-image: linear-gradient(top, #0088cc, #0055cc);+  background-repeat: repeat-x;+  border-color: #0055cc #0055cc #003580;+  border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);+  filter: progid:dximagetransform.microsoft.gradient(startColorstr='#0088cc', endColorstr='#0055cc', GradientType=0);+  filter: progid:dximagetransform.microsoft.gradient(enabled=false);+}++.btn-primary:hover,+.btn-primary:active,+.btn-primary.active,+.btn-primary.disabled,+.btn-primary[disabled] {+  background-color: #0055cc;+  *background-color: #004ab3;+}++.btn-primary:active,+.btn-primary.active {+  background-color: #004099 \9;+}++.btn-warning {+  background-color: #faa732;+  *background-color: #f89406;+  background-image: -ms-linear-gradient(top, #fbb450, #f89406);+  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fbb450), to(#f89406));+  background-image: -webkit-linear-gradient(top, #fbb450, #f89406);+  background-image: -o-linear-gradient(top, #fbb450, #f89406);+  background-image: -moz-linear-gradient(top, #fbb450, #f89406);+  background-image: linear-gradient(top, #fbb450, #f89406);+  background-repeat: repeat-x;+  border-color: #f89406 #f89406 #ad6704;+  border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);+  filter: progid:dximagetransform.microsoft.gradient(startColorstr='#fbb450', endColorstr='#f89406', GradientType=0);+  filter: progid:dximagetransform.microsoft.gradient(enabled=false);+}++.btn-warning:hover,+.btn-warning:active,+.btn-warning.active,+.btn-warning.disabled,+.btn-warning[disabled] {+  background-color: #f89406;+  *background-color: #df8505;+}++.btn-warning:active,+.btn-warning.active {+  background-color: #c67605 \9;+}++.btn-danger {+  background-color: #da4f49;+  *background-color: #bd362f;+  background-image: -ms-linear-gradient(top, #ee5f5b, #bd362f);+  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ee5f5b), to(#bd362f));+  background-image: -webkit-linear-gradient(top, #ee5f5b, #bd362f);+  background-image: -o-linear-gradient(top, #ee5f5b, #bd362f);+  background-image: -moz-linear-gradient(top, #ee5f5b, #bd362f);+  background-image: linear-gradient(top, #ee5f5b, #bd362f);+  background-repeat: repeat-x;+  border-color: #bd362f #bd362f #802420;+  border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);+  filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ee5f5b', endColorstr='#bd362f', GradientType=0);+  filter: progid:dximagetransform.microsoft.gradient(enabled=false);+}++.btn-danger:hover,+.btn-danger:active,+.btn-danger.active,+.btn-danger.disabled,+.btn-danger[disabled] {+  background-color: #bd362f;+  *background-color: #a9302a;+}++.btn-danger:active,+.btn-danger.active {+  background-color: #942a25 \9;+}++.btn-success {+  background-color: #5bb75b;+  *background-color: #51a351;+  background-image: -ms-linear-gradient(top, #62c462, #51a351);+  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#62c462), to(#51a351));+  background-image: -webkit-linear-gradient(top, #62c462, #51a351);+  background-image: -o-linear-gradient(top, #62c462, #51a351);+  background-image: -moz-linear-gradient(top, #62c462, #51a351);+  background-image: linear-gradient(top, #62c462, #51a351);+  background-repeat: repeat-x;+  border-color: #51a351 #51a351 #387038;+  border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);+  filter: progid:dximagetransform.microsoft.gradient(startColorstr='#62c462', endColorstr='#51a351', GradientType=0);+  filter: progid:dximagetransform.microsoft.gradient(enabled=false);+}++.btn-success:hover,+.btn-success:active,+.btn-success.active,+.btn-success.disabled,+.btn-success[disabled] {+  background-color: #51a351;+  *background-color: #499249;+}++.btn-success:active,+.btn-success.active {+  background-color: #408140 \9;+}++.btn-info {+  background-color: #49afcd;+  *background-color: #2f96b4;+  background-image: -ms-linear-gradient(top, #5bc0de, #2f96b4);+  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#5bc0de), to(#2f96b4));+  background-image: -webkit-linear-gradient(top, #5bc0de, #2f96b4);+  background-image: -o-linear-gradient(top, #5bc0de, #2f96b4);+  background-image: -moz-linear-gradient(top, #5bc0de, #2f96b4);+  background-image: linear-gradient(top, #5bc0de, #2f96b4);+  background-repeat: repeat-x;+  border-color: #2f96b4 #2f96b4 #1f6377;+  border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);+  filter: progid:dximagetransform.microsoft.gradient(startColorstr='#5bc0de', endColorstr='#2f96b4', GradientType=0);+  filter: progid:dximagetransform.microsoft.gradient(enabled=false);+}++.btn-info:hover,+.btn-info:active,+.btn-info.active,+.btn-info.disabled,+.btn-info[disabled] {+  background-color: #2f96b4;+  *background-color: #2a85a0;+}++.btn-info:active,+.btn-info.active {+  background-color: #24748c \9;+}++.btn-inverse {+  background-color: #414141;+  *background-color: #222222;+  background-image: -ms-linear-gradient(top, #555555, #222222);+  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#555555), to(#222222));+  background-image: -webkit-linear-gradient(top, #555555, #222222);+  background-image: -o-linear-gradient(top, #555555, #222222);+  background-image: -moz-linear-gradient(top, #555555, #222222);+  background-image: linear-gradient(top, #555555, #222222);+  background-repeat: repeat-x;+  border-color: #222222 #222222 #000000;+  border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);+  filter: progid:dximagetransform.microsoft.gradient(startColorstr='#555555', endColorstr='#222222', GradientType=0);+  filter: progid:dximagetransform.microsoft.gradient(enabled=false);+}++.btn-inverse:hover,+.btn-inverse:active,+.btn-inverse.active,+.btn-inverse.disabled,+.btn-inverse[disabled] {+  background-color: #222222;+  *background-color: #151515;+}++.btn-inverse:active,+.btn-inverse.active {+  background-color: #080808 \9;+}++button.btn,+input[type="submit"].btn {+  *padding-top: 2px;+  *padding-bottom: 2px;+}++button.btn::-moz-focus-inner,+input[type="submit"].btn::-moz-focus-inner {+  padding: 0;+  border: 0;+}++button.btn.btn-large,+input[type="submit"].btn.btn-large {+  *padding-top: 7px;+  *padding-bottom: 7px;+}++button.btn.btn-small,+input[type="submit"].btn.btn-small {+  *padding-top: 3px;+  *padding-bottom: 3px;+}++button.btn.btn-mini,+input[type="submit"].btn.btn-mini {+  *padding-top: 1px;+  *padding-bottom: 1px;+}++.btn-group {+  position: relative;+  *margin-left: .3em;+  *zoom: 1;+}++.btn-group:before,+.btn-group:after {+  display: table;+  content: "";+}++.btn-group:after {+  clear: both;+}++.btn-group:first-child {+  *margin-left: 0;+}++.btn-group + .btn-group {+  margin-left: 5px;+}++.btn-toolbar {+  margin-top: 9px;+  margin-bottom: 9px;+}++.btn-toolbar .btn-group {+  display: inline-block;+  *display: inline;+  /* IE7 inline-block hack */++  *zoom: 1;+}++.btn-group > .btn {+  position: relative;+  float: left;+  margin-left: -1px;+  -webkit-border-radius: 0;+     -moz-border-radius: 0;+          border-radius: 0;+}++.btn-group > .btn:first-child {+  margin-left: 0;+  -webkit-border-bottom-left-radius: 4px;+          border-bottom-left-radius: 4px;+  -webkit-border-top-left-radius: 4px;+          border-top-left-radius: 4px;+  -moz-border-radius-bottomleft: 4px;+  -moz-border-radius-topleft: 4px;+}++.btn-group > .btn:last-child,+.btn-group > .dropdown-toggle {+  -webkit-border-top-right-radius: 4px;+          border-top-right-radius: 4px;+  -webkit-border-bottom-right-radius: 4px;+          border-bottom-right-radius: 4px;+  -moz-border-radius-topright: 4px;+  -moz-border-radius-bottomright: 4px;+}++.btn-group > .btn.large:first-child {+  margin-left: 0;+  -webkit-border-bottom-left-radius: 6px;+          border-bottom-left-radius: 6px;+  -webkit-border-top-left-radius: 6px;+          border-top-left-radius: 6px;+  -moz-border-radius-bottomleft: 6px;+  -moz-border-radius-topleft: 6px;+}++.btn-group > .btn.large:last-child,+.btn-group > .large.dropdown-toggle {+  -webkit-border-top-right-radius: 6px;+          border-top-right-radius: 6px;+  -webkit-border-bottom-right-radius: 6px;+          border-bottom-right-radius: 6px;+  -moz-border-radius-topright: 6px;+  -moz-border-radius-bottomright: 6px;+}++.btn-group > .btn:hover,+.btn-group > .btn:focus,+.btn-group > .btn:active,+.btn-group > .btn.active {+  z-index: 2;+}++.btn-group .dropdown-toggle:active,+.btn-group.open .dropdown-toggle {+  outline: 0;+}++.btn-group > .dropdown-toggle {+  *padding-top: 4px;+  padding-right: 8px;+  *padding-bottom: 4px;+  padding-left: 8px;+  -webkit-box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.125), inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);+     -moz-box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.125), inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);+          box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.125), inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);+}++.btn-group > .btn-mini.dropdown-toggle {+  padding-right: 5px;+  padding-left: 5px;+}++.btn-group > .btn-small.dropdown-toggle {+  *padding-top: 4px;+  *padding-bottom: 4px;+}++.btn-group > .btn-large.dropdown-toggle {+  padding-right: 12px;+  padding-left: 12px;+}++.btn-group.open .dropdown-toggle {+  background-image: none;+  -webkit-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);+     -moz-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);+          box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);+}++.btn-group.open .btn.dropdown-toggle {+  background-color: #e6e6e6;+}++.btn-group.open .btn-primary.dropdown-toggle {+  background-color: #0055cc;+}++.btn-group.open .btn-warning.dropdown-toggle {+  background-color: #f89406;+}++.btn-group.open .btn-danger.dropdown-toggle {+  background-color: #bd362f;+}++.btn-group.open .btn-success.dropdown-toggle {+  background-color: #51a351;+}++.btn-group.open .btn-info.dropdown-toggle {+  background-color: #2f96b4;+}++.btn-group.open .btn-inverse.dropdown-toggle {+  background-color: #222222;+}++.btn .caret {+  margin-top: 7px;+  margin-left: 0;+}++.btn:hover .caret,+.open.btn-group .caret {+  opacity: 1;+  filter: alpha(opacity=100);+}++.btn-mini .caret {+  margin-top: 5px;+}++.btn-small .caret {+  margin-top: 6px;+}++.btn-large .caret {+  margin-top: 6px;+  border-top-width: 5px;+  border-right-width: 5px;+  border-left-width: 5px;+}++.dropup .btn-large .caret {+  border-top: 0;+  border-bottom: 5px solid #000000;+}++.btn-primary .caret,+.btn-warning .caret,+.btn-danger .caret,+.btn-info .caret,+.btn-success .caret,+.btn-inverse .caret {+  border-top-color: #ffffff;+  border-bottom-color: #ffffff;+  opacity: 0.75;+  filter: alpha(opacity=75);+}++.alert {+  padding: 8px 35px 8px 14px;+  margin-bottom: 18px;+  color: #c09853;+  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);+  background-color: #fcf8e3;+  border: 1px solid #fbeed5;+  -webkit-border-radius: 4px;+     -moz-border-radius: 4px;+          border-radius: 4px;+}++.alert-heading {+  color: inherit;+}++.alert .close {+  position: relative;+  top: -2px;+  right: -21px;+  line-height: 18px;+}++.alert-success {+  color: #468847;+  background-color: #dff0d8;+  border-color: #d6e9c6;+}++.alert-danger,+.alert-error {+  color: #b94a48;+  background-color: #f2dede;+  border-color: #eed3d7;+}++.alert-info {+  color: #3a87ad;+  background-color: #d9edf7;+  border-color: #bce8f1;+}++.alert-block {+  padding-top: 14px;+  padding-bottom: 14px;+}++.alert-block > p,+.alert-block > ul {+  margin-bottom: 0;+}++.alert-block p + p {+  margin-top: 5px;+}++.nav {+  margin-bottom: 18px;+  margin-left: 0;+  list-style: none;+}++.nav > li > a {+  display: block;+}++.nav > li > a:hover {+  text-decoration: none;+  background-color: #eeeeee;+}++.nav > .pull-right {+  float: right;+}++.nav .nav-header {+  display: block;+  padding: 3px 15px;+  font-size: 11px;+  font-weight: bold;+  line-height: 18px;+  color: #999999;+  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);+  text-transform: uppercase;+}++.nav li + .nav-header {+  margin-top: 9px;+}++.nav-list {+  padding-right: 15px;+  padding-left: 15px;+  margin-bottom: 0;+}++.nav-list > li > a,+.nav-list .nav-header {+  margin-right: -15px;+  margin-left: -15px;+  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);+}++.nav-list > li > a {+  padding: 3px 15px;+}++.nav-list > .active > a,+.nav-list > .active > a:hover {+  color: #ffffff;+  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.2);+  background-color: #0088cc;+}++.nav-list [class^="icon-"] {+  margin-right: 2px;+}++.nav-list .divider {+  *width: 100%;+  height: 1px;+  margin: 8px 1px;+  *margin: -5px 0 5px;+  overflow: hidden;+  background-color: #e5e5e5;+  border-bottom: 1px solid #ffffff;+}++.nav-tabs,+.nav-pills {+  *zoom: 1;+}++.nav-tabs:before,+.nav-pills:before,+.nav-tabs:after,+.nav-pills:after {+  display: table;+  content: "";+}++.nav-tabs:after,+.nav-pills:after {+  clear: both;+}++.nav-tabs > li,+.nav-pills > li {+  float: left;+}++.nav-tabs > li > a,+.nav-pills > li > a {+  padding-right: 12px;+  padding-left: 12px;+  margin-right: 2px;+  line-height: 14px;+}++.nav-tabs {+  border-bottom: 1px solid #ddd;+}++.nav-tabs > li {+  margin-bottom: -1px;+}++.nav-tabs > li > a {+  padding-top: 8px;+  padding-bottom: 8px;+  line-height: 18px;+  border: 1px solid transparent;+  -webkit-border-radius: 4px 4px 0 0;+     -moz-border-radius: 4px 4px 0 0;+          border-radius: 4px 4px 0 0;+}++.nav-tabs > li > a:hover {+  border-color: #eeeeee #eeeeee #dddddd;+}++.nav-tabs > .active > a,+.nav-tabs > .active > a:hover {+  color: #555555;+  cursor: default;+  background-color: #ffffff;+  border: 1px solid #ddd;+  border-bottom-color: transparent;+}++.nav-pills > li > a {+  padding-top: 8px;+  padding-bottom: 8px;+  margin-top: 2px;+  margin-bottom: 2px;+  -webkit-border-radius: 5px;+     -moz-border-radius: 5px;+          border-radius: 5px;+}++.nav-pills > .active > a,+.nav-pills > .active > a:hover {+  color: #ffffff;+  background-color: #0088cc;+}++.nav-stacked > li {+  float: none;+}++.nav-stacked > li > a {+  margin-right: 0;+}++.nav-tabs.nav-stacked {+  border-bottom: 0;+}++.nav-tabs.nav-stacked > li > a {+  border: 1px solid #ddd;+  -webkit-border-radius: 0;+     -moz-border-radius: 0;+          border-radius: 0;+}++.nav-tabs.nav-stacked > li:first-child > a {+  -webkit-border-radius: 4px 4px 0 0;+     -moz-border-radius: 4px 4px 0 0;+          border-radius: 4px 4px 0 0;+}++.nav-tabs.nav-stacked > li:last-child > a {+  -webkit-border-radius: 0 0 4px 4px;+     -moz-border-radius: 0 0 4px 4px;+          border-radius: 0 0 4px 4px;+}++.nav-tabs.nav-stacked > li > a:hover {+  z-index: 2;+  border-color: #ddd;+}++.nav-pills.nav-stacked > li > a {+  margin-bottom: 3px;+}++.nav-pills.nav-stacked > li:last-child > a {+  margin-bottom: 1px;+}++.nav-tabs .dropdown-menu {+  -webkit-border-radius: 0 0 5px 5px;+     -moz-border-radius: 0 0 5px 5px;+          border-radius: 0 0 5px 5px;+}++.nav-pills .dropdown-menu {+  -webkit-border-radius: 4px;+     -moz-border-radius: 4px;+          border-radius: 4px;+}++.nav-tabs .dropdown-toggle .caret,+.nav-pills .dropdown-toggle .caret {+  margin-top: 6px;+  border-top-color: #0088cc;+  border-bottom-color: #0088cc;+}++.nav-tabs .dropdown-toggle:hover .caret,+.nav-pills .dropdown-toggle:hover .caret {+  border-top-color: #005580;+  border-bottom-color: #005580;+}++.nav-tabs .active .dropdown-toggle .caret,+.nav-pills .active .dropdown-toggle .caret {+  border-top-color: #333333;+  border-bottom-color: #333333;+}++.nav > .dropdown.active > a:hover {+  color: #000000;+  cursor: pointer;+}++.nav-tabs .open .dropdown-toggle,+.nav-pills .open .dropdown-toggle,+.nav > li.dropdown.open.active > a:hover {+  color: #ffffff;+  background-color: #999999;+  border-color: #999999;+}++.nav li.dropdown.open .caret,+.nav li.dropdown.open.active .caret,+.nav li.dropdown.open a:hover .caret {+  border-top-color: #ffffff;+  border-bottom-color: #ffffff;+  opacity: 1;+  filter: alpha(opacity=100);+}++.tabs-stacked .open > a:hover {+  border-color: #999999;+}++.tabbable {+  *zoom: 1;+}++.tabbable:before,+.tabbable:after {+  display: table;+  content: "";+}++.tabbable:after {+  clear: both;+}++.tab-content {+  overflow: auto;+}++.tabs-below > .nav-tabs,+.tabs-right > .nav-tabs,+.tabs-left > .nav-tabs {+  border-bottom: 0;+}++.tab-content > .tab-pane,+.pill-content > .pill-pane {+  display: none;+}++.tab-content > .active,+.pill-content > .active {+  display: block;+}++.tabs-below > .nav-tabs {+  border-top: 1px solid #ddd;+}++.tabs-below > .nav-tabs > li {+  margin-top: -1px;+  margin-bottom: 0;+}++.tabs-below > .nav-tabs > li > a {+  -webkit-border-radius: 0 0 4px 4px;+     -moz-border-radius: 0 0 4px 4px;+          border-radius: 0 0 4px 4px;+}++.tabs-below > .nav-tabs > li > a:hover {+  border-top-color: #ddd;+  border-bottom-color: transparent;+}++.tabs-below > .nav-tabs > .active > a,+.tabs-below > .nav-tabs > .active > a:hover {+  border-color: transparent #ddd #ddd #ddd;+}++.tabs-left > .nav-tabs > li,+.tabs-right > .nav-tabs > li {+  float: none;+}++.tabs-left > .nav-tabs > li > a,+.tabs-right > .nav-tabs > li > a {+  min-width: 74px;+  margin-right: 0;+  margin-bottom: 3px;+}++.tabs-left > .nav-tabs {+  float: left;+  margin-right: 19px;+  border-right: 1px solid #ddd;+}++.tabs-left > .nav-tabs > li > a {+  margin-right: -1px;+  -webkit-border-radius: 4px 0 0 4px;+     -moz-border-radius: 4px 0 0 4px;+          border-radius: 4px 0 0 4px;+}++.tabs-left > .nav-tabs > li > a:hover {+  border-color: #eeeeee #dddddd #eeeeee #eeeeee;+}++.tabs-left > .nav-tabs .active > a,+.tabs-left > .nav-tabs .active > a:hover {+  border-color: #ddd transparent #ddd #ddd;+  *border-right-color: #ffffff;+}++.tabs-right > .nav-tabs {+  float: right;+  margin-left: 19px;+  border-left: 1px solid #ddd;+}++.tabs-right > .nav-tabs > li > a {+  margin-left: -1px;+  -webkit-border-radius: 0 4px 4px 0;+     -moz-border-radius: 0 4px 4px 0;+          border-radius: 0 4px 4px 0;+}++.tabs-right > .nav-tabs > li > a:hover {+  border-color: #eeeeee #eeeeee #eeeeee #dddddd;+}++.tabs-right > .nav-tabs .active > a,+.tabs-right > .nav-tabs .active > a:hover {+  border-color: #ddd #ddd #ddd transparent;+  *border-left-color: #ffffff;+}++.navbar {+  *position: relative;+  *z-index: 2;+  margin-bottom: 18px;+  overflow: visible;+}++.navbar-inner {+  min-height: 40px;+  padding-right: 20px;+  padding-left: 20px;+  background-color: #2c2c2c;+  background-image: -moz-linear-gradient(top, #333333, #222222);+  background-image: -ms-linear-gradient(top, #333333, #222222);+  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#333333), to(#222222));+  background-image: -webkit-linear-gradient(top, #333333, #222222);+  background-image: -o-linear-gradient(top, #333333, #222222);+  background-image: linear-gradient(top, #333333, #222222);+  background-repeat: repeat-x;+  -webkit-border-radius: 4px;+     -moz-border-radius: 4px;+          border-radius: 4px;+  filter: progid:dximagetransform.microsoft.gradient(startColorstr='#333333', endColorstr='#222222', GradientType=0);+  -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25), inset 0 -1px 0 rgba(0, 0, 0, 0.1);+     -moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25), inset 0 -1px 0 rgba(0, 0, 0, 0.1);+          box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25), inset 0 -1px 0 rgba(0, 0, 0, 0.1);+}++.navbar .container {+  width: auto;+}++.nav-collapse.collapse {+  height: auto;+}++.navbar {+  color: #999999;+}++.navbar .brand:hover {+  text-decoration: none;+}++.navbar .brand {+  display: block;+  float: left;+  padding: 8px 20px 12px;+  margin-left: -20px;+  font-size: 20px;+  font-weight: 200;+  line-height: 1;+  color: #999999;+}++.navbar .navbar-text {+  margin-bottom: 0;+  line-height: 40px;+}++.navbar .navbar-link {+  color: #999999;+}++.navbar .navbar-link:hover {+  color: #ffffff;+}++.navbar .btn,+.navbar .btn-group {+  margin-top: 5px;+}++.navbar .btn-group .btn {+  margin: 0;+}++.navbar-form {+  margin-bottom: 0;+  *zoom: 1;+}++.navbar-form:before,+.navbar-form:after {+  display: table;+  content: "";+}++.navbar-form:after {+  clear: both;+}++.navbar-form input,+.navbar-form select,+.navbar-form .radio,+.navbar-form .checkbox {+  margin-top: 5px;+}++.navbar-form input,+.navbar-form select {+  display: inline-block;+  margin-bottom: 0;+}++.navbar-form input[type="image"],+.navbar-form input[type="checkbox"],+.navbar-form input[type="radio"] {+  margin-top: 3px;+}++.navbar-form .input-append,+.navbar-form .input-prepend {+  margin-top: 6px;+  white-space: nowrap;+}++.navbar-form .input-append input,+.navbar-form .input-prepend input {+  margin-top: 0;+}++.navbar-search {+  position: relative;+  float: left;+  margin-top: 6px;+  margin-bottom: 0;+}++.navbar-search .search-query {+  padding: 4px 9px;+  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;+  font-size: 13px;+  font-weight: normal;+  line-height: 1;+  color: #ffffff;+  background-color: #626262;+  border: 1px solid #151515;+  -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1), 0 1px 0 rgba(255, 255, 255, 0.15);+     -moz-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1), 0 1px 0 rgba(255, 255, 255, 0.15);+          box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1), 0 1px 0 rgba(255, 255, 255, 0.15);+  -webkit-transition: none;+     -moz-transition: none;+      -ms-transition: none;+       -o-transition: none;+          transition: none;+}++.navbar-search .search-query:-moz-placeholder {+  color: #cccccc;+}++.navbar-search .search-query:-ms-input-placeholder {+  color: #cccccc;+}++.navbar-search .search-query::-webkit-input-placeholder {+  color: #cccccc;+}++.navbar-search .search-query:focus,+.navbar-search .search-query.focused {+  padding: 5px 10px;+  color: #333333;+  text-shadow: 0 1px 0 #ffffff;+  background-color: #ffffff;+  border: 0;+  outline: 0;+  -webkit-box-shadow: 0 0 3px rgba(0, 0, 0, 0.15);+     -moz-box-shadow: 0 0 3px rgba(0, 0, 0, 0.15);+          box-shadow: 0 0 3px rgba(0, 0, 0, 0.15);+}++.navbar-fixed-top,+.navbar-fixed-bottom {+  position: fixed;+  right: 0;+  left: 0;+  z-index: 1030;+  margin-bottom: 0;+}++.navbar-fixed-top .navbar-inner,+.navbar-fixed-bottom .navbar-inner {+  padding-right: 0;+  padding-left: 0;+  -webkit-border-radius: 0;+     -moz-border-radius: 0;+          border-radius: 0;+}++.navbar-fixed-top .container,+.navbar-fixed-bottom .container {+  width: 940px;+}++.navbar-fixed-top {+  top: 0;+}++.navbar-fixed-bottom {+  bottom: 0;+}++.navbar .nav {+  position: relative;+  left: 0;+  display: block;+  float: left;+  margin: 0 10px 0 0;+}++.navbar .nav.pull-right {+  float: right;+}++.navbar .nav > li {+  display: block;+  float: left;+}++.navbar .nav > li > a {+  float: none;+  padding: 9px 10px 11px;+  line-height: 19px;+  color: #999999;+  text-decoration: none;+  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);+}++.navbar .btn {+  display: inline-block;+  padding: 4px 10px 4px;+  margin: 5px 5px 6px;+  line-height: 18px;+}++.navbar .btn-group {+  padding: 5px 5px 6px;+  margin: 0;+}++.navbar .nav > li > a:hover {+  color: #ffffff;+  text-decoration: none;+  background-color: transparent;+}++.navbar .nav .active > a,+.navbar .nav .active > a:hover {+  color: #ffffff;+  text-decoration: none;+  background-color: #222222;+}++.navbar .divider-vertical {+  width: 1px;+  height: 40px;+  margin: 0 9px;+  overflow: hidden;+  background-color: #222222;+  border-right: 1px solid #333333;+}++.navbar .nav.pull-right {+  margin-right: 0;+  margin-left: 10px;+}++.navbar .btn-navbar {+  display: none;+  float: right;+  padding: 7px 10px;+  margin-right: 5px;+  margin-left: 5px;+  background-color: #2c2c2c;+  *background-color: #222222;+  background-image: -ms-linear-gradient(top, #333333, #222222);+  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#333333), to(#222222));+  background-image: -webkit-linear-gradient(top, #333333, #222222);+  background-image: -o-linear-gradient(top, #333333, #222222);+  background-image: linear-gradient(top, #333333, #222222);+  background-image: -moz-linear-gradient(top, #333333, #222222);+  background-repeat: repeat-x;+  border-color: #222222 #222222 #000000;+  border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);+  filter: progid:dximagetransform.microsoft.gradient(startColorstr='#333333', endColorstr='#222222', GradientType=0);+  filter: progid:dximagetransform.microsoft.gradient(enabled=false);+  -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.075);+     -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.075);+          box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.075);+}++.navbar .btn-navbar:hover,+.navbar .btn-navbar:active,+.navbar .btn-navbar.active,+.navbar .btn-navbar.disabled,+.navbar .btn-navbar[disabled] {+  background-color: #222222;+  *background-color: #151515;+}++.navbar .btn-navbar:active,+.navbar .btn-navbar.active {+  background-color: #080808 \9;+}++.navbar .btn-navbar .icon-bar {+  display: block;+  width: 18px;+  height: 2px;+  background-color: #f5f5f5;+  -webkit-border-radius: 1px;+     -moz-border-radius: 1px;+          border-radius: 1px;+  -webkit-box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);+     -moz-box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);+          box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);+}++.btn-navbar .icon-bar + .icon-bar {+  margin-top: 3px;+}++.navbar .dropdown-menu:before {+  position: absolute;+  top: -7px;+  left: 9px;+  display: inline-block;+  border-right: 7px solid transparent;+  border-bottom: 7px solid #ccc;+  border-left: 7px solid transparent;+  border-bottom-color: rgba(0, 0, 0, 0.2);+  content: '';+}++.navbar .dropdown-menu:after {+  position: absolute;+  top: -6px;+  left: 10px;+  display: inline-block;+  border-right: 6px solid transparent;+  border-bottom: 6px solid #ffffff;+  border-left: 6px solid transparent;+  content: '';+}++.navbar-fixed-bottom .dropdown-menu:before {+  top: auto;+  bottom: -7px;+  border-top: 7px solid #ccc;+  border-bottom: 0;+  border-top-color: rgba(0, 0, 0, 0.2);+}++.navbar-fixed-bottom .dropdown-menu:after {+  top: auto;+  bottom: -6px;+  border-top: 6px solid #ffffff;+  border-bottom: 0;+}++.navbar .nav li.dropdown .dropdown-toggle .caret,+.navbar .nav li.dropdown.open .caret {+  border-top-color: #ffffff;+  border-bottom-color: #ffffff;+}++.navbar .nav li.dropdown.active .caret {+  opacity: 1;+  filter: alpha(opacity=100);+}++.navbar .nav li.dropdown.open > .dropdown-toggle,+.navbar .nav li.dropdown.active > .dropdown-toggle,+.navbar .nav li.dropdown.open.active > .dropdown-toggle {+  background-color: transparent;+}++.navbar .nav li.dropdown.active > .dropdown-toggle:hover {+  color: #ffffff;+}++.navbar .pull-right .dropdown-menu,+.navbar .dropdown-menu.pull-right {+  right: 0;+  left: auto;+}++.navbar .pull-right .dropdown-menu:before,+.navbar .dropdown-menu.pull-right:before {+  right: 12px;+  left: auto;+}++.navbar .pull-right .dropdown-menu:after,+.navbar .dropdown-menu.pull-right:after {+  right: 13px;+  left: auto;+}++.breadcrumb {+  padding: 7px 14px;+  margin: 0 0 18px;+  list-style: none;+  background-color: #fbfbfb;+  background-image: -moz-linear-gradient(top, #ffffff, #f5f5f5);+  background-image: -ms-linear-gradient(top, #ffffff, #f5f5f5);+  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#f5f5f5));+  background-image: -webkit-linear-gradient(top, #ffffff, #f5f5f5);+  background-image: -o-linear-gradient(top, #ffffff, #f5f5f5);+  background-image: linear-gradient(top, #ffffff, #f5f5f5);+  background-repeat: repeat-x;+  border: 1px solid #ddd;+  -webkit-border-radius: 3px;+     -moz-border-radius: 3px;+          border-radius: 3px;+  filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ffffff', endColorstr='#f5f5f5', GradientType=0);+  -webkit-box-shadow: inset 0 1px 0 #ffffff;+     -moz-box-shadow: inset 0 1px 0 #ffffff;+          box-shadow: inset 0 1px 0 #ffffff;+}++.breadcrumb li {+  display: inline-block;+  *display: inline;+  text-shadow: 0 1px 0 #ffffff;+  *zoom: 1;+}++.breadcrumb .divider {+  padding: 0 5px;+  color: #999999;+}++.breadcrumb .active a {+  color: #333333;+}++.pagination {+  height: 36px;+  margin: 18px 0;+}++.pagination ul {+  display: inline-block;+  *display: inline;+  margin-bottom: 0;+  margin-left: 0;+  -webkit-border-radius: 3px;+     -moz-border-radius: 3px;+          border-radius: 3px;+  *zoom: 1;+  -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);+     -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);+          box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);+}++.pagination li {+  display: inline;+}++.pagination a {+  float: left;+  padding: 0 14px;+  line-height: 34px;+  text-decoration: none;+  border: 1px solid #ddd;+  border-left-width: 0;+}++.pagination a:hover,+.pagination .active a {+  background-color: #f5f5f5;+}++.pagination .active a {+  color: #999999;+  cursor: default;+}++.pagination .disabled span,+.pagination .disabled a,+.pagination .disabled a:hover {+  color: #999999;+  cursor: default;+  background-color: transparent;+}++.pagination li:first-child a {+  border-left-width: 1px;+  -webkit-border-radius: 3px 0 0 3px;+     -moz-border-radius: 3px 0 0 3px;+          border-radius: 3px 0 0 3px;+}++.pagination li:last-child a {+  -webkit-border-radius: 0 3px 3px 0;+     -moz-border-radius: 0 3px 3px 0;+          border-radius: 0 3px 3px 0;+}++.pagination-centered {+  text-align: center;+}++.pagination-right {+  text-align: right;+}++.pager {+  margin-bottom: 18px;+  margin-left: 0;+  text-align: center;+  list-style: none;+  *zoom: 1;+}++.pager:before,+.pager:after {+  display: table;+  content: "";+}++.pager:after {+  clear: both;+}++.pager li {+  display: inline;+}++.pager a {+  display: inline-block;+  padding: 5px 14px;+  background-color: #fff;+  border: 1px solid #ddd;+  -webkit-border-radius: 15px;+     -moz-border-radius: 15px;+          border-radius: 15px;+}++.pager a:hover {+  text-decoration: none;+  background-color: #f5f5f5;+}++.pager .next a {+  float: right;+}++.pager .previous a {+  float: left;+}++.pager .disabled a,+.pager .disabled a:hover {+  color: #999999;+  cursor: default;+  background-color: #fff;+}++.modal-open .dropdown-menu {+  z-index: 2050;+}++.modal-open .dropdown.open {+  *z-index: 2050;+}++.modal-open .popover {+  z-index: 2060;+}++.modal-open .tooltip {+  z-index: 2070;+}++.modal-backdrop {+  position: fixed;+  top: 0;+  right: 0;+  bottom: 0;+  left: 0;+  z-index: 1040;+  background-color: #000000;+}++.modal-backdrop.fade {+  opacity: 0;+}++.modal-backdrop,+.modal-backdrop.fade.in {+  opacity: 0.8;+  filter: alpha(opacity=80);+}++.modal {+  position: fixed;+  top: 50%;+  left: 50%;+  z-index: 1050;+  width: 560px;+  margin: -250px 0 0 -280px;+  overflow: auto;+  background-color: #ffffff;+  border: 1px solid #999;+  border: 1px solid rgba(0, 0, 0, 0.3);+  *border: 1px solid #999;+  -webkit-border-radius: 6px;+     -moz-border-radius: 6px;+          border-radius: 6px;+  -webkit-box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);+     -moz-box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);+          box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);+  -webkit-background-clip: padding-box;+     -moz-background-clip: padding-box;+          background-clip: padding-box;+}++.modal.fade {+  top: -25%;+  -webkit-transition: opacity 0.3s linear, top 0.3s ease-out;+     -moz-transition: opacity 0.3s linear, top 0.3s ease-out;+      -ms-transition: opacity 0.3s linear, top 0.3s ease-out;+       -o-transition: opacity 0.3s linear, top 0.3s ease-out;+          transition: opacity 0.3s linear, top 0.3s ease-out;+}++.modal.fade.in {+  top: 50%;+}++.modal-header {+  padding: 9px 15px;+  border-bottom: 1px solid #eee;+}++.modal-header .close {+  margin-top: 2px;+}++.modal-body {+  max-height: 400px;+  padding: 15px;+  overflow-y: auto;+}++.modal-form {+  margin-bottom: 0;+}++.modal-footer {+  padding: 14px 15px 15px;+  margin-bottom: 0;+  text-align: right;+  background-color: #f5f5f5;+  border-top: 1px solid #ddd;+  -webkit-border-radius: 0 0 6px 6px;+     -moz-border-radius: 0 0 6px 6px;+          border-radius: 0 0 6px 6px;+  *zoom: 1;+  -webkit-box-shadow: inset 0 1px 0 #ffffff;+     -moz-box-shadow: inset 0 1px 0 #ffffff;+          box-shadow: inset 0 1px 0 #ffffff;+}++.modal-footer:before,+.modal-footer:after {+  display: table;+  content: "";+}++.modal-footer:after {+  clear: both;+}++.modal-footer .btn + .btn {+  margin-bottom: 0;+  margin-left: 5px;+}++.modal-footer .btn-group .btn + .btn {+  margin-left: -1px;+}++.tooltip {+  position: absolute;+  z-index: 1020;+  display: block;+  padding: 5px;+  font-size: 11px;+  opacity: 0;+  filter: alpha(opacity=0);+  visibility: visible;+}++.tooltip.in {+  opacity: 0.8;+  filter: alpha(opacity=80);+}++.tooltip.top {+  margin-top: -2px;+}++.tooltip.right {+  margin-left: 2px;+}++.tooltip.bottom {+  margin-top: 2px;+}++.tooltip.left {+  margin-left: -2px;+}++.tooltip.top .tooltip-arrow {+  bottom: 0;+  left: 50%;+  margin-left: -5px;+  border-top: 5px solid #000000;+  border-right: 5px solid transparent;+  border-left: 5px solid transparent;+}++.tooltip.left .tooltip-arrow {+  top: 50%;+  right: 0;+  margin-top: -5px;+  border-top: 5px solid transparent;+  border-bottom: 5px solid transparent;+  border-left: 5px solid #000000;+}++.tooltip.bottom .tooltip-arrow {+  top: 0;+  left: 50%;+  margin-left: -5px;+  border-right: 5px solid transparent;+  border-bottom: 5px solid #000000;+  border-left: 5px solid transparent;+}++.tooltip.right .tooltip-arrow {+  top: 50%;+  left: 0;+  margin-top: -5px;+  border-top: 5px solid transparent;+  border-right: 5px solid #000000;+  border-bottom: 5px solid transparent;+}++.tooltip-inner {+  max-width: 200px;+  padding: 3px 8px;+  color: #ffffff;+  text-align: center;+  text-decoration: none;+  background-color: #000000;+  -webkit-border-radius: 4px;+     -moz-border-radius: 4px;+          border-radius: 4px;+}++.tooltip-arrow {+  position: absolute;+  width: 0;+  height: 0;+}++.popover {+  position: absolute;+  top: 0;+  left: 0;+  z-index: 1010;+  display: none;+  padding: 5px;+}++.popover.top {+  margin-top: -5px;+}++.popover.right {+  margin-left: 5px;+}++.popover.bottom {+  margin-top: 5px;+}++.popover.left {+  margin-left: -5px;+}++.popover.top .arrow {+  bottom: 0;+  left: 50%;+  margin-left: -5px;+  border-top: 5px solid #000000;+  border-right: 5px solid transparent;+  border-left: 5px solid transparent;+}++.popover.right .arrow {+  top: 50%;+  left: 0;+  margin-top: -5px;+  border-top: 5px solid transparent;+  border-right: 5px solid #000000;+  border-bottom: 5px solid transparent;+}++.popover.bottom .arrow {+  top: 0;+  left: 50%;+  margin-left: -5px;+  border-right: 5px solid transparent;+  border-bottom: 5px solid #000000;+  border-left: 5px solid transparent;+}++.popover.left .arrow {+  top: 50%;+  right: 0;+  margin-top: -5px;+  border-top: 5px solid transparent;+  border-bottom: 5px solid transparent;+  border-left: 5px solid #000000;+}++.popover .arrow {+  position: absolute;+  width: 0;+  height: 0;+}++.popover-inner {+  width: 280px;+  padding: 3px;+  overflow: hidden;+  background: #000000;+  background: rgba(0, 0, 0, 0.8);+  -webkit-border-radius: 6px;+     -moz-border-radius: 6px;+          border-radius: 6px;+  -webkit-box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);+     -moz-box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);+          box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);+}++.popover-title {+  padding: 9px 15px;+  line-height: 1;+  background-color: #f5f5f5;+  border-bottom: 1px solid #eee;+  -webkit-border-radius: 3px 3px 0 0;+     -moz-border-radius: 3px 3px 0 0;+          border-radius: 3px 3px 0 0;+}++.popover-content {+  padding: 14px;+  background-color: #ffffff;+  -webkit-border-radius: 0 0 3px 3px;+     -moz-border-radius: 0 0 3px 3px;+          border-radius: 0 0 3px 3px;+  -webkit-background-clip: padding-box;+     -moz-background-clip: padding-box;+          background-clip: padding-box;+}++.popover-content p,+.popover-content ul,+.popover-content ol {+  margin-bottom: 0;+}++.thumbnails {+  margin-left: -20px;+  list-style: none;+  *zoom: 1;+}++.thumbnails:before,+.thumbnails:after {+  display: table;+  content: "";+}++.thumbnails:after {+  clear: both;+}++.row-fluid .thumbnails {+  margin-left: 0;+}++.thumbnails > li {+  float: left;+  margin-bottom: 18px;+  margin-left: 20px;+}++.thumbnail {+  display: block;+  padding: 4px;+  line-height: 1;+  border: 1px solid #ddd;+  -webkit-border-radius: 4px;+     -moz-border-radius: 4px;+          border-radius: 4px;+  -webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075);+     -moz-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075);+          box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075);+}++a.thumbnail:hover {+  border-color: #0088cc;+  -webkit-box-shadow: 0 1px 4px rgba(0, 105, 214, 0.25);+     -moz-box-shadow: 0 1px 4px rgba(0, 105, 214, 0.25);+          box-shadow: 0 1px 4px rgba(0, 105, 214, 0.25);+}++.thumbnail > img {+  display: block;+  max-width: 100%;+  margin-right: auto;+  margin-left: auto;+}++.thumbnail .caption {+  padding: 9px;+}++.label,+.badge {+  font-size: 10.998px;+  font-weight: bold;+  line-height: 14px;+  color: #ffffff;+  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);+  white-space: nowrap;+  vertical-align: baseline;+  background-color: #999999;+}++.label {+  padding: 1px 4px 2px;+  -webkit-border-radius: 3px;+     -moz-border-radius: 3px;+          border-radius: 3px;+}++.badge {+  padding: 1px 9px 2px;+  -webkit-border-radius: 9px;+     -moz-border-radius: 9px;+          border-radius: 9px;+}++a.label:hover,+a.badge:hover {+  color: #ffffff;+  text-decoration: none;+  cursor: pointer;+}++.label-important,+.badge-important {+  background-color: #b94a48;+}++.label-important[href],+.badge-important[href] {+  background-color: #953b39;+}++.label-warning,+.badge-warning {+  background-color: #f89406;+}++.label-warning[href],+.badge-warning[href] {+  background-color: #c67605;+}++.label-success,+.badge-success {+  background-color: #468847;+}++.label-success[href],+.badge-success[href] {+  background-color: #356635;+}++.label-info,+.badge-info {+  background-color: #3a87ad;+}++.label-info[href],+.badge-info[href] {+  background-color: #2d6987;+}++.label-inverse,+.badge-inverse {+  background-color: #333333;+}++.label-inverse[href],+.badge-inverse[href] {+  background-color: #1a1a1a;+}++@-webkit-keyframes progress-bar-stripes {+  from {+    background-position: 40px 0;+  }+  to {+    background-position: 0 0;+  }+}++@-moz-keyframes progress-bar-stripes {+  from {+    background-position: 40px 0;+  }+  to {+    background-position: 0 0;+  }+}++@-ms-keyframes progress-bar-stripes {+  from {+    background-position: 40px 0;+  }+  to {+    background-position: 0 0;+  }+}++@-o-keyframes progress-bar-stripes {+  from {+    background-position: 0 0;+  }+  to {+    background-position: 40px 0;+  }+}++@keyframes progress-bar-stripes {+  from {+    background-position: 40px 0;+  }+  to {+    background-position: 0 0;+  }+}++.progress {+  height: 18px;+  margin-bottom: 18px;+  overflow: hidden;+  background-color: #f7f7f7;+  background-image: -moz-linear-gradient(top, #f5f5f5, #f9f9f9);+  background-image: -ms-linear-gradient(top, #f5f5f5, #f9f9f9);+  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#f5f5f5), to(#f9f9f9));+  background-image: -webkit-linear-gradient(top, #f5f5f5, #f9f9f9);+  background-image: -o-linear-gradient(top, #f5f5f5, #f9f9f9);+  background-image: linear-gradient(top, #f5f5f5, #f9f9f9);+  background-repeat: repeat-x;+  -webkit-border-radius: 4px;+     -moz-border-radius: 4px;+          border-radius: 4px;+  filter: progid:dximagetransform.microsoft.gradient(startColorstr='#f5f5f5', endColorstr='#f9f9f9', GradientType=0);+  -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);+     -moz-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);+          box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);+}++.progress .bar {+  width: 0;+  height: 18px;+  font-size: 12px;+  color: #ffffff;+  text-align: center;+  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);+  background-color: #0e90d2;+  background-image: -moz-linear-gradient(top, #149bdf, #0480be);+  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#149bdf), to(#0480be));+  background-image: -webkit-linear-gradient(top, #149bdf, #0480be);+  background-image: -o-linear-gradient(top, #149bdf, #0480be);+  background-image: linear-gradient(top, #149bdf, #0480be);+  background-image: -ms-linear-gradient(top, #149bdf, #0480be);+  background-repeat: repeat-x;+  filter: progid:dximagetransform.microsoft.gradient(startColorstr='#149bdf', endColorstr='#0480be', GradientType=0);+  -webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15);+     -moz-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15);+          box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15);+  -webkit-box-sizing: border-box;+     -moz-box-sizing: border-box;+      -ms-box-sizing: border-box;+          box-sizing: border-box;+  -webkit-transition: width 0.6s ease;+     -moz-transition: width 0.6s ease;+      -ms-transition: width 0.6s ease;+       -o-transition: width 0.6s ease;+          transition: width 0.6s ease;+}++.progress-striped .bar {+  background-color: #149bdf;+  background-image: -o-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);+  background-image: -webkit-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);+  background-image: -moz-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);+  background-image: -ms-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);+  background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));+  background-image: linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);+  -webkit-background-size: 40px 40px;+     -moz-background-size: 40px 40px;+       -o-background-size: 40px 40px;+          background-size: 40px 40px;+}++.progress.active .bar {+  -webkit-animation: progress-bar-stripes 2s linear infinite;+     -moz-animation: progress-bar-stripes 2s linear infinite;+      -ms-animation: progress-bar-stripes 2s linear infinite;+       -o-animation: progress-bar-stripes 2s linear infinite;+          animation: progress-bar-stripes 2s linear infinite;+}++.progress-danger .bar {+  background-color: #dd514c;+  background-image: -moz-linear-gradient(top, #ee5f5b, #c43c35);+  background-image: -ms-linear-gradient(top, #ee5f5b, #c43c35);+  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ee5f5b), to(#c43c35));+  background-image: -webkit-linear-gradient(top, #ee5f5b, #c43c35);+  background-image: -o-linear-gradient(top, #ee5f5b, #c43c35);+  background-image: linear-gradient(top, #ee5f5b, #c43c35);+  background-repeat: repeat-x;+  filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ee5f5b', endColorstr='#c43c35', GradientType=0);+}++.progress-danger.progress-striped .bar {+  background-color: #ee5f5b;+  background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));+  background-image: -webkit-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);+  background-image: -moz-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);+  background-image: -ms-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);+  background-image: -o-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);+  background-image: linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);+}++.progress-success .bar {+  background-color: #5eb95e;+  background-image: -moz-linear-gradient(top, #62c462, #57a957);+  background-image: -ms-linear-gradient(top, #62c462, #57a957);+  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#62c462), to(#57a957));+  background-image: -webkit-linear-gradient(top, #62c462, #57a957);+  background-image: -o-linear-gradient(top, #62c462, #57a957);+  background-image: linear-gradient(top, #62c462, #57a957);+  background-repeat: repeat-x;+  filter: progid:dximagetransform.microsoft.gradient(startColorstr='#62c462', endColorstr='#57a957', GradientType=0);+}++.progress-success.progress-striped .bar {+  background-color: #62c462;+  background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));+  background-image: -webkit-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);+  background-image: -moz-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);+  background-image: -ms-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);+  background-image: -o-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);+  background-image: linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);+}++.progress-info .bar {+  background-color: #4bb1cf;+  background-image: -moz-linear-gradient(top, #5bc0de, #339bb9);+  background-image: -ms-linear-gradient(top, #5bc0de, #339bb9);+  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#5bc0de), to(#339bb9));+  background-image: -webkit-linear-gradient(top, #5bc0de, #339bb9);+  background-image: -o-linear-gradient(top, #5bc0de, #339bb9);+  background-image: linear-gradient(top, #5bc0de, #339bb9);+  background-repeat: repeat-x;+  filter: progid:dximagetransform.microsoft.gradient(startColorstr='#5bc0de', endColorstr='#339bb9', GradientType=0);+}++.progress-info.progress-striped .bar {+  background-color: #5bc0de;+  background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));+  background-image: -webkit-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);+  background-image: -moz-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);+  background-image: -ms-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);+  background-image: -o-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);+  background-image: linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);+}++.progress-warning .bar {+  background-color: #faa732;+  background-image: -moz-linear-gradient(top, #fbb450, #f89406);+  background-image: -ms-linear-gradient(top, #fbb450, #f89406);+  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fbb450), to(#f89406));+  background-image: -webkit-linear-gradient(top, #fbb450, #f89406);+  background-image: -o-linear-gradient(top, #fbb450, #f89406);+  background-image: linear-gradient(top, #fbb450, #f89406);+  background-repeat: repeat-x;+  filter: progid:dximagetransform.microsoft.gradient(startColorstr='#fbb450', endColorstr='#f89406', GradientType=0);+}++.progress-warning.progress-striped .bar {+  background-color: #fbb450;+  background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));+  background-image: -webkit-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);+  background-image: -moz-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);+  background-image: -ms-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);+  background-image: -o-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);+  background-image: linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);+}++.accordion {+  margin-bottom: 18px;+}++.accordion-group {+  margin-bottom: 2px;+  border: 1px solid #e5e5e5;+  -webkit-border-radius: 4px;+     -moz-border-radius: 4px;+          border-radius: 4px;+}++.accordion-heading {+  border-bottom: 0;+}++.accordion-heading .accordion-toggle {+  display: block;+  padding: 8px 15px;+}++.accordion-toggle {+  cursor: pointer;+}++.accordion-inner {+  padding: 9px 15px;+  border-top: 1px solid #e5e5e5;+}++.carousel {+  position: relative;+  margin-bottom: 18px;+  line-height: 1;+}++.carousel-inner {+  position: relative;+  width: 100%;+  overflow: hidden;+}++.carousel .item {+  position: relative;+  display: none;+  -webkit-transition: 0.6s ease-in-out left;+     -moz-transition: 0.6s ease-in-out left;+      -ms-transition: 0.6s ease-in-out left;+       -o-transition: 0.6s ease-in-out left;+          transition: 0.6s ease-in-out left;+}++.carousel .item > img {+  display: block;+  line-height: 1;+}++.carousel .active,+.carousel .next,+.carousel .prev {+  display: block;+}++.carousel .active {+  left: 0;+}++.carousel .next,+.carousel .prev {+  position: absolute;+  top: 0;+  width: 100%;+}++.carousel .next {+  left: 100%;+}++.carousel .prev {+  left: -100%;+}++.carousel .next.left,+.carousel .prev.right {+  left: 0;+}++.carousel .active.left {+  left: -100%;+}++.carousel .active.right {+  left: 100%;+}++.carousel-control {+  position: absolute;+  top: 40%;+  left: 15px;+  width: 40px;+  height: 40px;+  margin-top: -20px;+  font-size: 60px;+  font-weight: 100;+  line-height: 30px;+  color: #ffffff;+  text-align: center;+  background: #222222;+  border: 3px solid #ffffff;+  -webkit-border-radius: 23px;+     -moz-border-radius: 23px;+          border-radius: 23px;+  opacity: 0.5;+  filter: alpha(opacity=50);+}++.carousel-control.right {+  right: 15px;+  left: auto;+}++.carousel-control:hover {+  color: #ffffff;+  text-decoration: none;+  opacity: 0.9;+  filter: alpha(opacity=90);+}++.carousel-caption {+  position: absolute;+  right: 0;+  bottom: 0;+  left: 0;+  padding: 10px 15px 5px;+  background: #333333;+  background: rgba(0, 0, 0, 0.75);+}++.carousel-caption h4,+.carousel-caption p {+  color: #ffffff;+}++.hero-unit {+  padding: 60px;+  margin-bottom: 30px;+  background-color: #eeeeee;+  -webkit-border-radius: 6px;+     -moz-border-radius: 6px;+          border-radius: 6px;+}++.hero-unit h1 {+  margin-bottom: 0;+  font-size: 60px;+  line-height: 1;+  letter-spacing: -1px;+  color: inherit;+}++.hero-unit p {+  font-size: 18px;+  font-weight: 200;+  line-height: 27px;+  color: inherit;+}++.pull-right {+  float: right;+}++.pull-left {+  float: left;+}++.hide {+  display: none;+}++.show {+  display: block;+}++.invisible {+  visibility: hidden;+}
+ static/favicon.ico view

binary file changed (absent → 405 bytes)

+ static/img/glyphicons-halflings-white.png view

binary file changed (absent → 4352 bytes)

+ static/img/glyphicons-halflings.png view

binary file changed (absent → 4352 bytes)

+ static/jquery.full.js view
@@ -0,0 +1,9404 @@+/*!+ * jQuery JavaScript Library v1.7.2+ * http://jquery.com/+ *+ * Copyright 2011, John Resig+ * Dual licensed under the MIT or GPL Version 2 licenses.+ * http://jquery.org/license+ *+ * Includes Sizzle.js+ * http://sizzlejs.com/+ * Copyright 2011, The Dojo Foundation+ * Released under the MIT, BSD, and GPL Licenses.+ *+ * Date: Wed Mar 21 12:46:34 2012 -0700+ */+(function( window, undefined ) {++// Use the correct document accordingly with window argument (sandbox)+var document = window.document,+	navigator = window.navigator,+	location = window.location;+var jQuery = (function() {++// Define a local copy of jQuery+var jQuery = function( selector, context ) {+		// The jQuery object is actually just the init constructor 'enhanced'+		return new jQuery.fn.init( selector, context, rootjQuery );+	},++	// Map over jQuery in case of overwrite+	_jQuery = window.jQuery,++	// Map over the $ in case of overwrite+	_$ = window.$,++	// A central reference to the root jQuery(document)+	rootjQuery,++	// A simple way to check for HTML strings or ID strings+	// Prioritize #id over <tag> to avoid XSS via location.hash (#9521)+	quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,++	// Check if a string has a non-whitespace character in it+	rnotwhite = /\S/,++	// Used for trimming whitespace+	trimLeft = /^\s+/,+	trimRight = /\s+$/,++	// Match a standalone tag+	rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,++	// JSON RegExp+	rvalidchars = /^[\],:{}\s]*$/,+	rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,+	rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,+	rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,++	// Useragent RegExp+	rwebkit = /(webkit)[ \/]([\w.]+)/,+	ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,+	rmsie = /(msie) ([\w.]+)/,+	rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,++	// Matches dashed string for camelizing+	rdashAlpha = /-([a-z]|[0-9])/ig,+	rmsPrefix = /^-ms-/,++	// Used by jQuery.camelCase as callback to replace()+	fcamelCase = function( all, letter ) {+		return ( letter + "" ).toUpperCase();+	},++	// Keep a UserAgent string for use with jQuery.browser+	userAgent = navigator.userAgent,++	// For matching the engine and version of the browser+	browserMatch,++	// The deferred used on DOM ready+	readyList,++	// The ready event handler+	DOMContentLoaded,++	// Save a reference to some core methods+	toString = Object.prototype.toString,+	hasOwn = Object.prototype.hasOwnProperty,+	push = Array.prototype.push,+	slice = Array.prototype.slice,+	trim = String.prototype.trim,+	indexOf = Array.prototype.indexOf,++	// [[Class]] -> type pairs+	class2type = {};++jQuery.fn = jQuery.prototype = {+	constructor: jQuery,+	init: function( selector, context, rootjQuery ) {+		var match, elem, ret, doc;++		// Handle $(""), $(null), or $(undefined)+		if ( !selector ) {+			return this;+		}++		// Handle $(DOMElement)+		if ( selector.nodeType ) {+			this.context = this[0] = selector;+			this.length = 1;+			return this;+		}++		// The body element only exists once, optimize finding it+		if ( selector === "body" && !context && document.body ) {+			this.context = document;+			this[0] = document.body;+			this.selector = selector;+			this.length = 1;+			return this;+		}++		// Handle HTML strings+		if ( typeof selector === "string" ) {+			// Are we dealing with HTML string or an ID?+			if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {+				// Assume that strings that start and end with <> are HTML and skip the regex check+				match = [ null, selector, null ];++			} else {+				match = quickExpr.exec( selector );+			}++			// Verify a match, and that no context was specified for #id+			if ( match && (match[1] || !context) ) {++				// HANDLE: $(html) -> $(array)+				if ( match[1] ) {+					context = context instanceof jQuery ? context[0] : context;+					doc = ( context ? context.ownerDocument || context : document );++					// If a single string is passed in and it's a single tag+					// just do a createElement and skip the rest+					ret = rsingleTag.exec( selector );++					if ( ret ) {+						if ( jQuery.isPlainObject( context ) ) {+							selector = [ document.createElement( ret[1] ) ];+							jQuery.fn.attr.call( selector, context, true );++						} else {+							selector = [ doc.createElement( ret[1] ) ];+						}++					} else {+						ret = jQuery.buildFragment( [ match[1] ], [ doc ] );+						selector = ( ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment ).childNodes;+					}++					return jQuery.merge( this, selector );++				// HANDLE: $("#id")+				} else {+					elem = document.getElementById( match[2] );++					// Check parentNode to catch when Blackberry 4.6 returns+					// nodes that are no longer in the document #6963+					if ( elem && elem.parentNode ) {+						// Handle the case where IE and Opera return items+						// by name instead of ID+						if ( elem.id !== match[2] ) {+							return rootjQuery.find( selector );+						}++						// Otherwise, we inject the element directly into the jQuery object+						this.length = 1;+						this[0] = elem;+					}++					this.context = document;+					this.selector = selector;+					return this;+				}++			// HANDLE: $(expr, $(...))+			} else if ( !context || context.jquery ) {+				return ( context || rootjQuery ).find( selector );++			// HANDLE: $(expr, context)+			// (which is just equivalent to: $(context).find(expr)+			} else {+				return this.constructor( context ).find( selector );+			}++		// HANDLE: $(function)+		// Shortcut for document ready+		} else if ( jQuery.isFunction( selector ) ) {+			return rootjQuery.ready( selector );+		}++		if ( selector.selector !== undefined ) {+			this.selector = selector.selector;+			this.context = selector.context;+		}++		return jQuery.makeArray( selector, this );+	},++	// Start with an empty selector+	selector: "",++	// The current version of jQuery being used+	jquery: "1.7.2",++	// The default length of a jQuery object is 0+	length: 0,++	// The number of elements contained in the matched element set+	size: function() {+		return this.length;+	},++	toArray: function() {+		return slice.call( this, 0 );+	},++	// Get the Nth element in the matched element set OR+	// Get the whole matched element set as a clean array+	get: function( num ) {+		return num == null ?++			// Return a 'clean' array+			this.toArray() :++			// Return just the object+			( num < 0 ? this[ this.length + num ] : this[ num ] );+	},++	// Take an array of elements and push it onto the stack+	// (returning the new matched element set)+	pushStack: function( elems, name, selector ) {+		// Build a new jQuery matched element set+		var ret = this.constructor();++		if ( jQuery.isArray( elems ) ) {+			push.apply( ret, elems );++		} else {+			jQuery.merge( ret, elems );+		}++		// Add the old object onto the stack (as a reference)+		ret.prevObject = this;++		ret.context = this.context;++		if ( name === "find" ) {+			ret.selector = this.selector + ( this.selector ? " " : "" ) + selector;+		} else if ( name ) {+			ret.selector = this.selector + "." + name + "(" + selector + ")";+		}++		// Return the newly-formed element set+		return ret;+	},++	// Execute a callback for every element in the matched set.+	// (You can seed the arguments with an array of args, but this is+	// only used internally.)+	each: function( callback, args ) {+		return jQuery.each( this, callback, args );+	},++	ready: function( fn ) {+		// Attach the listeners+		jQuery.bindReady();++		// Add the callback+		readyList.add( fn );++		return this;+	},++	eq: function( i ) {+		i = +i;+		return i === -1 ?+			this.slice( i ) :+			this.slice( i, i + 1 );+	},++	first: function() {+		return this.eq( 0 );+	},++	last: function() {+		return this.eq( -1 );+	},++	slice: function() {+		return this.pushStack( slice.apply( this, arguments ),+			"slice", slice.call(arguments).join(",") );+	},++	map: function( callback ) {+		return this.pushStack( jQuery.map(this, function( elem, i ) {+			return callback.call( elem, i, elem );+		}));+	},++	end: function() {+		return this.prevObject || this.constructor(null);+	},++	// For internal use only.+	// Behaves like an Array's method, not like a jQuery method.+	push: push,+	sort: [].sort,+	splice: [].splice+};++// Give the init function the jQuery prototype for later instantiation+jQuery.fn.init.prototype = jQuery.fn;++jQuery.extend = jQuery.fn.extend = function() {+	var options, name, src, copy, copyIsArray, clone,+		target = arguments[0] || {},+		i = 1,+		length = arguments.length,+		deep = false;++	// Handle a deep copy situation+	if ( typeof target === "boolean" ) {+		deep = target;+		target = arguments[1] || {};+		// skip the boolean and the target+		i = 2;+	}++	// Handle case when target is a string or something (possible in deep copy)+	if ( typeof target !== "object" && !jQuery.isFunction(target) ) {+		target = {};+	}++	// extend jQuery itself if only one argument is passed+	if ( length === i ) {+		target = this;+		--i;+	}++	for ( ; i < length; i++ ) {+		// Only deal with non-null/undefined values+		if ( (options = arguments[ i ]) != null ) {+			// Extend the base object+			for ( name in options ) {+				src = target[ name ];+				copy = options[ name ];++				// Prevent never-ending loop+				if ( target === copy ) {+					continue;+				}++				// Recurse if we're merging plain objects or arrays+				if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {+					if ( copyIsArray ) {+						copyIsArray = false;+						clone = src && jQuery.isArray(src) ? src : [];++					} else {+						clone = src && jQuery.isPlainObject(src) ? src : {};+					}++					// Never move original objects, clone them+					target[ name ] = jQuery.extend( deep, clone, copy );++				// Don't bring in undefined values+				} else if ( copy !== undefined ) {+					target[ name ] = copy;+				}+			}+		}+	}++	// Return the modified object+	return target;+};++jQuery.extend({+	noConflict: function( deep ) {+		if ( window.$ === jQuery ) {+			window.$ = _$;+		}++		if ( deep && window.jQuery === jQuery ) {+			window.jQuery = _jQuery;+		}++		return jQuery;+	},++	// Is the DOM ready to be used? Set to true once it occurs.+	isReady: false,++	// A counter to track how many items to wait for before+	// the ready event fires. See #6781+	readyWait: 1,++	// Hold (or release) the ready event+	holdReady: function( hold ) {+		if ( hold ) {+			jQuery.readyWait++;+		} else {+			jQuery.ready( true );+		}+	},++	// Handle when the DOM is ready+	ready: function( wait ) {+		// Either a released hold or an DOMready/load event and not yet ready+		if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) {+			// Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).+			if ( !document.body ) {+				return setTimeout( jQuery.ready, 1 );+			}++			// Remember that the DOM is ready+			jQuery.isReady = true;++			// If a normal DOM Ready event fired, decrement, and wait if need be+			if ( wait !== true && --jQuery.readyWait > 0 ) {+				return;+			}++			// If there are functions bound, to execute+			readyList.fireWith( document, [ jQuery ] );++			// Trigger any bound ready events+			if ( jQuery.fn.trigger ) {+				jQuery( document ).trigger( "ready" ).off( "ready" );+			}+		}+	},++	bindReady: function() {+		if ( readyList ) {+			return;+		}++		readyList = jQuery.Callbacks( "once memory" );++		// Catch cases where $(document).ready() is called after the+		// browser event has already occurred.+		if ( document.readyState === "complete" ) {+			// Handle it asynchronously to allow scripts the opportunity to delay ready+			return setTimeout( jQuery.ready, 1 );+		}++		// Mozilla, Opera and webkit nightlies currently support this event+		if ( document.addEventListener ) {+			// Use the handy event callback+			document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );++			// A fallback to window.onload, that will always work+			window.addEventListener( "load", jQuery.ready, false );++		// If IE event model is used+		} else if ( document.attachEvent ) {+			// ensure firing before onload,+			// maybe late but safe also for iframes+			document.attachEvent( "onreadystatechange", DOMContentLoaded );++			// A fallback to window.onload, that will always work+			window.attachEvent( "onload", jQuery.ready );++			// If IE and not a frame+			// continually check to see if the document is ready+			var toplevel = false;++			try {+				toplevel = window.frameElement == null;+			} catch(e) {}++			if ( document.documentElement.doScroll && toplevel ) {+				doScrollCheck();+			}+		}+	},++	// See test/unit/core.js for details concerning isFunction.+	// Since version 1.3, DOM methods and functions like alert+	// aren't supported. They return false on IE (#2968).+	isFunction: function( obj ) {+		return jQuery.type(obj) === "function";+	},++	isArray: Array.isArray || function( obj ) {+		return jQuery.type(obj) === "array";+	},++	isWindow: function( obj ) {+		return obj != null && obj == obj.window;+	},++	isNumeric: function( obj ) {+		return !isNaN( parseFloat(obj) ) && isFinite( obj );+	},++	type: function( obj ) {+		return obj == null ?+			String( obj ) :+			class2type[ toString.call(obj) ] || "object";+	},++	isPlainObject: function( obj ) {+		// Must be an Object.+		// Because of IE, we also have to check the presence of the constructor property.+		// Make sure that DOM nodes and window objects don't pass through, as well+		if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {+			return false;+		}++		try {+			// Not own constructor property must be Object+			if ( obj.constructor &&+				!hasOwn.call(obj, "constructor") &&+				!hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {+				return false;+			}+		} catch ( e ) {+			// IE8,9 Will throw exceptions on certain host objects #9897+			return false;+		}++		// Own properties are enumerated firstly, so to speed up,+		// if last one is own, then all properties are own.++		var key;+		for ( key in obj ) {}++		return key === undefined || hasOwn.call( obj, key );+	},++	isEmptyObject: function( obj ) {+		for ( var name in obj ) {+			return false;+		}+		return true;+	},++	error: function( msg ) {+		throw new Error( msg );+	},++	parseJSON: function( data ) {+		if ( typeof data !== "string" || !data ) {+			return null;+		}++		// Make sure leading/trailing whitespace is removed (IE can't handle it)+		data = jQuery.trim( data );++		// Attempt to parse using the native JSON parser first+		if ( window.JSON && window.JSON.parse ) {+			return window.JSON.parse( data );+		}++		// Make sure the incoming data is actual JSON+		// Logic borrowed from http://json.org/json2.js+		if ( rvalidchars.test( data.replace( rvalidescape, "@" )+			.replace( rvalidtokens, "]" )+			.replace( rvalidbraces, "")) ) {++			return ( new Function( "return " + data ) )();++		}+		jQuery.error( "Invalid JSON: " + data );+	},++	// Cross-browser xml parsing+	parseXML: function( data ) {+		if ( typeof data !== "string" || !data ) {+			return null;+		}+		var xml, tmp;+		try {+			if ( window.DOMParser ) { // Standard+				tmp = new DOMParser();+				xml = tmp.parseFromString( data , "text/xml" );+			} else { // IE+				xml = new ActiveXObject( "Microsoft.XMLDOM" );+				xml.async = "false";+				xml.loadXML( data );+			}+		} catch( e ) {+			xml = undefined;+		}+		if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {+			jQuery.error( "Invalid XML: " + data );+		}+		return xml;+	},++	noop: function() {},++	// Evaluates a script in a global context+	// Workarounds based on findings by Jim Driscoll+	// http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context+	globalEval: function( data ) {+		if ( data && rnotwhite.test( data ) ) {+			// We use execScript on Internet Explorer+			// We use an anonymous function so that context is window+			// rather than jQuery in Firefox+			( window.execScript || function( data ) {+				window[ "eval" ].call( window, data );+			} )( data );+		}+	},++	// Convert dashed to camelCase; used by the css and data modules+	// Microsoft forgot to hump their vendor prefix (#9572)+	camelCase: function( string ) {+		return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );+	},++	nodeName: function( elem, name ) {+		return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();+	},++	// args is for internal usage only+	each: function( object, callback, args ) {+		var name, i = 0,+			length = object.length,+			isObj = length === undefined || jQuery.isFunction( object );++		if ( args ) {+			if ( isObj ) {+				for ( name in object ) {+					if ( callback.apply( object[ name ], args ) === false ) {+						break;+					}+				}+			} else {+				for ( ; i < length; ) {+					if ( callback.apply( object[ i++ ], args ) === false ) {+						break;+					}+				}+			}++		// A special, fast, case for the most common use of each+		} else {+			if ( isObj ) {+				for ( name in object ) {+					if ( callback.call( object[ name ], name, object[ name ] ) === false ) {+						break;+					}+				}+			} else {+				for ( ; i < length; ) {+					if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) {+						break;+					}+				}+			}+		}++		return object;+	},++	// Use native String.trim function wherever possible+	trim: trim ?+		function( text ) {+			return text == null ?+				"" :+				trim.call( text );+		} :++		// Otherwise use our own trimming functionality+		function( text ) {+			return text == null ?+				"" :+				text.toString().replace( trimLeft, "" ).replace( trimRight, "" );+		},++	// results is for internal usage only+	makeArray: function( array, results ) {+		var ret = results || [];++		if ( array != null ) {+			// The window, strings (and functions) also have 'length'+			// Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930+			var type = jQuery.type( array );++			if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {+				push.call( ret, array );+			} else {+				jQuery.merge( ret, array );+			}+		}++		return ret;+	},++	inArray: function( elem, array, i ) {+		var len;++		if ( array ) {+			if ( indexOf ) {+				return indexOf.call( array, elem, i );+			}++			len = array.length;+			i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;++			for ( ; i < len; i++ ) {+				// Skip accessing in sparse arrays+				if ( i in array && array[ i ] === elem ) {+					return i;+				}+			}+		}++		return -1;+	},++	merge: function( first, second ) {+		var i = first.length,+			j = 0;++		if ( typeof second.length === "number" ) {+			for ( var l = second.length; j < l; j++ ) {+				first[ i++ ] = second[ j ];+			}++		} else {+			while ( second[j] !== undefined ) {+				first[ i++ ] = second[ j++ ];+			}+		}++		first.length = i;++		return first;+	},++	grep: function( elems, callback, inv ) {+		var ret = [], retVal;+		inv = !!inv;++		// Go through the array, only saving the items+		// that pass the validator function+		for ( var i = 0, length = elems.length; i < length; i++ ) {+			retVal = !!callback( elems[ i ], i );+			if ( inv !== retVal ) {+				ret.push( elems[ i ] );+			}+		}++		return ret;+	},++	// arg is for internal usage only+	map: function( elems, callback, arg ) {+		var value, key, ret = [],+			i = 0,+			length = elems.length,+			// jquery objects are treated as arrays+			isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ;++		// Go through the array, translating each of the items to their+		if ( isArray ) {+			for ( ; i < length; i++ ) {+				value = callback( elems[ i ], i, arg );++				if ( value != null ) {+					ret[ ret.length ] = value;+				}+			}++		// Go through every key on the object,+		} else {+			for ( key in elems ) {+				value = callback( elems[ key ], key, arg );++				if ( value != null ) {+					ret[ ret.length ] = value;+				}+			}+		}++		// Flatten any nested arrays+		return ret.concat.apply( [], ret );+	},++	// A global GUID counter for objects+	guid: 1,++	// Bind a function to a context, optionally partially applying any+	// arguments.+	proxy: function( fn, context ) {+		if ( typeof context === "string" ) {+			var tmp = fn[ context ];+			context = fn;+			fn = tmp;+		}++		// Quick check to determine if target is callable, in the spec+		// this throws a TypeError, but we will just return undefined.+		if ( !jQuery.isFunction( fn ) ) {+			return undefined;+		}++		// Simulated bind+		var args = slice.call( arguments, 2 ),+			proxy = function() {+				return fn.apply( context, args.concat( slice.call( arguments ) ) );+			};++		// Set the guid of unique handler to the same of original handler, so it can be removed+		proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;++		return proxy;+	},++	// Mutifunctional method to get and set values to a collection+	// The value/s can optionally be executed if it's a function+	access: function( elems, fn, key, value, chainable, emptyGet, pass ) {+		var exec,+			bulk = key == null,+			i = 0,+			length = elems.length;++		// Sets many values+		if ( key && typeof key === "object" ) {+			for ( i in key ) {+				jQuery.access( elems, fn, i, key[i], 1, emptyGet, value );+			}+			chainable = 1;++		// Sets one value+		} else if ( value !== undefined ) {+			// Optionally, function values get executed if exec is true+			exec = pass === undefined && jQuery.isFunction( value );++			if ( bulk ) {+				// Bulk operations only iterate when executing function values+				if ( exec ) {+					exec = fn;+					fn = function( elem, key, value ) {+						return exec.call( jQuery( elem ), value );+					};++				// Otherwise they run against the entire set+				} else {+					fn.call( elems, value );+					fn = null;+				}+			}++			if ( fn ) {+				for (; i < length; i++ ) {+					fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );+				}+			}++			chainable = 1;+		}++		return chainable ?+			elems :++			// Gets+			bulk ?+				fn.call( elems ) :+				length ? fn( elems[0], key ) : emptyGet;+	},++	now: function() {+		return ( new Date() ).getTime();+	},++	// Use of jQuery.browser is frowned upon.+	// More details: http://docs.jquery.com/Utilities/jQuery.browser+	uaMatch: function( ua ) {+		ua = ua.toLowerCase();++		var match = rwebkit.exec( ua ) ||+			ropera.exec( ua ) ||+			rmsie.exec( ua ) ||+			ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||+			[];++		return { browser: match[1] || "", version: match[2] || "0" };+	},++	sub: function() {+		function jQuerySub( selector, context ) {+			return new jQuerySub.fn.init( selector, context );+		}+		jQuery.extend( true, jQuerySub, this );+		jQuerySub.superclass = this;+		jQuerySub.fn = jQuerySub.prototype = this();+		jQuerySub.fn.constructor = jQuerySub;+		jQuerySub.sub = this.sub;+		jQuerySub.fn.init = function init( selector, context ) {+			if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {+				context = jQuerySub( context );+			}++			return jQuery.fn.init.call( this, selector, context, rootjQuerySub );+		};+		jQuerySub.fn.init.prototype = jQuerySub.fn;+		var rootjQuerySub = jQuerySub(document);+		return jQuerySub;+	},++	browser: {}+});++// Populate the class2type map+jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {+	class2type[ "[object " + name + "]" ] = name.toLowerCase();+});++browserMatch = jQuery.uaMatch( userAgent );+if ( browserMatch.browser ) {+	jQuery.browser[ browserMatch.browser ] = true;+	jQuery.browser.version = browserMatch.version;+}++// Deprecated, use jQuery.browser.webkit instead+if ( jQuery.browser.webkit ) {+	jQuery.browser.safari = true;+}++// IE doesn't match non-breaking spaces with \s+if ( rnotwhite.test( "\xA0" ) ) {+	trimLeft = /^[\s\xA0]+/;+	trimRight = /[\s\xA0]+$/;+}++// All jQuery objects should point back to these+rootjQuery = jQuery(document);++// Cleanup functions for the document ready method+if ( document.addEventListener ) {+	DOMContentLoaded = function() {+		document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );+		jQuery.ready();+	};++} else if ( document.attachEvent ) {+	DOMContentLoaded = function() {+		// Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).+		if ( document.readyState === "complete" ) {+			document.detachEvent( "onreadystatechange", DOMContentLoaded );+			jQuery.ready();+		}+	};+}++// The DOM ready check for Internet Explorer+function doScrollCheck() {+	if ( jQuery.isReady ) {+		return;+	}++	try {+		// If IE is used, use the trick by Diego Perini+		// http://javascript.nwbox.com/IEContentLoaded/+		document.documentElement.doScroll("left");+	} catch(e) {+		setTimeout( doScrollCheck, 1 );+		return;+	}++	// and execute any waiting functions+	jQuery.ready();+}++return jQuery;++})();+++// String to Object flags format cache+var flagsCache = {};++// Convert String-formatted flags into Object-formatted ones and store in cache+function createFlags( flags ) {+	var object = flagsCache[ flags ] = {},+		i, length;+	flags = flags.split( /\s+/ );+	for ( i = 0, length = flags.length; i < length; i++ ) {+		object[ flags[i] ] = true;+	}+	return object;+}++/*+ * Create a callback list using the following parameters:+ *+ *	flags:	an optional list of space-separated flags that will change how+ *			the callback list behaves+ *+ * By default a callback list will act like an event callback list and can be+ * "fired" multiple times.+ *+ * Possible flags:+ *+ *	once:			will ensure the callback list can only be fired once (like a Deferred)+ *+ *	memory:			will keep track of previous values and will call any callback added+ *					after the list has been fired right away with the latest "memorized"+ *					values (like a Deferred)+ *+ *	unique:			will ensure a callback can only be added once (no duplicate in the list)+ *+ *	stopOnFalse:	interrupt callings when a callback returns false+ *+ */+jQuery.Callbacks = function( flags ) {++	// Convert flags from String-formatted to Object-formatted+	// (we check in cache first)+	flags = flags ? ( flagsCache[ flags ] || createFlags( flags ) ) : {};++	var // Actual callback list+		list = [],+		// Stack of fire calls for repeatable lists+		stack = [],+		// Last fire value (for non-forgettable lists)+		memory,+		// Flag to know if list was already fired+		fired,+		// Flag to know if list is currently firing+		firing,+		// First callback to fire (used internally by add and fireWith)+		firingStart,+		// End of the loop when firing+		firingLength,+		// Index of currently firing callback (modified by remove if needed)+		firingIndex,+		// Add one or several callbacks to the list+		add = function( args ) {+			var i,+				length,+				elem,+				type,+				actual;+			for ( i = 0, length = args.length; i < length; i++ ) {+				elem = args[ i ];+				type = jQuery.type( elem );+				if ( type === "array" ) {+					// Inspect recursively+					add( elem );+				} else if ( type === "function" ) {+					// Add if not in unique mode and callback is not in+					if ( !flags.unique || !self.has( elem ) ) {+						list.push( elem );+					}+				}+			}+		},+		// Fire callbacks+		fire = function( context, args ) {+			args = args || [];+			memory = !flags.memory || [ context, args ];+			fired = true;+			firing = true;+			firingIndex = firingStart || 0;+			firingStart = 0;+			firingLength = list.length;+			for ( ; list && firingIndex < firingLength; firingIndex++ ) {+				if ( list[ firingIndex ].apply( context, args ) === false && flags.stopOnFalse ) {+					memory = true; // Mark as halted+					break;+				}+			}+			firing = false;+			if ( list ) {+				if ( !flags.once ) {+					if ( stack && stack.length ) {+						memory = stack.shift();+						self.fireWith( memory[ 0 ], memory[ 1 ] );+					}+				} else if ( memory === true ) {+					self.disable();+				} else {+					list = [];+				}+			}+		},+		// Actual Callbacks object+		self = {+			// Add a callback or a collection of callbacks to the list+			add: function() {+				if ( list ) {+					var length = list.length;+					add( arguments );+					// Do we need to add the callbacks to the+					// current firing batch?+					if ( firing ) {+						firingLength = list.length;+					// With memory, if we're not firing then+					// we should call right away, unless previous+					// firing was halted (stopOnFalse)+					} else if ( memory && memory !== true ) {+						firingStart = length;+						fire( memory[ 0 ], memory[ 1 ] );+					}+				}+				return this;+			},+			// Remove a callback from the list+			remove: function() {+				if ( list ) {+					var args = arguments,+						argIndex = 0,+						argLength = args.length;+					for ( ; argIndex < argLength ; argIndex++ ) {+						for ( var i = 0; i < list.length; i++ ) {+							if ( args[ argIndex ] === list[ i ] ) {+								// Handle firingIndex and firingLength+								if ( firing ) {+									if ( i <= firingLength ) {+										firingLength--;+										if ( i <= firingIndex ) {+											firingIndex--;+										}+									}+								}+								// Remove the element+								list.splice( i--, 1 );+								// If we have some unicity property then+								// we only need to do this once+								if ( flags.unique ) {+									break;+								}+							}+						}+					}+				}+				return this;+			},+			// Control if a given callback is in the list+			has: function( fn ) {+				if ( list ) {+					var i = 0,+						length = list.length;+					for ( ; i < length; i++ ) {+						if ( fn === list[ i ] ) {+							return true;+						}+					}+				}+				return false;+			},+			// Remove all callbacks from the list+			empty: function() {+				list = [];+				return this;+			},+			// Have the list do nothing anymore+			disable: function() {+				list = stack = memory = undefined;+				return this;+			},+			// Is it disabled?+			disabled: function() {+				return !list;+			},+			// Lock the list in its current state+			lock: function() {+				stack = undefined;+				if ( !memory || memory === true ) {+					self.disable();+				}+				return this;+			},+			// Is it locked?+			locked: function() {+				return !stack;+			},+			// Call all callbacks with the given context and arguments+			fireWith: function( context, args ) {+				if ( stack ) {+					if ( firing ) {+						if ( !flags.once ) {+							stack.push( [ context, args ] );+						}+					} else if ( !( flags.once && memory ) ) {+						fire( context, args );+					}+				}+				return this;+			},+			// Call all the callbacks with the given arguments+			fire: function() {+				self.fireWith( this, arguments );+				return this;+			},+			// To know if the callbacks have already been called at least once+			fired: function() {+				return !!fired;+			}+		};++	return self;+};+++++var // Static reference to slice+	sliceDeferred = [].slice;++jQuery.extend({++	Deferred: function( func ) {+		var doneList = jQuery.Callbacks( "once memory" ),+			failList = jQuery.Callbacks( "once memory" ),+			progressList = jQuery.Callbacks( "memory" ),+			state = "pending",+			lists = {+				resolve: doneList,+				reject: failList,+				notify: progressList+			},+			promise = {+				done: doneList.add,+				fail: failList.add,+				progress: progressList.add,++				state: function() {+					return state;+				},++				// Deprecated+				isResolved: doneList.fired,+				isRejected: failList.fired,++				then: function( doneCallbacks, failCallbacks, progressCallbacks ) {+					deferred.done( doneCallbacks ).fail( failCallbacks ).progress( progressCallbacks );+					return this;+				},+				always: function() {+					deferred.done.apply( deferred, arguments ).fail.apply( deferred, arguments );+					return this;+				},+				pipe: function( fnDone, fnFail, fnProgress ) {+					return jQuery.Deferred(function( newDefer ) {+						jQuery.each( {+							done: [ fnDone, "resolve" ],+							fail: [ fnFail, "reject" ],+							progress: [ fnProgress, "notify" ]+						}, function( handler, data ) {+							var fn = data[ 0 ],+								action = data[ 1 ],+								returned;+							if ( jQuery.isFunction( fn ) ) {+								deferred[ handler ](function() {+									returned = fn.apply( this, arguments );+									if ( returned && jQuery.isFunction( returned.promise ) ) {+										returned.promise().then( newDefer.resolve, newDefer.reject, newDefer.notify );+									} else {+										newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] );+									}+								});+							} else {+								deferred[ handler ]( newDefer[ action ] );+							}+						});+					}).promise();+				},+				// Get a promise for this deferred+				// If obj is provided, the promise aspect is added to the object+				promise: function( obj ) {+					if ( obj == null ) {+						obj = promise;+					} else {+						for ( var key in promise ) {+							obj[ key ] = promise[ key ];+						}+					}+					return obj;+				}+			},+			deferred = promise.promise({}),+			key;++		for ( key in lists ) {+			deferred[ key ] = lists[ key ].fire;+			deferred[ key + "With" ] = lists[ key ].fireWith;+		}++		// Handle state+		deferred.done( function() {+			state = "resolved";+		}, failList.disable, progressList.lock ).fail( function() {+			state = "rejected";+		}, doneList.disable, progressList.lock );++		// Call given func if any+		if ( func ) {+			func.call( deferred, deferred );+		}++		// All done!+		return deferred;+	},++	// Deferred helper+	when: function( firstParam ) {+		var args = sliceDeferred.call( arguments, 0 ),+			i = 0,+			length = args.length,+			pValues = new Array( length ),+			count = length,+			pCount = length,+			deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ?+				firstParam :+				jQuery.Deferred(),+			promise = deferred.promise();+		function resolveFunc( i ) {+			return function( value ) {+				args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;+				if ( !( --count ) ) {+					deferred.resolveWith( deferred, args );+				}+			};+		}+		function progressFunc( i ) {+			return function( value ) {+				pValues[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;+				deferred.notifyWith( promise, pValues );+			};+		}+		if ( length > 1 ) {+			for ( ; i < length; i++ ) {+				if ( args[ i ] && args[ i ].promise && jQuery.isFunction( args[ i ].promise ) ) {+					args[ i ].promise().then( resolveFunc(i), deferred.reject, progressFunc(i) );+				} else {+					--count;+				}+			}+			if ( !count ) {+				deferred.resolveWith( deferred, args );+			}+		} else if ( deferred !== firstParam ) {+			deferred.resolveWith( deferred, length ? [ firstParam ] : [] );+		}+		return promise;+	}+});+++++jQuery.support = (function() {++	var support,+		all,+		a,+		select,+		opt,+		input,+		fragment,+		tds,+		events,+		eventName,+		i,+		isSupported,+		div = document.createElement( "div" ),+		documentElement = document.documentElement;++	// Preliminary tests+	div.setAttribute("className", "t");+	div.innerHTML = "   <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>";++	all = div.getElementsByTagName( "*" );+	a = div.getElementsByTagName( "a" )[ 0 ];++	// Can't get basic test support+	if ( !all || !all.length || !a ) {+		return {};+	}++	// First batch of supports tests+	select = document.createElement( "select" );+	opt = select.appendChild( document.createElement("option") );+	input = div.getElementsByTagName( "input" )[ 0 ];++	support = {+		// IE strips leading whitespace when .innerHTML is used+		leadingWhitespace: ( div.firstChild.nodeType === 3 ),++		// Make sure that tbody elements aren't automatically inserted+		// IE will insert them into empty tables+		tbody: !div.getElementsByTagName("tbody").length,++		// Make sure that link elements get serialized correctly by innerHTML+		// This requires a wrapper element in IE+		htmlSerialize: !!div.getElementsByTagName("link").length,++		// Get the style information from getAttribute+		// (IE uses .cssText instead)+		style: /top/.test( a.getAttribute("style") ),++		// Make sure that URLs aren't manipulated+		// (IE normalizes it by default)+		hrefNormalized: ( a.getAttribute("href") === "/a" ),++		// Make sure that element opacity exists+		// (IE uses filter instead)+		// Use a regex to work around a WebKit issue. See #5145+		opacity: /^0.55/.test( a.style.opacity ),++		// Verify style float existence+		// (IE uses styleFloat instead of cssFloat)+		cssFloat: !!a.style.cssFloat,++		// Make sure that if no value is specified for a checkbox+		// that it defaults to "on".+		// (WebKit defaults to "" instead)+		checkOn: ( input.value === "on" ),++		// Make sure that a selected-by-default option has a working selected property.+		// (WebKit defaults to false instead of true, IE too, if it's in an optgroup)+		optSelected: opt.selected,++		// Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)+		getSetAttribute: div.className !== "t",++		// Tests for enctype support on a form(#6743)+		enctype: !!document.createElement("form").enctype,++		// Makes sure cloning an html5 element does not cause problems+		// Where outerHTML is undefined, this still works+		html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav></:nav>",++		// Will be defined later+		submitBubbles: true,+		changeBubbles: true,+		focusinBubbles: false,+		deleteExpando: true,+		noCloneEvent: true,+		inlineBlockNeedsLayout: false,+		shrinkWrapBlocks: false,+		reliableMarginRight: true,+		pixelMargin: true+	};++	// jQuery.boxModel DEPRECATED in 1.3, use jQuery.support.boxModel instead+	jQuery.boxModel = support.boxModel = (document.compatMode === "CSS1Compat");++	// Make sure checked status is properly cloned+	input.checked = true;+	support.noCloneChecked = input.cloneNode( true ).checked;++	// Make sure that the options inside disabled selects aren't marked as disabled+	// (WebKit marks them as disabled)+	select.disabled = true;+	support.optDisabled = !opt.disabled;++	// Test to see if it's possible to delete an expando from an element+	// Fails in Internet Explorer+	try {+		delete div.test;+	} catch( e ) {+		support.deleteExpando = false;+	}++	if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {+		div.attachEvent( "onclick", function() {+			// Cloning a node shouldn't copy over any+			// bound event handlers (IE does this)+			support.noCloneEvent = false;+		});+		div.cloneNode( true ).fireEvent( "onclick" );+	}++	// Check if a radio maintains its value+	// after being appended to the DOM+	input = document.createElement("input");+	input.value = "t";+	input.setAttribute("type", "radio");+	support.radioValue = input.value === "t";++	input.setAttribute("checked", "checked");++	// #11217 - WebKit loses check when the name is after the checked attribute+	input.setAttribute( "name", "t" );++	div.appendChild( input );+	fragment = document.createDocumentFragment();+	fragment.appendChild( div.lastChild );++	// WebKit doesn't clone checked state correctly in fragments+	support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;++	// Check if a disconnected checkbox will retain its checked+	// value of true after appended to the DOM (IE6/7)+	support.appendChecked = input.checked;++	fragment.removeChild( input );+	fragment.appendChild( div );++	// Technique from Juriy Zaytsev+	// http://perfectionkills.com/detecting-event-support-without-browser-sniffing/+	// We only care about the case where non-standard event systems+	// are used, namely in IE. Short-circuiting here helps us to+	// avoid an eval call (in setAttribute) which can cause CSP+	// to go haywire. See: https://developer.mozilla.org/en/Security/CSP+	if ( div.attachEvent ) {+		for ( i in {+			submit: 1,+			change: 1,+			focusin: 1+		}) {+			eventName = "on" + i;+			isSupported = ( eventName in div );+			if ( !isSupported ) {+				div.setAttribute( eventName, "return;" );+				isSupported = ( typeof div[ eventName ] === "function" );+			}+			support[ i + "Bubbles" ] = isSupported;+		}+	}++	fragment.removeChild( div );++	// Null elements to avoid leaks in IE+	fragment = select = opt = div = input = null;++	// Run tests that need a body at doc ready+	jQuery(function() {+		var container, outer, inner, table, td, offsetSupport,+			marginDiv, conMarginTop, style, html, positionTopLeftWidthHeight,+			paddingMarginBorderVisibility, paddingMarginBorder,+			body = document.getElementsByTagName("body")[0];++		if ( !body ) {+			// Return for frameset docs that don't have a body+			return;+		}++		conMarginTop = 1;+		paddingMarginBorder = "padding:0;margin:0;border:";+		positionTopLeftWidthHeight = "position:absolute;top:0;left:0;width:1px;height:1px;";+		paddingMarginBorderVisibility = paddingMarginBorder + "0;visibility:hidden;";+		style = "style='" + positionTopLeftWidthHeight + paddingMarginBorder + "5px solid #000;";+		html = "<div " + style + "display:block;'><div style='" + paddingMarginBorder + "0;display:block;overflow:hidden;'></div></div>" ++			"<table " + style + "' cellpadding='0' cellspacing='0'>" ++			"<tr><td></td></tr></table>";++		container = document.createElement("div");+		container.style.cssText = paddingMarginBorderVisibility + "width:0;height:0;position:static;top:0;margin-top:" + conMarginTop + "px";+		body.insertBefore( container, body.firstChild );++		// Construct the test element+		div = document.createElement("div");+		container.appendChild( div );++		// Check if table cells still have offsetWidth/Height when they are set+		// to display:none and there are still other visible table cells in a+		// table row; if so, offsetWidth/Height are not reliable for use when+		// determining if an element has been hidden directly using+		// display:none (it is still safe to use offsets if a parent element is+		// hidden; don safety goggles and see bug #4512 for more information).+		// (only IE 8 fails this test)+		div.innerHTML = "<table><tr><td style='" + paddingMarginBorder + "0;display:none'></td><td>t</td></tr></table>";+		tds = div.getElementsByTagName( "td" );+		isSupported = ( tds[ 0 ].offsetHeight === 0 );++		tds[ 0 ].style.display = "";+		tds[ 1 ].style.display = "none";++		// Check if empty table cells still have offsetWidth/Height+		// (IE <= 8 fail this test)+		support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );++		// Check if div with explicit width and no margin-right incorrectly+		// gets computed margin-right based on width of container. For more+		// info see bug #3333+		// Fails in WebKit before Feb 2011 nightlies+		// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right+		if ( window.getComputedStyle ) {+			div.innerHTML = "";+			marginDiv = document.createElement( "div" );+			marginDiv.style.width = "0";+			marginDiv.style.marginRight = "0";+			div.style.width = "2px";+			div.appendChild( marginDiv );+			support.reliableMarginRight =+				( parseInt( ( window.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0;+		}++		if ( typeof div.style.zoom !== "undefined" ) {+			// Check if natively block-level elements act like inline-block+			// elements when setting their display to 'inline' and giving+			// them layout+			// (IE < 8 does this)+			div.innerHTML = "";+			div.style.width = div.style.padding = "1px";+			div.style.border = 0;+			div.style.overflow = "hidden";+			div.style.display = "inline";+			div.style.zoom = 1;+			support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 );++			// Check if elements with layout shrink-wrap their children+			// (IE 6 does this)+			div.style.display = "block";+			div.style.overflow = "visible";+			div.innerHTML = "<div style='width:5px;'></div>";+			support.shrinkWrapBlocks = ( div.offsetWidth !== 3 );+		}++		div.style.cssText = positionTopLeftWidthHeight + paddingMarginBorderVisibility;+		div.innerHTML = html;++		outer = div.firstChild;+		inner = outer.firstChild;+		td = outer.nextSibling.firstChild.firstChild;++		offsetSupport = {+			doesNotAddBorder: ( inner.offsetTop !== 5 ),+			doesAddBorderForTableAndCells: ( td.offsetTop === 5 )+		};++		inner.style.position = "fixed";+		inner.style.top = "20px";++		// safari subtracts parent border width here which is 5px+		offsetSupport.fixedPosition = ( inner.offsetTop === 20 || inner.offsetTop === 15 );+		inner.style.position = inner.style.top = "";++		outer.style.overflow = "hidden";+		outer.style.position = "relative";++		offsetSupport.subtractsBorderForOverflowNotVisible = ( inner.offsetTop === -5 );+		offsetSupport.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== conMarginTop );++		if ( window.getComputedStyle ) {+			div.style.marginTop = "1%";+			support.pixelMargin = ( window.getComputedStyle( div, null ) || { marginTop: 0 } ).marginTop !== "1%";+		}++		if ( typeof container.style.zoom !== "undefined" ) {+			container.style.zoom = 1;+		}++		body.removeChild( container );+		marginDiv = div = container = null;++		jQuery.extend( support, offsetSupport );+	});++	return support;+})();+++++var rbrace = /^(?:\{.*\}|\[.*\])$/,+	rmultiDash = /([A-Z])/g;++jQuery.extend({+	cache: {},++	// Please use with caution+	uuid: 0,++	// Unique for each copy of jQuery on the page+	// Non-digits removed to match rinlinejQuery+	expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),++	// The following elements throw uncatchable exceptions if you+	// attempt to add expando properties to them.+	noData: {+		"embed": true,+		// Ban all objects except for Flash (which handle expandos)+		"object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",+		"applet": true+	},++	hasData: function( elem ) {+		elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];+		return !!elem && !isEmptyDataObject( elem );+	},++	data: function( elem, name, data, pvt /* Internal Use Only */ ) {+		if ( !jQuery.acceptData( elem ) ) {+			return;+		}++		var privateCache, thisCache, ret,+			internalKey = jQuery.expando,+			getByName = typeof name === "string",++			// We have to handle DOM nodes and JS objects differently because IE6-7+			// can't GC object references properly across the DOM-JS boundary+			isNode = elem.nodeType,++			// Only DOM nodes need the global jQuery cache; JS object data is+			// attached directly to the object so GC can occur automatically+			cache = isNode ? jQuery.cache : elem,++			// Only defining an ID for JS objects if its cache already exists allows+			// the code to shortcut on the same path as a DOM node with no cache+			id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey,+			isEvents = name === "events";++		// Avoid doing any more work than we need to when trying to get data on an+		// object that has no data at all+		if ( (!id || !cache[id] || (!isEvents && !pvt && !cache[id].data)) && getByName && data === undefined ) {+			return;+		}++		if ( !id ) {+			// Only DOM nodes need a new unique ID for each element since their data+			// ends up in the global cache+			if ( isNode ) {+				elem[ internalKey ] = id = ++jQuery.uuid;+			} else {+				id = internalKey;+			}+		}++		if ( !cache[ id ] ) {+			cache[ id ] = {};++			// Avoids exposing jQuery metadata on plain JS objects when the object+			// is serialized using JSON.stringify+			if ( !isNode ) {+				cache[ id ].toJSON = jQuery.noop;+			}+		}++		// An object can be passed to jQuery.data instead of a key/value pair; this gets+		// shallow copied over onto the existing cache+		if ( typeof name === "object" || typeof name === "function" ) {+			if ( pvt ) {+				cache[ id ] = jQuery.extend( cache[ id ], name );+			} else {+				cache[ id ].data = jQuery.extend( cache[ id ].data, name );+			}+		}++		privateCache = thisCache = cache[ id ];++		// jQuery data() is stored in a separate object inside the object's internal data+		// cache in order to avoid key collisions between internal data and user-defined+		// data.+		if ( !pvt ) {+			if ( !thisCache.data ) {+				thisCache.data = {};+			}++			thisCache = thisCache.data;+		}++		if ( data !== undefined ) {+			thisCache[ jQuery.camelCase( name ) ] = data;+		}++		// Users should not attempt to inspect the internal events object using jQuery.data,+		// it is undocumented and subject to change. But does anyone listen? No.+		if ( isEvents && !thisCache[ name ] ) {+			return privateCache.events;+		}++		// Check for both converted-to-camel and non-converted data property names+		// If a data property was specified+		if ( getByName ) {++			// First Try to find as-is property data+			ret = thisCache[ name ];++			// Test for null|undefined property data+			if ( ret == null ) {++				// Try to find the camelCased property+				ret = thisCache[ jQuery.camelCase( name ) ];+			}+		} else {+			ret = thisCache;+		}++		return ret;+	},++	removeData: function( elem, name, pvt /* Internal Use Only */ ) {+		if ( !jQuery.acceptData( elem ) ) {+			return;+		}++		var thisCache, i, l,++			// Reference to internal data cache key+			internalKey = jQuery.expando,++			isNode = elem.nodeType,++			// See jQuery.data for more information+			cache = isNode ? jQuery.cache : elem,++			// See jQuery.data for more information+			id = isNode ? elem[ internalKey ] : internalKey;++		// If there is already no cache entry for this object, there is no+		// purpose in continuing+		if ( !cache[ id ] ) {+			return;+		}++		if ( name ) {++			thisCache = pvt ? cache[ id ] : cache[ id ].data;++			if ( thisCache ) {++				// Support array or space separated string names for data keys+				if ( !jQuery.isArray( name ) ) {++					// try the string as a key before any manipulation+					if ( name in thisCache ) {+						name = [ name ];+					} else {++						// split the camel cased version by spaces unless a key with the spaces exists+						name = jQuery.camelCase( name );+						if ( name in thisCache ) {+							name = [ name ];+						} else {+							name = name.split( " " );+						}+					}+				}++				for ( i = 0, l = name.length; i < l; i++ ) {+					delete thisCache[ name[i] ];+				}++				// If there is no data left in the cache, we want to continue+				// and let the cache object itself get destroyed+				if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) {+					return;+				}+			}+		}++		// See jQuery.data for more information+		if ( !pvt ) {+			delete cache[ id ].data;++			// Don't destroy the parent cache unless the internal data object+			// had been the only thing left in it+			if ( !isEmptyDataObject(cache[ id ]) ) {+				return;+			}+		}++		// Browsers that fail expando deletion also refuse to delete expandos on+		// the window, but it will allow it on all other JS objects; other browsers+		// don't care+		// Ensure that `cache` is not a window object #10080+		if ( jQuery.support.deleteExpando || !cache.setInterval ) {+			delete cache[ id ];+		} else {+			cache[ id ] = null;+		}++		// We destroyed the cache and need to eliminate the expando on the node to avoid+		// false lookups in the cache for entries that no longer exist+		if ( isNode ) {+			// IE does not allow us to delete expando properties from nodes,+			// nor does it have a removeAttribute function on Document nodes;+			// we must handle all of these cases+			if ( jQuery.support.deleteExpando ) {+				delete elem[ internalKey ];+			} else if ( elem.removeAttribute ) {+				elem.removeAttribute( internalKey );+			} else {+				elem[ internalKey ] = null;+			}+		}+	},++	// For internal use only.+	_data: function( elem, name, data ) {+		return jQuery.data( elem, name, data, true );+	},++	// A method for determining if a DOM node can handle the data expando+	acceptData: function( elem ) {+		if ( elem.nodeName ) {+			var match = jQuery.noData[ elem.nodeName.toLowerCase() ];++			if ( match ) {+				return !(match === true || elem.getAttribute("classid") !== match);+			}+		}++		return true;+	}+});++jQuery.fn.extend({+	data: function( key, value ) {+		var parts, part, attr, name, l,+			elem = this[0],+			i = 0,+			data = null;++		// Gets all values+		if ( key === undefined ) {+			if ( this.length ) {+				data = jQuery.data( elem );++				if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {+					attr = elem.attributes;+					for ( l = attr.length; i < l; i++ ) {+						name = attr[i].name;++						if ( name.indexOf( "data-" ) === 0 ) {+							name = jQuery.camelCase( name.substring(5) );++							dataAttr( elem, name, data[ name ] );+						}+					}+					jQuery._data( elem, "parsedAttrs", true );+				}+			}++			return data;+		}++		// Sets multiple values+		if ( typeof key === "object" ) {+			return this.each(function() {+				jQuery.data( this, key );+			});+		}++		parts = key.split( ".", 2 );+		parts[1] = parts[1] ? "." + parts[1] : "";+		part = parts[1] + "!";++		return jQuery.access( this, function( value ) {++			if ( value === undefined ) {+				data = this.triggerHandler( "getData" + part, [ parts[0] ] );++				// Try to fetch any internally stored data first+				if ( data === undefined && elem ) {+					data = jQuery.data( elem, key );+					data = dataAttr( elem, key, data );+				}++				return data === undefined && parts[1] ?+					this.data( parts[0] ) :+					data;+			}++			parts[1] = value;+			this.each(function() {+				var self = jQuery( this );++				self.triggerHandler( "setData" + part, parts );+				jQuery.data( this, key, value );+				self.triggerHandler( "changeData" + part, parts );+			});+		}, null, value, arguments.length > 1, null, false );+	},++	removeData: function( key ) {+		return this.each(function() {+			jQuery.removeData( this, key );+		});+	}+});++function dataAttr( elem, key, data ) {+	// If nothing was found internally, try to fetch any+	// data from the HTML5 data-* attribute+	if ( data === undefined && elem.nodeType === 1 ) {++		var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();++		data = elem.getAttribute( name );++		if ( typeof data === "string" ) {+			try {+				data = data === "true" ? true :+				data === "false" ? false :+				data === "null" ? null :+				jQuery.isNumeric( data ) ? +data :+					rbrace.test( data ) ? jQuery.parseJSON( data ) :+					data;+			} catch( e ) {}++			// Make sure we set the data so it isn't changed later+			jQuery.data( elem, key, data );++		} else {+			data = undefined;+		}+	}++	return data;+}++// checks a cache object for emptiness+function isEmptyDataObject( obj ) {+	for ( var name in obj ) {++		// if the public data object is empty, the private is still empty+		if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {+			continue;+		}+		if ( name !== "toJSON" ) {+			return false;+		}+	}++	return true;+}+++++function handleQueueMarkDefer( elem, type, src ) {+	var deferDataKey = type + "defer",+		queueDataKey = type + "queue",+		markDataKey = type + "mark",+		defer = jQuery._data( elem, deferDataKey );+	if ( defer &&+		( src === "queue" || !jQuery._data(elem, queueDataKey) ) &&+		( src === "mark" || !jQuery._data(elem, markDataKey) ) ) {+		// Give room for hard-coded callbacks to fire first+		// and eventually mark/queue something else on the element+		setTimeout( function() {+			if ( !jQuery._data( elem, queueDataKey ) &&+				!jQuery._data( elem, markDataKey ) ) {+				jQuery.removeData( elem, deferDataKey, true );+				defer.fire();+			}+		}, 0 );+	}+}++jQuery.extend({++	_mark: function( elem, type ) {+		if ( elem ) {+			type = ( type || "fx" ) + "mark";+			jQuery._data( elem, type, (jQuery._data( elem, type ) || 0) + 1 );+		}+	},++	_unmark: function( force, elem, type ) {+		if ( force !== true ) {+			type = elem;+			elem = force;+			force = false;+		}+		if ( elem ) {+			type = type || "fx";+			var key = type + "mark",+				count = force ? 0 : ( (jQuery._data( elem, key ) || 1) - 1 );+			if ( count ) {+				jQuery._data( elem, key, count );+			} else {+				jQuery.removeData( elem, key, true );+				handleQueueMarkDefer( elem, type, "mark" );+			}+		}+	},++	queue: function( elem, type, data ) {+		var q;+		if ( elem ) {+			type = ( type || "fx" ) + "queue";+			q = jQuery._data( elem, type );++			// Speed up dequeue by getting out quickly if this is just a lookup+			if ( data ) {+				if ( !q || jQuery.isArray(data) ) {+					q = jQuery._data( elem, type, jQuery.makeArray(data) );+				} else {+					q.push( data );+				}+			}+			return q || [];+		}+	},++	dequeue: function( elem, type ) {+		type = type || "fx";++		var queue = jQuery.queue( elem, type ),+			fn = queue.shift(),+			hooks = {};++		// If the fx queue is dequeued, always remove the progress sentinel+		if ( fn === "inprogress" ) {+			fn = queue.shift();+		}++		if ( fn ) {+			// Add a progress sentinel to prevent the fx queue from being+			// automatically dequeued+			if ( type === "fx" ) {+				queue.unshift( "inprogress" );+			}++			jQuery._data( elem, type + ".run", hooks );+			fn.call( elem, function() {+				jQuery.dequeue( elem, type );+			}, hooks );+		}++		if ( !queue.length ) {+			jQuery.removeData( elem, type + "queue " + type + ".run", true );+			handleQueueMarkDefer( elem, type, "queue" );+		}+	}+});++jQuery.fn.extend({+	queue: function( type, data ) {+		var setter = 2;++		if ( typeof type !== "string" ) {+			data = type;+			type = "fx";+			setter--;+		}++		if ( arguments.length < setter ) {+			return jQuery.queue( this[0], type );+		}++		return data === undefined ?+			this :+			this.each(function() {+				var queue = jQuery.queue( this, type, data );++				if ( type === "fx" && queue[0] !== "inprogress" ) {+					jQuery.dequeue( this, type );+				}+			});+	},+	dequeue: function( type ) {+		return this.each(function() {+			jQuery.dequeue( this, type );+		});+	},+	// Based off of the plugin by Clint Helfers, with permission.+	// http://blindsignals.com/index.php/2009/07/jquery-delay/+	delay: function( time, type ) {+		time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;+		type = type || "fx";++		return this.queue( type, function( next, hooks ) {+			var timeout = setTimeout( next, time );+			hooks.stop = function() {+				clearTimeout( timeout );+			};+		});+	},+	clearQueue: function( type ) {+		return this.queue( type || "fx", [] );+	},+	// Get a promise resolved when queues of a certain type+	// are emptied (fx is the type by default)+	promise: function( type, object ) {+		if ( typeof type !== "string" ) {+			object = type;+			type = undefined;+		}+		type = type || "fx";+		var defer = jQuery.Deferred(),+			elements = this,+			i = elements.length,+			count = 1,+			deferDataKey = type + "defer",+			queueDataKey = type + "queue",+			markDataKey = type + "mark",+			tmp;+		function resolve() {+			if ( !( --count ) ) {+				defer.resolveWith( elements, [ elements ] );+			}+		}+		while( i-- ) {+			if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) ||+					( jQuery.data( elements[ i ], queueDataKey, undefined, true ) ||+						jQuery.data( elements[ i ], markDataKey, undefined, true ) ) &&+					jQuery.data( elements[ i ], deferDataKey, jQuery.Callbacks( "once memory" ), true ) )) {+				count++;+				tmp.add( resolve );+			}+		}+		resolve();+		return defer.promise( object );+	}+});+++++var rclass = /[\n\t\r]/g,+	rspace = /\s+/,+	rreturn = /\r/g,+	rtype = /^(?:button|input)$/i,+	rfocusable = /^(?:button|input|object|select|textarea)$/i,+	rclickable = /^a(?:rea)?$/i,+	rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,+	getSetAttribute = jQuery.support.getSetAttribute,+	nodeHook, boolHook, fixSpecified;++jQuery.fn.extend({+	attr: function( name, value ) {+		return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 );+	},++	removeAttr: function( name ) {+		return this.each(function() {+			jQuery.removeAttr( this, name );+		});+	},++	prop: function( name, value ) {+		return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 );+	},++	removeProp: function( name ) {+		name = jQuery.propFix[ name ] || name;+		return this.each(function() {+			// try/catch handles cases where IE balks (such as removing a property on window)+			try {+				this[ name ] = undefined;+				delete this[ name ];+			} catch( e ) {}+		});+	},++	addClass: function( value ) {+		var classNames, i, l, elem,+			setClass, c, cl;++		if ( jQuery.isFunction( value ) ) {+			return this.each(function( j ) {+				jQuery( this ).addClass( value.call(this, j, this.className) );+			});+		}++		if ( value && typeof value === "string" ) {+			classNames = value.split( rspace );++			for ( i = 0, l = this.length; i < l; i++ ) {+				elem = this[ i ];++				if ( elem.nodeType === 1 ) {+					if ( !elem.className && classNames.length === 1 ) {+						elem.className = value;++					} else {+						setClass = " " + elem.className + " ";++						for ( c = 0, cl = classNames.length; c < cl; c++ ) {+							if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) {+								setClass += classNames[ c ] + " ";+							}+						}+						elem.className = jQuery.trim( setClass );+					}+				}+			}+		}++		return this;+	},++	removeClass: function( value ) {+		var classNames, i, l, elem, className, c, cl;++		if ( jQuery.isFunction( value ) ) {+			return this.each(function( j ) {+				jQuery( this ).removeClass( value.call(this, j, this.className) );+			});+		}++		if ( (value && typeof value === "string") || value === undefined ) {+			classNames = ( value || "" ).split( rspace );++			for ( i = 0, l = this.length; i < l; i++ ) {+				elem = this[ i ];++				if ( elem.nodeType === 1 && elem.className ) {+					if ( value ) {+						className = (" " + elem.className + " ").replace( rclass, " " );+						for ( c = 0, cl = classNames.length; c < cl; c++ ) {+							className = className.replace(" " + classNames[ c ] + " ", " ");+						}+						elem.className = jQuery.trim( className );++					} else {+						elem.className = "";+					}+				}+			}+		}++		return this;+	},++	toggleClass: function( value, stateVal ) {+		var type = typeof value,+			isBool = typeof stateVal === "boolean";++		if ( jQuery.isFunction( value ) ) {+			return this.each(function( i ) {+				jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );+			});+		}++		return this.each(function() {+			if ( type === "string" ) {+				// toggle individual class names+				var className,+					i = 0,+					self = jQuery( this ),+					state = stateVal,+					classNames = value.split( rspace );++				while ( (className = classNames[ i++ ]) ) {+					// check each className given, space seperated list+					state = isBool ? state : !self.hasClass( className );+					self[ state ? "addClass" : "removeClass" ]( className );+				}++			} else if ( type === "undefined" || type === "boolean" ) {+				if ( this.className ) {+					// store className if set+					jQuery._data( this, "__className__", this.className );+				}++				// toggle whole className+				this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";+			}+		});+	},++	hasClass: function( selector ) {+		var className = " " + selector + " ",+			i = 0,+			l = this.length;+		for ( ; i < l; i++ ) {+			if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {+				return true;+			}+		}++		return false;+	},++	val: function( value ) {+		var hooks, ret, isFunction,+			elem = this[0];++		if ( !arguments.length ) {+			if ( elem ) {+				hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];++				if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {+					return ret;+				}++				ret = elem.value;++				return typeof ret === "string" ?+					// handle most common string cases+					ret.replace(rreturn, "") :+					// handle cases where value is null/undef or number+					ret == null ? "" : ret;+			}++			return;+		}++		isFunction = jQuery.isFunction( value );++		return this.each(function( i ) {+			var self = jQuery(this), val;++			if ( this.nodeType !== 1 ) {+				return;+			}++			if ( isFunction ) {+				val = value.call( this, i, self.val() );+			} else {+				val = value;+			}++			// Treat null/undefined as ""; convert numbers to string+			if ( val == null ) {+				val = "";+			} else if ( typeof val === "number" ) {+				val += "";+			} else if ( jQuery.isArray( val ) ) {+				val = jQuery.map(val, function ( value ) {+					return value == null ? "" : value + "";+				});+			}++			hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];++			// If set returns undefined, fall back to normal setting+			if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {+				this.value = val;+			}+		});+	}+});++jQuery.extend({+	valHooks: {+		option: {+			get: function( elem ) {+				// attributes.value is undefined in Blackberry 4.7 but+				// uses .value. See #6932+				var val = elem.attributes.value;+				return !val || val.specified ? elem.value : elem.text;+			}+		},+		select: {+			get: function( elem ) {+				var value, i, max, option,+					index = elem.selectedIndex,+					values = [],+					options = elem.options,+					one = elem.type === "select-one";++				// Nothing was selected+				if ( index < 0 ) {+					return null;+				}++				// Loop through all the selected options+				i = one ? index : 0;+				max = one ? index + 1 : options.length;+				for ( ; i < max; i++ ) {+					option = options[ i ];++					// Don't return options that are disabled or in a disabled optgroup+					if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&+							(!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {++						// Get the specific value for the option+						value = jQuery( option ).val();++						// We don't need an array for one selects+						if ( one ) {+							return value;+						}++						// Multi-Selects return an array+						values.push( value );+					}+				}++				// Fixes Bug #2551 -- select.val() broken in IE after form.reset()+				if ( one && !values.length && options.length ) {+					return jQuery( options[ index ] ).val();+				}++				return values;+			},++			set: function( elem, value ) {+				var values = jQuery.makeArray( value );++				jQuery(elem).find("option").each(function() {+					this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;+				});++				if ( !values.length ) {+					elem.selectedIndex = -1;+				}+				return values;+			}+		}+	},++	attrFn: {+		val: true,+		css: true,+		html: true,+		text: true,+		data: true,+		width: true,+		height: true,+		offset: true+	},++	attr: function( elem, name, value, pass ) {+		var ret, hooks, notxml,+			nType = elem.nodeType;++		// don't get/set attributes on text, comment and attribute nodes+		if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {+			return;+		}++		if ( pass && name in jQuery.attrFn ) {+			return jQuery( elem )[ name ]( value );+		}++		// Fallback to prop when attributes are not supported+		if ( typeof elem.getAttribute === "undefined" ) {+			return jQuery.prop( elem, name, value );+		}++		notxml = nType !== 1 || !jQuery.isXMLDoc( elem );++		// All attributes are lowercase+		// Grab necessary hook if one is defined+		if ( notxml ) {+			name = name.toLowerCase();+			hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook );+		}++		if ( value !== undefined ) {++			if ( value === null ) {+				jQuery.removeAttr( elem, name );+				return;++			} else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) {+				return ret;++			} else {+				elem.setAttribute( name, "" + value );+				return value;+			}++		} else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) {+			return ret;++		} else {++			ret = elem.getAttribute( name );++			// Non-existent attributes return null, we normalize to undefined+			return ret === null ?+				undefined :+				ret;+		}+	},++	removeAttr: function( elem, value ) {+		var propName, attrNames, name, l, isBool,+			i = 0;++		if ( value && elem.nodeType === 1 ) {+			attrNames = value.toLowerCase().split( rspace );+			l = attrNames.length;++			for ( ; i < l; i++ ) {+				name = attrNames[ i ];++				if ( name ) {+					propName = jQuery.propFix[ name ] || name;+					isBool = rboolean.test( name );++					// See #9699 for explanation of this approach (setting first, then removal)+					// Do not do this for boolean attributes (see #10870)+					if ( !isBool ) {+						jQuery.attr( elem, name, "" );+					}+					elem.removeAttribute( getSetAttribute ? name : propName );++					// Set corresponding property to false for boolean attributes+					if ( isBool && propName in elem ) {+						elem[ propName ] = false;+					}+				}+			}+		}+	},++	attrHooks: {+		type: {+			set: function( elem, value ) {+				// We can't allow the type property to be changed (since it causes problems in IE)+				if ( rtype.test( elem.nodeName ) && elem.parentNode ) {+					jQuery.error( "type property can't be changed" );+				} else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {+					// Setting the type on a radio button after the value resets the value in IE6-9+					// Reset value to it's default in case type is set after value+					// This is for element creation+					var val = elem.value;+					elem.setAttribute( "type", value );+					if ( val ) {+						elem.value = val;+					}+					return value;+				}+			}+		},+		// Use the value property for back compat+		// Use the nodeHook for button elements in IE6/7 (#1954)+		value: {+			get: function( elem, name ) {+				if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {+					return nodeHook.get( elem, name );+				}+				return name in elem ?+					elem.value :+					null;+			},+			set: function( elem, value, name ) {+				if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {+					return nodeHook.set( elem, value, name );+				}+				// Does not return so that setAttribute is also used+				elem.value = value;+			}+		}+	},++	propFix: {+		tabindex: "tabIndex",+		readonly: "readOnly",+		"for": "htmlFor",+		"class": "className",+		maxlength: "maxLength",+		cellspacing: "cellSpacing",+		cellpadding: "cellPadding",+		rowspan: "rowSpan",+		colspan: "colSpan",+		usemap: "useMap",+		frameborder: "frameBorder",+		contenteditable: "contentEditable"+	},++	prop: function( elem, name, value ) {+		var ret, hooks, notxml,+			nType = elem.nodeType;++		// don't get/set properties on text, comment and attribute nodes+		if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {+			return;+		}++		notxml = nType !== 1 || !jQuery.isXMLDoc( elem );++		if ( notxml ) {+			// Fix name and attach hooks+			name = jQuery.propFix[ name ] || name;+			hooks = jQuery.propHooks[ name ];+		}++		if ( value !== undefined ) {+			if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {+				return ret;++			} else {+				return ( elem[ name ] = value );+			}++		} else {+			if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {+				return ret;++			} else {+				return elem[ name ];+			}+		}+	},++	propHooks: {+		tabIndex: {+			get: function( elem ) {+				// elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set+				// http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/+				var attributeNode = elem.getAttributeNode("tabindex");++				return attributeNode && attributeNode.specified ?+					parseInt( attributeNode.value, 10 ) :+					rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?+						0 :+						undefined;+			}+		}+	}+});++// Add the tabIndex propHook to attrHooks for back-compat (different case is intentional)+jQuery.attrHooks.tabindex = jQuery.propHooks.tabIndex;++// Hook for boolean attributes+boolHook = {+	get: function( elem, name ) {+		// Align boolean attributes with corresponding properties+		// Fall back to attribute presence where some booleans are not supported+		var attrNode,+			property = jQuery.prop( elem, name );+		return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ?+			name.toLowerCase() :+			undefined;+	},+	set: function( elem, value, name ) {+		var propName;+		if ( value === false ) {+			// Remove boolean attributes when set to false+			jQuery.removeAttr( elem, name );+		} else {+			// value is true since we know at this point it's type boolean and not false+			// Set boolean attributes to the same name and set the DOM property+			propName = jQuery.propFix[ name ] || name;+			if ( propName in elem ) {+				// Only set the IDL specifically if it already exists on the element+				elem[ propName ] = true;+			}++			elem.setAttribute( name, name.toLowerCase() );+		}+		return name;+	}+};++// IE6/7 do not support getting/setting some attributes with get/setAttribute+if ( !getSetAttribute ) {++	fixSpecified = {+		name: true,+		id: true,+		coords: true+	};++	// Use this for any attribute in IE6/7+	// This fixes almost every IE6/7 issue+	nodeHook = jQuery.valHooks.button = {+		get: function( elem, name ) {+			var ret;+			ret = elem.getAttributeNode( name );+			return ret && ( fixSpecified[ name ] ? ret.nodeValue !== "" : ret.specified ) ?+				ret.nodeValue :+				undefined;+		},+		set: function( elem, value, name ) {+			// Set the existing or create a new attribute node+			var ret = elem.getAttributeNode( name );+			if ( !ret ) {+				ret = document.createAttribute( name );+				elem.setAttributeNode( ret );+			}+			return ( ret.nodeValue = value + "" );+		}+	};++	// Apply the nodeHook to tabindex+	jQuery.attrHooks.tabindex.set = nodeHook.set;++	// Set width and height to auto instead of 0 on empty string( Bug #8150 )+	// This is for removals+	jQuery.each([ "width", "height" ], function( i, name ) {+		jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {+			set: function( elem, value ) {+				if ( value === "" ) {+					elem.setAttribute( name, "auto" );+					return value;+				}+			}+		});+	});++	// Set contenteditable to false on removals(#10429)+	// Setting to empty string throws an error as an invalid value+	jQuery.attrHooks.contenteditable = {+		get: nodeHook.get,+		set: function( elem, value, name ) {+			if ( value === "" ) {+				value = "false";+			}+			nodeHook.set( elem, value, name );+		}+	};+}+++// Some attributes require a special call on IE+if ( !jQuery.support.hrefNormalized ) {+	jQuery.each([ "href", "src", "width", "height" ], function( i, name ) {+		jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {+			get: function( elem ) {+				var ret = elem.getAttribute( name, 2 );+				return ret === null ? undefined : ret;+			}+		});+	});+}++if ( !jQuery.support.style ) {+	jQuery.attrHooks.style = {+		get: function( elem ) {+			// Return undefined in the case of empty string+			// Normalize to lowercase since IE uppercases css property names+			return elem.style.cssText.toLowerCase() || undefined;+		},+		set: function( elem, value ) {+			return ( elem.style.cssText = "" + value );+		}+	};+}++// Safari mis-reports the default selected property of an option+// Accessing the parent's selectedIndex property fixes it+if ( !jQuery.support.optSelected ) {+	jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, {+		get: function( elem ) {+			var parent = elem.parentNode;++			if ( parent ) {+				parent.selectedIndex;++				// Make sure that it also works with optgroups, see #5701+				if ( parent.parentNode ) {+					parent.parentNode.selectedIndex;+				}+			}+			return null;+		}+	});+}++// IE6/7 call enctype encoding+if ( !jQuery.support.enctype ) {+	jQuery.propFix.enctype = "encoding";+}++// Radios and checkboxes getter/setter+if ( !jQuery.support.checkOn ) {+	jQuery.each([ "radio", "checkbox" ], function() {+		jQuery.valHooks[ this ] = {+			get: function( elem ) {+				// Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified+				return elem.getAttribute("value") === null ? "on" : elem.value;+			}+		};+	});+}+jQuery.each([ "radio", "checkbox" ], function() {+	jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], {+		set: function( elem, value ) {+			if ( jQuery.isArray( value ) ) {+				return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );+			}+		}+	});+});+++++var rformElems = /^(?:textarea|input|select)$/i,+	rtypenamespace = /^([^\.]*)?(?:\.(.+))?$/,+	rhoverHack = /(?:^|\s)hover(\.\S+)?\b/,+	rkeyEvent = /^key/,+	rmouseEvent = /^(?:mouse|contextmenu)|click/,+	rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,+	rquickIs = /^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,+	quickParse = function( selector ) {+		var quick = rquickIs.exec( selector );+		if ( quick ) {+			//   0  1    2   3+			// [ _, tag, id, class ]+			quick[1] = ( quick[1] || "" ).toLowerCase();+			quick[3] = quick[3] && new RegExp( "(?:^|\\s)" + quick[3] + "(?:\\s|$)" );+		}+		return quick;+	},+	quickIs = function( elem, m ) {+		var attrs = elem.attributes || {};+		return (+			(!m[1] || elem.nodeName.toLowerCase() === m[1]) &&+			(!m[2] || (attrs.id || {}).value === m[2]) &&+			(!m[3] || m[3].test( (attrs[ "class" ] || {}).value ))+		);+	},+	hoverHack = function( events ) {+		return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" );+	};++/*+ * Helper functions for managing events -- not part of the public interface.+ * Props to Dean Edwards' addEvent library for many of the ideas.+ */+jQuery.event = {++	add: function( elem, types, handler, data, selector ) {++		var elemData, eventHandle, events,+			t, tns, type, namespaces, handleObj,+			handleObjIn, quick, handlers, special;++		// Don't attach events to noData or text/comment nodes (allow plain objects tho)+		if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) {+			return;+		}++		// Caller can pass in an object of custom data in lieu of the handler+		if ( handler.handler ) {+			handleObjIn = handler;+			handler = handleObjIn.handler;+			selector = handleObjIn.selector;+		}++		// Make sure that the handler has a unique ID, used to find/remove it later+		if ( !handler.guid ) {+			handler.guid = jQuery.guid++;+		}++		// Init the element's event structure and main handler, if this is the first+		events = elemData.events;+		if ( !events ) {+			elemData.events = events = {};+		}+		eventHandle = elemData.handle;+		if ( !eventHandle ) {+			elemData.handle = eventHandle = function( e ) {+				// Discard the second event of a jQuery.event.trigger() and+				// when an event is called after a page has unloaded+				return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ?+					jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :+					undefined;+			};+			// Add elem as a property of the handle fn to prevent a memory leak with IE non-native events+			eventHandle.elem = elem;+		}++		// Handle multiple events separated by a space+		// jQuery(...).bind("mouseover mouseout", fn);+		types = jQuery.trim( hoverHack(types) ).split( " " );+		for ( t = 0; t < types.length; t++ ) {++			tns = rtypenamespace.exec( types[t] ) || [];+			type = tns[1];+			namespaces = ( tns[2] || "" ).split( "." ).sort();++			// If event changes its type, use the special event handlers for the changed type+			special = jQuery.event.special[ type ] || {};++			// If selector defined, determine special event api type, otherwise given type+			type = ( selector ? special.delegateType : special.bindType ) || type;++			// Update special based on newly reset type+			special = jQuery.event.special[ type ] || {};++			// handleObj is passed to all event handlers+			handleObj = jQuery.extend({+				type: type,+				origType: tns[1],+				data: data,+				handler: handler,+				guid: handler.guid,+				selector: selector,+				quick: selector && quickParse( selector ),+				namespace: namespaces.join(".")+			}, handleObjIn );++			// Init the event handler queue if we're the first+			handlers = events[ type ];+			if ( !handlers ) {+				handlers = events[ type ] = [];+				handlers.delegateCount = 0;++				// Only use addEventListener/attachEvent if the special events handler returns false+				if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {+					// Bind the global event handler to the element+					if ( elem.addEventListener ) {+						elem.addEventListener( type, eventHandle, false );++					} else if ( elem.attachEvent ) {+						elem.attachEvent( "on" + type, eventHandle );+					}+				}+			}++			if ( special.add ) {+				special.add.call( elem, handleObj );++				if ( !handleObj.handler.guid ) {+					handleObj.handler.guid = handler.guid;+				}+			}++			// Add to the element's handler list, delegates in front+			if ( selector ) {+				handlers.splice( handlers.delegateCount++, 0, handleObj );+			} else {+				handlers.push( handleObj );+			}++			// Keep track of which events have ever been used, for event optimization+			jQuery.event.global[ type ] = true;+		}++		// Nullify elem to prevent memory leaks in IE+		elem = null;+	},++	global: {},++	// Detach an event or set of events from an element+	remove: function( elem, types, handler, selector, mappedTypes ) {++		var elemData = jQuery.hasData( elem ) && jQuery._data( elem ),+			t, tns, type, origType, namespaces, origCount,+			j, events, special, handle, eventType, handleObj;++		if ( !elemData || !(events = elemData.events) ) {+			return;+		}++		// Once for each type.namespace in types; type may be omitted+		types = jQuery.trim( hoverHack( types || "" ) ).split(" ");+		for ( t = 0; t < types.length; t++ ) {+			tns = rtypenamespace.exec( types[t] ) || [];+			type = origType = tns[1];+			namespaces = tns[2];++			// Unbind all events (on this namespace, if provided) for the element+			if ( !type ) {+				for ( type in events ) {+					jQuery.event.remove( elem, type + types[ t ], handler, selector, true );+				}+				continue;+			}++			special = jQuery.event.special[ type ] || {};+			type = ( selector? special.delegateType : special.bindType ) || type;+			eventType = events[ type ] || [];+			origCount = eventType.length;+			namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.)?") + "(\\.|$)") : null;++			// Remove matching events+			for ( j = 0; j < eventType.length; j++ ) {+				handleObj = eventType[ j ];++				if ( ( mappedTypes || origType === handleObj.origType ) &&+					 ( !handler || handler.guid === handleObj.guid ) &&+					 ( !namespaces || namespaces.test( handleObj.namespace ) ) &&+					 ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {+					eventType.splice( j--, 1 );++					if ( handleObj.selector ) {+						eventType.delegateCount--;+					}+					if ( special.remove ) {+						special.remove.call( elem, handleObj );+					}+				}+			}++			// Remove generic event handler if we removed something and no more handlers exist+			// (avoids potential for endless recursion during removal of special event handlers)+			if ( eventType.length === 0 && origCount !== eventType.length ) {+				if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {+					jQuery.removeEvent( elem, type, elemData.handle );+				}++				delete events[ type ];+			}+		}++		// Remove the expando if it's no longer used+		if ( jQuery.isEmptyObject( events ) ) {+			handle = elemData.handle;+			if ( handle ) {+				handle.elem = null;+			}++			// removeData also checks for emptiness and clears the expando if empty+			// so use it instead of delete+			jQuery.removeData( elem, [ "events", "handle" ], true );+		}+	},++	// Events that are safe to short-circuit if no handlers are attached.+	// Native DOM events should not be added, they may have inline handlers.+	customEvent: {+		"getData": true,+		"setData": true,+		"changeData": true+	},++	trigger: function( event, data, elem, onlyHandlers ) {+		// Don't do events on text and comment nodes+		if ( elem && (elem.nodeType === 3 || elem.nodeType === 8) ) {+			return;+		}++		// Event object or event type+		var type = event.type || event,+			namespaces = [],+			cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType;++		// focus/blur morphs to focusin/out; ensure we're not firing them right now+		if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {+			return;+		}++		if ( type.indexOf( "!" ) >= 0 ) {+			// Exclusive events trigger only for the exact event (no namespaces)+			type = type.slice(0, -1);+			exclusive = true;+		}++		if ( type.indexOf( "." ) >= 0 ) {+			// Namespaced trigger; create a regexp to match event type in handle()+			namespaces = type.split(".");+			type = namespaces.shift();+			namespaces.sort();+		}++		if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) {+			// No jQuery handlers for this event type, and it can't have inline handlers+			return;+		}++		// Caller can pass in an Event, Object, or just an event type string+		event = typeof event === "object" ?+			// jQuery.Event object+			event[ jQuery.expando ] ? event :+			// Object literal+			new jQuery.Event( type, event ) :+			// Just the event type (string)+			new jQuery.Event( type );++		event.type = type;+		event.isTrigger = true;+		event.exclusive = exclusive;+		event.namespace = namespaces.join( "." );+		event.namespace_re = event.namespace? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)") : null;+		ontype = type.indexOf( ":" ) < 0 ? "on" + type : "";++		// Handle a global trigger+		if ( !elem ) {++			// TODO: Stop taunting the data cache; remove global events and always attach to document+			cache = jQuery.cache;+			for ( i in cache ) {+				if ( cache[ i ].events && cache[ i ].events[ type ] ) {+					jQuery.event.trigger( event, data, cache[ i ].handle.elem, true );+				}+			}+			return;+		}++		// Clean up the event in case it is being reused+		event.result = undefined;+		if ( !event.target ) {+			event.target = elem;+		}++		// Clone any incoming data and prepend the event, creating the handler arg list+		data = data != null ? jQuery.makeArray( data ) : [];+		data.unshift( event );++		// Allow special events to draw outside the lines+		special = jQuery.event.special[ type ] || {};+		if ( special.trigger && special.trigger.apply( elem, data ) === false ) {+			return;+		}++		// Determine event propagation path in advance, per W3C events spec (#9951)+		// Bubble up to document, then to window; watch for a global ownerDocument var (#9724)+		eventPath = [[ elem, special.bindType || type ]];+		if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {++			bubbleType = special.delegateType || type;+			cur = rfocusMorph.test( bubbleType + type ) ? elem : elem.parentNode;+			old = null;+			for ( ; cur; cur = cur.parentNode ) {+				eventPath.push([ cur, bubbleType ]);+				old = cur;+			}++			// Only add window if we got to document (e.g., not plain obj or detached DOM)+			if ( old && old === elem.ownerDocument ) {+				eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]);+			}+		}++		// Fire handlers on the event path+		for ( i = 0; i < eventPath.length && !event.isPropagationStopped(); i++ ) {++			cur = eventPath[i][0];+			event.type = eventPath[i][1];++			handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" );+			if ( handle ) {+				handle.apply( cur, data );+			}+			// Note that this is a bare JS function and not a jQuery handler+			handle = ontype && cur[ ontype ];+			if ( handle && jQuery.acceptData( cur ) && handle.apply( cur, data ) === false ) {+				event.preventDefault();+			}+		}+		event.type = type;++		// If nobody prevented the default action, do it now+		if ( !onlyHandlers && !event.isDefaultPrevented() ) {++			if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) &&+				!(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) {++				// Call a native DOM method on the target with the same name name as the event.+				// Can't use an .isFunction() check here because IE6/7 fails that test.+				// Don't do default actions on window, that's where global variables be (#6170)+				// IE<9 dies on focus/blur to hidden element (#1486)+				if ( ontype && elem[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) && !jQuery.isWindow( elem ) ) {++					// Don't re-trigger an onFOO event when we call its FOO() method+					old = elem[ ontype ];++					if ( old ) {+						elem[ ontype ] = null;+					}++					// Prevent re-triggering of the same event, since we already bubbled it above+					jQuery.event.triggered = type;+					elem[ type ]();+					jQuery.event.triggered = undefined;++					if ( old ) {+						elem[ ontype ] = old;+					}+				}+			}+		}++		return event.result;+	},++	dispatch: function( event ) {++		// Make a writable jQuery.Event from the native event object+		event = jQuery.event.fix( event || window.event );++		var handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []),+			delegateCount = handlers.delegateCount,+			args = [].slice.call( arguments, 0 ),+			run_all = !event.exclusive && !event.namespace,+			special = jQuery.event.special[ event.type ] || {},+			handlerQueue = [],+			i, j, cur, jqcur, ret, selMatch, matched, matches, handleObj, sel, related;++		// Use the fix-ed jQuery.Event rather than the (read-only) native event+		args[0] = event;+		event.delegateTarget = this;++		// Call the preDispatch hook for the mapped type, and let it bail if desired+		if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {+			return;+		}++		// Determine handlers that should run if there are delegated events+		// Avoid non-left-click bubbling in Firefox (#3861)+		if ( delegateCount && !(event.button && event.type === "click") ) {++			// Pregenerate a single jQuery object for reuse with .is()+			jqcur = jQuery(this);+			jqcur.context = this.ownerDocument || this;++			for ( cur = event.target; cur != this; cur = cur.parentNode || this ) {++				// Don't process events on disabled elements (#6911, #8165)+				if ( cur.disabled !== true ) {+					selMatch = {};+					matches = [];+					jqcur[0] = cur;+					for ( i = 0; i < delegateCount; i++ ) {+						handleObj = handlers[ i ];+						sel = handleObj.selector;++						if ( selMatch[ sel ] === undefined ) {+							selMatch[ sel ] = (+								handleObj.quick ? quickIs( cur, handleObj.quick ) : jqcur.is( sel )+							);+						}+						if ( selMatch[ sel ] ) {+							matches.push( handleObj );+						}+					}+					if ( matches.length ) {+						handlerQueue.push({ elem: cur, matches: matches });+					}+				}+			}+		}++		// Add the remaining (directly-bound) handlers+		if ( handlers.length > delegateCount ) {+			handlerQueue.push({ elem: this, matches: handlers.slice( delegateCount ) });+		}++		// Run delegates first; they may want to stop propagation beneath us+		for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) {+			matched = handlerQueue[ i ];+			event.currentTarget = matched.elem;++			for ( j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++ ) {+				handleObj = matched.matches[ j ];++				// Triggered event must either 1) be non-exclusive and have no namespace, or+				// 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).+				if ( run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) {++					event.data = handleObj.data;+					event.handleObj = handleObj;++					ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )+							.apply( matched.elem, args );++					if ( ret !== undefined ) {+						event.result = ret;+						if ( ret === false ) {+							event.preventDefault();+							event.stopPropagation();+						}+					}+				}+			}+		}++		// Call the postDispatch hook for the mapped type+		if ( special.postDispatch ) {+			special.postDispatch.call( this, event );+		}++		return event.result;+	},++	// Includes some event props shared by KeyEvent and MouseEvent+	// *** attrChange attrName relatedNode srcElement  are not normalized, non-W3C, deprecated, will be removed in 1.8 ***+	props: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),++	fixHooks: {},++	keyHooks: {+		props: "char charCode key keyCode".split(" "),+		filter: function( event, original ) {++			// Add which for key events+			if ( event.which == null ) {+				event.which = original.charCode != null ? original.charCode : original.keyCode;+			}++			return event;+		}+	},++	mouseHooks: {+		props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),+		filter: function( event, original ) {+			var eventDoc, doc, body,+				button = original.button,+				fromElement = original.fromElement;++			// Calculate pageX/Y if missing and clientX/Y available+			if ( event.pageX == null && original.clientX != null ) {+				eventDoc = event.target.ownerDocument || document;+				doc = eventDoc.documentElement;+				body = eventDoc.body;++				event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );+				event.pageY = original.clientY + ( doc && doc.scrollTop  || body && body.scrollTop  || 0 ) - ( doc && doc.clientTop  || body && body.clientTop  || 0 );+			}++			// Add relatedTarget, if necessary+			if ( !event.relatedTarget && fromElement ) {+				event.relatedTarget = fromElement === event.target ? original.toElement : fromElement;+			}++			// Add which for click: 1 === left; 2 === middle; 3 === right+			// Note: button is not normalized, so don't use it+			if ( !event.which && button !== undefined ) {+				event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );+			}++			return event;+		}+	},++	fix: function( event ) {+		if ( event[ jQuery.expando ] ) {+			return event;+		}++		// Create a writable copy of the event object and normalize some properties+		var i, prop,+			originalEvent = event,+			fixHook = jQuery.event.fixHooks[ event.type ] || {},+			copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;++		event = jQuery.Event( originalEvent );++		for ( i = copy.length; i; ) {+			prop = copy[ --i ];+			event[ prop ] = originalEvent[ prop ];+		}++		// Fix target property, if necessary (#1925, IE 6/7/8 & Safari2)+		if ( !event.target ) {+			event.target = originalEvent.srcElement || document;+		}++		// Target should not be a text node (#504, Safari)+		if ( event.target.nodeType === 3 ) {+			event.target = event.target.parentNode;+		}++		// For mouse/key events; add metaKey if it's not there (#3368, IE6/7/8)+		if ( event.metaKey === undefined ) {+			event.metaKey = event.ctrlKey;+		}++		return fixHook.filter? fixHook.filter( event, originalEvent ) : event;+	},++	special: {+		ready: {+			// Make sure the ready event is setup+			setup: jQuery.bindReady+		},++		load: {+			// Prevent triggered image.load events from bubbling to window.load+			noBubble: true+		},++		focus: {+			delegateType: "focusin"+		},+		blur: {+			delegateType: "focusout"+		},++		beforeunload: {+			setup: function( data, namespaces, eventHandle ) {+				// We only want to do this special case on windows+				if ( jQuery.isWindow( this ) ) {+					this.onbeforeunload = eventHandle;+				}+			},++			teardown: function( namespaces, eventHandle ) {+				if ( this.onbeforeunload === eventHandle ) {+					this.onbeforeunload = null;+				}+			}+		}+	},++	simulate: function( type, elem, event, bubble ) {+		// Piggyback on a donor event to simulate a different one.+		// Fake originalEvent to avoid donor's stopPropagation, but if the+		// simulated event prevents default then we do the same on the donor.+		var e = jQuery.extend(+			new jQuery.Event(),+			event,+			{ type: type,+				isSimulated: true,+				originalEvent: {}+			}+		);+		if ( bubble ) {+			jQuery.event.trigger( e, null, elem );+		} else {+			jQuery.event.dispatch.call( elem, e );+		}+		if ( e.isDefaultPrevented() ) {+			event.preventDefault();+		}+	}+};++// Some plugins are using, but it's undocumented/deprecated and will be removed.+// The 1.7 special event interface should provide all the hooks needed now.+jQuery.event.handle = jQuery.event.dispatch;++jQuery.removeEvent = document.removeEventListener ?+	function( elem, type, handle ) {+		if ( elem.removeEventListener ) {+			elem.removeEventListener( type, handle, false );+		}+	} :+	function( elem, type, handle ) {+		if ( elem.detachEvent ) {+			elem.detachEvent( "on" + type, handle );+		}+	};++jQuery.Event = function( src, props ) {+	// Allow instantiation without the 'new' keyword+	if ( !(this instanceof jQuery.Event) ) {+		return new jQuery.Event( src, props );+	}++	// Event object+	if ( src && src.type ) {+		this.originalEvent = src;+		this.type = src.type;++		// Events bubbling up the document may have been marked as prevented+		// by a handler lower down the tree; reflect the correct value.+		this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false ||+			src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse;++	// Event type+	} else {+		this.type = src;+	}++	// Put explicitly provided properties onto the event object+	if ( props ) {+		jQuery.extend( this, props );+	}++	// Create a timestamp if incoming event doesn't have one+	this.timeStamp = src && src.timeStamp || jQuery.now();++	// Mark it as fixed+	this[ jQuery.expando ] = true;+};++function returnFalse() {+	return false;+}+function returnTrue() {+	return true;+}++// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding+// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html+jQuery.Event.prototype = {+	preventDefault: function() {+		this.isDefaultPrevented = returnTrue;++		var e = this.originalEvent;+		if ( !e ) {+			return;+		}++		// if preventDefault exists run it on the original event+		if ( e.preventDefault ) {+			e.preventDefault();++		// otherwise set the returnValue property of the original event to false (IE)+		} else {+			e.returnValue = false;+		}+	},+	stopPropagation: function() {+		this.isPropagationStopped = returnTrue;++		var e = this.originalEvent;+		if ( !e ) {+			return;+		}+		// if stopPropagation exists run it on the original event+		if ( e.stopPropagation ) {+			e.stopPropagation();+		}+		// otherwise set the cancelBubble property of the original event to true (IE)+		e.cancelBubble = true;+	},+	stopImmediatePropagation: function() {+		this.isImmediatePropagationStopped = returnTrue;+		this.stopPropagation();+	},+	isDefaultPrevented: returnFalse,+	isPropagationStopped: returnFalse,+	isImmediatePropagationStopped: returnFalse+};++// Create mouseenter/leave events using mouseover/out and event-time checks+jQuery.each({+	mouseenter: "mouseover",+	mouseleave: "mouseout"+}, function( orig, fix ) {+	jQuery.event.special[ orig ] = {+		delegateType: fix,+		bindType: fix,++		handle: function( event ) {+			var target = this,+				related = event.relatedTarget,+				handleObj = event.handleObj,+				selector = handleObj.selector,+				ret;++			// For mousenter/leave call the handler if related is outside the target.+			// NB: No relatedTarget if the mouse left/entered the browser window+			if ( !related || (related !== target && !jQuery.contains( target, related )) ) {+				event.type = handleObj.origType;+				ret = handleObj.handler.apply( this, arguments );+				event.type = fix;+			}+			return ret;+		}+	};+});++// IE submit delegation+if ( !jQuery.support.submitBubbles ) {++	jQuery.event.special.submit = {+		setup: function() {+			// Only need this for delegated form submit events+			if ( jQuery.nodeName( this, "form" ) ) {+				return false;+			}++			// Lazy-add a submit handler when a descendant form may potentially be submitted+			jQuery.event.add( this, "click._submit keypress._submit", function( e ) {+				// Node name check avoids a VML-related crash in IE (#9807)+				var elem = e.target,+					form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined;+				if ( form && !form._submit_attached ) {+					jQuery.event.add( form, "submit._submit", function( event ) {+						event._submit_bubble = true;+					});+					form._submit_attached = true;+				}+			});+			// return undefined since we don't need an event listener+		},+		+		postDispatch: function( event ) {+			// If form was submitted by the user, bubble the event up the tree+			if ( event._submit_bubble ) {+				delete event._submit_bubble;+				if ( this.parentNode && !event.isTrigger ) {+					jQuery.event.simulate( "submit", this.parentNode, event, true );+				}+			}+		},++		teardown: function() {+			// Only need this for delegated form submit events+			if ( jQuery.nodeName( this, "form" ) ) {+				return false;+			}++			// Remove delegated handlers; cleanData eventually reaps submit handlers attached above+			jQuery.event.remove( this, "._submit" );+		}+	};+}++// IE change delegation and checkbox/radio fix+if ( !jQuery.support.changeBubbles ) {++	jQuery.event.special.change = {++		setup: function() {++			if ( rformElems.test( this.nodeName ) ) {+				// IE doesn't fire change on a check/radio until blur; trigger it on click+				// after a propertychange. Eat the blur-change in special.change.handle.+				// This still fires onchange a second time for check/radio after blur.+				if ( this.type === "checkbox" || this.type === "radio" ) {+					jQuery.event.add( this, "propertychange._change", function( event ) {+						if ( event.originalEvent.propertyName === "checked" ) {+							this._just_changed = true;+						}+					});+					jQuery.event.add( this, "click._change", function( event ) {+						if ( this._just_changed && !event.isTrigger ) {+							this._just_changed = false;+							jQuery.event.simulate( "change", this, event, true );+						}+					});+				}+				return false;+			}+			// Delegated event; lazy-add a change handler on descendant inputs+			jQuery.event.add( this, "beforeactivate._change", function( e ) {+				var elem = e.target;++				if ( rformElems.test( elem.nodeName ) && !elem._change_attached ) {+					jQuery.event.add( elem, "change._change", function( event ) {+						if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {+							jQuery.event.simulate( "change", this.parentNode, event, true );+						}+					});+					elem._change_attached = true;+				}+			});+		},++		handle: function( event ) {+			var elem = event.target;++			// Swallow native change events from checkbox/radio, we already triggered them above+			if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) {+				return event.handleObj.handler.apply( this, arguments );+			}+		},++		teardown: function() {+			jQuery.event.remove( this, "._change" );++			return rformElems.test( this.nodeName );+		}+	};+}++// Create "bubbling" focus and blur events+if ( !jQuery.support.focusinBubbles ) {+	jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {++		// Attach a single capturing handler while someone wants focusin/focusout+		var attaches = 0,+			handler = function( event ) {+				jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );+			};++		jQuery.event.special[ fix ] = {+			setup: function() {+				if ( attaches++ === 0 ) {+					document.addEventListener( orig, handler, true );+				}+			},+			teardown: function() {+				if ( --attaches === 0 ) {+					document.removeEventListener( orig, handler, true );+				}+			}+		};+	});+}++jQuery.fn.extend({++	on: function( types, selector, data, fn, /*INTERNAL*/ one ) {+		var origFn, type;++		// Types can be a map of types/handlers+		if ( typeof types === "object" ) {+			// ( types-Object, selector, data )+			if ( typeof selector !== "string" ) { // && selector != null+				// ( types-Object, data )+				data = data || selector;+				selector = undefined;+			}+			for ( type in types ) {+				this.on( type, selector, data, types[ type ], one );+			}+			return this;+		}++		if ( data == null && fn == null ) {+			// ( types, fn )+			fn = selector;+			data = selector = undefined;+		} else if ( fn == null ) {+			if ( typeof selector === "string" ) {+				// ( types, selector, fn )+				fn = data;+				data = undefined;+			} else {+				// ( types, data, fn )+				fn = data;+				data = selector;+				selector = undefined;+			}+		}+		if ( fn === false ) {+			fn = returnFalse;+		} else if ( !fn ) {+			return this;+		}++		if ( one === 1 ) {+			origFn = fn;+			fn = function( event ) {+				// Can use an empty set, since event contains the info+				jQuery().off( event );+				return origFn.apply( this, arguments );+			};+			// Use same guid so caller can remove using origFn+			fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );+		}+		return this.each( function() {+			jQuery.event.add( this, types, fn, data, selector );+		});+	},+	one: function( types, selector, data, fn ) {+		return this.on( types, selector, data, fn, 1 );+	},+	off: function( types, selector, fn ) {+		if ( types && types.preventDefault && types.handleObj ) {+			// ( event )  dispatched jQuery.Event+			var handleObj = types.handleObj;+			jQuery( types.delegateTarget ).off(+				handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,+				handleObj.selector,+				handleObj.handler+			);+			return this;+		}+		if ( typeof types === "object" ) {+			// ( types-object [, selector] )+			for ( var type in types ) {+				this.off( type, selector, types[ type ] );+			}+			return this;+		}+		if ( selector === false || typeof selector === "function" ) {+			// ( types [, fn] )+			fn = selector;+			selector = undefined;+		}+		if ( fn === false ) {+			fn = returnFalse;+		}+		return this.each(function() {+			jQuery.event.remove( this, types, fn, selector );+		});+	},++	bind: function( types, data, fn ) {+		return this.on( types, null, data, fn );+	},+	unbind: function( types, fn ) {+		return this.off( types, null, fn );+	},++	live: function( types, data, fn ) {+		jQuery( this.context ).on( types, this.selector, data, fn );+		return this;+	},+	die: function( types, fn ) {+		jQuery( this.context ).off( types, this.selector || "**", fn );+		return this;+	},++	delegate: function( selector, types, data, fn ) {+		return this.on( types, selector, data, fn );+	},+	undelegate: function( selector, types, fn ) {+		// ( namespace ) or ( selector, types [, fn] )+		return arguments.length == 1? this.off( selector, "**" ) : this.off( types, selector, fn );+	},++	trigger: function( type, data ) {+		return this.each(function() {+			jQuery.event.trigger( type, data, this );+		});+	},+	triggerHandler: function( type, data ) {+		if ( this[0] ) {+			return jQuery.event.trigger( type, data, this[0], true );+		}+	},++	toggle: function( fn ) {+		// Save reference to arguments for access in closure+		var args = arguments,+			guid = fn.guid || jQuery.guid++,+			i = 0,+			toggler = function( event ) {+				// Figure out which function to execute+				var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;+				jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );++				// Make sure that clicks stop+				event.preventDefault();++				// and execute the function+				return args[ lastToggle ].apply( this, arguments ) || false;+			};++		// link all the functions, so any of them can unbind this click handler+		toggler.guid = guid;+		while ( i < args.length ) {+			args[ i++ ].guid = guid;+		}++		return this.click( toggler );+	},++	hover: function( fnOver, fnOut ) {+		return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );+	}+});++jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " ++	"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " ++	"change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {++	// Handle event binding+	jQuery.fn[ name ] = function( data, fn ) {+		if ( fn == null ) {+			fn = data;+			data = null;+		}++		return arguments.length > 0 ?+			this.on( name, null, data, fn ) :+			this.trigger( name );+	};++	if ( jQuery.attrFn ) {+		jQuery.attrFn[ name ] = true;+	}++	if ( rkeyEvent.test( name ) ) {+		jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks;+	}++	if ( rmouseEvent.test( name ) ) {+		jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks;+	}+});++++/*!+ * Sizzle CSS Selector Engine+ *  Copyright 2011, The Dojo Foundation+ *  Released under the MIT, BSD, and GPL Licenses.+ *  More information: http://sizzlejs.com/+ */+(function(){++var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,+	expando = "sizcache" + (Math.random() + '').replace('.', ''),+	done = 0,+	toString = Object.prototype.toString,+	hasDuplicate = false,+	baseHasDuplicate = true,+	rBackslash = /\\/g,+	rReturn = /\r\n/g,+	rNonWord = /\W/;++// Here we check if the JavaScript engine is using some sort of+// optimization where it does not always call our comparision+// function. If that is the case, discard the hasDuplicate value.+//   Thus far that includes Google Chrome.+[0, 0].sort(function() {+	baseHasDuplicate = false;+	return 0;+});++var Sizzle = function( selector, context, results, seed ) {+	results = results || [];+	context = context || document;++	var origContext = context;++	if ( context.nodeType !== 1 && context.nodeType !== 9 ) {+		return [];+	}++	if ( !selector || typeof selector !== "string" ) {+		return results;+	}++	var m, set, checkSet, extra, ret, cur, pop, i,+		prune = true,+		contextXML = Sizzle.isXML( context ),+		parts = [],+		soFar = selector;++	// Reset the position of the chunker regexp (start from head)+	do {+		chunker.exec( "" );+		m = chunker.exec( soFar );++		if ( m ) {+			soFar = m[3];++			parts.push( m[1] );++			if ( m[2] ) {+				extra = m[3];+				break;+			}+		}+	} while ( m );++	if ( parts.length > 1 && origPOS.exec( selector ) ) {++		if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {+			set = posProcess( parts[0] + parts[1], context, seed );++		} else {+			set = Expr.relative[ parts[0] ] ?+				[ context ] :+				Sizzle( parts.shift(), context );++			while ( parts.length ) {+				selector = parts.shift();++				if ( Expr.relative[ selector ] ) {+					selector += parts.shift();+				}++				set = posProcess( selector, set, seed );+			}+		}++	} else {+		// Take a shortcut and set the context if the root selector is an ID+		// (but not if it'll be faster if the inner selector is an ID)+		if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&+				Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {++			ret = Sizzle.find( parts.shift(), context, contextXML );+			context = ret.expr ?+				Sizzle.filter( ret.expr, ret.set )[0] :+				ret.set[0];+		}++		if ( context ) {+			ret = seed ?+				{ expr: parts.pop(), set: makeArray(seed) } :+				Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );++			set = ret.expr ?+				Sizzle.filter( ret.expr, ret.set ) :+				ret.set;++			if ( parts.length > 0 ) {+				checkSet = makeArray( set );++			} else {+				prune = false;+			}++			while ( parts.length ) {+				cur = parts.pop();+				pop = cur;++				if ( !Expr.relative[ cur ] ) {+					cur = "";+				} else {+					pop = parts.pop();+				}++				if ( pop == null ) {+					pop = context;+				}++				Expr.relative[ cur ]( checkSet, pop, contextXML );+			}++		} else {+			checkSet = parts = [];+		}+	}++	if ( !checkSet ) {+		checkSet = set;+	}++	if ( !checkSet ) {+		Sizzle.error( cur || selector );+	}++	if ( toString.call(checkSet) === "[object Array]" ) {+		if ( !prune ) {+			results.push.apply( results, checkSet );++		} else if ( context && context.nodeType === 1 ) {+			for ( i = 0; checkSet[i] != null; i++ ) {+				if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) {+					results.push( set[i] );+				}+			}++		} else {+			for ( i = 0; checkSet[i] != null; i++ ) {+				if ( checkSet[i] && checkSet[i].nodeType === 1 ) {+					results.push( set[i] );+				}+			}+		}++	} else {+		makeArray( checkSet, results );+	}++	if ( extra ) {+		Sizzle( extra, origContext, results, seed );+		Sizzle.uniqueSort( results );+	}++	return results;+};++Sizzle.uniqueSort = function( results ) {+	if ( sortOrder ) {+		hasDuplicate = baseHasDuplicate;+		results.sort( sortOrder );++		if ( hasDuplicate ) {+			for ( var i = 1; i < results.length; i++ ) {+				if ( results[i] === results[ i - 1 ] ) {+					results.splice( i--, 1 );+				}+			}+		}+	}++	return results;+};++Sizzle.matches = function( expr, set ) {+	return Sizzle( expr, null, null, set );+};++Sizzle.matchesSelector = function( node, expr ) {+	return Sizzle( expr, null, null, [node] ).length > 0;+};++Sizzle.find = function( expr, context, isXML ) {+	var set, i, len, match, type, left;++	if ( !expr ) {+		return [];+	}++	for ( i = 0, len = Expr.order.length; i < len; i++ ) {+		type = Expr.order[i];++		if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {+			left = match[1];+			match.splice( 1, 1 );++			if ( left.substr( left.length - 1 ) !== "\\" ) {+				match[1] = (match[1] || "").replace( rBackslash, "" );+				set = Expr.find[ type ]( match, context, isXML );++				if ( set != null ) {+					expr = expr.replace( Expr.match[ type ], "" );+					break;+				}+			}+		}+	}++	if ( !set ) {+		set = typeof context.getElementsByTagName !== "undefined" ?+			context.getElementsByTagName( "*" ) :+			[];+	}++	return { set: set, expr: expr };+};++Sizzle.filter = function( expr, set, inplace, not ) {+	var match, anyFound,+		type, found, item, filter, left,+		i, pass,+		old = expr,+		result = [],+		curLoop = set,+		isXMLFilter = set && set[0] && Sizzle.isXML( set[0] );++	while ( expr && set.length ) {+		for ( type in Expr.filter ) {+			if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {+				filter = Expr.filter[ type ];+				left = match[1];++				anyFound = false;++				match.splice(1,1);++				if ( left.substr( left.length - 1 ) === "\\" ) {+					continue;+				}++				if ( curLoop === result ) {+					result = [];+				}++				if ( Expr.preFilter[ type ] ) {+					match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );++					if ( !match ) {+						anyFound = found = true;++					} else if ( match === true ) {+						continue;+					}+				}++				if ( match ) {+					for ( i = 0; (item = curLoop[i]) != null; i++ ) {+						if ( item ) {+							found = filter( item, match, i, curLoop );+							pass = not ^ found;++							if ( inplace && found != null ) {+								if ( pass ) {+									anyFound = true;++								} else {+									curLoop[i] = false;+								}++							} else if ( pass ) {+								result.push( item );+								anyFound = true;+							}+						}+					}+				}++				if ( found !== undefined ) {+					if ( !inplace ) {+						curLoop = result;+					}++					expr = expr.replace( Expr.match[ type ], "" );++					if ( !anyFound ) {+						return [];+					}++					break;+				}+			}+		}++		// Improper expression+		if ( expr === old ) {+			if ( anyFound == null ) {+				Sizzle.error( expr );++			} else {+				break;+			}+		}++		old = expr;+	}++	return curLoop;+};++Sizzle.error = function( msg ) {+	throw new Error( "Syntax error, unrecognized expression: " + msg );+};++/**+ * Utility function for retreiving the text value of an array of DOM nodes+ * @param {Array|Element} elem+ */+var getText = Sizzle.getText = function( elem ) {+    var i, node,+		nodeType = elem.nodeType,+		ret = "";++	if ( nodeType ) {+		if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {+			// Use textContent || innerText for elements+			if ( typeof elem.textContent === 'string' ) {+				return elem.textContent;+			} else if ( typeof elem.innerText === 'string' ) {+				// Replace IE's carriage returns+				return elem.innerText.replace( rReturn, '' );+			} else {+				// Traverse it's children+				for ( elem = elem.firstChild; elem; elem = elem.nextSibling) {+					ret += getText( elem );+				}+			}+		} else if ( nodeType === 3 || nodeType === 4 ) {+			return elem.nodeValue;+		}+	} else {++		// If no nodeType, this is expected to be an array+		for ( i = 0; (node = elem[i]); i++ ) {+			// Do not traverse comment nodes+			if ( node.nodeType !== 8 ) {+				ret += getText( node );+			}+		}+	}+	return ret;+};++var Expr = Sizzle.selectors = {+	order: [ "ID", "NAME", "TAG" ],++	match: {+		ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,+		CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,+		NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,+		ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,+		TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,+		CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,+		POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,+		PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/+	},++	leftMatch: {},++	attrMap: {+		"class": "className",+		"for": "htmlFor"+	},++	attrHandle: {+		href: function( elem ) {+			return elem.getAttribute( "href" );+		},+		type: function( elem ) {+			return elem.getAttribute( "type" );+		}+	},++	relative: {+		"+": function(checkSet, part){+			var isPartStr = typeof part === "string",+				isTag = isPartStr && !rNonWord.test( part ),+				isPartStrNotTag = isPartStr && !isTag;++			if ( isTag ) {+				part = part.toLowerCase();+			}++			for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {+				if ( (elem = checkSet[i]) ) {+					while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}++					checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?+						elem || false :+						elem === part;+				}+			}++			if ( isPartStrNotTag ) {+				Sizzle.filter( part, checkSet, true );+			}+		},++		">": function( checkSet, part ) {+			var elem,+				isPartStr = typeof part === "string",+				i = 0,+				l = checkSet.length;++			if ( isPartStr && !rNonWord.test( part ) ) {+				part = part.toLowerCase();++				for ( ; i < l; i++ ) {+					elem = checkSet[i];++					if ( elem ) {+						var parent = elem.parentNode;+						checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;+					}+				}++			} else {+				for ( ; i < l; i++ ) {+					elem = checkSet[i];++					if ( elem ) {+						checkSet[i] = isPartStr ?+							elem.parentNode :+							elem.parentNode === part;+					}+				}++				if ( isPartStr ) {+					Sizzle.filter( part, checkSet, true );+				}+			}+		},++		"": function(checkSet, part, isXML){+			var nodeCheck,+				doneName = done++,+				checkFn = dirCheck;++			if ( typeof part === "string" && !rNonWord.test( part ) ) {+				part = part.toLowerCase();+				nodeCheck = part;+				checkFn = dirNodeCheck;+			}++			checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML );+		},++		"~": function( checkSet, part, isXML ) {+			var nodeCheck,+				doneName = done++,+				checkFn = dirCheck;++			if ( typeof part === "string" && !rNonWord.test( part ) ) {+				part = part.toLowerCase();+				nodeCheck = part;+				checkFn = dirNodeCheck;+			}++			checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML );+		}+	},++	find: {+		ID: function( match, context, isXML ) {+			if ( typeof context.getElementById !== "undefined" && !isXML ) {+				var m = context.getElementById(match[1]);+				// Check parentNode to catch when Blackberry 4.6 returns+				// nodes that are no longer in the document #6963+				return m && m.parentNode ? [m] : [];+			}+		},++		NAME: function( match, context ) {+			if ( typeof context.getElementsByName !== "undefined" ) {+				var ret = [],+					results = context.getElementsByName( match[1] );++				for ( var i = 0, l = results.length; i < l; i++ ) {+					if ( results[i].getAttribute("name") === match[1] ) {+						ret.push( results[i] );+					}+				}++				return ret.length === 0 ? null : ret;+			}+		},++		TAG: function( match, context ) {+			if ( typeof context.getElementsByTagName !== "undefined" ) {+				return context.getElementsByTagName( match[1] );+			}+		}+	},+	preFilter: {+		CLASS: function( match, curLoop, inplace, result, not, isXML ) {+			match = " " + match[1].replace( rBackslash, "" ) + " ";++			if ( isXML ) {+				return match;+			}++			for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {+				if ( elem ) {+					if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) {+						if ( !inplace ) {+							result.push( elem );+						}++					} else if ( inplace ) {+						curLoop[i] = false;+					}+				}+			}++			return false;+		},++		ID: function( match ) {+			return match[1].replace( rBackslash, "" );+		},++		TAG: function( match, curLoop ) {+			return match[1].replace( rBackslash, "" ).toLowerCase();+		},++		CHILD: function( match ) {+			if ( match[1] === "nth" ) {+				if ( !match[2] ) {+					Sizzle.error( match[0] );+				}++				match[2] = match[2].replace(/^\+|\s*/g, '');++				// parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'+				var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec(+					match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||+					!/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);++				// calculate the numbers (first)n+(last) including if they are negative+				match[2] = (test[1] + (test[2] || 1)) - 0;+				match[3] = test[3] - 0;+			}+			else if ( match[2] ) {+				Sizzle.error( match[0] );+			}++			// TODO: Move to normal caching system+			match[0] = done++;++			return match;+		},++		ATTR: function( match, curLoop, inplace, result, not, isXML ) {+			var name = match[1] = match[1].replace( rBackslash, "" );++			if ( !isXML && Expr.attrMap[name] ) {+				match[1] = Expr.attrMap[name];+			}++			// Handle if an un-quoted value was used+			match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" );++			if ( match[2] === "~=" ) {+				match[4] = " " + match[4] + " ";+			}++			return match;+		},++		PSEUDO: function( match, curLoop, inplace, result, not ) {+			if ( match[1] === "not" ) {+				// If we're dealing with a complex expression, or a simple one+				if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {+					match[3] = Sizzle(match[3], null, null, curLoop);++				} else {+					var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);++					if ( !inplace ) {+						result.push.apply( result, ret );+					}++					return false;+				}++			} else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {+				return true;+			}++			return match;+		},++		POS: function( match ) {+			match.unshift( true );++			return match;+		}+	},++	filters: {+		enabled: function( elem ) {+			return elem.disabled === false && elem.type !== "hidden";+		},++		disabled: function( elem ) {+			return elem.disabled === true;+		},++		checked: function( elem ) {+			return elem.checked === true;+		},++		selected: function( elem ) {+			// Accessing this property makes selected-by-default+			// options in Safari work properly+			if ( elem.parentNode ) {+				elem.parentNode.selectedIndex;+			}++			return elem.selected === true;+		},++		parent: function( elem ) {+			return !!elem.firstChild;+		},++		empty: function( elem ) {+			return !elem.firstChild;+		},++		has: function( elem, i, match ) {+			return !!Sizzle( match[3], elem ).length;+		},++		header: function( elem ) {+			return (/h\d/i).test( elem.nodeName );+		},++		text: function( elem ) {+			var attr = elem.getAttribute( "type" ), type = elem.type;+			// IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)+			// use getAttribute instead to test this case+			return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null );+		},++		radio: function( elem ) {+			return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type;+		},++		checkbox: function( elem ) {+			return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type;+		},++		file: function( elem ) {+			return elem.nodeName.toLowerCase() === "input" && "file" === elem.type;+		},++		password: function( elem ) {+			return elem.nodeName.toLowerCase() === "input" && "password" === elem.type;+		},++		submit: function( elem ) {+			var name = elem.nodeName.toLowerCase();+			return (name === "input" || name === "button") && "submit" === elem.type;+		},++		image: function( elem ) {+			return elem.nodeName.toLowerCase() === "input" && "image" === elem.type;+		},++		reset: function( elem ) {+			var name = elem.nodeName.toLowerCase();+			return (name === "input" || name === "button") && "reset" === elem.type;+		},++		button: function( elem ) {+			var name = elem.nodeName.toLowerCase();+			return name === "input" && "button" === elem.type || name === "button";+		},++		input: function( elem ) {+			return (/input|select|textarea|button/i).test( elem.nodeName );+		},++		focus: function( elem ) {+			return elem === elem.ownerDocument.activeElement;+		}+	},+	setFilters: {+		first: function( elem, i ) {+			return i === 0;+		},++		last: function( elem, i, match, array ) {+			return i === array.length - 1;+		},++		even: function( elem, i ) {+			return i % 2 === 0;+		},++		odd: function( elem, i ) {+			return i % 2 === 1;+		},++		lt: function( elem, i, match ) {+			return i < match[3] - 0;+		},++		gt: function( elem, i, match ) {+			return i > match[3] - 0;+		},++		nth: function( elem, i, match ) {+			return match[3] - 0 === i;+		},++		eq: function( elem, i, match ) {+			return match[3] - 0 === i;+		}+	},+	filter: {+		PSEUDO: function( elem, match, i, array ) {+			var name = match[1],+				filter = Expr.filters[ name ];++			if ( filter ) {+				return filter( elem, i, match, array );++			} else if ( name === "contains" ) {+				return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0;++			} else if ( name === "not" ) {+				var not = match[3];++				for ( var j = 0, l = not.length; j < l; j++ ) {+					if ( not[j] === elem ) {+						return false;+					}+				}++				return true;++			} else {+				Sizzle.error( name );+			}+		},++		CHILD: function( elem, match ) {+			var first, last,+				doneName, parent, cache,+				count, diff,+				type = match[1],+				node = elem;++			switch ( type ) {+				case "only":+				case "first":+					while ( (node = node.previousSibling) ) {+						if ( node.nodeType === 1 ) {+							return false;+						}+					}++					if ( type === "first" ) {+						return true;+					}++					node = elem;++					/* falls through */+				case "last":+					while ( (node = node.nextSibling) ) {+						if ( node.nodeType === 1 ) {+							return false;+						}+					}++					return true;++				case "nth":+					first = match[2];+					last = match[3];++					if ( first === 1 && last === 0 ) {+						return true;+					}++					doneName = match[0];+					parent = elem.parentNode;++					if ( parent && (parent[ expando ] !== doneName || !elem.nodeIndex) ) {+						count = 0;++						for ( node = parent.firstChild; node; node = node.nextSibling ) {+							if ( node.nodeType === 1 ) {+								node.nodeIndex = ++count;+							}+						}++						parent[ expando ] = doneName;+					}++					diff = elem.nodeIndex - last;++					if ( first === 0 ) {+						return diff === 0;++					} else {+						return ( diff % first === 0 && diff / first >= 0 );+					}+			}+		},++		ID: function( elem, match ) {+			return elem.nodeType === 1 && elem.getAttribute("id") === match;+		},++		TAG: function( elem, match ) {+			return (match === "*" && elem.nodeType === 1) || !!elem.nodeName && elem.nodeName.toLowerCase() === match;+		},++		CLASS: function( elem, match ) {+			return (" " + (elem.className || elem.getAttribute("class")) + " ")+				.indexOf( match ) > -1;+		},++		ATTR: function( elem, match ) {+			var name = match[1],+				result = Sizzle.attr ?+					Sizzle.attr( elem, name ) :+					Expr.attrHandle[ name ] ?+					Expr.attrHandle[ name ]( elem ) :+					elem[ name ] != null ?+						elem[ name ] :+						elem.getAttribute( name ),+				value = result + "",+				type = match[2],+				check = match[4];++			return result == null ?+				type === "!=" :+				!type && Sizzle.attr ?+				result != null :+				type === "=" ?+				value === check :+				type === "*=" ?+				value.indexOf(check) >= 0 :+				type === "~=" ?+				(" " + value + " ").indexOf(check) >= 0 :+				!check ?+				value && result !== false :+				type === "!=" ?+				value !== check :+				type === "^=" ?+				value.indexOf(check) === 0 :+				type === "$=" ?+				value.substr(value.length - check.length) === check :+				type === "|=" ?+				value === check || value.substr(0, check.length + 1) === check + "-" :+				false;+		},++		POS: function( elem, match, i, array ) {+			var name = match[2],+				filter = Expr.setFilters[ name ];++			if ( filter ) {+				return filter( elem, i, match, array );+			}+		}+	}+};++var origPOS = Expr.match.POS,+	fescape = function(all, num){+		return "\\" + (num - 0 + 1);+	};++for ( var type in Expr.match ) {+	Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) );+	Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) );+}+// Expose origPOS+// "global" as in regardless of relation to brackets/parens+Expr.match.globalPOS = origPOS;++var makeArray = function( array, results ) {+	array = Array.prototype.slice.call( array, 0 );++	if ( results ) {+		results.push.apply( results, array );+		return results;+	}++	return array;+};++// Perform a simple check to determine if the browser is capable of+// converting a NodeList to an array using builtin methods.+// Also verifies that the returned array holds DOM nodes+// (which is not the case in the Blackberry browser)+try {+	Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType;++// Provide a fallback method if it does not work+} catch( e ) {+	makeArray = function( array, results ) {+		var i = 0,+			ret = results || [];++		if ( toString.call(array) === "[object Array]" ) {+			Array.prototype.push.apply( ret, array );++		} else {+			if ( typeof array.length === "number" ) {+				for ( var l = array.length; i < l; i++ ) {+					ret.push( array[i] );+				}++			} else {+				for ( ; array[i]; i++ ) {+					ret.push( array[i] );+				}+			}+		}++		return ret;+	};+}++var sortOrder, siblingCheck;++if ( document.documentElement.compareDocumentPosition ) {+	sortOrder = function( a, b ) {+		if ( a === b ) {+			hasDuplicate = true;+			return 0;+		}++		if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {+			return a.compareDocumentPosition ? -1 : 1;+		}++		return a.compareDocumentPosition(b) & 4 ? -1 : 1;+	};++} else {+	sortOrder = function( a, b ) {+		// The nodes are identical, we can exit early+		if ( a === b ) {+			hasDuplicate = true;+			return 0;++		// Fallback to using sourceIndex (in IE) if it's available on both nodes+		} else if ( a.sourceIndex && b.sourceIndex ) {+			return a.sourceIndex - b.sourceIndex;+		}++		var al, bl,+			ap = [],+			bp = [],+			aup = a.parentNode,+			bup = b.parentNode,+			cur = aup;++		// If the nodes are siblings (or identical) we can do a quick check+		if ( aup === bup ) {+			return siblingCheck( a, b );++		// If no parents were found then the nodes are disconnected+		} else if ( !aup ) {+			return -1;++		} else if ( !bup ) {+			return 1;+		}++		// Otherwise they're somewhere else in the tree so we need+		// to build up a full list of the parentNodes for comparison+		while ( cur ) {+			ap.unshift( cur );+			cur = cur.parentNode;+		}++		cur = bup;++		while ( cur ) {+			bp.unshift( cur );+			cur = cur.parentNode;+		}++		al = ap.length;+		bl = bp.length;++		// Start walking down the tree looking for a discrepancy+		for ( var i = 0; i < al && i < bl; i++ ) {+			if ( ap[i] !== bp[i] ) {+				return siblingCheck( ap[i], bp[i] );+			}+		}++		// We ended someplace up the tree so do a sibling check+		return i === al ?+			siblingCheck( a, bp[i], -1 ) :+			siblingCheck( ap[i], b, 1 );+	};++	siblingCheck = function( a, b, ret ) {+		if ( a === b ) {+			return ret;+		}++		var cur = a.nextSibling;++		while ( cur ) {+			if ( cur === b ) {+				return -1;+			}++			cur = cur.nextSibling;+		}++		return 1;+	};+}++// Check to see if the browser returns elements by name when+// querying by getElementById (and provide a workaround)+(function(){+	// We're going to inject a fake input element with a specified name+	var form = document.createElement("div"),+		id = "script" + (new Date()).getTime(),+		root = document.documentElement;++	form.innerHTML = "<a name='" + id + "'/>";++	// Inject it into the root element, check its status, and remove it quickly+	root.insertBefore( form, root.firstChild );++	// The workaround has to do additional checks after a getElementById+	// Which slows things down for other browsers (hence the branching)+	if ( document.getElementById( id ) ) {+		Expr.find.ID = function( match, context, isXML ) {+			if ( typeof context.getElementById !== "undefined" && !isXML ) {+				var m = context.getElementById(match[1]);++				return m ?+					m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ?+						[m] :+						undefined :+					[];+			}+		};++		Expr.filter.ID = function( elem, match ) {+			var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");++			return elem.nodeType === 1 && node && node.nodeValue === match;+		};+	}++	root.removeChild( form );++	// release memory in IE+	root = form = null;+})();++(function(){+	// Check to see if the browser returns only elements+	// when doing getElementsByTagName("*")++	// Create a fake element+	var div = document.createElement("div");+	div.appendChild( document.createComment("") );++	// Make sure no comments are found+	if ( div.getElementsByTagName("*").length > 0 ) {+		Expr.find.TAG = function( match, context ) {+			var results = context.getElementsByTagName( match[1] );++			// Filter out possible comments+			if ( match[1] === "*" ) {+				var tmp = [];++				for ( var i = 0; results[i]; i++ ) {+					if ( results[i].nodeType === 1 ) {+						tmp.push( results[i] );+					}+				}++				results = tmp;+			}++			return results;+		};+	}++	// Check to see if an attribute returns normalized href attributes+	div.innerHTML = "<a href='#'></a>";++	if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&+			div.firstChild.getAttribute("href") !== "#" ) {++		Expr.attrHandle.href = function( elem ) {+			return elem.getAttribute( "href", 2 );+		};+	}++	// release memory in IE+	div = null;+})();++if ( document.querySelectorAll ) {+	(function(){+		var oldSizzle = Sizzle,+			div = document.createElement("div"),+			id = "__sizzle__";++		div.innerHTML = "<p class='TEST'></p>";++		// Safari can't handle uppercase or unicode characters when+		// in quirks mode.+		if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {+			return;+		}++		Sizzle = function( query, context, extra, seed ) {+			context = context || document;++			// Only use querySelectorAll on non-XML documents+			// (ID selectors don't work in non-HTML documents)+			if ( !seed && !Sizzle.isXML(context) ) {+				// See if we find a selector to speed up+				var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query );++				if ( match && (context.nodeType === 1 || context.nodeType === 9) ) {+					// Speed-up: Sizzle("TAG")+					if ( match[1] ) {+						return makeArray( context.getElementsByTagName( query ), extra );++					// Speed-up: Sizzle(".CLASS")+					} else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) {+						return makeArray( context.getElementsByClassName( match[2] ), extra );+					}+				}++				if ( context.nodeType === 9 ) {+					// Speed-up: Sizzle("body")+					// The body element only exists once, optimize finding it+					if ( query === "body" && context.body ) {+						return makeArray( [ context.body ], extra );++					// Speed-up: Sizzle("#ID")+					} else if ( match && match[3] ) {+						var elem = context.getElementById( match[3] );++						// Check parentNode to catch when Blackberry 4.6 returns+						// nodes that are no longer in the document #6963+						if ( elem && elem.parentNode ) {+							// Handle the case where IE and Opera return items+							// by name instead of ID+							if ( elem.id === match[3] ) {+								return makeArray( [ elem ], extra );+							}++						} else {+							return makeArray( [], extra );+						}+					}++					try {+						return makeArray( context.querySelectorAll(query), extra );+					} catch(qsaError) {}++				// qSA works strangely on Element-rooted queries+				// We can work around this by specifying an extra ID on the root+				// and working up from there (Thanks to Andrew Dupont for the technique)+				// IE 8 doesn't work on object elements+				} else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {+					var oldContext = context,+						old = context.getAttribute( "id" ),+						nid = old || id,+						hasParent = context.parentNode,+						relativeHierarchySelector = /^\s*[+~]/.test( query );++					if ( !old ) {+						context.setAttribute( "id", nid );+					} else {+						nid = nid.replace( /'/g, "\\$&" );+					}+					if ( relativeHierarchySelector && hasParent ) {+						context = context.parentNode;+					}++					try {+						if ( !relativeHierarchySelector || hasParent ) {+							return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra );+						}++					} catch(pseudoError) {+					} finally {+						if ( !old ) {+							oldContext.removeAttribute( "id" );+						}+					}+				}+			}++			return oldSizzle(query, context, extra, seed);+		};++		for ( var prop in oldSizzle ) {+			Sizzle[ prop ] = oldSizzle[ prop ];+		}++		// release memory in IE+		div = null;+	})();+}++(function(){+	var html = document.documentElement,+		matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector;++	if ( matches ) {+		// Check to see if it's possible to do matchesSelector+		// on a disconnected node (IE 9 fails this)+		var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ),+			pseudoWorks = false;++		try {+			// This should fail with an exception+			// Gecko does not error, returns false instead+			matches.call( document.documentElement, "[test!='']:sizzle" );++		} catch( pseudoError ) {+			pseudoWorks = true;+		}++		Sizzle.matchesSelector = function( node, expr ) {+			// Make sure that attribute selectors are quoted+			expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");++			if ( !Sizzle.isXML( node ) ) {+				try {+					if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) {+						var ret = matches.call( node, expr );++						// IE 9's matchesSelector returns false on disconnected nodes+						if ( ret || !disconnectedMatch ||+								// As well, disconnected nodes are said to be in a document+								// fragment in IE 9, so check for that+								node.document && node.document.nodeType !== 11 ) {+							return ret;+						}+					}+				} catch(e) {}+			}++			return Sizzle(expr, null, null, [node]).length > 0;+		};+	}+})();++(function(){+	var div = document.createElement("div");++	div.innerHTML = "<div class='test e'></div><div class='test'></div>";++	// Opera can't find a second classname (in 9.6)+	// Also, make sure that getElementsByClassName actually exists+	if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {+		return;+	}++	// Safari caches class attributes, doesn't catch changes (in 3.2)+	div.lastChild.className = "e";++	if ( div.getElementsByClassName("e").length === 1 ) {+		return;+	}++	Expr.order.splice(1, 0, "CLASS");+	Expr.find.CLASS = function( match, context, isXML ) {+		if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {+			return context.getElementsByClassName(match[1]);+		}+	};++	// release memory in IE+	div = null;+})();++function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {+	for ( var i = 0, l = checkSet.length; i < l; i++ ) {+		var elem = checkSet[i];++		if ( elem ) {+			var match = false;++			elem = elem[dir];++			while ( elem ) {+				if ( elem[ expando ] === doneName ) {+					match = checkSet[elem.sizset];+					break;+				}++				if ( elem.nodeType === 1 && !isXML ){+					elem[ expando ] = doneName;+					elem.sizset = i;+				}++				if ( elem.nodeName.toLowerCase() === cur ) {+					match = elem;+					break;+				}++				elem = elem[dir];+			}++			checkSet[i] = match;+		}+	}+}++function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {+	for ( var i = 0, l = checkSet.length; i < l; i++ ) {+		var elem = checkSet[i];++		if ( elem ) {+			var match = false;++			elem = elem[dir];++			while ( elem ) {+				if ( elem[ expando ] === doneName ) {+					match = checkSet[elem.sizset];+					break;+				}++				if ( elem.nodeType === 1 ) {+					if ( !isXML ) {+						elem[ expando ] = doneName;+						elem.sizset = i;+					}++					if ( typeof cur !== "string" ) {+						if ( elem === cur ) {+							match = true;+							break;+						}++					} else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {+						match = elem;+						break;+					}+				}++				elem = elem[dir];+			}++			checkSet[i] = match;+		}+	}+}++if ( document.documentElement.contains ) {+	Sizzle.contains = function( a, b ) {+		return a !== b && (a.contains ? a.contains(b) : true);+	};++} else if ( document.documentElement.compareDocumentPosition ) {+	Sizzle.contains = function( a, b ) {+		return !!(a.compareDocumentPosition(b) & 16);+	};++} else {+	Sizzle.contains = function() {+		return false;+	};+}++Sizzle.isXML = function( elem ) {+	// documentElement is verified for cases where it doesn't yet exist+	// (such as loading iframes in IE - #4833)+	var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;++	return documentElement ? documentElement.nodeName !== "HTML" : false;+};++var posProcess = function( selector, context, seed ) {+	var match,+		tmpSet = [],+		later = "",+		root = context.nodeType ? [context] : context;++	// Position selectors must be done after the filter+	// And so must :not(positional) so we move all PSEUDOs to the end+	while ( (match = Expr.match.PSEUDO.exec( selector )) ) {+		later += match[0];+		selector = selector.replace( Expr.match.PSEUDO, "" );+	}++	selector = Expr.relative[selector] ? selector + "*" : selector;++	for ( var i = 0, l = root.length; i < l; i++ ) {+		Sizzle( selector, root[i], tmpSet, seed );+	}++	return Sizzle.filter( later, tmpSet );+};++// EXPOSE+// Override sizzle attribute retrieval+Sizzle.attr = jQuery.attr;+Sizzle.selectors.attrMap = {};+jQuery.find = Sizzle;+jQuery.expr = Sizzle.selectors;+jQuery.expr[":"] = jQuery.expr.filters;+jQuery.unique = Sizzle.uniqueSort;+jQuery.text = Sizzle.getText;+jQuery.isXMLDoc = Sizzle.isXML;+jQuery.contains = Sizzle.contains;+++})();+++var runtil = /Until$/,+	rparentsprev = /^(?:parents|prevUntil|prevAll)/,+	// Note: This RegExp should be improved, or likely pulled from Sizzle+	rmultiselector = /,/,+	isSimple = /^.[^:#\[\.,]*$/,+	slice = Array.prototype.slice,+	POS = jQuery.expr.match.globalPOS,+	// methods guaranteed to produce a unique set when starting from a unique set+	guaranteedUnique = {+		children: true,+		contents: true,+		next: true,+		prev: true+	};++jQuery.fn.extend({+	find: function( selector ) {+		var self = this,+			i, l;++		if ( typeof selector !== "string" ) {+			return jQuery( selector ).filter(function() {+				for ( i = 0, l = self.length; i < l; i++ ) {+					if ( jQuery.contains( self[ i ], this ) ) {+						return true;+					}+				}+			});+		}++		var ret = this.pushStack( "", "find", selector ),+			length, n, r;++		for ( i = 0, l = this.length; i < l; i++ ) {+			length = ret.length;+			jQuery.find( selector, this[i], ret );++			if ( i > 0 ) {+				// Make sure that the results are unique+				for ( n = length; n < ret.length; n++ ) {+					for ( r = 0; r < length; r++ ) {+						if ( ret[r] === ret[n] ) {+							ret.splice(n--, 1);+							break;+						}+					}+				}+			}+		}++		return ret;+	},++	has: function( target ) {+		var targets = jQuery( target );+		return this.filter(function() {+			for ( var i = 0, l = targets.length; i < l; i++ ) {+				if ( jQuery.contains( this, targets[i] ) ) {+					return true;+				}+			}+		});+	},++	not: function( selector ) {+		return this.pushStack( winnow(this, selector, false), "not", selector);+	},++	filter: function( selector ) {+		return this.pushStack( winnow(this, selector, true), "filter", selector );+	},++	is: function( selector ) {+		return !!selector && (+			typeof selector === "string" ?+				// If this is a positional selector, check membership in the returned set+				// so $("p:first").is("p:last") won't return true for a doc with two "p".+				POS.test( selector ) ?+					jQuery( selector, this.context ).index( this[0] ) >= 0 :+					jQuery.filter( selector, this ).length > 0 :+				this.filter( selector ).length > 0 );+	},++	closest: function( selectors, context ) {+		var ret = [], i, l, cur = this[0];++		// Array (deprecated as of jQuery 1.7)+		if ( jQuery.isArray( selectors ) ) {+			var level = 1;++			while ( cur && cur.ownerDocument && cur !== context ) {+				for ( i = 0; i < selectors.length; i++ ) {++					if ( jQuery( cur ).is( selectors[ i ] ) ) {+						ret.push({ selector: selectors[ i ], elem: cur, level: level });+					}+				}++				cur = cur.parentNode;+				level++;+			}++			return ret;+		}++		// String+		var pos = POS.test( selectors ) || typeof selectors !== "string" ?+				jQuery( selectors, context || this.context ) :+				0;++		for ( i = 0, l = this.length; i < l; i++ ) {+			cur = this[i];++			while ( cur ) {+				if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {+					ret.push( cur );+					break;++				} else {+					cur = cur.parentNode;+					if ( !cur || !cur.ownerDocument || cur === context || cur.nodeType === 11 ) {+						break;+					}+				}+			}+		}++		ret = ret.length > 1 ? jQuery.unique( ret ) : ret;++		return this.pushStack( ret, "closest", selectors );+	},++	// Determine the position of an element within+	// the matched set of elements+	index: function( elem ) {++		// No argument, return index in parent+		if ( !elem ) {+			return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1;+		}++		// index in selector+		if ( typeof elem === "string" ) {+			return jQuery.inArray( this[0], jQuery( elem ) );+		}++		// Locate the position of the desired element+		return jQuery.inArray(+			// If it receives a jQuery object, the first element is used+			elem.jquery ? elem[0] : elem, this );+	},++	add: function( selector, context ) {+		var set = typeof selector === "string" ?+				jQuery( selector, context ) :+				jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),+			all = jQuery.merge( this.get(), set );++		return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?+			all :+			jQuery.unique( all ) );+	},++	andSelf: function() {+		return this.add( this.prevObject );+	}+});++// A painfully simple check to see if an element is disconnected+// from a document (should be improved, where feasible).+function isDisconnected( node ) {+	return !node || !node.parentNode || node.parentNode.nodeType === 11;+}++jQuery.each({+	parent: function( elem ) {+		var parent = elem.parentNode;+		return parent && parent.nodeType !== 11 ? parent : null;+	},+	parents: function( elem ) {+		return jQuery.dir( elem, "parentNode" );+	},+	parentsUntil: function( elem, i, until ) {+		return jQuery.dir( elem, "parentNode", until );+	},+	next: function( elem ) {+		return jQuery.nth( elem, 2, "nextSibling" );+	},+	prev: function( elem ) {+		return jQuery.nth( elem, 2, "previousSibling" );+	},+	nextAll: function( elem ) {+		return jQuery.dir( elem, "nextSibling" );+	},+	prevAll: function( elem ) {+		return jQuery.dir( elem, "previousSibling" );+	},+	nextUntil: function( elem, i, until ) {+		return jQuery.dir( elem, "nextSibling", until );+	},+	prevUntil: function( elem, i, until ) {+		return jQuery.dir( elem, "previousSibling", until );+	},+	siblings: function( elem ) {+		return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );+	},+	children: function( elem ) {+		return jQuery.sibling( elem.firstChild );+	},+	contents: function( elem ) {+		return jQuery.nodeName( elem, "iframe" ) ?+			elem.contentDocument || elem.contentWindow.document :+			jQuery.makeArray( elem.childNodes );+	}+}, function( name, fn ) {+	jQuery.fn[ name ] = function( until, selector ) {+		var ret = jQuery.map( this, fn, until );++		if ( !runtil.test( name ) ) {+			selector = until;+		}++		if ( selector && typeof selector === "string" ) {+			ret = jQuery.filter( selector, ret );+		}++		ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret;++		if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {+			ret = ret.reverse();+		}++		return this.pushStack( ret, name, slice.call( arguments ).join(",") );+	};+});++jQuery.extend({+	filter: function( expr, elems, not ) {+		if ( not ) {+			expr = ":not(" + expr + ")";+		}++		return elems.length === 1 ?+			jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :+			jQuery.find.matches(expr, elems);+	},++	dir: function( elem, dir, until ) {+		var matched = [],+			cur = elem[ dir ];++		while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {+			if ( cur.nodeType === 1 ) {+				matched.push( cur );+			}+			cur = cur[dir];+		}+		return matched;+	},++	nth: function( cur, result, dir, elem ) {+		result = result || 1;+		var num = 0;++		for ( ; cur; cur = cur[dir] ) {+			if ( cur.nodeType === 1 && ++num === result ) {+				break;+			}+		}++		return cur;+	},++	sibling: function( n, elem ) {+		var r = [];++		for ( ; n; n = n.nextSibling ) {+			if ( n.nodeType === 1 && n !== elem ) {+				r.push( n );+			}+		}++		return r;+	}+});++// Implement the identical functionality for filter and not+function winnow( elements, qualifier, keep ) {++	// Can't pass null or undefined to indexOf in Firefox 4+	// Set to 0 to skip string check+	qualifier = qualifier || 0;++	if ( jQuery.isFunction( qualifier ) ) {+		return jQuery.grep(elements, function( elem, i ) {+			var retVal = !!qualifier.call( elem, i, elem );+			return retVal === keep;+		});++	} else if ( qualifier.nodeType ) {+		return jQuery.grep(elements, function( elem, i ) {+			return ( elem === qualifier ) === keep;+		});++	} else if ( typeof qualifier === "string" ) {+		var filtered = jQuery.grep(elements, function( elem ) {+			return elem.nodeType === 1;+		});++		if ( isSimple.test( qualifier ) ) {+			return jQuery.filter(qualifier, filtered, !keep);+		} else {+			qualifier = jQuery.filter( qualifier, filtered );+		}+	}++	return jQuery.grep(elements, function( elem, i ) {+		return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep;+	});+}+++++function createSafeFragment( document ) {+	var list = nodeNames.split( "|" ),+	safeFrag = document.createDocumentFragment();++	if ( safeFrag.createElement ) {+		while ( list.length ) {+			safeFrag.createElement(+				list.pop()+			);+		}+	}+	return safeFrag;+}++var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" ++		"header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",+	rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,+	rleadingWhitespace = /^\s+/,+	rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,+	rtagName = /<([\w:]+)/,+	rtbody = /<tbody/i,+	rhtml = /<|&#?\w+;/,+	rnoInnerhtml = /<(?:script|style)/i,+	rnocache = /<(?:script|object|embed|option|style)/i,+	rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),+	// checked="checked" or checked+	rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,+	rscriptType = /\/(java|ecma)script/i,+	rcleanScript = /^\s*<!(?:\[CDATA\[|\-\-)/,+	wrapMap = {+		option: [ 1, "<select multiple='multiple'>", "</select>" ],+		legend: [ 1, "<fieldset>", "</fieldset>" ],+		thead: [ 1, "<table>", "</table>" ],+		tr: [ 2, "<table><tbody>", "</tbody></table>" ],+		td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],+		col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],+		area: [ 1, "<map>", "</map>" ],+		_default: [ 0, "", "" ]+	},+	safeFragment = createSafeFragment( document );++wrapMap.optgroup = wrapMap.option;+wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;+wrapMap.th = wrapMap.td;++// IE can't serialize <link> and <script> tags normally+if ( !jQuery.support.htmlSerialize ) {+	wrapMap._default = [ 1, "div<div>", "</div>" ];+}++jQuery.fn.extend({+	text: function( value ) {+		return jQuery.access( this, function( value ) {+			return value === undefined ?+				jQuery.text( this ) :+				this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) );+		}, null, value, arguments.length );+	},++	wrapAll: function( html ) {+		if ( jQuery.isFunction( html ) ) {+			return this.each(function(i) {+				jQuery(this).wrapAll( html.call(this, i) );+			});+		}++		if ( this[0] ) {+			// The elements to wrap the target around+			var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);++			if ( this[0].parentNode ) {+				wrap.insertBefore( this[0] );+			}++			wrap.map(function() {+				var elem = this;++				while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {+					elem = elem.firstChild;+				}++				return elem;+			}).append( this );+		}++		return this;+	},++	wrapInner: function( html ) {+		if ( jQuery.isFunction( html ) ) {+			return this.each(function(i) {+				jQuery(this).wrapInner( html.call(this, i) );+			});+		}++		return this.each(function() {+			var self = jQuery( this ),+				contents = self.contents();++			if ( contents.length ) {+				contents.wrapAll( html );++			} else {+				self.append( html );+			}+		});+	},++	wrap: function( html ) {+		var isFunction = jQuery.isFunction( html );++		return this.each(function(i) {+			jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );+		});+	},++	unwrap: function() {+		return this.parent().each(function() {+			if ( !jQuery.nodeName( this, "body" ) ) {+				jQuery( this ).replaceWith( this.childNodes );+			}+		}).end();+	},++	append: function() {+		return this.domManip(arguments, true, function( elem ) {+			if ( this.nodeType === 1 ) {+				this.appendChild( elem );+			}+		});+	},++	prepend: function() {+		return this.domManip(arguments, true, function( elem ) {+			if ( this.nodeType === 1 ) {+				this.insertBefore( elem, this.firstChild );+			}+		});+	},++	before: function() {+		if ( this[0] && this[0].parentNode ) {+			return this.domManip(arguments, false, function( elem ) {+				this.parentNode.insertBefore( elem, this );+			});+		} else if ( arguments.length ) {+			var set = jQuery.clean( arguments );+			set.push.apply( set, this.toArray() );+			return this.pushStack( set, "before", arguments );+		}+	},++	after: function() {+		if ( this[0] && this[0].parentNode ) {+			return this.domManip(arguments, false, function( elem ) {+				this.parentNode.insertBefore( elem, this.nextSibling );+			});+		} else if ( arguments.length ) {+			var set = this.pushStack( this, "after", arguments );+			set.push.apply( set, jQuery.clean(arguments) );+			return set;+		}+	},++	// keepData is for internal use only--do not document+	remove: function( selector, keepData ) {+		for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {+			if ( !selector || jQuery.filter( selector, [ elem ] ).length ) {+				if ( !keepData && elem.nodeType === 1 ) {+					jQuery.cleanData( elem.getElementsByTagName("*") );+					jQuery.cleanData( [ elem ] );+				}++				if ( elem.parentNode ) {+					elem.parentNode.removeChild( elem );+				}+			}+		}++		return this;+	},++	empty: function() {+		for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {+			// Remove element nodes and prevent memory leaks+			if ( elem.nodeType === 1 ) {+				jQuery.cleanData( elem.getElementsByTagName("*") );+			}++			// Remove any remaining nodes+			while ( elem.firstChild ) {+				elem.removeChild( elem.firstChild );+			}+		}++		return this;+	},++	clone: function( dataAndEvents, deepDataAndEvents ) {+		dataAndEvents = dataAndEvents == null ? false : dataAndEvents;+		deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;++		return this.map( function () {+			return jQuery.clone( this, dataAndEvents, deepDataAndEvents );+		});+	},++	html: function( value ) {+		return jQuery.access( this, function( value ) {+			var elem = this[0] || {},+				i = 0,+				l = this.length;++			if ( value === undefined ) {+				return elem.nodeType === 1 ?+					elem.innerHTML.replace( rinlinejQuery, "" ) :+					null;+			}+++			if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&+				( jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&+				!wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) {++				value = value.replace( rxhtmlTag, "<$1></$2>" );++				try {+					for (; i < l; i++ ) {+						// Remove element nodes and prevent memory leaks+						elem = this[i] || {};+						if ( elem.nodeType === 1 ) {+							jQuery.cleanData( elem.getElementsByTagName( "*" ) );+							elem.innerHTML = value;+						}+					}++					elem = 0;++				// If using innerHTML throws an exception, use the fallback method+				} catch(e) {}+			}++			if ( elem ) {+				this.empty().append( value );+			}+		}, null, value, arguments.length );+	},++	replaceWith: function( value ) {+		if ( this[0] && this[0].parentNode ) {+			// Make sure that the elements are removed from the DOM before they are inserted+			// this can help fix replacing a parent with child elements+			if ( jQuery.isFunction( value ) ) {+				return this.each(function(i) {+					var self = jQuery(this), old = self.html();+					self.replaceWith( value.call( this, i, old ) );+				});+			}++			if ( typeof value !== "string" ) {+				value = jQuery( value ).detach();+			}++			return this.each(function() {+				var next = this.nextSibling,+					parent = this.parentNode;++				jQuery( this ).remove();++				if ( next ) {+					jQuery(next).before( value );+				} else {+					jQuery(parent).append( value );+				}+			});+		} else {+			return this.length ?+				this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) :+				this;+		}+	},++	detach: function( selector ) {+		return this.remove( selector, true );+	},++	domManip: function( args, table, callback ) {+		var results, first, fragment, parent,+			value = args[0],+			scripts = [];++		// We can't cloneNode fragments that contain checked, in WebKit+		if ( !jQuery.support.checkClone && arguments.length === 3 && typeof value === "string" && rchecked.test( value ) ) {+			return this.each(function() {+				jQuery(this).domManip( args, table, callback, true );+			});+		}++		if ( jQuery.isFunction(value) ) {+			return this.each(function(i) {+				var self = jQuery(this);+				args[0] = value.call(this, i, table ? self.html() : undefined);+				self.domManip( args, table, callback );+			});+		}++		if ( this[0] ) {+			parent = value && value.parentNode;++			// If we're in a fragment, just use that instead of building a new one+			if ( jQuery.support.parentNode && parent && parent.nodeType === 11 && parent.childNodes.length === this.length ) {+				results = { fragment: parent };++			} else {+				results = jQuery.buildFragment( args, this, scripts );+			}++			fragment = results.fragment;++			if ( fragment.childNodes.length === 1 ) {+				first = fragment = fragment.firstChild;+			} else {+				first = fragment.firstChild;+			}++			if ( first ) {+				table = table && jQuery.nodeName( first, "tr" );++				for ( var i = 0, l = this.length, lastIndex = l - 1; i < l; i++ ) {+					callback.call(+						table ?+							root(this[i], first) :+							this[i],+						// Make sure that we do not leak memory by inadvertently discarding+						// the original fragment (which might have attached data) instead of+						// using it; in addition, use the original fragment object for the last+						// item instead of first because it can end up being emptied incorrectly+						// in certain situations (Bug #8070).+						// Fragments from the fragment cache must always be cloned and never used+						// in place.+						results.cacheable || ( l > 1 && i < lastIndex ) ?+							jQuery.clone( fragment, true, true ) :+							fragment+					);+				}+			}++			if ( scripts.length ) {+				jQuery.each( scripts, function( i, elem ) {+					if ( elem.src ) {+						jQuery.ajax({+							type: "GET",+							global: false,+							url: elem.src,+							async: false,+							dataType: "script"+						});+					} else {+						jQuery.globalEval( ( elem.text || elem.textContent || elem.innerHTML || "" ).replace( rcleanScript, "/*$0*/" ) );+					}++					if ( elem.parentNode ) {+						elem.parentNode.removeChild( elem );+					}+				});+			}+		}++		return this;+	}+});++function root( elem, cur ) {+	return jQuery.nodeName(elem, "table") ?+		(elem.getElementsByTagName("tbody")[0] ||+		elem.appendChild(elem.ownerDocument.createElement("tbody"))) :+		elem;+}++function cloneCopyEvent( src, dest ) {++	if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {+		return;+	}++	var type, i, l,+		oldData = jQuery._data( src ),+		curData = jQuery._data( dest, oldData ),+		events = oldData.events;++	if ( events ) {+		delete curData.handle;+		curData.events = {};++		for ( type in events ) {+			for ( i = 0, l = events[ type ].length; i < l; i++ ) {+				jQuery.event.add( dest, type, events[ type ][ i ] );+			}+		}+	}++	// make the cloned public data object a copy from the original+	if ( curData.data ) {+		curData.data = jQuery.extend( {}, curData.data );+	}+}++function cloneFixAttributes( src, dest ) {+	var nodeName;++	// We do not need to do anything for non-Elements+	if ( dest.nodeType !== 1 ) {+		return;+	}++	// clearAttributes removes the attributes, which we don't want,+	// but also removes the attachEvent events, which we *do* want+	if ( dest.clearAttributes ) {+		dest.clearAttributes();+	}++	// mergeAttributes, in contrast, only merges back on the+	// original attributes, not the events+	if ( dest.mergeAttributes ) {+		dest.mergeAttributes( src );+	}++	nodeName = dest.nodeName.toLowerCase();++	// IE6-8 fail to clone children inside object elements that use+	// the proprietary classid attribute value (rather than the type+	// attribute) to identify the type of content to display+	if ( nodeName === "object" ) {+		dest.outerHTML = src.outerHTML;++	} else if ( nodeName === "input" && (src.type === "checkbox" || src.type === "radio") ) {+		// IE6-8 fails to persist the checked state of a cloned checkbox+		// or radio button. Worse, IE6-7 fail to give the cloned element+		// a checked appearance if the defaultChecked value isn't also set+		if ( src.checked ) {+			dest.defaultChecked = dest.checked = src.checked;+		}++		// IE6-7 get confused and end up setting the value of a cloned+		// checkbox/radio button to an empty string instead of "on"+		if ( dest.value !== src.value ) {+			dest.value = src.value;+		}++	// IE6-8 fails to return the selected option to the default selected+	// state when cloning options+	} else if ( nodeName === "option" ) {+		dest.selected = src.defaultSelected;++	// IE6-8 fails to set the defaultValue to the correct value when+	// cloning other types of input fields+	} else if ( nodeName === "input" || nodeName === "textarea" ) {+		dest.defaultValue = src.defaultValue;++	// IE blanks contents when cloning scripts+	} else if ( nodeName === "script" && dest.text !== src.text ) {+		dest.text = src.text;+	}++	// Event data gets referenced instead of copied if the expando+	// gets copied too+	dest.removeAttribute( jQuery.expando );++	// Clear flags for bubbling special change/submit events, they must+	// be reattached when the newly cloned events are first activated+	dest.removeAttribute( "_submit_attached" );+	dest.removeAttribute( "_change_attached" );+}++jQuery.buildFragment = function( args, nodes, scripts ) {+	var fragment, cacheable, cacheresults, doc,+	first = args[ 0 ];++	// nodes may contain either an explicit document object,+	// a jQuery collection or context object.+	// If nodes[0] contains a valid object to assign to doc+	if ( nodes && nodes[0] ) {+		doc = nodes[0].ownerDocument || nodes[0];+	}++	// Ensure that an attr object doesn't incorrectly stand in as a document object+	// Chrome and Firefox seem to allow this to occur and will throw exception+	// Fixes #8950+	if ( !doc.createDocumentFragment ) {+		doc = document;+	}++	// Only cache "small" (1/2 KB) HTML strings that are associated with the main document+	// Cloning options loses the selected state, so don't cache them+	// IE 6 doesn't like it when you put <object> or <embed> elements in a fragment+	// Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache+	// Lastly, IE6,7,8 will not correctly reuse cached fragments that were created from unknown elems #10501+	if ( args.length === 1 && typeof first === "string" && first.length < 512 && doc === document &&+		first.charAt(0) === "<" && !rnocache.test( first ) &&+		(jQuery.support.checkClone || !rchecked.test( first )) &&+		(jQuery.support.html5Clone || !rnoshimcache.test( first )) ) {++		cacheable = true;++		cacheresults = jQuery.fragments[ first ];+		if ( cacheresults && cacheresults !== 1 ) {+			fragment = cacheresults;+		}+	}++	if ( !fragment ) {+		fragment = doc.createDocumentFragment();+		jQuery.clean( args, doc, fragment, scripts );+	}++	if ( cacheable ) {+		jQuery.fragments[ first ] = cacheresults ? fragment : 1;+	}++	return { fragment: fragment, cacheable: cacheable };+};++jQuery.fragments = {};++jQuery.each({+	appendTo: "append",+	prependTo: "prepend",+	insertBefore: "before",+	insertAfter: "after",+	replaceAll: "replaceWith"+}, function( name, original ) {+	jQuery.fn[ name ] = function( selector ) {+		var ret = [],+			insert = jQuery( selector ),+			parent = this.length === 1 && this[0].parentNode;++		if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) {+			insert[ original ]( this[0] );+			return this;++		} else {+			for ( var i = 0, l = insert.length; i < l; i++ ) {+				var elems = ( i > 0 ? this.clone(true) : this ).get();+				jQuery( insert[i] )[ original ]( elems );+				ret = ret.concat( elems );+			}++			return this.pushStack( ret, name, insert.selector );+		}+	};+});++function getAll( elem ) {+	if ( typeof elem.getElementsByTagName !== "undefined" ) {+		return elem.getElementsByTagName( "*" );++	} else if ( typeof elem.querySelectorAll !== "undefined" ) {+		return elem.querySelectorAll( "*" );++	} else {+		return [];+	}+}++// Used in clean, fixes the defaultChecked property+function fixDefaultChecked( elem ) {+	if ( elem.type === "checkbox" || elem.type === "radio" ) {+		elem.defaultChecked = elem.checked;+	}+}+// Finds all inputs and passes them to fixDefaultChecked+function findInputs( elem ) {+	var nodeName = ( elem.nodeName || "" ).toLowerCase();+	if ( nodeName === "input" ) {+		fixDefaultChecked( elem );+	// Skip scripts, get other children+	} else if ( nodeName !== "script" && typeof elem.getElementsByTagName !== "undefined" ) {+		jQuery.grep( elem.getElementsByTagName("input"), fixDefaultChecked );+	}+}++// Derived From: http://www.iecss.com/shimprove/javascript/shimprove.1-0-1.js+function shimCloneNode( elem ) {+	var div = document.createElement( "div" );+	safeFragment.appendChild( div );++	div.innerHTML = elem.outerHTML;+	return div.firstChild;+}++jQuery.extend({+	clone: function( elem, dataAndEvents, deepDataAndEvents ) {+		var srcElements,+			destElements,+			i,+			// IE<=8 does not properly clone detached, unknown element nodes+			clone = jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ?+				elem.cloneNode( true ) :+				shimCloneNode( elem );++		if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&+				(elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {+			// IE copies events bound via attachEvent when using cloneNode.+			// Calling detachEvent on the clone will also remove the events+			// from the original. In order to get around this, we use some+			// proprietary methods to clear the events. Thanks to MooTools+			// guys for this hotness.++			cloneFixAttributes( elem, clone );++			// Using Sizzle here is crazy slow, so we use getElementsByTagName instead+			srcElements = getAll( elem );+			destElements = getAll( clone );++			// Weird iteration because IE will replace the length property+			// with an element if you are cloning the body and one of the+			// elements on the page has a name or id of "length"+			for ( i = 0; srcElements[i]; ++i ) {+				// Ensure that the destination node is not null; Fixes #9587+				if ( destElements[i] ) {+					cloneFixAttributes( srcElements[i], destElements[i] );+				}+			}+		}++		// Copy the events from the original to the clone+		if ( dataAndEvents ) {+			cloneCopyEvent( elem, clone );++			if ( deepDataAndEvents ) {+				srcElements = getAll( elem );+				destElements = getAll( clone );++				for ( i = 0; srcElements[i]; ++i ) {+					cloneCopyEvent( srcElements[i], destElements[i] );+				}+			}+		}++		srcElements = destElements = null;++		// Return the cloned set+		return clone;+	},++	clean: function( elems, context, fragment, scripts ) {+		var checkScriptType, script, j,+				ret = [];++		context = context || document;++		// !context.createElement fails in IE with an error but returns typeof 'object'+		if ( typeof context.createElement === "undefined" ) {+			context = context.ownerDocument || context[0] && context[0].ownerDocument || document;+		}++		for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {+			if ( typeof elem === "number" ) {+				elem += "";+			}++			if ( !elem ) {+				continue;+			}++			// Convert html string into DOM nodes+			if ( typeof elem === "string" ) {+				if ( !rhtml.test( elem ) ) {+					elem = context.createTextNode( elem );+				} else {+					// Fix "XHTML"-style tags in all browsers+					elem = elem.replace(rxhtmlTag, "<$1></$2>");++					// Trim whitespace, otherwise indexOf won't work as expected+					var tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase(),+						wrap = wrapMap[ tag ] || wrapMap._default,+						depth = wrap[0],+						div = context.createElement("div"),+						safeChildNodes = safeFragment.childNodes,+						remove;++					// Append wrapper element to unknown element safe doc fragment+					if ( context === document ) {+						// Use the fragment we've already created for this document+						safeFragment.appendChild( div );+					} else {+						// Use a fragment created with the owner document+						createSafeFragment( context ).appendChild( div );+					}++					// Go to html and back, then peel off extra wrappers+					div.innerHTML = wrap[1] + elem + wrap[2];++					// Move to the right depth+					while ( depth-- ) {+						div = div.lastChild;+					}++					// Remove IE's autoinserted <tbody> from table fragments+					if ( !jQuery.support.tbody ) {++						// String was a <table>, *may* have spurious <tbody>+						var hasBody = rtbody.test(elem),+							tbody = tag === "table" && !hasBody ?+								div.firstChild && div.firstChild.childNodes :++								// String was a bare <thead> or <tfoot>+								wrap[1] === "<table>" && !hasBody ?+									div.childNodes :+									[];++						for ( j = tbody.length - 1; j >= 0 ; --j ) {+							if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {+								tbody[ j ].parentNode.removeChild( tbody[ j ] );+							}+						}+					}++					// IE completely kills leading whitespace when innerHTML is used+					if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {+						div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );+					}++					elem = div.childNodes;++					// Clear elements from DocumentFragment (safeFragment or otherwise)+					// to avoid hoarding elements. Fixes #11356+					if ( div ) {+						div.parentNode.removeChild( div );++						// Guard against -1 index exceptions in FF3.6+						if ( safeChildNodes.length > 0 ) {+							remove = safeChildNodes[ safeChildNodes.length - 1 ];++							if ( remove && remove.parentNode ) {+								remove.parentNode.removeChild( remove );+							}+						}+					}+				}+			}++			// Resets defaultChecked for any radios and checkboxes+			// about to be appended to the DOM in IE 6/7 (#8060)+			var len;+			if ( !jQuery.support.appendChecked ) {+				if ( elem[0] && typeof (len = elem.length) === "number" ) {+					for ( j = 0; j < len; j++ ) {+						findInputs( elem[j] );+					}+				} else {+					findInputs( elem );+				}+			}++			if ( elem.nodeType ) {+				ret.push( elem );+			} else {+				ret = jQuery.merge( ret, elem );+			}+		}++		if ( fragment ) {+			checkScriptType = function( elem ) {+				return !elem.type || rscriptType.test( elem.type );+			};+			for ( i = 0; ret[i]; i++ ) {+				script = ret[i];+				if ( scripts && jQuery.nodeName( script, "script" ) && (!script.type || rscriptType.test( script.type )) ) {+					scripts.push( script.parentNode ? script.parentNode.removeChild( script ) : script );++				} else {+					if ( script.nodeType === 1 ) {+						var jsTags = jQuery.grep( script.getElementsByTagName( "script" ), checkScriptType );++						ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );+					}+					fragment.appendChild( script );+				}+			}+		}++		return ret;+	},++	cleanData: function( elems ) {+		var data, id,+			cache = jQuery.cache,+			special = jQuery.event.special,+			deleteExpando = jQuery.support.deleteExpando;++		for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {+			if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {+				continue;+			}++			id = elem[ jQuery.expando ];++			if ( id ) {+				data = cache[ id ];++				if ( data && data.events ) {+					for ( var type in data.events ) {+						if ( special[ type ] ) {+							jQuery.event.remove( elem, type );++						// This is a shortcut to avoid jQuery.event.remove's overhead+						} else {+							jQuery.removeEvent( elem, type, data.handle );+						}+					}++					// Null the DOM reference to avoid IE6/7/8 leak (#7054)+					if ( data.handle ) {+						data.handle.elem = null;+					}+				}++				if ( deleteExpando ) {+					delete elem[ jQuery.expando ];++				} else if ( elem.removeAttribute ) {+					elem.removeAttribute( jQuery.expando );+				}++				delete cache[ id ];+			}+		}+	}+});+++++var ralpha = /alpha\([^)]*\)/i,+	ropacity = /opacity=([^)]*)/,+	// fixed for IE9, see #8346+	rupper = /([A-Z]|^ms)/g,+	rnum = /^[\-+]?(?:\d*\.)?\d+$/i,+	rnumnonpx = /^-?(?:\d*\.)?\d+(?!px)[^\d\s]+$/i,+	rrelNum = /^([\-+])=([\-+.\de]+)/,+	rmargin = /^margin/,++	cssShow = { position: "absolute", visibility: "hidden", display: "block" },++	// order is important!+	cssExpand = [ "Top", "Right", "Bottom", "Left" ],++	curCSS,++	getComputedStyle,+	currentStyle;++jQuery.fn.css = function( name, value ) {+	return jQuery.access( this, function( elem, name, value ) {+		return value !== undefined ?+			jQuery.style( elem, name, value ) :+			jQuery.css( elem, name );+	}, name, value, arguments.length > 1 );+};++jQuery.extend({+	// Add in style property hooks for overriding the default+	// behavior of getting and setting a style property+	cssHooks: {+		opacity: {+			get: function( elem, computed ) {+				if ( computed ) {+					// We should always get a number back from opacity+					var ret = curCSS( elem, "opacity" );+					return ret === "" ? "1" : ret;++				} else {+					return elem.style.opacity;+				}+			}+		}+	},++	// Exclude the following css properties to add px+	cssNumber: {+		"fillOpacity": true,+		"fontWeight": true,+		"lineHeight": true,+		"opacity": true,+		"orphans": true,+		"widows": true,+		"zIndex": true,+		"zoom": true+	},++	// Add in properties whose names you wish to fix before+	// setting or getting the value+	cssProps: {+		// normalize float css property+		"float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat"+	},++	// Get and set the style property on a DOM Node+	style: function( elem, name, value, extra ) {+		// Don't set styles on text and comment nodes+		if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {+			return;+		}++		// Make sure that we're working with the right name+		var ret, type, origName = jQuery.camelCase( name ),+			style = elem.style, hooks = jQuery.cssHooks[ origName ];++		name = jQuery.cssProps[ origName ] || origName;++		// Check if we're setting a value+		if ( value !== undefined ) {+			type = typeof value;++			// convert relative number strings (+= or -=) to relative numbers. #7345+			if ( type === "string" && (ret = rrelNum.exec( value )) ) {+				value = ( +( ret[1] + 1) * +ret[2] ) + parseFloat( jQuery.css( elem, name ) );+				// Fixes bug #9237+				type = "number";+			}++			// Make sure that NaN and null values aren't set. See: #7116+			if ( value == null || type === "number" && isNaN( value ) ) {+				return;+			}++			// If a number was passed in, add 'px' to the (except for certain CSS properties)+			if ( type === "number" && !jQuery.cssNumber[ origName ] ) {+				value += "px";+			}++			// If a hook was provided, use that value, otherwise just set the specified value+			if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value )) !== undefined ) {+				// Wrapped to prevent IE from throwing errors when 'invalid' values are provided+				// Fixes bug #5509+				try {+					style[ name ] = value;+				} catch(e) {}+			}++		} else {+			// If a hook was provided get the non-computed value from there+			if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {+				return ret;+			}++			// Otherwise just get the value from the style object+			return style[ name ];+		}+	},++	css: function( elem, name, extra ) {+		var ret, hooks;++		// Make sure that we're working with the right name+		name = jQuery.camelCase( name );+		hooks = jQuery.cssHooks[ name ];+		name = jQuery.cssProps[ name ] || name;++		// cssFloat needs a special treatment+		if ( name === "cssFloat" ) {+			name = "float";+		}++		// If a hook was provided get the computed value from there+		if ( hooks && "get" in hooks && (ret = hooks.get( elem, true, extra )) !== undefined ) {+			return ret;++		// Otherwise, if a way to get the computed value exists, use that+		} else if ( curCSS ) {+			return curCSS( elem, name );+		}+	},++	// A method for quickly swapping in/out CSS properties to get correct calculations+	swap: function( elem, options, callback ) {+		var old = {},+			ret, name;++		// Remember the old values, and insert the new ones+		for ( name in options ) {+			old[ name ] = elem.style[ name ];+			elem.style[ name ] = options[ name ];+		}++		ret = callback.call( elem );++		// Revert the old values+		for ( name in options ) {+			elem.style[ name ] = old[ name ];+		}++		return ret;+	}+});++// DEPRECATED in 1.3, Use jQuery.css() instead+jQuery.curCSS = jQuery.css;++if ( document.defaultView && document.defaultView.getComputedStyle ) {+	getComputedStyle = function( elem, name ) {+		var ret, defaultView, computedStyle, width,+			style = elem.style;++		name = name.replace( rupper, "-$1" ).toLowerCase();++		if ( (defaultView = elem.ownerDocument.defaultView) &&+				(computedStyle = defaultView.getComputedStyle( elem, null )) ) {++			ret = computedStyle.getPropertyValue( name );+			if ( ret === "" && !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) {+				ret = jQuery.style( elem, name );+			}+		}++		// A tribute to the "awesome hack by Dean Edwards"+		// WebKit uses "computed value (percentage if specified)" instead of "used value" for margins+		// which is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values+		if ( !jQuery.support.pixelMargin && computedStyle && rmargin.test( name ) && rnumnonpx.test( ret ) ) {+			width = style.width;+			style.width = ret;+			ret = computedStyle.width;+			style.width = width;+		}++		return ret;+	};+}++if ( document.documentElement.currentStyle ) {+	currentStyle = function( elem, name ) {+		var left, rsLeft, uncomputed,+			ret = elem.currentStyle && elem.currentStyle[ name ],+			style = elem.style;++		// Avoid setting ret to empty string here+		// so we don't default to auto+		if ( ret == null && style && (uncomputed = style[ name ]) ) {+			ret = uncomputed;+		}++		// From the awesome hack by Dean Edwards+		// http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291++		// If we're not dealing with a regular pixel number+		// but a number that has a weird ending, we need to convert it to pixels+		if ( rnumnonpx.test( ret ) ) {++			// Remember the original values+			left = style.left;+			rsLeft = elem.runtimeStyle && elem.runtimeStyle.left;++			// Put in the new values to get a computed value out+			if ( rsLeft ) {+				elem.runtimeStyle.left = elem.currentStyle.left;+			}+			style.left = name === "fontSize" ? "1em" : ret;+			ret = style.pixelLeft + "px";++			// Revert the changed values+			style.left = left;+			if ( rsLeft ) {+				elem.runtimeStyle.left = rsLeft;+			}+		}++		return ret === "" ? "auto" : ret;+	};+}++curCSS = getComputedStyle || currentStyle;++function getWidthOrHeight( elem, name, extra ) {++	// Start with offset property+	var val = name === "width" ? elem.offsetWidth : elem.offsetHeight,+		i = name === "width" ? 1 : 0,+		len = 4;++	if ( val > 0 ) {+		if ( extra !== "border" ) {+			for ( ; i < len; i += 2 ) {+				if ( !extra ) {+					val -= parseFloat( jQuery.css( elem, "padding" + cssExpand[ i ] ) ) || 0;+				}+				if ( extra === "margin" ) {+					val += parseFloat( jQuery.css( elem, extra + cssExpand[ i ] ) ) || 0;+				} else {+					val -= parseFloat( jQuery.css( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0;+				}+			}+		}++		return val + "px";+	}++	// Fall back to computed then uncomputed css if necessary+	val = curCSS( elem, name );+	if ( val < 0 || val == null ) {+		val = elem.style[ name ];+	}++	// Computed unit is not pixels. Stop here and return.+	if ( rnumnonpx.test(val) ) {+		return val;+	}++	// Normalize "", auto, and prepare for extra+	val = parseFloat( val ) || 0;++	// Add padding, border, margin+	if ( extra ) {+		for ( ; i < len; i += 2 ) {+			val += parseFloat( jQuery.css( elem, "padding" + cssExpand[ i ] ) ) || 0;+			if ( extra !== "padding" ) {+				val += parseFloat( jQuery.css( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0;+			}+			if ( extra === "margin" ) {+				val += parseFloat( jQuery.css( elem, extra + cssExpand[ i ]) ) || 0;+			}+		}+	}++	return val + "px";+}++jQuery.each([ "height", "width" ], function( i, name ) {+	jQuery.cssHooks[ name ] = {+		get: function( elem, computed, extra ) {+			if ( computed ) {+				if ( elem.offsetWidth !== 0 ) {+					return getWidthOrHeight( elem, name, extra );+				} else {+					return jQuery.swap( elem, cssShow, function() {+						return getWidthOrHeight( elem, name, extra );+					});+				}+			}+		},++		set: function( elem, value ) {+			return rnum.test( value ) ?+				value + "px" :+				value;+		}+	};+});++if ( !jQuery.support.opacity ) {+	jQuery.cssHooks.opacity = {+		get: function( elem, computed ) {+			// IE uses filters for opacity+			return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?+				( parseFloat( RegExp.$1 ) / 100 ) + "" :+				computed ? "1" : "";+		},++		set: function( elem, value ) {+			var style = elem.style,+				currentStyle = elem.currentStyle,+				opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",+				filter = currentStyle && currentStyle.filter || style.filter || "";++			// IE has trouble with opacity if it does not have layout+			// Force it by setting the zoom level+			style.zoom = 1;++			// if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652+			if ( value >= 1 && jQuery.trim( filter.replace( ralpha, "" ) ) === "" ) {++				// Setting style.filter to null, "" & " " still leave "filter:" in the cssText+				// if "filter:" is present at all, clearType is disabled, we want to avoid this+				// style.removeAttribute is IE Only, but so apparently is this code path...+				style.removeAttribute( "filter" );++				// if there there is no filter style applied in a css rule, we are done+				if ( currentStyle && !currentStyle.filter ) {+					return;+				}+			}++			// otherwise, set new filter values+			style.filter = ralpha.test( filter ) ?+				filter.replace( ralpha, opacity ) :+				filter + " " + opacity;+		}+	};+}++jQuery(function() {+	// This hook cannot be added until DOM ready because the support test+	// for it is not run until after DOM ready+	if ( !jQuery.support.reliableMarginRight ) {+		jQuery.cssHooks.marginRight = {+			get: function( elem, computed ) {+				// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right+				// Work around by temporarily setting element display to inline-block+				return jQuery.swap( elem, { "display": "inline-block" }, function() {+					if ( computed ) {+						return curCSS( elem, "margin-right" );+					} else {+						return elem.style.marginRight;+					}+				});+			}+		};+	}+});++if ( jQuery.expr && jQuery.expr.filters ) {+	jQuery.expr.filters.hidden = function( elem ) {+		var width = elem.offsetWidth,+			height = elem.offsetHeight;++		return ( width === 0 && height === 0 ) || (!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || jQuery.css( elem, "display" )) === "none");+	};++	jQuery.expr.filters.visible = function( elem ) {+		return !jQuery.expr.filters.hidden( elem );+	};+}++// These hooks are used by animate to expand properties+jQuery.each({+	margin: "",+	padding: "",+	border: "Width"+}, function( prefix, suffix ) {++	jQuery.cssHooks[ prefix + suffix ] = {+		expand: function( value ) {+			var i,++				// assumes a single number if not a string+				parts = typeof value === "string" ? value.split(" ") : [ value ],+				expanded = {};++			for ( i = 0; i < 4; i++ ) {+				expanded[ prefix + cssExpand[ i ] + suffix ] =+					parts[ i ] || parts[ i - 2 ] || parts[ 0 ];+			}++			return expanded;+		}+	};+});+++++var r20 = /%20/g,+	rbracket = /\[\]$/,+	rCRLF = /\r?\n/g,+	rhash = /#.*$/,+	rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL+	rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,+	// #7653, #8125, #8152: local protocol detection+	rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,+	rnoContent = /^(?:GET|HEAD)$/,+	rprotocol = /^\/\//,+	rquery = /\?/,+	rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,+	rselectTextarea = /^(?:select|textarea)/i,+	rspacesAjax = /\s+/,+	rts = /([?&])_=[^&]*/,+	rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,++	// Keep a copy of the old load method+	_load = jQuery.fn.load,++	/* Prefilters+	 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)+	 * 2) These are called:+	 *    - BEFORE asking for a transport+	 *    - AFTER param serialization (s.data is a string if s.processData is true)+	 * 3) key is the dataType+	 * 4) the catchall symbol "*" can be used+	 * 5) execution will start with transport dataType and THEN continue down to "*" if needed+	 */+	prefilters = {},++	/* Transports bindings+	 * 1) key is the dataType+	 * 2) the catchall symbol "*" can be used+	 * 3) selection will start with transport dataType and THEN go to "*" if needed+	 */+	transports = {},++	// Document location+	ajaxLocation,++	// Document location segments+	ajaxLocParts,++	// Avoid comment-prolog char sequence (#10098); must appease lint and evade compression+	allTypes = ["*/"] + ["*"];++// #8138, IE may throw an exception when accessing+// a field from window.location if document.domain has been set+try {+	ajaxLocation = location.href;+} catch( e ) {+	// Use the href attribute of an A element+	// since IE will modify it given document.location+	ajaxLocation = document.createElement( "a" );+	ajaxLocation.href = "";+	ajaxLocation = ajaxLocation.href;+}++// Segment location into parts+ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];++// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport+function addToPrefiltersOrTransports( structure ) {++	// dataTypeExpression is optional and defaults to "*"+	return function( dataTypeExpression, func ) {++		if ( typeof dataTypeExpression !== "string" ) {+			func = dataTypeExpression;+			dataTypeExpression = "*";+		}++		if ( jQuery.isFunction( func ) ) {+			var dataTypes = dataTypeExpression.toLowerCase().split( rspacesAjax ),+				i = 0,+				length = dataTypes.length,+				dataType,+				list,+				placeBefore;++			// For each dataType in the dataTypeExpression+			for ( ; i < length; i++ ) {+				dataType = dataTypes[ i ];+				// We control if we're asked to add before+				// any existing element+				placeBefore = /^\+/.test( dataType );+				if ( placeBefore ) {+					dataType = dataType.substr( 1 ) || "*";+				}+				list = structure[ dataType ] = structure[ dataType ] || [];+				// then we add to the structure accordingly+				list[ placeBefore ? "unshift" : "push" ]( func );+			}+		}+	};+}++// Base inspection function for prefilters and transports+function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR,+		dataType /* internal */, inspected /* internal */ ) {++	dataType = dataType || options.dataTypes[ 0 ];+	inspected = inspected || {};++	inspected[ dataType ] = true;++	var list = structure[ dataType ],+		i = 0,+		length = list ? list.length : 0,+		executeOnly = ( structure === prefilters ),+		selection;++	for ( ; i < length && ( executeOnly || !selection ); i++ ) {+		selection = list[ i ]( options, originalOptions, jqXHR );+		// If we got redirected to another dataType+		// we try there if executing only and not done already+		if ( typeof selection === "string" ) {+			if ( !executeOnly || inspected[ selection ] ) {+				selection = undefined;+			} else {+				options.dataTypes.unshift( selection );+				selection = inspectPrefiltersOrTransports(+						structure, options, originalOptions, jqXHR, selection, inspected );+			}+		}+	}+	// If we're only executing or nothing was selected+	// we try the catchall dataType if not done already+	if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) {+		selection = inspectPrefiltersOrTransports(+				structure, options, originalOptions, jqXHR, "*", inspected );+	}+	// unnecessary when only executing (prefilters)+	// but it'll be ignored by the caller in that case+	return selection;+}++// A special extend for ajax options+// that takes "flat" options (not to be deep extended)+// Fixes #9887+function ajaxExtend( target, src ) {+	var key, deep,+		flatOptions = jQuery.ajaxSettings.flatOptions || {};+	for ( key in src ) {+		if ( src[ key ] !== undefined ) {+			( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];+		}+	}+	if ( deep ) {+		jQuery.extend( true, target, deep );+	}+}++jQuery.fn.extend({+	load: function( url, params, callback ) {+		if ( typeof url !== "string" && _load ) {+			return _load.apply( this, arguments );++		// Don't do a request if no elements are being requested+		} else if ( !this.length ) {+			return this;+		}++		var off = url.indexOf( " " );+		if ( off >= 0 ) {+			var selector = url.slice( off, url.length );+			url = url.slice( 0, off );+		}++		// Default to a GET request+		var type = "GET";++		// If the second parameter was provided+		if ( params ) {+			// If it's a function+			if ( jQuery.isFunction( params ) ) {+				// We assume that it's the callback+				callback = params;+				params = undefined;++			// Otherwise, build a param string+			} else if ( typeof params === "object" ) {+				params = jQuery.param( params, jQuery.ajaxSettings.traditional );+				type = "POST";+			}+		}++		var self = this;++		// Request the remote document+		jQuery.ajax({+			url: url,+			type: type,+			dataType: "html",+			data: params,+			// Complete callback (responseText is used internally)+			complete: function( jqXHR, status, responseText ) {+				// Store the response as specified by the jqXHR object+				responseText = jqXHR.responseText;+				// If successful, inject the HTML into all the matched elements+				if ( jqXHR.isResolved() ) {+					// #4825: Get the actual response in case+					// a dataFilter is present in ajaxSettings+					jqXHR.done(function( r ) {+						responseText = r;+					});+					// See if a selector was specified+					self.html( selector ?+						// Create a dummy div to hold the results+						jQuery("<div>")+							// inject the contents of the document in, removing the scripts+							// to avoid any 'Permission Denied' errors in IE+							.append(responseText.replace(rscript, ""))++							// Locate the specified elements+							.find(selector) :++						// If not, just inject the full result+						responseText );+				}++				if ( callback ) {+					self.each( callback, [ responseText, status, jqXHR ] );+				}+			}+		});++		return this;+	},++	serialize: function() {+		return jQuery.param( this.serializeArray() );+	},++	serializeArray: function() {+		return this.map(function(){+			return this.elements ? jQuery.makeArray( this.elements ) : this;+		})+		.filter(function(){+			return this.name && !this.disabled &&+				( this.checked || rselectTextarea.test( this.nodeName ) ||+					rinput.test( this.type ) );+		})+		.map(function( i, elem ){+			var val = jQuery( this ).val();++			return val == null ?+				null :+				jQuery.isArray( val ) ?+					jQuery.map( val, function( val, i ){+						return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };+					}) :+					{ name: elem.name, value: val.replace( rCRLF, "\r\n" ) };+		}).get();+	}+});++// Attach a bunch of functions for handling common AJAX events+jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i, o ){+	jQuery.fn[ o ] = function( f ){+		return this.on( o, f );+	};+});++jQuery.each( [ "get", "post" ], function( i, method ) {+	jQuery[ method ] = function( url, data, callback, type ) {+		// shift arguments if data argument was omitted+		if ( jQuery.isFunction( data ) ) {+			type = type || callback;+			callback = data;+			data = undefined;+		}++		return jQuery.ajax({+			type: method,+			url: url,+			data: data,+			success: callback,+			dataType: type+		});+	};+});++jQuery.extend({++	getScript: function( url, callback ) {+		return jQuery.get( url, undefined, callback, "script" );+	},++	getJSON: function( url, data, callback ) {+		return jQuery.get( url, data, callback, "json" );+	},++	// Creates a full fledged settings object into target+	// with both ajaxSettings and settings fields.+	// If target is omitted, writes into ajaxSettings.+	ajaxSetup: function( target, settings ) {+		if ( settings ) {+			// Building a settings object+			ajaxExtend( target, jQuery.ajaxSettings );+		} else {+			// Extending ajaxSettings+			settings = target;+			target = jQuery.ajaxSettings;+		}+		ajaxExtend( target, settings );+		return target;+	},++	ajaxSettings: {+		url: ajaxLocation,+		isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),+		global: true,+		type: "GET",+		contentType: "application/x-www-form-urlencoded; charset=UTF-8",+		processData: true,+		async: true,+		/*+		timeout: 0,+		data: null,+		dataType: null,+		username: null,+		password: null,+		cache: null,+		traditional: false,+		headers: {},+		*/++		accepts: {+			xml: "application/xml, text/xml",+			html: "text/html",+			text: "text/plain",+			json: "application/json, text/javascript",+			"*": allTypes+		},++		contents: {+			xml: /xml/,+			html: /html/,+			json: /json/+		},++		responseFields: {+			xml: "responseXML",+			text: "responseText"+		},++		// List of data converters+		// 1) key format is "source_type destination_type" (a single space in-between)+		// 2) the catchall symbol "*" can be used for source_type+		converters: {++			// Convert anything to text+			"* text": window.String,++			// Text to html (true = no transformation)+			"text html": true,++			// Evaluate text as a json expression+			"text json": jQuery.parseJSON,++			// Parse text as xml+			"text xml": jQuery.parseXML+		},++		// For options that shouldn't be deep extended:+		// you can add your own custom options here if+		// and when you create one that shouldn't be+		// deep extended (see ajaxExtend)+		flatOptions: {+			context: true,+			url: true+		}+	},++	ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),+	ajaxTransport: addToPrefiltersOrTransports( transports ),++	// Main method+	ajax: function( url, options ) {++		// If url is an object, simulate pre-1.5 signature+		if ( typeof url === "object" ) {+			options = url;+			url = undefined;+		}++		// Force options to be an object+		options = options || {};++		var // Create the final options object+			s = jQuery.ajaxSetup( {}, options ),+			// Callbacks context+			callbackContext = s.context || s,+			// Context for global events+			// It's the callbackContext if one was provided in the options+			// and if it's a DOM node or a jQuery collection+			globalEventContext = callbackContext !== s &&+				( callbackContext.nodeType || callbackContext instanceof jQuery ) ?+						jQuery( callbackContext ) : jQuery.event,+			// Deferreds+			deferred = jQuery.Deferred(),+			completeDeferred = jQuery.Callbacks( "once memory" ),+			// Status-dependent callbacks+			statusCode = s.statusCode || {},+			// ifModified key+			ifModifiedKey,+			// Headers (they are sent all at once)+			requestHeaders = {},+			requestHeadersNames = {},+			// Response headers+			responseHeadersString,+			responseHeaders,+			// transport+			transport,+			// timeout handle+			timeoutTimer,+			// Cross-domain detection vars+			parts,+			// The jqXHR state+			state = 0,+			// To know if global events are to be dispatched+			fireGlobals,+			// Loop variable+			i,+			// Fake xhr+			jqXHR = {++				readyState: 0,++				// Caches the header+				setRequestHeader: function( name, value ) {+					if ( !state ) {+						var lname = name.toLowerCase();+						name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;+						requestHeaders[ name ] = value;+					}+					return this;+				},++				// Raw string+				getAllResponseHeaders: function() {+					return state === 2 ? responseHeadersString : null;+				},++				// Builds headers hashtable if needed+				getResponseHeader: function( key ) {+					var match;+					if ( state === 2 ) {+						if ( !responseHeaders ) {+							responseHeaders = {};+							while( ( match = rheaders.exec( responseHeadersString ) ) ) {+								responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];+							}+						}+						match = responseHeaders[ key.toLowerCase() ];+					}+					return match === undefined ? null : match;+				},++				// Overrides response content-type header+				overrideMimeType: function( type ) {+					if ( !state ) {+						s.mimeType = type;+					}+					return this;+				},++				// Cancel the request+				abort: function( statusText ) {+					statusText = statusText || "abort";+					if ( transport ) {+						transport.abort( statusText );+					}+					done( 0, statusText );+					return this;+				}+			};++		// Callback for when everything is done+		// It is defined here because jslint complains if it is declared+		// at the end of the function (which would be more logical and readable)+		function done( status, nativeStatusText, responses, headers ) {++			// Called once+			if ( state === 2 ) {+				return;+			}++			// State is "done" now+			state = 2;++			// Clear timeout if it exists+			if ( timeoutTimer ) {+				clearTimeout( timeoutTimer );+			}++			// Dereference transport for early garbage collection+			// (no matter how long the jqXHR object will be used)+			transport = undefined;++			// Cache response headers+			responseHeadersString = headers || "";++			// Set readyState+			jqXHR.readyState = status > 0 ? 4 : 0;++			var isSuccess,+				success,+				error,+				statusText = nativeStatusText,+				response = responses ? ajaxHandleResponses( s, jqXHR, responses ) : undefined,+				lastModified,+				etag;++			// If successful, handle type chaining+			if ( status >= 200 && status < 300 || status === 304 ) {++				// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.+				if ( s.ifModified ) {++					if ( ( lastModified = jqXHR.getResponseHeader( "Last-Modified" ) ) ) {+						jQuery.lastModified[ ifModifiedKey ] = lastModified;+					}+					if ( ( etag = jqXHR.getResponseHeader( "Etag" ) ) ) {+						jQuery.etag[ ifModifiedKey ] = etag;+					}+				}++				// If not modified+				if ( status === 304 ) {++					statusText = "notmodified";+					isSuccess = true;++				// If we have data+				} else {++					try {+						success = ajaxConvert( s, response );+						statusText = "success";+						isSuccess = true;+					} catch(e) {+						// We have a parsererror+						statusText = "parsererror";+						error = e;+					}+				}+			} else {+				// We extract error from statusText+				// then normalize statusText and status for non-aborts+				error = statusText;+				if ( !statusText || status ) {+					statusText = "error";+					if ( status < 0 ) {+						status = 0;+					}+				}+			}++			// Set data for the fake xhr object+			jqXHR.status = status;+			jqXHR.statusText = "" + ( nativeStatusText || statusText );++			// Success/Error+			if ( isSuccess ) {+				deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );+			} else {+				deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );+			}++			// Status-dependent callbacks+			jqXHR.statusCode( statusCode );+			statusCode = undefined;++			if ( fireGlobals ) {+				globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ),+						[ jqXHR, s, isSuccess ? success : error ] );+			}++			// Complete+			completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );++			if ( fireGlobals ) {+				globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );+				// Handle the global AJAX counter+				if ( !( --jQuery.active ) ) {+					jQuery.event.trigger( "ajaxStop" );+				}+			}+		}++		// Attach deferreds+		deferred.promise( jqXHR );+		jqXHR.success = jqXHR.done;+		jqXHR.error = jqXHR.fail;+		jqXHR.complete = completeDeferred.add;++		// Status-dependent callbacks+		jqXHR.statusCode = function( map ) {+			if ( map ) {+				var tmp;+				if ( state < 2 ) {+					for ( tmp in map ) {+						statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ];+					}+				} else {+					tmp = map[ jqXHR.status ];+					jqXHR.then( tmp, tmp );+				}+			}+			return this;+		};++		// Remove hash character (#7531: and string promotion)+		// Add protocol if not provided (#5866: IE7 issue with protocol-less urls)+		// We also use the url parameter if available+		s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );++		// Extract dataTypes list+		s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( rspacesAjax );++		// Determine if a cross-domain request is in order+		if ( s.crossDomain == null ) {+			parts = rurl.exec( s.url.toLowerCase() );+			s.crossDomain = !!( parts &&+				( parts[ 1 ] != ajaxLocParts[ 1 ] || parts[ 2 ] != ajaxLocParts[ 2 ] ||+					( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) !=+						( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) )+			);+		}++		// Convert data if not already a string+		if ( s.data && s.processData && typeof s.data !== "string" ) {+			s.data = jQuery.param( s.data, s.traditional );+		}++		// Apply prefilters+		inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );++		// If request was aborted inside a prefilter, stop there+		if ( state === 2 ) {+			return false;+		}++		// We can fire global events as of now if asked to+		fireGlobals = s.global;++		// Uppercase the type+		s.type = s.type.toUpperCase();++		// Determine if request has content+		s.hasContent = !rnoContent.test( s.type );++		// Watch for a new set of requests+		if ( fireGlobals && jQuery.active++ === 0 ) {+			jQuery.event.trigger( "ajaxStart" );+		}++		// More options handling for requests with no content+		if ( !s.hasContent ) {++			// If data is available, append data to url+			if ( s.data ) {+				s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data;+				// #9682: remove data so that it's not used in an eventual retry+				delete s.data;+			}++			// Get ifModifiedKey before adding the anti-cache parameter+			ifModifiedKey = s.url;++			// Add anti-cache in url if needed+			if ( s.cache === false ) {++				var ts = jQuery.now(),+					// try replacing _= if it is there+					ret = s.url.replace( rts, "$1_=" + ts );++				// if nothing was replaced, add timestamp to the end+				s.url = ret + ( ( ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" );+			}+		}++		// Set the correct header, if data is being sent+		if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {+			jqXHR.setRequestHeader( "Content-Type", s.contentType );+		}++		// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.+		if ( s.ifModified ) {+			ifModifiedKey = ifModifiedKey || s.url;+			if ( jQuery.lastModified[ ifModifiedKey ] ) {+				jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ ifModifiedKey ] );+			}+			if ( jQuery.etag[ ifModifiedKey ] ) {+				jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ ifModifiedKey ] );+			}+		}++		// Set the Accepts header for the server, depending on the dataType+		jqXHR.setRequestHeader(+			"Accept",+			s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?+				s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :+				s.accepts[ "*" ]+		);++		// Check for headers option+		for ( i in s.headers ) {+			jqXHR.setRequestHeader( i, s.headers[ i ] );+		}++		// Allow custom headers/mimetypes and early abort+		if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {+				// Abort if not done already+				jqXHR.abort();+				return false;++		}++		// Install callbacks on deferreds+		for ( i in { success: 1, error: 1, complete: 1 } ) {+			jqXHR[ i ]( s[ i ] );+		}++		// Get transport+		transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );++		// If no transport, we auto-abort+		if ( !transport ) {+			done( -1, "No Transport" );+		} else {+			jqXHR.readyState = 1;+			// Send global event+			if ( fireGlobals ) {+				globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );+			}+			// Timeout+			if ( s.async && s.timeout > 0 ) {+				timeoutTimer = setTimeout( function(){+					jqXHR.abort( "timeout" );+				}, s.timeout );+			}++			try {+				state = 1;+				transport.send( requestHeaders, done );+			} catch (e) {+				// Propagate exception as error if not done+				if ( state < 2 ) {+					done( -1, e );+				// Simply rethrow otherwise+				} else {+					throw e;+				}+			}+		}++		return jqXHR;+	},++	// Serialize an array of form elements or a set of+	// key/values into a query string+	param: function( a, traditional ) {+		var s = [],+			add = function( key, value ) {+				// If value is a function, invoke it and return its value+				value = jQuery.isFunction( value ) ? value() : value;+				s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );+			};++		// Set traditional to true for jQuery <= 1.3.2 behavior.+		if ( traditional === undefined ) {+			traditional = jQuery.ajaxSettings.traditional;+		}++		// If an array was passed in, assume that it is an array of form elements.+		if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {+			// Serialize the form elements+			jQuery.each( a, function() {+				add( this.name, this.value );+			});++		} else {+			// If traditional, encode the "old" way (the way 1.3.2 or older+			// did it), otherwise encode params recursively.+			for ( var prefix in a ) {+				buildParams( prefix, a[ prefix ], traditional, add );+			}+		}++		// Return the resulting serialization+		return s.join( "&" ).replace( r20, "+" );+	}+});++function buildParams( prefix, obj, traditional, add ) {+	if ( jQuery.isArray( obj ) ) {+		// Serialize array item.+		jQuery.each( obj, function( i, v ) {+			if ( traditional || rbracket.test( prefix ) ) {+				// Treat each array item as a scalar.+				add( prefix, v );++			} else {+				// If array item is non-scalar (array or object), encode its+				// numeric index to resolve deserialization ambiguity issues.+				// Note that rack (as of 1.0.0) can't currently deserialize+				// nested arrays properly, and attempting to do so may cause+				// a server error. Possible fixes are to modify rack's+				// deserialization algorithm or to provide an option or flag+				// to force array serialization to be shallow.+				buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );+			}+		});++	} else if ( !traditional && jQuery.type( obj ) === "object" ) {+		// Serialize object item.+		for ( var name in obj ) {+			buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );+		}++	} else {+		// Serialize scalar item.+		add( prefix, obj );+	}+}++// This is still on the jQuery object... for now+// Want to move this to jQuery.ajax some day+jQuery.extend({++	// Counter for holding the number of active queries+	active: 0,++	// Last-Modified header cache for next request+	lastModified: {},+	etag: {}++});++/* Handles responses to an ajax request:+ * - sets all responseXXX fields accordingly+ * - finds the right dataType (mediates between content-type and expected dataType)+ * - returns the corresponding response+ */+function ajaxHandleResponses( s, jqXHR, responses ) {++	var contents = s.contents,+		dataTypes = s.dataTypes,+		responseFields = s.responseFields,+		ct,+		type,+		finalDataType,+		firstDataType;++	// Fill responseXXX fields+	for ( type in responseFields ) {+		if ( type in responses ) {+			jqXHR[ responseFields[type] ] = responses[ type ];+		}+	}++	// Remove auto dataType and get content-type in the process+	while( dataTypes[ 0 ] === "*" ) {+		dataTypes.shift();+		if ( ct === undefined ) {+			ct = s.mimeType || jqXHR.getResponseHeader( "content-type" );+		}+	}++	// Check if we're dealing with a known content-type+	if ( ct ) {+		for ( type in contents ) {+			if ( contents[ type ] && contents[ type ].test( ct ) ) {+				dataTypes.unshift( type );+				break;+			}+		}+	}++	// Check to see if we have a response for the expected dataType+	if ( dataTypes[ 0 ] in responses ) {+		finalDataType = dataTypes[ 0 ];+	} else {+		// Try convertible dataTypes+		for ( type in responses ) {+			if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {+				finalDataType = type;+				break;+			}+			if ( !firstDataType ) {+				firstDataType = type;+			}+		}+		// Or just use first one+		finalDataType = finalDataType || firstDataType;+	}++	// If we found a dataType+	// We add the dataType to the list if needed+	// and return the corresponding response+	if ( finalDataType ) {+		if ( finalDataType !== dataTypes[ 0 ] ) {+			dataTypes.unshift( finalDataType );+		}+		return responses[ finalDataType ];+	}+}++// Chain conversions given the request and the original response+function ajaxConvert( s, response ) {++	// Apply the dataFilter if provided+	if ( s.dataFilter ) {+		response = s.dataFilter( response, s.dataType );+	}++	var dataTypes = s.dataTypes,+		converters = {},+		i,+		key,+		length = dataTypes.length,+		tmp,+		// Current and previous dataTypes+		current = dataTypes[ 0 ],+		prev,+		// Conversion expression+		conversion,+		// Conversion function+		conv,+		// Conversion functions (transitive conversion)+		conv1,+		conv2;++	// For each dataType in the chain+	for ( i = 1; i < length; i++ ) {++		// Create converters map+		// with lowercased keys+		if ( i === 1 ) {+			for ( key in s.converters ) {+				if ( typeof key === "string" ) {+					converters[ key.toLowerCase() ] = s.converters[ key ];+				}+			}+		}++		// Get the dataTypes+		prev = current;+		current = dataTypes[ i ];++		// If current is auto dataType, update it to prev+		if ( current === "*" ) {+			current = prev;+		// If no auto and dataTypes are actually different+		} else if ( prev !== "*" && prev !== current ) {++			// Get the converter+			conversion = prev + " " + current;+			conv = converters[ conversion ] || converters[ "* " + current ];++			// If there is no direct converter, search transitively+			if ( !conv ) {+				conv2 = undefined;+				for ( conv1 in converters ) {+					tmp = conv1.split( " " );+					if ( tmp[ 0 ] === prev || tmp[ 0 ] === "*" ) {+						conv2 = converters[ tmp[1] + " " + current ];+						if ( conv2 ) {+							conv1 = converters[ conv1 ];+							if ( conv1 === true ) {+								conv = conv2;+							} else if ( conv2 === true ) {+								conv = conv1;+							}+							break;+						}+					}+				}+			}+			// If we found no converter, dispatch an error+			if ( !( conv || conv2 ) ) {+				jQuery.error( "No conversion from " + conversion.replace(" "," to ") );+			}+			// If found converter is not an equivalence+			if ( conv !== true ) {+				// Convert with 1 or 2 converters accordingly+				response = conv ? conv( response ) : conv2( conv1(response) );+			}+		}+	}+	return response;+}+++++var jsc = jQuery.now(),+	jsre = /(\=)\?(&|$)|\?\?/i;++// Default jsonp settings+jQuery.ajaxSetup({+	jsonp: "callback",+	jsonpCallback: function() {+		return jQuery.expando + "_" + ( jsc++ );+	}+});++// Detect, normalize options and install callbacks for jsonp requests+jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {++	var inspectData = ( typeof s.data === "string" ) && /^application\/x\-www\-form\-urlencoded/.test( s.contentType );++	if ( s.dataTypes[ 0 ] === "jsonp" ||+		s.jsonp !== false && ( jsre.test( s.url ) ||+				inspectData && jsre.test( s.data ) ) ) {++		var responseContainer,+			jsonpCallback = s.jsonpCallback =+				jQuery.isFunction( s.jsonpCallback ) ? s.jsonpCallback() : s.jsonpCallback,+			previous = window[ jsonpCallback ],+			url = s.url,+			data = s.data,+			replace = "$1" + jsonpCallback + "$2";++		if ( s.jsonp !== false ) {+			url = url.replace( jsre, replace );+			if ( s.url === url ) {+				if ( inspectData ) {+					data = data.replace( jsre, replace );+				}+				if ( s.data === data ) {+					// Add callback manually+					url += (/\?/.test( url ) ? "&" : "?") + s.jsonp + "=" + jsonpCallback;+				}+			}+		}++		s.url = url;+		s.data = data;++		// Install callback+		window[ jsonpCallback ] = function( response ) {+			responseContainer = [ response ];+		};++		// Clean-up function+		jqXHR.always(function() {+			// Set callback back to previous value+			window[ jsonpCallback ] = previous;+			// Call if it was a function and we have a response+			if ( responseContainer && jQuery.isFunction( previous ) ) {+				window[ jsonpCallback ]( responseContainer[ 0 ] );+			}+		});++		// Use data converter to retrieve json after script execution+		s.converters["script json"] = function() {+			if ( !responseContainer ) {+				jQuery.error( jsonpCallback + " was not called" );+			}+			return responseContainer[ 0 ];+		};++		// force json dataType+		s.dataTypes[ 0 ] = "json";++		// Delegate to script+		return "script";+	}+});+++++// Install script dataType+jQuery.ajaxSetup({+	accepts: {+		script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"+	},+	contents: {+		script: /javascript|ecmascript/+	},+	converters: {+		"text script": function( text ) {+			jQuery.globalEval( text );+			return text;+		}+	}+});++// Handle cache's special case and global+jQuery.ajaxPrefilter( "script", function( s ) {+	if ( s.cache === undefined ) {+		s.cache = false;+	}+	if ( s.crossDomain ) {+		s.type = "GET";+		s.global = false;+	}+});++// Bind script tag hack transport+jQuery.ajaxTransport( "script", function(s) {++	// This transport only deals with cross domain requests+	if ( s.crossDomain ) {++		var script,+			head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement;++		return {++			send: function( _, callback ) {++				script = document.createElement( "script" );++				script.async = "async";++				if ( s.scriptCharset ) {+					script.charset = s.scriptCharset;+				}++				script.src = s.url;++				// Attach handlers for all browsers+				script.onload = script.onreadystatechange = function( _, isAbort ) {++					if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {++						// Handle memory leak in IE+						script.onload = script.onreadystatechange = null;++						// Remove the script+						if ( head && script.parentNode ) {+							head.removeChild( script );+						}++						// Dereference the script+						script = undefined;++						// Callback if not abort+						if ( !isAbort ) {+							callback( 200, "success" );+						}+					}+				};+				// Use insertBefore instead of appendChild  to circumvent an IE6 bug.+				// This arises when a base node is used (#2709 and #4378).+				head.insertBefore( script, head.firstChild );+			},++			abort: function() {+				if ( script ) {+					script.onload( 0, 1 );+				}+			}+		};+	}+});+++++var // #5280: Internet Explorer will keep connections alive if we don't abort on unload+	xhrOnUnloadAbort = window.ActiveXObject ? function() {+		// Abort all pending requests+		for ( var key in xhrCallbacks ) {+			xhrCallbacks[ key ]( 0, 1 );+		}+	} : false,+	xhrId = 0,+	xhrCallbacks;++// Functions to create xhrs+function createStandardXHR() {+	try {+		return new window.XMLHttpRequest();+	} catch( e ) {}+}++function createActiveXHR() {+	try {+		return new window.ActiveXObject( "Microsoft.XMLHTTP" );+	} catch( e ) {}+}++// Create the request object+// (This is still attached to ajaxSettings for backward compatibility)+jQuery.ajaxSettings.xhr = window.ActiveXObject ?+	/* Microsoft failed to properly+	 * implement the XMLHttpRequest in IE7 (can't request local files),+	 * so we use the ActiveXObject when it is available+	 * Additionally XMLHttpRequest can be disabled in IE7/IE8 so+	 * we need a fallback.+	 */+	function() {+		return !this.isLocal && createStandardXHR() || createActiveXHR();+	} :+	// For all other browsers, use the standard XMLHttpRequest object+	createStandardXHR;++// Determine support properties+(function( xhr ) {+	jQuery.extend( jQuery.support, {+		ajax: !!xhr,+		cors: !!xhr && ( "withCredentials" in xhr )+	});+})( jQuery.ajaxSettings.xhr() );++// Create transport if the browser can provide an xhr+if ( jQuery.support.ajax ) {++	jQuery.ajaxTransport(function( s ) {+		// Cross domain only allowed if supported through XMLHttpRequest+		if ( !s.crossDomain || jQuery.support.cors ) {++			var callback;++			return {+				send: function( headers, complete ) {++					// Get a new xhr+					var xhr = s.xhr(),+						handle,+						i;++					// Open the socket+					// Passing null username, generates a login popup on Opera (#2865)+					if ( s.username ) {+						xhr.open( s.type, s.url, s.async, s.username, s.password );+					} else {+						xhr.open( s.type, s.url, s.async );+					}++					// Apply custom fields if provided+					if ( s.xhrFields ) {+						for ( i in s.xhrFields ) {+							xhr[ i ] = s.xhrFields[ i ];+						}+					}++					// Override mime type if needed+					if ( s.mimeType && xhr.overrideMimeType ) {+						xhr.overrideMimeType( s.mimeType );+					}++					// X-Requested-With header+					// For cross-domain requests, seeing as conditions for a preflight are+					// akin to a jigsaw puzzle, we simply never set it to be sure.+					// (it can always be set on a per-request basis or even using ajaxSetup)+					// For same-domain requests, won't change header if already provided.+					if ( !s.crossDomain && !headers["X-Requested-With"] ) {+						headers[ "X-Requested-With" ] = "XMLHttpRequest";+					}++					// Need an extra try/catch for cross domain requests in Firefox 3+					try {+						for ( i in headers ) {+							xhr.setRequestHeader( i, headers[ i ] );+						}+					} catch( _ ) {}++					// Do send the request+					// This may raise an exception which is actually+					// handled in jQuery.ajax (so no try/catch here)+					xhr.send( ( s.hasContent && s.data ) || null );++					// Listener+					callback = function( _, isAbort ) {++						var status,+							statusText,+							responseHeaders,+							responses,+							xml;++						// Firefox throws exceptions when accessing properties+						// of an xhr when a network error occured+						// http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)+						try {++							// Was never called and is aborted or complete+							if ( callback && ( isAbort || xhr.readyState === 4 ) ) {++								// Only called once+								callback = undefined;++								// Do not keep as active anymore+								if ( handle ) {+									xhr.onreadystatechange = jQuery.noop;+									if ( xhrOnUnloadAbort ) {+										delete xhrCallbacks[ handle ];+									}+								}++								// If it's an abort+								if ( isAbort ) {+									// Abort it manually if needed+									if ( xhr.readyState !== 4 ) {+										xhr.abort();+									}+								} else {+									status = xhr.status;+									responseHeaders = xhr.getAllResponseHeaders();+									responses = {};+									xml = xhr.responseXML;++									// Construct response list+									if ( xml && xml.documentElement /* #4958 */ ) {+										responses.xml = xml;+									}++									// When requesting binary data, IE6-9 will throw an exception+									// on any attempt to access responseText (#11426)+									try {+										responses.text = xhr.responseText;+									} catch( _ ) {+									}++									// Firefox throws an exception when accessing+									// statusText for faulty cross-domain requests+									try {+										statusText = xhr.statusText;+									} catch( e ) {+										// We normalize with Webkit giving an empty statusText+										statusText = "";+									}++									// Filter status for non standard behaviors++									// If the request is local and we have data: assume a success+									// (success with no data won't get notified, that's the best we+									// can do given current implementations)+									if ( !status && s.isLocal && !s.crossDomain ) {+										status = responses.text ? 200 : 404;+									// IE - #1450: sometimes returns 1223 when it should be 204+									} else if ( status === 1223 ) {+										status = 204;+									}+								}+							}+						} catch( firefoxAccessException ) {+							if ( !isAbort ) {+								complete( -1, firefoxAccessException );+							}+						}++						// Call complete if needed+						if ( responses ) {+							complete( status, statusText, responses, responseHeaders );+						}+					};++					// if we're in sync mode or it's in cache+					// and has been retrieved directly (IE6 & IE7)+					// we need to manually fire the callback+					if ( !s.async || xhr.readyState === 4 ) {+						callback();+					} else {+						handle = ++xhrId;+						if ( xhrOnUnloadAbort ) {+							// Create the active xhrs callbacks list if needed+							// and attach the unload handler+							if ( !xhrCallbacks ) {+								xhrCallbacks = {};+								jQuery( window ).unload( xhrOnUnloadAbort );+							}+							// Add to list of active xhrs callbacks+							xhrCallbacks[ handle ] = callback;+						}+						xhr.onreadystatechange = callback;+					}+				},++				abort: function() {+					if ( callback ) {+						callback(0,1);+					}+				}+			};+		}+	});+}+++++var elemdisplay = {},+	iframe, iframeDoc,+	rfxtypes = /^(?:toggle|show|hide)$/,+	rfxnum = /^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,+	timerId,+	fxAttrs = [+		// height animations+		[ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],+		// width animations+		[ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],+		// opacity animations+		[ "opacity" ]+	],+	fxNow;++jQuery.fn.extend({+	show: function( speed, easing, callback ) {+		var elem, display;++		if ( speed || speed === 0 ) {+			return this.animate( genFx("show", 3), speed, easing, callback );++		} else {+			for ( var i = 0, j = this.length; i < j; i++ ) {+				elem = this[ i ];++				if ( elem.style ) {+					display = elem.style.display;++					// Reset the inline display of this element to learn if it is+					// being hidden by cascaded rules or not+					if ( !jQuery._data(elem, "olddisplay") && display === "none" ) {+						display = elem.style.display = "";+					}++					// Set elements which have been overridden with display: none+					// in a stylesheet to whatever the default browser style is+					// for such an element+					if ( (display === "" && jQuery.css(elem, "display") === "none") ||+						!jQuery.contains( elem.ownerDocument.documentElement, elem ) ) {+						jQuery._data( elem, "olddisplay", defaultDisplay(elem.nodeName) );+					}+				}+			}++			// Set the display of most of the elements in a second loop+			// to avoid the constant reflow+			for ( i = 0; i < j; i++ ) {+				elem = this[ i ];++				if ( elem.style ) {+					display = elem.style.display;++					if ( display === "" || display === "none" ) {+						elem.style.display = jQuery._data( elem, "olddisplay" ) || "";+					}+				}+			}++			return this;+		}+	},++	hide: function( speed, easing, callback ) {+		if ( speed || speed === 0 ) {+			return this.animate( genFx("hide", 3), speed, easing, callback);++		} else {+			var elem, display,+				i = 0,+				j = this.length;++			for ( ; i < j; i++ ) {+				elem = this[i];+				if ( elem.style ) {+					display = jQuery.css( elem, "display" );++					if ( display !== "none" && !jQuery._data( elem, "olddisplay" ) ) {+						jQuery._data( elem, "olddisplay", display );+					}+				}+			}++			// Set the display of the elements in a second loop+			// to avoid the constant reflow+			for ( i = 0; i < j; i++ ) {+				if ( this[i].style ) {+					this[i].style.display = "none";+				}+			}++			return this;+		}+	},++	// Save the old toggle function+	_toggle: jQuery.fn.toggle,++	toggle: function( fn, fn2, callback ) {+		var bool = typeof fn === "boolean";++		if ( jQuery.isFunction(fn) && jQuery.isFunction(fn2) ) {+			this._toggle.apply( this, arguments );++		} else if ( fn == null || bool ) {+			this.each(function() {+				var state = bool ? fn : jQuery(this).is(":hidden");+				jQuery(this)[ state ? "show" : "hide" ]();+			});++		} else {+			this.animate(genFx("toggle", 3), fn, fn2, callback);+		}++		return this;+	},++	fadeTo: function( speed, to, easing, callback ) {+		return this.filter(":hidden").css("opacity", 0).show().end()+					.animate({opacity: to}, speed, easing, callback);+	},++	animate: function( prop, speed, easing, callback ) {+		var optall = jQuery.speed( speed, easing, callback );++		if ( jQuery.isEmptyObject( prop ) ) {+			return this.each( optall.complete, [ false ] );+		}++		// Do not change referenced properties as per-property easing will be lost+		prop = jQuery.extend( {}, prop );++		function doAnimation() {+			// XXX 'this' does not always have a nodeName when running the+			// test suite++			if ( optall.queue === false ) {+				jQuery._mark( this );+			}++			var opt = jQuery.extend( {}, optall ),+				isElement = this.nodeType === 1,+				hidden = isElement && jQuery(this).is(":hidden"),+				name, val, p, e, hooks, replace,+				parts, start, end, unit,+				method;++			// will store per property easing and be used to determine when an animation is complete+			opt.animatedProperties = {};++			// first pass over propertys to expand / normalize+			for ( p in prop ) {+				name = jQuery.camelCase( p );+				if ( p !== name ) {+					prop[ name ] = prop[ p ];+					delete prop[ p ];+				}++				if ( ( hooks = jQuery.cssHooks[ name ] ) && "expand" in hooks ) {+					replace = hooks.expand( prop[ name ] );+					delete prop[ name ];++					// not quite $.extend, this wont overwrite keys already present.+					// also - reusing 'p' from above because we have the correct "name"+					for ( p in replace ) {+						if ( ! ( p in prop ) ) {+							prop[ p ] = replace[ p ];+						}+					}+				}+			}++			for ( name in prop ) {+				val = prop[ name ];+				// easing resolution: per property > opt.specialEasing > opt.easing > 'swing' (default)+				if ( jQuery.isArray( val ) ) {+					opt.animatedProperties[ name ] = val[ 1 ];+					val = prop[ name ] = val[ 0 ];+				} else {+					opt.animatedProperties[ name ] = opt.specialEasing && opt.specialEasing[ name ] || opt.easing || 'swing';+				}++				if ( val === "hide" && hidden || val === "show" && !hidden ) {+					return opt.complete.call( this );+				}++				if ( isElement && ( name === "height" || name === "width" ) ) {+					// Make sure that nothing sneaks out+					// Record all 3 overflow attributes because IE does not+					// change the overflow attribute when overflowX and+					// overflowY are set to the same value+					opt.overflow = [ this.style.overflow, this.style.overflowX, this.style.overflowY ];++					// Set display property to inline-block for height/width+					// animations on inline elements that are having width/height animated+					if ( jQuery.css( this, "display" ) === "inline" &&+							jQuery.css( this, "float" ) === "none" ) {++						// inline-level elements accept inline-block;+						// block-level elements need to be inline with layout+						if ( !jQuery.support.inlineBlockNeedsLayout || defaultDisplay( this.nodeName ) === "inline" ) {+							this.style.display = "inline-block";++						} else {+							this.style.zoom = 1;+						}+					}+				}+			}++			if ( opt.overflow != null ) {+				this.style.overflow = "hidden";+			}++			for ( p in prop ) {+				e = new jQuery.fx( this, opt, p );+				val = prop[ p ];++				if ( rfxtypes.test( val ) ) {++					// Tracks whether to show or hide based on private+					// data attached to the element+					method = jQuery._data( this, "toggle" + p ) || ( val === "toggle" ? hidden ? "show" : "hide" : 0 );+					if ( method ) {+						jQuery._data( this, "toggle" + p, method === "show" ? "hide" : "show" );+						e[ method ]();+					} else {+						e[ val ]();+					}++				} else {+					parts = rfxnum.exec( val );+					start = e.cur();++					if ( parts ) {+						end = parseFloat( parts[2] );+						unit = parts[3] || ( jQuery.cssNumber[ p ] ? "" : "px" );++						// We need to compute starting value+						if ( unit !== "px" ) {+							jQuery.style( this, p, (end || 1) + unit);+							start = ( (end || 1) / e.cur() ) * start;+							jQuery.style( this, p, start + unit);+						}++						// If a +=/-= token was provided, we're doing a relative animation+						if ( parts[1] ) {+							end = ( (parts[ 1 ] === "-=" ? -1 : 1) * end ) + start;+						}++						e.custom( start, end, unit );++					} else {+						e.custom( start, val, "" );+					}+				}+			}++			// For JS strict compliance+			return true;+		}++		return optall.queue === false ?+			this.each( doAnimation ) :+			this.queue( optall.queue, doAnimation );+	},++	stop: function( type, clearQueue, gotoEnd ) {+		if ( typeof type !== "string" ) {+			gotoEnd = clearQueue;+			clearQueue = type;+			type = undefined;+		}+		if ( clearQueue && type !== false ) {+			this.queue( type || "fx", [] );+		}++		return this.each(function() {+			var index,+				hadTimers = false,+				timers = jQuery.timers,+				data = jQuery._data( this );++			// clear marker counters if we know they won't be+			if ( !gotoEnd ) {+				jQuery._unmark( true, this );+			}++			function stopQueue( elem, data, index ) {+				var hooks = data[ index ];+				jQuery.removeData( elem, index, true );+				hooks.stop( gotoEnd );+			}++			if ( type == null ) {+				for ( index in data ) {+					if ( data[ index ] && data[ index ].stop && index.indexOf(".run") === index.length - 4 ) {+						stopQueue( this, data, index );+					}+				}+			} else if ( data[ index = type + ".run" ] && data[ index ].stop ){+				stopQueue( this, data, index );+			}++			for ( index = timers.length; index--; ) {+				if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {+					if ( gotoEnd ) {++						// force the next step to be the last+						timers[ index ]( true );+					} else {+						timers[ index ].saveState();+					}+					hadTimers = true;+					timers.splice( index, 1 );+				}+			}++			// start the next in the queue if the last step wasn't forced+			// timers currently will call their complete callbacks, which will dequeue+			// but only if they were gotoEnd+			if ( !( gotoEnd && hadTimers ) ) {+				jQuery.dequeue( this, type );+			}+		});+	}++});++// Animations created synchronously will run synchronously+function createFxNow() {+	setTimeout( clearFxNow, 0 );+	return ( fxNow = jQuery.now() );+}++function clearFxNow() {+	fxNow = undefined;+}++// Generate parameters to create a standard animation+function genFx( type, num ) {+	var obj = {};++	jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice( 0, num )), function() {+		obj[ this ] = type;+	});++	return obj;+}++// Generate shortcuts for custom animations+jQuery.each({+	slideDown: genFx( "show", 1 ),+	slideUp: genFx( "hide", 1 ),+	slideToggle: genFx( "toggle", 1 ),+	fadeIn: { opacity: "show" },+	fadeOut: { opacity: "hide" },+	fadeToggle: { opacity: "toggle" }+}, function( name, props ) {+	jQuery.fn[ name ] = function( speed, easing, callback ) {+		return this.animate( props, speed, easing, callback );+	};+});++jQuery.extend({+	speed: function( speed, easing, fn ) {+		var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {+			complete: fn || !fn && easing ||+				jQuery.isFunction( speed ) && speed,+			duration: speed,+			easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing+		};++		opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :+			opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;++		// normalize opt.queue - true/undefined/null -> "fx"+		if ( opt.queue == null || opt.queue === true ) {+			opt.queue = "fx";+		}++		// Queueing+		opt.old = opt.complete;++		opt.complete = function( noUnmark ) {+			if ( jQuery.isFunction( opt.old ) ) {+				opt.old.call( this );+			}++			if ( opt.queue ) {+				jQuery.dequeue( this, opt.queue );+			} else if ( noUnmark !== false ) {+				jQuery._unmark( this );+			}+		};++		return opt;+	},++	easing: {+		linear: function( p ) {+			return p;+		},+		swing: function( p ) {+			return ( -Math.cos( p*Math.PI ) / 2 ) + 0.5;+		}+	},++	timers: [],++	fx: function( elem, options, prop ) {+		this.options = options;+		this.elem = elem;+		this.prop = prop;++		options.orig = options.orig || {};+	}++});++jQuery.fx.prototype = {+	// Simple function for setting a style value+	update: function() {+		if ( this.options.step ) {+			this.options.step.call( this.elem, this.now, this );+		}++		( jQuery.fx.step[ this.prop ] || jQuery.fx.step._default )( this );+	},++	// Get the current size+	cur: function() {+		if ( this.elem[ this.prop ] != null && (!this.elem.style || this.elem.style[ this.prop ] == null) ) {+			return this.elem[ this.prop ];+		}++		var parsed,+			r = jQuery.css( this.elem, this.prop );+		// Empty strings, null, undefined and "auto" are converted to 0,+		// complex values such as "rotate(1rad)" are returned as is,+		// simple values such as "10px" are parsed to Float.+		return isNaN( parsed = parseFloat( r ) ) ? !r || r === "auto" ? 0 : r : parsed;+	},++	// Start an animation from one number to another+	custom: function( from, to, unit ) {+		var self = this,+			fx = jQuery.fx;++		this.startTime = fxNow || createFxNow();+		this.end = to;+		this.now = this.start = from;+		this.pos = this.state = 0;+		this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" );++		function t( gotoEnd ) {+			return self.step( gotoEnd );+		}++		t.queue = this.options.queue;+		t.elem = this.elem;+		t.saveState = function() {+			if ( jQuery._data( self.elem, "fxshow" + self.prop ) === undefined ) {+				if ( self.options.hide ) {+					jQuery._data( self.elem, "fxshow" + self.prop, self.start );+				} else if ( self.options.show ) {+					jQuery._data( self.elem, "fxshow" + self.prop, self.end );+				}+			}+		};++		if ( t() && jQuery.timers.push(t) && !timerId ) {+			timerId = setInterval( fx.tick, fx.interval );+		}+	},++	// Simple 'show' function+	show: function() {+		var dataShow = jQuery._data( this.elem, "fxshow" + this.prop );++		// Remember where we started, so that we can go back to it later+		this.options.orig[ this.prop ] = dataShow || jQuery.style( this.elem, this.prop );+		this.options.show = true;++		// Begin the animation+		// Make sure that we start at a small width/height to avoid any flash of content+		if ( dataShow !== undefined ) {+			// This show is picking up where a previous hide or show left off+			this.custom( this.cur(), dataShow );+		} else {+			this.custom( this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur() );+		}++		// Start by showing the element+		jQuery( this.elem ).show();+	},++	// Simple 'hide' function+	hide: function() {+		// Remember where we started, so that we can go back to it later+		this.options.orig[ this.prop ] = jQuery._data( this.elem, "fxshow" + this.prop ) || jQuery.style( this.elem, this.prop );+		this.options.hide = true;++		// Begin the animation+		this.custom( this.cur(), 0 );+	},++	// Each step of an animation+	step: function( gotoEnd ) {+		var p, n, complete,+			t = fxNow || createFxNow(),+			done = true,+			elem = this.elem,+			options = this.options;++		if ( gotoEnd || t >= options.duration + this.startTime ) {+			this.now = this.end;+			this.pos = this.state = 1;+			this.update();++			options.animatedProperties[ this.prop ] = true;++			for ( p in options.animatedProperties ) {+				if ( options.animatedProperties[ p ] !== true ) {+					done = false;+				}+			}++			if ( done ) {+				// Reset the overflow+				if ( options.overflow != null && !jQuery.support.shrinkWrapBlocks ) {++					jQuery.each( [ "", "X", "Y" ], function( index, value ) {+						elem.style[ "overflow" + value ] = options.overflow[ index ];+					});+				}++				// Hide the element if the "hide" operation was done+				if ( options.hide ) {+					jQuery( elem ).hide();+				}++				// Reset the properties, if the item has been hidden or shown+				if ( options.hide || options.show ) {+					for ( p in options.animatedProperties ) {+						jQuery.style( elem, p, options.orig[ p ] );+						jQuery.removeData( elem, "fxshow" + p, true );+						// Toggle data is no longer needed+						jQuery.removeData( elem, "toggle" + p, true );+					}+				}++				// Execute the complete function+				// in the event that the complete function throws an exception+				// we must ensure it won't be called twice. #5684++				complete = options.complete;+				if ( complete ) {++					options.complete = false;+					complete.call( elem );+				}+			}++			return false;++		} else {+			// classical easing cannot be used with an Infinity duration+			if ( options.duration == Infinity ) {+				this.now = t;+			} else {+				n = t - this.startTime;+				this.state = n / options.duration;++				// Perform the easing function, defaults to swing+				this.pos = jQuery.easing[ options.animatedProperties[this.prop] ]( this.state, n, 0, 1, options.duration );+				this.now = this.start + ( (this.end - this.start) * this.pos );+			}+			// Perform the next step of the animation+			this.update();+		}++		return true;+	}+};++jQuery.extend( jQuery.fx, {+	tick: function() {+		var timer,+			timers = jQuery.timers,+			i = 0;++		for ( ; i < timers.length; i++ ) {+			timer = timers[ i ];+			// Checks the timer has not already been removed+			if ( !timer() && timers[ i ] === timer ) {+				timers.splice( i--, 1 );+			}+		}++		if ( !timers.length ) {+			jQuery.fx.stop();+		}+	},++	interval: 13,++	stop: function() {+		clearInterval( timerId );+		timerId = null;+	},++	speeds: {+		slow: 600,+		fast: 200,+		// Default speed+		_default: 400+	},++	step: {+		opacity: function( fx ) {+			jQuery.style( fx.elem, "opacity", fx.now );+		},++		_default: function( fx ) {+			if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {+				fx.elem.style[ fx.prop ] = fx.now + fx.unit;+			} else {+				fx.elem[ fx.prop ] = fx.now;+			}+		}+	}+});++// Ensure props that can't be negative don't go there on undershoot easing+jQuery.each( fxAttrs.concat.apply( [], fxAttrs ), function( i, prop ) {+	// exclude marginTop, marginLeft, marginBottom and marginRight from this list+	if ( prop.indexOf( "margin" ) ) {+		jQuery.fx.step[ prop ] = function( fx ) {+			jQuery.style( fx.elem, prop, Math.max(0, fx.now) + fx.unit );+		};+	}+});++if ( jQuery.expr && jQuery.expr.filters ) {+	jQuery.expr.filters.animated = function( elem ) {+		return jQuery.grep(jQuery.timers, function( fn ) {+			return elem === fn.elem;+		}).length;+	};+}++// Try to restore the default display value of an element+function defaultDisplay( nodeName ) {++	if ( !elemdisplay[ nodeName ] ) {++		var body = document.body,+			elem = jQuery( "<" + nodeName + ">" ).appendTo( body ),+			display = elem.css( "display" );+		elem.remove();++		// If the simple way fails,+		// get element's real default display by attaching it to a temp iframe+		if ( display === "none" || display === "" ) {+			// No iframe to use yet, so create it+			if ( !iframe ) {+				iframe = document.createElement( "iframe" );+				iframe.frameBorder = iframe.width = iframe.height = 0;+			}++			body.appendChild( iframe );++			// Create a cacheable copy of the iframe document on first call.+			// IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML+			// document to it; WebKit & Firefox won't allow reusing the iframe document.+			if ( !iframeDoc || !iframe.createElement ) {+				iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;+				iframeDoc.write( ( jQuery.support.boxModel ? "<!doctype html>" : "" ) + "<html><body>" );+				iframeDoc.close();+			}++			elem = iframeDoc.createElement( nodeName );++			iframeDoc.body.appendChild( elem );++			display = jQuery.css( elem, "display" );+			body.removeChild( iframe );+		}++		// Store the correct default display+		elemdisplay[ nodeName ] = display;+	}++	return elemdisplay[ nodeName ];+}+++++var getOffset,+	rtable = /^t(?:able|d|h)$/i,+	rroot = /^(?:body|html)$/i;++if ( "getBoundingClientRect" in document.documentElement ) {+	getOffset = function( elem, doc, docElem, box ) {+		try {+			box = elem.getBoundingClientRect();+		} catch(e) {}++		// Make sure we're not dealing with a disconnected DOM node+		if ( !box || !jQuery.contains( docElem, elem ) ) {+			return box ? { top: box.top, left: box.left } : { top: 0, left: 0 };+		}++		var body = doc.body,+			win = getWindow( doc ),+			clientTop  = docElem.clientTop  || body.clientTop  || 0,+			clientLeft = docElem.clientLeft || body.clientLeft || 0,+			scrollTop  = win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop  || body.scrollTop,+			scrollLeft = win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft,+			top  = box.top  + scrollTop  - clientTop,+			left = box.left + scrollLeft - clientLeft;++		return { top: top, left: left };+	};++} else {+	getOffset = function( elem, doc, docElem ) {+		var computedStyle,+			offsetParent = elem.offsetParent,+			prevOffsetParent = elem,+			body = doc.body,+			defaultView = doc.defaultView,+			prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle,+			top = elem.offsetTop,+			left = elem.offsetLeft;++		while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {+			if ( jQuery.support.fixedPosition && prevComputedStyle.position === "fixed" ) {+				break;+			}++			computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle;+			top  -= elem.scrollTop;+			left -= elem.scrollLeft;++			if ( elem === offsetParent ) {+				top  += elem.offsetTop;+				left += elem.offsetLeft;++				if ( jQuery.support.doesNotAddBorder && !(jQuery.support.doesAddBorderForTableAndCells && rtable.test(elem.nodeName)) ) {+					top  += parseFloat( computedStyle.borderTopWidth  ) || 0;+					left += parseFloat( computedStyle.borderLeftWidth ) || 0;+				}++				prevOffsetParent = offsetParent;+				offsetParent = elem.offsetParent;+			}++			if ( jQuery.support.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) {+				top  += parseFloat( computedStyle.borderTopWidth  ) || 0;+				left += parseFloat( computedStyle.borderLeftWidth ) || 0;+			}++			prevComputedStyle = computedStyle;+		}++		if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) {+			top  += body.offsetTop;+			left += body.offsetLeft;+		}++		if ( jQuery.support.fixedPosition && prevComputedStyle.position === "fixed" ) {+			top  += Math.max( docElem.scrollTop, body.scrollTop );+			left += Math.max( docElem.scrollLeft, body.scrollLeft );+		}++		return { top: top, left: left };+	};+}++jQuery.fn.offset = function( options ) {+	if ( arguments.length ) {+		return options === undefined ?+			this :+			this.each(function( i ) {+				jQuery.offset.setOffset( this, options, i );+			});+	}++	var elem = this[0],+		doc = elem && elem.ownerDocument;++	if ( !doc ) {+		return null;+	}++	if ( elem === doc.body ) {+		return jQuery.offset.bodyOffset( elem );+	}++	return getOffset( elem, doc, doc.documentElement );+};++jQuery.offset = {++	bodyOffset: function( body ) {+		var top = body.offsetTop,+			left = body.offsetLeft;++		if ( jQuery.support.doesNotIncludeMarginInBodyOffset ) {+			top  += parseFloat( jQuery.css(body, "marginTop") ) || 0;+			left += parseFloat( jQuery.css(body, "marginLeft") ) || 0;+		}++		return { top: top, left: left };+	},++	setOffset: function( elem, options, i ) {+		var position = jQuery.css( elem, "position" );++		// set position first, in-case top/left are set even on static elem+		if ( position === "static" ) {+			elem.style.position = "relative";+		}++		var curElem = jQuery( elem ),+			curOffset = curElem.offset(),+			curCSSTop = jQuery.css( elem, "top" ),+			curCSSLeft = jQuery.css( elem, "left" ),+			calculatePosition = ( position === "absolute" || position === "fixed" ) && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1,+			props = {}, curPosition = {}, curTop, curLeft;++		// need to be able to calculate position if either top or left is auto and position is either absolute or fixed+		if ( calculatePosition ) {+			curPosition = curElem.position();+			curTop = curPosition.top;+			curLeft = curPosition.left;+		} else {+			curTop = parseFloat( curCSSTop ) || 0;+			curLeft = parseFloat( curCSSLeft ) || 0;+		}++		if ( jQuery.isFunction( options ) ) {+			options = options.call( elem, i, curOffset );+		}++		if ( options.top != null ) {+			props.top = ( options.top - curOffset.top ) + curTop;+		}+		if ( options.left != null ) {+			props.left = ( options.left - curOffset.left ) + curLeft;+		}++		if ( "using" in options ) {+			options.using.call( elem, props );+		} else {+			curElem.css( props );+		}+	}+};+++jQuery.fn.extend({++	position: function() {+		if ( !this[0] ) {+			return null;+		}++		var elem = this[0],++		// Get *real* offsetParent+		offsetParent = this.offsetParent(),++		// Get correct offsets+		offset       = this.offset(),+		parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();++		// Subtract element margins+		// note: when an element has margin: auto the offsetLeft and marginLeft+		// are the same in Safari causing offset.left to incorrectly be 0+		offset.top  -= parseFloat( jQuery.css(elem, "marginTop") ) || 0;+		offset.left -= parseFloat( jQuery.css(elem, "marginLeft") ) || 0;++		// Add offsetParent borders+		parentOffset.top  += parseFloat( jQuery.css(offsetParent[0], "borderTopWidth") ) || 0;+		parentOffset.left += parseFloat( jQuery.css(offsetParent[0], "borderLeftWidth") ) || 0;++		// Subtract the two offsets+		return {+			top:  offset.top  - parentOffset.top,+			left: offset.left - parentOffset.left+		};+	},++	offsetParent: function() {+		return this.map(function() {+			var offsetParent = this.offsetParent || document.body;+			while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {+				offsetParent = offsetParent.offsetParent;+			}+			return offsetParent;+		});+	}+});+++// Create scrollLeft and scrollTop methods+jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( method, prop ) {+	var top = /Y/.test( prop );++	jQuery.fn[ method ] = function( val ) {+		return jQuery.access( this, function( elem, method, val ) {+			var win = getWindow( elem );++			if ( val === undefined ) {+				return win ? (prop in win) ? win[ prop ] :+					jQuery.support.boxModel && win.document.documentElement[ method ] ||+						win.document.body[ method ] :+					elem[ method ];+			}++			if ( win ) {+				win.scrollTo(+					!top ? val : jQuery( win ).scrollLeft(),+					 top ? val : jQuery( win ).scrollTop()+				);++			} else {+				elem[ method ] = val;+			}+		}, method, val, arguments.length, null );+	};+});++function getWindow( elem ) {+	return jQuery.isWindow( elem ) ?+		elem :+		elem.nodeType === 9 ?+			elem.defaultView || elem.parentWindow :+			false;+}+++++// Create width, height, innerHeight, innerWidth, outerHeight and outerWidth methods+jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {+	var clientProp = "client" + name,+		scrollProp = "scroll" + name,+		offsetProp = "offset" + name;++	// innerHeight and innerWidth+	jQuery.fn[ "inner" + name ] = function() {+		var elem = this[0];+		return elem ?+			elem.style ?+			parseFloat( jQuery.css( elem, type, "padding" ) ) :+			this[ type ]() :+			null;+	};++	// outerHeight and outerWidth+	jQuery.fn[ "outer" + name ] = function( margin ) {+		var elem = this[0];+		return elem ?+			elem.style ?+			parseFloat( jQuery.css( elem, type, margin ? "margin" : "border" ) ) :+			this[ type ]() :+			null;+	};++	jQuery.fn[ type ] = function( value ) {+		return jQuery.access( this, function( elem, type, value ) {+			var doc, docElemProp, orig, ret;++			if ( jQuery.isWindow( elem ) ) {+				// 3rd condition allows Nokia support, as it supports the docElem prop but not CSS1Compat+				doc = elem.document;+				docElemProp = doc.documentElement[ clientProp ];+				return jQuery.support.boxModel && docElemProp ||+					doc.body && doc.body[ clientProp ] || docElemProp;+			}++			// Get document width or height+			if ( elem.nodeType === 9 ) {+				// Either scroll[Width/Height] or offset[Width/Height], whichever is greater+				doc = elem.documentElement;++				// when a window > document, IE6 reports a offset[Width/Height] > client[Width/Height]+				// so we can't use max, as it'll choose the incorrect offset[Width/Height]+				// instead we use the correct client[Width/Height]+				// support:IE6+				if ( doc[ clientProp ] >= doc[ scrollProp ] ) {+					return doc[ clientProp ];+				}++				return Math.max(+					elem.body[ scrollProp ], doc[ scrollProp ],+					elem.body[ offsetProp ], doc[ offsetProp ]+				);+			}++			// Get width or height on the element+			if ( value === undefined ) {+				orig = jQuery.css( elem, type );+				ret = parseFloat( orig );+				return jQuery.isNumeric( ret ) ? ret : orig;+			}++			// Set the width or height on the element+			jQuery( elem ).css( type, value );+		}, type, value, arguments.length, null );+	};+});+++++// Expose jQuery to the global object+window.jQuery = window.$ = jQuery;++// Expose jQuery as an AMD module, but only for AMD loaders that+// understand the issues with loading multiple versions of jQuery+// in a page that all might call define(). The loader will indicate+// they have special allowances for multiple jQuery versions by+// specifying define.amd.jQuery = true. Register as a named module,+// since jQuery can be concatenated with other files that may use define,+// but not use a proper concatenation script that understands anonymous+// AMD modules. A named AMD is safest and most robust way to register.+// Lowercase jquery is used because AMD module names are derived from+// file names, and jQuery is normally delivered in a lowercase file name.+// Do this after creating the global so that if an AMD module wants to call+// noConflict to hide this version of jQuery, it will work.+if ( typeof define === "function" && define.amd && define.amd.jQuery ) {+	define( "jquery", [], function () { return jQuery; } );+}++++})( window );
+ static/js/bootstrap-dropdown.js view
@@ -0,0 +1,92 @@+/* ============================================================+ * bootstrap-dropdown.js v2.0.2+ * http://twitter.github.com/bootstrap/javascript.html#dropdowns+ * ============================================================+ * Copyright 2012 Twitter, Inc.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ * ============================================================ */+++!function( $ ){++  "use strict"++ /* DROPDOWN CLASS DEFINITION+  * ========================= */++  var toggle = '[data-toggle="dropdown"]'+    , Dropdown = function ( element ) {+        var $el = $(element).on('click.dropdown.data-api', this.toggle)+        $('html').on('click.dropdown.data-api', function () {+          $el.parent().removeClass('open')+        })+      }++  Dropdown.prototype = {++    constructor: Dropdown++  , toggle: function ( e ) {+      var $this = $(this)+        , selector = $this.attr('data-target')+        , $parent+        , isActive++      if (!selector) {+        selector = $this.attr('href')+        selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7+      }++      $parent = $(selector)+      $parent.length || ($parent = $this.parent())++      isActive = $parent.hasClass('open')++      clearMenus()+      !isActive && $parent.toggleClass('open')++      return false+    }++  }++  function clearMenus() {+    $(toggle).parent().removeClass('open')+  }+++  /* DROPDOWN PLUGIN DEFINITION+   * ========================== */++  $.fn.dropdown = function ( option ) {+    return this.each(function () {+      var $this = $(this)+        , data = $this.data('dropdown')+      if (!data) $this.data('dropdown', (data = new Dropdown(this)))+      if (typeof option == 'string') data[option].call($this)+    })+  }++  $.fn.dropdown.Constructor = Dropdown+++  /* APPLY TO STANDARD DROPDOWN ELEMENTS+   * =================================== */++  $(function () {+    $('html').on('click.dropdown.data-api', clearMenus)+    $('body').on('click.dropdown.data-api', toggle, Dropdown.prototype.toggle)+  })++}( window.jQuery );
+ static/js/bootstrap-modal.js view
@@ -0,0 +1,210 @@+/* =========================================================+ * bootstrap-modal.js v2.0.2+ * http://twitter.github.com/bootstrap/javascript.html#modals+ * =========================================================+ * Copyright 2012 Twitter, Inc.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ * ========================================================= */+++!function( $ ){++  "use strict"++ /* MODAL CLASS DEFINITION+  * ====================== */++  var Modal = function ( content, options ) {+    this.options = options+    this.$element = $(content)+      .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))+  }++  Modal.prototype = {++      constructor: Modal++    , toggle: function () {+        return this[!this.isShown ? 'show' : 'hide']()+      }++    , show: function () {+        var that = this++        if (this.isShown) return++        $('body').addClass('modal-open')++        this.isShown = true+        this.$element.trigger('show')++        escape.call(this)+        backdrop.call(this, function () {+          var transition = $.support.transition && that.$element.hasClass('fade')++          !that.$element.parent().length && that.$element.appendTo(document.body) //don't move modals dom position++          that.$element+            .show()++          if (transition) {+            that.$element[0].offsetWidth // force reflow+          }++          that.$element.addClass('in')++          transition ?+            that.$element.one($.support.transition.end, function () { that.$element.trigger('shown') }) :+            that.$element.trigger('shown')++        })+      }++    , hide: function ( e ) {+        e && e.preventDefault()++        if (!this.isShown) return++        var that = this+        this.isShown = false++        $('body').removeClass('modal-open')++        escape.call(this)++        this.$element+          .trigger('hide')+          .removeClass('in')++        $.support.transition && this.$element.hasClass('fade') ?+          hideWithTransition.call(this) :+          hideModal.call(this)+      }++  }+++ /* MODAL PRIVATE METHODS+  * ===================== */++  function hideWithTransition() {+    var that = this+      , timeout = setTimeout(function () {+          that.$element.off($.support.transition.end)+          hideModal.call(that)+        }, 500)++    this.$element.one($.support.transition.end, function () {+      clearTimeout(timeout)+      hideModal.call(that)+    })+  }++  function hideModal( that ) {+    this.$element+      .hide()+      .trigger('hidden')++    backdrop.call(this)+  }++  function backdrop( callback ) {+    var that = this+      , animate = this.$element.hasClass('fade') ? 'fade' : ''++    if (this.isShown && this.options.backdrop) {+      var doAnimate = $.support.transition && animate++      this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')+        .appendTo(document.body)++      if (this.options.backdrop != 'static') {+        this.$backdrop.click($.proxy(this.hide, this))+      }++      if (doAnimate) this.$backdrop[0].offsetWidth // force reflow++      this.$backdrop.addClass('in')++      doAnimate ?+        this.$backdrop.one($.support.transition.end, callback) :+        callback()++    } else if (!this.isShown && this.$backdrop) {+      this.$backdrop.removeClass('in')++      $.support.transition && this.$element.hasClass('fade')?+        this.$backdrop.one($.support.transition.end, $.proxy(removeBackdrop, this)) :+        removeBackdrop.call(this)++    } else if (callback) {+      callback()+    }+  }++  function removeBackdrop() {+    this.$backdrop.remove()+    this.$backdrop = null+  }++  function escape() {+    var that = this+    if (this.isShown && this.options.keyboard) {+      $(document).on('keyup.dismiss.modal', function ( e ) {+        e.which == 27 && that.hide()+      })+    } else if (!this.isShown) {+      $(document).off('keyup.dismiss.modal')+    }+  }+++ /* MODAL PLUGIN DEFINITION+  * ======================= */++  $.fn.modal = function ( option ) {+    return this.each(function () {+      var $this = $(this)+        , data = $this.data('modal')+        , options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option)+      if (!data) $this.data('modal', (data = new Modal(this, options)))+      if (typeof option == 'string') data[option]()+      else if (options.show) data.show()+    })+  }++  $.fn.modal.defaults = {+      backdrop: true+    , keyboard: true+    , show: true+  }++  $.fn.modal.Constructor = Modal+++ /* MODAL DATA-API+  * ============== */++  $(function () {+    $('body').on('click.modal.data-api', '[data-toggle="modal"]', function ( e ) {+      var $this = $(this), href+        , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7+        , option = $target.data('modal') ? 'toggle' : $.extend({}, $target.data(), $this.data())++      e.preventDefault()+      $target.modal(option)+    })+  })++}( window.jQuery );
+ static/longpolling.js view
@@ -0,0 +1,25 @@+// Updates a div with a specified id, by polling an url,+// which should return a new div, with the same id.++connfails=0;++function longpoll(url, divid, cont, fail) {+	$.ajax({+		'url': url,+		'dataType': 'html',+		'success': function(data, status, jqxhr) {+			$('#' + divid).replaceWith(data);+			connfails=0;+			cont();+		},+		'error': function(jqxhr, msg, e) {+			connfails=connfails+1;+			if (connfails > 3) {+				fail();+			}+			else {+				cont();+			}+		}+	});+}
+ templates/README view
@@ -0,0 +1,7 @@+These are template files for the git-annex webapp. They use the+Shakespearean template library, which is documented here:+http://www.yesodweb.com/book/shakespearean-templates++Note that for most of the templates, it will use files ending in+.hamlet, .julius, and .cassius if they exist. So if you need to add CSS,+or javascript, you can create the missing template files.
+ templates/actionbutton.hamlet view
@@ -0,0 +1,2 @@+<a class="#{buttonclass}" href="@{route}" onclick="(function( $ ) { $.post('@{route}'); })( jQuery ); return false;">+  <i class="#{iconclass}"></i> #{fromMaybe "" label}
+ templates/bootstrap.hamlet view
@@ -0,0 +1,14 @@+$doctype 5+<html>+  <head>+    <title>+     $maybe reldir <- relDir webapp+       #{reldir} #{pageTitle page}+     $nothing+       #{pageTitle page}+    <link rel="icon" href=@{StaticR favicon_ico} type="image/x-icon">+    <meta name="viewport" content="width=device-width,initial-scale=1.0">+    ^{pageHead page}+  <body>+    ^{pageBody page}+    <div #modal></div>
+ templates/configurators/adddrive.hamlet view
@@ -0,0 +1,39 @@+<div .span9 .hero-unit>+  <h2>+    Adding a removable drive+  <p>+    Clone this repository to a USB drive, memory stick, or other #+    removable media. Whenever the removable drive is plugged in, its+    content will be synced with the content of this repository.+  <p>+  $if (null writabledrives)+    <div .span6 .alert .alert-error .alert-block>+      $if (null removabledrives)+        <h4 .alert-heading>+          No removable drives found+        Please make sure you have a removable drive plugged in and mounted.+      $else+        <h4 .alert-heading>+          No usable removable drives found+        Seems you cannot write to any of the removable drives that are #+        currently mounted. Try plugging in a removable drive that you can #+        write to, or correcting the write permissions.+      <p>+        <a .btn .btn-primary href="@{AddDriveR}">+          Rescan for removable drives+  $else+    <form enctype=#{enctype}>+      <fieldset>+        ^{form}+        ^{authtoken}+        <button .btn .btn-primary type=submit onclick="$('#clonemodal').modal('show');">Use this drive</button> #+        <a .btn href="@{AddDriveR}">+          Rescan for removable drives+<div .modal .fade #clonemodal>+  <div .modal-header>+    <h3>+      Cloning to drive+  <div .modal-body>+    <p>+      Cloning the repository to the drive. This may take a few minutes; #+      do not remove the drive.
+ templates/configurators/addrsync.net.hamlet view
@@ -0,0 +1,43 @@+<div .span9 .hero-unit>+  <h2>+    Adding a Rsync.net repository+  <p>+    <a href="http://rsync.net/">+      Rsync.net #+    is a well-respected cloud storage provider. Its rsync repositories are #+    supported very well by git-annex. #+    <a href="http://www.rsync.net/products/pricing.html">+      pricing details+  <p>+    $case status+      $of UnusableServer msg+        <div .alert .alert-error>+          <i .icon-warning-sign></i> #{msg}+      $of _+        <i .icon-warning-sign></i> #+        All your data will be synced to the Rsync.net repository, so make #+        sure it has enough available space. Your data will be encrypted before #+        it is sent to Rsync.net.+  <p>+    When you sign up for a Rsync.net account, you receive an #+    email from them with a host name and a username. Fill that #+    information in below. You also likely don't want to use your whole #+    rsync.net repository for git-annex alone, so git-annex will use a #+    subdirectory of it, as configured below.+  <p>+    <form .form-horizontal enctype=#{enctype}>+      <fieldset>+        ^{form}+        ^{authtoken}+        <div .form-actions>+          <button .btn .btn-primary type=submit onclick="$('#testmodal').modal('show');">+            Use this rsync.net repository+<div .modal .fade #testmodal>+  <div .modal-header>+    <h3>+      Making repository ...+  <div .modal-body>+    <p>+      Setting up your rsync.net repository. This could take a minute.+    <p>+      You may be prompted for your rsync.net ssh password.
+ templates/configurators/enabledirectory.hamlet view
@@ -0,0 +1,10 @@+<div .span9 .hero-unit>+  <h2>+    Enabling #{description}+  <p>+    Where is this repository located?+  <p>+    <a .btn href="@{AddDriveR}">+      On a removable drive+    <a .btn href="@{RepositoriesR}">+      Cancel
+ templates/configurators/intro.hamlet view
@@ -0,0 +1,28 @@+<div .span9 ##{ident} .hero-unit>+  $maybe reldir <- relDir webapp+   <h2>+      git-annex is watching over your files in <small><tt>#{reldir}</tt></small>+    <p>+      It will automatically notice changes, and keep files in sync between #+      $if notenough+        repositories on your devices ...+        <h2>+          But no other repositories are set up yet.+        <a .btn .btn-primary .btn-large href="@{RepositoriesR}">Add another repository</a>+      $else+        $if barelyenough+          <span .badge .badge-warning>#{numrepos}</span>+        $else+          <span .badge .badge-success>#{numrepos}</span>+        \ repositories and devices:+        <table .table .table-striped .table-condensed>+          <tbody>+            $forall (num, name, _) <- repolist+              <tr>+                <td>+                  #{num}+                <td>+                  #{name}+        <a .btn .btn-primary .btn-large href="@{RepositoriesR}">Add another repository</a>+        <p>+          Or just sit back, watch the magic, and get on with using your files.
+ templates/configurators/main.hamlet view
@@ -0,0 +1,9 @@+<div .span9>+  <div .row-fluid>+    <div .span4>+      <h3>+        <a href="@{RepositoriesR}">+          Manage repositories+     <p>+       Distribute the files in this repository to other devices, #+       make backups, and more, by adding repositories.
+ templates/configurators/newrepository.hamlet view
@@ -0,0 +1,15 @@+<div .span9 .hero-unit>+  <h2>+    Add another repository+  <p>+    The form below will make a separate repository, that is not synced #+    with your existing repository. You can use the new repository for #+    different sorts of files, that are synced and shared with other #+    devices and users.+  <p>+    <form .form-inline enctype=#{enctype}>+      ^{form}+  <p>+    <i .icon-asterisk></i> #+    Do you want to add another repository that is kept in sync with #+    the current one? If so, <a href="@{RepositoriesR}">go here</a>.
+ templates/configurators/newrepository/first.hamlet view
@@ -0,0 +1,14 @@+<div .span9 .hero-unit>+  <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.+  <p>+    <form .form-inline enctype=#{enctype}>+      ^{form}
+ templates/configurators/newrepository/form.hamlet view
@@ -0,0 +1,11 @@+#{msg}+<p>+  <div .input-prepend .input-append>+    <span .add-on>+      <i .icon-folder-open></i>+    ^{fvInput pathView}+    <button type=submit .btn .btn-primary>+      Make Repository+$if err+  <div .alert .alert-error>+    #{errmsg}
+ templates/configurators/pairing/disabled.hamlet view
@@ -0,0 +1,5 @@+<div .span9 .hero-unit>+  <h2>+    Pairing not supported+  <p>+    This build of git-annex does not support pairing. Sorry!
+ templates/configurators/pairing/inprogress.hamlet view
@@ -0,0 +1,18 @@+<div .span9 .hero-unit>+  <h2>+    Pairing in progress ..+  $if T.null secret+    <p>+      You do not need to leave this page open; pairing will finish #+      automatically.+  $else+    <p>+      Now you should either go tell the owner of the computer you want to pair #+      with the secret phrase you selected ("#{secret}"), or go enter it into #+      the computer you want to pair with.+    <p>+      You do not need to leave this page open; pairing will finish automatically #+      as soon as the secret phrase is entered into the other computer.+    <p>+      If you're not seeing a pair request on the other computer, try moving #+      it to the same switch or wireless network as this one.
+ templates/configurators/pairing/prompt.hamlet view
@@ -0,0 +1,50 @@+<div .span9 .hero-unit>+  <h2>+    Pairing with a local computer+  <p>+    $if start+      Pair with a computer on your local network (or VPN), and the #+      two git annex repositories will be combined into one, with changes #+      kept in sync between them.+    $else+      Pairing with #{username}@#{hostname} will combine the two git annex #+      repositories into one, with changes kept in sync between them.+  <p>+    $if start+      For security, enter a secret phrase. This same secret phrase will #+      also need to be entered on the computer you're pairing with. #+      It will be used to verify you're pairing with the right computer.+    $else+      $if sameusername+        For security, you need to enter the same secret phrase that was #+        entered on #{hostname} when the pairing was started.+      $else+        For security, a secret phrase has been selected, which you need #+        to enter here to finish the pairing. If you don't know the #+        phrase, go ask #{username} ...+  $if badphrase+    <div .alert .alert-error>+      <i .icon-warning-sign></i> #{problem}+  <p>+    <form .form-horizontal enctype=#{enctype}>+      <fieldset>+        ^{form}+        ^{authtoken}+        <div .form-actions>+          <button .btn .btn-primary type=submit>+            $if start+              Start pairing+            $else+              Finish pairing+    <div .alert .alert-info>+      $if start+        <p>+          A good secret phrase is reasonably long. You'll only #+          type it a few times. Only letters and numbers matter; #+          punctuation and white space is ignored.+        <p>+          A quotation is one good choice, something like: #+          "#{sampleQuote}"+      $else+        Only letters and numbers matter; punctuation and spaces are #+        ignored.
+ templates/configurators/repositories.hamlet view
@@ -0,0 +1,78 @@+<div .span9>+  <h2>+    Your repositories+  <table .table .table-condensed>+    <tbody>+      $forall (num, name, needsenabled) <- repolist+        <tr>+          <td>+            #{num}+          <td>+            $if isJust needsenabled+              <i>#{name}+            $else+              #{name}+          <td>+            $maybe enable <- needsenabled+              <i>not enabled here #+              &rarr; #+              <a href="@{enable}">+                enable+  <div .row-fluid>+    <div .span6>+      <h2>+        Add more repositories++      <h3>+        <a href="@{AddDriveR}">+          <i .icon-plus-sign></i> Removable drive+      <p>+        Clone this repository to a USB drive, memory stick, or other #+        removable media.+      <p>+        For offline archiving, backups, or to #+        <a href="http://en.wikipedia.org/wiki/Sneakernet">SneakerNet</a> #+        between computers. ++      <h3>+        <a href="@{StartPairR}">+          <i .icon-plus-sign></i> Local computer+      <p>+        Pair with a local computer to automatically keep files in sync #+        between computers on your local network.+      <p>+        For easy sharing with family and friends, or between your devices.++      <h3>+        <i .icon-plus-sign></i> Phone+      <p>+        Save photos and recordings from your phone.+      <p>+        Send selected files to your phone.++    <div .span6>+      <h2>+        Store your data in the cloud++      <h3>+        <a href="@{AddRsyncNetR}">+          <i .icon-plus-sign></i> Rsync.net+      <p>+        Works very well with git-annex.++      <h3>+        <i .icon-plus-sign></i> Amazon S3+      <p>+        Good choice for professional storage quality and low prices.++      <h3>+        <i .icon-plus-sign></i> Box.com+      <p>+        Provides free cloud storage for small amounts of data.++      <h3>+        <a href="@{AddSshR}">+          <i .icon-plus-sign></i> Remote server+      <p>+        Set up a repository on a remote server using #+        <tt>ssh</tt>, to build your own personal cloud.
+ templates/configurators/ssh/add.hamlet view
@@ -0,0 +1,33 @@+<div .span9 .hero-unit>+  <h2>+    Adding a remote server using ssh+  <p>+    You can use nearly any server that has ssh and rsync. For example, you #+    could use a <a href="http://linode.com/">Linode</a> or another VPS, or #+    an account on a friend's server.+  <p>+    $case status+      $of UnusableServer msg+        <div .alert .alert-error>+          <i .icon-warning-sign></i> #{msg}+      $of _+        <i .icon-warning-sign></i> Do keep in mind that all your data #+        will be synced to the server, so make sure it has enough available #+        disk space and bandwidth, and that you trust it with your data.+  <p>+    <form .form-horizontal enctype=#{enctype}>+      <fieldset>+        ^{form}+        ^{authtoken}+        <div .form-actions>+          <button .btn .btn-primary type=submit onclick="$('#testmodal').modal('show');">+            Check this server+<div .modal .fade #testmodal>+  <div .modal-header>+    <h3>+      Testing server ...+  <div .modal-body>+    <p>+      Checking ssh connection to the server. This could take a minute.+    <p>+      You may be prompted for your password to log into the server.
+ templates/configurators/ssh/confirm.hamlet view
@@ -0,0 +1,42 @@+<div .span9 .hero-unit>+  <h2>+    Ready to add remote server+  <div .row-fluid>+    <div .span8>+      <p>+        The server #{sshHostName sshdata} has been verified to be usable.+      $if not (rsyncOnly sshdata)+        <p>+          You have two options for how to use the server.+        <p>+          <a .btn .btn-primary href="@{MakeSshGitR sshdata}" onclick="$('#setupmodal').modal('show');">+            Use a git repository on the server+          <br>+          All your data will be uploaded to the server. If you set up other #+          devices to use the same server, they will all be kept in sync, #+          using the server as a central hub. #+      <p>+        <a .btn .btn-primary href="@{MakeSshRsyncR sshdata}" onclick="$('#setupmodal').modal('show');">+          Use an encrypted rsync repository on the server+        <br>+        The contents of your files will be stored, fully encrypted, on the #+        server. The server will not store other information about your #+        git repository.+    <div .span4>+      $if needsPubKey sshdata+        <div .alert .alert-info>+          <i .icon-info-sign></i> #+          A ssh key will be installed on the server, allowing git-annex to #+          access it securely without a password.+<div .modal .fade #setupmodal>+  <div .modal-header>+    <h3>+      Making repository ...+  <div .modal-body>+    <p>+      Setting up repository on the remote server. This could take a minute.+    $if needsPubKey sshdata+      <p>+        You will be prompted once more for your ssh password. A ssh key #+        is being installed on the server, allowing git-annex to access it #+        securely without a password.
+ templates/configurators/ssh/enable.hamlet view
@@ -0,0 +1,30 @@+<div .span9 .hero-unit>+  <h2>+    Enabling #{description}+  <p>+    Another repository uses this server, but the server is not #+    yet enabled for use here. The first step to enable it is to check if it's #+    usable here.+  <p>+  <p>+    <form .form-horizontal enctype=#{enctype}>+      <fieldset>+        <div .form-actions>+          <button .btn .btn-primary type=submit onclick="$('#testmodal').modal('show');">+            Check this server+        $case status+          $of UnusableServer msg+            <div .alert .alert-error>+              <i .icon-warning-sign></i> #{msg}+          $of _+        ^{form}+        ^{authtoken}+<div .modal .fade #testmodal>+  <div .modal-header>+    <h3>+      Testing server ...+  <div .modal-body>+    <p>+      Checking ssh connection to the server. This could take a minute.+    <p>+      You may be prompted for your password to log into the server.
+ templates/configurators/ssh/error.hamlet view
@@ -0,0 +1,10 @@+<div .span9 .hero-unit>+  <h2>+    <i .icon-warning-sign></i> Failed to make repository+  <p>+    Something went wrong setting up the repository on the remote server.+  <p>+    Transcript: #{msg}+  <p>+    <a .btn .btn-primary href="#">+     Retry
+ templates/dashboard/main.hamlet view
@@ -0,0 +1,10 @@+^{content}+  $if warnNoScript+    <noscript>+      <div .navbar .navbar-fixed-bottom>+        <div .navbar-inner>+          <div .container>+            Javascript is disabled; cannot update in real-time.+            <div .btn-group>+              <a .btn .btn-primary href="@{NoScriptAutoR}">Auto-refresh every 3 seconds #+              <a .btn .btn-primary href="@{NoScriptR}">Manually refresh
+ templates/dashboard/metarefresh.hamlet view
@@ -0,0 +1,2 @@+<noscript>+  <meta http-equiv="refresh" content="#{show delayseconds}; URL=@{this}">
+ templates/dashboard/transfers.hamlet view
@@ -0,0 +1,37 @@+<div .span9 ##{ident}>+  $if null transfers+  $else+    <h2>Transfers+    $forall (transfer, info) <- transfers+      $with percent <- maybe "unknown" (showPercentage 0) $ percentComplete transfer info+        <div .row-fluid>+          <div .span10>+            <div .row-fluid>+              <h3>+                $maybe file <- associatedFile info+                  #{file}+                $nothing+                  #{key2file $ transferKey transfer}+                $case transferDirection transfer+                  $of Upload+                    &rarr;+                  $of Download+                    &larr;+                <small>#{maybe "unknown" Remote.name $ transferRemote info}</small>+                  $with size <- maybe "unknown" (roughSize dataUnits True) $ keySize $ transferKey transfer+                    $if isJust $ startedTime info+                      $if isrunning info+                        <small .pull-right><b>#{percent} of #{size}</b></small>+                      $else+                        <small .pull-right>paused at #{percent} of #{size}</small>+                    $else+                        <small .pull-right>queued (#{size})</small>+            <div .row-fluid>+              <div .progress .progress-striped>+                <div .bar style="width: #{percent};">+          <div .btn-group .span2>+            $if isrunning info+              ^{actionButton (PauseTransferR transfer) Nothing "btn" "icon-pause"}+            $else+              ^{actionButton (StartTransferR transfer) Nothing "btn" "icon-play"}+            ^{actionButton (CancelTransferR transfer) Nothing "btn" "icon-remove"}
+ templates/documentation/about.hamlet view
@@ -0,0 +1,17 @@+<div .span9 .hero-unit>+  <h2>+    git-annex watches over your files+  <p>+    It will automatically notice changes, and keep files in sync between #+    repositories and devices.+  <p>+    For full details, see #+    <a href="http://git-annex.branchable.com/">the git-annex website</a>.+  <hr>+    git-annex is © 2010-2012 Joey Hess. It is free software, licensed #+    under the terms of the GNU General Public License, version 3 or above. #+    <p>+    Its development was made possible by #+    <a href="http://git-annex.branchable.com/assistant/thanks/">+      many excellent people+    . <i .icon-heart></i>
+ templates/notifications/longpolling.julius view
@@ -0,0 +1,12 @@+function longpoll_#{ident}() {+	longpoll(longpoll_#{ident}_url, '#{ident}'+		, function() { setTimeout(longpoll_#{ident}, #{delay}); }+		, function() { webapp_disconnected(); }+	);+}+$(function() {+	$.get("@{geturl}", function(url){+		longpoll_#{ident}_url = url;+		setTimeout(longpoll_#{ident}, #{startdelay});+	});+});
+ templates/otherrepos.hamlet view
@@ -0,0 +1,10 @@+<ul .dropdown-menu>+  $forall (name, path) <- repolist+    <li>+      <a href="@{SwitchToRepositoryR path}">+        #{name}+  $if not (null repolist)+    <li .divider></li>+  <li>+    <a href="@{NewRepositoryR}">+      Add another repository
+ templates/page.cassius view
@@ -0,0 +1,5 @@+body+  padding-top: 60px+  padding-bottom: 40px+.sidebar-nav+  padding: 9px 0
+ templates/page.hamlet view
@@ -0,0 +1,23 @@+<div .navbar .navbar-fixed-top>+  <div .navbar-inner>+    <div .container>+      <a .brand>+        git-annex+      <ul .nav>+        $forall (name, route, isactive) <- navbar+          <li :isactive:.active>+            <a href="@{route}">+              #{name}+      $maybe reldir <- relDir webapp+        <ul .nav .pull-right>+          <li>+            ^{actionButton FileBrowserR (Just "Files") "" "icon-folder-open icon-white"}+          <li .dropdown #menu1>+            <a .dropdown-toggle data-toggle="dropdown" href="#menu1">+              Current Repository: #{reldir}+              <b .caret></b>+            ^{otherReposWidget}+      $nothing+<div .container-fluid>+  <div .row-fluid>+    ^{content}
+ templates/page.julius view
@@ -0,0 +1,17 @@+connfailed =+  '<div id="modal" class="modal fade">' ++  '  <div class="modal-header">' ++  '    <h3>git-annex has shut down</h3>' ++  '  </div>' ++  '  <div class="modal-body">' ++  '    You can now close this browser window.' ++  '  </div>' ++  '</div>' ;++function webapp_disconnected () {+	$('#modal').replaceWith(connfailed);+	$('#modal').modal('show');++	// ideal, but blocked by many browsers+	window.close();+}
+ templates/sidebar/alert.hamlet view
@@ -0,0 +1,21 @@+<div .alert .fade .in .#{divclass} :block:.alert-block ##{alertid}>+  $if closable+    <a .close onclick="(function( $ ) { $.get('@{CloseAlert aid}') })( jQuery );">&times;</a>+  $maybe h <- renderAlertHeader alert+    $if block+      <h4 .alert-heading>+        $maybe i <- alertIcon alert+          <i .icon-#{bootstrapIcon i}></i> #+        #{h}+    $else+      $maybe i <- alertIcon alert+        <i .icon-#{bootstrapIcon i}></i> #+      <strong>#{h}</strong> #+  $nothing+    $maybe i <- alertIcon alert+      <i .icon-#{bootstrapIcon i}></i> #+  #{renderAlertMessage alert}+  $maybe button <- alertButton alert+    <br>+    <a .btn .btn-primary href="@{ClickAlert aid}">+      #{buttonLabel button}
+ templates/sidebar/main.hamlet view
@@ -0,0 +1,3 @@+<div .span3 ##{ident}>+  <div .sidebar-nav>+    ^{content}
test.hs view
@@ -14,6 +14,7 @@ import System.Posix.Directory (changeWorkingDirectory) import System.Posix.Files import System.Posix.Env+import System.Posix.Process import Control.Exception.Extensible import qualified Data.Map as M import System.IO.HVFS (SystemFS(..))@@ -46,6 +47,7 @@ import qualified Utility.Gpg import qualified Build.SysConfig import qualified Utility.Format+import qualified Utility.Verifiable  -- for quickcheck instance Arbitrary Types.Key.Key where@@ -76,7 +78,7 @@ 	[ qctest "prop_idempotent_deencode_git" Git.Filename.prop_idempotent_deencode 	, qctest "prop_idempotent_deencode" Utility.Format.prop_idempotent_deencode 	, qctest "prop_idempotent_fileKey" Locations.prop_idempotent_fileKey-	, qctest "prop_idempotent_key_read_show" Types.Key.prop_idempotent_key_read_show+	, qctest "prop_idempotent_key_encode" Types.Key.prop_idempotent_key_encode 	, qctest "prop_idempotent_shellEscape" Utility.SafeCommand.prop_idempotent_shellEscape 	, qctest "prop_idempotent_shellEscape_multiword" Utility.SafeCommand.prop_idempotent_shellEscape_multiword 	, qctest "prop_idempotent_configEscape" Logs.Remote.prop_idempotent_configEscape@@ -88,6 +90,7 @@ 	, qctest "prop_hmacWithCipher_sane" Crypto.prop_hmacWithCipher_sane 	, qctest "prop_TimeStamp_sane" Logs.UUIDBased.prop_TimeStamp_sane 	, qctest "prop_addLog_sane" Logs.UUIDBased.prop_addLog_sane+	, qctest "prop_verifiable_sane" Utility.Verifiable.prop_verifiable_sane 	]  blackbox :: Test@@ -174,7 +177,7 @@ 	writeFile tmp $ content sha1annexedfile 	r <- annexeval $ Types.Backend.getKey backendSHA1 $ 		Types.KeySource.KeySource { Types.KeySource.keyFilename = tmp, Types.KeySource.contentLocation = tmp }-	let key = show $ fromJust r+	let key = Types.Key.key2file $ fromJust r 	git_annex "reinject" [tmp, sha1annexedfile] @? "reinject failed" 	git_annex "fromkey" [key, sha1annexedfiledup] @? "fromkey failed" 	annexed_present sha1annexedfiledup@@ -472,33 +475,33 @@ 	sha1annexedfilekey <- annexeval $ findkey sha1annexedfile 	git_annex "get" [annexedfile] @? "get of file failed" 	git_annex "get" [sha1annexedfile] @? "get of file failed"-	checkunused []+	checkunused [] "after get" 	boolSystem "git" [Params "rm -q", File annexedfile] @? "git rm failed"-	checkunused []+	checkunused [] "after rm" 	boolSystem "git" [Params "commit -q -m foo"] @? "git commit failed"-	checkunused []+	checkunused [] "after commit" 	-- unused checks origin/master; once it's gone it is really unused 	boolSystem "git" [Params "remote rm origin"] @? "git remote rm origin failed"-	checkunused [annexedfilekey]+	checkunused [annexedfilekey] "after origin branches are gone" 	boolSystem "git" [Params "rm -q", File sha1annexedfile] @? "git rm failed" 	boolSystem "git" [Params "commit -q -m foo"] @? "git commit failed"-	checkunused [annexedfilekey, sha1annexedfilekey]+	checkunused [annexedfilekey, sha1annexedfilekey] "after rm sha1annexedfile"  	-- good opportunity to test dropkey also-	git_annex "dropkey" ["--force", show annexedfilekey]+	git_annex "dropkey" ["--force", Types.Key.key2file annexedfilekey] 		@? "dropkey failed"-	checkunused [sha1annexedfilekey]+	checkunused [sha1annexedfilekey] ("after dropkey --force " ++ Types.Key.key2file annexedfilekey)  	git_annex "dropunused" ["1", "2"] @? "dropunused failed"-	checkunused []+	checkunused [] "after dropunused" 	git_annex "dropunused" ["10", "501"] @? "dropunused failed on bogus numbers"  	where-		checkunused expectedkeys = do+		checkunused expectedkeys desc = do 			git_annex "unused" [] @? "unused failed" 			unusedmap <- annexeval $ Logs.Unused.readUnusedLog "" 			let unusedkeys = M.elems unusedmap-			assertEqual "unused keys differ"+			assertEqual ("unused keys differ " ++ desc) 				(sort expectedkeys) (sort unusedkeys) 		findkey f = do 			r <- Backend.lookupFile f@@ -839,7 +842,7 @@ 	case r of 		Just (k, _) -> do 			uuids <- annexeval $ Remote.keyLocations k-			assertEqual ("bad content in location log for " ++ f ++ " key " ++ (show k) ++ " uuid " ++ show thisuuid)+			assertEqual ("bad content in location log for " ++ f ++ " key " ++ (Types.Key.key2file k) ++ " uuid " ++ show thisuuid) 				expected (thisuuid `elem` uuids) 		_ -> assertFailure $ f ++ " failed to look up key" @@ -881,8 +884,11 @@ 	setEnv "PATH" (cwd ++ ":" ++ p) True 	setEnv "TOPDIR" cwd True 	-- Avoid git complaining if it cannot determine the user's email-	-- address.-	setEnv "EMAIL" "git-annex test <test@example.com>" True+	-- address, or exploding if it doesn't know the user's name.+	setEnv "GIT_AUTHOR_EMAIL" "test@example.com" True+	setEnv "GIT_AUTHOR_NAME" "git-annex test" True+	setEnv "GIT_COMMITTER_EMAIL" "test@example.com" True+	setEnv "GIT_COMMITTER_NAME" "git-annex test" True  changeToTmpDir :: FilePath -> IO () changeToTmpDir t = do
+ ui-macos/git-annex.app/Contents/Info.plist view
@@ -0,0 +1,45 @@+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<plist version="1.0">+<dict>+	<key>CFBundleDevelopmentRegion</key>+	<string>English</string>+	<key>CFBundleExecutable</key>+	<string>git-annex</string>+	<key>NSHumanReadableCopyright</key>+	<string>GPL 3</string>+	<key>CFBundleGetInfoString</key>+	<string>0.0.1</string>+	<key>CFBundleIconFile</key>+	<string>git-annex</string>+	<key>CFBundleIdentifier</key>+	<string>com.branchable.git-annex</string>+	<key>CFBundleInfoDictionaryVersion</key>+	<string>6.0</string>+	<key>CFBundleName</key>+	<string>GIT-ANNEX</string>+	<key>CFBundlePackageType</key>+	<string>APPL</string>+	<key>CFBundleShortVersionString</key>+	<string>0.0.1</string>+	<key>CFBundleSignature</key>+	<string>git-annex</string>+	<key>CFBundleVersion</key>+	<string>0.0.1</string>+	<key>NSAppleScriptEnabled</key>+	<true/>+	<key>CGDisableCoalescedUpdates</key>+	<true/>+	<key>LSMinimumSystemVersion</key>+	<string>10.5</string>+	<key>CFBundleDisplayName</key>+	<string>Start git-annex webapp</string>+	<key>LSMinimumSystemVersionByArchitecture</key>+	<dict>+		<key>i386</key>+		<string>10.5.0</string>+		<key>x86_64</key>+		<string>10.6.0</string>+	</dict>+</dict>+</plist>
+ ui-macos/git-annex.app/Contents/MacOS/git-annex view
@@ -0,0 +1,5 @@+#!/bin/sh+# The contents of this file are not installed; instead a script +# is generated containing the full path to the real git-annex+# executable.+git annex webapp
+ ui-macos/git-annex.app/Contents/Resources/git-annex.icns view

binary file changed (absent → 52194 bytes)