mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2025-05-07 17:14:06 +00:00
Rename MediaHypha to NonEmptyHypha
This commit is contained in:
parent
002e9f7a93
commit
6fc5cf994e
@ -4,7 +4,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Its value is number of all existing hyphae. MediaHypha mutators are expected to manipulate the value. It is concurrent-safe.
|
// Its value is number of all existing hyphae. NonEmptyHypha mutators are expected to manipulate the value. It is concurrent-safe.
|
||||||
var count = struct {
|
var count = struct {
|
||||||
value int
|
value int
|
||||||
sync.Mutex
|
sync.Mutex
|
||||||
|
@ -27,8 +27,8 @@ func NewEmptyHypha(hyphaName string) *EmptyHypha {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func FillEmptyHyphaUpToTextualHypha(e *EmptyHypha, textPath string) *MediaHypha { // sic!
|
func FillEmptyHyphaUpToTextualHypha(e *EmptyHypha, textPath string) *NonEmptyHypha { // sic!
|
||||||
return &MediaHypha{
|
return &NonEmptyHypha{
|
||||||
name: e.CanonicalName(),
|
name: e.CanonicalName(),
|
||||||
TextPath: textPath,
|
TextPath: textPath,
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ func Index(path string) {
|
|||||||
insert(nh)
|
insert(nh)
|
||||||
default:
|
default:
|
||||||
// In case of conflicts the newer hypha overwrites the previous
|
// In case of conflicts the newer hypha overwrites the previous
|
||||||
switch nh, oh := nh.(*MediaHypha), oh.(*MediaHypha); {
|
switch nh, oh := nh.(*NonEmptyHypha), oh.(*NonEmptyHypha); {
|
||||||
case (nh.Kind() == HyphaText) && (oh.Kind() == HyphaMedia):
|
case (nh.Kind() == HyphaText) && (oh.Kind() == HyphaMedia):
|
||||||
oh.TextPath = nh.TextPartPath()
|
oh.TextPath = nh.TextPartPath()
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ func indexHelper(path string, nestLevel uint, ch chan Hypher) {
|
|||||||
var (
|
var (
|
||||||
hyphaPartPath = filepath.Join(path, node.Name())
|
hyphaPartPath = filepath.Join(path, node.Name())
|
||||||
hyphaName, isText, skip = mimetype.DataFromFilename(hyphaPartPath)
|
hyphaName, isText, skip = mimetype.DataFromFilename(hyphaPartPath)
|
||||||
hypha = &MediaHypha{name: hyphaName, Exists: true}
|
hypha = &NonEmptyHypha{name: hyphaName, Exists: true}
|
||||||
)
|
)
|
||||||
if !skip {
|
if !skip {
|
||||||
if isText {
|
if isText {
|
||||||
|
@ -29,7 +29,7 @@ const (
|
|||||||
HyphaMedia
|
HyphaMedia
|
||||||
)
|
)
|
||||||
|
|
||||||
// Hypher is a temporary name for this interface. The name will become MediaHypha, once the struct with the said name is deprecated for good.
|
// Hypher is a temporary name for this interface. The name will become NonEmptyHypha, once the struct with the said name is deprecated for good.
|
||||||
type Hypher interface {
|
type Hypher interface {
|
||||||
sync.Locker
|
sync.Locker
|
||||||
|
|
||||||
@ -54,8 +54,8 @@ func RenameHyphaTo(h Hypher, newName string) {
|
|||||||
byNamesMutex.Lock()
|
byNamesMutex.Lock()
|
||||||
h.Lock()
|
h.Lock()
|
||||||
delete(byNames, h.CanonicalName())
|
delete(byNames, h.CanonicalName())
|
||||||
h.(*MediaHypha).SetName(newName)
|
h.(*NonEmptyHypha).SetName(newName)
|
||||||
byNames[h.CanonicalName()] = h.(*MediaHypha)
|
byNames[h.CanonicalName()] = h.(*NonEmptyHypha)
|
||||||
byNamesMutex.Unlock()
|
byNamesMutex.Unlock()
|
||||||
h.Unlock()
|
h.Unlock()
|
||||||
}
|
}
|
||||||
|
@ -1,52 +0,0 @@
|
|||||||
// Package hyphae is for the MediaHypha type, hypha storage and stuff like that. It shall not depend on mycorrhiza modules other than util.
|
|
||||||
package hyphae
|
|
||||||
|
|
||||||
import (
|
|
||||||
"path/filepath"
|
|
||||||
"sync"
|
|
||||||
|
|
||||||
"github.com/bouncepaw/mycorrhiza/files"
|
|
||||||
)
|
|
||||||
|
|
||||||
// MediaHypha keeps vital information about a media hypha
|
|
||||||
type MediaHypha struct {
|
|
||||||
sync.RWMutex
|
|
||||||
|
|
||||||
name string // Canonical name
|
|
||||||
Exists bool
|
|
||||||
TextPath string // == "" => no text part
|
|
||||||
binaryPath string // == "" => no attachment
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *MediaHypha) SetName(s string) { h.name = s }
|
|
||||||
|
|
||||||
func (h *MediaHypha) BinaryPath() string { return h.binaryPath }
|
|
||||||
func (h *MediaHypha) SetBinaryPath(s string) { h.binaryPath = s }
|
|
||||||
|
|
||||||
func (h *MediaHypha) CanonicalName() string {
|
|
||||||
return h.name
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *MediaHypha) Kind() HyphaKind { // sic!
|
|
||||||
if h.HasAttachment() {
|
|
||||||
return HyphaMedia
|
|
||||||
}
|
|
||||||
return HyphaText
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *MediaHypha) HasTextPart() bool {
|
|
||||||
return h.TextPath != ""
|
|
||||||
}
|
|
||||||
|
|
||||||
// TextPartPath returns rooted path to the file where the text part should be.
|
|
||||||
func (h *MediaHypha) TextPartPath() string {
|
|
||||||
if h.TextPath == "" {
|
|
||||||
return filepath.Join(files.HyphaeDir(), h.name+".myco")
|
|
||||||
}
|
|
||||||
return h.TextPath
|
|
||||||
}
|
|
||||||
|
|
||||||
// HasAttachment is true if the hypha has an attachment.
|
|
||||||
func (h *MediaHypha) HasAttachment() bool {
|
|
||||||
return h.binaryPath != ""
|
|
||||||
}
|
|
52
hyphae/non_empty_hypha.go
Normal file
52
hyphae/non_empty_hypha.go
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
// Package hyphae is for the NonEmptyHypha type, hypha storage and stuff like that. It shall not depend on mycorrhiza modules other than util.
|
||||||
|
package hyphae
|
||||||
|
|
||||||
|
import (
|
||||||
|
"path/filepath"
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"github.com/bouncepaw/mycorrhiza/files"
|
||||||
|
)
|
||||||
|
|
||||||
|
// NonEmptyHypha keeps vital information about a media hypha
|
||||||
|
type NonEmptyHypha struct {
|
||||||
|
sync.RWMutex
|
||||||
|
|
||||||
|
name string // Canonical name
|
||||||
|
Exists bool
|
||||||
|
TextPath string // == "" => no text part
|
||||||
|
binaryPath string // == "" => no attachment
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *NonEmptyHypha) SetName(s string) { h.name = s }
|
||||||
|
|
||||||
|
func (h *NonEmptyHypha) BinaryPath() string { return h.binaryPath }
|
||||||
|
func (h *NonEmptyHypha) SetBinaryPath(s string) { h.binaryPath = s }
|
||||||
|
|
||||||
|
func (h *NonEmptyHypha) CanonicalName() string {
|
||||||
|
return h.name
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *NonEmptyHypha) Kind() HyphaKind { // sic!
|
||||||
|
if h.HasAttachment() {
|
||||||
|
return HyphaMedia
|
||||||
|
}
|
||||||
|
return HyphaText
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *NonEmptyHypha) HasTextPart() bool {
|
||||||
|
return h.TextPath != ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// TextPartPath returns rooted path to the file where the text part should be.
|
||||||
|
func (h *NonEmptyHypha) TextPartPath() string {
|
||||||
|
if h.TextPath == "" {
|
||||||
|
return filepath.Join(files.HyphaeDir(), h.name+".myco")
|
||||||
|
}
|
||||||
|
return h.TextPath
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasAttachment is true if the hypha has an attachment.
|
||||||
|
func (h *NonEmptyHypha) HasAttachment() bool {
|
||||||
|
return h.binaryPath != ""
|
||||||
|
}
|
@ -69,7 +69,7 @@ var (
|
|||||||
func(h hyphae.Hypher, u *user.User, lc *l18n.Localizer) (errmsg, errtitle string) {
|
func(h hyphae.Hypher, u *user.User, lc *l18n.Localizer) (errmsg, errtitle string) {
|
||||||
switch h := h.(type) {
|
switch h := h.(type) {
|
||||||
case *hyphae.EmptyHypha:
|
case *hyphae.EmptyHypha:
|
||||||
case *hyphae.MediaHypha:
|
case *hyphae.NonEmptyHypha:
|
||||||
if h.Kind() != hyphae.HyphaMedia {
|
if h.Kind() != hyphae.HyphaMedia {
|
||||||
rejectUnattachLog(h, u, "no amnt")
|
rejectUnattachLog(h, u, "no amnt")
|
||||||
return lc.Get("ui.act_noattachment_tip"), lc.Get("ui.act_noattachment")
|
return lc.Get("ui.act_noattachment_tip"), lc.Get("ui.act_noattachment")
|
||||||
|
@ -21,7 +21,7 @@ func DeleteHypha(u *user.User, h hyphae.Hypher, lc *l18n.Localizer) (hop *histor
|
|||||||
|
|
||||||
originalText, _ := FetchTextPart(h)
|
originalText, _ := FetchTextPart(h)
|
||||||
hop.
|
hop.
|
||||||
WithFilesRemoved(h.TextPartPath(), h.(*hyphae.MediaHypha).BinaryPath()).
|
WithFilesRemoved(h.TextPartPath(), h.(*hyphae.NonEmptyHypha).BinaryPath()).
|
||||||
WithMsg(fmt.Sprintf("Delete ‘%s’", h.CanonicalName())).
|
WithMsg(fmt.Sprintf("Delete ‘%s’", h.CanonicalName())).
|
||||||
WithUser(u).
|
WithUser(u).
|
||||||
Apply()
|
Apply()
|
||||||
|
@ -24,7 +24,7 @@ func init() {
|
|||||||
err = errors.New("Hypha " + hyphaName + " does not exist")
|
err = errors.New("Hypha " + hyphaName + " does not exist")
|
||||||
default:
|
default:
|
||||||
rawText, err = FetchTextPart(h)
|
rawText, err = FetchTextPart(h)
|
||||||
if h := h.(*hyphae.MediaHypha); h.Kind() == hyphae.HyphaMedia {
|
if h := h.(*hyphae.NonEmptyHypha); h.Kind() == hyphae.HyphaMedia {
|
||||||
// the view is localized, but we can't pass it, so...
|
// the view is localized, but we can't pass it, so...
|
||||||
binaryBlock = views.AttachmentHTMLRaw(h)
|
binaryBlock = views.AttachmentHTMLRaw(h)
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ func RenameHypha(h hyphae.Hypher, newHypha hyphae.Hypher, recursive bool, u *use
|
|||||||
Apply()
|
Apply()
|
||||||
if len(hop.Errs) == 0 {
|
if len(hop.Errs) == 0 {
|
||||||
for _, h := range hyphaeToRename {
|
for _, h := range hyphaeToRename {
|
||||||
h := h.(*hyphae.MediaHypha) // ontology think
|
h := h.(*hyphae.NonEmptyHypha) // ontology think
|
||||||
oldName := h.CanonicalName()
|
oldName := h.CanonicalName()
|
||||||
hyphae.RenameHyphaTo(h, replaceName(h.CanonicalName()))
|
hyphae.RenameHyphaTo(h, replaceName(h.CanonicalName()))
|
||||||
h.Lock()
|
h.Lock()
|
||||||
@ -102,7 +102,7 @@ func renamingPairs(hyphaeToRename []hyphae.Hypher, replaceName func(string) stri
|
|||||||
renameMap[h.TextPartPath()] = replaceName(h.TextPartPath())
|
renameMap[h.TextPartPath()] = replaceName(h.TextPartPath())
|
||||||
}
|
}
|
||||||
switch h := h.(type) {
|
switch h := h.(type) {
|
||||||
case *hyphae.MediaHypha:
|
case *hyphae.NonEmptyHypha:
|
||||||
if h.Kind() == hyphae.HyphaMedia { // ontology think
|
if h.Kind() == hyphae.HyphaMedia { // ontology think
|
||||||
renameMap[h.BinaryPath()] = replaceName(h.BinaryPath())
|
renameMap[h.BinaryPath()] = replaceName(h.BinaryPath())
|
||||||
}
|
}
|
||||||
@ -110,7 +110,7 @@ func renamingPairs(hyphaeToRename []hyphae.Hypher, replaceName func(string) stri
|
|||||||
h.Unlock()
|
h.Unlock()
|
||||||
}
|
}
|
||||||
if firstFailure, ok := hyphae.AreFreeNames(newNames...); !ok {
|
if firstFailure, ok := hyphae.AreFreeNames(newNames...); !ok {
|
||||||
return nil, errors.New("MediaHypha " + firstFailure + " already exists")
|
return nil, errors.New("NonEmptyHypha " + firstFailure + " already exists")
|
||||||
}
|
}
|
||||||
return renameMap, nil
|
return renameMap, nil
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ func UnattachHypha(u *user.User, h hyphae.Hypher, lc *l18n.Localizer) (hop *hist
|
|||||||
hop.WithErrAbort(err)
|
hop.WithErrAbort(err)
|
||||||
return hop, errtitle
|
return hop, errtitle
|
||||||
}
|
}
|
||||||
H := h.(*hyphae.MediaHypha)
|
H := h.(*hyphae.NonEmptyHypha)
|
||||||
|
|
||||||
hop.
|
hop.
|
||||||
WithFilesRemoved(H.BinaryPath()).
|
WithFilesRemoved(H.BinaryPath()).
|
||||||
|
@ -41,7 +41,7 @@ func writeTextToDiskForEmptyHypha(eh *hyphae.EmptyHypha, data []byte) error {
|
|||||||
return writeTextToDiskForNonEmptyHypha(h, data)
|
return writeTextToDiskForNonEmptyHypha(h, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeTextToDiskForNonEmptyHypha(h *hyphae.MediaHypha, data []byte) error {
|
func writeTextToDiskForNonEmptyHypha(h *hyphae.NonEmptyHypha, data []byte) error {
|
||||||
if err := os.MkdirAll(filepath.Dir(h.TextPartPath()), 0777); err != nil {
|
if err := os.MkdirAll(filepath.Dir(h.TextPartPath()), 0777); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -77,7 +77,7 @@ func UploadText(h hyphae.Hypher, data []byte, userMessage string, u *user.User,
|
|||||||
case *hyphae.EmptyHypha:
|
case *hyphae.EmptyHypha:
|
||||||
// It's ok, just like cancel button.
|
// It's ok, just like cancel button.
|
||||||
return hop.Abort(), ""
|
return hop.Abort(), ""
|
||||||
case *hyphae.MediaHypha:
|
case *hyphae.NonEmptyHypha:
|
||||||
switch h.Kind() {
|
switch h.Kind() {
|
||||||
case hyphae.HyphaMedia:
|
case hyphae.HyphaMedia:
|
||||||
// Writing no description, it's ok, just like cancel button.
|
// Writing no description, it's ok, just like cancel button.
|
||||||
@ -99,7 +99,7 @@ func UploadText(h hyphae.Hypher, data []byte, userMessage string, u *user.User,
|
|||||||
}
|
}
|
||||||
|
|
||||||
hyphae.InsertIfNew(h)
|
hyphae.InsertIfNew(h)
|
||||||
case *hyphae.MediaHypha:
|
case *hyphae.NonEmptyHypha:
|
||||||
oldText, err := FetchTextPart(h)
|
oldText, err := FetchTextPart(h)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return hop.WithErrAbort(err), err.Error()
|
return hop.WithErrAbort(err), err.Error()
|
||||||
@ -152,7 +152,7 @@ func UploadBinary(h hyphae.Hypher, mime string, file multipart.File, u *user.Use
|
|||||||
err := errors.New("bad path")
|
err := errors.New("bad path")
|
||||||
return hop.WithErrAbort(err), err.Error()
|
return hop.WithErrAbort(err), err.Error()
|
||||||
}
|
}
|
||||||
if h := h.(*hyphae.MediaHypha); hop.Type == history.TypeEditBinary {
|
if h := h.(*hyphae.NonEmptyHypha); hop.Type == history.TypeEditBinary {
|
||||||
sourceFullPath = h.BinaryPath()
|
sourceFullPath = h.BinaryPath()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ func UploadBinary(h hyphae.Hypher, mime string, file multipart.File, u *user.Use
|
|||||||
}
|
}
|
||||||
|
|
||||||
// sic!
|
// sic!
|
||||||
h.(*hyphae.MediaHypha).SetBinaryPath(fullPath)
|
h.(*hyphae.NonEmptyHypha).SetBinaryPath(fullPath)
|
||||||
return hop.WithFiles(fullPath).WithUser(u).Apply(), ""
|
return hop.WithFiles(fullPath).WithUser(u).Apply(), ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ func findSiblings(hyphaName string) []*sibling {
|
|||||||
siblingsMap = make(map[string]bool)
|
siblingsMap = make(map[string]bool)
|
||||||
siblingCheck = func(h hyphae.Hypher) hyphae.CheckResult {
|
siblingCheck = func(h hyphae.Hypher) hyphae.CheckResult {
|
||||||
switch {
|
switch {
|
||||||
case h.CanonicalName() == hyphaName, // MediaHypha is no sibling of itself
|
case h.CanonicalName() == hyphaName, // NonEmptyHypha is no sibling of itself
|
||||||
h.CanonicalName() == parentHyphaName: // Parent hypha is no sibling of its child
|
h.CanonicalName() == parentHyphaName: // Parent hypha is no sibling of its child
|
||||||
return hyphae.CheckContinue
|
return hyphae.CheckContinue
|
||||||
}
|
}
|
||||||
|
@ -75,9 +75,9 @@
|
|||||||
</h1>
|
</h1>
|
||||||
{% endfunc %}
|
{% endfunc %}
|
||||||
|
|
||||||
{% func AttachmentHTMLRaw(h *hyphae.MediaHypha) %}{%= AttachmentHTML(h, l18n.New("en", "en")) %}{% endfunc %}
|
{% func AttachmentHTMLRaw(h *hyphae.NonEmptyHypha) %}{%= AttachmentHTML(h, l18n.New("en", "en")) %}{% endfunc %}
|
||||||
|
|
||||||
{% func AttachmentHTML(h *hyphae.MediaHypha, lc *l18n.Localizer) %}
|
{% func AttachmentHTML(h *hyphae.NonEmptyHypha, lc *l18n.Localizer) %}
|
||||||
{% switch filepath.Ext(h.BinaryPath()) %}
|
{% switch filepath.Ext(h.BinaryPath()) %}
|
||||||
|
|
||||||
{% case ".jpg", ".gif", ".png", ".webp", ".svg", ".ico" %}
|
{% case ".jpg", ".gif", ".png", ".webp", ".svg", ".ico" %}
|
||||||
|
@ -349,14 +349,14 @@ func NaviTitleHTML(h hyphae.Hypher) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//line views/hypha.qtpl:78
|
//line views/hypha.qtpl:78
|
||||||
func StreamAttachmentHTMLRaw(qw422016 *qt422016.Writer, h *hyphae.MediaHypha) {
|
func StreamAttachmentHTMLRaw(qw422016 *qt422016.Writer, h *hyphae.NonEmptyHypha) {
|
||||||
//line views/hypha.qtpl:78
|
//line views/hypha.qtpl:78
|
||||||
StreamAttachmentHTML(qw422016, h, l18n.New("en", "en"))
|
StreamAttachmentHTML(qw422016, h, l18n.New("en", "en"))
|
||||||
//line views/hypha.qtpl:78
|
//line views/hypha.qtpl:78
|
||||||
}
|
}
|
||||||
|
|
||||||
//line views/hypha.qtpl:78
|
//line views/hypha.qtpl:78
|
||||||
func WriteAttachmentHTMLRaw(qq422016 qtio422016.Writer, h *hyphae.MediaHypha) {
|
func WriteAttachmentHTMLRaw(qq422016 qtio422016.Writer, h *hyphae.NonEmptyHypha) {
|
||||||
//line views/hypha.qtpl:78
|
//line views/hypha.qtpl:78
|
||||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||||
//line views/hypha.qtpl:78
|
//line views/hypha.qtpl:78
|
||||||
@ -367,7 +367,7 @@ func WriteAttachmentHTMLRaw(qq422016 qtio422016.Writer, h *hyphae.MediaHypha) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//line views/hypha.qtpl:78
|
//line views/hypha.qtpl:78
|
||||||
func AttachmentHTMLRaw(h *hyphae.MediaHypha) string {
|
func AttachmentHTMLRaw(h *hyphae.NonEmptyHypha) string {
|
||||||
//line views/hypha.qtpl:78
|
//line views/hypha.qtpl:78
|
||||||
qb422016 := qt422016.AcquireByteBuffer()
|
qb422016 := qt422016.AcquireByteBuffer()
|
||||||
//line views/hypha.qtpl:78
|
//line views/hypha.qtpl:78
|
||||||
@ -382,7 +382,7 @@ func AttachmentHTMLRaw(h *hyphae.MediaHypha) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//line views/hypha.qtpl:80
|
//line views/hypha.qtpl:80
|
||||||
func StreamAttachmentHTML(qw422016 *qt422016.Writer, h *hyphae.MediaHypha, lc *l18n.Localizer) {
|
func StreamAttachmentHTML(qw422016 *qt422016.Writer, h *hyphae.NonEmptyHypha, lc *l18n.Localizer) {
|
||||||
//line views/hypha.qtpl:80
|
//line views/hypha.qtpl:80
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
`)
|
`)
|
||||||
@ -486,7 +486,7 @@ func StreamAttachmentHTML(qw422016 *qt422016.Writer, h *hyphae.MediaHypha, lc *l
|
|||||||
}
|
}
|
||||||
|
|
||||||
//line views/hypha.qtpl:109
|
//line views/hypha.qtpl:109
|
||||||
func WriteAttachmentHTML(qq422016 qtio422016.Writer, h *hyphae.MediaHypha, lc *l18n.Localizer) {
|
func WriteAttachmentHTML(qq422016 qtio422016.Writer, h *hyphae.NonEmptyHypha, lc *l18n.Localizer) {
|
||||||
//line views/hypha.qtpl:109
|
//line views/hypha.qtpl:109
|
||||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||||
//line views/hypha.qtpl:109
|
//line views/hypha.qtpl:109
|
||||||
@ -497,7 +497,7 @@ func WriteAttachmentHTML(qq422016 qtio422016.Writer, h *hyphae.MediaHypha, lc *l
|
|||||||
}
|
}
|
||||||
|
|
||||||
//line views/hypha.qtpl:109
|
//line views/hypha.qtpl:109
|
||||||
func AttachmentHTML(h *hyphae.MediaHypha, lc *l18n.Localizer) string {
|
func AttachmentHTML(h *hyphae.NonEmptyHypha, lc *l18n.Localizer) string {
|
||||||
//line views/hypha.qtpl:109
|
//line views/hypha.qtpl:109
|
||||||
qb422016 := qt422016.AcquireByteBuffer()
|
qb422016 := qt422016.AcquireByteBuffer()
|
||||||
//line views/hypha.qtpl:109
|
//line views/hypha.qtpl:109
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
{% import "github.com/bouncepaw/mycorrhiza/user" %}
|
{% import "github.com/bouncepaw/mycorrhiza/user" %}
|
||||||
{% import "github.com/bouncepaw/mycorrhiza/util" %}
|
{% import "github.com/bouncepaw/mycorrhiza/util" %}
|
||||||
|
|
||||||
{% func AttachmentMenuHTML(rq *http.Request, h *hyphae.MediaHypha, u *user.User) %}
|
{% func AttachmentMenuHTML(rq *http.Request, h *hyphae.NonEmptyHypha, u *user.User) %}
|
||||||
{% code
|
{% code
|
||||||
lc := l18n.FromRequest(rq)
|
lc := l18n.FromRequest(rq)
|
||||||
%}
|
%}
|
||||||
|
@ -262,7 +262,7 @@ sort.Strings(editors)
|
|||||||
close(hyphaNames)
|
close(hyphaNames)
|
||||||
%}
|
%}
|
||||||
{% for hyphaName := range sortedHypha %}
|
{% for hyphaName := range sortedHypha %}
|
||||||
{% code hypha := hyphae.ByName(hyphaName).(*hyphae.MediaHypha) %}
|
{% code hypha := hyphae.ByName(hyphaName).(*hyphae.NonEmptyHypha) %}
|
||||||
<li class="hypha-list__entry">
|
<li class="hypha-list__entry">
|
||||||
<a class="hypha-list__link" href="/hypha/{%s hypha.CanonicalName() %}">
|
<a class="hypha-list__link" href="/hypha/{%s hypha.CanonicalName() %}">
|
||||||
{%s util.BeautifulName(hypha.CanonicalName()) %}
|
{%s util.BeautifulName(hypha.CanonicalName()) %}
|
||||||
|
@ -47,7 +47,7 @@ func handlerAttachment(w http.ResponseWriter, rq *http.Request) {
|
|||||||
util.HTTP200Page(w,
|
util.HTTP200Page(w,
|
||||||
views.BaseHTML(
|
views.BaseHTML(
|
||||||
lc.Get("ui.attach_title", &l18n.Replacements{"name": util.BeautifulName(hyphaName)}),
|
lc.Get("ui.attach_title", &l18n.Replacements{"name": util.BeautifulName(hyphaName)}),
|
||||||
views.AttachmentMenuHTML(rq, h.(*hyphae.MediaHypha), u),
|
views.AttachmentMenuHTML(rq, h.(*hyphae.NonEmptyHypha), u),
|
||||||
lc,
|
lc,
|
||||||
u))
|
u))
|
||||||
}
|
}
|
||||||
@ -154,7 +154,7 @@ func handlerBinary(w http.ResponseWriter, rq *http.Request) {
|
|||||||
switch h := hyphae.ByName(hyphaName).(type) {
|
switch h := hyphae.ByName(hyphaName).(type) {
|
||||||
case *hyphae.EmptyHypha:
|
case *hyphae.EmptyHypha:
|
||||||
default: // TODO: deindent
|
default: // TODO: deindent
|
||||||
switch h := h.(*hyphae.MediaHypha); h.Kind() {
|
switch h := h.(*hyphae.NonEmptyHypha); h.Kind() {
|
||||||
case hyphae.HyphaText:
|
case hyphae.HyphaText:
|
||||||
w.WriteHeader(http.StatusNotFound)
|
w.WriteHeader(http.StatusNotFound)
|
||||||
log.Printf("Textual hypha ‘%s’ has no media, cannot serve\n", h.CanonicalName())
|
log.Printf("Textual hypha ‘%s’ has no media, cannot serve\n", h.CanonicalName())
|
||||||
@ -187,7 +187,7 @@ func handlerHypha(w http.ResponseWriter, rq *http.Request) {
|
|||||||
lc,
|
lc,
|
||||||
u,
|
u,
|
||||||
openGraph))
|
openGraph))
|
||||||
case *hyphae.MediaHypha:
|
case *hyphae.NonEmptyHypha:
|
||||||
fileContentsT, errT := os.ReadFile(h.TextPartPath())
|
fileContentsT, errT := os.ReadFile(h.TextPartPath())
|
||||||
if errT == nil {
|
if errT == nil {
|
||||||
ctx, _ := mycocontext.ContextFromStringInput(hyphaName, string(fileContentsT))
|
ctx, _ := mycocontext.ContextFromStringInput(hyphaName, string(fileContentsT))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user