# emus.patch -rw-r--r-- 1.9 KiB View raw
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
diff -r c69bdb6354f1 web.go
--- a/web.go	Mon Nov 14 14:21:49 2022 -0500
+++ b/web.go	Sat Nov 19 11:44:15 2022 +0000
@@ -50,6 +50,8 @@
 
 var develMode = false
 
+var emunames []string
+
 func getuserstyle(u *login.UserInfo) template.CSS {
 	if u == nil {
 		return ""
@@ -147,6 +149,16 @@
 	honkpage(w, u, honks, templinfo)
 }
 
+func showemus(w http.ResponseWriter, r *http.Request) {
+	templinfo := getInfo(r)
+	templinfo["Emus"] = emunames
+	err := readviews.Execute(w, "emus.html", templinfo)
+	if err != nil {
+	elog.Print(err)
+	}
+}
+
+
 func showfunzone(w http.ResponseWriter, r *http.Request) {
 	var emunames, memenames []string
 	emuext := make(map[string]string)
@@ -2419,9 +2431,26 @@
 	}
 }
 
+func emuinit(){
+        dir, err := os.Open(dataDir + "/emus")
+        if err == nil {
+                emunames, _ = dir.Readdirnames(0)
+                dir.Close()
+        }
+        for i, e := range emunames {
+                if len(e) > 4 {
+                        emunames[i] = e[:len(e)-4]
+                }
+        }
+        sort.Slice(emunames, func(i, j int) bool {
+                    return emunames[i] < emunames[j]
+            })
+}
+
 func serve() {
 	db := opendatabase()
 	login.Init(login.InitArgs{Db: db, Logger: ilog, Insecure: develMode})
+	emuinit()
 
 	listener, err := openListener()
 	if err != nil {
@@ -2445,6 +2474,7 @@
 		viewDir+"/views/honk.html",
 		viewDir+"/views/account.html",
 		viewDir+"/views/about.html",
+		viewDir+"/views/emus.html",
 		viewDir+"/views/funzone.html",
 		viewDir+"/views/login.html",
 		viewDir+"/views/xzone.html",
@@ -2528,6 +2558,7 @@
 	loggedin.Handle("/sendchonk", login.CSRFWrap("sendchonk", http.HandlerFunc(submitchonk)))
 	loggedin.HandleFunc("/saved", homepage)
 	loggedin.HandleFunc("/account", accountpage)
+	loggedin.HandleFunc("/emus", showemus)
 	loggedin.HandleFunc("/funzone", showfunzone)
 	loggedin.HandleFunc("/chpass", dochpass)
 	loggedin.HandleFunc("/atme", homepage)