|
|
@ -8,9 +8,12 @@ import ( |
|
|
|
"errors" |
|
|
|
"errors" |
|
|
|
"fmt" |
|
|
|
"fmt" |
|
|
|
"io/ioutil" |
|
|
|
"io/ioutil" |
|
|
|
|
|
|
|
"html" |
|
|
|
|
|
|
|
"html/template" |
|
|
|
"os" |
|
|
|
"os" |
|
|
|
"path" |
|
|
|
"path" |
|
|
|
"path/filepath" |
|
|
|
"path/filepath" |
|
|
|
|
|
|
|
"regexp" |
|
|
|
"runtime" |
|
|
|
"runtime" |
|
|
|
"sort" |
|
|
|
"sort" |
|
|
|
"strings" |
|
|
|
"strings" |
|
|
@ -46,6 +49,10 @@ var ( |
|
|
|
LanguageIgns, Licenses []string |
|
|
|
LanguageIgns, Licenses []string |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var ( |
|
|
|
|
|
|
|
DescriptionPattern = regexp.MustCompile(`https?://\S+`) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
// getAssetList returns corresponding asset list in 'conf'.
|
|
|
|
// getAssetList returns corresponding asset list in 'conf'.
|
|
|
|
func getAssetList(prefix string) []string { |
|
|
|
func getAssetList(prefix string) []string { |
|
|
|
assets := make([]string, 0, 15) |
|
|
|
assets := make([]string, 0, 15) |
|
|
@ -145,6 +152,16 @@ func (repo *Repository) GetOwner() (err error) { |
|
|
|
return err |
|
|
|
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.
|
|
|
|
// IsRepositoryExist returns true if the repository with given name under user has already existed.
|
|
|
|
func IsRepositoryExist(u *User, repoName string) (bool, error) { |
|
|
|
func IsRepositoryExist(u *User, repoName string) (bool, error) { |
|
|
|
repo := Repository{OwnerId: u.Id} |
|
|
|
repo := Repository{OwnerId: u.Id} |
|
|
@ -1000,4 +1017,4 @@ func IsWatching(uid, rid int64) bool { |
|
|
|
|
|
|
|
|
|
|
|
func ForkRepository(repoName string, uid int64) { |
|
|
|
func ForkRepository(repoName string, uid int64) { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |