mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2025-01-07 02:10:26 +00:00
Rename Hypha to MediaHypha
This commit is contained in:
parent
154069091e
commit
a30d581bfd
@ -4,7 +4,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Its value is number of all existing hyphae. Hypha mutators are expected to manipulate the value. It is concurrent-safe.
|
// Its value is number of all existing hyphae. MediaHypha 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
|
||||||
|
@ -21,9 +21,9 @@ func Index(path string) {
|
|||||||
for h := range ch {
|
for h := range ch {
|
||||||
// It's safe to ignore the mutex because there is a single worker right now.
|
// It's safe to ignore the mutex because there is a single worker right now.
|
||||||
if oh := ByName(h.CanonicalName()); oh.DoesExist() {
|
if oh := ByName(h.CanonicalName()); oh.DoesExist() {
|
||||||
oh.(*Hypha).mergeIn(h.(*Hypha))
|
oh.(*MediaHypha).mergeIn(h.(*MediaHypha))
|
||||||
} else {
|
} else {
|
||||||
insert(h.(*Hypha))
|
insert(h.(*MediaHypha))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.Println("Indexed", Count(), "hyphae")
|
log.Println("Indexed", Count(), "hyphae")
|
||||||
@ -49,7 +49,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 = &Hypha{name: hyphaName, Exists: true}
|
hypha = &MediaHypha{name: hyphaName, Exists: true}
|
||||||
)
|
)
|
||||||
if !skip {
|
if !skip {
|
||||||
if isText {
|
if isText {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Package hyphae is for the Hypha type, hypha storage and stuff like that. It shall not depend on mycorrhiza modules other than util.
|
// 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
|
package hyphae
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -27,8 +27,8 @@ func IsValidName(hyphaName string) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hypha keeps vital information about a hypha
|
// MediaHypha keeps vital information about a media hypha
|
||||||
type Hypha struct {
|
type MediaHypha struct {
|
||||||
sync.RWMutex
|
sync.RWMutex
|
||||||
|
|
||||||
name string // Canonical name
|
name string // Canonical name
|
||||||
@ -37,16 +37,16 @@ type Hypha struct {
|
|||||||
binaryPath string // == "" => no attachment
|
binaryPath string // == "" => no attachment
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Hypha) SetName(s string) { h.name = s }
|
func (h *MediaHypha) SetName(s string) { h.name = s }
|
||||||
|
|
||||||
func (h *Hypha) BinaryPath() string { return h.binaryPath }
|
func (h *MediaHypha) BinaryPath() string { return h.binaryPath }
|
||||||
func (h *Hypha) SetBinaryPath(s string) { h.binaryPath = s }
|
func (h *MediaHypha) SetBinaryPath(s string) { h.binaryPath = s }
|
||||||
|
|
||||||
func (h *Hypha) CanonicalName() string {
|
func (h *MediaHypha) CanonicalName() string {
|
||||||
return h.name
|
return h.name
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Hypha) Kind() HyphaKind {
|
func (h *MediaHypha) Kind() HyphaKind {
|
||||||
if !h.DoesExist() {
|
if !h.DoesExist() {
|
||||||
return HyphaEmpty
|
return HyphaEmpty
|
||||||
}
|
}
|
||||||
@ -56,16 +56,16 @@ func (h *Hypha) Kind() HyphaKind {
|
|||||||
return HyphaText
|
return HyphaText
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Hypha) DoesExist() bool { // TODO: rename
|
func (h *MediaHypha) DoesExist() bool { // TODO: rename
|
||||||
return h.Exists
|
return h.Exists
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Hypha) HasTextPart() bool {
|
func (h *MediaHypha) HasTextPart() bool {
|
||||||
return h.TextPath != ""
|
return h.TextPath != ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// TextPartPath returns rooted path to the file where the text part should be.
|
// TextPartPath returns rooted path to the file where the text part should be.
|
||||||
func (h *Hypha) TextPartPath() string {
|
func (h *MediaHypha) TextPartPath() string {
|
||||||
if h.TextPath == "" {
|
if h.TextPath == "" {
|
||||||
return filepath.Join(files.HyphaeDir(), h.name+".myco")
|
return filepath.Join(files.HyphaeDir(), h.name+".myco")
|
||||||
}
|
}
|
||||||
@ -73,7 +73,7 @@ func (h *Hypha) TextPartPath() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HasAttachment is true if the hypha has an attachment.
|
// HasAttachment is true if the hypha has an attachment.
|
||||||
func (h *Hypha) HasAttachment() bool {
|
func (h *MediaHypha) HasAttachment() bool {
|
||||||
return h.binaryPath != ""
|
return h.binaryPath != ""
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,8 +81,8 @@ var byNames = make(map[string]Hypher)
|
|||||||
var byNamesMutex = sync.Mutex{}
|
var byNamesMutex = sync.Mutex{}
|
||||||
|
|
||||||
// EmptyHypha returns an empty hypha struct with given name.
|
// EmptyHypha returns an empty hypha struct with given name.
|
||||||
func EmptyHypha(hyphaName string) *Hypha {
|
func EmptyHypha(hyphaName string) *MediaHypha {
|
||||||
return &Hypha{
|
return &MediaHypha{
|
||||||
name: hyphaName,
|
name: hyphaName,
|
||||||
Exists: false,
|
Exists: false,
|
||||||
TextPath: "",
|
TextPath: "",
|
||||||
@ -105,7 +105,7 @@ func storeHypha(h Hypher) {
|
|||||||
byNamesMutex.Unlock()
|
byNamesMutex.Unlock()
|
||||||
|
|
||||||
h.Lock()
|
h.Lock()
|
||||||
h.(*Hypha).Exists = true
|
h.(*MediaHypha).Exists = true
|
||||||
h.Unlock()
|
h.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,7 +113,7 @@ func storeHypha(h Hypher) {
|
|||||||
func insert(h Hypher) (madeNewRecord bool) {
|
func insert(h Hypher) (madeNewRecord bool) {
|
||||||
hp, recorded := byNames[h.CanonicalName()]
|
hp, recorded := byNames[h.CanonicalName()]
|
||||||
if recorded {
|
if recorded {
|
||||||
hp.(*Hypha).mergeIn(h)
|
hp.(*MediaHypha).mergeIn(h)
|
||||||
} else {
|
} else {
|
||||||
storeHypha(h)
|
storeHypha(h)
|
||||||
incrementCount()
|
incrementCount()
|
||||||
@ -131,7 +131,7 @@ func InsertIfNew(h Hypher) (madeNewRecord bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// mergeIn merges in content file paths from a different hypha object. Prints warnings sometimes.
|
// mergeIn merges in content file paths from a different hypha object. Prints warnings sometimes.
|
||||||
func (h *Hypha) mergeIn(oh Hypher) {
|
func (h *MediaHypha) mergeIn(oh Hypher) {
|
||||||
if h == oh {
|
if h == oh {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -139,7 +139,7 @@ func (h *Hypha) mergeIn(oh Hypher) {
|
|||||||
if h.TextPath == "" && oh.HasTextPart() {
|
if h.TextPath == "" && oh.HasTextPart() {
|
||||||
h.TextPath = oh.TextPartPath()
|
h.TextPath = oh.TextPartPath()
|
||||||
}
|
}
|
||||||
if oh := oh.(*Hypha); oh.Kind() == HyphaMedia {
|
if oh := oh.(*MediaHypha); oh.Kind() == HyphaMedia {
|
||||||
if h.binaryPath != "" {
|
if h.binaryPath != "" {
|
||||||
log.Println("There is a file collision for attachment of a hypha:", h.binaryPath, "and", oh.binaryPath, "-- going on with the latter")
|
log.Println("There is a file collision for attachment of a hypha:", h.binaryPath, "and", oh.binaryPath, "-- going on with the latter")
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ const (
|
|||||||
HyphaMedia
|
HyphaMedia
|
||||||
)
|
)
|
||||||
|
|
||||||
// Hypher is a temporary name for this interface. The name will become Hypha, once the struct with the said name is deprecated for good.
|
// Hypher is a temporary name for this interface. The name will become MediaHypha, once the struct with the said name is deprecated for good.
|
||||||
type Hypher interface {
|
type Hypher interface {
|
||||||
sync.Locker
|
sync.Locker
|
||||||
|
|
||||||
@ -37,8 +37,8 @@ func RenameHyphaTo(h Hypher, newName string) {
|
|||||||
byNamesMutex.Lock()
|
byNamesMutex.Lock()
|
||||||
h.Lock()
|
h.Lock()
|
||||||
delete(byNames, h.CanonicalName())
|
delete(byNames, h.CanonicalName())
|
||||||
h.(*Hypha).SetName(newName)
|
h.(*MediaHypha).SetName(newName)
|
||||||
byNames[h.CanonicalName()] = h.(*Hypha)
|
byNames[h.CanonicalName()] = h.(*MediaHypha)
|
||||||
byNamesMutex.Unlock()
|
byNamesMutex.Unlock()
|
||||||
h.Unlock()
|
h.Unlock()
|
||||||
}
|
}
|
||||||
|
@ -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.Hypha).BinaryPath()).
|
WithFilesRemoved(h.TextPartPath(), h.(*hyphae.MediaHypha).BinaryPath()).
|
||||||
WithMsg(fmt.Sprintf("Delete ‘%s’", h.CanonicalName())).
|
WithMsg(fmt.Sprintf("Delete ‘%s’", h.CanonicalName())).
|
||||||
WithUser(u).
|
WithUser(u).
|
||||||
Apply()
|
Apply()
|
||||||
|
@ -16,12 +16,12 @@ func init() {
|
|||||||
globals.HyphaAccess = func(hyphaName string) (rawText, binaryBlock string, err error) {
|
globals.HyphaAccess = func(hyphaName string) (rawText, binaryBlock string, err error) {
|
||||||
if h := hyphae.ByName(hyphaName); h.DoesExist() {
|
if h := hyphae.ByName(hyphaName); h.DoesExist() {
|
||||||
rawText, err = FetchTextPart(h)
|
rawText, err = FetchTextPart(h)
|
||||||
if h.(*hyphae.Hypha).BinaryPath() != "" {
|
if h := h.(*hyphae.MediaHypha); 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)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
err = errors.New("Hypha " + hyphaName + " does not exist")
|
err = errors.New("MediaHypha " + hyphaName + " does not exist")
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,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.Hypha) // ontology think
|
h := h.(*hyphae.MediaHypha) // ontology think
|
||||||
oldName := h.CanonicalName()
|
oldName := h.CanonicalName()
|
||||||
hyphae.RenameHyphaTo(h, replaceName(h.CanonicalName()))
|
hyphae.RenameHyphaTo(h, replaceName(h.CanonicalName()))
|
||||||
h.Lock()
|
h.Lock()
|
||||||
@ -100,13 +100,13 @@ func renamingPairs(hyphaeToRename []hyphae.Hypher, replaceName func(string) stri
|
|||||||
renameMap[h.TextPartPath()] = replaceName(h.TextPartPath())
|
renameMap[h.TextPartPath()] = replaceName(h.TextPartPath())
|
||||||
}
|
}
|
||||||
if h.Kind() == hyphae.HyphaMedia { // ontology think
|
if h.Kind() == hyphae.HyphaMedia { // ontology think
|
||||||
h := h.(*hyphae.Hypha)
|
h := h.(*hyphae.MediaHypha)
|
||||||
renameMap[h.BinaryPath()] = replaceName(h.BinaryPath())
|
renameMap[h.BinaryPath()] = replaceName(h.BinaryPath())
|
||||||
}
|
}
|
||||||
h.Unlock()
|
h.Unlock()
|
||||||
}
|
}
|
||||||
if firstFailure, ok := hyphae.AreFreeNames(newNames...); !ok {
|
if firstFailure, ok := hyphae.AreFreeNames(newNames...); !ok {
|
||||||
return nil, errors.New("Hypha " + firstFailure + " already exists")
|
return nil, errors.New("MediaHypha " + 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.Hypha)
|
H := h.(*hyphae.MediaHypha)
|
||||||
|
|
||||||
hop.
|
hop.
|
||||||
WithFilesRemoved(H.BinaryPath()).
|
WithFilesRemoved(H.BinaryPath()).
|
||||||
|
@ -77,7 +77,7 @@ func uploadHelp(h hyphae.Hypher, hop *history.Op, ext string, data []byte, u *us
|
|||||||
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.Hypha); hop.Type == history.TypeEditBinary {
|
if h := h.(*hyphae.MediaHypha); hop.Type == history.TypeEditBinary {
|
||||||
sourceFullPath = h.BinaryPath()
|
sourceFullPath = h.BinaryPath()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ func uploadHelp(h hyphae.Hypher, hop *history.Op, ext string, data []byte, u *us
|
|||||||
return hop.Abort(), "No changes"
|
return hop.Abort(), "No changes"
|
||||||
}
|
}
|
||||||
// TODO: test
|
// TODO: test
|
||||||
if h := h.(*hyphae.Hypha); hop.Type == history.TypeEditBinary {
|
if h := h.(*hyphae.MediaHypha); hop.Type == history.TypeEditBinary {
|
||||||
h.SetBinaryPath(fullPath)
|
h.SetBinaryPath(fullPath)
|
||||||
} else {
|
} else {
|
||||||
h.TextPath = fullPath
|
h.TextPath = fullPath
|
||||||
|
@ -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, // Hypha is no sibling of itself
|
case h.CanonicalName() == hyphaName, // MediaHypha 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,10 +75,10 @@
|
|||||||
</h1>
|
</h1>
|
||||||
{% endfunc %}
|
{% endfunc %}
|
||||||
|
|
||||||
{% func AttachmentHTMLRaw(h hyphae.Hypher) %}{%= AttachmentHTML(h, l18n.New("en", "en")) %}{% endfunc %}
|
{% func AttachmentHTMLRaw(h *hyphae.MediaHypha) %}{%= AttachmentHTML(h, l18n.New("en", "en")) %}{% endfunc %}
|
||||||
|
|
||||||
{% func AttachmentHTML(h hyphae.Hypher, lc *l18n.Localizer) %}
|
{% func AttachmentHTML(h *hyphae.MediaHypha, lc *l18n.Localizer) %}
|
||||||
{% switch filepath.Ext(h.(*hyphae.Hypha).BinaryPath()) %}
|
{% switch filepath.Ext(h.BinaryPath()) %}
|
||||||
|
|
||||||
{% case ".jpg", ".gif", ".png", ".webp", ".svg", ".ico" %}
|
{% case ".jpg", ".gif", ".png", ".webp", ".svg", ".ico" %}
|
||||||
<div class="binary-container binary-container_with-img">
|
<div class="binary-container binary-container_with-img">
|
||||||
|
@ -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.Hypher) {
|
func StreamAttachmentHTMLRaw(qw422016 *qt422016.Writer, h *hyphae.MediaHypha) {
|
||||||
//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.Hypher) {
|
func WriteAttachmentHTMLRaw(qq422016 qtio422016.Writer, h *hyphae.MediaHypha) {
|
||||||
//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.Hypher) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//line views/hypha.qtpl:78
|
//line views/hypha.qtpl:78
|
||||||
func AttachmentHTMLRaw(h hyphae.Hypher) string {
|
func AttachmentHTMLRaw(h *hyphae.MediaHypha) 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,12 +382,12 @@ func AttachmentHTMLRaw(h hyphae.Hypher) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//line views/hypha.qtpl:80
|
//line views/hypha.qtpl:80
|
||||||
func StreamAttachmentHTML(qw422016 *qt422016.Writer, h hyphae.Hypher, lc *l18n.Localizer) {
|
func StreamAttachmentHTML(qw422016 *qt422016.Writer, h *hyphae.MediaHypha, lc *l18n.Localizer) {
|
||||||
//line views/hypha.qtpl:80
|
//line views/hypha.qtpl:80
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
`)
|
`)
|
||||||
//line views/hypha.qtpl:81
|
//line views/hypha.qtpl:81
|
||||||
switch filepath.Ext(h.(*hyphae.Hypha).BinaryPath()) {
|
switch filepath.Ext(h.BinaryPath()) {
|
||||||
//line views/hypha.qtpl:83
|
//line views/hypha.qtpl:83
|
||||||
case ".jpg", ".gif", ".png", ".webp", ".svg", ".ico":
|
case ".jpg", ".gif", ".png", ".webp", ".svg", ".ico":
|
||||||
//line views/hypha.qtpl:83
|
//line views/hypha.qtpl:83
|
||||||
@ -486,7 +486,7 @@ func StreamAttachmentHTML(qw422016 *qt422016.Writer, h hyphae.Hypher, lc *l18n.L
|
|||||||
}
|
}
|
||||||
|
|
||||||
//line views/hypha.qtpl:109
|
//line views/hypha.qtpl:109
|
||||||
func WriteAttachmentHTML(qq422016 qtio422016.Writer, h hyphae.Hypher, lc *l18n.Localizer) {
|
func WriteAttachmentHTML(qq422016 qtio422016.Writer, h *hyphae.MediaHypha, 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.Hypher, lc *l18n.L
|
|||||||
}
|
}
|
||||||
|
|
||||||
//line views/hypha.qtpl:109
|
//line views/hypha.qtpl:109
|
||||||
func AttachmentHTML(h hyphae.Hypher, lc *l18n.Localizer) string {
|
func AttachmentHTML(h *hyphae.MediaHypha, 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.Hypha, u *user.User) %}
|
{% func AttachmentMenuHTML(rq *http.Request, h *hyphae.MediaHypha, u *user.User) %}
|
||||||
{% code
|
{% code
|
||||||
lc := l18n.FromRequest(rq)
|
lc := l18n.FromRequest(rq)
|
||||||
%}
|
%}
|
||||||
|
@ -51,7 +51,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
//line views/readers.qtpl:14
|
//line views/readers.qtpl:14
|
||||||
func StreamAttachmentMenuHTML(qw422016 *qt422016.Writer, rq *http.Request, h *hyphae.Hypha, u *user.User) {
|
func StreamAttachmentMenuHTML(qw422016 *qt422016.Writer, rq *http.Request, h *hyphae.MediaHypha, u *user.User) {
|
||||||
//line views/readers.qtpl:14
|
//line views/readers.qtpl:14
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
`)
|
`)
|
||||||
@ -265,7 +265,7 @@ func StreamAttachmentMenuHTML(qw422016 *qt422016.Writer, rq *http.Request, h *hy
|
|||||||
}
|
}
|
||||||
|
|
||||||
//line views/readers.qtpl:78
|
//line views/readers.qtpl:78
|
||||||
func WriteAttachmentMenuHTML(qq422016 qtio422016.Writer, rq *http.Request, h *hyphae.Hypha, u *user.User) {
|
func WriteAttachmentMenuHTML(qq422016 qtio422016.Writer, rq *http.Request, h *hyphae.MediaHypha, u *user.User) {
|
||||||
//line views/readers.qtpl:78
|
//line views/readers.qtpl:78
|
||||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||||
//line views/readers.qtpl:78
|
//line views/readers.qtpl:78
|
||||||
@ -276,7 +276,7 @@ func WriteAttachmentMenuHTML(qq422016 qtio422016.Writer, rq *http.Request, h *hy
|
|||||||
}
|
}
|
||||||
|
|
||||||
//line views/readers.qtpl:78
|
//line views/readers.qtpl:78
|
||||||
func AttachmentMenuHTML(rq *http.Request, h *hyphae.Hypha, u *user.User) string {
|
func AttachmentMenuHTML(rq *http.Request, h *hyphae.MediaHypha, u *user.User) string {
|
||||||
//line views/readers.qtpl:78
|
//line views/readers.qtpl:78
|
||||||
qb422016 := qt422016.AcquireByteBuffer()
|
qb422016 := qt422016.AcquireByteBuffer()
|
||||||
//line views/readers.qtpl:78
|
//line views/readers.qtpl:78
|
||||||
|
@ -266,7 +266,7 @@ sort.Strings(editors)
|
|||||||
<li class="hypha-list__entry">
|
<li class="hypha-list__entry">
|
||||||
<a class="hypha-list__link" href="/hypha/{%s hypha.CanonicalName() %}">{%s util.BeautifulName(hypha.CanonicalName()) %}</a>
|
<a class="hypha-list__link" href="/hypha/{%s hypha.CanonicalName() %}">{%s util.BeautifulName(hypha.CanonicalName()) %}</a>
|
||||||
{% if hypha.Kind() == hyphae.HyphaMedia %}
|
{% if hypha.Kind() == hyphae.HyphaMedia %}
|
||||||
<span class="hypha-list__amnt-type">{%s filepath.Ext(hypha.(*hyphae.Hypha).BinaryPath())[1:] %}</span>
|
<span class="hypha-list__amnt-type">{%s filepath.Ext(hypha.(*hyphae.MediaHypha).BinaryPath())[1:] %}</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -1041,7 +1041,7 @@ func StreamHyphaListHTML(qw422016 *qt422016.Writer, lc *l18n.Localizer) {
|
|||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
<span class="hypha-list__amnt-type">`)
|
<span class="hypha-list__amnt-type">`)
|
||||||
//line views/stuff.qtpl:269
|
//line views/stuff.qtpl:269
|
||||||
qw422016.E().S(filepath.Ext(hypha.(*hyphae.Hypha).BinaryPath())[1:])
|
qw422016.E().S(filepath.Ext(hypha.(*hyphae.MediaHypha).BinaryPath())[1:])
|
||||||
//line views/stuff.qtpl:269
|
//line views/stuff.qtpl:269
|
||||||
qw422016.N().S(`</span>
|
qw422016.N().S(`</span>
|
||||||
`)
|
`)
|
||||||
|
@ -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.Hypha), u),
|
views.AttachmentMenuHTML(rq, h.(*hyphae.MediaHypha), u),
|
||||||
lc,
|
lc,
|
||||||
u))
|
u))
|
||||||
}
|
}
|
||||||
@ -149,7 +149,7 @@ func handlerText(w http.ResponseWriter, rq *http.Request) {
|
|||||||
func handlerBinary(w http.ResponseWriter, rq *http.Request) {
|
func handlerBinary(w http.ResponseWriter, rq *http.Request) {
|
||||||
util.PrepareRq(rq)
|
util.PrepareRq(rq)
|
||||||
hyphaName := util.HyphaNameFromRq(rq, "binary")
|
hyphaName := util.HyphaNameFromRq(rq, "binary")
|
||||||
if h := hyphae.ByName(hyphaName).(*hyphae.Hypha); h.DoesExist() {
|
if h := hyphae.ByName(hyphaName).(*hyphae.MediaHypha); h.DoesExist() {
|
||||||
log.Println("Serving", h.BinaryPath())
|
log.Println("Serving", h.BinaryPath())
|
||||||
w.Header().Set("Content-Type", mimetype.FromExtension(filepath.Ext(h.BinaryPath())))
|
w.Header().Set("Content-Type", mimetype.FromExtension(filepath.Ext(h.BinaryPath())))
|
||||||
http.ServeFile(w, rq, h.BinaryPath())
|
http.ServeFile(w, rq, h.BinaryPath())
|
||||||
@ -178,7 +178,7 @@ func handlerHypha(w http.ResponseWriter, rq *http.Request) {
|
|||||||
openGraph = getOpenGraph()
|
openGraph = getOpenGraph()
|
||||||
}
|
}
|
||||||
if h.Kind() == hyphae.HyphaMedia {
|
if h.Kind() == hyphae.HyphaMedia {
|
||||||
contents = views.AttachmentHTML(h, lc) + contents
|
contents = views.AttachmentHTML(h.(*hyphae.MediaHypha), lc) + contents
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if contents == "" {
|
if contents == "" {
|
||||||
|
Loading…
Reference in New Issue
Block a user