mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2025-05-04 16:04:04 +00:00
Fix revisions for deleted hyphae
This commit is contained in:
parent
b7d524880f
commit
cbf7ae50d3
@ -3,6 +3,7 @@ package web
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/bouncepaw/mycomarkup/v4"
|
"github.com/bouncepaw/mycomarkup/v4"
|
||||||
|
"github.com/bouncepaw/mycorrhiza/files"
|
||||||
"github.com/bouncepaw/mycorrhiza/shroom"
|
"github.com/bouncepaw/mycorrhiza/shroom"
|
||||||
"github.com/bouncepaw/mycorrhiza/viewutil"
|
"github.com/bouncepaw/mycorrhiza/viewutil"
|
||||||
"io"
|
"io"
|
||||||
@ -99,15 +100,22 @@ func handlerRevision(w http.ResponseWriter, rq *http.Request) {
|
|||||||
h = hyphae.ByName(hyphaName)
|
h = hyphae.ByName(hyphaName)
|
||||||
contents = fmt.Sprintf(`<p>%s</p>`, lc.Get("ui.revision_no_text"))
|
contents = fmt.Sprintf(`<p>%s</p>`, lc.Get("ui.revision_no_text"))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
textContents string
|
||||||
|
err error
|
||||||
|
)
|
||||||
switch h := h.(type) {
|
switch h := h.(type) {
|
||||||
case hyphae.ExistingHypha:
|
case hyphae.ExistingHypha:
|
||||||
var textContents, err = history.FileAtRevision(h.TextFilePath(), revHash)
|
textContents, err = history.FileAtRevision(h.TextFilePath(), revHash)
|
||||||
|
case *hyphae.EmptyHypha:
|
||||||
|
textContents, err = history.FileAtRevision(filepath.Join(files.HyphaeDir(), h.CanonicalName()+".myco"), revHash)
|
||||||
|
}
|
||||||
if err == nil {
|
if err == nil {
|
||||||
ctx, _ := mycocontext.ContextFromStringInput(textContents, shroom.MarkupOptions(hyphaName))
|
ctx, _ := mycocontext.ContextFromStringInput(textContents, shroom.MarkupOptions(hyphaName))
|
||||||
contents = mycomarkup.BlocksToHTML(ctx, mycomarkup.BlockTree(ctx))
|
contents = mycomarkup.BlocksToHTML(ctx, mycomarkup.BlockTree(ctx))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
page := views.Revision(
|
page := views.Revision(
|
||||||
viewutil.MetaFrom(w, rq),
|
viewutil.MetaFrom(w, rq),
|
||||||
h,
|
h,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user