Show database file size on info page

This commit is contained in:
2022-08-21 13:24:52 +09:30
parent a03baca498
commit f98df478bb
7 changed files with 25 additions and 10 deletions

View File

@@ -1,12 +1,16 @@
<div class="grid-x grid-padding-x">
<div class="large-12 cell">
<div class="large-6 medium-12 cell">
<h5>System information</h5>
<table>
<tr><th>Memory in use</th><td>{{ meminfo }}</td></tr>
<tr><th>Bookmarks</th><td>{{ .stats.MostRecentBookmarkInfo.Bookmarks }}</td></tr>
<tr><th>Words Indexed</th><td>{{ .stats.MostRecentBookmarkInfo.IndexedWords }}</td></tr>
<tr><th>Database disk size</th><td>{{ niceSizeMB .stats.FileSize }}Mb</td></tr>
</table>
</div>
<div class="large-6 medium-12 cell">
<h5>Release info</h5>
{{ if not version.Remote.Valid }}

View File

@@ -79,12 +79,13 @@ func Create(bmm *db.BookmarkManager, cmm *db.ConfigManager) *Server {
// templ := template.Must(template.New("").Funcs(template.FuncMap{"dict": dictHelper}).ParseFS(templateFiles, "templates/*.html"))
templ := template.Must(template.New("").Funcs(
template.FuncMap{
"nicetime": niceTime,
"niceURL": niceURL,
"join": strings.Join,
"version": func() *version.Info { return &version.VersionInfo },
"meminfo": meta.MemInfo,
"markdown": func(s string) template.HTML { return template.HTML(string(markdown.ToHTML([]byte(s), nil, nil))) },
"nicetime": niceTime,
"niceURL": niceURL,
"niceSizeMB": func(s int) string { return fmt.Sprintf("%.1f", float32(s)/1024/1024) },
"join": strings.Join,
"version": func() *version.Info { return &version.VersionInfo },
"meminfo": meta.MemInfo,
"markdown": func(s string) template.HTML { return template.HTML(string(markdown.ToHTML([]byte(s), nil, nil))) },
}).ParseFS(templateFiles, "templates/*.html"))
config, err := cmm.LoadConfig()