2024-01-12 12:26:05 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2024-01-12 13:52:55 -06:00
|
|
|
"strings"
|
2024-01-12 12:26:05 -06:00
|
|
|
"net/http"
|
2024-01-12 13:52:55 -06:00
|
|
|
|
|
|
|
"go.wit.com/log"
|
2024-01-12 12:26:05 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
func indexHeader(w http.ResponseWriter) {
|
|
|
|
fmt.Fprintln(w, "<!DOCTYPE html>")
|
|
|
|
fmt.Fprintln(w, "<html>")
|
|
|
|
fmt.Fprintln(w, " <head>")
|
2024-01-12 12:40:54 -06:00
|
|
|
// fmt.Fprintln(w, " <link rel=\"stylesheet\" href=\"skeleton.v2.css\" />")
|
2024-01-12 12:26:05 -06:00
|
|
|
fmt.Fprintln(w, " <style>")
|
|
|
|
fmt.Fprintln(w, " #footer {")
|
|
|
|
fmt.Fprintln(w, " position: fixed;")
|
|
|
|
fmt.Fprintln(w, " padding: 1% 0% 1% 0%; /* top left bottom right */")
|
|
|
|
fmt.Fprintln(w, " bottom: 0;")
|
|
|
|
fmt.Fprintln(w, " width: 100%;")
|
|
|
|
fmt.Fprintln(w, " /* Height of the footer*/")
|
|
|
|
fmt.Fprintln(w, " height: 40px;")
|
|
|
|
fmt.Fprintln(w, " background: lightgrey;")
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
fmt.Fprintln(w, " </style>")
|
|
|
|
fmt.Fprintln(w, " </head>")
|
|
|
|
fmt.Fprintln(w, "</html>")
|
|
|
|
}
|
|
|
|
|
|
|
|
func indexBodyStart(w http.ResponseWriter) {
|
|
|
|
// fmt.Fprintln(w, "
|
2024-01-12 12:40:54 -06:00
|
|
|
fmt.Fprintln(w, "<body>")
|
|
|
|
fmt.Fprintln(w, " <div class=\"container\">")
|
|
|
|
fmt.Fprintln(w, " <div class=\"row\">")
|
|
|
|
fmt.Fprintln(w, " <table class=\"u-full-width\">")
|
2024-01-12 13:52:55 -06:00
|
|
|
// fmt.Fprintln(w, " <thead>")
|
2024-01-12 12:40:54 -06:00
|
|
|
fmt.Fprintln(w, " <tr>")
|
|
|
|
fmt.Fprintln(w, " <th>Package</th>")
|
|
|
|
fmt.Fprintln(w, " <th>go get</th>")
|
|
|
|
fmt.Fprintln(w, " <th>Authoritative sources (IPv6 only)</th>")
|
|
|
|
fmt.Fprintln(w, " <th>github mirror</th>")
|
|
|
|
fmt.Fprintln(w, " <th>Documentation</th>")
|
|
|
|
fmt.Fprintln(w, " </tr>")
|
2024-01-12 13:52:55 -06:00
|
|
|
// fmt.Fprintln(w, " </thead>")
|
2024-01-12 12:40:54 -06:00
|
|
|
fmt.Fprintln(w, " <tbody>")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
}
|
|
|
|
|
2024-01-12 13:52:55 -06:00
|
|
|
func insertHTMLnote(w http.ResponseWriter, i int, parts []string) {
|
|
|
|
log.Info("comment # line:", i, strings.Join(parts, " "))
|
2024-01-12 14:33:30 -06:00
|
|
|
fmt.Fprintln(w, " <tr> <td><h3>", strings.Join(parts, " "), "</h3></td> <td></td> <td></td> <td></td> <td></td> </tr>")
|
2024-01-12 13:52:55 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
log.Info("config file line:", i, line)
|
|
|
|
}
|
|
|
|
log.Info("indexBodyScanConfig() END")
|
|
|
|
}
|
|
|
|
|
|
|
|
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>")
|
2024-01-12 12:26:05 -06:00
|
|
|
fmt.Fprintln(w, " <tr>")
|
2024-01-12 14:33:30 -06:00
|
|
|
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>")
|
|
|
|
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>")
|
2024-01-12 12:26:05 -06:00
|
|
|
fmt.Fprintln(w, " </tr>")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
}
|
|
|
|
|
2024-01-15 16:28:03 -06:00
|
|
|
func indexDivEnd(w http.ResponseWriter) {
|
2024-01-12 12:26:05 -06:00
|
|
|
// fmt.Fprintln(w, "
|
|
|
|
fmt.Fprintln(w, " </tbody>")
|
|
|
|
fmt.Fprintln(w, " </table>")
|
|
|
|
fmt.Fprintln(w, " </div>")
|
|
|
|
fmt.Fprintln(w, " </div>")
|
2024-01-15 16:28:03 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func indexBodyEnd(w http.ResponseWriter) {
|
2024-01-12 12:26:05 -06:00
|
|
|
fmt.Fprintln(w, " </body>")
|
|
|
|
fmt.Fprintln(w, " </html>")
|
|
|
|
}
|