diff --git a/Makefile b/Makefile
index 8381034..4b3227e 100644
--- a/Makefile
+++ b/Makefile
@@ -6,6 +6,9 @@ all:
./go.wit.com
@# ./myrepos >/tmp/myrepos.stderr 2>&1
+goimports:
+ goimports -w *.go
+
redomod:
rm -f go.*
GO111MODULE= go mod init
diff --git a/dumpClient.go b/dumpClient.go
index 2b5dcf4..188a8d7 100644
--- a/dumpClient.go
+++ b/dumpClient.go
@@ -2,9 +2,9 @@ package main
import (
"fmt"
- "time"
- "net/http"
"io/ioutil"
+ "net/http"
+ "time"
"go.wit.com/log"
)
@@ -32,9 +32,8 @@ func dumpClient(r *http.Request) {
fmt.Fprintln(clientf, "Host:", r.Host)
fmt.Fprintln(clientf, "Remote Address:", r.RemoteAddr)
-
// Headers
- fmt.Fprintln(clientf,"Headers:")
+ fmt.Fprintln(clientf, "Headers:")
for name, values := range r.Header {
for _, value := range values {
fmt.Fprintln(clientf, "Headers:", name, value)
@@ -56,7 +55,7 @@ func dumpClient(r *http.Request) {
fmt.Fprintln(clientf, "Content Length:", r.ContentLength)
// Cookies
- fmt.Fprintln(clientf,"Cookies:")
+ fmt.Fprintln(clientf, "Cookies:")
for _, cookie := range r.Cookies() {
fmt.Fprintln(clientf, cookie.Name, cookie.Value)
}
diff --git a/files/repomap b/files/repomap
index 5f4cf3e..84ec168 100644
--- a/files/repomap
+++ b/files/repomap
@@ -31,7 +31,8 @@ go.wit.com/lib/protobuf/wit git.wit.org/wit/witProtobuf
go.wit.com/apps/helloworld git.wit.org/gui/helloworld
go.wit.com/apps/basicwindow git.wit.org/jcarr/basicwindow
go.wit.com/apps/gadgetwindow git.wit.org/jcarr/gadgetwindow
-go.wit.com/apps/autotypist git.wit.org/jcarr/myrepos
+go.wit.com/apps/autotypist git.wit.org/jcarr/autotypist
+go.wit.com/apps/guireleaser git.wit.org/jcarr/guireleaser
go.wit.com/apps/control-panel-dns git.wit.org/jcarr/control-panel-dns
go.wit.com/apps/control-panel-digitalocean git.wit.org/wit/control-panel-digitalocean
go.wit.com/apps/control-panel-cloudflare git.wit.org/wit/control-panel-cloudflare
diff --git a/indexHtml.go b/indexHtml.go
index 1fca005..3fe8d9c 100644
--- a/indexHtml.go
+++ b/indexHtml.go
@@ -2,8 +2,10 @@ package main
import (
"fmt"
- "strings"
"net/http"
+ "strconv"
+ "strings"
+ "time"
"go.wit.com/log"
)
@@ -34,22 +36,25 @@ func indexBodyStart(w http.ResponseWriter) {
fmt.Fprintln(w, "
")
fmt.Fprintln(w, "
")
fmt.Fprintln(w, "
")
-// fmt.Fprintln(w, " ")
+ // fmt.Fprintln(w, " ")
fmt.Fprintln(w, " ")
fmt.Fprintln(w, " Package | ")
+ fmt.Fprintln(w, " Version | ")
+ fmt.Fprintln(w, " Age | ")
+ fmt.Fprintln(w, " Dev Version | ")
fmt.Fprintln(w, " go get | ")
fmt.Fprintln(w, " Authoritative sources (IPv6 only) | ")
fmt.Fprintln(w, " | ")
fmt.Fprintln(w, " Documentation | ")
fmt.Fprintln(w, "
")
-// fmt.Fprintln(w, " ")
+ // fmt.Fprintln(w, " ")
fmt.Fprintln(w, " ")
fmt.Fprintln(w, "")
}
func insertHTMLnote(w http.ResponseWriter, i int, parts []string) {
log.Info("comment # line:", i, strings.Join(parts, " "))
- fmt.Fprintln(w, " ", strings.Join(parts, " "), " | | | | |
")
+ fmt.Fprintln(w, " ", strings.Join(parts, " "), " | | | | | | | |
")
}
func indexBodyScanConfig(w http.ResponseWriter) {
@@ -57,15 +62,15 @@ func indexBodyScanConfig(w http.ResponseWriter) {
for i, line := range configfile {
// log.Info("config file line:", i, line)
fields := strings.Fields(line)
- if (len(fields) == 0) {
+ if len(fields) == 0 {
continue
}
- if (fields[0] == "#") {
+ if fields[0] == "#" {
insertHTMLnote(w, i, fields[0:])
// log.Info("comment # line:", i, line)
continue
}
- if (len(fields) == 2) {
+ if len(fields) == 2 {
log.Info("short file line:", i, line)
gourl := fields[0]
giturl := fields[1]
@@ -80,15 +85,48 @@ func indexBodyScanConfig(w http.ResponseWriter) {
func indexBodyRepo(w http.ResponseWriter, gourl string, giturl string, github string) {
// fmt.Fprintln(w, " log/ (needed for the gui) | | | | |
")
fmt.Fprintln(w, " ")
- fmt.Fprintln(w, " " + gourl + " | ")
- fmt.Fprintln(w, " " + gourl + " | ")
- fmt.Fprintln(w, " " + giturl + " | ")
+ fmt.Fprintln(w, " "+gourl+" | ")
+ for i, s := range versionMap {
+ log.Println("found i =", i, "with", "s =", s)
+ }
+ var vtime, version string
+ gourl = strings.TrimSpace(gourl)
+ tmp, _ := versionMap[gourl]
+ parts := strings.Split(tmp, " ")
+ if len(parts) > 0 {
+ version = parts[0]
+ }
+ if len(parts) > 1 {
+ vtime = parts[1]
+ }
+
+ if vtime != "" {
+ // Convert the string to an integer
+ gitTagTimestampInt, _ := strconv.ParseInt(vtime, 10, 64)
+
+ // Parse the Unix timestamp into a time.Time object
+ gitTagDate := time.Unix(gitTagTimestampInt, 0)
+
+ // Get the current time
+ currentTime := time.Now()
+
+ // Calculate the duration between the git tag date and the current time
+ duration := currentTime.Sub(gitTagDate)
+
+ vtime = formatDuration(duration)
+ }
+
+ fmt.Fprintln(w, " "+version+" | ") // version
+ fmt.Fprintln(w, " "+ vtime +" | ") // dev version
+ fmt.Fprintln(w, " | ") // dev version
+ fmt.Fprintln(w, " "+gourl+" | ")
+ fmt.Fprintln(w, " "+giturl+" | ")
if github == "" {
fmt.Fprintln(w, " | ")
} else {
fmt.Fprintln(w, " github.com/wit-go/log | ")
}
- fmt.Fprintln(w, " | ")
+ fmt.Fprintln(w, " | ")
fmt.Fprintln(w, "
")
fmt.Fprintln(w, "")
}
diff --git a/jsonClient.go b/jsonClient.go
index 756fae7..4dc9b10 100644
--- a/jsonClient.go
+++ b/jsonClient.go
@@ -1,9 +1,9 @@
package main
import (
- "io/ioutil"
"bytes"
"encoding/json"
+ "io/ioutil"
"net/http"
)
@@ -33,7 +33,7 @@ func dumpJsonClient(r *http.Request) (string, error) {
var bodyBytes []byte
if r.Body != nil { // Read the body if it's not nil
bodyBytes, _ = ioutil.ReadAll(r.Body)
- r.Body.Close() // Close the body when done reading
+ r.Body.Close() // Close the body when done reading
r.Body = ioutil.NopCloser(bytes.NewBuffer(bodyBytes)) // Reset the body
}
@@ -46,7 +46,7 @@ func dumpJsonClient(r *http.Request) (string, error) {
Headers: r.Header,
Cookies: cookieMap,
QueryParams: r.URL.Query(),
- Body: string(bodyBytes),
+ Body: string(bodyBytes),
}
// Marshal the struct to a JSON string
@@ -68,6 +68,7 @@ func dumpJsonClient(r *http.Request) (string, error) {
return string(formattedJSON), nil
}
+
/*
package main
diff --git a/main.go b/main.go
index 67891c8..0e1b544 100644
--- a/main.go
+++ b/main.go
@@ -1,12 +1,14 @@
package main
import (
- "os"
- "fmt"
- "go.wit.com/log"
- "net/http"
"embed"
+ "fmt"
+ "net/http"
+ "os"
"strings"
+ "time"
+
+ "go.wit.com/log"
)
//go:embed files/*
@@ -14,6 +16,11 @@ var htmlFiles embed.FS
var accessf, clientf *os.File
+var repoMap map[string]string
+var versionMap map[string]string
+var configfile []string
+var keysSorted []string
+
// remove '?' part and trailing '/'
func cleanURL(url string) string {
url = "/" + strings.Trim(url, "/")
@@ -77,7 +84,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
func findFile(w http.ResponseWriter, filename string) {
// fmt.Fprintln(w, "GOT TEST?")
pfile, err := htmlFiles.ReadFile(filename)
- if (err != nil) {
+ if err != nil {
log.Println("ERROR:", err)
// w.Write(pfile)
return
@@ -89,19 +96,25 @@ func findFile(w http.ResponseWriter, filename string) {
log.Println("findFile() found internal file:", filename)
// w.Close()
/*
- filename = "/tmp/" + name + ".so"
- log.Error(err, "write out file here", name, filename, len(pfile))
- f, _ := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE, 0600)
- f.Close()
+ filename = "/tmp/" + name + ".so"
+ log.Error(err, "write out file here", name, filename, len(pfile))
+ f, _ := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE, 0600)
+ f.Close()
*/
}
func main() {
- accessf, _ = os.OpenFile("/home/jcarr/accessclient.log", os.O_RDWR | os.O_CREATE | os.O_APPEND, 0666)
- clientf, _ = os.OpenFile("/home/jcarr/httpclient.log", os.O_RDWR | os.O_CREATE | os.O_APPEND, 0666)
+ accessf, _ = os.OpenFile("/home/jcarr/accessclient.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
+ clientf, _ = os.OpenFile("/home/jcarr/httpclient.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
readconfigfile()
+ readVersionFile()
+
+ for i, s := range versionMap {
+ log.Println("found i =", i, "with", "s =", s)
+ }
+ log.Println("found log =", versionMap["go.wit.com/log"])
http.HandleFunc("/", okHandler)
- https()
+ go https()
err := http.ListenAndServe(":80", nil)
if err != nil {
log.Println("Error starting server:", err)
@@ -122,3 +135,28 @@ func badurl(w http.ResponseWriter, badurl string) {
fmt.Fprintln(w, "