2017-04-12 10:10:36 +00:00
package main
2017-11-07 22:38:15 +00:00
// TODO: How should we handle headerLite and headerVar?
2017-04-12 10:10:36 +00:00
func routes ( ) {
2017-11-12 07:18:25 +00:00
addRoute ( View ( "routeAPI" , "/api/" ) )
addRoute ( View ( "routeOverview" , "/overview/" ) )
2017-12-22 03:32:23 +00:00
addRoute ( View ( "routeCustomPage" , "/pages/" , "extraData" ) )
2017-11-12 07:18:25 +00:00
addRoute ( View ( "routeForums" , "/forums/" /*,"&forums"*/ ) )
2017-12-19 03:53:13 +00:00
addRoute ( View ( "routeForum" , "/forum/" , "extraData" ) )
2017-11-12 07:18:25 +00:00
addRoute ( AnonAction ( "routeChangeTheme" , "/theme/" ) )
addRoute (
2017-12-19 03:53:13 +00:00
View ( "routeShowAttachment" , "/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/" ,
2017-11-12 07:18:25 +00:00
View ( "routeTopics" , "/topics/" ) ,
2017-12-19 03:53:13 +00:00
MemberView ( "routeTopicCreate" , "/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 ( )
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 (
2017-12-19 03:53:13 +00:00
View ( "routeProfile" , "/user/" ) . LitBefore ( "req.URL.Path += extraData" ) ,
2017-11-12 07:18:25 +00:00
MemberView ( "routeAccountEditCritical" , "/user/edit/critical/" ) ,
Action ( "routeAccountEditCriticalSubmit" , "/user/edit/critical/submit/" ) , // TODO: Full test this
MemberView ( "routeAccountEditAvatar" , "/user/edit/avatar/" ) ,
2018-01-14 12:03:20 +00:00
UploadAction ( "routeAccountEditAvatarSubmit" , "/user/edit/avatar/submit/" ) . MaxSizeVar ( "common.Config.MaxRequestSize" ) ,
2017-11-12 07:18:25 +00:00
MemberView ( "routeAccountEditUsername" , "/user/edit/username/" ) ,
Action ( "routeAccountEditUsernameSubmit" , "/user/edit/username/submit/" ) , // TODO: Full test this
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 (
2017-12-25 02:41:10 +00:00
Action ( "routeBanSubmit" , "/users/ban/submit/" , "extraData" ) ,
Action ( "routeUnban" , "/users/unban/" , "extraData" ) ,
Action ( "routeActivate" , "/users/activate/" , "extraData" ) ,
2017-12-19 03:53:13 +00:00
MemberView ( "routeIps" , "/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 (
View ( "routeTopicID" , "/topic/" , "extraData" ) ,
Action ( "routeTopicCreateSubmit" , "/topic/create/submit/" ) ,
Action ( "routeEditTopicSubmit" , "/topic/edit/submit/" , "extraData" ) ,
Action ( "routeDeleteTopicSubmit" , "/topic/delete/submit/" ) . LitBefore ( "req.URL.Path += extraData" ) ,
Action ( "routeStickTopicSubmit" , "/topic/stick/submit/" , "extraData" ) ,
Action ( "routeUnstickTopicSubmit" , "/topic/unstick/submit/" , "extraData" ) ,
Action ( "routeLockTopicSubmit" , "/topic/lock/submit/" ) . LitBefore ( "req.URL.Path += extraData" ) ,
Action ( "routeUnlockTopicSubmit" , "/topic/unlock/submit/" , "extraData" ) ,
Action ( "routeMoveTopicSubmit" , "/topic/move/submit/" , "extraData" ) ,
Action ( "routeLikeTopicSubmit" , "/topic/like/submit/" , "extraData" ) ,
)
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 ( "routeCreateReplySubmit" , "/reply/create/" ) . MaxSizeVar ( "common.Config.MaxRequestSize" ) , // TODO: Rename the route so it's /reply/create/submit/
Action ( "routeReplyEditSubmit" , "/reply/edit/submit/" , "extraData" ) ,
Action ( "routeReplyDeleteSubmit" , "/reply/delete/submit/" , "extraData" ) ,
Action ( "routeReplyLikeSubmit" , "/reply/like/submit/" , "extraData" ) ,
)
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 (
Action ( "routeProfileReplyCreateSubmit" , "/profile/reply/create/" ) , // TODO: Add /submit/ to the end
Action ( "routeProfileReplyEditSubmit" , "/profile/reply/edit/submit/" , "extraData" ) ,
Action ( "routeProfileReplyDeleteSubmit" , "/profile/reply/delete/submit/" , "extraData" ) ,
)
addRouteGroup ( pReplyGroup )
}
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 (
2017-11-12 07:18:25 +00:00
View ( "routePanel" , "/panel/" ) ,
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/" ) ,
Action ( "routePanelWordFiltersCreate" , "/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" ) ,
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-04 10:23:33 +00:00
View ( "routePanelAnalyticsRoutes" , "/panel/analytics/routes/" ) ,
2018-01-09 07:39:29 +00:00
View ( "routePanelAnalyticsAgents" , "/panel/analytics/agents/" ) ,
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-01-14 12:03:20 +00:00
View ( "routePanelAnalyticsPosts" , "/panel/analytics/posts/" ) . 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
}