aboutsummaryrefslogtreecommitdiff
path: root/models
diff options
context:
space:
mode:
Diffstat (limited to 'models')
-rw-r--r--models/issue.go12
-rw-r--r--models/repo.go19
2 files changed, 29 insertions, 2 deletions
diff --git a/models/issue.go b/models/issue.go
index 8b2d57cd..62538372 100644
--- a/models/issue.go
+++ b/models/issue.go
@@ -109,7 +109,17 @@ func NewIssue(issue *Issue) (err error) {
sess.Rollback()
return err
}
- return sess.Commit()
+
+ if err = sess.Commit(); err != nil {
+ return err
+ }
+
+ if issue.MilestoneId > 0 {
+ // FIXES(280): Update milestone counter.
+ return ChangeMilestoneAssign(0, issue.MilestoneId, issue)
+ }
+
+ return
}
// GetIssueByIndex returns issue by given index in repository.
diff --git a/models/repo.go b/models/repo.go
index fb7bbbd0..845c1b75 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -8,9 +8,12 @@ import (
"errors"
"fmt"
"io/ioutil"
+ "html"
+ "html/template"
"os"
"path"
"path/filepath"
+ "regexp"
"runtime"
"sort"
"strings"
@@ -46,6 +49,10 @@ var (
LanguageIgns, Licenses []string
)
+var (
+ DescriptionPattern = regexp.MustCompile(`https?://\S+`)
+)
+
// getAssetList returns corresponding asset list in 'conf'.
func getAssetList(prefix string) []string {
assets := make([]string, 0, 15)
@@ -145,6 +152,16 @@ func (repo *Repository) GetOwner() (err error) {
return err
}
+func (repo *Repository) DescriptionHtml() template.HTML {
+ sanitize := func(s string) string {
+ // TODO(nuss-justin): Improve sanitization. Strip all tags?
+ ss := html.EscapeString(s)
+
+ return fmt.Sprintf(`<a href="%s" target="_blank">%s</a>`, ss, ss)
+ }
+ return template.HTML(DescriptionPattern.ReplaceAllStringFunc(repo.Description, sanitize))
+}
+
// IsRepositoryExist returns true if the repository with given name under user has already existed.
func IsRepositoryExist(u *User, repoName string) (bool, error) {
repo := Repository{OwnerId: u.Id}
@@ -1000,4 +1017,4 @@ func IsWatching(uid, rid int64) bool {
func ForkRepository(repoName string, uid int64) {
-}
+} \ No newline at end of file