diff --git a/hyphae/hyphae.go b/hyphae/hyphae.go index a8f5bb5..ebd810e 100644 --- a/hyphae/hyphae.go +++ b/hyphae/hyphae.go @@ -2,7 +2,9 @@ package hyphae import ( + "github.com/bouncepaw/mycorrhiza/files" "log" + "path/filepath" "regexp" "sync" ) @@ -19,6 +21,14 @@ type Hypha struct { BinaryPath string // == "" => no attachment } +// TextPartPath returns rooted path to the file where the text part should be. +func (h *Hypha) TextPartPath() string { + if h.TextPath == "" { + return filepath.Join(files.HyphaeDir(), h.Name+".myco") + } + return h.TextPath +} + var byNames = make(map[string]*Hypha) var byNamesMutex = sync.Mutex{} diff --git a/web/readers.go b/web/readers.go index ac22633..f1b797c 100644 --- a/web/readers.go +++ b/web/readers.go @@ -73,7 +73,7 @@ func handlerRevision(w http.ResponseWriter, rq *http.Request) { hyphaName = util.CanonicalName(shorterUrl[firstSlashIndex+1:]) h = hyphae.ByName(hyphaName) contents = fmt.Sprintf(`

This hypha had no text at this revision.

`) - textContents, err = history.FileAtRevision(h.TextPath, revHash) + textContents, err = history.FileAtRevision(h.TextPartPath(), revHash) u = user.FromRequest(rq) ) if err == nil {