go tool vet -composites=false -methods=false -structtags=false . | go tool vet -composites=false -methods=false -structtags=false . | ||||
build-dev: $(GENERATED) govet | build-dev: $(GENERATED) govet | ||||
go install $(BUILD_FLAGS) -tags '$(TAGS)' | |||||
cp '$(GOPATH)/bin/gogs' . | |||||
build-dev-race: $(GENERATED) govet | |||||
go install $(BUILD_FLAGS) -race -tags '$(TAGS)' | go install $(BUILD_FLAGS) -race -tags '$(TAGS)' | ||||
cp '$(GOPATH)/bin/gogs' . | cp '$(GOPATH)/bin/gogs' . | ||||
![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true) | ![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true) | ||||
##### Current tip version: 0.9.54 (see [Releases](https://github.com/gogits/gogs/releases) for binary versions) | |||||
##### Current tip version: 0.9.55 (see [Releases](https://github.com/gogits/gogs/releases) for binary versions) | |||||
| Web | UI | Preview | | | Web | UI | Preview | | ||||
|:-------------:|:-------:|:-------:| | |:-------------:|:-------:|:-------:| |
m.Post("/content", repo.UpdateIssueContent) | m.Post("/content", repo.UpdateIssueContent) | ||||
}) | }) | ||||
}) | }) | ||||
m.Post("/comments/:id", repo.UpdateCommentContent) | |||||
m.Group("/comments/:id", func() { | |||||
m.Post("", repo.UpdateCommentContent) | |||||
m.Post("/delete", repo.DeleteComment) | |||||
}) | |||||
m.Group("/labels", func() { | m.Group("/labels", func() { | ||||
m.Post("/new", bindIgnErr(auth.CreateLabelForm{}), repo.NewLabel) | m.Post("/new", bindIgnErr(auth.CreateLabelForm{}), repo.NewLabel) | ||||
m.Post("/edit", bindIgnErr(auth.CreateLabelForm{}), repo.UpdateLabel) | m.Post("/edit", bindIgnErr(auth.CreateLabelForm{}), repo.UpdateLabel) |
issues.open_title = Open | issues.open_title = Open | ||||
issues.closed_title = Closed | issues.closed_title = Closed | ||||
issues.num_comments = %d comments | issues.num_comments = %d comments | ||||
issues.commented_at = `commented <a id="%[1]s" href="#%[1]s">%[2]s</a>` | |||||
issues.commented_at = `commented <a href="#%s">%s</a>` | |||||
issues.delete_comment_confirm = Are you sure you want to delete this comment? | |||||
issues.no_content = There is no content yet. | issues.no_content = There is no content yet. | ||||
issues.close_issue = Close | issues.close_issue = Close | ||||
issues.close_comment_issue = Comment and close | issues.close_comment_issue = Comment and close |
"github.com/gogits/gogs/modules/setting" | "github.com/gogits/gogs/modules/setting" | ||||
) | ) | ||||
const APP_VER = "0.9.54.0724" | |||||
const APP_VER = "0.9.55.0726" | |||||
func init() { | func init() { | ||||
runtime.GOMAXPROCS(runtime.NumCPU()) | runtime.GOMAXPROCS(runtime.NumCPU()) |
_, err := x.Id(c.ID).AllCols().Update(c) | _, err := x.Id(c.ID).AllCols().Update(c) | ||||
return err | return err | ||||
} | } | ||||
// DeleteCommentByID deletes a comment by given ID. | |||||
func DeleteCommentByID(id int64) error { | |||||
comment, err := GetCommentByID(id) | |||||
if err != nil { | |||||
return err | |||||
} | |||||
sess := x.NewSession() | |||||
defer sessionRelease(sess) | |||||
if err = sess.Begin(); err != nil { | |||||
return err | |||||
} | |||||
if _, err = sess.Id(comment.ID).Delete(new(Comment)); err != nil { | |||||
return err | |||||
} | |||||
if comment.Type == COMMENT_TYPE_COMMENT { | |||||
if _, err = sess.Exec("UPDATE `issue` SET num_comments = num_comments - 1 WHERE id = ?", comment.IssueID); err != nil { | |||||
return err | |||||
} | |||||
} | |||||
return sess.Commit() | |||||
} |
ctx.HTML(status, base.TplName(fmt.Sprintf("status/%d", status))) | ctx.HTML(status, base.TplName(fmt.Sprintf("status/%d", status))) | ||||
} | } | ||||
// HandleError use error check function to determine if server should | |||||
// response as client input error or server internal error. | |||||
// It responses with given status code for client error, | |||||
// or error context description for logging purpose of server error. | |||||
func (ctx *Context) HandleError(title string, errck func(error) bool, err error, status int) { | |||||
if errck(err) { | |||||
ctx.Error(status, err.Error()) | |||||
return | |||||
} | |||||
ctx.Handle(500, title, err) | |||||
} | |||||
func (ctx *Context) HandleText(status int, title string) { | func (ctx *Context) HandleText(status int, title string) { | ||||
if (status/100 == 4) || (status/100 == 5) { | if (status/100 == 4) || (status/100 == 5) { | ||||
log.Error(4, "%s", title) | log.Error(4, "%s", title) |
.repository.view.issue .comment-list .comment .actions .item { | .repository.view.issue .comment-list .comment .actions .item { | ||||
float: left; | float: left; | ||||
} | } | ||||
.repository.view.issue .comment-list .comment .actions a.item { | |||||
.repository.view.issue .comment-list .comment .actions .item.tag { | |||||
margin-right: 5px; | |||||
} | |||||
.repository.view.issue .comment-list .comment .actions .item.action { | |||||
margin-top: 6px; | margin-top: 6px; | ||||
margin-left: 10px; | margin-left: 10px; | ||||
} | } |
// Edit issue or comment content | // Edit issue or comment content | ||||
$('.edit-content').click(function () { | $('.edit-content').click(function () { | ||||
var $segment = $(this).parent().parent().next(); | |||||
var $segment = $(this).parent().parent().parent().next(); | |||||
var $edit_content_zone = $segment.find('.edit-content-zone'); | var $edit_content_zone = $segment.find('.edit-content-zone'); | ||||
var $render_content = $segment.find('.render-content'); | var $render_content = $segment.find('.render-content'); | ||||
var $raw_content = $segment.find('.raw-content'); | var $raw_content = $segment.find('.raw-content'); | ||||
return false; | return false; | ||||
}); | }); | ||||
// Delete comment | |||||
$('.delete-comment').click(function () { | |||||
var $this = $(this); | |||||
if (confirm($this.data('locale'))) { | |||||
$.post($this.data('url'), { | |||||
"_csrf": csrf | |||||
}).success(function() { | |||||
$('#' + $this.data('comment-id')).remove(); | |||||
}) | |||||
} | |||||
return false; | |||||
}); | |||||
// Change status | // Change status | ||||
var $status_btn = $('#status-button'); | var $status_btn = $('#status-button'); | ||||
$('#content').keyup(function () { | $('#content').keyup(function () { |
.actions { | .actions { | ||||
.item { | .item { | ||||
float: left; | float: left; | ||||
} | |||||
a.item { | |||||
margin-top: 6px; | |||||
margin-left: 10px; | |||||
&.tag { | |||||
margin-right: 5px; | |||||
} | |||||
&.action { | |||||
margin-top: 6px; | |||||
margin-left: 10px; | |||||
} | |||||
} | } | ||||
} | } | ||||
.content { | .content { |
func NewComment(ctx *context.Context, form auth.CreateCommentForm) { | func NewComment(ctx *context.Context, form auth.CreateCommentForm) { | ||||
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) | issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) | ||||
if err != nil { | if err != nil { | ||||
if models.IsErrIssueNotExist(err) { | |||||
ctx.Handle(404, "GetIssueByIndex", err) | |||||
} else { | |||||
ctx.Handle(500, "GetIssueByIndex", err) | |||||
} | |||||
ctx.HandleError("GetIssueByIndex", models.IsErrIssueNotExist, err, 404) | |||||
return | return | ||||
} | } | ||||
if issue.IsPull { | if issue.IsPull { | ||||
func UpdateCommentContent(ctx *context.Context) { | func UpdateCommentContent(ctx *context.Context) { | ||||
comment, err := models.GetCommentByID(ctx.ParamsInt64(":id")) | comment, err := models.GetCommentByID(ctx.ParamsInt64(":id")) | ||||
if err != nil { | if err != nil { | ||||
if models.IsErrCommentNotExist(err) { | |||||
ctx.Error(404, "GetCommentByID") | |||||
} else { | |||||
ctx.Handle(500, "GetCommentByID", err) | |||||
} | |||||
ctx.HandleError("GetCommentByID", models.IsErrCommentNotExist, err, 404) | |||||
return | return | ||||
} | } | ||||
}) | }) | ||||
return | return | ||||
} | } | ||||
if err := models.UpdateComment(comment); err != nil { | |||||
if err = models.UpdateComment(comment); err != nil { | |||||
ctx.Handle(500, "UpdateComment", err) | ctx.Handle(500, "UpdateComment", err) | ||||
return | return | ||||
} | } | ||||
}) | }) | ||||
} | } | ||||
func DeleteComment(ctx *context.Context) { | |||||
comment, err := models.GetCommentByID(ctx.ParamsInt64(":id")) | |||||
if err != nil { | |||||
ctx.HandleError("GetCommentByID", models.IsErrCommentNotExist, err, 404) | |||||
return | |||||
} | |||||
if !ctx.IsSigned || (ctx.User.ID != comment.PosterID && !ctx.Repo.IsAdmin()) { | |||||
ctx.Error(403) | |||||
return | |||||
} else if comment.Type != models.COMMENT_TYPE_COMMENT { | |||||
ctx.Error(204) | |||||
return | |||||
} | |||||
if err = models.DeleteCommentByID(comment.ID); err != nil { | |||||
ctx.Handle(500, "DeleteCommentByID", err) | |||||
return | |||||
} | |||||
ctx.Status(200) | |||||
} | |||||
func Labels(ctx *context.Context) { | func Labels(ctx *context.Context) { | ||||
ctx.Data["Title"] = ctx.Tr("repo.labels") | ctx.Data["Title"] = ctx.Tr("repo.labels") | ||||
ctx.Data["PageIsIssueList"] = true | ctx.Data["PageIsIssueList"] = true |
0.9.54.0724 | |||||
0.9.55.0726 |
<span class="text grey"><a {{if gt .Issue.Poster.ID 0}}href="{{.Issue.Poster.HomeLink}}"{{end}}>{{.Issue.Poster.Name}}</a> {{.i18n.Tr "repo.issues.commented_at" .Issue.HashTag $createdStr | Safe}}</span> | <span class="text grey"><a {{if gt .Issue.Poster.ID 0}}href="{{.Issue.Poster.HomeLink}}"{{end}}>{{.Issue.Poster.Name}}</a> {{.i18n.Tr "repo.issues.commented_at" .Issue.HashTag $createdStr | Safe}}</span> | ||||
<div class="ui right actions"> | <div class="ui right actions"> | ||||
{{if .IsIssueOwner}} | {{if .IsIssueOwner}} | ||||
<a class="edit-content item" href="#"><i class="octicon octicon-pencil"></i></a> | |||||
<div class="item action"> | |||||
<a class="edit-content" href="#"><i class="octicon octicon-pencil"></i></a> | |||||
</div> | |||||
{{end}} | {{end}} | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<!-- 0 = COMMENT, 1 = REOPEN, 2 = CLOSE, 3 = ISSUE_REF, 4 = COMMIT_REF, 5 = COMMENT_REF, 6 = PULL_REF --> | <!-- 0 = COMMENT, 1 = REOPEN, 2 = CLOSE, 3 = ISSUE_REF, 4 = COMMIT_REF, 5 = COMMENT_REF, 6 = PULL_REF --> | ||||
{{if eq .Type 0}} | {{if eq .Type 0}} | ||||
<div class="comment"> | |||||
<div class="comment" id="{{.HashTag}}"> | |||||
<a class="avatar" {{if gt .Poster.ID 0}}href="{{.Poster.HomeLink}}"{{end}}> | <a class="avatar" {{if gt .Poster.ID 0}}href="{{.Poster.HomeLink}}"{{end}}> | ||||
<img src="{{.Poster.AvatarLink}}"> | <img src="{{.Poster.AvatarLink}}"> | ||||
</a> | </a> | ||||
</div> | </div> | ||||
{{end}} | {{end}} | ||||
{{if or $.IsRepositoryAdmin (eq .Poster.ID $.SignedUserID)}} | {{if or $.IsRepositoryAdmin (eq .Poster.ID $.SignedUserID)}} | ||||
<a class="edit-content item" href="#"><i class="octicon octicon-pencil"></i></a> | |||||
<div class="item action"> | |||||
<a class="edit-content" href="#"><i class="octicon octicon-pencil"></i></a> | |||||
<a class="delete-comment" href="#" data-comment-id={{.HashTag}} data-url="{{$.RepoLink}}/comments/{{.ID}}/delete" data-locale="{{$.i18n.Tr "repo.issues.delete_comment_confirm"}}"><i class="octicon octicon-x"></i></a> | |||||
</div> | |||||
{{end}} | {{end}} | ||||
</div> | </div> | ||||
</div> | </div> |