Open DanielHeath opened 6 years ago
I think that would be a great change - I always like to move towards encapsulating the data structures.
This would definitely be a cowyo 3.0 change, so there could be some heavy refactoring if you see fit. I know there are places I'd like to improve still (templating, the switches in the / handler), so I'd be happy to work on this too.
I think it'll need a configuration file to meaningfully support it. I propose the following format (with one or two wishful features like letsencrypt support):
defaults:
cookieSecret: "EZUvlyegpu3+4t4cC2X3f7GzsLZ+wtST67qoLuErpugJz06ZIpdDHEjcMxR+XOLM"
parentDataDir: "root_data"
sites:
"nerdy.party:80":
dataDir: "somewhere else"
TLS:
certPath: ""
keyPath: ""
port: 443
theme: "custom.css"
defaultPage: "welcome"
allowInsecureMarkup: true
defaultLockPin: "1234"
debounceSave: 600
diary: true
accessCode: "correct horse battery staple"
fileUploadsAllowed: true
maxFileUploadMb: 6
"cowyo.com:80":
# dataDir: "defaults to root_data/cowyo.com:80"
allowInsecureMarkup: false
fileUploadsAllowed: false
TLS:
letsEncrypt: true
port: 443
"*:80":
# dataDir: "defaults to root_data/<domain>:<port>"
# Setting '*:80' lets you host arbitrary wikis on port 80
cookieSecret: "ASADFGKLJSH+4t4cC2X3f7GzsLZ+wtST67qoLuErpugJz06ZIpdDHEjcMxR+XOLM"
@DanielHeath I think that looks great. I'm not sure how to do letsEncrypt (I have Caddy do that stuff for me), but I'm sure that there is a Go library for it
If you're not bothered about formats I might do it with toml instead - easier on the eyes.
Oh yeah, definitely toml is a plus. I thought maybe you preferred yaml!
I'd like to let my friends use my server for their own wikis.
I could just run a bunch of copies of cowyo on different ports, but I'm already low on RAM.
One alternative would be to refactor cowyo to support running multiple sites alongside one another.
This would be a pretty invasive change (getting rid of all the global variables), so I'd want to be sure it's welcome before trying it.