summaryrefslogtreecommitdiff
path: root/repoHTML.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 /repoHTML.go
parent9ff813b0ad6a68c2aad8f6a7365b452a19c07457 (diff)
add versions and timestamps
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'repoHTML.go')
-rw-r--r--repoHTML.go61
1 files changed, 40 insertions, 21 deletions
diff --git a/repoHTML.go b/repoHTML.go
index 0cba639..24b20c5 100644
--- a/repoHTML.go
+++ b/repoHTML.go
@@ -1,13 +1,16 @@
package main
import (
+ "bufio"
"fmt"
- "strings"
- "go.wit.com/log"
"net/http"
+ "os"
+ "path/filepath"
"sort"
-)
+ "strings"
+ "go.wit.com/log"
+)
/*
<!DOCTYPE html>
@@ -29,32 +32,28 @@ func repoHTML(w http.ResponseWriter, gourl string, realurl string) {
fmt.Fprintln(w, "<!DOCTYPE html>")
fmt.Fprintln(w, "<html>")
fmt.Fprintln(w, "<head>")
- // fmt.Fprintln(w,
- fmt.Fprintln(w, "<meta name=\"go-import\" content=\"", gourl, "git", realurl + "\">")
- fmt.Fprintln(w, "<meta name=\"go-source\" content=\"", gourl, realurl, realurl + "/tree/master{/dir}", realurl + "tree/master{/dir}/{file}#L{line}", "\"", ">")
+ // fmt.Fprintln(w,
+ fmt.Fprintln(w, "<meta name=\"go-import\" content=\"", gourl, "git", realurl+"\">")
+ fmt.Fprintln(w, "<meta name=\"go-source\" content=\"", gourl, realurl, realurl+"/tree/master{/dir}", realurl+"tree/master{/dir}/{file}#L{line}", "\"", ">")
- fmt.Fprintln(w, "<meta http-equiv=\"refresh\" content=\"0; url=" + realurl + "\">")
+ fmt.Fprintln(w, "<meta http-equiv=\"refresh\" content=\"0; url="+realurl+"\">")
fmt.Fprintln(w, "</head>")
fmt.Fprintln(w, "<body>")
- fmt.Fprintln(w, "Nothing to see here. Please <a href=\"" + realurl + "\">move along</a>.\"")
+ fmt.Fprintln(w, "Nothing to see here. Please <a href=\""+realurl+"\">move along</a>.\"")
fmt.Fprintln(w, "</body>")
fmt.Fprintln(w, "</html>")
/*
- var tmp string
- tmp = r.URL.String()
- if tmp == "/gui" {
- findFile(w)
- return
- }
- fmt.Fprintln(w, "OK")
+ var tmp string
+ tmp = r.URL.String()
+ if tmp == "/gui" {
+ findFile(w)
+ return
+ }
+ fmt.Fprintln(w, "OK")
*/
}
-var repoMap map[string]string
-var configfile []string
-var keysSorted []string
-
func findkey(url string) (string, string) {
key := "go.wit.com" + url
if repoMap[key] != "" {
@@ -74,7 +73,7 @@ func readconfigfile() {
configfile = strings.Split(string(pfile), "\n")
for _, line := range configfile {
fields := strings.Fields(line)
- if (len(fields) < 2) {
+ if len(fields) < 2 {
continue
}
repo := fields[0]
@@ -84,7 +83,6 @@ func readconfigfile() {
// log.Info("repo =", repo, "real url =", realurl)
}
-
for repo, _ := range repoMap {
// log.Info("repo =", repo, "real url =", url)
keysSorted = append(keysSorted, repo)
@@ -97,3 +95,24 @@ func readconfigfile() {
log.Info("repo =", key, "real url =", repoMap[key])
}
}
+
+func readVersionFile() {
+ versionMap = make(map[string]string)
+ file, err := os.Open(filepath.Join(os.Getenv("HOME"), "go.wit.com.versions"))
+ if err != nil {
+ return
+ }
+ defer file.Close()
+
+ scanner := bufio.NewScanner(file)
+ for scanner.Scan() {
+ tmp := scanner.Text()
+ fields := strings.Split(tmp, " ")
+ if len(fields) < 2 {
+ continue
+ }
+ // log.Println("readVersionFile() fields[0] =", fields[0])
+ // log.Println("readVersionFile() fields[1:] =", fields[1:])
+ versionMap[fields[0]] = strings.Join(fields[1:], " ")
+ }
+}