mirror of
https://github.com/gitbucket/gitbucket.git
synced 2026-01-30 03:09:22 +01:00
Check existence of Wiki page for Wiki links (#3907)
This commit is contained in:
committed by
GitHub
parent
3b9b261878
commit
fbcf962630
@@ -9,6 +9,7 @@ import gitbucket.core.service.{RepositoryService, RequestCache}
|
||||
import gitbucket.core.util.StringUtil
|
||||
import io.github.gitbucket.markedj._
|
||||
import io.github.gitbucket.markedj.Utils._
|
||||
import gitbucket.core.service.WikiService
|
||||
|
||||
object Markdown {
|
||||
|
||||
@@ -75,7 +76,8 @@ object Markdown {
|
||||
)(implicit val context: Context)
|
||||
extends Renderer(options)
|
||||
with LinkConverter
|
||||
with RequestCache {
|
||||
with RequestCache
|
||||
with WikiService {
|
||||
|
||||
override def heading(text: String, level: Int, raw: String): String = {
|
||||
val id = generateAnchorName(text)
|
||||
@@ -193,8 +195,11 @@ object Markdown {
|
||||
}
|
||||
} else {
|
||||
// URL is being modified to link to the image file on the repository, but users may want to link to the page if the page name is a link.
|
||||
// As a interim solution, if the link contains a ., it will use the current conversion, otherwise it will perform the conversion the user wants.
|
||||
if (url.lastIndexOf(".") > 0) {
|
||||
// If the wiki page cannot be retrieved from the url, the blob address is returned; otherwise, the page address is returned.
|
||||
val pathElems = context.currentPath.split("/")
|
||||
val owner = pathElems(1)
|
||||
val repos = pathElems(2)
|
||||
if (getWikiPage(owner, repos, url, branch) == None) {
|
||||
repository.httpUrl.replaceFirst("/git/", "/").stripSuffix(".git") + "/wiki/_blob/" + url
|
||||
} else {
|
||||
repository.httpUrl.replaceFirst("/git/", "/").stripSuffix(".git") + "/wiki/" + url
|
||||
|
||||
Reference in New Issue
Block a user