a5f5f4af7e
Added the PageStore. Renamed account_own_edit.html to account_own_edit_password.html Renamed custom-page.html to custom_page.html Renamed the pre_render_custom_page hook to pre_render_tmpl_page. Added a new pre_render_custom_page hook, not to be confused with the previous one. Renamed the pre_render_account_own_edit_critical hook to pre_render_account_own_edit_password. Moved the report forum ID into a constant. Renamed todaysReportCount to topicsTopicCountByForum and made it more generic. Renamed panel-menu.html to panel_menu.html Renamed panel-inner-menu.html to panel_inner_menu.html Removed an irrelevant editable_parent in a no results row. Fixed the profile page loading the wrong profile.css Fixed a bug where the last poster avatar would break on the forum page. Added the AddNotice method to *Header. Greatly simplified many of the page struct definitions. Added the ErrorPage page struct and refactored the error pages to use it. Added the BasePanelPage page struct and refactored the panel page structs to use it. Tweaked the DefaultHeader function to set the user on the spot rather than after the fact. Simplified AccountEditAvatarSubmit into a redirect. Add the addElement closure in the control panel dashboard to reduce the amount of complexity. Tweaked LogWarning to better handle nils. Added the account_username phrase. Added the account_avatar phrase. Added the account_email phrase. Added the panel_pages phrase. Added the panel_pages_edit phrase. Added the panel_page_created phrase. Added the panel_page_updated phrase. Added the panel_page_deleted phrase. Added the account_menu_security phrase. Added the panel_menu_pages phrase. Added the panel_pages_head phrase. Added the panel_pages_edit_button_aria phrase. Added the panel_pages_delete_button_aria phrase. Added the panel_pages_no_pages phrase. Added the panel_pages_create_head phrase. Added the panel_pages_create_name phrase. Added the panel_pages_create_name_placeholder phrase. Added the panel_pages_create_title phrase. Added the panel_pages_create_title_placeholder phrase. Added the panel_pages_create_body_placeholder phrase. Added the panel_pages_create_submit_button phrase. Added the panel_pages_edit_head phrase. Added the panel_pages_name phrase. Added the panel_pages_title phrase. Added the panel_pages_edit_update_button phrase. Began work on two-factor authentication. Made more progress with the Nox Theme.
209 lines
10 KiB
Go
209 lines
10 KiB
Go
package main
|
|
|
|
// TODO: How should we handle *HeaderLite and *Header?
|
|
func routes() {
|
|
addRoute(View("routeAPI", "/api/"))
|
|
addRoute(View("routes.Overview", "/overview/"))
|
|
addRoute(View("routes.CustomPage", "/pages/", "extraData"))
|
|
addRoute(View("routes.ForumList", "/forums/" /*,"&forums"*/))
|
|
addRoute(View("routes.ViewForum", "/forum/", "extraData"))
|
|
addRoute(AnonAction("routes.ChangeTheme", "/theme/"))
|
|
addRoute(
|
|
View("routes.ShowAttachment", "/attachs/", "extraData").Before("ParseForm"),
|
|
)
|
|
|
|
// TODO: Reduce the number of Befores. With a new method, perhaps?
|
|
reportGroup := newRouteGroup("/report/",
|
|
Action("routes.ReportSubmit", "/report/submit/", "extraData"),
|
|
).Before("NoBanned")
|
|
addRouteGroup(reportGroup)
|
|
|
|
topicGroup := newRouteGroup("/topics/",
|
|
View("routes.TopicList", "/topics/"),
|
|
MemberView("routes.CreateTopic", "/topics/create/", "extraData"),
|
|
)
|
|
addRouteGroup(topicGroup)
|
|
|
|
buildPanelRoutes()
|
|
buildUserRoutes()
|
|
buildTopicRoutes()
|
|
buildReplyRoutes()
|
|
buildProfileReplyRoutes()
|
|
buildPollRoutes()
|
|
buildAccountRoutes()
|
|
|
|
addRoute(Special("common.RouteWebsockets", "/ws/"))
|
|
}
|
|
|
|
// TODO: Test the email token route
|
|
func buildUserRoutes() {
|
|
userGroup := newRouteGroup("/user/")
|
|
userGroup.Routes(
|
|
View("routes.ViewProfile", "/user/").LitBefore("req.URL.Path += extraData"),
|
|
MemberView("routes.AccountEditCritical", "/user/edit/critical/"),
|
|
Action("routes.AccountEditCriticalSubmit", "/user/edit/critical/submit/"), // TODO: Full test this
|
|
MemberView("routes.AccountEditAvatar", "/user/edit/avatar/"),
|
|
UploadAction("routes.AccountEditAvatarSubmit", "/user/edit/avatar/submit/").MaxSizeVar("int(common.Config.MaxRequestSize)"),
|
|
MemberView("routes.AccountEditUsername", "/user/edit/username/"),
|
|
Action("routes.AccountEditUsernameSubmit", "/user/edit/username/submit/"), // TODO: Full test this
|
|
MemberView("routes.AccountEditEmail", "/user/edit/email/"),
|
|
Action("routes.AccountEditEmailTokenSubmit", "/user/edit/token/", "extraData"),
|
|
)
|
|
addRouteGroup(userGroup)
|
|
|
|
// TODO: Auto test and manual test these routes
|
|
userGroup = newRouteGroup("/users/")
|
|
userGroup.Routes(
|
|
Action("routes.BanUserSubmit", "/users/ban/submit/", "extraData"),
|
|
Action("routes.UnbanUser", "/users/unban/", "extraData"),
|
|
Action("routes.ActivateUser", "/users/activate/", "extraData"),
|
|
MemberView("routes.IPSearch", "/users/ips/"), // TODO: .Perms("ViewIPs")?
|
|
)
|
|
addRouteGroup(userGroup)
|
|
}
|
|
|
|
func buildTopicRoutes() {
|
|
topicGroup := newRouteGroup("/topic/")
|
|
topicGroup.Routes(
|
|
View("routes.ViewTopic", "/topic/", "extraData"),
|
|
UploadAction("routes.CreateTopicSubmit", "/topic/create/submit/").MaxSizeVar("int(common.Config.MaxRequestSize)"),
|
|
Action("routes.EditTopicSubmit", "/topic/edit/submit/", "extraData"),
|
|
Action("routes.DeleteTopicSubmit", "/topic/delete/submit/").LitBefore("req.URL.Path += extraData"),
|
|
Action("routes.StickTopicSubmit", "/topic/stick/submit/", "extraData"),
|
|
Action("routes.UnstickTopicSubmit", "/topic/unstick/submit/", "extraData"),
|
|
Action("routes.LockTopicSubmit", "/topic/lock/submit/").LitBefore("req.URL.Path += extraData"),
|
|
Action("routes.UnlockTopicSubmit", "/topic/unlock/submit/", "extraData"),
|
|
Action("routes.MoveTopicSubmit", "/topic/move/submit/", "extraData"),
|
|
Action("routes.LikeTopicSubmit", "/topic/like/submit/", "extraData").Before("ParseForm"),
|
|
)
|
|
addRouteGroup(topicGroup)
|
|
}
|
|
|
|
func buildReplyRoutes() {
|
|
//router.HandleFunc("/reply/edit/", routeReplyEdit) // No js fallback
|
|
//router.HandleFunc("/reply/delete/", routeReplyDelete) // No js confirmation page? We could have a confirmation modal for the JS case
|
|
replyGroup := newRouteGroup("/reply/")
|
|
replyGroup.Routes(
|
|
// TODO: Reduce this to 1MB for attachments for each file?
|
|
UploadAction("routes.CreateReplySubmit", "/reply/create/").MaxSizeVar("int(common.Config.MaxRequestSize)"), // TODO: Rename the route so it's /reply/create/submit/
|
|
Action("routes.ReplyEditSubmit", "/reply/edit/submit/", "extraData"),
|
|
Action("routes.ReplyDeleteSubmit", "/reply/delete/submit/", "extraData"),
|
|
Action("routes.ReplyLikeSubmit", "/reply/like/submit/", "extraData").Before("ParseForm"),
|
|
)
|
|
addRouteGroup(replyGroup)
|
|
}
|
|
|
|
// TODO: Move these into /user/?
|
|
func buildProfileReplyRoutes() {
|
|
//router.HandleFunc("/user/edit/submit/", routeLogout) // routeLogout? what on earth? o.o
|
|
pReplyGroup := newRouteGroup("/profile/")
|
|
pReplyGroup.Routes(
|
|
Action("routes.ProfileReplyCreateSubmit", "/profile/reply/create/"), // TODO: Add /submit/ to the end
|
|
Action("routes.ProfileReplyEditSubmit", "/profile/reply/edit/submit/", "extraData"),
|
|
Action("routes.ProfileReplyDeleteSubmit", "/profile/reply/delete/submit/", "extraData"),
|
|
)
|
|
addRouteGroup(pReplyGroup)
|
|
}
|
|
|
|
func buildPollRoutes() {
|
|
pollGroup := newRouteGroup("/poll/")
|
|
pollGroup.Routes(
|
|
Action("routes.PollVote", "/poll/vote/", "extraData"),
|
|
View("routes.PollResults", "/poll/results/", "extraData"),
|
|
)
|
|
addRouteGroup(pollGroup)
|
|
}
|
|
|
|
func buildAccountRoutes() {
|
|
//router.HandleFunc("/accounts/list/", routeLogin) // Redirect /accounts/ and /user/ to here.. // Get a list of all of the accounts on the forum
|
|
accReplyGroup := newRouteGroup("/accounts/")
|
|
accReplyGroup.Routes(
|
|
View("routes.AccountLogin", "/accounts/login/"),
|
|
View("routes.AccountRegister", "/accounts/create/"),
|
|
Action("routes.AccountLogout", "/accounts/logout/"),
|
|
AnonAction("routes.AccountLoginSubmit", "/accounts/login/submit/"), // TODO: Guard this with a token, maybe the IP hashed with a rotated key?
|
|
AnonAction("routes.AccountRegisterSubmit", "/accounts/create/submit/"),
|
|
)
|
|
addRouteGroup(accReplyGroup)
|
|
}
|
|
|
|
func buildPanelRoutes() {
|
|
panelGroup := newRouteGroup("/panel/").Before("SuperModOnly")
|
|
panelGroup.Routes(
|
|
View("routePanelDashboard", "/panel/"),
|
|
View("panel.Forums", "/panel/forums/"),
|
|
Action("panel.ForumsCreateSubmit", "/panel/forums/create/"),
|
|
Action("panel.ForumsDelete", "/panel/forums/delete/", "extraData"),
|
|
Action("panel.ForumsDeleteSubmit", "/panel/forums/delete/submit/", "extraData"),
|
|
View("panel.ForumsEdit", "/panel/forums/edit/", "extraData"),
|
|
Action("panel.ForumsEditSubmit", "/panel/forums/edit/submit/", "extraData"),
|
|
Action("panel.ForumsEditPermsSubmit", "/panel/forums/edit/perms/submit/", "extraData"),
|
|
View("panel.ForumsEditPermsAdvance", "/panel/forums/edit/perms/", "extraData"),
|
|
Action("panel.ForumsEditPermsAdvanceSubmit", "/panel/forums/edit/perms/adv/submit/", "extraData"),
|
|
|
|
View("panel.Settings", "/panel/settings/"),
|
|
View("panel.SettingEdit", "/panel/settings/edit/", "extraData"),
|
|
Action("panel.SettingEditSubmit", "/panel/settings/edit/submit/", "extraData"),
|
|
|
|
View("routePanelWordFilters", "/panel/settings/word-filters/"),
|
|
Action("routePanelWordFiltersCreateSubmit", "/panel/settings/word-filters/create/"),
|
|
View("routePanelWordFiltersEdit", "/panel/settings/word-filters/edit/", "extraData"),
|
|
Action("routePanelWordFiltersEditSubmit", "/panel/settings/word-filters/edit/submit/", "extraData"),
|
|
Action("routePanelWordFiltersDeleteSubmit", "/panel/settings/word-filters/delete/submit/", "extraData"),
|
|
|
|
View("panel.Pages", "/panel/pages/").Before("AdminOnly"),
|
|
Action("panel.PagesCreateSubmit", "/panel/pages/create/submit/").Before("AdminOnly"),
|
|
View("panel.PagesEdit", "/panel/pages/edit/", "extraData").Before("AdminOnly"),
|
|
Action("panel.PagesEditSubmit", "/panel/pages/edit/submit/", "extraData").Before("AdminOnly"),
|
|
Action("panel.PagesDeleteSubmit", "/panel/pages/delete/submit/", "extraData").Before("AdminOnly"),
|
|
|
|
View("routePanelThemes", "/panel/themes/"),
|
|
Action("routePanelThemesSetDefault", "/panel/themes/default/", "extraData"),
|
|
View("routePanelThemesMenus", "/panel/themes/menus/"),
|
|
View("routePanelThemesMenusEdit", "/panel/themes/menus/edit/", "extraData"),
|
|
View("routePanelThemesMenuItemEdit", "/panel/themes/menus/item/edit/", "extraData"),
|
|
Action("routePanelThemesMenuItemEditSubmit", "/panel/themes/menus/item/edit/submit/", "extraData"),
|
|
Action("routePanelThemesMenuItemCreateSubmit", "/panel/themes/menus/item/create/submit/"),
|
|
Action("routePanelThemesMenuItemDeleteSubmit", "/panel/themes/menus/item/delete/submit/", "extraData"),
|
|
Action("routePanelThemesMenuItemOrderSubmit", "/panel/themes/menus/item/order/edit/submit/", "extraData"),
|
|
|
|
View("routePanelPlugins", "/panel/plugins/"),
|
|
Action("routePanelPluginsActivate", "/panel/plugins/activate/", "extraData"),
|
|
Action("routePanelPluginsDeactivate", "/panel/plugins/deactivate/", "extraData"),
|
|
Action("routePanelPluginsInstall", "/panel/plugins/install/", "extraData"),
|
|
|
|
View("routePanelUsers", "/panel/users/"),
|
|
View("routePanelUsersEdit", "/panel/users/edit/", "extraData"),
|
|
Action("routePanelUsersEditSubmit", "/panel/users/edit/submit/", "extraData"),
|
|
|
|
View("panel.AnalyticsViews", "/panel/analytics/views/").Before("ParseForm"),
|
|
View("panel.AnalyticsRoutes", "/panel/analytics/routes/").Before("ParseForm"),
|
|
View("panel.AnalyticsAgents", "/panel/analytics/agents/").Before("ParseForm"),
|
|
View("panel.AnalyticsSystems", "/panel/analytics/systems/").Before("ParseForm"),
|
|
View("panel.AnalyticsLanguages", "/panel/analytics/langs/").Before("ParseForm"),
|
|
View("panel.AnalyticsReferrers", "/panel/analytics/referrers/").Before("ParseForm"),
|
|
View("panel.AnalyticsRouteViews", "/panel/analytics/route/", "extraData"),
|
|
View("panel.AnalyticsAgentViews", "/panel/analytics/agent/", "extraData"),
|
|
View("panel.AnalyticsForumViews", "/panel/analytics/forum/", "extraData"),
|
|
View("panel.AnalyticsSystemViews", "/panel/analytics/system/", "extraData"),
|
|
View("panel.AnalyticsLanguageViews", "/panel/analytics/lang/", "extraData"),
|
|
View("panel.AnalyticsReferrerViews", "/panel/analytics/referrer/", "extraData"),
|
|
View("panel.AnalyticsPosts", "/panel/analytics/posts/").Before("ParseForm"),
|
|
View("panel.AnalyticsTopics", "/panel/analytics/topics/").Before("ParseForm"),
|
|
View("panel.AnalyticsForums", "/panel/analytics/forums/").Before("ParseForm"),
|
|
|
|
View("routePanelGroups", "/panel/groups/"),
|
|
View("routePanelGroupsEdit", "/panel/groups/edit/", "extraData"),
|
|
View("routePanelGroupsEditPerms", "/panel/groups/edit/perms/", "extraData"),
|
|
Action("routePanelGroupsEditSubmit", "/panel/groups/edit/submit/", "extraData"),
|
|
Action("routePanelGroupsEditPermsSubmit", "/panel/groups/edit/perms/submit/", "extraData"),
|
|
Action("routePanelGroupsCreateSubmit", "/panel/groups/create/"),
|
|
|
|
View("panel.Backups", "/panel/backups/", "extraData").Before("SuperAdminOnly"), // TODO: Tests for this
|
|
View("panel.LogsRegs", "/panel/logs/regs/"),
|
|
View("panel.LogsMod", "/panel/logs/mod/"),
|
|
View("panel.Debug", "/panel/debug/").Before("AdminOnly"),
|
|
)
|
|
addRouteGroup(panelGroup)
|
|
}
|