mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-08 14:35:52 +01:00
Show issue/PR title as a tooltip (#2532)
* Show issue/PR title as a tooltip * Enable title for issue/PR on activities
This commit is contained in:
@@ -54,12 +54,14 @@ trait LinkConverter { self: RequestCache =>
|
|||||||
.replaceBy(("(?<=(^|\\W))([a-zA-Z0-9\\-_]+)/([a-zA-Z0-9\\-_\\.]+)" + issueIdPrefix + "([0-9]+)(?=(\\W|$))").r) {
|
.replaceBy(("(?<=(^|\\W))([a-zA-Z0-9\\-_]+)/([a-zA-Z0-9\\-_\\.]+)" + issueIdPrefix + "([0-9]+)(?=(\\W|$))").r) {
|
||||||
m =>
|
m =>
|
||||||
getIssueFromCache(m.group(2), m.group(3), m.group(4)) match {
|
getIssueFromCache(m.group(2), m.group(3), m.group(4)) match {
|
||||||
case Some(issue) if (issue.isPullRequest) =>
|
case Some(pull) if (pull.isPullRequest) =>
|
||||||
Some(s"""<a href="${context.path}/${m.group(2)}/${m.group(3)}/pull/${m.group(4)}">${m.group(2)}/${m.group(
|
Some(s"""<a href="${context.path}/${m.group(2)}/${m.group(3)}/pull/${m
|
||||||
|
.group(4)}" title="${pull.title}">${m.group(2)}/${m.group(
|
||||||
3
|
3
|
||||||
)}#${m.group(4)}</a>""")
|
)}#${m.group(4)}</a>""")
|
||||||
case Some(_) =>
|
case Some(issue) =>
|
||||||
Some(s"""<a href="${context.path}/${m.group(2)}/${m.group(3)}/issues/${m.group(4)}">${m.group(2)}/${m
|
Some(s"""<a href="${context.path}/${m.group(2)}/${m.group(3)}/issues/${m
|
||||||
|
.group(4)}" title="${issue.title}">${m.group(2)}/${m
|
||||||
.group(3)}#${m.group(4)}</a>""")
|
.group(3)}#${m.group(4)}</a>""")
|
||||||
case None =>
|
case None =>
|
||||||
Some(s"""${m.group(2)}/${m.group(3)}#${m.group(4)}""")
|
Some(s"""${m.group(2)}/${m.group(3)}#${m.group(4)}""")
|
||||||
@@ -93,11 +95,13 @@ trait LinkConverter { self: RequestCache =>
|
|||||||
.replaceBy(("(?<=(^|\\W))(GH-|(?<!&)" + issueIdPrefix + ")([0-9]+)(?=(\\W|$))").r) { m =>
|
.replaceBy(("(?<=(^|\\W))(GH-|(?<!&)" + issueIdPrefix + ")([0-9]+)(?=(\\W|$))").r) { m =>
|
||||||
val prefix = if (m.group(2) == "issue:") "#" else m.group(2)
|
val prefix = if (m.group(2) == "issue:") "#" else m.group(2)
|
||||||
getIssueFromCache(repository.owner, repository.name, m.group(3)) match {
|
getIssueFromCache(repository.owner, repository.name, m.group(3)) match {
|
||||||
case Some(issue) if (issue.isPullRequest) =>
|
case Some(pull) if (pull.isPullRequest) =>
|
||||||
Some(s"""<a href="${context.path}/${repository.owner}/${repository.name}/pull/${m.group(3)}">${prefix}${m
|
Some(s"""<a href="${context.path}/${repository.owner}/${repository.name}/pull/${m
|
||||||
|
.group(3)}" title="${pull.title}">${prefix}${m
|
||||||
.group(3)}</a>""")
|
.group(3)}</a>""")
|
||||||
case Some(_) =>
|
case Some(issue) =>
|
||||||
Some(s"""<a href="${context.path}/${repository.owner}/${repository.name}/issues/${m.group(3)}">${prefix}${m
|
Some(s"""<a href="${context.path}/${repository.owner}/${repository.name}/issues/${m
|
||||||
|
.group(3)}" title="${issue.title}">${prefix}${m
|
||||||
.group(3)}</a>""")
|
.group(3)}</a>""")
|
||||||
case None =>
|
case None =>
|
||||||
Some(s"""${m.group(2)}${m.group(3)}""")
|
Some(s"""${m.group(2)}${m.group(3)}""")
|
||||||
|
|||||||
@@ -208,15 +208,17 @@ object helpers extends AvatarImageProvider with LinkConverter with RequestCache
|
|||||||
Html(
|
Html(
|
||||||
message
|
message
|
||||||
.replaceAll("\\[issue:([^\\s]+?)/([^\\s]+?)#((\\d+))\\]"){ m =>
|
.replaceAll("\\[issue:([^\\s]+?)/([^\\s]+?)#((\\d+))\\]"){ m =>
|
||||||
if (getRepositoryInfoFromCache(m.group(1), m.group(2)).isDefined) {
|
val issue = getIssueFromCache(m.group(1), m.group(2), m.group(3))
|
||||||
s"""<a href="${context.path}/${m.group(1)}/${m.group(2)}/issues/${m.group(3)}">${m.group(1)}/${m.group(2)}#${m.group(3)}</a>"""
|
if (issue.isDefined) {
|
||||||
|
s"""<a href="${context.path}/${m.group(1)}/${m.group(2)}/issues/${m.group(3)}" title="${issue.get.title}">${m.group(1)}/${m.group(2)}#${m.group(3)}</a>"""
|
||||||
} else {
|
} else {
|
||||||
s"${m.group(1)}/${m.group(2)}#${m.group(3)}"
|
s"${m.group(1)}/${m.group(2)}#${m.group(3)}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.replaceAll("\\[pullreq:([^\\s]+?)/([^\\s]+?)#((\\d+))\\]"){ m =>
|
.replaceAll("\\[pullreq:([^\\s]+?)/([^\\s]+?)#((\\d+))\\]"){ m =>
|
||||||
if (getRepositoryInfoFromCache(m.group(1), m.group(2)).isDefined) {
|
val pullreq = getIssueFromCache(m.group(1), m.group(2), m.group(3))
|
||||||
s"""<a href="${context.path}/${m.group(1)}/${m.group(2)}/pull/${m.group(3)}">${m.group(1)}/${m.group(2)}#${m.group(3)}</a>"""
|
if (pullreq.isDefined) {
|
||||||
|
s"""<a href="${context.path}/${m.group(1)}/${m.group(2)}/pull/${m.group(3)}" title="${pullreq.get.title}">${m.group(1)}/${m.group(2)}#${m.group(3)}</a>"""
|
||||||
} else {
|
} else {
|
||||||
s"${m.group(1)}/${m.group(2)}#${m.group(3)}"
|
s"${m.group(1)}/${m.group(2)}#${m.group(3)}"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user