Tried getting astilectron to work
continuous-integration/drone/push Build is passing Details

This commit is contained in:
kolaente 2019-09-04 22:11:13 +02:00
parent 684bb421b3
commit 7b83f23ff0
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
8 changed files with 97 additions and 25 deletions

7
bundler.json Normal file
View File

@ -0,0 +1,7 @@
{
"app_name": "Konfi@Castle Kasino",
"icon_path_darwin": "gopher.icns",
"icon_path_linux": "gopher.png",
"icon_path_windows": "gopher.ico",
"resources_path": "assets"
}

View File

@ -9,4 +9,6 @@ Mode = 1
; Das Interface inkl. Port, auf dem der Webserver läuft. Muss komplett mit IP-Adresse vorhanden sein.
Interface = :8080
; Hier wird die Datenbank gespeichert
DBFile = ./data.db
DBFile = ./data.db
; Ob Fenster geöffnet werden sollen, oder nicht.
OpenWindows = true

7
go.mod
View File

@ -3,10 +3,14 @@ module git.kolaente.de/konrad/Konfi-Castle-Kasino
go 1.12
require (
github.com/akavel/rsrc v0.8.0 // indirect
github.com/astaxie/session v0.0.0-20130408050157-95d7fe18579c
github.com/asticode/go-astilectron v0.8.0
github.com/asticode/go-astilectron-bootstrap v0.0.0-20190816065004-25b857285999
github.com/asticode/go-astilectron-bundler v0.0.0-20190426172205-155c2a10bbb1 // indirect
github.com/asticode/go-astilog v1.0.0
github.com/asticode/go-astitools v1.1.0 // indirect
github.com/asticode/go-bindata v0.0.0-20151023091102-a0ff2567cfb7 // indirect
github.com/go-ini/ini v1.46.0
github.com/go-xorm/xorm v0.7.6
github.com/gorilla/sessions v1.2.0
@ -15,7 +19,10 @@ require (
github.com/labstack/gommon v0.3.0
github.com/mattn/go-sqlite3 v1.11.0
github.com/pkg/errors v0.8.1
github.com/prometheus/common v0.2.0
github.com/sam-kamerer/go-plister v1.1.2 // indirect
github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337 // indirect
github.com/zserge/webview v0.0.0-20190123072648-16c93bcaeaeb
golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472 // indirect
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 // indirect
gopkg.in/ini.v1 v1.46.0 // indirect

12
go.sum
View File

@ -6,6 +6,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
github.com/akavel/rsrc v0.8.0 h1:zjWn7ukO9Kc5Q62DOJCcxGpXC18RawVtYAGdz2aLlfw=
github.com/akavel/rsrc v0.8.0/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc h1:cAKDfWh5VpdgMhJosfJnn5/FoN2SRZ4p7fJNX58YPaU=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY=
@ -16,11 +18,17 @@ github.com/astaxie/session v0.0.0-20130408050157-95d7fe18579c/go.mod h1:0t1M8SLg
github.com/asticode/go-astiamqp v1.0.0/go.mod h1:PDHG8FjHJDtbDNNHixFCm80+7Ma1dKvwYl325Mj5DI4=
github.com/asticode/go-astilectron v0.8.0 h1:OuLahP7CKcQNyXrFMWRzvK4Mymltd94Orp6SvoE4P4g=
github.com/asticode/go-astilectron v0.8.0/go.mod h1:XN7r4w/s0Eu7D5TgmXuPN07sO8CmYHg95kw2EuW15nE=
github.com/asticode/go-astilectron-bootstrap v0.0.0-20190816065004-25b857285999 h1:UI2sYZr5MU2iXdC83j17ufsFoDZSGbeHIwE3TaBnFMI=
github.com/asticode/go-astilectron-bootstrap v0.0.0-20190816065004-25b857285999/go.mod h1:SRaKevdZAZLWX+GCK49MNPYnHGjcNEP4XN3swtIWC3Q=
github.com/asticode/go-astilectron-bundler v0.0.0-20190426172205-155c2a10bbb1 h1:T3veYqBjxmQ7Jz43DDxjvfTnn/xfoxvwbPT65N+qzDk=
github.com/asticode/go-astilectron-bundler v0.0.0-20190426172205-155c2a10bbb1/go.mod h1:7iR/tJj8CDwh3dlELvVf/GzgPzRoj+5t4zqiAPLOZfI=
github.com/asticode/go-astilog v1.0.0 h1:l9tek0K7KoQCmhZ7cvBTtVu0NsKpS9hB6jBLtQyxWYk=
github.com/asticode/go-astilog v1.0.0/go.mod h1:Vg6SGUYb3tVyFeGQe0Mqmh0RMygpwy+huFKcyL92EVc=
github.com/asticode/go-astitools v1.0.0/go.mod h1:E7f1P0KkBNgafRCD0dHqn41jNHyYHjxrnK1jH2s4pmA=
github.com/asticode/go-astitools v1.1.0 h1:h5hVWUKB9eUZY7/mgu6Ic6Rke8ZiWHkiJO0rIGIb5j4=
github.com/asticode/go-astitools v1.1.0/go.mod h1:EfgrhUJK6nM17TckqASIqR2W71uNUAoIonm6mNhUtaQ=
github.com/asticode/go-bindata v0.0.0-20151023091102-a0ff2567cfb7 h1:gYpAQQSHIQDjCQDNZFLK2QNg2AHojNEDtdr5lgN7BAQ=
github.com/asticode/go-bindata v0.0.0-20151023091102-a0ff2567cfb7/go.mod h1:U4/+WvsiMSeOj+af0opIouj0B3bEaTvHoIJ73+r6vUU=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/casbin/casbin v1.8.2/go.mod h1:z8uPsfBJGUsnkagrt3G8QvjgTKFMBJ32UP8HpZllfog=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
@ -133,6 +141,8 @@ github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/sam-kamerer/go-plister v1.1.2 h1:41zrzYK0j9YTDL0G9beEDY4Bv92rNNnN2+Up3o8RLrQ=
github.com/sam-kamerer/go-plister v1.1.2/go.mod h1:gTt1Ko2oTA5bfDYsNcLjRGyyx6LPxHIeo0ZTtTRZG2I=
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24 h1:pntxY8Ary0t43dCZ5dqY4YTJCObLY1kIXl0uzMv+7DE=
@ -157,6 +167,8 @@ github.com/valyala/fasttemplate v1.0.1 h1:tY9CJiPnMXf1ERmG2EyK7gNUd+c6RKGD0IfU8W
github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
github.com/ziutek/mymysql v1.5.4 h1:GB0qdRGsTwQSBVYuVShFBKaXSnSnYYC2d9knnE1LHFs=
github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0=
github.com/zserge/webview v0.0.0-20190123072648-16c93bcaeaeb h1:zVjnyZIM7UtkG3dNckiudIm+TUHkZqi5xlVQPd3J6/c=
github.com/zserge/webview v0.0.0-20190123072648-16c93bcaeaeb/go.mod h1:a1CV8KR4Dd1eP2g+mEijGOp+HKczwdKHWyx0aPHKvo4=
go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=

View File

@ -6,6 +6,7 @@ import (
"git.kolaente.de/konrad/Konfi-Castle-Kasino/pkg/config"
"git.kolaente.de/konrad/Konfi-Castle-Kasino/pkg/models"
"git.kolaente.de/konrad/Konfi-Castle-Kasino/pkg/router"
"git.kolaente.de/konrad/Konfi-Castle-Kasino/pkg/windows"
"github.com/astaxie/session"
_ "github.com/astaxie/session/providers/memory"
"github.com/labstack/gommon/log"
@ -66,6 +67,11 @@ func main() {
}
}()
// Windows
if config.GetOpenWindows() {
go windows.OpenWindows()
}
// Wait for interrupt signal to gracefully shutdown the server with
// a timeout of 10 seconds.
quit := make(chan os.Signal, 1)
@ -77,7 +83,4 @@ func main() {
if err := e.Shutdown(ctx); err != nil {
e.Logger.Fatal(err)
}
//Windows
//windows.OpenWindows()
}

View File

@ -11,6 +11,7 @@ type Configuration struct {
Interface string
DBFile string
Mode int
OpenWindows bool
}
var siteConf = &Configuration{}
@ -41,3 +42,7 @@ func GetAdminPassword() string {
func GetDBFile() string {
return siteConf.DBFile
}
func GetOpenWindows() bool {
return siteConf.OpenWindows
}

15
pkg/windows/bind.go Normal file
View File

@ -0,0 +1,15 @@
package windows
/*
func Asset(name string) ([]byte, error) {
return []byte{}, nil
}
func AssetDir(name string) ([]string, error) {
return []string{}, nil
}
func RestoreAssets(dir, name string) error {
return nil
}
*/

View File

@ -1,33 +1,58 @@
package windows
import (
"fmt"
"git.kolaente.de/konrad/Konfi-Castle-Kasino/pkg/config"
"github.com/asticode/go-astilectron"
"github.com/asticode/go-astilog"
"github.com/pkg/errors"
"github.com/labstack/gommon/log"
)
func OpenWindows() {
// Create astilectron
var a *astilectron.Astilectron
var err error
if a, err = astilectron.New(astilectron.Options{
AppName: "Astilectron",
// Webview viewer
/* err := webview.Open("Konfi@Castle Viewer", "http://127.0.0.1:8080", 800, 600, true)
if err != nil {
log.Fatal(err)
}*/
// Astilectron Bootstrapper and bundler
/*if err := bootstrap.Run(bootstrap.Options{
Asset: Asset,
AssetDir: AssetDir,
AstilectronOptions: astilectron.Options{
AppName: "Konfi@Castle Kasino",
AppIconDarwinPath: "gopher.icns",
AppIconDefaultPath: "gopher.png",
},
RestoreAssets: RestoreAssets,
Windows: []*bootstrap.Window{{
Homepage: "http://127.0.0.1:8080",
Options: &astilectron.WindowOptions{
BackgroundColor: astilectron.PtrStr("#333"),
Center: astilectron.PtrBool(true),
Height: astilectron.PtrInt(700),
Width: astilectron.PtrInt(700),
},
}},
}); err != nil {
log.Fatal("running bootstrap failed ", err)
//astilog.Fatal(errors.Wrap(err, "running bootstrap failed"))
}*/
// Astilectron classic
a, err := astilectron.New(astilectron.Options{
AppName: "Konfi@Castle Kasino",
AppIconDefaultPath: "gopher.png",
AppIconDarwinPath: "gopher.icns",
BaseDirectoryPath: "astilectron-deps",
}); err != nil {
fmt.Println(err)
astilog.Fatal(errors.Wrap(err, "creating new astilectron failed"))
})
if err != nil {
log.Error("creating new astilectron failed", err)
}
defer a.Close()
a.HandleSignals()
// Start
if err = a.Start(); err != nil {
fmt.Println(err)
astilog.Fatal(errors.Wrap(err, "starting failed"))
log.Error("starting failed", err)
}
// Create Frontend window
@ -39,12 +64,10 @@ func OpenWindows() {
})
if err != nil {
fmt.Println(err)
astilog.Fatal(errors.Wrap(err, "new window failed"))
log.Error("new window failed", err)
}
if err = wFrontend.Create(); err != nil {
fmt.Println(err)
astilog.Fatal(errors.Wrap(err, "creating window failed"))
log.Error("creating window failed", err)
}
// If several displays, move the window to the second display
@ -65,12 +88,10 @@ func OpenWindows() {
Height: astilectron.PtrInt(700),
Width: astilectron.PtrInt(1200),
}); err != nil {
fmt.Println(err)
astilog.Fatal(errors.Wrap(err, "new window failed"))
log.Error("new window failed", err)
}
if err = wAdmin.Create(); err != nil {
fmt.Println(err)
astilog.Fatal(errors.Wrap(err, "creating window failed"))
log.Error("creating window failed", err)
}
// Blocking pattern