Please note that viewing binary parts of hyphae is not supported in history for now.
%[2]s
%[3]s
`, hyphaName,
naviTitle(hyphaName),
contents,
tree.TreeAsHtml(hyphaName, IterateHyphaNamesWith),
revHash)
w.Header().Set("Content-Type", "text/html;charset=utf-8")
w.WriteHeader(http.StatusOK)
w.Write([]byte(base(hyphaName, form)))
}
// handlerHistory lists all revisions of a hypha
func handlerHistory(w http.ResponseWriter, rq *http.Request) {
log.Println(rq.URL)
hyphaName := HyphaNameFromRq(rq, "history")
var tbody string
if _, ok := HyphaStorage[hyphaName]; ok {
revs, err := history.Revisions(hyphaName)
if err == nil {
for _, rev := range revs {
tbody += rev.AsHtmlTableRow(hyphaName)
}
}
log.Println(revs)
}
table := fmt.Sprintf(`
Hash
Username
Time
Message
%[2]s
`, hyphaName, tbody)
w.Header().Set("Content-Type", "text/html;charset=utf-8")
w.WriteHeader(http.StatusOK)
w.Write([]byte(base(hyphaName, table)))
}
// handlerText serves raw source text of the hypha.
func handlerText(w http.ResponseWriter, rq *http.Request) {
log.Println(rq.URL)
hyphaName := HyphaNameFromRq(rq, "text")
if data, ok := HyphaStorage[hyphaName]; ok {
log.Println("Serving", data.textPath)
w.Header().Set("Content-Type", data.textType.Mime())
http.ServeFile(w, rq, data.textPath)
}
}
// handlerBinary serves binary part of the hypha.
func handlerBinary(w http.ResponseWriter, rq *http.Request) {
log.Println(rq.URL)
hyphaName := HyphaNameFromRq(rq, "binary")
if data, ok := HyphaStorage[hyphaName]; ok {
log.Println("Serving", data.binaryPath)
w.Header().Set("Content-Type", data.binaryType.Mime())
http.ServeFile(w, rq, data.binaryPath)
}
}
// handlerPage is the main hypha action that displays the hypha and the binary upload form along with some navigation.
func handlerPage(w http.ResponseWriter, rq *http.Request) {
log.Println(rq.URL)
var (
hyphaName = HyphaNameFromRq(rq, "page")
contents = fmt.Sprintf(`