2017-04-12 10:10:36 +00:00
package main
2018-04-22 12:33:56 +00:00
// TODO: How should we handle *HeaderLite and *Header?
2017-04-12 10:10:36 +00:00
func routes ( ) {
2017-11-12 07:18:25 +00:00
addRoute ( View ( "routeAPI" , "/api/" ) )
2018-02-03 05:47:14 +00:00
addRoute ( View ( "routes.Overview" , "/overview/" ) )
addRoute ( View ( "routes.CustomPage" , "/pages/" , "extraData" ) )
2018-03-17 08:16:43 +00:00
addRoute ( View ( "routes.ForumList" , "/forums/" /*,"&forums"*/ ) )
2018-02-22 02:27:17 +00:00
addRoute ( View ( "routes.ViewForum" , "/forum/" , "extraData" ) )
2018-05-15 05:59:52 +00:00
addRoute ( AnonAction ( "routes.ChangeTheme" , "/theme/" ) )
2017-11-12 07:18:25 +00:00
addRoute (
2018-05-15 05:59:52 +00:00
View ( "routes.ShowAttachment" , "/attachs/" , "extraData" ) . Before ( "ParseForm" ) ,
2017-11-12 07:18:25 +00:00
)
2017-06-05 11:57:27 +00:00
2017-11-08 07:28:33 +00:00
// TODO: Reduce the number of Befores. With a new method, perhaps?
2017-10-30 09:57:08 +00:00
reportGroup := newRouteGroup ( "/report/" ,
2017-12-19 03:53:13 +00:00
Action ( "routeReportSubmit" , "/report/submit/" , "extraData" ) ,
2017-11-12 07:18:25 +00:00
) . Before ( "NoBanned" )
2017-10-30 09:57:08 +00:00
addRouteGroup ( reportGroup )
2017-06-05 11:57:27 +00:00
2017-10-30 09:57:08 +00:00
topicGroup := newRouteGroup ( "/topics/" ,
2018-02-10 15:07:21 +00:00
View ( "routes.TopicList" , "/topics/" ) ,
2018-01-21 11:17:43 +00:00
MemberView ( "routes.CreateTopic" , "/topics/create/" , "extraData" ) ,
2017-04-13 09:26:40 +00:00
)
2017-10-30 09:57:08 +00:00
addRouteGroup ( topicGroup )
2017-06-05 11:57:27 +00:00
2017-10-31 07:26:44 +00:00
buildPanelRoutes ( )
2017-11-05 09:55:34 +00:00
buildUserRoutes ( )
2018-01-14 12:03:20 +00:00
buildTopicRoutes ( )
buildReplyRoutes ( )
2018-01-14 14:27:10 +00:00
buildProfileReplyRoutes ( )
2018-01-27 07:30:44 +00:00
buildPollRoutes ( )
2018-01-17 11:13:08 +00:00
buildAccountRoutes ( )
2018-01-18 12:31:25 +00:00
2018-03-08 03:59:47 +00:00
addRoute ( Special ( "common.RouteWebsockets" , "/ws/" ) )
2017-11-05 09:55:34 +00:00
}
// TODO: Test the email token route
func buildUserRoutes ( ) {
2017-11-08 07:28:33 +00:00
userGroup := newRouteGroup ( "/user/" )
2017-11-05 09:55:34 +00:00
userGroup . Routes (
2018-02-26 09:07:00 +00:00
View ( "routes.ViewProfile" , "/user/" ) . LitBefore ( "req.URL.Path += extraData" ) ,
2018-01-23 10:48:44 +00:00
MemberView ( "routes.AccountEditCritical" , "/user/edit/critical/" ) ,
2018-05-14 08:56:56 +00:00
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
2017-11-12 07:18:25 +00:00
MemberView ( "routeAccountEditEmail" , "/user/edit/email/" ) ,
2017-12-19 03:53:13 +00:00
Action ( "routeAccountEditEmailTokenSubmit" , "/user/edit/token/" , "extraData" ) ,
2017-11-12 07:18:25 +00:00
)
2017-11-05 09:55:34 +00:00
addRouteGroup ( userGroup )
2017-11-10 03:33:11 +00:00
// TODO: Auto test and manual test these routes
2017-11-12 07:18:25 +00:00
userGroup = newRouteGroup ( "/users/" )
2017-11-10 03:33:11 +00:00
userGroup . Routes (
2018-01-21 11:17:43 +00:00
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")?
2017-11-12 07:18:25 +00:00
)
2017-11-10 03:33:11 +00:00
addRouteGroup ( userGroup )
2017-10-31 07:26:44 +00:00
}
2018-01-14 12:03:20 +00:00
func buildTopicRoutes ( ) {
topicGroup := newRouteGroup ( "/topic/" )
topicGroup . Routes (
2018-02-03 05:47:14 +00:00
View ( "routes.ViewTopic" , "/topic/" , "extraData" ) ,
2018-05-14 08:56:56 +00:00
UploadAction ( "routes.CreateTopicSubmit" , "/topic/create/submit/" ) . MaxSizeVar ( "int(common.Config.MaxRequestSize)" ) ,
2018-01-18 12:31:25 +00:00
Action ( "routes.EditTopicSubmit" , "/topic/edit/submit/" , "extraData" ) ,
2018-01-20 06:50:29 +00:00
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" ) ,
2018-05-15 05:59:52 +00:00
Action ( "routes.LikeTopicSubmit" , "/topic/like/submit/" , "extraData" ) . Before ( "ParseForm" ) ,
2018-01-14 12:03:20 +00:00
)
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?
2018-05-14 08:56:56 +00:00
UploadAction ( "routes.CreateReplySubmit" , "/reply/create/" ) . MaxSizeVar ( "int(common.Config.MaxRequestSize)" ) , // TODO: Rename the route so it's /reply/create/submit/
2018-01-20 06:50:29 +00:00
Action ( "routes.ReplyEditSubmit" , "/reply/edit/submit/" , "extraData" ) ,
Action ( "routes.ReplyDeleteSubmit" , "/reply/delete/submit/" , "extraData" ) ,
2018-05-15 05:59:52 +00:00
Action ( "routes.ReplyLikeSubmit" , "/reply/like/submit/" , "extraData" ) . Before ( "ParseForm" ) ,
2018-01-14 12:03:20 +00:00
)
addRouteGroup ( replyGroup )
}
2018-01-14 14:27:10 +00:00
// TODO: Move these into /user/?
func buildProfileReplyRoutes ( ) {
//router.HandleFunc("/user/edit/submit/", routeLogout) // routeLogout? what on earth? o.o
pReplyGroup := newRouteGroup ( "/profile/" )
pReplyGroup . Routes (
2018-05-15 05:59:52 +00:00
Action ( "routes.ProfileReplyCreateSubmit" , "/profile/reply/create/" ) , // TODO: Add /submit/ to the end
2018-01-20 06:50:29 +00:00
Action ( "routes.ProfileReplyEditSubmit" , "/profile/reply/edit/submit/" , "extraData" ) ,
Action ( "routes.ProfileReplyDeleteSubmit" , "/profile/reply/delete/submit/" , "extraData" ) ,
2018-01-14 14:27:10 +00:00
)
addRouteGroup ( pReplyGroup )
}
2018-01-27 07:30:44 +00:00
func buildPollRoutes ( ) {
pollGroup := newRouteGroup ( "/poll/" )
pollGroup . Routes (
Action ( "routes.PollVote" , "/poll/vote/" , "extraData" ) ,
2018-01-28 14:30:24 +00:00
View ( "routes.PollResults" , "/poll/results/" , "extraData" ) ,
2018-01-27 07:30:44 +00:00
)
addRouteGroup ( pollGroup )
}
2018-01-17 11:13:08 +00:00
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 (
2018-02-03 05:47:14 +00:00
View ( "routes.AccountLogin" , "/accounts/login/" ) ,
View ( "routes.AccountRegister" , "/accounts/create/" ) ,
2018-05-15 05:59:52 +00:00
Action ( "routes.AccountLogout" , "/accounts/logout/" ) ,
2018-02-03 05:47:14 +00:00
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/" ) ,
2018-01-17 11:13:08 +00:00
)
addRouteGroup ( accReplyGroup )
}
2017-10-31 07:26:44 +00:00
func buildPanelRoutes ( ) {
2017-11-05 09:55:34 +00:00
panelGroup := newRouteGroup ( "/panel/" ) . Before ( "SuperModOnly" )
2017-10-30 09:57:08 +00:00
panelGroup . Routes (
2018-01-22 08:15:45 +00:00
View ( "routePanelDashboard" , "/panel/" ) ,
2017-11-12 07:18:25 +00:00
View ( "routePanelForums" , "/panel/forums/" ) ,
Action ( "routePanelForumsCreateSubmit" , "/panel/forums/create/" ) ,
2017-12-19 03:53:13 +00:00
Action ( "routePanelForumsDelete" , "/panel/forums/delete/" , "extraData" ) ,
Action ( "routePanelForumsDeleteSubmit" , "/panel/forums/delete/submit/" , "extraData" ) ,
View ( "routePanelForumsEdit" , "/panel/forums/edit/" , "extraData" ) ,
Action ( "routePanelForumsEditSubmit" , "/panel/forums/edit/submit/" , "extraData" ) ,
Action ( "routePanelForumsEditPermsSubmit" , "/panel/forums/edit/perms/submit/" , "extraData" ) ,
2018-01-08 08:53:51 +00:00
View ( "routePanelForumsEditPermsAdvance" , "/panel/forums/edit/perms/" , "extraData" ) ,
2018-01-10 03:32:48 +00:00
Action ( "routePanelForumsEditPermsAdvanceSubmit" , "/panel/forums/edit/perms/adv/submit/" , "extraData" ) ,
2017-10-31 07:26:44 +00:00
2017-11-12 07:18:25 +00:00
View ( "routePanelSettings" , "/panel/settings/" ) ,
2017-12-19 03:53:13 +00:00
View ( "routePanelSettingEdit" , "/panel/settings/edit/" , "extraData" ) ,
Action ( "routePanelSettingEditSubmit" , "/panel/settings/edit/submit/" , "extraData" ) ,
2017-10-31 07:26:44 +00:00
2017-11-12 07:18:25 +00:00
View ( "routePanelWordFilters" , "/panel/settings/word-filters/" ) ,
2018-01-18 12:31:25 +00:00
Action ( "routePanelWordFiltersCreateSubmit" , "/panel/settings/word-filters/create/" ) ,
2017-12-19 03:53:13 +00:00
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" ) ,
2017-10-31 07:26:44 +00:00
2017-11-12 07:18:25 +00:00
View ( "routePanelThemes" , "/panel/themes/" ) ,
2017-12-19 03:53:13 +00:00
Action ( "routePanelThemesSetDefault" , "/panel/themes/default/" , "extraData" ) ,
2018-05-11 05:41:51 +00:00
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" ) ,
2018-05-13 06:56:59 +00:00
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" ) ,
2017-10-31 07:26:44 +00:00
2017-11-12 07:18:25 +00:00
View ( "routePanelPlugins" , "/panel/plugins/" ) ,
2017-12-19 03:53:13 +00:00
Action ( "routePanelPluginsActivate" , "/panel/plugins/activate/" , "extraData" ) ,
Action ( "routePanelPluginsDeactivate" , "/panel/plugins/deactivate/" , "extraData" ) ,
Action ( "routePanelPluginsInstall" , "/panel/plugins/install/" , "extraData" ) ,
2017-10-31 07:26:44 +00:00
2017-11-12 07:18:25 +00:00
View ( "routePanelUsers" , "/panel/users/" ) ,
2017-12-19 03:53:13 +00:00
View ( "routePanelUsersEdit" , "/panel/users/edit/" , "extraData" ) ,
Action ( "routePanelUsersEditSubmit" , "/panel/users/edit/submit/" , "extraData" ) ,
2017-10-31 07:26:44 +00:00
2018-01-08 08:53:51 +00:00
View ( "routePanelAnalyticsViews" , "/panel/analytics/views/" ) . Before ( "ParseForm" ) ,
2018-01-17 11:13:08 +00:00
View ( "routePanelAnalyticsRoutes" , "/panel/analytics/routes/" ) . Before ( "ParseForm" ) ,
View ( "routePanelAnalyticsAgents" , "/panel/analytics/agents/" ) . Before ( "ParseForm" ) ,
2018-02-04 08:15:20 +00:00
View ( "routePanelAnalyticsSystems" , "/panel/analytics/systems/" ) . Before ( "ParseForm" ) ,
2018-03-08 03:59:47 +00:00
View ( "routePanelAnalyticsLanguages" , "/panel/analytics/langs/" ) . Before ( "ParseForm" ) ,
2018-02-05 10:29:13 +00:00
View ( "routePanelAnalyticsReferrers" , "/panel/analytics/referrers/" ) . Before ( "ParseForm" ) ,
2018-01-05 22:47:13 +00:00
View ( "routePanelAnalyticsRouteViews" , "/panel/analytics/route/" , "extraData" ) ,
2018-01-10 03:32:48 +00:00
View ( "routePanelAnalyticsAgentViews" , "/panel/analytics/agent/" , "extraData" ) ,
2018-02-22 02:27:17 +00:00
View ( "routePanelAnalyticsForumViews" , "/panel/analytics/forum/" , "extraData" ) ,
2018-02-04 08:15:20 +00:00
View ( "routePanelAnalyticsSystemViews" , "/panel/analytics/system/" , "extraData" ) ,
2018-03-08 03:59:47 +00:00
View ( "routePanelAnalyticsLanguageViews" , "/panel/analytics/lang/" , "extraData" ) ,
2018-02-05 10:29:13 +00:00
View ( "routePanelAnalyticsReferrerViews" , "/panel/analytics/referrer/" , "extraData" ) ,
2018-01-14 12:03:20 +00:00
View ( "routePanelAnalyticsPosts" , "/panel/analytics/posts/" ) . Before ( "ParseForm" ) ,
2018-01-18 12:31:25 +00:00
View ( "routePanelAnalyticsTopics" , "/panel/analytics/topics/" ) . Before ( "ParseForm" ) ,
2018-02-22 02:27:17 +00:00
View ( "routePanelAnalyticsForums" , "/panel/analytics/forums/" ) . Before ( "ParseForm" ) ,
2017-12-30 05:47:46 +00:00
2017-11-12 07:18:25 +00:00
View ( "routePanelGroups" , "/panel/groups/" ) ,
2017-12-19 03:53:13 +00:00
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" ) ,
2017-11-12 07:18:25 +00:00
Action ( "routePanelGroupsCreateSubmit" , "/panel/groups/create/" ) ,
2017-10-31 07:26:44 +00:00
2017-12-19 03:53:13 +00:00
View ( "routePanelBackups" , "/panel/backups/" , "extraData" ) . Before ( "SuperAdminOnly" ) , // TODO: Test
2017-11-12 07:18:25 +00:00
View ( "routePanelLogsMod" , "/panel/logs/mod/" ) ,
View ( "routePanelDebug" , "/panel/debug/" ) . Before ( "AdminOnly" ) ,
2017-04-13 10:55:51 +00:00
)
2017-10-30 09:57:08 +00:00
addRouteGroup ( panelGroup )
2017-04-12 10:10:36 +00:00
}