aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--models/issue.go12
-rw-r--r--models/repo.go19
-rw-r--r--public/js/app.js6
-rw-r--r--templates/repo/issue/list.tmpl4
-rw-r--r--templates/repo/nav.tmpl4
5 files changed, 40 insertions, 5 deletions
diff --git a/models/issue.go b/models/issue.go
index baf710a5..c370af36 100644
--- a/models/issue.go
+++ b/models/issue.go
@@ -108,7 +108,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
diff --git a/public/js/app.js b/public/js/app.js
index 4c376ea0..88ddd471 100644
--- a/public/js/app.js
+++ b/public/js/app.js
@@ -406,8 +406,10 @@ function initRepository() {
// watching script
(function () {
var $watch = $('#repo-watching'),
- watchLink = $watch.data("watch"),
- unwatchLink = $watch.data("unwatch");
+ watchLink = $watch.attr("data-watch"),
+ // Use $.attr() to work around jQuery not finding $.data("unwatch") in Firefox,
+ // which has a method "unwatch" on `Object` that gets returned instead.
+ unwatchLink = $watch.attr("data-unwatch");
$watch.on('click', '.to-watch', function () {
if ($watch.hasClass("watching")) {
return false;
diff --git a/templates/repo/issue/list.tmpl b/templates/repo/issue/list.tmpl
index 0fae3eb6..ffbdcc83 100644
--- a/templates/repo/issue/list.tmpl
+++ b/templates/repo/issue/list.tmpl
@@ -26,6 +26,7 @@
<a class="del pull-right" href="#" data-id="{{.Id}}"><i class="fa fa-times-circle-o"></i></a>
</li>
{{end}}
+ {{if or .IsRepositoryOwner .IsAdmin}}
<li class="label-change-li" style="display: none">
<form id="label-change-form" action="{{$.RepoLink}}/issues/labels/edit" method="post">
{{.CsrfTokenHtml}}
@@ -41,7 +42,9 @@
</div>
</form>
</li>
+ {{end}}
</ul>
+ {{if or .IsRepositoryOwner .IsAdmin}}
<button class="btn btn-default btn-block label-button" id="label-manage-btn">Manage Labels</button>
<hr/>
<form id="label-add-form" action="{{$.RepoLink}}/issues/labels/new" method="post">
@@ -57,6 +60,7 @@
<button class="btn btn-default btn-sm">Create</button>
</div>
</form>
+ {{end}}
</div>
</div>
<div class="col-md-9">
diff --git a/templates/repo/nav.tmpl b/templates/repo/nav.tmpl
index ea7799b3..69f60ba4 100644
--- a/templates/repo/nav.tmpl
+++ b/templates/repo/nav.tmpl
@@ -3,7 +3,7 @@
<div class="row">
<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>
- <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 class="col-md-5 actions text-right clone-group-btn">
{{if not .IsBareRepo}}
@@ -31,6 +31,7 @@
</div>
</div>
</div>
+ {{if .IsSigned}}
<div class="btn-group {{if .IsRepositoryWatching}}watching{{else}}no-watching{{end}}" id="repo-watching" data-watch="/{{.Owner.Name}}/{{.Repository.Name}}/action/watch" data-unwatch="/{{.Owner.Name}}/{{.Repository.Name}}/action/unwatch">
{{if .IsRepositoryWatching}}
<button type="button" class="btn btn-default"><i class="fa fa-eye fa-lg fa-m"></i></button>
@@ -52,6 +53,7 @@
</div>
</div>
</div>
+ {{end}}
<!-- <div class="btn-group">
<button type="button" class="btn btn-default" data-toggle="tooltip" data-placement="top" title="Star"><i class="fa fa-star"></i>&nbsp;{{.Repository.NumStars}}</button>
</div> -->