mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2025-07-04 10:42:50 +00:00
Delete DoesExist
Now type switches are enforced
This commit is contained in:
parent
6b3e8a245c
commit
ae13fdab43
@ -12,10 +12,6 @@ func (e *EmptyHypha) CanonicalName() string {
|
|||||||
return e.canonicalName
|
return e.canonicalName
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *EmptyHypha) Kind() HyphaKind {
|
|
||||||
return HyphaEmpty
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *EmptyHypha) DoesExist() bool {
|
func (e *EmptyHypha) DoesExist() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -34,3 +30,11 @@ func NewEmptyHypha(hyphaName string) *EmptyHypha {
|
|||||||
canonicalName: hyphaName,
|
canonicalName: hyphaName,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func FillEmptyHyphaUpToMediaHypha(e *EmptyHypha) *MediaHypha { // sic!
|
||||||
|
return &MediaHypha{
|
||||||
|
name: e.CanonicalName(),
|
||||||
|
TextPath: "",
|
||||||
|
binaryPath: "",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -18,12 +18,27 @@ func Index(path string) {
|
|||||||
close(ch)
|
close(ch)
|
||||||
}(ch)
|
}(ch)
|
||||||
|
|
||||||
for h := range ch {
|
for nh := range ch {
|
||||||
// It's safe to ignore the mutex because there is a single worker right now.
|
switch oh := ByName(nh.CanonicalName()).(type) {
|
||||||
if oh := ByName(h.CanonicalName()); oh.DoesExist() {
|
case *EmptyHypha:
|
||||||
oh.(*MediaHypha).mergeIn(h.(*MediaHypha))
|
insert(nh)
|
||||||
} else {
|
default:
|
||||||
insert(h.(*MediaHypha))
|
// In case of conflicts the newer hypha overwrites the previous
|
||||||
|
switch nh, oh := nh.(*MediaHypha), oh.(*MediaHypha); {
|
||||||
|
case (nh.Kind() == HyphaText) && (oh.Kind() == HyphaMedia):
|
||||||
|
oh.TextPath = nh.TextPartPath()
|
||||||
|
|
||||||
|
case (nh.Kind() == HyphaText) && (oh.Kind() == HyphaText):
|
||||||
|
log.Printf("File collision for hypha ‘%s’, using %s rather than %s\n", nh.CanonicalName(), nh.TextPartPath(), oh.TextPartPath())
|
||||||
|
oh.TextPath = nh.TextPartPath()
|
||||||
|
|
||||||
|
case (nh.Kind() == HyphaMedia) && (oh.Kind() == HyphaMedia):
|
||||||
|
log.Printf("File collision for hypha ‘%s’, using %s rather than %s\n", nh.CanonicalName(), nh.BinaryPath(), oh.BinaryPath())
|
||||||
|
oh.SetBinaryPath(nh.BinaryPath())
|
||||||
|
|
||||||
|
case (nh.Kind() == HyphaMedia) && (oh.Kind() == HyphaText):
|
||||||
|
oh.SetBinaryPath(nh.BinaryPath())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.Println("Indexed", Count(), "hyphae")
|
log.Println("Indexed", Count(), "hyphae")
|
||||||
|
@ -25,8 +25,7 @@ func IsValidName(hyphaName string) bool {
|
|||||||
type HyphaKind int
|
type HyphaKind int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
HyphaEmpty HyphaKind = iota
|
HyphaText HyphaKind = iota
|
||||||
HyphaText
|
|
||||||
HyphaMedia
|
HyphaMedia
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -35,8 +34,6 @@ type Hypher interface {
|
|||||||
sync.Locker
|
sync.Locker
|
||||||
|
|
||||||
CanonicalName() string
|
CanonicalName() string
|
||||||
Kind() HyphaKind
|
|
||||||
DoesExist() bool
|
|
||||||
|
|
||||||
HasTextPart() bool
|
HasTextPart() bool
|
||||||
TextPartPath() string
|
TextPartPath() string
|
||||||
@ -63,39 +60,35 @@ func RenameHyphaTo(h Hypher, newName string) {
|
|||||||
h.Unlock()
|
h.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
// insert inserts the hypha into the storage. A previous record is used if possible. Count incrementation is done if needed.
|
// insert inserts the hypha into the storage, possibly overwriting the previous hypha with the same name. Count incrementation is done if needed.
|
||||||
func insert(h Hypher) (madeNewRecord bool) {
|
func insert(h Hypher) (madeNewRecord bool) {
|
||||||
hp, recorded := byNames[h.CanonicalName()]
|
_, recorded := byNames[h.CanonicalName()]
|
||||||
if recorded {
|
|
||||||
hp.(*MediaHypha).mergeIn(h)
|
byNamesMutex.Lock()
|
||||||
} else {
|
byNames[h.CanonicalName()] = h
|
||||||
storeHypha(h)
|
byNamesMutex.Unlock()
|
||||||
|
|
||||||
|
if !recorded {
|
||||||
incrementCount()
|
incrementCount()
|
||||||
}
|
}
|
||||||
|
|
||||||
return !recorded
|
return !recorded
|
||||||
}
|
}
|
||||||
|
|
||||||
// InsertIfNew checks whether hypha exists and returns `true` if it didn't and has been created.
|
// InsertIfNew checks whether the hypha exists and returns `true` if it didn't and has been created.
|
||||||
func InsertIfNew(h Hypher) (madeNewRecord bool) {
|
func InsertIfNew(h Hypher) (madeNewRecord bool) {
|
||||||
if h.DoesExist() {
|
switch ByName(h.CanonicalName()).(type) {
|
||||||
|
case *EmptyHypha:
|
||||||
|
return insert(h)
|
||||||
|
default:
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return insert(h)
|
|
||||||
}
|
|
||||||
|
|
||||||
func storeHypha(h Hypher) {
|
|
||||||
byNamesMutex.Lock()
|
|
||||||
byNames[h.CanonicalName()] = h
|
|
||||||
byNamesMutex.Unlock()
|
|
||||||
|
|
||||||
h.Lock()
|
|
||||||
h.(*MediaHypha).Exists = true
|
|
||||||
h.Unlock()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ByName returns a hypha by name. It may have been recorded to the storage.
|
// ByName returns a hypha by name. It may have been recorded to the storage.
|
||||||
func ByName(hyphaName string) (h Hypher) {
|
func ByName(hyphaName string) (h Hypher) {
|
||||||
|
byNamesMutex.Lock()
|
||||||
|
defer byNamesMutex.Unlock()
|
||||||
h, recorded := byNames[hyphaName]
|
h, recorded := byNames[hyphaName]
|
||||||
if recorded {
|
if recorded {
|
||||||
return h
|
return h
|
||||||
|
@ -16,7 +16,9 @@ func YieldExistingHyphae() chan Hypher {
|
|||||||
ch := make(chan Hypher)
|
ch := make(chan Hypher)
|
||||||
go func() {
|
go func() {
|
||||||
for _, h := range byNames {
|
for _, h := range byNames {
|
||||||
if h.DoesExist() {
|
switch h.(type) {
|
||||||
|
case *EmptyHypha:
|
||||||
|
default:
|
||||||
ch <- h
|
ch <- h
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
package hyphae
|
package hyphae
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
@ -28,20 +27,13 @@ func (h *MediaHypha) CanonicalName() string {
|
|||||||
return h.name
|
return h.name
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *MediaHypha) Kind() HyphaKind {
|
func (h *MediaHypha) Kind() HyphaKind { // sic!
|
||||||
if !h.DoesExist() {
|
|
||||||
return HyphaEmpty
|
|
||||||
}
|
|
||||||
if h.HasAttachment() {
|
if h.HasAttachment() {
|
||||||
return HyphaMedia
|
return HyphaMedia
|
||||||
}
|
}
|
||||||
return HyphaText
|
return HyphaText
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *MediaHypha) DoesExist() bool { // TODO: rename
|
|
||||||
return h.Exists
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *MediaHypha) HasTextPart() bool {
|
func (h *MediaHypha) HasTextPart() bool {
|
||||||
return h.TextPath != ""
|
return h.TextPath != ""
|
||||||
}
|
}
|
||||||
@ -58,21 +50,3 @@ func (h *MediaHypha) TextPartPath() string {
|
|||||||
func (h *MediaHypha) HasAttachment() bool {
|
func (h *MediaHypha) HasAttachment() bool {
|
||||||
return h.binaryPath != ""
|
return h.binaryPath != ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// mergeIn merges in content file paths from a different hypha object. Prints warnings sometimes.
|
|
||||||
func (h *MediaHypha) mergeIn(oh Hypher) {
|
|
||||||
if h == oh {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
h.Lock()
|
|
||||||
if h.TextPath == "" && oh.HasTextPart() {
|
|
||||||
h.TextPath = oh.TextPartPath()
|
|
||||||
}
|
|
||||||
if oh := oh.(*MediaHypha); oh.Kind() == HyphaMedia {
|
|
||||||
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")
|
|
||||||
}
|
|
||||||
h.binaryPath = oh.binaryPath
|
|
||||||
}
|
|
||||||
h.Unlock()
|
|
||||||
}
|
|
||||||
|
@ -22,9 +22,12 @@ func canFactory(
|
|||||||
return lc.Get("ui.act_no_rights"), errors.New(lc.Get(noRightsMsg))
|
return lc.Get("ui.act_no_rights"), errors.New(lc.Get(noRightsMsg))
|
||||||
}
|
}
|
||||||
|
|
||||||
if mustExist && !h.DoesExist() {
|
if mustExist {
|
||||||
rejectLogger(h, u, "does not exist")
|
switch h.(type) {
|
||||||
return lc.Get("ui.act_notexist"), errors.New(lc.Get(notExistsMsg))
|
case *hyphae.EmptyHypha:
|
||||||
|
rejectLogger(h, u, "does not exist")
|
||||||
|
return lc.Get("ui.act_notexist"), errors.New(lc.Get(notExistsMsg))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if dispatcher == nil {
|
if dispatcher == nil {
|
||||||
@ -62,9 +65,13 @@ var (
|
|||||||
rejectUnattachLog,
|
rejectUnattachLog,
|
||||||
"unattach-confirm",
|
"unattach-confirm",
|
||||||
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) {
|
||||||
if h.Kind() != hyphae.HyphaMedia {
|
switch h := h.(type) {
|
||||||
rejectUnattachLog(h, u, "no amnt")
|
case *hyphae.EmptyHypha:
|
||||||
return lc.Get("ui.act_noattachment_tip"), lc.Get("ui.act_noattachment")
|
case *hyphae.MediaHypha:
|
||||||
|
if h.Kind() != hyphae.HyphaMedia {
|
||||||
|
rejectUnattachLog(h, u, "no amnt")
|
||||||
|
return lc.Get("ui.act_noattachment_tip"), lc.Get("ui.act_noattachment")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return "", ""
|
return "", ""
|
||||||
|
@ -11,17 +11,23 @@ import (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
globals.HyphaExists = func(hyphaName string) bool {
|
globals.HyphaExists = func(hyphaName string) bool {
|
||||||
return hyphae.ByName(hyphaName).DoesExist()
|
switch hyphae.ByName(hyphaName).(type) {
|
||||||
|
case *hyphae.EmptyHypha:
|
||||||
|
return false
|
||||||
|
default:
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
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() {
|
switch h := hyphae.ByName(hyphaName).(type) {
|
||||||
|
case *hyphae.EmptyHypha:
|
||||||
|
err = errors.New("Hypha " + hyphaName + " does not exist")
|
||||||
|
default:
|
||||||
rawText, err = FetchTextPart(h)
|
rawText, err = FetchTextPart(h)
|
||||||
if h := h.(*hyphae.MediaHypha); h.Kind() == hyphae.HyphaMedia {
|
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 {
|
|
||||||
err = errors.New("MediaHypha " + hyphaName + " does not exist")
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func canRenameThisToThat(oh hyphae.Hypher, nh hyphae.Hypher, u *user.User, lc *l18n.Localizer) (errtitle string, err error) {
|
func canRenameThisToThat(oh hyphae.Hypher, nh hyphae.Hypher, u *user.User, lc *l18n.Localizer) (errtitle string, err error) {
|
||||||
if nh.DoesExist() {
|
switch nh.(type) {
|
||||||
|
case *hyphae.EmptyHypha:
|
||||||
|
default:
|
||||||
rejectRenameLog(oh, u, fmt.Sprintf("name ‘%s’ taken already", nh.CanonicalName()))
|
rejectRenameLog(oh, u, fmt.Sprintf("name ‘%s’ taken already", nh.CanonicalName()))
|
||||||
return lc.Get("ui.rename_taken"), fmt.Errorf(lc.Get("ui.rename_taken_tip", &l18n.Replacements{"name": "<a href='/hypha/%[1]s'>%[1]s</a>"}), nh.CanonicalName())
|
return lc.Get("ui.rename_taken"), fmt.Errorf(lc.Get("ui.rename_taken_tip", &l18n.Replacements{"name": "<a href='/hypha/%[1]s'>%[1]s</a>"}), nh.CanonicalName())
|
||||||
}
|
}
|
||||||
@ -99,9 +101,11 @@ func renamingPairs(hyphaeToRename []hyphae.Hypher, replaceName func(string) stri
|
|||||||
if h.HasTextPart() {
|
if h.HasTextPart() {
|
||||||
renameMap[h.TextPartPath()] = replaceName(h.TextPartPath())
|
renameMap[h.TextPartPath()] = replaceName(h.TextPartPath())
|
||||||
}
|
}
|
||||||
if h.Kind() == hyphae.HyphaMedia { // ontology think
|
switch h := h.(type) {
|
||||||
h := h.(*hyphae.MediaHypha)
|
case *hyphae.MediaHypha:
|
||||||
renameMap[h.BinaryPath()] = replaceName(h.BinaryPath())
|
if h.Kind() == hyphae.HyphaMedia { // ontology think
|
||||||
|
renameMap[h.BinaryPath()] = replaceName(h.BinaryPath())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
h.Unlock()
|
h.Unlock()
|
||||||
}
|
}
|
||||||
|
@ -23,11 +23,13 @@ import (
|
|||||||
// UploadText edits a hypha' text part and makes a history record about that.
|
// UploadText edits a hypha' text part and makes a history record about that.
|
||||||
func UploadText(h hyphae.Hypher, data []byte, message string, u *user.User, lc *l18n.Localizer) (hop *history.Op, errtitle string) {
|
func UploadText(h hyphae.Hypher, data []byte, message string, u *user.User, lc *l18n.Localizer) (hop *history.Op, errtitle string) {
|
||||||
hop = history.Operation(history.TypeEditText)
|
hop = history.Operation(history.TypeEditText)
|
||||||
|
|
||||||
var action string
|
var action string
|
||||||
if h.DoesExist() {
|
switch h.(type) {
|
||||||
action = "Edit"
|
case *hyphae.EmptyHypha:
|
||||||
} else {
|
|
||||||
action = "Create"
|
action = "Create"
|
||||||
|
default:
|
||||||
|
action = "Edit"
|
||||||
}
|
}
|
||||||
|
|
||||||
if message == "" {
|
if message == "" {
|
||||||
@ -39,8 +41,13 @@ func UploadText(h hyphae.Hypher, data []byte, message string, u *user.User, lc *
|
|||||||
if errtitle, err := CanEdit(u, h, lc); err != nil {
|
if errtitle, err := CanEdit(u, h, lc); err != nil {
|
||||||
return hop.WithErrAbort(err), errtitle
|
return hop.WithErrAbort(err), errtitle
|
||||||
}
|
}
|
||||||
if len(bytes.TrimSpace(data)) == 0 && h.Kind() != hyphae.HyphaMedia {
|
if len(bytes.TrimSpace(data)) == 0 {
|
||||||
return hop.WithErrAbort(errors.New("No data passed")), "Empty"
|
switch h := h.(type) {
|
||||||
|
case *hyphae.MediaHypha:
|
||||||
|
if h.Kind() != hyphae.HyphaMedia {
|
||||||
|
return hop.WithErrAbort(errors.New("No data passed")), "Empty"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return uploadHelp(h, hop, ".myco", data, u)
|
return uploadHelp(h, hop, ".myco", data, u)
|
||||||
@ -93,18 +100,28 @@ func uploadHelp(h hyphae.Hypher, hop *history.Op, ext string, data []byte, u *us
|
|||||||
return hop.WithErrAbort(err), err.Error()
|
return hop.WithErrAbort(err), err.Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
if h.DoesExist() && sourceFullPath != fullPath && sourceFullPath != "" {
|
switch h.(type) {
|
||||||
if err := history.Rename(sourceFullPath, fullPath); err != nil {
|
case *hyphae.EmptyHypha:
|
||||||
return hop.WithErrAbort(err), err.Error()
|
default:
|
||||||
|
if sourceFullPath != fullPath && sourceFullPath != "" {
|
||||||
|
if err := history.Rename(sourceFullPath, fullPath); err != nil {
|
||||||
|
return hop.WithErrAbort(err), err.Error()
|
||||||
|
}
|
||||||
|
log.Println("Move", sourceFullPath, "to", fullPath)
|
||||||
}
|
}
|
||||||
log.Println("Move", sourceFullPath, "to", fullPath)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hyphae.InsertIfNew(h)
|
hyphae.InsertIfNew(h)
|
||||||
if h.DoesExist() && h.HasTextPart() && hop.Type == history.TypeEditText && !history.FileChanged(fullPath) {
|
|
||||||
return hop.Abort(), "No changes"
|
switch h.(type) {
|
||||||
|
case *hyphae.EmptyHypha:
|
||||||
|
default:
|
||||||
|
if h.HasTextPart() && hop.Type == history.TypeEditText && !history.FileChanged(fullPath) {
|
||||||
|
return hop.Abort(), "No changes"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// TODO: test
|
|
||||||
|
// sic!
|
||||||
if h := h.(*hyphae.MediaHypha); hop.Type == history.TypeEditBinary {
|
if h := h.(*hyphae.MediaHypha); hop.Type == history.TypeEditBinary {
|
||||||
h.SetBinaryPath(fullPath)
|
h.SetBinaryPath(fullPath)
|
||||||
} else {
|
} else {
|
||||||
|
@ -23,9 +23,10 @@ func FetchTextPart(h hyphae.Hypher) (string, error) {
|
|||||||
|
|
||||||
// SetHeaderLinks initializes header links by reading the configured hypha, if there is any, or resorting to default values.
|
// SetHeaderLinks initializes header links by reading the configured hypha, if there is any, or resorting to default values.
|
||||||
func SetHeaderLinks() {
|
func SetHeaderLinks() {
|
||||||
if userLinksHypha := hyphae.ByName(cfg.HeaderLinksHypha); !userLinksHypha.DoesExist() {
|
switch userLinksHypha := hyphae.ByName(cfg.HeaderLinksHypha).(type) {
|
||||||
|
case *hyphae.EmptyHypha:
|
||||||
cfg.SetDefaultHeaderLinks()
|
cfg.SetDefaultHeaderLinks()
|
||||||
} else {
|
default:
|
||||||
contents, err := os.ReadFile(userLinksHypha.TextPartPath())
|
contents, err := os.ReadFile(userLinksHypha.TextPartPath())
|
||||||
if err != nil || len(contents) == 0 {
|
if err != nil || len(contents) == 0 {
|
||||||
cfg.SetDefaultHeaderLinks()
|
cfg.SetDefaultHeaderLinks()
|
||||||
|
@ -106,11 +106,12 @@ If you rename .prevnext, change the docs too.
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{%s= NaviTitleHTML(h) %}
|
{%s= NaviTitleHTML(h) %}
|
||||||
{% if h.DoesExist() %}
|
{% switch h.(type) %}
|
||||||
{%s= contents %}
|
{% case *hyphae.EmptyHypha %}
|
||||||
{% else %}
|
{%= nonExistentHyphaNotice(h, u, lc) %}
|
||||||
{%= nonExistentHyphaNotice(h, u, lc) %}
|
{% default %}
|
||||||
{% endif %}
|
{%s= contents %}
|
||||||
|
{% endswitch %}
|
||||||
</section>
|
</section>
|
||||||
<section class="prevnext">
|
<section class="prevnext">
|
||||||
{% if prevHyphaName != "" %}
|
{% if prevHyphaName != "" %}
|
||||||
|
@ -372,257 +372,259 @@ func StreamHyphaHTML(qw422016 *qt422016.Writer, rq *http.Request, lc *l18n.Local
|
|||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
`)
|
`)
|
||||||
//line views/readers.qtpl:109
|
//line views/readers.qtpl:109
|
||||||
if h.DoesExist() {
|
switch h.(type) {
|
||||||
//line views/readers.qtpl:109
|
//line views/readers.qtpl:110
|
||||||
|
case *hyphae.EmptyHypha:
|
||||||
|
//line views/readers.qtpl:110
|
||||||
|
qw422016.N().S(`
|
||||||
|
`)
|
||||||
|
//line views/readers.qtpl:111
|
||||||
|
streamnonExistentHyphaNotice(qw422016, h, u, lc)
|
||||||
|
//line views/readers.qtpl:111
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
`)
|
`)
|
||||||
//line views/readers.qtpl:110
|
//line views/readers.qtpl:112
|
||||||
|
default:
|
||||||
|
//line views/readers.qtpl:112
|
||||||
|
qw422016.N().S(`
|
||||||
|
`)
|
||||||
|
//line views/readers.qtpl:113
|
||||||
qw422016.N().S(contents)
|
qw422016.N().S(contents)
|
||||||
//line views/readers.qtpl:110
|
|
||||||
qw422016.N().S(`
|
|
||||||
`)
|
|
||||||
//line views/readers.qtpl:111
|
|
||||||
} else {
|
|
||||||
//line views/readers.qtpl:111
|
|
||||||
qw422016.N().S(`
|
|
||||||
`)
|
|
||||||
//line views/readers.qtpl:112
|
|
||||||
streamnonExistentHyphaNotice(qw422016, h, u, lc)
|
|
||||||
//line views/readers.qtpl:112
|
|
||||||
qw422016.N().S(`
|
|
||||||
`)
|
|
||||||
//line views/readers.qtpl:113
|
//line views/readers.qtpl:113
|
||||||
|
qw422016.N().S(`
|
||||||
|
`)
|
||||||
|
//line views/readers.qtpl:114
|
||||||
}
|
}
|
||||||
//line views/readers.qtpl:113
|
//line views/readers.qtpl:114
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
</section>
|
</section>
|
||||||
<section class="prevnext">
|
<section class="prevnext">
|
||||||
`)
|
`)
|
||||||
//line views/readers.qtpl:116
|
//line views/readers.qtpl:117
|
||||||
if prevHyphaName != "" {
|
if prevHyphaName != "" {
|
||||||
//line views/readers.qtpl:116
|
//line views/readers.qtpl:117
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
<a class="prevnext__el prevnext__prev" href="/hypha/`)
|
<a class="prevnext__el prevnext__prev" href="/hypha/`)
|
||||||
//line views/readers.qtpl:117
|
//line views/readers.qtpl:118
|
||||||
qw422016.E().S(prevHyphaName)
|
qw422016.E().S(prevHyphaName)
|
||||||
//line views/readers.qtpl:117
|
//line views/readers.qtpl:118
|
||||||
qw422016.N().S(`" rel="prev">← `)
|
qw422016.N().S(`" rel="prev">← `)
|
||||||
//line views/readers.qtpl:117
|
//line views/readers.qtpl:118
|
||||||
qw422016.E().S(util.BeautifulName(path.Base(prevHyphaName)))
|
qw422016.E().S(util.BeautifulName(path.Base(prevHyphaName)))
|
||||||
//line views/readers.qtpl:117
|
//line views/readers.qtpl:118
|
||||||
qw422016.N().S(`</a>
|
qw422016.N().S(`</a>
|
||||||
`)
|
`)
|
||||||
//line views/readers.qtpl:118
|
//line views/readers.qtpl:119
|
||||||
}
|
}
|
||||||
//line views/readers.qtpl:118
|
//line views/readers.qtpl:119
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
`)
|
`)
|
||||||
//line views/readers.qtpl:119
|
//line views/readers.qtpl:120
|
||||||
if nextHyphaName != "" {
|
if nextHyphaName != "" {
|
||||||
//line views/readers.qtpl:119
|
//line views/readers.qtpl:120
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
<a class="prevnext__el prevnext__next" href="/hypha/`)
|
<a class="prevnext__el prevnext__next" href="/hypha/`)
|
||||||
//line views/readers.qtpl:120
|
//line views/readers.qtpl:121
|
||||||
qw422016.E().S(nextHyphaName)
|
qw422016.E().S(nextHyphaName)
|
||||||
//line views/readers.qtpl:120
|
//line views/readers.qtpl:121
|
||||||
qw422016.N().S(`" rel="next">`)
|
qw422016.N().S(`" rel="next">`)
|
||||||
//line views/readers.qtpl:120
|
//line views/readers.qtpl:121
|
||||||
qw422016.E().S(util.BeautifulName(path.Base(nextHyphaName)))
|
qw422016.E().S(util.BeautifulName(path.Base(nextHyphaName)))
|
||||||
//line views/readers.qtpl:120
|
//line views/readers.qtpl:121
|
||||||
qw422016.N().S(` →</a>
|
qw422016.N().S(` →</a>
|
||||||
`)
|
`)
|
||||||
//line views/readers.qtpl:121
|
//line views/readers.qtpl:122
|
||||||
}
|
}
|
||||||
//line views/readers.qtpl:121
|
//line views/readers.qtpl:122
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
</section>
|
</section>
|
||||||
`)
|
`)
|
||||||
//line views/readers.qtpl:123
|
//line views/readers.qtpl:124
|
||||||
StreamSubhyphaeHTML(qw422016, subhyphae, lc)
|
StreamSubhyphaeHTML(qw422016, subhyphae, lc)
|
||||||
//line views/readers.qtpl:123
|
//line views/readers.qtpl:124
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
<section id="hypha-bottom">
|
<section id="hypha-bottom">
|
||||||
`)
|
`)
|
||||||
//line views/readers.qtpl:125
|
//line views/readers.qtpl:126
|
||||||
streamhyphaInfo(qw422016, rq, h)
|
streamhyphaInfo(qw422016, rq, h)
|
||||||
//line views/readers.qtpl:125
|
//line views/readers.qtpl:126
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
`)
|
`)
|
||||||
//line views/readers.qtpl:128
|
//line views/readers.qtpl:129
|
||||||
streamsiblingHyphaeHTML(qw422016, siblings, lc)
|
streamsiblingHyphaeHTML(qw422016, siblings, lc)
|
||||||
//line views/readers.qtpl:128
|
//line views/readers.qtpl:129
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
</div>
|
</div>
|
||||||
`)
|
`)
|
||||||
//line views/readers.qtpl:130
|
//line views/readers.qtpl:131
|
||||||
streamviewScripts(qw422016)
|
streamviewScripts(qw422016)
|
||||||
//line views/readers.qtpl:130
|
//line views/readers.qtpl:131
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
`)
|
`)
|
||||||
//line views/readers.qtpl:131
|
//line views/readers.qtpl:132
|
||||||
}
|
}
|
||||||
|
|
||||||
//line views/readers.qtpl:131
|
//line views/readers.qtpl:132
|
||||||
func WriteHyphaHTML(qq422016 qtio422016.Writer, rq *http.Request, lc *l18n.Localizer, h hyphae.Hypher, contents string) {
|
func WriteHyphaHTML(qq422016 qtio422016.Writer, rq *http.Request, lc *l18n.Localizer, h hyphae.Hypher, contents string) {
|
||||||
//line views/readers.qtpl:131
|
//line views/readers.qtpl:132
|
||||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||||
//line views/readers.qtpl:131
|
//line views/readers.qtpl:132
|
||||||
StreamHyphaHTML(qw422016, rq, lc, h, contents)
|
StreamHyphaHTML(qw422016, rq, lc, h, contents)
|
||||||
//line views/readers.qtpl:131
|
//line views/readers.qtpl:132
|
||||||
qt422016.ReleaseWriter(qw422016)
|
qt422016.ReleaseWriter(qw422016)
|
||||||
//line views/readers.qtpl:131
|
//line views/readers.qtpl:132
|
||||||
}
|
}
|
||||||
|
|
||||||
//line views/readers.qtpl:131
|
//line views/readers.qtpl:132
|
||||||
func HyphaHTML(rq *http.Request, lc *l18n.Localizer, h hyphae.Hypher, contents string) string {
|
func HyphaHTML(rq *http.Request, lc *l18n.Localizer, h hyphae.Hypher, contents string) string {
|
||||||
//line views/readers.qtpl:131
|
//line views/readers.qtpl:132
|
||||||
qb422016 := qt422016.AcquireByteBuffer()
|
qb422016 := qt422016.AcquireByteBuffer()
|
||||||
//line views/readers.qtpl:131
|
//line views/readers.qtpl:132
|
||||||
WriteHyphaHTML(qb422016, rq, lc, h, contents)
|
WriteHyphaHTML(qb422016, rq, lc, h, contents)
|
||||||
//line views/readers.qtpl:131
|
//line views/readers.qtpl:132
|
||||||
qs422016 := string(qb422016.B)
|
qs422016 := string(qb422016.B)
|
||||||
//line views/readers.qtpl:131
|
//line views/readers.qtpl:132
|
||||||
qt422016.ReleaseByteBuffer(qb422016)
|
qt422016.ReleaseByteBuffer(qb422016)
|
||||||
//line views/readers.qtpl:131
|
//line views/readers.qtpl:132
|
||||||
return qs422016
|
return qs422016
|
||||||
//line views/readers.qtpl:131
|
//line views/readers.qtpl:132
|
||||||
}
|
}
|
||||||
|
|
||||||
//line views/readers.qtpl:133
|
//line views/readers.qtpl:134
|
||||||
func StreamRevisionHTML(qw422016 *qt422016.Writer, rq *http.Request, lc *l18n.Localizer, h hyphae.Hypher, contents, revHash string) {
|
func StreamRevisionHTML(qw422016 *qt422016.Writer, rq *http.Request, lc *l18n.Localizer, h hyphae.Hypher, contents, revHash string) {
|
||||||
//line views/readers.qtpl:133
|
//line views/readers.qtpl:134
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
`)
|
`)
|
||||||
//line views/readers.qtpl:135
|
//line views/readers.qtpl:136
|
||||||
siblings, subhyphae, _, _ := tree.Tree(h.CanonicalName())
|
siblings, subhyphae, _, _ := tree.Tree(h.CanonicalName())
|
||||||
|
|
||||||
//line views/readers.qtpl:136
|
//line views/readers.qtpl:137
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
<div class="layout">
|
<div class="layout">
|
||||||
<main class="main-width">
|
<main class="main-width">
|
||||||
<section>
|
<section>
|
||||||
<p>`)
|
<p>`)
|
||||||
//line views/readers.qtpl:140
|
//line views/readers.qtpl:141
|
||||||
qw422016.E().S(lc.Get("ui.revision_warning"))
|
qw422016.E().S(lc.Get("ui.revision_warning"))
|
||||||
//line views/readers.qtpl:140
|
//line views/readers.qtpl:141
|
||||||
qw422016.N().S(` <a href="/rev-text/`)
|
qw422016.N().S(` <a href="/rev-text/`)
|
||||||
//line views/readers.qtpl:140
|
//line views/readers.qtpl:141
|
||||||
qw422016.E().S(revHash)
|
qw422016.E().S(revHash)
|
||||||
//line views/readers.qtpl:140
|
//line views/readers.qtpl:141
|
||||||
qw422016.N().S(`/`)
|
qw422016.N().S(`/`)
|
||||||
//line views/readers.qtpl:140
|
//line views/readers.qtpl:141
|
||||||
qw422016.E().S(h.CanonicalName())
|
qw422016.E().S(h.CanonicalName())
|
||||||
//line views/readers.qtpl:140
|
//line views/readers.qtpl:141
|
||||||
qw422016.N().S(`">`)
|
qw422016.N().S(`">`)
|
||||||
//line views/readers.qtpl:140
|
//line views/readers.qtpl:141
|
||||||
qw422016.E().S(lc.Get("ui.revision_link"))
|
qw422016.E().S(lc.Get("ui.revision_link"))
|
||||||
//line views/readers.qtpl:140
|
//line views/readers.qtpl:141
|
||||||
qw422016.N().S(`</a></p>
|
qw422016.N().S(`</a></p>
|
||||||
`)
|
`)
|
||||||
//line views/readers.qtpl:141
|
//line views/readers.qtpl:142
|
||||||
qw422016.N().S(NaviTitleHTML(h))
|
qw422016.N().S(NaviTitleHTML(h))
|
||||||
//line views/readers.qtpl:141
|
//line views/readers.qtpl:142
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
`)
|
`)
|
||||||
//line views/readers.qtpl:142
|
//line views/readers.qtpl:143
|
||||||
qw422016.N().S(contents)
|
qw422016.N().S(contents)
|
||||||
//line views/readers.qtpl:142
|
//line views/readers.qtpl:143
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
</section>
|
</section>
|
||||||
`)
|
`)
|
||||||
//line views/readers.qtpl:144
|
//line views/readers.qtpl:145
|
||||||
StreamSubhyphaeHTML(qw422016, subhyphae, lc)
|
StreamSubhyphaeHTML(qw422016, subhyphae, lc)
|
||||||
//line views/readers.qtpl:144
|
//line views/readers.qtpl:145
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
</main>
|
</main>
|
||||||
`)
|
`)
|
||||||
//line views/readers.qtpl:146
|
//line views/readers.qtpl:147
|
||||||
streamsiblingHyphaeHTML(qw422016, siblings, lc)
|
streamsiblingHyphaeHTML(qw422016, siblings, lc)
|
||||||
//line views/readers.qtpl:146
|
//line views/readers.qtpl:147
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
</div>
|
</div>
|
||||||
`)
|
`)
|
||||||
//line views/readers.qtpl:148
|
//line views/readers.qtpl:149
|
||||||
streamviewScripts(qw422016)
|
streamviewScripts(qw422016)
|
||||||
//line views/readers.qtpl:148
|
//line views/readers.qtpl:149
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
`)
|
`)
|
||||||
//line views/readers.qtpl:149
|
//line views/readers.qtpl:150
|
||||||
}
|
}
|
||||||
|
|
||||||
//line views/readers.qtpl:149
|
//line views/readers.qtpl:150
|
||||||
func WriteRevisionHTML(qq422016 qtio422016.Writer, rq *http.Request, lc *l18n.Localizer, h hyphae.Hypher, contents, revHash string) {
|
func WriteRevisionHTML(qq422016 qtio422016.Writer, rq *http.Request, lc *l18n.Localizer, h hyphae.Hypher, contents, revHash string) {
|
||||||
//line views/readers.qtpl:149
|
//line views/readers.qtpl:150
|
||||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||||
//line views/readers.qtpl:149
|
//line views/readers.qtpl:150
|
||||||
StreamRevisionHTML(qw422016, rq, lc, h, contents, revHash)
|
StreamRevisionHTML(qw422016, rq, lc, h, contents, revHash)
|
||||||
//line views/readers.qtpl:149
|
//line views/readers.qtpl:150
|
||||||
qt422016.ReleaseWriter(qw422016)
|
qt422016.ReleaseWriter(qw422016)
|
||||||
//line views/readers.qtpl:149
|
//line views/readers.qtpl:150
|
||||||
}
|
}
|
||||||
|
|
||||||
//line views/readers.qtpl:149
|
//line views/readers.qtpl:150
|
||||||
func RevisionHTML(rq *http.Request, lc *l18n.Localizer, h hyphae.Hypher, contents, revHash string) string {
|
func RevisionHTML(rq *http.Request, lc *l18n.Localizer, h hyphae.Hypher, contents, revHash string) string {
|
||||||
//line views/readers.qtpl:149
|
//line views/readers.qtpl:150
|
||||||
qb422016 := qt422016.AcquireByteBuffer()
|
qb422016 := qt422016.AcquireByteBuffer()
|
||||||
//line views/readers.qtpl:149
|
//line views/readers.qtpl:150
|
||||||
WriteRevisionHTML(qb422016, rq, lc, h, contents, revHash)
|
WriteRevisionHTML(qb422016, rq, lc, h, contents, revHash)
|
||||||
//line views/readers.qtpl:149
|
//line views/readers.qtpl:150
|
||||||
qs422016 := string(qb422016.B)
|
qs422016 := string(qb422016.B)
|
||||||
//line views/readers.qtpl:149
|
//line views/readers.qtpl:150
|
||||||
qt422016.ReleaseByteBuffer(qb422016)
|
qt422016.ReleaseByteBuffer(qb422016)
|
||||||
//line views/readers.qtpl:149
|
//line views/readers.qtpl:150
|
||||||
return qs422016
|
return qs422016
|
||||||
//line views/readers.qtpl:149
|
//line views/readers.qtpl:150
|
||||||
}
|
}
|
||||||
|
|
||||||
//line views/readers.qtpl:151
|
//line views/readers.qtpl:152
|
||||||
func streamviewScripts(qw422016 *qt422016.Writer) {
|
func streamviewScripts(qw422016 *qt422016.Writer) {
|
||||||
//line views/readers.qtpl:151
|
//line views/readers.qtpl:152
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
`)
|
`)
|
||||||
//line views/readers.qtpl:152
|
//line views/readers.qtpl:153
|
||||||
for _, scriptPath := range cfg.ViewScripts {
|
for _, scriptPath := range cfg.ViewScripts {
|
||||||
//line views/readers.qtpl:152
|
//line views/readers.qtpl:153
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
<script src="`)
|
<script src="`)
|
||||||
//line views/readers.qtpl:153
|
//line views/readers.qtpl:154
|
||||||
qw422016.E().S(scriptPath)
|
qw422016.E().S(scriptPath)
|
||||||
//line views/readers.qtpl:153
|
//line views/readers.qtpl:154
|
||||||
qw422016.N().S(`"></script>
|
qw422016.N().S(`"></script>
|
||||||
`)
|
`)
|
||||||
//line views/readers.qtpl:154
|
//line views/readers.qtpl:155
|
||||||
}
|
}
|
||||||
//line views/readers.qtpl:154
|
//line views/readers.qtpl:155
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
`)
|
`)
|
||||||
//line views/readers.qtpl:155
|
//line views/readers.qtpl:156
|
||||||
}
|
}
|
||||||
|
|
||||||
//line views/readers.qtpl:155
|
//line views/readers.qtpl:156
|
||||||
func writeviewScripts(qq422016 qtio422016.Writer) {
|
func writeviewScripts(qq422016 qtio422016.Writer) {
|
||||||
//line views/readers.qtpl:155
|
//line views/readers.qtpl:156
|
||||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||||
//line views/readers.qtpl:155
|
//line views/readers.qtpl:156
|
||||||
streamviewScripts(qw422016)
|
streamviewScripts(qw422016)
|
||||||
//line views/readers.qtpl:155
|
//line views/readers.qtpl:156
|
||||||
qt422016.ReleaseWriter(qw422016)
|
qt422016.ReleaseWriter(qw422016)
|
||||||
//line views/readers.qtpl:155
|
//line views/readers.qtpl:156
|
||||||
}
|
}
|
||||||
|
|
||||||
//line views/readers.qtpl:155
|
//line views/readers.qtpl:156
|
||||||
func viewScripts() string {
|
func viewScripts() string {
|
||||||
//line views/readers.qtpl:155
|
//line views/readers.qtpl:156
|
||||||
qb422016 := qt422016.AcquireByteBuffer()
|
qb422016 := qt422016.AcquireByteBuffer()
|
||||||
//line views/readers.qtpl:155
|
//line views/readers.qtpl:156
|
||||||
writeviewScripts(qb422016)
|
writeviewScripts(qb422016)
|
||||||
//line views/readers.qtpl:155
|
//line views/readers.qtpl:156
|
||||||
qs422016 := string(qb422016.B)
|
qs422016 := string(qb422016.B)
|
||||||
//line views/readers.qtpl:155
|
//line views/readers.qtpl:156
|
||||||
qt422016.ReleaseByteBuffer(qb422016)
|
qt422016.ReleaseByteBuffer(qb422016)
|
||||||
//line views/readers.qtpl:155
|
//line views/readers.qtpl:156
|
||||||
return qs422016
|
return qs422016
|
||||||
//line views/readers.qtpl:155
|
//line views/readers.qtpl:156
|
||||||
}
|
}
|
||||||
|
@ -262,11 +262,15 @@ sort.Strings(editors)
|
|||||||
close(hyphaNames)
|
close(hyphaNames)
|
||||||
%}
|
%}
|
||||||
{% for hyphaName := range sortedHypha %}
|
{% for hyphaName := range sortedHypha %}
|
||||||
{% code hypha := hyphae.ByName(hyphaName) %}
|
{% code hypha := hyphae.ByName(hyphaName).(*hyphae.MediaHypha) %}
|
||||||
<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.MediaHypha).BinaryPath())[1:] %}</span>
|
<span class="hypha-list__amnt-type">
|
||||||
|
{%s filepath.Ext(hypha.BinaryPath())[1:] %}
|
||||||
|
</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -1020,7 +1020,7 @@ func StreamHyphaListHTML(qw422016 *qt422016.Writer, lc *l18n.Localizer) {
|
|||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
`)
|
`)
|
||||||
//line views/stuff.qtpl:265
|
//line views/stuff.qtpl:265
|
||||||
hypha := hyphae.ByName(hyphaName)
|
hypha := hyphae.ByName(hyphaName).(*hyphae.MediaHypha)
|
||||||
|
|
||||||
//line views/stuff.qtpl:265
|
//line views/stuff.qtpl:265
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
@ -1029,234 +1029,238 @@ func StreamHyphaListHTML(qw422016 *qt422016.Writer, lc *l18n.Localizer) {
|
|||||||
//line views/stuff.qtpl:267
|
//line views/stuff.qtpl:267
|
||||||
qw422016.E().S(hypha.CanonicalName())
|
qw422016.E().S(hypha.CanonicalName())
|
||||||
//line views/stuff.qtpl:267
|
//line views/stuff.qtpl:267
|
||||||
qw422016.N().S(`">`)
|
qw422016.N().S(`">
|
||||||
//line views/stuff.qtpl:267
|
`)
|
||||||
|
//line views/stuff.qtpl:268
|
||||||
qw422016.E().S(util.BeautifulName(hypha.CanonicalName()))
|
qw422016.E().S(util.BeautifulName(hypha.CanonicalName()))
|
||||||
//line views/stuff.qtpl:267
|
|
||||||
qw422016.N().S(`</a>
|
|
||||||
`)
|
|
||||||
//line views/stuff.qtpl:268
|
//line views/stuff.qtpl:268
|
||||||
|
qw422016.N().S(`
|
||||||
|
</a>
|
||||||
|
`)
|
||||||
|
//line views/stuff.qtpl:270
|
||||||
if hypha.Kind() == hyphae.HyphaMedia {
|
if hypha.Kind() == hyphae.HyphaMedia {
|
||||||
//line views/stuff.qtpl:268
|
//line views/stuff.qtpl:270
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
<span class="hypha-list__amnt-type">`)
|
<span class="hypha-list__amnt-type">
|
||||||
//line views/stuff.qtpl:269
|
`)
|
||||||
qw422016.E().S(filepath.Ext(hypha.(*hyphae.MediaHypha).BinaryPath())[1:])
|
//line views/stuff.qtpl:272
|
||||||
//line views/stuff.qtpl:269
|
qw422016.E().S(filepath.Ext(hypha.BinaryPath())[1:])
|
||||||
qw422016.N().S(`</span>
|
//line views/stuff.qtpl:272
|
||||||
|
qw422016.N().S(`
|
||||||
|
</span>
|
||||||
`)
|
`)
|
||||||
//line views/stuff.qtpl:270
|
//line views/stuff.qtpl:274
|
||||||
}
|
}
|
||||||
//line views/stuff.qtpl:270
|
//line views/stuff.qtpl:274
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
</li>
|
</li>
|
||||||
`)
|
`)
|
||||||
//line views/stuff.qtpl:272
|
//line views/stuff.qtpl:276
|
||||||
}
|
}
|
||||||
//line views/stuff.qtpl:272
|
//line views/stuff.qtpl:276
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
</ul>
|
</ul>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
`)
|
`)
|
||||||
//line views/stuff.qtpl:276
|
//line views/stuff.qtpl:280
|
||||||
}
|
}
|
||||||
|
|
||||||
//line views/stuff.qtpl:276
|
//line views/stuff.qtpl:280
|
||||||
func WriteHyphaListHTML(qq422016 qtio422016.Writer, lc *l18n.Localizer) {
|
func WriteHyphaListHTML(qq422016 qtio422016.Writer, lc *l18n.Localizer) {
|
||||||
//line views/stuff.qtpl:276
|
//line views/stuff.qtpl:280
|
||||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||||
//line views/stuff.qtpl:276
|
//line views/stuff.qtpl:280
|
||||||
StreamHyphaListHTML(qw422016, lc)
|
StreamHyphaListHTML(qw422016, lc)
|
||||||
//line views/stuff.qtpl:276
|
//line views/stuff.qtpl:280
|
||||||
qt422016.ReleaseWriter(qw422016)
|
qt422016.ReleaseWriter(qw422016)
|
||||||
//line views/stuff.qtpl:276
|
//line views/stuff.qtpl:280
|
||||||
}
|
}
|
||||||
|
|
||||||
//line views/stuff.qtpl:276
|
//line views/stuff.qtpl:280
|
||||||
func HyphaListHTML(lc *l18n.Localizer) string {
|
func HyphaListHTML(lc *l18n.Localizer) string {
|
||||||
//line views/stuff.qtpl:276
|
//line views/stuff.qtpl:280
|
||||||
qb422016 := qt422016.AcquireByteBuffer()
|
qb422016 := qt422016.AcquireByteBuffer()
|
||||||
//line views/stuff.qtpl:276
|
//line views/stuff.qtpl:280
|
||||||
WriteHyphaListHTML(qb422016, lc)
|
WriteHyphaListHTML(qb422016, lc)
|
||||||
//line views/stuff.qtpl:276
|
//line views/stuff.qtpl:280
|
||||||
qs422016 := string(qb422016.B)
|
qs422016 := string(qb422016.B)
|
||||||
//line views/stuff.qtpl:276
|
//line views/stuff.qtpl:280
|
||||||
qt422016.ReleaseByteBuffer(qb422016)
|
qt422016.ReleaseByteBuffer(qb422016)
|
||||||
//line views/stuff.qtpl:276
|
//line views/stuff.qtpl:280
|
||||||
return qs422016
|
return qs422016
|
||||||
//line views/stuff.qtpl:276
|
//line views/stuff.qtpl:280
|
||||||
}
|
}
|
||||||
|
|
||||||
//line views/stuff.qtpl:278
|
//line views/stuff.qtpl:282
|
||||||
func StreamAboutHTML(qw422016 *qt422016.Writer, lc *l18n.Localizer) {
|
func StreamAboutHTML(qw422016 *qt422016.Writer, lc *l18n.Localizer) {
|
||||||
//line views/stuff.qtpl:278
|
//line views/stuff.qtpl:282
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
<div class="layout">
|
<div class="layout">
|
||||||
<main class="main-width">
|
<main class="main-width">
|
||||||
<section>
|
<section>
|
||||||
<h1>`)
|
<h1>`)
|
||||||
//line views/stuff.qtpl:282
|
//line views/stuff.qtpl:286
|
||||||
qw422016.E().S(lc.Get("ui.about_title", &l18n.Replacements{"name": cfg.WikiName}))
|
qw422016.E().S(lc.Get("ui.about_title", &l18n.Replacements{"name": cfg.WikiName}))
|
||||||
//line views/stuff.qtpl:282
|
//line views/stuff.qtpl:286
|
||||||
qw422016.N().S(`</h1>
|
qw422016.N().S(`</h1>
|
||||||
<ul>
|
<ul>
|
||||||
<li><b>`)
|
<li><b>`)
|
||||||
//line views/stuff.qtpl:284
|
//line views/stuff.qtpl:288
|
||||||
qw422016.N().S(lc.Get("ui.about_version", &l18n.Replacements{"pre": "<a href=\"https://mycorrhiza.wiki\">", "post": "</a>"}))
|
qw422016.N().S(lc.Get("ui.about_version", &l18n.Replacements{"pre": "<a href=\"https://mycorrhiza.wiki\">", "post": "</a>"}))
|
||||||
//line views/stuff.qtpl:284
|
//line views/stuff.qtpl:288
|
||||||
qw422016.N().S(`</b> 1.8.0</li>
|
qw422016.N().S(`</b> 1.8.0</li>
|
||||||
`)
|
`)
|
||||||
//line views/stuff.qtpl:285
|
//line views/stuff.qtpl:289
|
||||||
if cfg.UseAuth {
|
if cfg.UseAuth {
|
||||||
//line views/stuff.qtpl:285
|
//line views/stuff.qtpl:289
|
||||||
qw422016.N().S(` <li><b>`)
|
qw422016.N().S(` <li><b>`)
|
||||||
//line views/stuff.qtpl:286
|
//line views/stuff.qtpl:290
|
||||||
qw422016.E().S(lc.Get("ui.about_usercount"))
|
qw422016.E().S(lc.Get("ui.about_usercount"))
|
||||||
//line views/stuff.qtpl:286
|
//line views/stuff.qtpl:290
|
||||||
qw422016.N().S(`</b> `)
|
qw422016.N().S(`</b> `)
|
||||||
//line views/stuff.qtpl:286
|
//line views/stuff.qtpl:290
|
||||||
qw422016.N().DUL(user.Count())
|
qw422016.N().DUL(user.Count())
|
||||||
//line views/stuff.qtpl:286
|
//line views/stuff.qtpl:290
|
||||||
qw422016.N().S(`</li>
|
qw422016.N().S(`</li>
|
||||||
<li><b>`)
|
<li><b>`)
|
||||||
//line views/stuff.qtpl:287
|
//line views/stuff.qtpl:291
|
||||||
qw422016.E().S(lc.Get("ui.about_homepage"))
|
qw422016.E().S(lc.Get("ui.about_homepage"))
|
||||||
//line views/stuff.qtpl:287
|
//line views/stuff.qtpl:291
|
||||||
qw422016.N().S(`</b> <a href="/">`)
|
qw422016.N().S(`</b> <a href="/">`)
|
||||||
//line views/stuff.qtpl:287
|
//line views/stuff.qtpl:291
|
||||||
qw422016.E().S(cfg.HomeHypha)
|
qw422016.E().S(cfg.HomeHypha)
|
||||||
//line views/stuff.qtpl:287
|
//line views/stuff.qtpl:291
|
||||||
qw422016.N().S(`</a></li>
|
qw422016.N().S(`</a></li>
|
||||||
<li><b>`)
|
<li><b>`)
|
||||||
//line views/stuff.qtpl:288
|
//line views/stuff.qtpl:292
|
||||||
qw422016.E().S(lc.Get("ui.about_admins"))
|
qw422016.E().S(lc.Get("ui.about_admins"))
|
||||||
//line views/stuff.qtpl:288
|
//line views/stuff.qtpl:292
|
||||||
qw422016.N().S(`</b>`)
|
qw422016.N().S(`</b>`)
|
||||||
//line views/stuff.qtpl:288
|
//line views/stuff.qtpl:292
|
||||||
for i, username := range user.ListUsersWithGroup("admin") {
|
for i, username := range user.ListUsersWithGroup("admin") {
|
||||||
//line views/stuff.qtpl:289
|
//line views/stuff.qtpl:293
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
//line views/stuff.qtpl:289
|
//line views/stuff.qtpl:293
|
||||||
qw422016.N().S(`<span aria-hidden="true">, </span>
|
qw422016.N().S(`<span aria-hidden="true">, </span>
|
||||||
`)
|
`)
|
||||||
//line views/stuff.qtpl:290
|
//line views/stuff.qtpl:294
|
||||||
}
|
}
|
||||||
//line views/stuff.qtpl:290
|
//line views/stuff.qtpl:294
|
||||||
qw422016.N().S(` <a href="/hypha/`)
|
qw422016.N().S(` <a href="/hypha/`)
|
||||||
//line views/stuff.qtpl:291
|
//line views/stuff.qtpl:295
|
||||||
qw422016.E().S(cfg.UserHypha)
|
qw422016.E().S(cfg.UserHypha)
|
||||||
//line views/stuff.qtpl:291
|
//line views/stuff.qtpl:295
|
||||||
qw422016.N().S(`/`)
|
qw422016.N().S(`/`)
|
||||||
//line views/stuff.qtpl:291
|
//line views/stuff.qtpl:295
|
||||||
qw422016.E().S(username)
|
qw422016.E().S(username)
|
||||||
//line views/stuff.qtpl:291
|
//line views/stuff.qtpl:295
|
||||||
qw422016.N().S(`">`)
|
qw422016.N().S(`">`)
|
||||||
//line views/stuff.qtpl:291
|
//line views/stuff.qtpl:295
|
||||||
qw422016.E().S(username)
|
qw422016.E().S(username)
|
||||||
//line views/stuff.qtpl:291
|
//line views/stuff.qtpl:295
|
||||||
qw422016.N().S(`</a>`)
|
qw422016.N().S(`</a>`)
|
||||||
//line views/stuff.qtpl:291
|
//line views/stuff.qtpl:295
|
||||||
}
|
}
|
||||||
//line views/stuff.qtpl:291
|
//line views/stuff.qtpl:295
|
||||||
qw422016.N().S(`</li>
|
qw422016.N().S(`</li>
|
||||||
`)
|
`)
|
||||||
//line views/stuff.qtpl:292
|
//line views/stuff.qtpl:296
|
||||||
} else {
|
} else {
|
||||||
//line views/stuff.qtpl:292
|
//line views/stuff.qtpl:296
|
||||||
qw422016.N().S(` <li>`)
|
qw422016.N().S(` <li>`)
|
||||||
//line views/stuff.qtpl:293
|
//line views/stuff.qtpl:297
|
||||||
qw422016.E().S(lc.Get("ui.about_noauth"))
|
qw422016.E().S(lc.Get("ui.about_noauth"))
|
||||||
//line views/stuff.qtpl:293
|
//line views/stuff.qtpl:297
|
||||||
qw422016.N().S(`</li>
|
qw422016.N().S(`</li>
|
||||||
`)
|
`)
|
||||||
//line views/stuff.qtpl:294
|
//line views/stuff.qtpl:298
|
||||||
}
|
}
|
||||||
//line views/stuff.qtpl:294
|
//line views/stuff.qtpl:298
|
||||||
qw422016.N().S(` </ul>
|
qw422016.N().S(` </ul>
|
||||||
<p>`)
|
<p>`)
|
||||||
//line views/stuff.qtpl:296
|
//line views/stuff.qtpl:300
|
||||||
qw422016.N().S(lc.Get("ui.about_hyphae", &l18n.Replacements{"link": "<a href=\"/list\">/list</a>"}))
|
qw422016.N().S(lc.Get("ui.about_hyphae", &l18n.Replacements{"link": "<a href=\"/list\">/list</a>"}))
|
||||||
//line views/stuff.qtpl:296
|
//line views/stuff.qtpl:300
|
||||||
qw422016.N().S(`</p>
|
qw422016.N().S(`</p>
|
||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
`)
|
`)
|
||||||
//line views/stuff.qtpl:300
|
//line views/stuff.qtpl:304
|
||||||
}
|
}
|
||||||
|
|
||||||
//line views/stuff.qtpl:300
|
//line views/stuff.qtpl:304
|
||||||
func WriteAboutHTML(qq422016 qtio422016.Writer, lc *l18n.Localizer) {
|
func WriteAboutHTML(qq422016 qtio422016.Writer, lc *l18n.Localizer) {
|
||||||
//line views/stuff.qtpl:300
|
//line views/stuff.qtpl:304
|
||||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||||
//line views/stuff.qtpl:300
|
//line views/stuff.qtpl:304
|
||||||
StreamAboutHTML(qw422016, lc)
|
StreamAboutHTML(qw422016, lc)
|
||||||
//line views/stuff.qtpl:300
|
//line views/stuff.qtpl:304
|
||||||
qt422016.ReleaseWriter(qw422016)
|
qt422016.ReleaseWriter(qw422016)
|
||||||
//line views/stuff.qtpl:300
|
//line views/stuff.qtpl:304
|
||||||
}
|
}
|
||||||
|
|
||||||
//line views/stuff.qtpl:300
|
//line views/stuff.qtpl:304
|
||||||
func AboutHTML(lc *l18n.Localizer) string {
|
func AboutHTML(lc *l18n.Localizer) string {
|
||||||
//line views/stuff.qtpl:300
|
//line views/stuff.qtpl:304
|
||||||
qb422016 := qt422016.AcquireByteBuffer()
|
qb422016 := qt422016.AcquireByteBuffer()
|
||||||
//line views/stuff.qtpl:300
|
//line views/stuff.qtpl:304
|
||||||
WriteAboutHTML(qb422016, lc)
|
WriteAboutHTML(qb422016, lc)
|
||||||
//line views/stuff.qtpl:300
|
//line views/stuff.qtpl:304
|
||||||
qs422016 := string(qb422016.B)
|
qs422016 := string(qb422016.B)
|
||||||
//line views/stuff.qtpl:300
|
//line views/stuff.qtpl:304
|
||||||
qt422016.ReleaseByteBuffer(qb422016)
|
qt422016.ReleaseByteBuffer(qb422016)
|
||||||
//line views/stuff.qtpl:300
|
//line views/stuff.qtpl:304
|
||||||
return qs422016
|
return qs422016
|
||||||
//line views/stuff.qtpl:300
|
//line views/stuff.qtpl:304
|
||||||
}
|
}
|
||||||
|
|
||||||
//line views/stuff.qtpl:302
|
//line views/stuff.qtpl:306
|
||||||
func StreamCommonScripts(qw422016 *qt422016.Writer) {
|
func StreamCommonScripts(qw422016 *qt422016.Writer) {
|
||||||
//line views/stuff.qtpl:302
|
//line views/stuff.qtpl:306
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
`)
|
`)
|
||||||
//line views/stuff.qtpl:303
|
//line views/stuff.qtpl:307
|
||||||
for _, scriptPath := range cfg.CommonScripts {
|
for _, scriptPath := range cfg.CommonScripts {
|
||||||
//line views/stuff.qtpl:303
|
//line views/stuff.qtpl:307
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
<script src="`)
|
<script src="`)
|
||||||
//line views/stuff.qtpl:304
|
//line views/stuff.qtpl:308
|
||||||
qw422016.E().S(scriptPath)
|
qw422016.E().S(scriptPath)
|
||||||
//line views/stuff.qtpl:304
|
//line views/stuff.qtpl:308
|
||||||
qw422016.N().S(`"></script>
|
qw422016.N().S(`"></script>
|
||||||
`)
|
`)
|
||||||
//line views/stuff.qtpl:305
|
//line views/stuff.qtpl:309
|
||||||
}
|
}
|
||||||
//line views/stuff.qtpl:305
|
//line views/stuff.qtpl:309
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
`)
|
`)
|
||||||
//line views/stuff.qtpl:306
|
//line views/stuff.qtpl:310
|
||||||
}
|
}
|
||||||
|
|
||||||
//line views/stuff.qtpl:306
|
//line views/stuff.qtpl:310
|
||||||
func WriteCommonScripts(qq422016 qtio422016.Writer) {
|
func WriteCommonScripts(qq422016 qtio422016.Writer) {
|
||||||
//line views/stuff.qtpl:306
|
//line views/stuff.qtpl:310
|
||||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||||
//line views/stuff.qtpl:306
|
//line views/stuff.qtpl:310
|
||||||
StreamCommonScripts(qw422016)
|
StreamCommonScripts(qw422016)
|
||||||
//line views/stuff.qtpl:306
|
//line views/stuff.qtpl:310
|
||||||
qt422016.ReleaseWriter(qw422016)
|
qt422016.ReleaseWriter(qw422016)
|
||||||
//line views/stuff.qtpl:306
|
//line views/stuff.qtpl:310
|
||||||
}
|
}
|
||||||
|
|
||||||
//line views/stuff.qtpl:306
|
//line views/stuff.qtpl:310
|
||||||
func CommonScripts() string {
|
func CommonScripts() string {
|
||||||
//line views/stuff.qtpl:306
|
//line views/stuff.qtpl:310
|
||||||
qb422016 := qt422016.AcquireByteBuffer()
|
qb422016 := qt422016.AcquireByteBuffer()
|
||||||
//line views/stuff.qtpl:306
|
//line views/stuff.qtpl:310
|
||||||
WriteCommonScripts(qb422016)
|
WriteCommonScripts(qb422016)
|
||||||
//line views/stuff.qtpl:306
|
//line views/stuff.qtpl:310
|
||||||
qs422016 := string(qb422016.B)
|
qs422016 := string(qb422016.B)
|
||||||
//line views/stuff.qtpl:306
|
//line views/stuff.qtpl:310
|
||||||
qt422016.ReleaseByteBuffer(qb422016)
|
qt422016.ReleaseByteBuffer(qb422016)
|
||||||
//line views/stuff.qtpl:306
|
//line views/stuff.qtpl:310
|
||||||
return qs422016
|
return qs422016
|
||||||
//line views/stuff.qtpl:306
|
//line views/stuff.qtpl:310
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,8 @@ func initMutators(r *mux.Router) {
|
|||||||
r.PathPrefix("/unattach-confirm/").HandlerFunc(handlerUnattachConfirm)
|
r.PathPrefix("/unattach-confirm/").HandlerFunc(handlerUnattachConfirm)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// TODO: this is ridiculous, refactor heavily:
|
||||||
|
|
||||||
func factoryHandlerAsker(
|
func factoryHandlerAsker(
|
||||||
actionPath string,
|
actionPath string,
|
||||||
asker func(*user.User, hyphae.Hypher, *l18n.Localizer) (string, error),
|
asker func(*user.User, hyphae.Hypher, *l18n.Localizer) (string, error),
|
||||||
@ -61,7 +63,14 @@ func factoryHandlerAsker(
|
|||||||
w,
|
w,
|
||||||
views.BaseHTML(
|
views.BaseHTML(
|
||||||
fmt.Sprintf(lc.Get(succTitleKey), util.BeautifulName(hyphaName)),
|
fmt.Sprintf(lc.Get(succTitleKey), util.BeautifulName(hyphaName)),
|
||||||
succPageTemplate(rq, hyphaName, h.DoesExist()),
|
succPageTemplate(rq, hyphaName, func(h hyphae.Hypher) bool {
|
||||||
|
switch h.(type) {
|
||||||
|
case *hyphae.EmptyHypha:
|
||||||
|
return false
|
||||||
|
default:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}(h)),
|
||||||
lc,
|
lc,
|
||||||
u))
|
u))
|
||||||
}
|
}
|
||||||
@ -164,7 +173,10 @@ func handlerEdit(w http.ResponseWriter, rq *http.Request) {
|
|||||||
err.Error())
|
err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if h.DoesExist() {
|
switch h.(type) {
|
||||||
|
case *hyphae.EmptyHypha:
|
||||||
|
warning = fmt.Sprintf(`<p class="warning warning_new-hypha">%s</p>`, lc.Get("edit.new_hypha"))
|
||||||
|
default:
|
||||||
textAreaFill, err = shroom.FetchTextPart(h)
|
textAreaFill, err = shroom.FetchTextPart(h)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
@ -173,8 +185,6 @@ func handlerEdit(w http.ResponseWriter, rq *http.Request) {
|
|||||||
lc.Get("ui.error_text_fetch"))
|
lc.Get("ui.error_text_fetch"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
warning = fmt.Sprintf(`<p class="warning warning_new-hypha">%s</p>`, lc.Get("edit.new_hypha"))
|
|
||||||
}
|
}
|
||||||
util.HTTP200Page(
|
util.HTTP200Page(
|
||||||
w,
|
w,
|
||||||
|
@ -138,7 +138,9 @@ func handlerRevision(w http.ResponseWriter, rq *http.Request) {
|
|||||||
func handlerText(w http.ResponseWriter, rq *http.Request) {
|
func handlerText(w http.ResponseWriter, rq *http.Request) {
|
||||||
util.PrepareRq(rq)
|
util.PrepareRq(rq)
|
||||||
hyphaName := util.HyphaNameFromRq(rq, "text")
|
hyphaName := util.HyphaNameFromRq(rq, "text")
|
||||||
if h := hyphae.ByName(hyphaName); h.DoesExist() {
|
switch h := hyphae.ByName(hyphaName).(type) {
|
||||||
|
case *hyphae.EmptyHypha:
|
||||||
|
default:
|
||||||
log.Println("Serving", h.TextPartPath())
|
log.Println("Serving", h.TextPartPath())
|
||||||
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
|
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
|
||||||
http.ServeFile(w, rq, h.TextPartPath())
|
http.ServeFile(w, rq, h.TextPartPath())
|
||||||
@ -149,10 +151,18 @@ 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.MediaHypha); h.DoesExist() {
|
switch h := hyphae.ByName(hyphaName).(type) {
|
||||||
log.Println("Serving", h.BinaryPath())
|
case *hyphae.EmptyHypha:
|
||||||
w.Header().Set("Content-Type", mimetype.FromExtension(filepath.Ext(h.BinaryPath())))
|
default: // TODO: deindent
|
||||||
http.ServeFile(w, rq, h.BinaryPath())
|
switch h := h.(*hyphae.MediaHypha); h.Kind() {
|
||||||
|
case hyphae.HyphaText:
|
||||||
|
w.WriteHeader(http.StatusNotFound)
|
||||||
|
log.Printf("Textual hypha ‘%s’ has no media, cannot serve\n", h.CanonicalName())
|
||||||
|
default:
|
||||||
|
log.Println("Serving", h.BinaryPath())
|
||||||
|
w.Header().Set("Content-Type", mimetype.FromExtension(filepath.Ext(h.BinaryPath())))
|
||||||
|
http.ServeFile(w, rq, h.BinaryPath())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,7 +177,17 @@ func handlerHypha(w http.ResponseWriter, rq *http.Request) {
|
|||||||
u = user.FromRequest(rq)
|
u = user.FromRequest(rq)
|
||||||
lc = l18n.FromRequest(rq)
|
lc = l18n.FromRequest(rq)
|
||||||
)
|
)
|
||||||
if h.DoesExist() {
|
|
||||||
|
switch h := h.(type) {
|
||||||
|
case *hyphae.EmptyHypha:
|
||||||
|
util.HTTP404Page(w,
|
||||||
|
views.BaseHTML(
|
||||||
|
util.BeautifulName(hyphaName),
|
||||||
|
views.HyphaHTML(rq, lc, h, contents),
|
||||||
|
lc,
|
||||||
|
u,
|
||||||
|
openGraph))
|
||||||
|
case *hyphae.MediaHypha:
|
||||||
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))
|
||||||
@ -178,18 +198,9 @@ 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.(*hyphae.MediaHypha), lc) + contents
|
contents = views.AttachmentHTML(h, lc) + contents
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if contents == "" {
|
|
||||||
util.HTTP404Page(w,
|
|
||||||
views.BaseHTML(
|
|
||||||
util.BeautifulName(hyphaName),
|
|
||||||
views.HyphaHTML(rq, lc, h, contents),
|
|
||||||
lc,
|
|
||||||
u,
|
|
||||||
openGraph))
|
|
||||||
} else {
|
|
||||||
util.HTTP200Page(w,
|
util.HTTP200Page(w,
|
||||||
views.BaseHTML(
|
views.BaseHTML(
|
||||||
util.BeautifulName(hyphaName),
|
util.BeautifulName(hyphaName),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user