summaryrefslogtreecommitdiff
path: root/system
diff options
context:
space:
mode:
authorSteve Manuel <nilslice@gmail.com>2017-06-10 17:09:47 -0600
committerGitHub <noreply@github.com>2017-06-10 17:09:47 -0600
commite3fb3aba33645ef1c7ba1d1556c806d7c0eb853b (patch)
treee65b5a0dc7579b0af904c487570c5c5ade742f7b /system
parent427dff52c3db481dff38dd1eee83f93e54ea8065 (diff)
parent4d767c13f15b24fdbfcb610589e757a98c931d70 (diff)
Merge pull request #159 from ponzu-cms/ponzu-dev
[cli] adding documentation server for local use
Diffstat (limited to 'system')
-rw-r--r--system/admin/server.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/system/admin/server.go b/system/admin/server.go
index 426dabd..9f28a0d 100644
--- a/system/admin/server.go
+++ b/system/admin/server.go
@@ -1,6 +1,7 @@
package admin
import (
+ "fmt"
"log"
"net/http"
"os"
@@ -62,3 +63,23 @@ func Run() {
// Database & uploads backup via HTTP route registered with Basic Auth middleware.
http.HandleFunc("/admin/backup", system.BasicAuth(backupHandler))
}
+
+// Docs adds the documentation file server to the server, accessible at
+// http://localhost:1234 by default
+func Docs(port int) {
+ pwd, err := os.Getwd()
+ if err != nil {
+ log.Fatalln("Couldn't find current directory for file server.")
+ }
+
+ docsDir := filepath.Join(pwd, "docs", "build")
+
+ addr := fmt.Sprintf(":%d", port)
+ url := fmt.Sprintf("http://localhost%s", addr)
+
+ fmt.Println("")
+ fmt.Println("View documentation offline at:", url)
+ fmt.Println("")
+
+ go http.ListenAndServe(addr, http.FileServer(http.Dir(docsDir)))
+}