diff options
author | guillep2k <18600385+guillep2k@users.noreply.github.com> | 2019-11-18 10:13:07 -0300 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2019-11-18 15:13:07 +0200 |
commit | b15f26b1cf3dc976ae400d4a3c73ec3bd4a50bc6 (patch) | |
tree | 14e4b0e743605f25da792c96c6deb2d5e8200155 /modules | |
parent | 08ae6bb7edb9582c38edb8a0dba1b1be10fb00fc (diff) | |
download | gitea-b15f26b1cf3dc976ae400d4a3c73ec3bd4a50bc6.tar.gz gitea-b15f26b1cf3dc976ae400d4a3c73ec3bd4a50bc6.zip |
Close/reopen issues by keywords in titles and comments (#8866)
* Add close/reopen from comment functionality
* Fix comment
* Rewrite closing/reopening template
* Check xref permissions, move action to services/pull
* Fix RefIsPull field
* Add xref tests
* Fix xref unique filter
* Only highlight keywords for actionable xrefs
* Fix xref neuter filter
* Fix check return status
* Restart CI
Diffstat (limited to 'modules')
-rw-r--r-- | modules/markup/html.go | 12 | ||||
-rw-r--r-- | modules/references/references.go | 5 |
2 files changed, 15 insertions, 2 deletions
diff --git a/modules/markup/html.go b/modules/markup/html.go index 1ff7a41cbb..924d0089a5 100644 --- a/modules/markup/html.go +++ b/modules/markup/html.go @@ -659,8 +659,16 @@ func issueIndexPatternProcessor(ctx *postProcessCtx, node *html.Node) { return } - // Decorate action keywords - keyword := createKeyword(node.Data[ref.ActionLocation.Start:ref.ActionLocation.End]) + // Decorate action keywords if actionable + var keyword *html.Node + if references.IsXrefActionable(ref.Action) { + keyword = createKeyword(node.Data[ref.ActionLocation.Start:ref.ActionLocation.End]) + } else { + keyword = &html.Node{ + Type: html.TextNode, + Data: node.Data[ref.ActionLocation.Start:ref.ActionLocation.End], + } + } spaces := &html.Node{ Type: html.TextNode, Data: node.Data[ref.ActionLocation.End:ref.RefLocation.Start], diff --git a/modules/references/references.go b/modules/references/references.go index af0fe1aa0d..17e9ec2c91 100644 --- a/modules/references/references.go +++ b/modules/references/references.go @@ -350,3 +350,8 @@ func findActionKeywords(content []byte, start int) (XRefAction, *RefSpan) { } return XRefActionNone, nil } + +// IsXrefActionable returns true if the xref action is actionable (i.e. produces a result when resolved) +func IsXrefActionable(a XRefAction) bool { + return a == XRefActionCloses || a == XRefActionReopens +} |