diff options
| author | Gab Virebent <gabriel1@virebent.art> | 2026-07-07 16:24:28 +0200 |
|---|---|---|
| committer | Gab Virebent <gabriel1@virebent.art> | 2026-07-07 16:24:28 +0200 |
| commit | 37f156c30e2a2b01c840d39f0dd2bdbf811732d6 (patch) | |
| tree | e2ce84dc7f88ce0eb312899448f91b7bb93ca8a3 /internal/cms/status.go | |
| download | gemcms-main.tar.gz gemcms-main.tar.xz gemcms-main.zip | |
Diffstat (limited to 'internal/cms/status.go')
| -rw-r--r-- | internal/cms/status.go | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/internal/cms/status.go b/internal/cms/status.go new file mode 100644 index 0000000..8147ee7 --- /dev/null +++ b/internal/cms/status.go @@ -0,0 +1,50 @@ +package cms + +import ( + "os" + "path/filepath" +) + +func Status(root string) (StatusReport, error) { + project, err := LoadProject(root) + if err != nil { + return StatusReport{}, err + } + check, err := Check(root) + if err != nil { + return StatusReport{}, err + } + report := StatusReport{ + Root: root, + Config: project.Config, + Menus: len(project.Menus), + Sections: len(project.Sections), + Widgets: len(project.Widgets), + PublicFiles: countPublicFiles(filepath.Join(root, "public")), + Issues: check.Issues, + } + for _, doc := range project.Docs { + switch doc.Type { + case "page": + report.Pages++ + case "article": + report.Articles++ + } + if doc.Draft { + report.Drafts++ + } + } + return report, nil +} + +func countPublicFiles(root string) int { + count := 0 + filepath.WalkDir(root, func(_ string, entry os.DirEntry, err error) error { + if err != nil || entry.IsDir() { + return nil + } + count++ + return nil + }) + return count +} |
