package main
import (
"fmt"
"net/http"
"strconv"
"strings"
"time"
"go.wit.com/log"
)
func indexHeader(w http.ResponseWriter) {
fmt.Fprintln(w, "")
fmt.Fprintln(w, "")
fmt.Fprintln(w, "
")
// fmt.Fprintln(w, " ")
fmt.Fprintln(w, " ")
fmt.Fprintln(w, " ")
fmt.Fprintln(w, "")
}
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, " ")
fmt.Fprintln(w, " Package (IPv6 only) ")
fmt.Fprintln(w, " Documentation ")
fmt.Fprintln(w, " Version ")
fmt.Fprintln(w, " Age ")
fmt.Fprintln(w, " Dev Version ")
fmt.Fprintln(w, " Description ")
// fmt.Fprintln(w, " Authoritative sources (IPv6 only) ")
// 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, " "), " ")
}
func indexBodyScanConfig(w http.ResponseWriter) {
// log.Info("indexBodyScanConfig() START")
for i, line := range configfile {
// log.Info("config file line:", i, line)
fields := strings.Fields(line)
if len(fields) == 0 {
continue
}
if fields[0] == "#" {
insertHTMLnote(w, i, fields[0:])
// log.Info("comment # line:", i, line)
continue
}
if len(fields) == 2 {
// log.Info("short file line:", i, line)
gourl := fields[0]
giturl := fields[1]
indexBodyRepo(w, gourl, giturl, "")
continue
}
if len(fields) > 2 {
// log.Info("short file line:", i, line)
gourl := fields[0]
giturl := fields[1]
desc := strings.Join(fields[2:], " ")
desc = strings.TrimSpace(desc)
indexBodyRepo(w, gourl, giturl, desc)
continue
}
// log.Info("config file line:", i, line)
}
// log.Info("indexBodyScanConfig() END")
}
func indexBodyRepo(w http.ResponseWriter, gourl string, giturl string, desc string) {
// skip displaying packages without a desc
if desc == "" {
return
}
// fmt.Fprintln(w, " log/ (needed for the gui) ")
fmt.Fprintln(w, " ")
// fmt.Fprintln(w, " "+gourl+" ")
fmt.Fprintln(w, " "+gourl+" ")
fmt.Fprintln(w, " ")
// 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 {
vtime = parts[0]
}
if len(parts) > 1 {
version = parts[1]
}
log.Warn("gourl ", gourl, "vtime =", vtime, "version =", version)
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
if gourl == "go.wit.com/apps/helloworld" {
fmt.Fprintln(w, " Video Demo ") // dev version
} else {
fmt.Fprintln(w, " ") // dev version
}
fmt.Fprintln(w, " "+desc+" ")
// fmt.Fprintln(w, " "+giturl+" ")
fmt.Fprintln(w, " ")
fmt.Fprintln(w, "")
}
func indexDivEnd(w http.ResponseWriter) {
// fmt.Fprintln(w, "
fmt.Fprintln(w, " ")
fmt.Fprintln(w, "
")
fmt.Fprintln(w, "
")
fmt.Fprintln(w, "
")
}
func indexBodyEnd(w http.ResponseWriter) {
fmt.Fprintln(w, " ")
fmt.Fprintln(w, "echo deb http://mirrors.wit.com/wit/ sid main > /etc/apt/sources.list.d/wit.list ")
fmt.Fprintln(w, "apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4A854AEAF7E0E16D ")
fmt.Fprintln(w, "apt update ")
fmt.Fprintln(w, "apt install go-clone # replicates the old 'go get' behavior ")
fmt.Fprintln(w, "apt install go-deb # make a debian package from a golang project ")
fmt.Fprintln(w, "apt install networkquality # debian package of apple's command line speedtest tool ")
fmt.Fprintln(w, "apt install virtigo # virt-manager from the command line (runs wit.com) ")
fmt.Fprintln(w, " ")
fmt.Fprintln(w, "