From e4632d36bab7c37a588bed37c2488891c1ef794f Mon Sep 17 00:00:00 2001 From: Bel LaPointe Date: Thu, 21 Nov 2019 14:17:45 -0700 Subject: [PATCH] Manual test versioning looks good --- TODO | 1 + config/config.go | 14 +++++++++----- main.go | 16 ++++++++++++++++ public/A/asdf | 3 +++ 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/TODO b/TODO index 61fdca4..ca473b6 100644 --- a/TODO +++ b/TODO @@ -36,3 +36,4 @@ x move auth as flag in router x . and ../** as roots cause bugs in listing and loading and linking x `create` at root is a 400, base= in URL (when `create` input is empty) delete top-level pages +versioning diff --git a/config/config.go b/config/config.go index 6edcd0c..e6bbcca 100755 --- a/config/config.go +++ b/config/config.go @@ -8,14 +8,16 @@ import ( "log" "os" "strings" + "time" ) var ( - Root string - Port string - Head string - Foot string - OAuthServer string + Root string + Port string + Head string + Foot string + OAuthServer string + VersionInterval time.Duration ) func init() { @@ -32,6 +34,7 @@ func Refresh() { as.Append(args.STRING, "port", "port to listen on", "49909") as.Append(args.STRING, "wrap", "file with http header/footer", "./wrapper.html") as.Append(args.STRING, "oauth", "oauth URL", "") + as.Append(args.DURATION, "version", "duration to mark versions", "0s") if err := as.Parse(); err != nil { panic(err) } @@ -52,4 +55,5 @@ func Refresh() { Head = string(bs[0]) Foot = string(bs[1]) OAuthServer = as.Get("oauth").GetString() + VersionInterval = as.Get("version").GetDuration() } diff --git a/main.go b/main.go index 24d41ec..f348bec 100644 --- a/main.go +++ b/main.go @@ -3,10 +3,12 @@ package main import ( "local/notes-server/config" "local/notes-server/server" + "local/notes-server/versions" "log" "net/http" "os" "os/signal" + "time" ) func main() { @@ -15,6 +17,20 @@ func main() { panic(err) } + go func() { + if config.VersionInterval == 0 { + log.Println("versions disabled") + return + } + versions, err := versions.New() + if err != nil { + panic(err) + } + for _ = range time.NewTicker(config.VersionInterval).C { + log.Println(versions.Gitmmit()) + } + }() + go func() { log.Printf("Serving %q on %q", config.Root, config.Port) if err := http.ListenAndServe(config.Port, server); err != nil { diff --git a/public/A/asdf b/public/A/asdf index ba4b0bc..c382581 100755 --- a/public/A/asdf +++ b/public/A/asdf @@ -1,2 +1,5 @@ asdf searchString + + +here is my new line \ No newline at end of file