Manual test versioning looks good

master v1.0
Bel LaPointe 2019-11-21 14:17:45 -07:00
parent fecd343f1b
commit e4632d36ba
4 changed files with 29 additions and 5 deletions

1
TODO
View File

@ -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

View File

@ -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()
}

16
main.go
View File

@ -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 {

View File

@ -1,2 +1,5 @@
asdf
searchString
here is my new line