Add support for [^\n] meme files & hgignore

Should be done in separated commits but my mercurial-fu is bad.
This commit is contained in:
Haelwenn (lanodan) Monnier 2019-11-26 10:35:10 +00:00
parent 59cc3645b0
commit ef845b2a2c
3 changed files with 19 additions and 5 deletions

4
.hgignore Normal file
View File

@ -0,0 +1,4 @@
.*\.db
memes
emus
honk

2
fun.go
View File

@ -340,7 +340,7 @@ func herdofemus(noise string) []Emu {
return emus return emus
} }
var re_memes = regexp.MustCompile("meme: ?([[:alnum:]_.-]+)") var re_memes = regexp.MustCompile("meme: ?([^\n]+)")
func memetize(honk *Honk) { func memetize(honk *Honk) {
repl := func(x string) string { repl := func(x string) string {

18
web.go
View File

@ -2026,13 +2026,23 @@ func servehtml(w http.ResponseWriter, r *http.Request) {
} }
func serveemu(w http.ResponseWriter, r *http.Request) { func serveemu(w http.ResponseWriter, r *http.Request) {
xid := mux.Vars(r)["xid"] xid := mux.Vars(r)["xid"]
emu, err := url.QueryUnescape(xid)
if err != nil {
log.Print(err)
}
w.Header().Set("Cache-Control", "max-age="+somedays()) w.Header().Set("Cache-Control", "max-age="+somedays())
http.ServeFile(w, r, dataDir+"/emus/"+xid) http.ServeFile(w, r, dataDir+"/emus/"+emu)
} }
func servememe(w http.ResponseWriter, r *http.Request) { func servememe(w http.ResponseWriter, r *http.Request) {
xid := mux.Vars(r)["xid"] xid := mux.Vars(r)["xid"]
meme, err := url.QueryUnescape(xid)
if err != nil {
log.Print(err)
}
w.Header().Set("Cache-Control", "max-age="+somedays()) w.Header().Set("Cache-Control", "max-age="+somedays())
http.ServeFile(w, r, dataDir+"/memes/"+xid) http.ServeFile(w, r, dataDir+"/memes/"+meme)
} }
func servefile(w http.ResponseWriter, r *http.Request) { func servefile(w http.ResponseWriter, r *http.Request) {
@ -2279,8 +2289,8 @@ func serve() {
getters.HandleFunc("/o", thelistingoftheontologies) getters.HandleFunc("/o", thelistingoftheontologies)
getters.HandleFunc("/o/{name:.+}", showontology) getters.HandleFunc("/o/{name:.+}", showontology)
getters.HandleFunc("/d/{xid:[[:alnum:].]+}", servefile) getters.HandleFunc("/d/{xid:[[:alnum:].]+}", servefile)
getters.HandleFunc("/emu/{xid:[[:alnum:]_.-]+}", serveemu) getters.HandleFunc("/emu/{xid:.+}", serveemu)
getters.HandleFunc("/meme/{xid:[[:alnum:]_.-]+}", servememe) getters.HandleFunc("/meme/{xid:.+}", servememe)
getters.HandleFunc("/.well-known/webfinger", fingerlicker) getters.HandleFunc("/.well-known/webfinger", fingerlicker)
getters.HandleFunc("/server", serveractor) getters.HandleFunc("/server", serveractor)