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, " ") fmt.Fprintln(w, " ") fmt.Fprintln(w, " ") fmt.Fprintln(w, " ") fmt.Fprintln(w, " ") fmt.Fprintln(w, " ") // fmt.Fprintln(w, " ") // 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, " ") } 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, " ") fmt.Fprintln(w, " ") // fmt.Fprintln(w, " ") fmt.Fprintln(w, " ") 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 fmt.Fprintln(w, " ") // dev version if gourl == "go.wit.com/apps/helloworld" { fmt.Fprintln(w, " ") // dev version } else { fmt.Fprintln(w, " ") // dev version } fmt.Fprintln(w, " ") // fmt.Fprintln(w, " ") fmt.Fprintln(w, " ") fmt.Fprintln(w, "") } func indexDivEnd(w http.ResponseWriter) { // fmt.Fprintln(w, " fmt.Fprintln(w, " ") fmt.Fprintln(w, "
Package (IPv6 only)DocumentationVersionAgeDev VersionDescriptionAuthoritative sources (IPv6 only)

", strings.Join(parts, " "), "

log/ (needed for the gui)
"+gourl+" "+gourl+" \"pkg.go.dev\" "+version+""+vtime+"Video Demo "+desc+" "+giturl+"
") fmt.Fprintln(w, "
") fmt.Fprintln(w, "
") } func indexBodyEnd(w http.ResponseWriter) { fmt.Fprintln(w, " ") fmt.Fprintln(w, " ") }