aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorUnknown <joe2010xtmf@163.com>2014-04-14 01:57:25 -0400
committerUnknown <joe2010xtmf@163.com>2014-04-14 01:57:25 -0400
commitf644cefa865c04b440902695ba90114b224c640d (patch)
tree0046427683c47bbc0487d0d053ee643ffef902c8 /modules
parent190b83e05eb1ade979c0e17314ab892832d62e5b (diff)
downloadgitea-f644cefa865c04b440902695ba90114b224c640d.tar.gz
gitea-f644cefa865c04b440902695ba90114b224c640d.zip
Finish release
Diffstat (limited to 'modules')
-rw-r--r--modules/auth/release.go50
-rw-r--r--modules/base/markdown.go4
2 files changed, 54 insertions, 0 deletions
diff --git a/modules/auth/release.go b/modules/auth/release.go
new file mode 100644
index 0000000000..a29028e0e4
--- /dev/null
+++ b/modules/auth/release.go
@@ -0,0 +1,50 @@
+// Copyright 2014 The Gogs Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package auth
+
+import (
+ "net/http"
+ "reflect"
+
+ "github.com/go-martini/martini"
+
+ "github.com/gogits/gogs/modules/base"
+ "github.com/gogits/gogs/modules/log"
+)
+
+type NewReleaseForm struct {
+ TagName string `form:"tag_name" binding:"Required"`
+ Title string `form:"title" binding:"Required"`
+ Content string `form:"content" binding:"Required"`
+ Prerelease bool `form:"prerelease"`
+}
+
+func (f *NewReleaseForm) Name(field string) string {
+ names := map[string]string{
+ "TagName": "Tag name",
+ "Title": "Release title",
+ "Content": "Release content",
+ }
+ return names[field]
+}
+
+func (f *NewReleaseForm) Validate(errors *base.BindingErrors, req *http.Request, context martini.Context) {
+ if req.Method == "GET" || errors.Count() == 0 {
+ return
+ }
+
+ data := context.Get(reflect.TypeOf(base.TmplData{})).Interface().(base.TmplData)
+ data["HasError"] = true
+ AssignForm(f, data)
+
+ if len(errors.Overall) > 0 {
+ for _, err := range errors.Overall {
+ log.Error("NewReleaseForm.Validate: %v", err)
+ }
+ return
+ }
+
+ validate(errors, data, f)
+}
diff --git a/modules/base/markdown.go b/modules/base/markdown.go
index cc1807750d..95b4b212fd 100644
--- a/modules/base/markdown.go
+++ b/modules/base/markdown.go
@@ -166,3 +166,7 @@ func RenderMarkdown(rawBytes []byte, urlPrefix string) []byte {
// fmt.Println(string(body))
return body
}
+
+func RenderMarkdownString(raw, urlPrefix string) string {
+ return string(RenderMarkdown([]byte(raw), urlPrefix))
+}