mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2025-04-13 22:33:19 +00:00
Backlinks: Fix backlinks for media and empty hyphae
This commit is contained in:
parent
3e82c6f189
commit
d8699d46c0
@ -2,6 +2,8 @@ package hyphae
|
||||
|
||||
import (
|
||||
"github.com/bouncepaw/mycorrhiza/util"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// ExistingHypha is not EmptyHypha. *MediaHypha and *TextualHypha implement this interface.
|
||||
@ -59,3 +61,19 @@ func Insert(h ExistingHypha) (madeNewRecord bool) {
|
||||
|
||||
return !recorded
|
||||
}
|
||||
|
||||
func WriteToMycoFile(h ExistingHypha, data []byte) error {
|
||||
if err := os.MkdirAll(filepath.Dir(h.TextFilePath()), 0777); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := os.WriteFile(h.TextFilePath(), data, 0666); err != nil {
|
||||
return err
|
||||
}
|
||||
switch h := h.(type) {
|
||||
case *MediaHypha:
|
||||
if !h.HasTextFile() {
|
||||
h.mycoFilePath = h.TextFilePath()
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -33,11 +33,7 @@ func historyMessageForTextUpload(h hyphae.Hypha, userMessage string) string {
|
||||
}
|
||||
|
||||
func writeTextToDisk(h hyphae.ExistingHypha, data []byte, hop *history.Op) error {
|
||||
if err := os.MkdirAll(filepath.Dir(h.TextFilePath()), 0777); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := os.WriteFile(h.TextFilePath(), data, 0666); err != nil {
|
||||
if err := hyphae.WriteToMycoFile(h, data); err != nil {
|
||||
return err
|
||||
}
|
||||
hop.WithFiles(h.TextFilePath())
|
||||
@ -92,6 +88,7 @@ func UploadText(h hyphae.Hypha, data []byte, userMessage string, u *user.User) e
|
||||
}
|
||||
|
||||
hyphae.Insert(H)
|
||||
backlinks.UpdateBacklinksAfterEdit(H, "")
|
||||
case *hyphae.MediaHypha:
|
||||
oldText, err := FetchTextFile(h)
|
||||
if err != nil {
|
||||
|
@ -31,6 +31,10 @@ type User struct {
|
||||
|
||||
// Route — Right (more is more right)
|
||||
var minimalRights = map[string]int{
|
||||
"text": 0,
|
||||
"backlinks": 0,
|
||||
"history": 0,
|
||||
"attachment": 1,
|
||||
"edit": 1,
|
||||
"upload-binary": 1,
|
||||
"upload-text": 1,
|
||||
|
@ -24,7 +24,7 @@
|
||||
<ul class="hypha-info__list">
|
||||
{%= hyphaInfoEntry(h, u, "history", lc.Get("ui.history_link")) %}
|
||||
{%= hyphaInfoEntry(h, u, "rename", lc.Get("ui.rename_link")) %}
|
||||
{%= hyphaInfoEntry(h, u, "delete-ask", lc.Get("ui.delete_link")) %}
|
||||
{%= hyphaInfoEntry(h, u, "delete", lc.Get("ui.delete_link")) %}
|
||||
{%= hyphaInfoEntry(h, u, "text", lc.Get("ui.text_link")) %}
|
||||
{%= hyphaInfoEntry(h, u, "attachment", lc.Get("ui.attachment_link")) %}
|
||||
{%= hyphaInfoEntry(h, u, "backlinks", lc.GetPlural("ui.backlinks_link", backs)) %}
|
||||
|
@ -127,7 +127,7 @@ func streamhyphaInfo(qw422016 *qt422016.Writer, rq *http.Request, h hyphae.Hypha
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line views/nav.qtpl:27
|
||||
streamhyphaInfoEntry(qw422016, h, u, "delete-ask", lc.Get("ui.delete_link"))
|
||||
streamhyphaInfoEntry(qw422016, h, u, "delete", lc.Get("ui.delete_link"))
|
||||
//line views/nav.qtpl:27
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
|
Loading…
x
Reference in New Issue
Block a user