More exoskeletons and routes being moved around.

This commit is contained in:
Azareal 2018-01-14 14:27:10 +00:00
parent 9a3d8425e0
commit 4bfa48a926
9 changed files with 165 additions and 95 deletions

View File

@ -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 {

View File

@ -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")

View File

@ -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)

View File

@ -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)
}

View File

@ -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(

View File

@ -647,56 +647,60 @@ var profile_comments_row_7 = []byte(`</a>&nbsp;&nbsp;
`)
var profile_comments_row_8 = []byte(`<a href="/profile/reply/edit/submit/`)
var profile_comments_row_9 = []byte(`" class="mod_button" title="Edit Item"><button class="username edit_item edit_label"></button></a>
var profile_comments_row_9 = []byte(`?session=`)
var profile_comments_row_10 = []byte(`" class="mod_button" title="Edit Item"><button class="username edit_item edit_label"></button></a>
<a href="/profile/reply/delete/submit/`)
var profile_comments_row_10 = []byte(`" class="mod_button" title="Delete Item"><button class="username delete_item trash_label"></button></a>`)
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"><button class="username delete_item trash_label"></button></a>`)
var profile_comments_row_13 = []byte(`
<a class="mod_button" href="/report/submit/`)
var profile_comments_row_12 = []byte(`?session=`)
var profile_comments_row_13 = []byte(`&type=user-reply"><button class="username report_item flag_label"></button></a>
var profile_comments_row_14 = []byte(`?session=`)
var profile_comments_row_15 = []byte(`&type=user-reply"><button class="username report_item flag_label"></button></a>
`)
var profile_comments_row_14 = []byte(`<a class="username hide_on_mobile user_tag" style="float: right;">`)
var profile_comments_row_15 = []byte(`</a>`)
var profile_comments_row_16 = []byte(`
var profile_comments_row_16 = []byte(`<a class="username hide_on_mobile user_tag" style="float: right;">`)
var profile_comments_row_17 = []byte(`</a>`)
var profile_comments_row_18 = []byte(`
</span>
</div>
`)
var profile_comments_row_17 = []byte(`
var profile_comments_row_19 = []byte(`
<div class="rowitem passive deletable_block editable_parent comment `)
var profile_comments_row_18 = []byte(`">
var profile_comments_row_20 = []byte(`">
<div class="userbit">
<img src="`)
var profile_comments_row_19 = []byte(`" alt="`)
var profile_comments_row_20 = []byte(`'s Avatar" title="`)
var profile_comments_row_21 = []byte(`'s Avatar" />
var profile_comments_row_21 = []byte(`" alt="`)
var profile_comments_row_22 = []byte(`'s Avatar" title="`)
var profile_comments_row_23 = []byte(`'s Avatar" />
<span class="nameAndTitle">
<a href="`)
var profile_comments_row_22 = []byte(`" class="real_username username">`)
var profile_comments_row_23 = []byte(`</a>
var profile_comments_row_24 = []byte(`" class="real_username username">`)
var profile_comments_row_25 = []byte(`</a>
`)
var profile_comments_row_24 = []byte(`<a class="username hide_on_mobile user_tag" style="float: right;">`)
var profile_comments_row_25 = []byte(`</a>`)
var profile_comments_row_26 = []byte(`
var profile_comments_row_26 = []byte(`<a class="username hide_on_mobile user_tag" style="float: right;">`)
var profile_comments_row_27 = []byte(`</a>`)
var profile_comments_row_28 = []byte(`
</span>
</div>
<div class="content_column">
<span class="editable_block user_content">`)
var profile_comments_row_27 = []byte(`</span>
var profile_comments_row_29 = []byte(`</span>
<span class="controls">
`)
var profile_comments_row_28 = []byte(`
var profile_comments_row_30 = []byte(`
<a href="/profile/reply/edit/submit/`)
var profile_comments_row_29 = []byte(`" class="mod_button" title="Edit Item"><button class="username edit_item edit_label"></button></a>
var profile_comments_row_31 = []byte(`?session=`)
var profile_comments_row_32 = []byte(`" class="mod_button" title="Edit Item"><button class="username edit_item edit_label"></button></a>
<a href="/profile/reply/delete/submit/`)
var profile_comments_row_30 = []byte(`" class="mod_button" title="Delete Item"><button class="username delete_item trash_label"></button></a>
var profile_comments_row_33 = []byte(`?session=`)
var profile_comments_row_34 = []byte(`" class="mod_button" title="Delete Item"><button class="username delete_item trash_label"></button></a>
`)
var profile_comments_row_31 = []byte(`
var profile_comments_row_35 = []byte(`
<a class="mod_button" href="/report/submit/`)
var profile_comments_row_32 = []byte(`?session=`)
var profile_comments_row_33 = []byte(`&type=user-reply"><button class="username report_item flag_label"></button></a>
var profile_comments_row_36 = []byte(`?session=`)
var profile_comments_row_37 = []byte(`&type=user-reply"><button class="username report_item flag_label"></button></a>
</span>
</div>
</div>
@ -705,9 +709,10 @@ var profile_22 = []byte(`</div>
`)
var profile_23 = []byte(`
<form id="profile_comments_form" class="hash_hide" action="/profile/reply/create/" method="post">
<form id="profile_comments_form" class="hash_hide" action="/profile/reply/create/?session=`)
var profile_24 = []byte(`" method="post">
<input name="uid" value='`)
var profile_24 = []byte(`' type="hidden" />
var profile_25 = []byte(`' type="hidden" />
<div class="colstack_item topic_reply_form" style="border-top: none;">
<div class="formrow">
<div class="formitem"><textarea class="input_content" name="reply-content" placeholder="Insert comment here"></textarea></div>
@ -718,13 +723,13 @@ var profile_24 = []byte(`' type="hidden" />
</div>
</form>
`)
var profile_25 = []byte(`
var profile_26 = []byte(`
</div>
</div>
`)
var profile_26 = []byte(`
var profile_27 = []byte(`
<script type="text/javascript">
function handle_profile_hashbit() {
var hash_class = ""

View File

@ -144,69 +144,79 @@ if tmpl_profile_vars.CurrentUser.IsMod {
w.Write(profile_comments_row_8)
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write(profile_comments_row_9)
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write(profile_comments_row_10)
}
w.Write(profile_comments_row_11)
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write(profile_comments_row_12)
w.Write([]byte(tmpl_profile_vars.CurrentUser.Session))
w.Write(profile_comments_row_13)
if item.Tag != "" {
w.Write(profile_comments_row_14)
w.Write([]byte(item.Tag))
w.Write(profile_comments_row_15)
w.Write(profile_comments_row_10)
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write(profile_comments_row_11)
w.Write([]byte(tmpl_profile_vars.CurrentUser.Session))
w.Write(profile_comments_row_12)
}
w.Write(profile_comments_row_13)
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write(profile_comments_row_14)
w.Write([]byte(tmpl_profile_vars.CurrentUser.Session))
w.Write(profile_comments_row_15)
if item.Tag != "" {
w.Write(profile_comments_row_16)
w.Write([]byte(item.Tag))
w.Write(profile_comments_row_17)
}
w.Write(profile_comments_row_18)
}
}
} else {
if len(tmpl_profile_vars.ItemList) != 0 {
for _, item := range tmpl_profile_vars.ItemList {
w.Write(profile_comments_row_17)
w.Write([]byte(item.ClassName))
w.Write(profile_comments_row_18)
w.Write([]byte(item.Avatar))
w.Write(profile_comments_row_19)
w.Write([]byte(item.CreatedByName))
w.Write([]byte(item.ClassName))
w.Write(profile_comments_row_20)
w.Write([]byte(item.CreatedByName))
w.Write([]byte(item.Avatar))
w.Write(profile_comments_row_21)
w.Write([]byte(item.UserLink))
w.Write([]byte(item.CreatedByName))
w.Write(profile_comments_row_22)
w.Write([]byte(item.CreatedByName))
w.Write(profile_comments_row_23)
if item.Tag != "" {
w.Write([]byte(item.UserLink))
w.Write(profile_comments_row_24)
w.Write([]byte(item.Tag))
w.Write([]byte(item.CreatedByName))
w.Write(profile_comments_row_25)
}
if item.Tag != "" {
w.Write(profile_comments_row_26)
w.Write([]byte(item.ContentHtml))
w.Write([]byte(item.Tag))
w.Write(profile_comments_row_27)
if tmpl_profile_vars.CurrentUser.IsMod {
w.Write(profile_comments_row_28)
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write(profile_comments_row_29)
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write(profile_comments_row_30)
}
w.Write(profile_comments_row_31)
w.Write(profile_comments_row_28)
w.Write([]byte(item.ContentHtml))
w.Write(profile_comments_row_29)
if tmpl_profile_vars.CurrentUser.IsMod {
w.Write(profile_comments_row_30)
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write(profile_comments_row_32)
w.Write(profile_comments_row_31)
w.Write([]byte(tmpl_profile_vars.CurrentUser.Session))
w.Write(profile_comments_row_32)
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write(profile_comments_row_33)
w.Write([]byte(tmpl_profile_vars.CurrentUser.Session))
w.Write(profile_comments_row_34)
}
w.Write(profile_comments_row_35)
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write(profile_comments_row_36)
w.Write([]byte(tmpl_profile_vars.CurrentUser.Session))
w.Write(profile_comments_row_37)
}
}
}
w.Write(profile_22)
if !tmpl_profile_vars.CurrentUser.IsBanned {
w.Write(profile_23)
w.Write([]byte(strconv.Itoa(tmpl_profile_vars.ProfileOwner.ID)))
w.Write([]byte(tmpl_profile_vars.CurrentUser.Session))
w.Write(profile_24)
}
w.Write([]byte(strconv.Itoa(tmpl_profile_vars.ProfileOwner.ID)))
w.Write(profile_25)
}
w.Write(profile_26)
w.Write(profile_27)
w.Write(footer_0)
w.Write([]byte(common.BuildWidget("footer",tmpl_profile_vars.Header)))
w.Write(footer_1)

View File

@ -72,7 +72,7 @@
<div id="profile_comments" class="colstack_item hash_hide">{{template "profile_comments_row.html" . }}</div>
{{if not .CurrentUser.IsBanned}}
<form id="profile_comments_form" class="hash_hide" action="/profile/reply/create/" method="post">
<form id="profile_comments_form" class="hash_hide" action="/profile/reply/create/?session={{.CurrentUser.Session}}" method="post">
<input name="uid" value='{{.ProfileOwner.ID}}' type="hidden" />
<div class="colstack_item topic_reply_form" style="border-top: none;">
<div class="formrow">

View File

@ -6,9 +6,9 @@
<span class="controls">
<a href="{{.UserLink}}" class="real_username username">{{.CreatedByName}}</a>&nbsp;&nbsp;
{{if $.CurrentUser.IsMod}}<a href="/profile/reply/edit/submit/{{.ID}}" class="mod_button" title="Edit Item"><button class="username edit_item edit_label"></button></a>
{{if $.CurrentUser.IsMod}}<a href="/profile/reply/edit/submit/{{.ID}}?session={{$.CurrentUser.Session}}" class="mod_button" title="Edit Item"><button class="username edit_item edit_label"></button></a>
<a href="/profile/reply/delete/submit/{{.ID}}" class="mod_button" title="Delete Item"><button class="username delete_item trash_label"></button></a>{{end}}
<a href="/profile/reply/delete/submit/{{.ID}}?session={{$.CurrentUser.Session}}" class="mod_button" title="Delete Item"><button class="username delete_item trash_label"></button></a>{{end}}
<a class="mod_button" href="/report/submit/{{.ID}}?session={{$.CurrentUser.Session}}&type=user-reply"><button class="username report_item flag_label"></button></a>
@ -30,8 +30,8 @@
<span class="editable_block user_content">{{.ContentHtml}}</span>
<span class="controls">
{{if $.CurrentUser.IsMod}}
<a href="/profile/reply/edit/submit/{{.ID}}" class="mod_button" title="Edit Item"><button class="username edit_item edit_label"></button></a>
<a href="/profile/reply/delete/submit/{{.ID}}" class="mod_button" title="Delete Item"><button class="username delete_item trash_label"></button></a>
<a href="/profile/reply/edit/submit/{{.ID}}?session={{$.CurrentUser.Session}}" class="mod_button" title="Edit Item"><button class="username edit_item edit_label"></button></a>
<a href="/profile/reply/delete/submit/{{.ID}}?session={{$.CurrentUser.Session}}" class="mod_button" title="Delete Item"><button class="username delete_item trash_label"></button></a>
{{end}}
<a class="mod_button" href="/report/submit/{{.ID}}?session={{$.CurrentUser.Session}}&type=user-reply"><button class="username report_item flag_label"></button></a>
</span>