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:
Viliam Dias
2015-11-16 14:25:22 -02:00
parent 30f072f925
commit 6ad724d80c

View File

@@ -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)
} }