mirror of
				https://codeberg.org/forgejo/forgejo.git
				synced 2025-10-31 14:31:02 +00: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" | ||||
| 	"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) { | ||||
| 
 | ||||
| } | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue