-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for Linux/Windows, running in a web browser
- Loading branch information
KyleBanks
committed
Mar 24, 2017
1 parent
4ec1ca0
commit a5ca260
Showing
59 changed files
with
1,755 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Package cmd provides shared functionality for the multiple run-modes. | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"net/http" | ||
"os" | ||
|
||
"github.com/KyleBanks/goggles" | ||
"github.com/KyleBanks/goggles/conf" | ||
"github.com/KyleBanks/goggles/pkg/sys" | ||
"github.com/KyleBanks/goggles/server" | ||
) | ||
|
||
const ( | ||
aboutURL = "https://github.com/KyleBanks/goggles" | ||
thanksURL = "https://github.com/KyleBanks/goggles#thanks" | ||
) | ||
|
||
var ( | ||
// port is the port number to listen on. | ||
port = 10765 | ||
|
||
// Index is the URL of the root index.html file. | ||
Index = fmt.Sprintf("http://127.0.0.1:%v/static/index.html", port) | ||
) | ||
|
||
func init() { | ||
// Update the $GOPATH if a custom value is set. | ||
c := conf.Get() | ||
if c != nil && len(c.Gopath) > 0 { | ||
sys.SetGopath(c.Gopath) | ||
} | ||
|
||
log.Printf("$GOPATH=%v, srcdir=%v", sys.Gopath(), sys.Srcdir()) | ||
} | ||
|
||
// StartServer starts the application server. | ||
func StartServer() { | ||
p := provider{goggles.Service{}} | ||
api := server.New(p) | ||
addr := fmt.Sprintf(":%v", port) | ||
|
||
log.Fatal(http.ListenAndServe(addr, api)) | ||
} | ||
|
||
// OpenAbout opens the 'About' page in a web browser. | ||
func OpenAbout() { | ||
sys.OpenBrowser(aboutURL) | ||
} | ||
|
||
// OpenThanks opens the 'Thanks' page in a web browser. | ||
func OpenThanks() { | ||
sys.OpenBrowser(thanksURL) | ||
} | ||
|
||
// Quit terminates the running application. | ||
func Quit() { | ||
os.Exit(0) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Package main handles running Goggles as a standalone native application. | ||
package main | ||
|
||
import ( | ||
"runtime" | ||
|
||
"github.com/KyleBanks/goggles/cmd" | ||
) | ||
|
||
const ( | ||
title = "Goggles" | ||
titleAbout = "About" | ||
titleThanks = "Thanks" | ||
titleDebug = "Debug" | ||
titleQuit = "Quit" | ||
) | ||
|
||
func init() { | ||
runtime.LockOSThread() | ||
} | ||
|
||
func startServer() { | ||
cmd.StartServer() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,18 @@ | ||
// Package main handles running Goggles in a web browser. | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"net/http" | ||
"os" | ||
"path/filepath" | ||
"runtime" | ||
"time" | ||
|
||
"github.com/KyleBanks/goggles/conf" | ||
"github.com/KyleBanks/goggles/goggles" | ||
"github.com/KyleBanks/goggles/cmd" | ||
"github.com/KyleBanks/goggles/pkg/sys" | ||
"github.com/KyleBanks/goggles/server" | ||
) | ||
|
||
const ( | ||
port = 10765 | ||
func main() { | ||
go func() { | ||
time.Sleep(time.Millisecond * 500) | ||
sys.OpenBrowser(cmd.Index) | ||
}() | ||
|
||
title = "Goggles" | ||
titleAbout = "About" | ||
titleThanks = "Thanks" | ||
titleDebug = "Debug" | ||
titleQuit = "Quit" | ||
|
||
aboutURL = "https://github.com/KyleBanks/goggles" | ||
thanksURL = "https://github.com/KyleBanks/goggles#thanks" | ||
) | ||
|
||
var ( | ||
logFile = os.ExpandEnv("$HOME/Library/Logs/goggles.log") | ||
index = fmt.Sprintf("http://127.0.0.1:%v/static/index.html", port) | ||
) | ||
|
||
func init() { | ||
runtime.LockOSThread() | ||
|
||
// Update the $GOPATH if a custom value is set. | ||
c := conf.Get() | ||
if c != nil && len(c.Gopath) > 0 { | ||
sys.SetGopath(c.Gopath) | ||
} | ||
} | ||
|
||
func startServer() { | ||
log.Printf("$GOPATH=%v, srcdir=%v", sys.Gopath(), sys.Srcdir()) | ||
|
||
p := provider{goggles.Service{}} | ||
api := server.New(p, filepath.Dir(os.Args[0])) | ||
addr := fmt.Sprintf(":%v", port) | ||
log.Fatal(http.ListenAndServe(addr, api)) | ||
} | ||
|
||
func openAbout() { | ||
sys.OpenBrowser(aboutURL) | ||
} | ||
|
||
func openThanks() { | ||
sys.OpenBrowser(thanksURL) | ||
} | ||
|
||
func quit() { | ||
os.Exit(0) | ||
cmd.StartServer() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.