diff --git a/Debian_Dockerfile b/Debian_Dockerfile index af97503..e110321 100644 --- a/Debian_Dockerfile +++ b/Debian_Dockerfile @@ -31,8 +31,10 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update \ ARG WOLWEBPORT=8089 ARG WOLWEBVDIR=/wolweb +ARG WOLWEBHIDEAPIDOCS=false ENV WOLWEBPORT=${WOLWEBPORT} ENV WOLWEBVDIR=${WOLWEBVDIR} +ENV WOLWEBHIDEAPIDOCS=${WOLWEBHIDEAPIDOCS} CMD ["/wolweb/wolweb"] diff --git a/Dockerfile b/Dockerfile index c92f3c4..decfd31 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,8 +30,10 @@ RUN apk add --no-cache curl ARG WOLWEBPORT=8089 ARG WOLWEBVDIR=/wolweb +ARG WOLWEBHIDEAPIDOCS=false ENV WOLWEBPORT=${WOLWEBPORT} ENV WOLWEBVDIR=${WOLWEBVDIR} +ENV WOLWEBHIDEAPIDOCS=${WOLWEBHIDEAPIDOCS} CMD ["/wolweb/wolweb"] diff --git a/README.md b/README.md index a54de8f..52e668a 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ The application will use the following default values if they are not explicitly | Virtual Directory | A virtual directory to mount this application under | **/wolweb** | Broadcast IP and Port | This is broadcast IP address and port for the local network. *Please include the port :9* | **192.168.1.255:9** | Read Only | If set to true, the UI will be read only | **false** +| Hide API Docs | If set to true, the API documentation section is hidden on the web UI | **false** You can override the default application configuration by using a config file or by setting environment variables. The application will first load values from config file and look for environment variables and overwrites values from the file with the values which were found in the environment. @@ -62,7 +63,8 @@ You can override the default application configuration by using a config file or "port": 8089, "vdir":"/wolweb", "bcastip":"192.168.1.255:9", - "read_only":false + "read_only":false, + "hide_api_docs":false } ``` **Using Environment Variables:** @@ -76,6 +78,7 @@ You can override the default application configuration by using a config file or | WOLWEBVDIR | Override for default virtual directory | WOLWEBBCASTIP | Override for broadcast IP address and port | WOLWEBREADONLY | Override for read only mode of UI +| WOLWEBHIDEAPIDOCS | Override for hiding the API documentation section on the web UI ## Devices (targets) - devices.json format ```json diff --git a/config.json b/config.json index db6aecd..91cc329 100644 --- a/config.json +++ b/config.json @@ -3,5 +3,6 @@ "port": 8089, "vdir": "/wolweb", "bcastip": "192.168.1.255:9", - "read_only": false + "read_only": false, + "hide_api_docs": false } diff --git a/docker-compose.yml b/docker-compose.yml index 33c3782..cdcccc5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -22,3 +22,4 @@ services: WOLWEBPORT: "8089" #WOLWEBVDIR: "/wolweb" WOLWEBBCASTIP: "192.168.1.255:9" + #WOLWEBHIDEAPIDOCS: "false" diff --git a/index.html b/index.html index 4b02f23..5187609 100644 --- a/index.html +++ b/index.html @@ -48,6 +48,7 @@

Devices

+ {{ if not .HideAPIDocs }}

Wake-up directly using HTTP Requests

@@ -99,6 +100,7 @@

+ {{ end }}

Project Page: https://github.com/sameerdhoot/wolweb @@ -116,11 +118,13 @@

window.vDir = "{{$.VDir}}" window.bCastIP = "{{$.BCastIP}}" + {{ if not .HideAPIDocs }} $( "#code-element" ).load( "static/api-sample.txt" , function() { hljs.highlightAll(); }); document.getElementById("app-vdir").innerHTML = window.vDir + "/wake/" + {{ end }} Toast.setMaxCount(3); Toast.enableQueue(true); diff --git a/pages.go b/pages.go index 09250bd..d789367 100644 --- a/pages.go +++ b/pages.go @@ -14,15 +14,17 @@ var indexHtml string func renderHomePage(w http.ResponseWriter, r *http.Request) { pageData := struct { - Devices []Device - VDir string - BCastIP string - ReadOnly bool + Devices []Device + VDir string + BCastIP string + ReadOnly bool + HideAPIDocs bool }{ - Devices: appData.Devices, - VDir: appConfig.VDir, - BCastIP: appConfig.BCastIP, - ReadOnly: appConfig.ReadOnly, + Devices: appData.Devices, + VDir: appConfig.VDir, + BCastIP: appConfig.BCastIP, + ReadOnly: appConfig.ReadOnly, + HideAPIDocs: appConfig.HideAPIDocs, } if appConfig.VDir == "/" { pageData.VDir = "" diff --git a/types.go b/types.go index 50b0a72..c0f1af4 100644 --- a/types.go +++ b/types.go @@ -26,5 +26,6 @@ type AppConfig struct { Port int `json:"port" env:"WOLWEBPORT" env-default:"8089"` VDir string `json:"vdir" env:"WOLWEBVDIR" env-default:"/wolweb"` BCastIP string `json:"bcastip" env:"WOLWEBBCASTIP" env-default:"192.168.1.255:9"` - ReadOnly bool `json:"read_only" env:"WOLWEBREADONLY" env-default:"false"` + ReadOnly bool `json:"read_only" env:"WOLWEBREADONLY" env-default:"false"` + HideAPIDocs bool `json:"hide_api_docs" env:"WOLWEBHIDEAPIDOCS" env-default:"false"` }