mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-13 21:31:15 +01:00
Fix issue #259. Allow links in the repository description
This commit is contained in:
parent
536f65b8ad
commit
e194cf3291
2 changed files with 12 additions and 2 deletions
|
@ -8,9 +8,11 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"html/template"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -46,6 +48,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 +151,10 @@ func (repo *Repository) GetOwner() (err error) {
|
||||||
return err
|
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.
|
// 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}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-7">
|
<div class="col-md-7">
|
||||||
<h3 class="name"><i class="fa fa-book fa-lg"></i><a href="{{.Owner.HomeLink}}">{{.Owner.Name}}</a> / <a href="/{{.Owner.Name}}/{{.Repository.Name}}">{{.Repository.Name}}</a> {{if .Repository.IsPrivate}}<span class="label label-default">Private</span>{{else if .Repository.IsMirror}}<span class="label label-default">Mirror</span>{{end}}</h3>
|
<h3 class="name"><i class="fa fa-book fa-lg"></i><a href="{{.Owner.HomeLink}}">{{.Owner.Name}}</a> / <a href="/{{.Owner.Name}}/{{.Repository.Name}}">{{.Repository.Name}}</a> {{if .Repository.IsPrivate}}<span class="label label-default">Private</span>{{else if .Repository.IsMirror}}<span class="label label-default">Mirror</span>{{end}}</h3>
|
||||||
<p class="desc">{{.Repository.Description}}{{if .Repository.Website}} <a href="{{.Repository.Website}}">{{.Repository.Website}}</a>{{end}}</p>
|
<p class="desc">{{.Repository.DescriptionHtml}}{{if .Repository.Website}} <a href="{{.Repository.Website}}">{{.Repository.Website}}</a>{{end}}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-5 actions text-right clone-group-btn">
|
<div class="col-md-5 actions text-right clone-group-btn">
|
||||||
{{if not .IsBareRepo}}
|
{{if not .IsBareRepo}}
|
||||||
|
|
Loading…
Reference in a new issue