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) {
|
||||
m =>
|
||||
getIssueFromCache(m.group(2), m.group(3), m.group(4)) match {
|
||||
case Some(issue) if (issue.isPullRequest) =>
|
||||
Some(s"""<a href="${context.path}/${m.group(2)}/${m.group(3)}/pull/${m.group(4)}">${m.group(2)}/${m.group(
|
||||
case Some(pull) if (pull.isPullRequest) =>
|
||||
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
|
||||
)}#${m.group(4)}</a>""")
|
||||
case Some(_) =>
|
||||
Some(s"""<a href="${context.path}/${m.group(2)}/${m.group(3)}/issues/${m.group(4)}">${m.group(2)}/${m
|
||||
case Some(issue) =>
|
||||
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>""")
|
||||
case None =>
|
||||
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 =>
|
||||
val prefix = if (m.group(2) == "issue:") "#" else m.group(2)
|
||||
getIssueFromCache(repository.owner, repository.name, m.group(3)) match {
|
||||
case Some(issue) if (issue.isPullRequest) =>
|
||||
Some(s"""<a href="${context.path}/${repository.owner}/${repository.name}/pull/${m.group(3)}">${prefix}${m
|
||||
case Some(pull) if (pull.isPullRequest) =>
|
||||
Some(s"""<a href="${context.path}/${repository.owner}/${repository.name}/pull/${m
|
||||
.group(3)}" title="${pull.title}">${prefix}${m
|
||||
.group(3)}</a>""")
|
||||
case Some(_) =>
|
||||
Some(s"""<a href="${context.path}/${repository.owner}/${repository.name}/issues/${m.group(3)}">${prefix}${m
|
||||
case Some(issue) =>
|
||||
Some(s"""<a href="${context.path}/${repository.owner}/${repository.name}/issues/${m
|
||||
.group(3)}" title="${issue.title}">${prefix}${m
|
||||
.group(3)}</a>""")
|
||||
case None =>
|
||||
Some(s"""${m.group(2)}${m.group(3)}""")
|
||||
|
||||
@@ -208,15 +208,17 @@ object helpers extends AvatarImageProvider with LinkConverter with RequestCache
|
||||
Html(
|
||||
message
|
||||
.replaceAll("\\[issue:([^\\s]+?)/([^\\s]+?)#((\\d+))\\]"){ m =>
|
||||
if (getRepositoryInfoFromCache(m.group(1), m.group(2)).isDefined) {
|
||||
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>"""
|
||||
val issue = getIssueFromCache(m.group(1), m.group(2), m.group(3))
|
||||
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 {
|
||||
s"${m.group(1)}/${m.group(2)}#${m.group(3)}"
|
||||
}
|
||||
}
|
||||
.replaceAll("\\[pullreq:([^\\s]+?)/([^\\s]+?)#((\\d+))\\]"){ m =>
|
||||
if (getRepositoryInfoFromCache(m.group(1), m.group(2)).isDefined) {
|
||||
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>"""
|
||||
val pullreq = getIssueFromCache(m.group(1), m.group(2), m.group(3))
|
||||
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 {
|
||||
s"${m.group(1)}/${m.group(2)}#${m.group(3)}"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user