dd8f68b6d2
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places. The auth interface now handles all the authentication stuff. Renamed the debug config variable to debug_mode. Added the PluginPerms API. Internal Errors will now dump the stack trace in the console. Added support for installable plugins. Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/) Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems. Added the same CreateTable method to the query builder. Began work on PostgreSQL support. Added the string-string hook type Added the pre_render hook type. Added the ParentID and ParentType fields to forums. Added the get_forum_url_prefix function. Added a more generic build_slug function. Added the get_topic_url_prefix function. Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions. Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there. Plugins can now see the router instance. The plugin initialisation handlers can now throw errors. Plugins are now initialised after all the forum's subsystems are. Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases. Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code. Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start. Fixed an issue with forum creation where the forum permissions didn't get cached. Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora. Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests. Revamped the phrase system to make it easier for us to add language pack related features in the future. Added the WidgetMenu widget type. Revamped the theme again. I'm experimenting to see which approach I like most. - Excuse the little W3C rage. Some things about CSS drive me crazy :p Tests: Added 22 bbcode_full_parse tests. Added 19 bbcode_regex_parse tests. Added 27 markdown_parse tests. Added four UserStore tests. More to come when the test database functionality is added. Added 18 name_to_slug tests. Hooks: Added the pre_render hook. Added the pre_render_forum_list hook. Added the pre_render_view_forum hook. Added the pre_render_topic_list hook. Added the pre_render_view_topic hook. Added the pre_render_profile hook. Added the pre_render_custom_page hook. Added the pre_render_overview hook. Added the pre_render_create_topic hook. Added the pre_render_account_own_edit_critical hook. Added the pre_render_account_own_edit_avatar hook. Added the pre_render_account_own_edit_username hook. Added the pre_render_account_own_edit_email hook. Added the pre_render_login hook. Added the pre_render_register hook. Added the pre_render_ban hook. Added the pre_render_panel_dashboard hook. Added the pre_render_panel_forums hook. Added the pre_render_panel_delete_forum hook. Added the pre_render_panel_edit_forum hook. Added the pre_render_panel_settings hook. Added the pre_render_panel_setting hook. Added the pre_render_panel_plugins hook. Added the pre_render_panel_users hook. Added the pre_render_panel_edit_user hook. Added the pre_render_panel_groups hook. Added the pre_render_panel_edit_group hook. Added the pre_render_panel_edit_group_perms hook. Added the pre_render_panel_themes hook. Added the pre_render_panel_mod_log hook. Added the pre_render_error hook. Added the pre_render_security_error hook. Added the create_group_preappend hook. Added the intercept_build_widgets hook. Added the simple_forum_check_pre_perms hook. Added the forum_check_pre_perms hook.
219 lines
5.6 KiB
Go
219 lines
5.6 KiB
Go
// Code generated by. DO NOT EDIT.
|
|
/* This file was automatically generated by the software. Please don't edit it as your changes may be overwritten at any moment. */
|
|
package main
|
|
|
|
//import "fmt"
|
|
import "strings"
|
|
import "sync"
|
|
import "errors"
|
|
import "net/http"
|
|
|
|
var ErrNoRoute = errors.New("That route doesn't exist.")
|
|
|
|
type GenRouter struct {
|
|
UploadHandler func(http.ResponseWriter, *http.Request)
|
|
extra_routes map[string]func(http.ResponseWriter, *http.Request, User)
|
|
|
|
sync.RWMutex
|
|
}
|
|
|
|
func NewGenRouter(uploads http.Handler) *GenRouter {
|
|
return &GenRouter{
|
|
UploadHandler: http.StripPrefix("/uploads/",uploads).ServeHTTP,
|
|
extra_routes: make(map[string]func(http.ResponseWriter, *http.Request, User)),
|
|
}
|
|
}
|
|
|
|
func (router *GenRouter) Handle(_ string, _ http.Handler) {
|
|
}
|
|
|
|
func (router *GenRouter) HandleFunc(pattern string, handle func(http.ResponseWriter, *http.Request, User)) {
|
|
router.Lock()
|
|
router.extra_routes[pattern] = handle
|
|
router.Unlock()
|
|
}
|
|
|
|
func (router *GenRouter) RemoveFunc(pattern string) error {
|
|
router.Lock()
|
|
_, ok := router.extra_routes[pattern]
|
|
if !ok {
|
|
router.Unlock()
|
|
return ErrNoRoute
|
|
}
|
|
delete(router.extra_routes,pattern)
|
|
router.Unlock()
|
|
return nil
|
|
}
|
|
|
|
func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|
//if req.URL.Path == "/" {
|
|
// default_route(w,req)
|
|
// return
|
|
//}
|
|
if req.URL.Path[0] != '/' {
|
|
w.WriteHeader(405)
|
|
w.Write([]byte(""))
|
|
return
|
|
}
|
|
|
|
var prefix, extra_data string
|
|
prefix = req.URL.Path[0:strings.IndexByte(req.URL.Path[1:],'/') + 1]
|
|
if req.URL.Path[len(req.URL.Path) - 1] != '/' {
|
|
extra_data = req.URL.Path[strings.LastIndexByte(req.URL.Path,'/') + 1:]
|
|
req.URL.Path = req.URL.Path[:strings.LastIndexByte(req.URL.Path,'/') + 1]
|
|
}
|
|
//fmt.Println("prefix:",prefix)
|
|
//fmt.Println("req.URL.Path:",req.URL.Path)
|
|
//fmt.Println("extra_data:",extra_data)
|
|
|
|
if prefix == "/static" {
|
|
req.URL.Path += extra_data
|
|
route_static(w,req)
|
|
return
|
|
}
|
|
|
|
// Deal with the session stuff, etc.
|
|
user, ok := PreRoute(w,req)
|
|
if !ok {
|
|
return
|
|
}
|
|
|
|
switch(prefix) {
|
|
case "/api":
|
|
route_api(w,req,user)
|
|
return
|
|
case "/overview":
|
|
route_overview(w,req,user)
|
|
return
|
|
case "/forums":
|
|
route_forums(w,req,user)
|
|
return
|
|
case "/forum":
|
|
route_forum(w,req,user,extra_data)
|
|
return
|
|
case "/report":
|
|
switch(req.URL.Path) {
|
|
case "/report/submit/":
|
|
route_report_submit(w,req,user,extra_data)
|
|
return
|
|
}
|
|
case "/topics":
|
|
switch(req.URL.Path) {
|
|
case "/topics/create/":
|
|
route_topic_create(w,req,user,extra_data)
|
|
return
|
|
default:
|
|
route_topics(w,req,user)
|
|
return
|
|
}
|
|
case "/panel":
|
|
switch(req.URL.Path) {
|
|
case "/panel/forums/":
|
|
route_panel_forums(w,req,user)
|
|
return
|
|
case "/panel/forums/create/":
|
|
route_panel_forums_create_submit(w,req,user)
|
|
return
|
|
case "/panel/forums/delete/":
|
|
route_panel_forums_delete(w,req,user,extra_data)
|
|
return
|
|
case "/panel/forums/delete/submit/":
|
|
route_panel_forums_delete_submit(w,req,user,extra_data)
|
|
return
|
|
case "/panel/forums/edit/":
|
|
route_panel_forums_edit(w,req,user,extra_data)
|
|
return
|
|
case "/panel/forums/edit/submit/":
|
|
route_panel_forums_edit_submit(w,req,user,extra_data)
|
|
return
|
|
case "/panel/forums/edit/perms/submit/":
|
|
route_panel_forums_edit_perms_submit(w,req,user,extra_data)
|
|
return
|
|
case "/panel/settings/":
|
|
route_panel_settings(w,req,user)
|
|
return
|
|
case "/panel/settings/edit/":
|
|
route_panel_setting(w,req,user,extra_data)
|
|
return
|
|
case "/panel/settings/edit/submit/":
|
|
route_panel_setting_edit(w,req,user,extra_data)
|
|
return
|
|
case "/panel/themes/":
|
|
route_panel_themes(w,req,user)
|
|
return
|
|
case "/panel/themes/default/":
|
|
route_panel_themes_default(w,req,user,extra_data)
|
|
return
|
|
case "/panel/plugins/":
|
|
route_panel_plugins(w,req,user)
|
|
return
|
|
case "/panel/plugins/activate/":
|
|
route_panel_plugins_activate(w,req,user,extra_data)
|
|
return
|
|
case "/panel/plugins/deactivate/":
|
|
route_panel_plugins_deactivate(w,req,user,extra_data)
|
|
return
|
|
case "/panel/plugins/install/":
|
|
route_panel_plugins_install(w,req,user,extra_data)
|
|
return
|
|
case "/panel/users/":
|
|
route_panel_users(w,req,user)
|
|
return
|
|
case "/panel/users/edit/":
|
|
route_panel_users_edit(w,req,user,extra_data)
|
|
return
|
|
case "/panel/users/edit/submit/":
|
|
route_panel_users_edit_submit(w,req,user,extra_data)
|
|
return
|
|
case "/panel/groups/":
|
|
route_panel_groups(w,req,user)
|
|
return
|
|
case "/panel/groups/edit/":
|
|
route_panel_groups_edit(w,req,user,extra_data)
|
|
return
|
|
case "/panel/groups/edit/perms/":
|
|
route_panel_groups_edit_perms(w,req,user,extra_data)
|
|
return
|
|
case "/panel/groups/edit/submit/":
|
|
route_panel_groups_edit_submit(w,req,user,extra_data)
|
|
return
|
|
case "/panel/groups/edit/perms/submit/":
|
|
route_panel_groups_edit_perms_submit(w,req,user,extra_data)
|
|
return
|
|
case "/panel/groups/create/":
|
|
route_panel_groups_create_submit(w,req,user)
|
|
return
|
|
case "/panel/logs/mod/":
|
|
route_panel_logs_mod(w,req,user)
|
|
return
|
|
default:
|
|
route_panel(w,req,user)
|
|
return
|
|
}
|
|
case "/uploads":
|
|
if extra_data == "" {
|
|
NotFound(w,req)
|
|
return
|
|
}
|
|
req.URL.Path += extra_data
|
|
router.UploadHandler(w,req)
|
|
return
|
|
case "":
|
|
default_route(w,req,user)
|
|
return
|
|
//default: NotFound(w,req)
|
|
}
|
|
|
|
// A fallback for the routes which haven't been converted to the new router yet or plugins
|
|
router.RLock()
|
|
handle, ok := router.extra_routes[req.URL.Path]
|
|
router.RUnlock()
|
|
|
|
if ok {
|
|
req.URL.Path += extra_data
|
|
handle(w,req,user)
|
|
return
|
|
}
|
|
NotFound(w,req)
|
|
}
|