summaryrefslogtreecommitdiff
path: root/indexHtml.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-01-31 08:45:58 -0600
committerJeff Carr <[email protected]>2024-01-31 08:45:58 -0600
commit424c8d5a36e272ccedb2a6717c2a3d08b2ea1768 (patch)
treec3ae81966d601dcb9a5fc49f1cbc135262e26d27 /indexHtml.go
parent9ff813b0ad6a68c2aad8f6a7365b452a19c07457 (diff)
add versions and timestamps
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'indexHtml.go')
-rw-r--r--indexHtml.go60
1 files changed, 49 insertions, 11 deletions
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, " <div class=\"container\">")
fmt.Fprintln(w, " <div class=\"row\">")
fmt.Fprintln(w, " <table class=\"u-full-width\">")
-// fmt.Fprintln(w, " <thead>")
+ // fmt.Fprintln(w, " <thead>")
fmt.Fprintln(w, " <tr>")
fmt.Fprintln(w, " <th>Package</th>")
+ fmt.Fprintln(w, " <th>Version</th>")
+ fmt.Fprintln(w, " <th>Age</th>")
+ fmt.Fprintln(w, " <th>Dev Version</th>")
fmt.Fprintln(w, " <th>go get</th>")
fmt.Fprintln(w, " <th>Authoritative sources (IPv6 only)</th>")
fmt.Fprintln(w, " <th></th>")
fmt.Fprintln(w, " <th>Documentation</th>")
fmt.Fprintln(w, " </tr>")
-// fmt.Fprintln(w, " </thead>")
+ // fmt.Fprintln(w, " </thead>")
fmt.Fprintln(w, " <tbody>")
fmt.Fprintln(w, "")
}
func insertHTMLnote(w http.ResponseWriter, i int, parts []string) {
log.Info("comment # line:", i, strings.Join(parts, " "))
- fmt.Fprintln(w, " <tr> <td><h3>", strings.Join(parts, " "), "</h3></td> <td></td> <td></td> <td></td> <td></td> </tr>")
+ fmt.Fprintln(w, " <tr> <td><h3>", strings.Join(parts, " "), "</h3></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr>")
}
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, " <tr> <td><h5>log/ (needed for the gui)</h5></td> <td></td> <td></td> <td></td> <td></td> </tr>")
fmt.Fprintln(w, " <tr>")
- fmt.Fprintln(w, " <td>" + gourl + "</td>")
- fmt.Fprintln(w, " <td> <a href=\"//" + gourl + "\">" + gourl + "</a></td>")
- fmt.Fprintln(w, " <td> <a href=\"//" + gourl + "\">" + giturl + "</a></td>")
+ fmt.Fprintln(w, " <td>"+gourl+"</td>")
+ 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, " <td>"+version+"</td>") // version
+ fmt.Fprintln(w, " <td>"+ vtime +"</td>") // dev version
+ fmt.Fprintln(w, " <td></td>") // dev version
+ fmt.Fprintln(w, " <td> <a href=\"//"+gourl+"\">"+gourl+"</a></td>")
+ fmt.Fprintln(w, " <td> <a href=\"//"+gourl+"\">"+giturl+"</a></td>")
if github == "" {
fmt.Fprintln(w, " <td></td>")
} else {
fmt.Fprintln(w, " <td> <a href=\"//github.com/wit-go/log\">github.com/wit-go/log</a></td>")
}
- fmt.Fprintln(w, " <td> <a href=\"//pkg.go.dev/" + gourl + "\"> <img src=\"goReference.svg\" alt=\"pkg.go.dev docs\" /> </a> </td>")
+ fmt.Fprintln(w, " <td> <a href=\"//pkg.go.dev/"+gourl+"\"> <img src=\"goReference.svg\" alt=\"pkg.go.dev docs\" /> </a> </td>")
fmt.Fprintln(w, " </tr>")
fmt.Fprintln(w, "")
}