Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[add] sui page tree debug log #491

Merged
merged 1 commit into from
Oct 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions sui/storages/local/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (tmpl *Template) PageTree(route string) ([]*core.PageTreeNode, error) {
tmpl.local.fs.Walk(tmpl.Root, func(root, file string, isdir bool) error {
name := filepath.Base(file)
relPath := file
log.Debug("[PageTree] file: %s isdir: %v", relPath, isdir)
log.Debug("[PageTree] Walk | file: %s isdir: %v name: %v", relPath, isdir, name)

if isdir {
if strings.HasPrefix(name, "__") || name == ".tmp" {
Expand All @@ -81,7 +81,7 @@ func (tmpl *Template) PageTree(route string) ([]*core.PageTreeNode, error) {
}
}

log.Debug("[PageTree] dirs: %s found: %v", dir, found)
log.Debug("[PageTree] Walk | dirs: %s found: %v", dir, found)
// If not found, create a new directory node.
if !found {
newDir := &core.PageTreeNode{
Expand All @@ -101,6 +101,7 @@ func (tmpl *Template) PageTree(route string) ([]*core.PageTreeNode, error) {
return nil
}

log.Debug("[PageTree] getPageFrom | file: %s", file)
page, err := tmpl.getPageFrom(file)
if err != nil {
log.Error("Get page error: %v", err)
Expand All @@ -109,12 +110,16 @@ func (tmpl *Template) PageTree(route string) ([]*core.PageTreeNode, error) {

pageInfo := page.Get()
active := route == pageInfo.Route
log.Debug("[PageTree] getPageFrom |\t pageInfo.Name: %s", pageInfo.Name)

// Attach the page to the appropriate directory node.
dirs := strings.Split(relPath, string(filepath.Separator))
currentDir := rootNode
log.Debug("[PageTree] currentDir | name: %s Children: %d", currentDir.Name, len(currentDir.Children))

for _, dir := range dirs {
for _, child := range currentDir.Children {
log.Debug("[PageTree] currentDir.Children | child.Name: %s dir:%s", child.Name, dir)
if child.Name == dir {
currentDir = child
break
Expand Down