gosora/router_gen/routes.go

108 lines
4.7 KiB
Go
Raw Normal View History

package main
type Route struct {
Name string
Path string
Before string
Vars []string
}
type RouteGroup struct {
Path string
RouteList []Route
Before []string
}
func addRoute(fname string, path string, before string, vars ...string) {
routeList = append(routeList, Route{fname, path, before, vars})
}
func newRouteGroup(path string, routes ...Route) *RouteGroup {
return &RouteGroup{path, routes, []string{}}
}
func addRouteGroup(routeGroup *RouteGroup) {
routeGroups = append(routeGroups, routeGroup)
}
func (group *RouteGroup) RunBefore(line string) {
group.Before = append(group.Before, line)
}
func (group *RouteGroup) Routes(routes ...Route) {
group.RouteList = append(group.RouteList, routes...)
}
func routes() {
//addRoute("default_route","","")
addRoute("routeAPI", "/api/", "")
///addRoute("routeStatic","/static/","req.URL.Path += extra_data")
addRoute("routeOverview", "/overview/", "")
//addRoute("routeCustomPage","/pages/",""/*,"&extra_data"*/)
addRoute("routeForums", "/forums/", "" /*,"&forums"*/)
addRoute("routeForum", "/forum/", "", "extra_data")
//addRoute("routeTopicCreate","/topics/create/","","extra_data")
//addRoute("routeTopics","/topics/",""/*,"&groups","&forums"*/)
addRoute("routeChangeTheme", "/theme/", "")
addRoute("routeShowAttachment", "/attachs/", "", "extra_data")
reportGroup := newRouteGroup("/report/",
Route{"routeReportSubmit", "/report/submit/", "", []string{"extra_data"}},
)
addRouteGroup(reportGroup)
topicGroup := newRouteGroup("/topics/",
Route{"routeTopics", "/topics/", "", []string{}},
Route{"routeTopicCreate", "/topics/create/", "", []string{"extra_data"}},
)
addRouteGroup(topicGroup)
// The Control Panel
panelGroup := newRouteGroup("/panel/")
panelGroup.RunBefore("SuperModOnly")
panelGroup.Routes(
Route{"routePanel", "/panel/", "", []string{}},
Route{"routePanelForums", "/panel/forums/", "", []string{}},
Route{"routePanelForumsCreateSubmit", "/panel/forums/create/", "", []string{}},
Route{"routePanelForumsDelete", "/panel/forums/delete/", "", []string{"extra_data"}},
Route{"routePanelForumsDeleteSubmit", "/panel/forums/delete/submit/", "", []string{"extra_data"}},
Route{"routePanelForumsEdit", "/panel/forums/edit/", "", []string{"extra_data"}},
Route{"routePanelForumsEditSubmit", "/panel/forums/edit/submit/", "", []string{"extra_data"}},
Route{"routePanelForumsEditPermsSubmit", "/panel/forums/edit/perms/submit/", "", []string{"extra_data"}},
Route{"routePanelSettings", "/panel/settings/", "", []string{}},
Route{"routePanelSetting", "/panel/settings/edit/", "", []string{"extra_data"}},
Route{"routePanelSettingEdit", "/panel/settings/edit/submit/", "", []string{"extra_data"}},
Route{"routePanelWordFilters", "/panel/settings/word-filters/", "", []string{}},
Route{"routePanelWordFiltersCreate", "/panel/settings/word-filters/create/", "", []string{}},
Route{"routePanelWordFiltersEdit", "/panel/settings/word-filters/edit/", "", []string{"extra_data"}},
Route{"routePanelWordFiltersEditSubmit", "/panel/settings/word-filters/edit/submit/", "", []string{"extra_data"}},
Route{"routePanelWordFiltersDeleteSubmit", "/panel/settings/word-filters/delete/submit/", "", []string{"extra_data"}},
Route{"routePanelThemes", "/panel/themes/", "", []string{}},
Route{"routePanelThemesSetDefault", "/panel/themes/default/", "", []string{"extra_data"}},
Route{"routePanelPlugins", "/panel/plugins/", "", []string{}},
Route{"routePanelPluginsActivate", "/panel/plugins/activate/", "", []string{"extra_data"}},
Route{"routePanelPluginsDeactivate", "/panel/plugins/deactivate/", "", []string{"extra_data"}},
Route{"routePanelPluginsInstall", "/panel/plugins/install/", "", []string{"extra_data"}},
Route{"routePanelUsers", "/panel/users/", "", []string{}},
Route{"routePanelUsersEdit", "/panel/users/edit/", "", []string{"extra_data"}},
Route{"routePanelUsersEditSubmit", "/panel/users/edit/submit/", "", []string{"extra_data"}},
Route{"routePanelGroups", "/panel/groups/", "", []string{}},
Route{"routePanelGroupsEdit", "/panel/groups/edit/", "", []string{"extra_data"}},
Route{"routePanelGroupsEditPerms", "/panel/groups/edit/perms/", "", []string{"extra_data"}},
Route{"routePanelGroupsEditSubmit", "/panel/groups/edit/submit/", "", []string{"extra_data"}},
Route{"routePanelGroupsEditPermsSubmit", "/panel/groups/edit/perms/submit/", "", []string{"extra_data"}},
Route{"routePanelGroupsCreateSubmit", "/panel/groups/create/", "", []string{}},
Route{"routePanelBackups", "/panel/backups/", "", []string{"extra_data"}},
Route{"routePanelLogsMod", "/panel/logs/mod/", "", []string{}},
Route{"routePanelDebug", "/panel/debug/", "", []string{}},
)
addRouteGroup(panelGroup)
}