Bump Markedj to 1.0.16 (#2292)

This commit is contained in:
Naoki Takezoe
2019-03-31 22:37:03 +09:00
committed by GitHub
parent f648d60abb
commit 8ad0b25023
5 changed files with 46 additions and 26 deletions

View File

@@ -41,7 +41,7 @@ libraryDependencies ++= Seq(
"org.json4s" %% "json4s-jackson" % "3.5.2",
"commons-io" % "commons-io" % "2.6",
"io.github.gitbucket" % "solidbase" % "1.0.3",
"io.github.gitbucket" % "markedj" % "1.0.15",
"io.github.gitbucket" % "markedj" % "1.0.16",
"org.apache.commons" % "commons-compress" % "1.18",
"org.apache.commons" % "commons-email" % "1.5",
"org.apache.httpcomponents" % "httpclient" % "4.5.6",

View File

@@ -169,24 +169,33 @@ object Markdown {
private def fixUrl(url: String, branch: String, isImage: Boolean = false): String = {
lazy val urlWithRawParam: String = url + (if (isImage && !url.endsWith("?raw=true")) "?raw=true" else "")
if (url.startsWith("http://") || url.startsWith("https://") || url.startsWith("mailto:") || url.startsWith("/")) {
if (url.startsWith("http://") || url.startsWith("https://") || url.startsWith("mailto:")) {
url
} else if (url.startsWith("/")) {
context.baseUrl + url
} else if (url.startsWith("#")) {
("#" + generateAnchorName(url.substring(1)))
} else if (!enableWikiLink) {
} else {
// Relative path
if (!enableWikiLink) {
if (context.currentPath.contains("/blob/")) {
urlWithRawParam
val paths = context.currentPath.split("/").dropRight(1)
val path = if (paths.length > 3) paths.drop(4).mkString("/") else branch
repository.httpUrl.replaceFirst("/git/", "/").stripSuffix(".git") + "/blob/" + path + "/" + urlWithRawParam
} else if (context.currentPath.contains("/tree/")) {
val paths = context.currentPath.split("/")
val path = if (paths.length > 3) paths.drop(4).mkString("/") else branch
repository.httpUrl.replaceFirst("/git/", "/").stripSuffix(".git") + "/blob/" + path + "/" + urlWithRawParam
} else {
repository.httpUrl.replaceFirst("/git/", "/").stripSuffix(".git") + "/blob/" + branch + "/" + urlWithRawParam
repository.httpUrl
.replaceFirst("/git/", "/")
.stripSuffix(".git") + "/blob/" + branch + "/" + urlWithRawParam
}
} else {
repository.httpUrl.replaceFirst("/git/", "/").stripSuffix(".git") + "/wiki/_blob/" + url
}
}
}
}

View File

@@ -218,14 +218,18 @@ object helpers extends AvatarImageProvider with LinkConverter with RequestCache
.replaceAll(
"\\[branch:([^\\s]+?)/([^\\s]+?)#([^\\s]+?)\\]",
(m: Match) =>
s"""<a href="${context.path}/${m.group(1)}/${m.group(2)}/tree/${encodeRefName(m.group(3))}">${m
.group(3)}</a>"""
s"""<a href="${context.path}/${m.group(1)}/${m.group(2)}/tree/${encodeRefName(m.group(3))}">${StringUtil
.escapeHtml(
m.group(3)
)}</a>"""
)
.replaceAll(
"\\[tag:([^\\s]+?)/([^\\s]+?)#([^\\s]+?)\\]",
(m: Match) =>
s"""<a href="${context.path}/${m.group(1)}/${m.group(2)}/tree/${encodeRefName(m.group(3))}">${m
.group(3)}</a>"""
s"""<a href="${context.path}/${m.group(1)}/${m.group(2)}/tree/${encodeRefName(m.group(3))}">${StringUtil
.escapeHtml(
m.group(3)
)}</a>"""
)
.replaceAll("\\[user:([^\\s]+?)\\]", (m: Match) => user(m.group(1)).body)
.replaceAll(
@@ -237,8 +241,10 @@ object helpers extends AvatarImageProvider with LinkConverter with RequestCache
.replaceAll(
"\\[release:([^\\s]+?)/([^\\s]+?)/([^\\s]+?):(.+)\\]",
(m: Match) =>
s"""<a href="${context.path}/${m.group(1)}/${m.group(2)}/releases/${encodeRefName(m.group(3))}">${m
.group(4)}</a>"""
s"""<a href="${context.path}/${m.group(1)}/${m.group(2)}/releases/${encodeRefName(m.group(3))}">${StringUtil
.escapeHtml(
m.group(4)
)}</a>"""
)
)

View File

@@ -12,21 +12,26 @@
</div>
</div>
<div style="padding-left: 10px; padding-right: 10px;">
@account.description.map{ description =>
@account.description.map { description =>
<p style="color: #999">@description</p>
}
@if(account.url.isDefined){
@account.url.map { url =>
<p style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
<i class="octicon octicon-home"></i> <a href="@account.url">@account.url</a>
<i class="octicon octicon-home"></i>
@if(url.startsWith("http://") || url.startsWith("https://")){
<a href="@url">@url</a>
} else {
<span style="color: #999">@url</span>
}
</p>
}
@if(context.settings.showMailAddress){
<p style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
<i class="octicon octicon-mail"></i> <a href="mailto: @account.mailAddress">@account.mailAddress</a>
<i class="octicon octicon-mail"></i> <a href="mailto:@account.mailAddress">@account.mailAddress</a>
</p>
@extraMailAddresses.map{ mail =>
@extraMailAddresses.map { mail =>
<p style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
<i class="octicon octicon-mail"></i> <a href="mailto: @mail">@mail</a>
<i class="octicon octicon-mail"></i> <a href="mailto:@mail">@mail</a>
</p>
}
}

View File

@@ -154,7 +154,7 @@ tasks
)(context)
assert(
html == """<p><a href="CHANGELOG.md">ChangeLog</a></p>"""
html == """<p><a href="http://localhost:8080/user/repo/blob/master/sub/dir/CHANGELOG.md">ChangeLog</a></p>"""
)
}
}