Fork Notesium source and restructure into Go package layout

Initial fork of github.com/alonswartz/notesium into librenotes:
- Source moved to internal/notesium/ (package notesium)
- Thin entry point at cmd/librenotes/main.go
- Module renamed to git.librete.ch/public/librenotes
- main() exposed as notesium.Run()
- LICENSE preserved (MIT), NOTICE added with attribution
- Web assets and completion.bash co-located with embedding code
  to satisfy go:embed path constraints

Closes #3, #34, #35.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-28 21:52:25 +02:00
co-authored by Claude Opus 4.7
parent b816914b9c
commit df9407dd8d
63 changed files with 7391 additions and 0 deletions
+82
View File
@@ -0,0 +1,82 @@
package notesium
import (
"fmt"
"runtime"
)
type WebInfo struct {
Webroot string `json:"webroot"`
Writable bool `json:"writable"`
StopOnIdle bool `json:"stop-on-idle"`
VersionCheck bool `json:"daily-version-check"`
}
type BuildInfo struct {
GitVersion string `json:"gitversion"`
Buildtime string `json:"buildtime"`
GoVersion string `json:"goversion"`
LatestReleaseURL string `json:"latest-release-url"`
}
type MemoryInfo struct {
MemoryAlloc string `json:"alloc"`
MemoryTotalAlloc string `json:"total-alloc"`
MemorySys string `json:"sys"`
MemoryLookups uint64 `json:"lookups"`
MemoryMallocs uint64 `json:"mallocs"`
MemoryFrees uint64 `json:"frees"`
}
type RuntimeResponse struct {
Home string `json:"home"`
Version string `json:"version"`
Platform string `json:"platform"`
Web WebInfo `json:"web"`
Build BuildInfo `json:"build"`
Memory MemoryInfo `json:"memory"`
}
func GetRuntimeInfo(dir string, webOpts webOptions) RuntimeResponse {
var memStats runtime.MemStats
runtime.ReadMemStats(&memStats)
return RuntimeResponse{
Home: dir,
Version: getVersion(gitversion),
Platform: fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH),
Web: WebInfo{
Webroot: webOpts.webroot,
Writable: !webOpts.readOnly,
StopOnIdle: webOpts.heartbeat,
VersionCheck: webOpts.check,
},
Build: BuildInfo{
GitVersion: gitversion,
Buildtime: buildtime,
GoVersion: runtime.Version(),
LatestReleaseURL: latestReleaseURL,
},
Memory: MemoryInfo{
MemoryAlloc: bytesToHumanReadable(memStats.Alloc),
MemoryTotalAlloc: bytesToHumanReadable(memStats.TotalAlloc),
MemorySys: bytesToHumanReadable(memStats.Sys),
MemoryLookups: memStats.Lookups,
MemoryMallocs: memStats.Mallocs,
MemoryFrees: memStats.Frees,
},
}
}
func bytesToHumanReadable(bytes uint64) string {
const unit = 1024
if bytes < unit {
return fmt.Sprintf("%d B", bytes)
}
div, exp := int64(unit), 0
for n := bytes / unit; n >= unit; n /= unit {
div *= unit
exp++
}
return fmt.Sprintf("%.1f %cB", float64(bytes)/float64(div), "KMGTPE"[exp])
}