-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsurveyutil.go
64 lines (55 loc) · 1.27 KB
/
surveyutil.go
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
// +build main
package main
import (
"bufio"
"flag"
"fmt"
"github.com/strickyak/carpe-qrss"
"log"
"os"
"path/filepath"
)
var SPOOL = flag.String("spool", "spool/", "spool dir prefix")
func main() {
flag.Parse()
s := carpe.NewSurvey(*SPOOL)
s.UsedOther[*SPOOL+"/index.html"] = true
s.UsedOther[*SPOOL+"index.html"] = true
for i := 0; i < 8; i++ {
filename := fmt.Sprintf("%s/index%d.html", *SPOOL, i)
s.UsedOther[filename] = true
s.UsedOther[filepath.Clean(filename)] = true
}
log.Printf("walking")
s.Walk()
log.Printf("walked")
s.BuildMovies("tmp")
log.Printf("built movies")
s.CollectGarbage()
log.Printf("GCed")
{
fd, err := os.Create(*SPOOL + "/index.html")
carpe.DieIf(err, "os.Create", *SPOOL+"/index.html")
w := bufio.NewWriter(fd)
// s.WriteWebPage(w)
redirect := `<!DOCTYPE html>
<html><head>
<meta http-equiv="refresh"
content="0; url=index0.html">
</head></html>`
fmt.Fprintln(w, redirect)
w.Flush()
fd.Close()
}
for i := 0; i < 8; i++ {
filename := fmt.Sprintf("%s/index%d.html", *SPOOL, i)
fd, err := os.Create(filename)
carpe.DieIf(err, "os.Create", filename)
w := bufio.NewWriter(fd)
s.WriteWebPageForDay(w, i)
w.Flush()
fd.Close()
log.Printf("wrote %q", filename)
}
log.Printf("surveyutil DONE.")
}