2020-10-29 07:50:25 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2020-10-29 15:52:31 +01:00
|
|
|
"context"
|
2021-02-10 00:46:49 +01:00
|
|
|
"fmt"
|
2020-10-29 07:50:25 +01:00
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
"os/exec"
|
|
|
|
"strconv"
|
|
|
|
|
2021-02-10 00:46:49 +01:00
|
|
|
"github.com/google/uuid"
|
2020-10-29 07:50:25 +01:00
|
|
|
"github.com/webview/webview"
|
|
|
|
)
|
|
|
|
|
2021-02-10 00:46:49 +01:00
|
|
|
var sessionToken string = "su-" + uuid.New().String()
|
|
|
|
|
2021-01-26 19:52:42 +01:00
|
|
|
func runServer(ctx context.Context) {
|
2021-02-11 19:13:17 +01:00
|
|
|
cmd := exec.CommandContext(ctx, "./focalboard-server", "--monitorpid", strconv.FormatInt(int64(os.Getpid()), 10), "-single-user")
|
|
|
|
cmd.Env = []string{fmt.Sprintf("FOCALBOARD_SINGLE_USER_TOKEN=%s", sessionToken)}
|
2020-10-29 07:50:25 +01:00
|
|
|
cmd.Stdout = os.Stdout
|
|
|
|
err := cmd.Run()
|
|
|
|
if err != nil {
|
2021-02-11 19:13:17 +01:00
|
|
|
log.Println("Failed to start server")
|
2020-10-29 07:50:25 +01:00
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
log.Printf("Just ran subprocess %d, exiting\n", cmd.Process.Pid)
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
debug := true
|
|
|
|
w := webview.New(debug)
|
|
|
|
defer w.Destroy()
|
2020-10-29 15:52:31 +01:00
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
2021-01-26 19:52:42 +01:00
|
|
|
go runServer(ctx)
|
2020-10-29 07:50:25 +01:00
|
|
|
|
2021-01-26 19:52:42 +01:00
|
|
|
w.SetTitle("Focalboard")
|
2020-10-29 07:50:25 +01:00
|
|
|
w.SetSize(1024, 768, webview.HintNone)
|
2021-02-10 00:46:49 +01:00
|
|
|
|
|
|
|
script := fmt.Sprintf("localStorage.setItem('sessionId', '%s');", sessionToken)
|
|
|
|
w.Init(script)
|
|
|
|
|
2021-01-20 23:09:41 +01:00
|
|
|
w.Navigate("http://localhost:8088")
|
2020-10-29 07:50:25 +01:00
|
|
|
w.Run()
|
2020-10-29 15:52:31 +01:00
|
|
|
cancel()
|
2020-10-29 07:50:25 +01:00
|
|
|
}
|