summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorJustin Nuß <nuss.justin@gmail.com>2014-07-22 19:52:37 +0200
committerJustin Nuß <nuss.justin@gmail.com>2014-07-22 19:52:37 +0200
commite194cf3291df11ddf4d9235fe0d7e18322bbd0f3 (patch)
tree2713b2bf24742d5b7aaca7039f788d42161c735f /models
parent536f65b8ad700dc919295562dd72d5d4ea750506 (diff)
downloadgitea-e194cf3291df11ddf4d9235fe0d7e18322bbd0f3.tar.gz
gitea-e194cf3291df11ddf4d9235fe0d7e18322bbd0f3.zip
Fix issue #259. Allow links in the repository description
Diffstat (limited to 'models')
-rw-r--r--models/repo.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/models/repo.go b/models/repo.go
index fb7bbbd036..1cfa50f7b5 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -8,9 +8,11 @@ import (
"errors"
"fmt"
"io/ioutil"
+ "html/template"
"os"
"path"
"path/filepath"
+ "regexp"
"runtime"
"sort"
"strings"
@@ -46,6 +48,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 +151,10 @@ func (repo *Repository) GetOwner() (err error) {
return err
}
+func (repo *Repository) DescriptionHtml() template.HTML {
+ return template.HTML(DescriptionPattern.ReplaceAllString(repo.Description, `<a href="$0" target="_blank">$0</a>`))
+}
+
// 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 +1010,4 @@ func IsWatching(uid, rid int64) bool {
func ForkRepository(repoName string, uid int64) {
-}
+} \ No newline at end of file