Compare commits
3 Commits
Author | SHA1 | Date |
---|---|---|
vilmibm | 17e95105c8 | |
vilmibm | 890e8e71be | |
vilmibm | 34574c0713 |
|
@ -1,3 +1,4 @@
|
|||
Junk commit
|
||||
# townstats
|
||||
|
||||
This program dumps information about tilde.town in the [Tilde Data Protocol](http://protocol.club/~datagrok/beta-wiki/tdp.html).
|
||||
|
@ -8,4 +9,4 @@ vilmibm, based on python work by [datagrok](https://datagrok.org)
|
|||
|
||||
# license
|
||||
|
||||
gplv3+
|
||||
gplv3+
|
||||
|
|
12
main.go
12
main.go
|
@ -107,7 +107,7 @@ func getNews() (entries []newsEntry, err error) {
|
|||
} else if kv[0] == "title" {
|
||||
current.Title = strings.TrimSpace(kv[1])
|
||||
} else {
|
||||
log.Printf("Ignoring unknown metadata in news entry: %v\n", newsLine)
|
||||
log.Printf("ignoring unknown metadata in news entry: %v\n", newsLine)
|
||||
}
|
||||
if current.Pubdate != "" && current.Title != "" {
|
||||
inMeta = false
|
||||
|
@ -138,7 +138,7 @@ func indexPathFor(username string) (string, error) {
|
|||
}
|
||||
|
||||
if indexPath == "" {
|
||||
return "", fmt.Errorf("Failed to locate index file for %v; tried %v; encountered errors: %v", username, potentialPaths, errs)
|
||||
return "", fmt.Errorf("failed to locate index file for %v; tried %v; encountered errors: %v", username, potentialPaths, errs)
|
||||
}
|
||||
|
||||
return indexPath, nil
|
||||
|
@ -148,12 +148,10 @@ func pageTitleFor(username string) string {
|
|||
pageTitleRe := regexp.MustCompile(`<title[^>]*>(.*)</title>`)
|
||||
indexPath, err := indexPathFor(username)
|
||||
if err != nil {
|
||||
log.Print(err)
|
||||
return ""
|
||||
}
|
||||
content, err := ioutil.ReadFile(indexPath)
|
||||
if err != nil {
|
||||
log.Printf("failed to read %q: %v\n", indexPath, err)
|
||||
return ""
|
||||
}
|
||||
titleMatch := pageTitleRe.FindStringSubmatch(string(content))
|
||||
|
@ -182,7 +180,7 @@ func systemUsers() map[string]bool {
|
|||
func mtimeFor(username string) int64 {
|
||||
path := path.Join(homesDir(), username, "public_html")
|
||||
var maxMtime int64 = 0
|
||||
err := filepath.Walk(path, func(path string, info os.FileInfo, err error) error {
|
||||
_ = filepath.Walk(path, func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -191,9 +189,6 @@ func mtimeFor(username string) int64 {
|
|||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
log.Printf("error walking %q: %v\n", path, err)
|
||||
}
|
||||
|
||||
return maxMtime
|
||||
}
|
||||
|
@ -201,7 +196,6 @@ func mtimeFor(username string) int64 {
|
|||
func detectDefaultPageFor(username string, defaultHTML []byte) bool {
|
||||
indexPath, err := indexPathFor(username)
|
||||
if err != nil {
|
||||
log.Print(err)
|
||||
return false
|
||||
}
|
||||
indexFile, err := os.Open(indexPath)
|
||||
|
|
Loading…
Reference in New Issue