mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2025-08-06 22:04:11 +00:00
Several improvements
This commit is contained in:
parent
28585171bd
commit
3a04f7e80a
@ -28,13 +28,15 @@ var (
|
|||||||
configJsonPath string
|
configJsonPath string
|
||||||
|
|
||||||
// Default values that can be overriden in config.json
|
// Default values that can be overriden in config.json
|
||||||
Address = "0.0.0.0:80"
|
Address = "0.0.0.0:80"
|
||||||
TitleEditTemplate = `Edit %s`
|
TitleEditTemplate = `Edit %s`
|
||||||
TitleTemplate = `%s`
|
TitleTemplate = `%s`
|
||||||
GenericErrorMsg = `<b>Sorry, something went wrong</b>`
|
GenericErrorMsg = `<b>Sorry, something went wrong</b>`
|
||||||
SiteTitle = `MycorrhizaWiki`
|
SiteTitle = `MycorrhizaWiki`
|
||||||
Theme = `default-light`
|
Theme = `default-light`
|
||||||
Mycelia = []MyceliumConfig{
|
HomePage = `/Home`
|
||||||
|
BinaryLimit int64 = 10 << 20
|
||||||
|
Mycelia = []MyceliumConfig{
|
||||||
{[]string{"main"}, "main"},
|
{[]string{"main"}, "main"},
|
||||||
{[]string{"sys", "system"}, "system"},
|
{[]string{"sys", "system"}, "system"},
|
||||||
}
|
}
|
||||||
@ -64,6 +66,8 @@ func readConfig() bool {
|
|||||||
Address string `json:"address"`
|
Address string `json:"address"`
|
||||||
Theme string `json:"theme"`
|
Theme string `json:"theme"`
|
||||||
SiteTitle string `json:"site-title"`
|
SiteTitle string `json:"site-title"`
|
||||||
|
HomePage string `json:"home-page"`
|
||||||
|
BinaryLimitMB int64 `json:"binary-limit-mb"`
|
||||||
Mycelia []MyceliumConfig `json:"mycelia"`
|
Mycelia []MyceliumConfig `json:"mycelia"`
|
||||||
TitleTemplates struct {
|
TitleTemplates struct {
|
||||||
EditHypha string `json:"edit-hypha"`
|
EditHypha string `json:"edit-hypha"`
|
||||||
@ -82,6 +86,8 @@ func readConfig() bool {
|
|||||||
SiteTitle = cfg.SiteTitle
|
SiteTitle = cfg.SiteTitle
|
||||||
TitleEditTemplate = cfg.TitleTemplates.EditHypha
|
TitleEditTemplate = cfg.TitleTemplates.EditHypha
|
||||||
TitleTemplate = cfg.TitleTemplates.ViewHypha
|
TitleTemplate = cfg.TitleTemplates.ViewHypha
|
||||||
|
HomePage = "/" + cfg.HomePage
|
||||||
|
BinaryLimit = 1024 * cfg.BinaryLimitMB
|
||||||
Mycelia = cfg.Mycelia
|
Mycelia = cfg.Mycelia
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
@ -15,6 +15,7 @@ func (h *Hypha) asHtml() (string, error) {
|
|||||||
<h1 class="page__title">` + rev.FullName + `</h1>
|
<h1 class="page__title">` + rev.FullName + `</h1>
|
||||||
`
|
`
|
||||||
// What about using <figure>?
|
// What about using <figure>?
|
||||||
|
// TODO: support other things
|
||||||
if h.hasBinaryData() {
|
if h.hasBinaryData() {
|
||||||
ret += fmt.Sprintf(`<img src="/:%s?action=binary&rev=%d" class="page__amnt"/>`, util.DisplayToCanonical(rev.FullName), rev.Id)
|
ret += fmt.Sprintf(`<img src="/:%s?action=binary&rev=%d" class="page__amnt"/>`, util.DisplayToCanonical(rev.FullName), rev.Id)
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/bouncepaw/mycorrhiza/cfg"
|
||||||
"github.com/bouncepaw/mycorrhiza/mycelium"
|
"github.com/bouncepaw/mycorrhiza/mycelium"
|
||||||
"github.com/bouncepaw/mycorrhiza/util"
|
"github.com/bouncepaw/mycorrhiza/util"
|
||||||
)
|
)
|
||||||
@ -275,7 +276,7 @@ func (h *Hypha) WriteBinaryFileFromHttpData(rq *http.Request) *Hypha {
|
|||||||
return h
|
return h
|
||||||
}
|
}
|
||||||
// 10 MB file size limit
|
// 10 MB file size limit
|
||||||
rq.ParseMultipartForm(10 << 20)
|
rq.ParseMultipartForm(cfg.BinaryLimit)
|
||||||
// Read file
|
// Read file
|
||||||
file, handler, err := rq.FormFile("binary")
|
file, handler, err := rq.FormFile("binary")
|
||||||
if file != nil {
|
if file != nil {
|
||||||
|
11
main.go
11
main.go
@ -1,7 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
@ -82,16 +81,8 @@ func main() {
|
|||||||
r.HandleFunc(cfg.MyceliumUrl+cfg.HyphaUrl, HandlerView)
|
r.HandleFunc(cfg.MyceliumUrl+cfg.HyphaUrl, HandlerView)
|
||||||
r.HandleFunc(cfg.HyphaUrl, HandlerView)
|
r.HandleFunc(cfg.HyphaUrl, HandlerView)
|
||||||
|
|
||||||
// Debug page that renders all hyphae.
|
|
||||||
// TODO: make it redirect to home page.
|
|
||||||
// TODO: make a home page.
|
|
||||||
r.HandleFunc("/", func(w http.ResponseWriter, rq *http.Request) {
|
r.HandleFunc("/", func(w http.ResponseWriter, rq *http.Request) {
|
||||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
http.Redirect(w, rq, cfg.HomePage, http.StatusSeeOther)
|
||||||
w.WriteHeader(http.StatusOK)
|
|
||||||
fmt.Fprintln(w, `
|
|
||||||
<p>Check out <a href="/Fruit">Fruit</a> maybe.</p>
|
|
||||||
<p><strong>TODO:</strong> make this page usable</p>
|
|
||||||
`)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
http.Handle("/", r)
|
http.Handle("/", r)
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
"address": "0.0.0.0:1737",
|
"address": "0.0.0.0:1737",
|
||||||
"theme": "default-light",
|
"theme": "default-light",
|
||||||
"site-title": "🍄 MycorrhizaWiki",
|
"site-title": "🍄 MycorrhizaWiki",
|
||||||
|
"home-page": "Home",
|
||||||
|
"binary-limit-mb": 10,
|
||||||
"title-templates": {
|
"title-templates": {
|
||||||
"edit-hypha": "Edit %s at MycorrhizaWiki",
|
"edit-hypha": "Edit %s at MycorrhizaWiki",
|
||||||
"view-hypha": "%s at MycorrhizaWiki"
|
"view-hypha": "%s at MycorrhizaWiki"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user