e099dfd40e
Added forum descriptions. Began work on the Advanced Forum Editor. Not to be confused with the Quick Forum Editor. You can access it by going to /panel/forums/edit/{forumid} We'll fix it so the Forum Manager links to it in the next commit. Fixed the Linux shell scripts. Fixed an issue with relative timess being off by an hour due to timezones. Added reply count and author names to the topic list and forum pages. Improved the look of the forum list, forum page, and topic list. Added an overlay effect for when the alert list is open on mobile. You can now close the alert list by clicking on the bell. Removed the "Report:" prefix from report posts. Fixed a bug in the template system where "and" and "or" wouldn't work on non-boolean values. Improved the debug logging in the template system. Fixed a bug in the forum creator where the "Hidden?" value was inverted. Fixed a visual bug in the profile where the Ban button rendered in a glitchy way. Added support for hidden fields to the JS Framework for inline editing rows. Fixed a bug with the like counter rendering on-top of the alert list. Atom's stripping trailing tabs for some reason, so don't be confused if there are a bunch of weird changes.
57 lines
1.2 KiB
Go
57 lines
1.2 KiB
Go
package main
|
|
|
|
//import "fmt"
|
|
import "strings"
|
|
import "sync"
|
|
import "net/http"
|
|
|
|
type Router struct {
|
|
sync.RWMutex
|
|
routes map[string]func(http.ResponseWriter, *http.Request)
|
|
}
|
|
|
|
func NewRouter() *Router {
|
|
return &Router{
|
|
routes: make(map[string]func(http.ResponseWriter, *http.Request)),
|
|
}
|
|
}
|
|
|
|
func (router *Router) Handle(pattern string, handle http.Handler) {
|
|
router.Lock()
|
|
router.routes[pattern] = handle.ServeHTTP
|
|
router.Unlock()
|
|
}
|
|
|
|
func (router *Router) HandleFunc(pattern string, handle func(http.ResponseWriter, *http.Request)) {
|
|
router.Lock()
|
|
router.routes[pattern] = handle
|
|
router.Unlock()
|
|
}
|
|
|
|
func (router *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|
if req.URL.Path[0] != '/' {
|
|
w.WriteHeader(405)
|
|
w.Write([]byte(""))
|
|
return
|
|
}
|
|
|
|
var /*extra_data, */prefix string
|
|
if req.URL.Path[len(req.URL.Path) - 1] != '/' {
|
|
//extra_data = req.URL.Path[strings.LastIndexByte(req.URL.Path,'/') + 1:]
|
|
prefix = req.URL.Path[:strings.LastIndexByte(req.URL.Path,'/') + 1]
|
|
} else {
|
|
prefix = req.URL.Path
|
|
}
|
|
|
|
router.RLock()
|
|
handle, ok := router.routes[prefix]
|
|
router.RUnlock()
|
|
|
|
if ok {
|
|
handle(w,req)
|
|
return
|
|
}
|
|
//fmt.Println(req.URL.Path[:strings.LastIndexByte(req.URL.Path,'/')])
|
|
NotFound(w,req)
|
|
}
|