Browse Source

Update customized domain support

pull/103/head
Unknown 12 years ago
parent
commit
f7ee57d1dd
  1. 1
      cmd/get.go
  2. 18
      doc/bitbucket.go
  3. 18
      doc/github.go
  4. 18
      doc/google.go
  5. 18
      doc/oschina.go
  6. 58
      doc/utils.go

1
cmd/get.go

@ -212,6 +212,7 @@ func downloadPackages(nodes []*doc.Node) {
// Invalid import path.
doc.ColorLog("[WARN] Skipped invalid package path( %s => %s:%s )\n",
n.ImportPath, n.Type, n.Value)
failConut++
}
}
}

18
doc/bitbucket.go

@ -99,15 +99,19 @@ func getBitbucketDoc(client *http.Client, match map[string]string, installRepoPa
return nil, err
}
suf := "." + nod.Value
if len(suf) == 1 {
suf = ""
var installPath string
if nod.ImportPath == nod.DownloadURL {
suf := "." + nod.Value
if len(suf) == 1 {
suf = ""
}
projectPath := expand("bitbucket.org/{owner}/{repo}", match)
installPath = installRepoPath + "/" + projectPath + suf
nod.ImportPath = projectPath
} else {
installPath = installRepoPath + "/" + nod.ImportPath
}
projectPath := expand("bitbucket.org/{owner}/{repo}", match)
installPath := installRepoPath + "/" + projectPath + suf
nod.ImportPath = projectPath
// Remove old files.
os.RemoveAll(installPath + "/")
os.MkdirAll(installPath+"/", os.ModePerm)

18
doc/github.go

@ -75,15 +75,19 @@ func getGithubDoc(client *http.Client, match map[string]string, installRepoPath
shaName = strings.Replace(shaName, "-v", "-", 1)
}
suf := "." + nod.Value
if len(suf) == 1 {
suf = ""
var installPath string
if nod.ImportPath == nod.DownloadURL {
suf := "." + nod.Value
if len(suf) == 1 {
suf = ""
}
projectPath := expand("github.com/{owner}/{repo}", match)
installPath = installRepoPath + "/" + projectPath + suf
nod.ImportPath = projectPath
} else {
installPath = installRepoPath + "/" + nod.ImportPath
}
projectPath := expand("github.com/{owner}/{repo}", match)
installPath := installRepoPath + "/" + projectPath + suf
nod.ImportPath = projectPath
// Remove old files.
os.RemoveAll(installPath + "/")
os.MkdirAll(installPath+"/", os.ModePerm)

18
doc/google.go

@ -74,15 +74,19 @@ func getGoogleDoc(client *http.Client, match map[string]string, installRepoPath
return nil, err
}
suf := "." + nod.Value
if len(suf) == 1 {
suf = ""
var installPath string
if nod.ImportPath == nod.DownloadURL {
suf := "." + nod.Value
if len(suf) == 1 {
suf = ""
}
projectPath := expand("code.google.com/p/{repo}{dot}{subrepo}{dir}", match)
installPath = installRepoPath + "/" + projectPath + suf
nod.ImportPath = projectPath
} else {
installPath = installRepoPath + "/" + nod.ImportPath
}
projectPath := expand("code.google.com/p/{repo}{dot}{subrepo}{dir}", match)
installPath := installRepoPath + "/" + projectPath + suf
nod.ImportPath = projectPath
// Remove old files.
os.RemoveAll(installPath + "/")
os.MkdirAll(installPath+"/", os.ModePerm)

18
doc/oschina.go

@ -54,15 +54,19 @@ func getOSCDoc(client *http.Client, match map[string]string, installRepoPath str
return nil, errors.New("Fail to donwload OSChina repo -> " + err.Error())
}
suf := "." + nod.Value
if len(suf) == 1 {
suf = ""
var installPath string
if nod.ImportPath == nod.DownloadURL {
suf := "." + nod.Value
if len(suf) == 1 {
suf = ""
}
projectPath := expand("git.oschina.net/{owner}/{repo}", match)
installPath = installRepoPath + "/" + projectPath + suf
nod.ImportPath = projectPath
} else {
installPath = installRepoPath + "/" + nod.ImportPath
}
projectPath := expand("git.oschina.net/{owner}/{repo}", match)
installPath := installRepoPath + "/" + projectPath + suf
nod.ImportPath = projectPath
// Remove old files.
os.RemoveAll(installPath + "/")
os.MkdirAll(installPath+"/", os.ModePerm)

58
doc/utils.go

@ -21,6 +21,7 @@ import (
"regexp"
"runtime"
"strings"
"syscall"
)
// IsExist returns if a file or directory exists
@ -29,6 +30,7 @@ func IsExist(path string) bool {
return err == nil || os.IsExist(err)
}
// Non-Windows.
const (
Gray = uint8(iota + 90)
Red
@ -40,6 +42,26 @@ const (
EndColor = "\033[0m"
)
// Windows.
const (
WDefault = uintptr(iota)
WBlue
WGreen
WCyan
WRed
WPurple
WYellow
WGray
WSilver
WLightBlue
WLime
WLightCyan
WLightRed
WLightPurple
WLightYellow
WWhite
)
// ColorLog colors log and print to stdout.
// Log format: <level> <content [highlight][path]> [ error ].
// Level: TRAC -> blue; ERRO -> red; WARN -> Magenta; SUCC -> green; others -> default.
@ -74,6 +96,16 @@ func ColorLog(format string, a ...interface{}) {
log = strings.Replace(log, " #", EndColor, -1)
log = clog + log
} else {
// Level.
i := strings.Index(log, "]")
if log[0] == '[' && i > -1 {
fmt.Print("[")
printColorLevel(log[1:i])
fmt.Print("]")
}
log = log[i+1:]
}
fmt.Print(log)
@ -96,6 +128,32 @@ func getColorLevel(level string) string {
}
}
// printColorLevel prints color level prompt, this is only for Windows.
func printColorLevel(level string) {
cc := WDefault
level = strings.ToUpper(level)
switch level {
case "TRAC":
cc = WBlue
case "ERRO":
cc = WRed
case "WARN":
cc = WPurple
case "SUCC":
cc = WGreen
default:
cc = WWhite
}
kernel32 := syscall.NewLazyDLL("kernel32.dll")
proc := kernel32.NewProc("SetConsoleTextAttribute")
handle, _, _ := proc.Call(uintptr(syscall.Stdout), uintptr(cc))
fmt.Print(level)
handle, _, _ = proc.Call(uintptr(syscall.Stdout), uintptr(WSilver))
CloseHandle := kernel32.NewProc("CloseHandle")
CloseHandle.Call(handle)
}
// GetGOPATH returns all paths in GOPATH variable.
func GetGOPATH() []string {
gopath := os.Getenv("GOPATH")

Loading…
Cancel
Save