wired up "Post & Go Next" correctly

This commit is contained in:
2026-01-19 17:31:43 -07:00
parent 9ec2310a72
commit ca8a92eaa3
4 changed files with 34 additions and 15 deletions
+19 -13
View File
@@ -111,7 +111,7 @@ func Topics(ctxt ui.AmContext) (string, any, error) {
} }
// create the "read new" URL // create the "read new" URL
urlStem := fmt.Sprintf("/comm/%s/conf/%s", comm.Alias, ctxt.URLParam("confid")) urlStem := fmt.Sprintf("/comm/%s/conf/%s", comm.Alias, ctxt.GetScratch("currentAlias"))
firstTopic := traverser.FirstTopic() firstTopic := traverser.FirstTopic()
if firstTopic >= 1 { if firstTopic >= 1 {
ctxt.VarMap().Set("urlReadNew", fmt.Sprintf("%s/r/%d", urlStem, firstTopic)) ctxt.VarMap().Set("urlReadNew", fmt.Sprintf("%s/r/%d", urlStem, firstTopic))
@@ -147,7 +147,7 @@ func NewTopicForm(ctxt ui.AmContext) (string, any, error) {
return ui.ErrorPage(ctxt, errors.New("you are not permitted to create topics in this conference")) return ui.ErrorPage(ctxt, errors.New("you are not permitted to create topics in this conference"))
} }
ctxt.VarMap().Set("conferenceName", conf.Name) ctxt.VarMap().Set("conferenceName", conf.Name)
ctxt.VarMap().Set("urlStem", fmt.Sprintf("/comm/%s/conf/%s", comm.Alias, ctxt.URLParam("confid"))) ctxt.VarMap().Set("urlStem", fmt.Sprintf("/comm/%s/conf/%s", comm.Alias, ctxt.GetScratch("currentAlias")))
ctxt.VarMap().Set("topicName", "") ctxt.VarMap().Set("topicName", "")
pseud, err := conf.DefaultPseud(ctxt.Ctx(), ctxt.CurrentUser()) pseud, err := conf.DefaultPseud(ctxt.Ctx(), ctxt.CurrentUser())
if err != nil { if err != nil {
@@ -176,7 +176,7 @@ func NewTopic(ctxt ui.AmContext) (string, any, error) {
return ui.ErrorPage(ctxt, errors.New("you are not permitted to create topics in this conference")) return ui.ErrorPage(ctxt, errors.New("you are not permitted to create topics in this conference"))
} }
urlStem := fmt.Sprintf("/comm/%s/conf/%s", comm.Alias, ctxt.URLParam("confid")) urlStem := fmt.Sprintf("/comm/%s/conf/%s", comm.Alias, ctxt.GetScratch("currentAlias"))
if ctxt.FormFieldIsSet("cancel") { if ctxt.FormFieldIsSet("cancel") {
return "redirect", urlStem, nil return "redirect", urlStem, nil
} }
@@ -679,10 +679,14 @@ func PostInTopic(ctxt ui.AmContext) (string, any, error) {
v, _ = checker.Value() v, _ = checker.Value()
ctxt.VarMap().Set("pb", v) ctxt.VarMap().Set("pb", v)
// also set the "attach" flag into the post data // also set the "attach" flag and "next topic" link (where applicable) into the post data
if ctxt.FormFieldIsSet("attach") { if ctxt.FormFieldIsSet("attach") {
ctxt.VarMap().Set("attachFile", true) ctxt.VarMap().Set("attachFile", true)
} }
urlNextTopic := ctxt.FormField("nextlink")
if len(urlNextTopic) > 0 {
ctxt.VarMap().Set("urlNextTopic", urlNextTopic)
}
if ctxt.FormFieldIsSet("preview") { if ctxt.FormFieldIsSet("preview") {
// Preview the post. // Preview the post.
@@ -707,20 +711,22 @@ func PostInTopic(ctxt ui.AmContext) (string, any, error) {
var returnURL string var returnURL string
if ctxt.FormFieldIsSet("post") { if ctxt.FormFieldIsSet("post") {
returnURL = urlStem returnURL = urlStem
} else if ctxt.FormFieldIsSet("postnext") { } else if ctxt.FormFieldIsSet("postnext") && len(urlNextTopic) > 0 {
returnURL = urlStem // TODO returnURL = urlNextTopic
} else if ctxt.FormFieldIsSet("posttopics") { } else if ctxt.FormFieldIsSet("posttopics") {
returnURL = fmt.Sprintf("/comm/%s/conf/%s", comm.Alias, ctxt.URLParam("confid")) returnURL = fmt.Sprintf("/comm/%s/conf/%s", comm.Alias, ctxt.GetScratch("currentAlias"))
} else { } else {
return ui.ErrorPage(ctxt, errors.New("unknown post button")) return ui.ErrorPage(ctxt, errors.New("unknown post button"))
} }
// Check for slippage.
maxPost, err := ctxt.FormFieldInt("xp") maxPost, err := ctxt.FormFieldInt("xp")
if err != nil { if err != nil {
return ui.ErrorPage(ctxt, err) return ui.ErrorPage(ctxt, err)
} }
if int32(maxPost) < topic.TopMessage { if int32(maxPost) < topic.TopMessage {
// Slippage detected! Display the slipped posts and another post box. // Slippage detected! Display the slipped posts and another post box.
// Get the slipped posts. // Start by getting the slipped posts.
posts, err := database.AmGetPostRange(ctxt.Ctx(), topic, int32(maxPost), topic.TopMessage) posts, err := database.AmGetPostRange(ctxt.Ctx(), topic, int32(maxPost), topic.TopMessage)
if err != nil { if err != nil {
return ui.ErrorPage(ctxt, err) return ui.ErrorPage(ctxt, err)
@@ -735,7 +741,7 @@ func PostInTopic(ctxt ui.AmContext) (string, any, error) {
ctxt.VarMap().SetFunc("post_getOverrideLink", templateOverrideLink) ctxt.VarMap().SetFunc("post_getOverrideLink", templateOverrideLink)
ctxt.VarMap().SetFunc("post_getText", templatePostText) ctxt.VarMap().SetFunc("post_getText", templatePostText)
ctxt.VarMap().SetFunc("post_getUserName", templateExtractUserName) ctxt.VarMap().SetFunc("post_getUserName", templateExtractUserName)
ctxt.VarMap().Set("post_stem", fmt.Sprintf("/comm/%s/conf/%s/r/%d", comm.Alias, ctxt.GetScratch("currentAlias").(string), topic.Number)) ctxt.VarMap().Set("post_stem", fmt.Sprintf("/comm/%s/conf/%s/r/%d", comm.Alias, ctxt.GetScratch("currentAlias"), topic.Number))
ctxt.VarMap().Set("post_max", topic.TopMessage) ctxt.VarMap().Set("post_max", topic.TopMessage)
ctxt.VarMap().Set("posts", posts) ctxt.VarMap().Set("posts", posts)
ctxt.VarMap().Set("topicName", topic.Name) ctxt.VarMap().Set("topicName", topic.Name)
@@ -769,12 +775,12 @@ func PostInTopic(ctxt ui.AmContext) (string, any, error) {
return ui.ErrorPage(ctxt, err) return ui.ErrorPage(ctxt, err)
} }
if !ctxt.FormFieldIsSet("attach") {
return "redirect", returnURL, nil // no attachment - just redisplay topic list
}
// TODO: whoever's subscribed needs to get a copy of this post in their E-mail // TODO: whoever's subscribed needs to get a copy of this post in their E-mail
if !ctxt.FormFieldIsSet("attach") {
return "redirect", returnURL, nil // no attachment - just bounce directly to the destination
}
// go upload the attachment // go upload the attachment
ctxt.VarMap().Set("target", returnURL) ctxt.VarMap().Set("target", returnURL)
ctxt.VarMap().Set("post", hdr.PostId) ctxt.VarMap().Set("post", hdr.PostId)
+5
View File
@@ -172,6 +172,9 @@
<form method="POST" action="{{ post_stem }}"> <form method="POST" action="{{ post_stem }}">
<input type="hidden" name="xp" value="{{ post_max }}"/> <input type="hidden" name="xp" value="{{ post_max }}"/>
{{ if isset(urlNextTopic) }}
<input type="hidden" name="nextlink" value="{{ urlNextTopic }}"/>
{{ end }}
<div class="bg-gray-50 p-6 rounded-lg space-y-4"> <div class="bg-gray-50 p-6 rounded-lg space-y-4">
<div> <div>
@@ -198,7 +201,9 @@
<div class="flex justify-center gap-4"> <div class="flex justify-center gap-4">
<button type="submit" name="preview" class="bg-gray-600 hover:bg-gray-700 text-white px-6 py-2 rounded font-medium transition-colors">Preview</button> <button type="submit" name="preview" class="bg-gray-600 hover:bg-gray-700 text-white px-6 py-2 rounded font-medium transition-colors">Preview</button>
<button type="submit" name="post" class="bg-green-600 hover:bg-green-700 text-white px-6 py-2 rounded font-medium transition-colors">Post & Reload</button> <button type="submit" name="post" class="bg-green-600 hover:bg-green-700 text-white px-6 py-2 rounded font-medium transition-colors">Post & Reload</button>
{{ if isset(urlNextTopic) }}
<button type="submit" name="postnext" class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded font-medium transition-colors">Post & Go Next</button> <button type="submit" name="postnext" class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded font-medium transition-colors">Post & Go Next</button>
{{ end }}
<button type="submit" name="posttopics" class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded font-medium transition-colors">Post & Go Topics</button> <button type="submit" name="posttopics" class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded font-medium transition-colors">Post & Go Topics</button>
</div> </div>
</div> </div>
+3
View File
@@ -45,6 +45,9 @@
<div class="max-w-3xl"> <div class="max-w-3xl">
<form method="POST" action="{{ urlStem }}"> <form method="POST" action="{{ urlStem }}">
<input type="hidden" name="xp" value="{{ maxPost }}"/> <input type="hidden" name="xp" value="{{ maxPost }}"/>
{{ if isset(urlNextTopic) }}
<input type="hidden" name="nextlink" value="{{ urlNextTopic }}"/>
{{ end }}
<div class="bg-gray-50 p-6 rounded-lg space-y-4"> <div class="bg-gray-50 p-6 rounded-lg space-y-4">
<!-- Your Name/Header and Attach File --> <!-- Your Name/Header and Attach File -->
<div> <div>
+5
View File
@@ -44,6 +44,9 @@
<div class="max-w-3xl"> <div class="max-w-3xl">
<form method="POST" action="{{ post_stem }}"> <form method="POST" action="{{ post_stem }}">
<input type="hidden" name="xp" value="{{ post_max }}"/> <input type="hidden" name="xp" value="{{ post_max }}"/>
{{ if isset(urlNextTopic) }}
<input type="hidden" name="nextlink" value="{{ urlNextTopic }}"/>
{{ end }}
<div class="bg-gray-50 p-6 rounded-lg space-y-4"> <div class="bg-gray-50 p-6 rounded-lg space-y-4">
<!-- Your Name/Header and Attach File --> <!-- Your Name/Header and Attach File -->
<div> <div>
@@ -76,7 +79,9 @@
<div class="flex justify-center gap-4 pt-4"> <div class="flex justify-center gap-4 pt-4">
<button type="submit" name="preview" class="bg-gray-600 hover:bg-gray-700 text-white px-6 py-2 rounded font-medium transition-colors">Preview</button> <button type="submit" name="preview" class="bg-gray-600 hover:bg-gray-700 text-white px-6 py-2 rounded font-medium transition-colors">Preview</button>
<button type="submit" name="post" class="bg-green-600 hover:bg-green-700 text-white px-6 py-2 rounded font-medium transition-colors">Post & Reload</button> <button type="submit" name="post" class="bg-green-600 hover:bg-green-700 text-white px-6 py-2 rounded font-medium transition-colors">Post & Reload</button>
{{ if isset(urlNextTopic) }}
<button type="submit" name="postnext" class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded font-medium transition-colors">Post & Go Next</button> <button type="submit" name="postnext" class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded font-medium transition-colors">Post & Go Next</button>
{{ end }}
<button type="submit" name="posttopics" class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded font-medium transition-colors">Post & Go Topics</button> <button type="submit" name="posttopics" class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded font-medium transition-colors">Post & Go Topics</button>
<button type="submit" name="cancel" class="bg-red-600 hover:bg-red-700 text-white px-6 py-2 rounded font-medium transition-colors">Cancel</button> <button type="submit" name="cancel" class="bg-red-600 hover:bg-red-700 text-white px-6 py-2 rounded font-medium transition-colors">Cancel</button>
</div> </div>