diff --git a/README.md b/README.md index f564532..2f42622 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ A wiki engine. This is the development branch for version 0.10. Features planned for this version: +* [ ] New file structure * [ ] Mycomarkup * [ ] CLI options * [ ] CSS improvements diff --git a/http_readers.go b/http_readers.go index 5843e4d..8166353 100644 --- a/http_readers.go +++ b/http_readers.go @@ -6,6 +6,7 @@ import ( "log" "net/http" "os" + "path/filepath" "strings" "github.com/bouncepaw/mycorrhiza/gemtext" @@ -75,7 +76,7 @@ func handlerText(w http.ResponseWriter, rq *http.Request) { hyphaName := HyphaNameFromRq(rq, "text") if data, ok := HyphaStorage[hyphaName]; ok { log.Println("Serving", data.textPath) - w.Header().Set("Content-Type", data.textType.Mime()) + w.Header().Set("Content-Type", "text/plain") http.ServeFile(w, rq, data.textPath) } } @@ -86,7 +87,7 @@ func handlerBinary(w http.ResponseWriter, rq *http.Request) { hyphaName := HyphaNameFromRq(rq, "binary") if data, ok := HyphaStorage[hyphaName]; ok { log.Println("Serving", data.binaryPath) - w.Header().Set("Content-Type", data.binaryType.Mime()) + w.Header().Set("Content-Type", ExtensionToMime(filepath.Ext(data.binaryPath))) http.ServeFile(w, rq, data.binaryPath) } } diff --git a/hypha.go b/hypha.go index e630b34..322a3d8 100644 --- a/hypha.go +++ b/hypha.go @@ -36,9 +36,7 @@ func init() { // HyphaData represents a hypha's meta information: binary and text parts rooted paths and content types. type HyphaData struct { textPath string - textType TextType binaryPath string - binaryType BinaryType } // uploadHelp is a helper function for UploadText and UploadBinary @@ -167,14 +165,14 @@ func (hd *HyphaData) RenameHypha(hyphaName, newName string, recursive bool) *his } // binaryHtmlBlock creates an html block for binary part of the hypha. -func binaryHtmlBlock(hyphaName string, d *HyphaData) string { - switch d.binaryType { - case BinaryJpeg, BinaryGif, BinaryPng, BinaryWebp, BinarySvg, BinaryIco: +func binaryHtmlBlock(hyphaName string, hd *HyphaData) string { + switch filepath.Ext(hd.binaryPath) { + case ".jpg", ".gif", ".png", ".webp", ".svg", ".ico": return fmt.Sprintf(`
`, hyphaName) - case BinaryOgg, BinaryWebm, BinaryMp4: + case ".ogg", ".webm", ".mp4": return fmt.Sprintf(`
`, hyphaName) - case BinaryMp3: + case ".mp3": return fmt.Sprintf(`