Remove extraneous processing

pull/1/head
Case 2022-09-09 19:09:01 -05:00
parent eca0447a35
commit fc7ec910c5
1 changed files with 0 additions and 38 deletions

View File

@ -7,7 +7,6 @@ import (
"fmt" "fmt"
"os" "os"
"os/exec" "os/exec"
"sort"
"text/template" "text/template"
) )
@ -22,23 +21,10 @@ type newsEntry struct {
Content string // HTML of entry Content string // HTML of entry
} }
type User struct {
Username string
Default bool
}
type tildeData struct { type tildeData struct {
News []newsEntry News []newsEntry
Users []User
ActiveUsers []string `json:"active_users"`
} }
type ByName []User
func (n ByName) Len() int { return len(n) }
func (n ByName) Swap(i, j int) { n[i], n[j] = n[j], n[i] }
func (n ByName) Less(i, j int) bool { return n[i].Username < n[j].Username }
func _main() error { func _main() error {
data, err := stats() data, err := stats()
if err != nil { if err != nil {
@ -47,34 +33,10 @@ func _main() error {
type tmplData struct { type tmplData struct {
News []newsEntry News []newsEntry
Lights string
} }
td := &tmplData{ td := &tmplData{
News: data.News, News: data.News,
Lights: "",
}
sort.Sort(ByName(data.Users))
isActive := func(username string) bool {
for _, u := range data.ActiveUsers {
if u == username {
return true
}
}
return false
}
for _, u := range data.Users {
if isActive(u.Username) {
td.Lights += fmt.Sprintf("<a href=\"/~%s\">*</a>", u.Username)
} else if !u.Default {
td.Lights += fmt.Sprintf("<a href=\"/~%s\">+</a>", u.Username)
} else {
td.Lights += "."
}
} }
t, err := template.New("feed").Parse(feedTmpl) t, err := template.New("feed").Parse(feedTmpl)