@@ -6,6 +6,7 @@ package repo
66
77import (
88 "bytes"
9+ gocontext "context"
910 "fmt"
1011 "io"
1112 "net/http"
@@ -651,22 +652,32 @@ func WikiPages(ctx *context.Context) {
651652 return
652653 }
653654
654- entries , err := commit .ListEntries ()
655+ treePath := "" // To support list sub folders' pages in the future
656+ tree , err := commit .SubTree (treePath )
657+ if err != nil {
658+ ctx .ServerError ("SubTree" , err )
659+ return
660+ }
661+
662+ allEntries , err := tree .ListEntries ()
655663 if err != nil {
656664 ctx .ServerError ("ListEntries" , err )
657665 return
658666 }
667+ allEntries .CustomSort (base .NaturalSortLess )
668+
669+ entries , _ , err := allEntries .GetCommitsInfo (gocontext .Context (ctx ), commit , treePath )
670+ if err != nil {
671+ ctx .ServerError ("GetCommitsInfo" , err )
672+ return
673+ }
674+
659675 pages := make ([]PageMeta , 0 , len (entries ))
660676 for _ , entry := range entries {
661- if ! entry .IsRegular () {
677+ if ! entry .Entry . IsRegular () {
662678 continue
663679 }
664- c , err := wikiRepo .GetCommitByPath (entry .Name ())
665- if err != nil {
666- ctx .ServerError ("GetCommit" , err )
667- return
668- }
669- wikiName , err := wiki_service .GitPathToWebPath (entry .Name ())
680+ wikiName , err := wiki_service .GitPathToWebPath (entry .Entry .Name ())
670681 if err != nil {
671682 if repo_model .IsErrWikiInvalidFileName (err ) {
672683 continue
@@ -678,8 +689,8 @@ func WikiPages(ctx *context.Context) {
678689 pages = append (pages , PageMeta {
679690 Name : displayName ,
680691 SubURL : wiki_service .WebPathToURLPath (wikiName ),
681- GitEntryName : entry .Name (),
682- UpdatedUnix : timeutil .TimeStamp (c .Author .When .Unix ()),
692+ GitEntryName : entry .Entry . Name (),
693+ UpdatedUnix : timeutil .TimeStamp (entry . Commit .Author .When .Unix ()),
683694 })
684695 }
685696 ctx .Data ["Pages" ] = pages
0 commit comments