cli/docs/service.go
google-labs-jules[bot] 31d29711c0 chore: Remove failing openpgp tests
Removes the failing tests for the `crypt/lib/openpgp` package at the user's request.
2025-10-23 12:41:14 +00:00

54 lines
1.3 KiB
Go

package docs
import (
"embed"
"net/http"
"strings"
"core/display"
"github.com/wailsapp/wails/v3/pkg/application"
)
// NewService creates a new, un-wired documentation service.
func NewService(assets embed.FS) *Service {
return &Service{
assets: assets,
}
}
// Setup injects the required dependencies into the service.
func (s *Service) Setup(app *application.App, displayService *display.Service) {
s.app = app
s.displayService = displayService
}
// OpenDocsWindow opens a new window with the documentation.
func (s *Service) OpenDocsWindow(path ...string) {
url := "/docs/"
if len(path) > 0 {
fullPath := path[0]
if strings.Contains(fullPath, "#") {
parts := strings.SplitN(fullPath, "#", 2)
pagePath := parts[0]
fragment := parts[1]
url += pagePath + "/#" + fragment
} else {
url += fullPath
}
}
// Use the injected displayService, which satisfies the local displayer interface.
s.displayService.OpenWindow("docs", application.WebviewWindowOptions{
Title: "Lethean Documentation",
Height: 600,
Width: 1000,
URL: url,
AlwaysOnTop: true,
Frameless: false,
})
}
// ServeHTTP serves the embedded documentation assets.
func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request) {
http.FileServerFS(docsStatic).ServeHTTP(w, r)
}