forked from tildetown/tilde.town
Remove extraneous processing
parent
eca0447a35
commit
fc7ec910c5
38
genfeed.go
38
genfeed.go
|
@ -7,7 +7,6 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"sort"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
|
@ -22,23 +21,10 @@ type newsEntry struct {
|
|||
Content string // HTML of entry
|
||||
}
|
||||
|
||||
type User struct {
|
||||
Username string
|
||||
Default bool
|
||||
}
|
||||
|
||||
type tildeData struct {
|
||||
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 {
|
||||
data, err := stats()
|
||||
if err != nil {
|
||||
|
@ -47,34 +33,10 @@ func _main() error {
|
|||
|
||||
type tmplData struct {
|
||||
News []newsEntry
|
||||
Lights string
|
||||
}
|
||||
|
||||
td := &tmplData{
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue