diff --git a/gen_router.go b/gen_router.go index b3692442..afb5be01 100644 --- a/gen_router.go +++ b/gen_router.go @@ -94,6 +94,9 @@ var RouteMap = map[string]interface{}{ "routeReplyEditSubmit": routeReplyEditSubmit, "routeReplyDeleteSubmit": routeReplyDeleteSubmit, "routeReplyLikeSubmit": routeReplyLikeSubmit, + "routeProfileReplyCreateSubmit": routeProfileReplyCreateSubmit, + "routeProfileReplyEditSubmit": routeProfileReplyEditSubmit, + "routeProfileReplyDeleteSubmit": routeProfileReplyDeleteSubmit, "routeDynamic": routeDynamic, "routeUploads": routeUploads, } @@ -179,8 +182,11 @@ var routeMapEnum = map[string]int{ "routeReplyEditSubmit": 76, "routeReplyDeleteSubmit": 77, "routeReplyLikeSubmit": 78, - "routeDynamic": 79, - "routeUploads": 80, + "routeProfileReplyCreateSubmit": 79, + "routeProfileReplyEditSubmit": 80, + "routeProfileReplyDeleteSubmit": 81, + "routeDynamic": 82, + "routeUploads": 83, } var reverseRouteMapEnum = map[int]string{ 0: "routeAPI", @@ -262,8 +268,11 @@ var reverseRouteMapEnum = map[int]string{ 76: "routeReplyEditSubmit", 77: "routeReplyDeleteSubmit", 78: "routeReplyLikeSubmit", - 79: "routeDynamic", - 80: "routeUploads", + 79: "routeProfileReplyCreateSubmit", + 80: "routeProfileReplyEditSubmit", + 81: "routeProfileReplyDeleteSubmit", + 82: "routeDynamic", + 83: "routeUploads", } var agentMapEnum = map[string]int{ "unknown": 0, @@ -1234,6 +1243,57 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { if err != nil { router.handleError(err,w,req,user) } + case "/profile": + switch(req.URL.Path) { + case "/profile/reply/create/": + err = common.NoSessionMismatch(w,req,user) + if err != nil { + router.handleError(err,w,req,user) + return + } + + err = common.MemberOnly(w,req,user) + if err != nil { + router.handleError(err,w,req,user) + return + } + + common.RouteViewCounter.Bump(79) + err = routeProfileReplyCreateSubmit(w,req,user) + case "/profile/reply/edit/submit/": + err = common.NoSessionMismatch(w,req,user) + if err != nil { + router.handleError(err,w,req,user) + return + } + + err = common.MemberOnly(w,req,user) + if err != nil { + router.handleError(err,w,req,user) + return + } + + common.RouteViewCounter.Bump(80) + err = routeProfileReplyEditSubmit(w,req,user,extraData) + case "/profile/reply/delete/submit/": + err = common.NoSessionMismatch(w,req,user) + if err != nil { + router.handleError(err,w,req,user) + return + } + + err = common.MemberOnly(w,req,user) + if err != nil { + router.handleError(err,w,req,user) + return + } + + common.RouteViewCounter.Bump(81) + err = routeProfileReplyDeleteSubmit(w,req,user,extraData) + } + if err != nil { + router.handleError(err,w,req,user) + } /*case "/sitemaps": // TODO: Count these views req.URL.Path += extraData err = sitemapSwitch(w,req) @@ -1245,7 +1305,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { common.NotFound(w,req) return } - common.RouteViewCounter.Bump(80) + common.RouteViewCounter.Bump(83) req.URL.Path += extraData // TODO: Find a way to propagate errors up from this? router.UploadHandler(w,req) // TODO: Count these views @@ -1289,7 +1349,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { router.RUnlock() if ok { - common.RouteViewCounter.Bump(79) // TODO: Be more specific about *which* dynamic route it is + common.RouteViewCounter.Bump(82) // TODO: Be more specific about *which* dynamic route it is req.URL.Path += extraData err = handle(w,req,user) if err != nil { diff --git a/main.go b/main.go index 7c23fefa..bcf60797 100644 --- a/main.go +++ b/main.go @@ -312,11 +312,6 @@ func main() { router.HandleFunc("/accounts/create/submit/", routeRegisterSubmit) //router.HandleFunc("/accounts/list/", routeLogin) // Redirect /accounts/ and /user/ to here.. // Get a list of all of the accounts on the forum - // TODO: Move these into /user/? - router.HandleFunc("/profile/reply/create/", routeProfileReplyCreate) - router.HandleFunc("/profile/reply/edit/submit/", routeProfileReplyEditSubmit) - router.HandleFunc("/profile/reply/delete/submit/", routeProfileReplyDeleteSubmit) - //router.HandleFunc("/user/edit/submit/", routeLogout) // routeLogout? what on earth? o.o router.HandleFunc("/ws/", routeWebsockets) log.Print("Initialising the plugins") diff --git a/member_routes.go b/member_routes.go index 2886fc2f..da0ad5e5 100644 --- a/member_routes.go +++ b/member_routes.go @@ -495,16 +495,11 @@ func routeReplyLikeSubmit(w http.ResponseWriter, r *http.Request, user common.Us return nil } -func routeProfileReplyCreate(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError { +func routeProfileReplyCreateSubmit(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError { if !user.Perms.ViewTopic || !user.Perms.CreateReply { return common.NoPermissions(w, r, user) } - err := r.ParseForm() - if err != nil { - return common.LocalError("Bad Form", w, r, user) - } - uid, err := strconv.Atoi(r.PostFormValue("uid")) if err != nil { return common.LocalError("Invalid UID", w, r, user) diff --git a/mod_routes.go b/mod_routes.go index 7299d748..f6ae35ec 100644 --- a/mod_routes.go +++ b/mod_routes.go @@ -476,14 +476,10 @@ func routeReplyDeleteSubmit(w http.ResponseWriter, r *http.Request, user common. return nil } -func routeProfileReplyEditSubmit(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError { - err := r.ParseForm() - if err != nil { - return common.LocalError("Bad Form", w, r, user) - } +func routeProfileReplyEditSubmit(w http.ResponseWriter, r *http.Request, user common.User, srid string) common.RouteError { isJs := (r.PostFormValue("js") == "1") - rid, err := strconv.Atoi(r.URL.Path[len("/profile/reply/edit/submit/"):]) + rid, err := strconv.Atoi(srid) if err != nil { return common.LocalErrorJSQ("The provided Reply ID is not a valid number.", w, r, user, isJs) } @@ -513,14 +509,10 @@ func routeProfileReplyEditSubmit(w http.ResponseWriter, r *http.Request, user co return nil } -func routeProfileReplyDeleteSubmit(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError { - err := r.ParseForm() - if err != nil { - return common.LocalError("Bad Form", w, r, user) - } +func routeProfileReplyDeleteSubmit(w http.ResponseWriter, r *http.Request, user common.User, srid string) common.RouteError { isJs := (r.PostFormValue("isJs") == "1") - rid, err := strconv.Atoi(r.URL.Path[len("/profile/reply/delete/submit/"):]) + rid, err := strconv.Atoi(srid) if err != nil { return common.LocalErrorJSQ("The provided Reply ID is not a valid number.", w, r, user, isJs) } diff --git a/router_gen/routes.go b/router_gen/routes.go index 30973509..5027c664 100644 --- a/router_gen/routes.go +++ b/router_gen/routes.go @@ -28,6 +28,7 @@ func routes() { buildUserRoutes() buildTopicRoutes() buildReplyRoutes() + buildProfileReplyRoutes() } // TODO: Test the email token route @@ -88,6 +89,18 @@ func buildReplyRoutes() { 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("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) +} + func buildPanelRoutes() { panelGroup := newRouteGroup("/panel/").Before("SuperModOnly") panelGroup.Routes( diff --git a/template_list.go b/template_list.go index 8059405e..c5b30429 100644 --- a/template_list.go +++ b/template_list.go @@ -647,56 +647,60 @@ var profile_comments_row_7 = []byte(` `) var profile_comments_row_8 = []byte(` +var profile_comments_row_9 = []byte(`?session=`) +var profile_comments_row_10 = []byte(`" class="mod_button" title="Edit Item"> `) -var profile_comments_row_11 = []byte(` +var profile_comments_row_11 = []byte(`?session=`) +var profile_comments_row_12 = []byte(`" class="mod_button" title="Delete Item">`) +var profile_comments_row_13 = []byte(` +var profile_comments_row_14 = []byte(`?session=`) +var profile_comments_row_15 = []byte(`&type=user-reply"> `) -var profile_comments_row_14 = []byte(` `) -var profile_comments_row_16 = []byte(` +var profile_comments_row_16 = []byte(` `) +var profile_comments_row_18 = []byte(` `) -var profile_comments_row_17 = []byte(` +var profile_comments_row_19 = []byte(`