diff --git a/Makefile b/Makefile index 79a606d..85bf405 100644 --- a/Makefile +++ b/Makefile @@ -28,4 +28,14 @@ install: /etc/init.d/awwkoala.init restart rm -rf jinstall +binaries: + rm -rf binaries + rm -f awwkoala + mkdir binaries + env GOOS=linux GOARCH=amd64 go build -o awwkoala -v *.go + zip -9 -r awwkoala-linux-amd64.zip awwkoala static/* templates/* + rm -f awwkoala + + .PHONY: install +.PHONY: binaries \ No newline at end of file diff --git a/main.go b/main.go index a605c82..3d875d9 100644 --- a/main.go +++ b/main.go @@ -31,6 +31,7 @@ var RuntimeArgs struct { ServerKey string SourcePath string AdminKey string + Socket string } var VersionNum string @@ -45,10 +46,10 @@ func main() { flag.StringVar(&RuntimeArgs.ServerKey, "key", "", "location of ssl key") flag.StringVar(&RuntimeArgs.WikiName, "w", "AwwKoala", "custom name for wiki") flag.CommandLine.Usage = func() { - fmt.Println(`AwwKoala: A Websocket Wiki and Kind Of A List Application + fmt.Println(`AwwKoala (version ` + VersionNum + `): A Websocket Wiki and Kind Of A List Application run this to start the server and then visit localhost at the port you specify (see parameters). -Example: 'awwkoala localhost' +Example: 'awwkoala yourserver.com' Example: 'awwkoala -p :8080 localhost:8080' Example: 'awwkoala -db /var/lib/awwkoala/db.bolt localhost:8003' Example: 'awwkoala -p :8080 -crt ssl/server.crt -key ssl/server.key localhost:8080' @@ -58,7 +59,7 @@ Options:`) flag.Parse() RuntimeArgs.ExternalIP = flag.Arg(0) if RuntimeArgs.ExternalIP == "" { - log.Fatal("You need to specify the external IP address") + RuntimeArgs.ExternalIP = GetLocalIP() + RuntimeArgs.Port } RuntimeArgs.SourcePath = path.Dir(executableFile) Open(RuntimeArgs.DatabaseLocation) @@ -95,9 +96,16 @@ Options:`) r.DELETE("/listitem", deleteListItem) r.DELETE("/deletepage", deletePage) if RuntimeArgs.ServerCRT != "" && RuntimeArgs.ServerKey != "" { + RuntimeArgs.Socket = "wss" + fmt.Println("--------------------------") + fmt.Println("AwwKoala is up and running on https://" + RuntimeArgs.ExternalIP) + fmt.Println("--------------------------") r.RunTLS(RuntimeArgs.Port, RuntimeArgs.ServerCRT, RuntimeArgs.ServerKey) } else { - log.Println("No crt/key found, running non-https") + RuntimeArgs.Socket = "ws" + fmt.Println("--------------------------") + fmt.Println("AwwKoala is up and running on http://" + RuntimeArgs.ExternalIP) + fmt.Println("--------------------------") r.Run(RuntimeArgs.Port) } } diff --git a/routes.go b/routes.go index bb0db7a..7bf9129 100644 --- a/routes.go +++ b/routes.go @@ -48,6 +48,7 @@ func editNote(c *gin.Context) { "NumRows": numRows, "Versions": versions, "TotalTime": totalTime, + "SocketType": RuntimeArgs.Socket, }) } else { c.HTML(http.StatusOK, "index.tmpl", gin.H{ @@ -58,6 +59,7 @@ func editNote(c *gin.Context) { "NumRows": numRows, "Versions": versions, "TotalTime": totalTime, + "SocketType": RuntimeArgs.Socket, "NoEdit": true, }) } diff --git a/static/js/websockets.js b/static/js/websockets.js index d298448..69ed052 100644 --- a/static/js/websockets.js +++ b/static/js/websockets.js @@ -44,7 +44,7 @@ $(document).ready(function() { } // websockets - url = 'ws://'+external_ip+'/ws'; + url = socketType + '://'+external_ip+'/ws'; c = new WebSocket(url); send = function(data){ diff --git a/templates/index.tmpl b/templates/index.tmpl index 71616df..d81adf0 100644 --- a/templates/index.tmpl +++ b/templates/index.tmpl @@ -14,6 +14,7 @@ diff --git a/templates/list.tmpl b/templates/list.tmpl index 00174c4..635d624 100644 --- a/templates/list.tmpl +++ b/templates/list.tmpl @@ -28,7 +28,7 @@ - {{ .WikiName }} + {{ .Title }}