-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
3,360 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.syso | ||
*.exe | ||
*.stackdump |
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,144 @@ | ||
package bootstrap | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"io" | ||
"log" | ||
"os" | ||
"path/filepath" | ||
"runtime" | ||
|
||
"github.com/pkg/errors" | ||
"github.com/rocketsoftware/open-web-launch/java" | ||
"github.com/rocketsoftware/open-web-launch/launcher" | ||
"github.com/rocketsoftware/open-web-launch/messaging" | ||
"github.com/rocketsoftware/open-web-launch/utils" | ||
) | ||
|
||
func Run(productName, productTitle, productVersion string) { | ||
productWorkDir := filepath.Join(os.TempDir(), productName) | ||
productLogFile := filepath.Join(productWorkDir, productName+".log") | ||
fmt.Fprintf(os.Stderr, "%s %s\n", productTitle, productVersion) | ||
if err := utils.CreateProductWorkDir(productWorkDir); err != nil { | ||
log.Fatal(err) | ||
} | ||
logFile, err := utils.OpenOrCreateProductLogFile(productLogFile) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
log.SetFlags(log.LstdFlags | log.Lmicroseconds) | ||
log.SetOutput(logFile) | ||
log.Printf("starting %s %s with arguments %v\n", productTitle, productVersion, os.Args) | ||
log.Printf("current platform is OS=%q Architecture=%q\n", runtime.GOOS, runtime.GOARCH) | ||
if len(os.Args) == 2 { | ||
filenameOrURL := os.Args[1] | ||
handleURLOrFilename(filenameOrURL, nil, productWorkDir, productTitle) | ||
} else if len(os.Args) == 3 && os.Args[1] == "-uninstall" { | ||
handleUninstallCommand(productWorkDir, productTitle) | ||
} else if len(os.Args) == 4 && os.Args[1] == "-javadir" { | ||
javaDir := os.Args[2] | ||
filenameOrURL := os.Args[3] | ||
var err error | ||
if javaDir, err = java.UseJavaDir(javaDir); err != nil { | ||
log.Fatal(err) | ||
} | ||
options := &launcher.Options{JavaDir: javaDir} | ||
handleURLOrFilename(filenameOrURL, options, productWorkDir, productTitle) | ||
} else { | ||
isRunningFromBrowser := len(os.Args) > 2 | ||
options := &launcher.Options{IsRunningFromBrowser: isRunningFromBrowser} | ||
log.Printf("running from browser: %v\n", isRunningFromBrowser) | ||
listenForMessage(options, productWorkDir, productTitle) | ||
} | ||
} | ||
|
||
func handleURLOrFilename(filenameOrURL string, options *launcher.Options, productWorkDir string, productTitle string) { | ||
myLauncher, byURL, err := launcher.FindLauncherForURLOrFilename(filenameOrURL) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
if err := myLauncher.CheckPlatform(); err != nil { | ||
log.Fatal(err) | ||
} | ||
myLauncher.SetWorkDir(productWorkDir) | ||
myLauncher.SetWindowTitle(productTitle) | ||
myLauncher.SetOptions(options) | ||
defer myLauncher.Wait() | ||
if byURL { | ||
if err := myLauncher.RunByURL(filenameOrURL); err != nil { | ||
log.Println(err) | ||
return | ||
} | ||
} else { | ||
if err := myLauncher.RunByFilename(filenameOrURL); err != nil { | ||
log.Println(err) | ||
return | ||
} | ||
} | ||
} | ||
|
||
func listenForMessage(options *launcher.Options, productWorkDir string, productTitle string) { | ||
message, err := messaging.GetMessage(os.Stdin) | ||
if err != nil { | ||
if errors.Cause(err) != io.EOF { | ||
log.Fatal(err) | ||
} | ||
log.Println("exit because stdin has been closed") | ||
return | ||
} | ||
if message.Status != "" { | ||
response := fmt.Sprintf(`{"status": "installed"}`) | ||
if err := messaging.SendMessage(os.Stdout, response); err != nil { | ||
log.Fatal(err) | ||
} | ||
return | ||
} | ||
myLauncher, err := launcher.FindLauncherForURL(message.URL) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
if err := myLauncher.CheckPlatform(); err != nil { | ||
log.Fatal(err) | ||
} | ||
myLauncher.SetWorkDir(productWorkDir) | ||
myLauncher.SetWindowTitle(productTitle) | ||
myLauncher.SetOptions(options) | ||
defer myLauncher.Wait() | ||
if err := myLauncher.RunByURL(message.URL); err != nil { | ||
stringError := fmt.Sprintf("%v", err) | ||
jsonError, _ := json.Marshal(stringError) | ||
response := fmt.Sprintf(`{"status": %s}`, string(jsonError)) | ||
log.Println(response) | ||
if err := messaging.SendMessage(os.Stdout, response); err != nil { | ||
log.Fatal(err) | ||
} | ||
return | ||
} | ||
response := fmt.Sprintf(`{"status": "ok"}`) | ||
if err := messaging.SendMessage(os.Stdout, response); err != nil { | ||
log.Fatal(err) | ||
} | ||
} | ||
|
||
func handleUninstallCommand(productWorkDir string, productTitle string) { | ||
_ = os.Args[1] // -uninstall | ||
filenameOrURL := os.Args[2] | ||
myLauncher, byURL, err := launcher.FindLauncherForURLOrFilename(filenameOrURL) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
myLauncher.SetWorkDir(productWorkDir) | ||
myLauncher.SetWindowTitle(productTitle) | ||
if byURL { | ||
if err := myLauncher.UninstallByURL(filenameOrURL); err != nil { | ||
log.Println(err) | ||
return | ||
} | ||
} else { | ||
if err := myLauncher.UninstallByFilename(filenameOrURL); err != nil { | ||
log.Println(err) | ||
return | ||
} | ||
} | ||
} |
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,19 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/rocketsoftware/open-web-launch/bootstrap" | ||
_ "github.com/rocketsoftware/open-web-launch/launcher/jnlp" | ||
) | ||
|
||
//go:generate goversioninfo -o openweblaunch.syso | ||
|
||
const ( | ||
productName = "openweblaunch" | ||
productTitle = "Open Web Launch" | ||
) | ||
|
||
var productVersion = "Dummy version number" | ||
|
||
func main() { | ||
bootstrap.Run(productName, productTitle, productVersion) | ||
} |
Binary file not shown.
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,37 @@ | ||
{ | ||
"FixedFileInfo": { | ||
"FileVersion": { | ||
"Major": 1, | ||
"Minor": 0, | ||
"Patch": 0, | ||
"Build": 0 | ||
}, | ||
"ProductVersion": { | ||
"Major": 1, | ||
"Minor": 0, | ||
"Patch": 0, | ||
"Build": 0 | ||
}, | ||
"FileFlagsMask": "3f", | ||
"FileFlags ": "00", | ||
"FileOS": "040004", | ||
"FileType": "01", | ||
"FileSubType": "00" | ||
}, | ||
"StringFileInfo": { | ||
"Comments": "", | ||
"CompanyName": "Rocket Software Inc.", | ||
"FileDescription": "Open Web Launch", | ||
"FileVersion": "", | ||
"InternalName": "openweblaunch", | ||
"LegalCopyright": "©2019 Rocket Software Inc.", | ||
"LegalTrademarks": "", | ||
"OriginalFilename": "", | ||
"PrivateBuild": "", | ||
"ProductName": "Open Web Launch", | ||
"ProductVersion": "v1.0.0.0", | ||
"SpecialBuild": "" | ||
}, | ||
"IconPath": "resources\\icon.ico", | ||
"ManifestPath": "" | ||
} |
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,12 @@ | ||
module github.com/rocketsoftware/open-web-launch | ||
|
||
require ( | ||
github.com/aarzilli/nucular v0.0.0-20190604155258-847327059ed7 | ||
github.com/elazarl/go-bindata-assetfs v1.0.0 | ||
github.com/go-ole/go-ole v1.2.4 | ||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 | ||
github.com/pkg/errors v0.8.1 | ||
golang.org/x/image v0.0.0-20190616094056-33659d3de4f5 | ||
golang.org/x/mobile v0.0.0-20190607214518-6fa95d984e88 | ||
golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f | ||
) |
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,33 @@ | ||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= | ||
github.com/BurntSushi/xgb v0.0.0-20160522221800-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= | ||
github.com/aarzilli/nucular v0.0.0-20190604155258-847327059ed7 h1:hUPnGRVk7zIgDxQEzeETm9L45edIkyYlOR78rtrpYmA= | ||
github.com/aarzilli/nucular v0.0.0-20190604155258-847327059ed7/go.mod h1:kmRix5MpiU9CMTXlMppPUJ6FEza2no59rZZZWcF3xMU= | ||
github.com/elazarl/go-bindata-assetfs v1.0.0 h1:G/bYguwHIzWq9ZoyUQqrjTmJbbYn3j3CKKpKinvZLFk= | ||
github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4= | ||
github.com/go-ole/go-ole v1.2.4 h1:nNBDSCOigTSiarFpYE9J/KtEA1IOW4CNeqT9TQDqCxI= | ||
github.com/go-ole/go-ole v1.2.4/go.mod h1:XCwSNxSkXRo4vlyPy93sltvi/qJq0jqQhjqQNIwKuxM= | ||
github.com/golang/freetype v0.0.0-20161208064710-d9be45aaf745/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= | ||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g= | ||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= | ||
github.com/hashicorp/golang-lru v0.0.0-20160813221303-0a025b7e63ad h1:eMxs9EL0PvIGS9TTtxg4R+JxuPGav82J8rA+GFnY7po= | ||
github.com/hashicorp/golang-lru v0.0.0-20160813221303-0a025b7e63ad/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= | ||
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= | ||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= | ||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= | ||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= | ||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522 h1:OeRHuibLsmZkFj773W4LcfAGsSxJgfPONhr8cmO+eLA= | ||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= | ||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= | ||
golang.org/x/image v0.0.0-20190616094056-33659d3de4f5 h1:ngW7cqsJcNIFizl289rKwy+nVvw7TQS8z3ejrra6syo= | ||
golang.org/x/image v0.0.0-20190616094056-33659d3de4f5/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= | ||
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= | ||
golang.org/x/mobile v0.0.0-20190318164015-6bd122906c08/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= | ||
golang.org/x/mobile v0.0.0-20190607214518-6fa95d984e88 h1:H6DkDrMSuEE2MQR7DgGwkzbXSY1lvMpEN5MDE1bo/5U= | ||
golang.org/x/mobile v0.0.0-20190607214518-6fa95d984e88/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= | ||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= | ||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f h1:25KHgbfyiSm6vwQLbM3zZIe1v9p/3ea4Rz+nnM5K/i4= | ||
golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | ||
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= |
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 @@ | ||
bindata.go |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,18 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Open Web Launch</title> | ||
<link rel="stylesheet" type="text/css" href="main.css"/> | ||
</head> | ||
<body> | ||
<div class="main"> | ||
<div class="title">Open Web Launch</div> | ||
<div class="app-title"></div> | ||
<div class="progress-container"> | ||
<div class="progress"></div> | ||
</div> | ||
<div class="text"></div> | ||
</div> | ||
<script src="main.js"></script> | ||
</body> | ||
</html> |
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,65 @@ | ||
* { | ||
font-family: Helvetica; | ||
} | ||
|
||
body { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
|
||
.main { | ||
display: flex; | ||
width: 640px; | ||
height: 480px; | ||
align-items: center; | ||
border: 2px solid blue; | ||
border-radius: 2px; | ||
background-color: lightblue; | ||
justify-content: center; | ||
flex-direction: column; | ||
} | ||
|
||
.title { | ||
display: flex; | ||
flex: 1 1 auto; | ||
justify-content: center; | ||
font-size: 3rem; | ||
font-weight: 800; | ||
height: 30%; | ||
align-items: center; | ||
} | ||
|
||
.app-title { | ||
display: flex; | ||
justify-content: center; | ||
font-size: 1rem; | ||
font-weight: 600; | ||
min-height: 40px; | ||
} | ||
|
||
.text { | ||
min-height: 40px; | ||
display: flex; | ||
font-weight: 400; | ||
justify-content: center; | ||
} | ||
|
||
.progress-container { | ||
position: relative; | ||
display: flex; | ||
flex-direction: row; | ||
align-self: stretch; | ||
height: 30px; | ||
align-items: stretch; | ||
margin: 10px 7px 60px 7px; | ||
} | ||
|
||
.progress { | ||
display: flex; | ||
flex-direction: row; | ||
width: 0; | ||
background-color: blue; | ||
border-radius: 3px; | ||
} |
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,53 @@ | ||
(function() { | ||
var socket = new WebSocket('ws://localhost:18485/status'); | ||
var progress = 0; | ||
var progressMax = 0; | ||
|
||
socket.onopen = function() { | ||
showMessage('Started'); | ||
}; | ||
|
||
socket.onclose = function(event) { | ||
closeWindow(); | ||
}; | ||
|
||
socket.onmessage = function(event) { | ||
var message = JSON.parse(event.data); | ||
if (message.type === 'close') { | ||
showMessage('Exiting...'); | ||
closeWindow(); | ||
} else if (message.type === 'progress_step') { | ||
progressStep(); | ||
} else if (message.type === 'progress_max') { | ||
progressMax = +message.payload; | ||
} else if (message.type === 'title') { | ||
setTitle(message.payload); | ||
} else { | ||
showMessage(message.payload); | ||
} | ||
}; | ||
|
||
socket.onerror = function(error) { | ||
showMessage('Error: ' + error.message); | ||
}; | ||
|
||
function showMessage(message) { | ||
document.querySelector('div.text').innerText = message; | ||
} | ||
|
||
function closeWindow() { | ||
setTimeout(function () { | ||
window.close(); | ||
}, 500); | ||
} | ||
|
||
function setTitle(title) { | ||
document.querySelector('div.app-title').innerText = title; | ||
} | ||
|
||
function progressStep() { | ||
progress++; | ||
var width = String(progress/progressMax * 100) + '%'; | ||
document.querySelector('div.progress').style.width = width; | ||
} | ||
})(); |
Oops, something went wrong.