mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-12 08:25:50 +01:00
A service to get the wiki sidebar page
- getWikiSideBar: a new service to get the wiki sidebar file "_Sidebar.md". - getFileContent: must ignore MD files which starts with "_".
This commit is contained in:
@@ -71,6 +71,20 @@ trait WikiService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the wiki sidebar page.
|
||||||
|
*/
|
||||||
|
def getWikiSideBar(owner: String, repository: String): Option[WikiPageInfo] = {
|
||||||
|
using(Git.open(Directory.getWikiRepositoryDir(owner, repository))){ git =>
|
||||||
|
if(!JGitUtil.isEmpty(git)){
|
||||||
|
JGitUtil.getFileList(git, "master", ".").find(_.name == "_Sidebar.md").map { file =>
|
||||||
|
WikiPageInfo(file.name, StringUtil.convertFromByteArray(git.getRepository.open(file.id).getBytes),
|
||||||
|
file.author, file.time, file.commitId)
|
||||||
|
}
|
||||||
|
} else None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the content of the specified file.
|
* Returns the content of the specified file.
|
||||||
*/
|
*/
|
||||||
@@ -93,7 +107,7 @@ trait WikiService {
|
|||||||
def getWikiPageList(owner: String, repository: String): List[String] = {
|
def getWikiPageList(owner: String, repository: String): List[String] = {
|
||||||
using(Git.open(Directory.getWikiRepositoryDir(owner, repository))){ git =>
|
using(Git.open(Directory.getWikiRepositoryDir(owner, repository))){ git =>
|
||||||
JGitUtil.getFileList(git, "master", ".")
|
JGitUtil.getFileList(git, "master", ".")
|
||||||
.filter(_.name.endsWith(".md"))
|
.filter(_.name.endsWith(".md")).filterNot(_.name.startsWith("_"))
|
||||||
.map(_.name.stripSuffix(".md"))
|
.map(_.name.stripSuffix(".md"))
|
||||||
.sortBy(x => x)
|
.sortBy(x => x)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user