mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-12-24 09:20:04 +01:00
Limit the number of characters for user completion and issue completioin (#2534)
This commit is contained in:
@@ -213,8 +213,10 @@ trait IndexControllerBase extends ControllerBase {
|
||||
}
|
||||
.map { t =>
|
||||
Map(
|
||||
"label" -> s"${avatar(t.userName, 16)}<b>@${StringUtil.escapeHtml(t.userName)}</b> ${StringUtil
|
||||
.escapeHtml(t.fullName)}",
|
||||
"label" -> s"${avatar(t.userName, 16)}<b>@${StringUtil.escapeHtml(
|
||||
StringUtil.cutTail(t.userName, 25, "...")
|
||||
)}</b> ${StringUtil
|
||||
.escapeHtml(StringUtil.cutTail(t.fullName, 25, "..."))}",
|
||||
"value" -> t.userName
|
||||
)
|
||||
}
|
||||
|
||||
@@ -430,7 +430,8 @@ trait IssuesControllerBase extends ControllerBase {
|
||||
Map(
|
||||
"label" -> s"""${if (t.isPullRequest) "<i class='octicon octicon-git-pull-request'></i>"
|
||||
else "<i class='octicon octicon-issue-opened'></i>"}<b> #${StringUtil
|
||||
.escapeHtml(t.issueId.toString)} ${StringUtil.escapeHtml(t.title)}</b>""",
|
||||
.escapeHtml(t.issueId.toString)} ${StringUtil
|
||||
.escapeHtml(StringUtil.cutTail(t.title, 50, "..."))}</b>""",
|
||||
"value" -> t.issueId.toString
|
||||
)
|
||||
}
|
||||
|
||||
@@ -182,4 +182,11 @@ object StringUtil {
|
||||
}
|
||||
}
|
||||
|
||||
def cutTail(txt: String, limit: Int, suffix: String = ""): String = {
|
||||
txt.length match {
|
||||
case x if x > limit => txt.substring(0, limit).concat(suffix)
|
||||
case _ => txt
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -186,13 +186,6 @@ object helpers extends AvatarImageProvider with LinkConverter with RequestCache
|
||||
def link(value: String, repository: RepositoryService.RepositoryInfo)(implicit context: Context): Html =
|
||||
Html(decorateHtml(convertRefsLinks(value, repository), repository))
|
||||
|
||||
def cut(value: String, length: Int): String =
|
||||
if (value.length > length) {
|
||||
value.substring(0, length) + "..."
|
||||
} else {
|
||||
value
|
||||
}
|
||||
|
||||
import scala.util.matching.Regex._
|
||||
implicit class RegexReplaceString(private val s: String) extends AnyVal {
|
||||
def replaceAll(pattern: String)(replacer: Match => String): String = {
|
||||
|
||||
Reference in New Issue
Block a user