From 5c2da610a2cfd3fa9666d20739e054c3588b4d05 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 13 Apr 2014 01:57:42 -0400 Subject: Move binding as subrepo --- modules/base/base.go | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'modules/base/base.go') diff --git a/modules/base/base.go b/modules/base/base.go index 7c08dcc5..84cf41c8 100644 --- a/modules/base/base.go +++ b/modules/base/base.go @@ -8,3 +8,49 @@ type ( // Type TmplData represents data in the templates. TmplData map[string]interface{} ) + +// __________.__ .___.__ +// \______ \__| ____ __| _/|__| ____ ____ +// | | _/ |/ \ / __ | | |/ \ / ___\ +// | | \ | | \/ /_/ | | | | \/ /_/ > +// |______ /__|___| /\____ | |__|___| /\___ / +// \/ \/ \/ \//_____/ + +// Errors represents the contract of the response body when the +// binding step fails before getting to the application. +type BindingErrors struct { + Overall map[string]string `json:"overall"` + Fields map[string]string `json:"fields"` +} + +// Total errors is the sum of errors with the request overall +// and errors on individual fields. +func (err BindingErrors) Count() int { + return len(err.Overall) + len(err.Fields) +} + +func (this *BindingErrors) Combine(other BindingErrors) { + for key, val := range other.Fields { + if _, exists := this.Fields[key]; !exists { + this.Fields[key] = val + } + } + for key, val := range other.Overall { + if _, exists := this.Overall[key]; !exists { + this.Overall[key] = val + } + } +} + +const ( + BindingRequireError string = "Required" + BindingAlphaDashError string = "AlphaDash" + BindingMinSizeError string = "MinSize" + BindingMaxSizeError string = "MaxSize" + BindingEmailError string = "Email" + BindingUrlError string = "Url" + BindingDeserializationError string = "DeserializationError" + BindingIntegerTypeError string = "IntegerTypeError" + BindingBooleanTypeError string = "BooleanTypeError" + BindingFloatTypeError string = "FloatTypeError" +) -- cgit v1.2.3 From ea74be2f2eb2356666c39448019956f9fe1c1f99 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 13 Apr 2014 04:27:29 -0400 Subject: go get --- modules/base/base.go | 2 ++ modules/base/template.go | 12 ++++++++++++ routers/dashboard.go | 5 +++++ routers/repo/repo.go | 4 ++++ templates/base/head.tmpl | 2 +- 5 files changed, 24 insertions(+), 1 deletion(-) (limited to 'modules/base/base.go') diff --git a/modules/base/base.go b/modules/base/base.go index 84cf41c8..3e80a436 100644 --- a/modules/base/base.go +++ b/modules/base/base.go @@ -54,3 +54,5 @@ const ( BindingBooleanTypeError string = "BooleanTypeError" BindingFloatTypeError string = "FloatTypeError" ) + +var GoGetMetas = make(map[string]bool) diff --git a/modules/base/template.go b/modules/base/template.go index 62414979..863bd89e 100644 --- a/modules/base/template.go +++ b/modules/base/template.go @@ -197,3 +197,15 @@ func DiffLineTypeToStr(diffType int) string { } return "same" } + +const ( + TPL_GO_GET_META = `` +) + +func GetGoGetMetaList() []byte { + buf := bytes.NewBuffer([]byte("")) + for meta := range GoGetMetas { + buf.WriteString(fmt.Sprintf(TPL_GO_GET_META, Domain, meta)) + } + return buf.Bytes() +} diff --git a/routers/dashboard.go b/routers/dashboard.go index 2c81cf23..12635412 100644 --- a/routers/dashboard.go +++ b/routers/dashboard.go @@ -11,6 +11,11 @@ import ( ) func Home(ctx *middleware.Context) { + if ctx.Query("go-get") == "1" { + ctx.Write(base.GetGoGetMetaList()) + return + } + if ctx.IsSigned { user.Dashboard(ctx) return diff --git a/routers/repo/repo.go b/routers/repo/repo.go index dda26899..a7088d55 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -107,6 +107,10 @@ func MigratePost(ctx *middleware.Context, form auth.MigrateRepoForm) { } func Single(ctx *middleware.Context, params martini.Params) { + if ctx.Query("go-get") == "1" { + base.GoGetMetas[strings.TrimSuffix(ctx.Repo.CloneLink.HTTPS, ".git")] = true + } + branchName := ctx.Repo.BranchName userName := ctx.Repo.Owner.Name repoName := ctx.Repo.Repository.Name diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index 441fd542..1d63b466 100644 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -9,7 +9,7 @@ - + {{if IsProdMode}} -- cgit v1.2.3