Move wisski instance code to separate package
This commit is contained in:
parent
7c3c84e116
commit
063f3f9b7d
67 changed files with 533 additions and 409 deletions
36
internal/wisski/pathbuilders.go
Normal file
36
internal/wisski/pathbuilders.go
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
package wisski
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
//go:embed php/export_pathbuilder.php
|
||||
var exportPathbuilderPHP string
|
||||
|
||||
// Pathbuilders returns the ids of all pathbuilders in consistent order.
|
||||
//
|
||||
// server is the server to fetch the pathbuilders from, any may be nil.
|
||||
func (wisski *WissKI) Pathbuilders(server *PHPServer) (ids []string, err error) {
|
||||
err = wisski.ExecPHPScript(server, &ids, exportPathbuilderPHP, "all_list")
|
||||
slices.Sort(ids)
|
||||
return
|
||||
}
|
||||
|
||||
// Pathbuilder returns a single pathbuilder as xml.
|
||||
// If it does not exist, it returns the empty string and nil error.
|
||||
//
|
||||
// server is the server to fetch the pathbuilders from, any may be nil.
|
||||
func (wisski *WissKI) Pathbuilder(server *PHPServer, id string) (xml string, err error) {
|
||||
err = wisski.ExecPHPScript(server, &xml, exportPathbuilderPHP, "one_xml", id)
|
||||
return
|
||||
}
|
||||
|
||||
// AllPathbuilders returns all pathbuilders serialized as xml
|
||||
//
|
||||
// server is the server to fetch the pathbuilders from, any may be nil.
|
||||
func (wisski *WissKI) AllPathbuilders(server *PHPServer) (pathbuilders map[string]string, err error) {
|
||||
err = wisski.ExecPHPScript(server, &pathbuilders, exportPathbuilderPHP, "all_xml")
|
||||
return
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue