From 759996b4cd8b69fe09c07ac784202be0afabbc9a Mon Sep 17 00:00:00 2001 From: Amy Gale Ruth Bowersox Date: Fri, 24 Apr 2026 22:40:33 -0600 Subject: [PATCH] extended the use of ConferenceLink throughout the conferencing code --- conference.go | 18 +++++------ conference_ops.go | 58 ++++++++++++++++------------------- conferenceadmin.go | 76 +++++++++++++++++++--------------------------- find.go | 18 +++++------ invites.go | 4 +-- 5 files changed, 78 insertions(+), 96 deletions(-) diff --git a/conference.go b/conference.go index 8c3d78f..fdf8aea 100644 --- a/conference.go +++ b/conference.go @@ -136,7 +136,7 @@ func Topics(ctxt ui.AmContext) (string, any) { } // create the "read new" URL - urlStem := fmt.Sprintf("/comm/%s/conf/%s", comm.Alias, ctxt.GetScratch("currentAlias")) + urlStem := ctxt.GetScratch("ConferenceLink").(string) if !ctxt.CurrentUser().IsAnon { traverser := ui.NewTopicTraverser(topics) ctxt.SetSession("topic.traverser", traverser) @@ -178,14 +178,13 @@ func Topics(ctxt ui.AmContext) (string, any) { * Data as a parameter for the command string. */ func NewTopicForm(ctxt ui.AmContext) (string, any) { - comm := ctxt.CurrentCommunity() conf := ctxt.GetScratch("currentConference").(*database.Conference) myLevel := ctxt.GetScratch("levelInConference").(uint16) if !conf.TestPermission("Conference.Create", myLevel) { return "error", echo.NewHTTPError(http.StatusForbidden, "you are not permitted to create topics in this conference") } ctxt.VarMap().Set("conferenceName", conf.Name) - ctxt.VarMap().Set("urlStem", fmt.Sprintf("/comm/%s/conf/%s", comm.Alias, ctxt.GetScratch("currentAlias"))) + ctxt.VarMap().Set("urlStem", ctxt.GetScratch("ConferenceLink").(string)) ctxt.VarMap().Set("topicName", "") pseud, err := conf.DefaultPseud(ctxt.Ctx(), ctxt.CurrentUser()) if err != nil { @@ -212,7 +211,7 @@ func NewTopic(ctxt ui.AmContext) (string, any) { return "error", echo.NewHTTPError(http.StatusForbidden, "you are not permitted to create topics in this conference") } - urlStem := fmt.Sprintf("/comm/%s/conf/%s", comm.Alias, ctxt.GetScratch("currentAlias")) + urlStem := ctxt.GetScratch("ConferenceLink").(string) if ctxt.FormFieldIsSet("cancel") { return "redirect", urlStem } @@ -634,7 +633,7 @@ func ReadPosts(ctxt ui.AmContext) (string, any) { ctxt.VarMap().Set("advancedControls", advancedControls) // Adjust the traverser and get the "next" link. - urlStem := fmt.Sprintf("/comm/%s/conf/%s", comm.Alias, ctxt.GetScratch("currentAlias").(string)) + urlStem := ctxt.GetScratch("ConferenceLink").(string) if traverser != nil { traverser.ClearTopic(topic.Number) nextTopic := traverser.NextTopic(topic.Number) @@ -689,7 +688,7 @@ func PostInTopic(ctxt ui.AmContext) (string, any) { topic := ctxt.GetScratch("currentTopic").(*database.Topic) ctxt.VarMap().Set("post_topic", topic) - urlStem := fmt.Sprintf("/comm/%s/conf/%s/r/%d", comm.Alias, ctxt.GetScratch("currentAlias"), topic.Number) + urlStem := fmt.Sprintf("%s/r/%d", ctxt.GetScratch("ConferenceLink"), topic.Number) if ctxt.FormFieldIsSet("cancel") { return "redirect", urlStem } @@ -757,7 +756,7 @@ func PostInTopic(ctxt ui.AmContext) (string, any) { } else if ctxt.FormFieldIsSet("postnext") && len(urlNextTopic) > 0 { returnURL = urlNextTopic } else if ctxt.FormFieldIsSet("posttopics") { - returnURL = fmt.Sprintf("/comm/%s/conf/%s", comm.Alias, ctxt.GetScratch("currentAlias")) + returnURL = ctxt.GetScratch("ConferenceLink").(string) } else { return "error", EBUTTON } @@ -779,7 +778,9 @@ func PostInTopic(ctxt ui.AmContext) (string, any) { ctxt.VarMap().Set("post_confRef", plc.AsString()) plc.Community = comm.Alias ctxt.VarMap().Set("post_topicPermalink", fmt.Sprintf("/go/%s", plc.AsString())) - ctxt.VarMap().Set("post_topicLink", fmt.Sprintf("%s/r/%d", ctxt.GetScratch("ConferenceLink"), topic.Number)) + t := fmt.Sprintf("%s/r/%d", ctxt.GetScratch("ConferenceLink"), topic.Number) + ctxt.VarMap().Set("post_topicLink", t) + ctxt.VarMap().Set("post_stem", t) ctxt.VarMap().SetFunc("post_getOverrideLine", templateOverrideLine) ctxt.VarMap().SetFunc("post_getOverrideLink", templateOverrideLink) @@ -787,7 +788,6 @@ func PostInTopic(ctxt ui.AmContext) (string, any) { ctxt.VarMap().SetFunc("post_getUserName", templateExtractUserName) ctxt.VarMap().SetFunc("post_getAttachmentInfo", templateAttachmentInfo) ctxt.VarMap().SetFunc("post_isBozo", templateBozo) - 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("posts", posts) ctxt.VarMap().Set("topicName", topic.Name) diff --git a/conference_ops.go b/conference_ops.go index 65d80e0..d864121 100644 --- a/conference_ops.go +++ b/conference_ops.go @@ -156,7 +156,7 @@ func ConfManage(ctxt ui.AmContext) (string, any) { comm := ctxt.CurrentCommunity() conf := ctxt.GetScratch("currentConference").(*database.Conference) myLevel := ctxt.GetScratch("levelInConference").(uint16) - urlStem := fmt.Sprintf("/comm/%s/conf/%s", comm.Alias, ctxt.GetScratch("currentAlias")) + urlStem := ctxt.GetScratch("ConferenceLink").(string) ctxt.VarMap().Set("confName", conf.Name) ctxt.VarMap().Set("urlStem", urlStem) @@ -193,14 +193,13 @@ func ConfManage(ctxt ui.AmContext) (string, any) { * Data as a parameter for the command string. */ func SetPseud(ctxt ui.AmContext) (string, any) { - comm := ctxt.CurrentCommunity() conf := ctxt.GetScratch("currentConference").(*database.Conference) pseud := ctxt.FormField("pseud") err := conf.SetDefaultPseud(ctxt.Ctx(), ctxt.CurrentUser(), pseud) if err != nil { return "error", err } - return "redirect", fmt.Sprintf("/comm/%s/conf/%s/manage", comm.Alias, ctxt.GetScratch("currentAlias")) + return "redirect", fmt.Sprintf("%s/manage", ctxt.GetScratch("ConferenceLink")) } /* ConfFixseen marks all messages in a conference as read. @@ -211,13 +210,12 @@ func SetPseud(ctxt ui.AmContext) (string, any) { * Data as a parameter for the command string. */ func ConfFixseen(ctxt ui.AmContext) (string, any) { - comm := ctxt.CurrentCommunity() conf := ctxt.GetScratch("currentConference").(*database.Conference) err := conf.Fixseen(ctxt.Ctx(), ctxt.CurrentUser()) if err != nil { return "error", err } - return "redirect", fmt.Sprintf("/comm/%s/conf/%s/manage", comm.Alias, ctxt.GetScratch("currentAlias")) + return "redirect", fmt.Sprintf("%s/manage", ctxt.GetScratch("ConferenceLink")) } /* AddToHotlist adds the current community and conference to the user's hotlist.. @@ -234,7 +232,7 @@ func AddToHotlist(ctxt ui.AmContext) (string, any) { if err != nil { return "error", err } - return "redirect", fmt.Sprintf("/comm/%s/conf/%s", comm.Alias, ctxt.GetScratch("currentAlias")) + return "redirect", ctxt.GetScratch("ConferenceLink").(string) } /* HideTopic hides or shows the current topic for the current user. @@ -254,7 +252,7 @@ func HideTopic(ctxt ui.AmContext) (string, any) { if err != nil { return "error", err } - return "redirect", fmt.Sprintf("/comm/%s/conf/%s/r/%d", ctxt.CurrentCommunity().Alias, ctxt.GetScratch("currentAlias"), topic.Number) + return "redirect", fmt.Sprintf("%s/r/%d", ctxt.GetScratch("ConferenceLink"), topic.Number) } /* FreezeTopic freezes or unfreezes the current topic. @@ -275,7 +273,7 @@ func FreezeTopic(ctxt ui.AmContext) (string, any) { if err != nil { return "error", err } - return "redirect", fmt.Sprintf("/comm/%s/conf/%s/r/%d", ctxt.CurrentCommunity().Alias, ctxt.GetScratch("currentAlias"), topic.Number) + return "redirect", fmt.Sprintf("%s/r/%d", ctxt.GetScratch("ConferenceLink"), topic.Number) } /* ArchiveTopic archives or unarchives the current topic. @@ -296,7 +294,7 @@ func ArchiveTopic(ctxt ui.AmContext) (string, any) { if err != nil { return "error", err } - return "redirect", fmt.Sprintf("/comm/%s/conf/%s/r/%d", ctxt.CurrentCommunity().Alias, ctxt.GetScratch("currentAlias"), topic.Number) + return "redirect", fmt.Sprintf("%s/r/%d", ctxt.GetScratch("ConferenceLink"), topic.Number) } /* StickTopic sticks or unsticks the current topic. @@ -317,7 +315,7 @@ func StickTopic(ctxt ui.AmContext) (string, any) { if err != nil { return "error", err } - return "redirect", fmt.Sprintf("/comm/%s/conf/%s/r/%d", ctxt.CurrentCommunity().Alias, ctxt.GetScratch("currentAlias"), topic.Number) + return "redirect", fmt.Sprintf("%s/r/%d", ctxt.GetScratch("ConferenceLink"), topic.Number) } /* DeleteTopic deletes the current topic. @@ -348,14 +346,14 @@ func DeleteTopic(ctxt ui.AmContext) (string, any) { if err != nil { return "error", err } - return "redirect", fmt.Sprintf("/comm/%s/conf/%s", ctxt.CurrentCommunity().Alias, ctxt.GetScratch("currentAlias")) + return "redirect", ctxt.GetScratch("ConferenceLink").(string) } // Set up to display the message box. mbox.SetMessage(fmt.Sprintf(`You are about to detele the topic "%s" from the "%s" conference!`, topic.Name, conf.Name)) - mbox.SetLink("no", fmt.Sprintf("/comm/%s/conf/%s/r/%d", ctxt.CurrentCommunity().Alias, ctxt.GetScratch("currentAlias"), topic.Number)) - mbox.SetLink("yes", fmt.Sprintf("/comm/%s/conf/%s/op/%d/delete", ctxt.CurrentCommunity().Alias, ctxt.GetScratch("currentAlias"), topic.Number)) + mbox.SetLink("no", fmt.Sprintf("%s/r/%d", ctxt.GetScratch("ConferenceLink"), topic.Number)) + mbox.SetLink("yes", fmt.Sprintf("%s/op/%d/delete", ctxt.GetScratch("ConferenceLink"), topic.Number)) return mbox.Render(ctxt) } @@ -390,7 +388,7 @@ func HideMessage(ctxt ui.AmContext) (string, any) { if err != nil { return "error", err } - return "redirect", fmt.Sprintf("/comm/%s/conf/%s/r/%d?r=%d&ac=1", ctxt.CurrentCommunity().Alias, ctxt.GetScratch("currentAlias"), topic.Number, hdrs[0].Num) + return "redirect", fmt.Sprintf("%s/r/%d?r=%d&ac=1", ctxt.GetScratch("ConferenceLink"), topic.Number, hdrs[0].Num) } /* ScribbleMessage scribbles a topic message. @@ -424,7 +422,7 @@ func ScribbleMessage(ctxt ui.AmContext) (string, any) { if err != nil { return "error", err } - return "redirect", fmt.Sprintf("/comm/%s/conf/%s/r/%d?r=%d&ac=1", ctxt.CurrentCommunity().Alias, ctxt.GetScratch("currentAlias"), topic.Number, hdrs[0].Num) + return "redirect", fmt.Sprintf("%s/r/%d?r=%d&ac=1", ctxt.GetScratch("ConferenceLink"), topic.Number, hdrs[0].Num) } /* NukeMessage nukes (deletes entirely) a topic message. @@ -466,7 +464,7 @@ func NukeMessage(ctxt ui.AmContext) (string, any) { if err != nil { return "error", err } - return "redirect", fmt.Sprintf("/comm/%s/conf/%s/r/%d", ctxt.CurrentCommunity().Alias, ctxt.GetScratch("currentAlias"), topic.Number) + return "redirect", fmt.Sprintf("%s/r/%d", ctxt.GetScratch("ConferenceLink"), topic.Number) } // Set up to display the message box. @@ -480,8 +478,8 @@ func NukeMessage(ctxt ui.AmContext) (string, any) { } mbox.SetMessage(fmt.Sprintf(`You are about to nuke message <%s>, originally composed by <%s>!`, link, creator.Username)) - mbox.SetLink("no", fmt.Sprintf("/comm/%s/conf/%s/r/%d?r=%d&ac=1", ctxt.CurrentCommunity().Alias, ctxt.GetScratch("currentAlias"), topic.Number, hdrs[0].Num)) - mbox.SetLink("yes", fmt.Sprintf("/comm/%s/conf/%s/op/%d/nuke/%d", ctxt.CurrentCommunity().Alias, ctxt.GetScratch("currentAlias"), topic.Number, hdrs[0].Num)) + mbox.SetLink("no", fmt.Sprintf("%s/r/%d?r=%d&ac=1", ctxt.GetScratch("ConferenceLink"), topic.Number, hdrs[0].Num)) + mbox.SetLink("yes", fmt.Sprintf("%s/op/%d/nuke/%d", ctxt.GetScratch("ConferenceLink"), topic.Number, hdrs[0].Num)) return mbox.Render(ctxt) } @@ -524,7 +522,7 @@ func PruneMessageAttachment(ctxt ui.AmContext) (string, any) { if err != nil { return "error", err } - return "redirect", fmt.Sprintf("/comm/%s/conf/%s/r/%d?r=%d&ac=1", ctxt.CurrentCommunity().Alias, ctxt.GetScratch("currentAlias"), topic.Number, hdrs[0].Num) + return "redirect", fmt.Sprintf("%s/r/%d?r=%d&ac=1", ctxt.GetScratch("ConferenceLink"), topic.Number, hdrs[0].Num) } // Set up to display the message box. @@ -538,8 +536,8 @@ func PruneMessageAttachment(ctxt ui.AmContext) (string, any) { } mbox.SetMessage(fmt.Sprintf(`You are about to prune the attachment of message <%s>, originally composed by <%s>!`, link, creator.Username)) - mbox.SetLink("no", fmt.Sprintf("/comm/%s/conf/%s/r/%d?r=%d&ac=1", ctxt.CurrentCommunity().Alias, ctxt.GetScratch("currentAlias"), topic.Number, hdrs[0].Num)) - mbox.SetLink("yes", fmt.Sprintf("/comm/%s/conf/%s/op/%d/prune/%d", ctxt.CurrentCommunity().Alias, ctxt.GetScratch("currentAlias"), topic.Number, hdrs[0].Num)) + mbox.SetLink("no", fmt.Sprintf("%s/r/%d?r=%d&ac=1", ctxt.GetScratch("ConferenceLink"), topic.Number, hdrs[0].Num)) + mbox.SetLink("yes", fmt.Sprintf("%s/op/%d/prune/%d", ctxt.GetScratch("ConferenceLink"), topic.Number, hdrs[0].Num)) return mbox.Render(ctxt) } @@ -591,7 +589,7 @@ func MoveMessageForm(ctxt ui.AmContext) (string, any) { ctxt.VarMap().Set("post", hdrs[0]) ctxt.VarMap().Set("topMessage", topic.TopMessage) - formLink := fmt.Sprintf("/comm/%s/conf/%s/op/%d/move/%d", ctxt.CurrentCommunity().Alias, ctxt.GetScratch("currentAlias"), topic.Number, hdrs[0].Num) + formLink := fmt.Sprintf("%s/op/%d/move/%d", ctxt.GetScratch("ConferenceLink"), topic.Number, hdrs[0].Num) ctxt.VarMap().Set("formLink", formLink) ctxt.SetFrameTitle("Move Message") @@ -625,7 +623,7 @@ func PublishMessage(ctxt ui.AmContext) (string, any) { if err = hdrs[0].Publish(ctxt.Ctx(), comm, ctxt.CurrentUser(), ctxt.RemoteIP()); err != nil { return "error", err } - return "redirect", fmt.Sprintf("/comm/%s/conf/%s/r/%d?r=%d&ac=1", ctxt.CurrentCommunity().Alias, ctxt.GetScratch("currentAlias"), topic.Number, hdrs[0].Num) + return "redirect", fmt.Sprintf("%s/r/%d?r=%d&ac=1", ctxt.GetScratch("ConferenceLink"), topic.Number, hdrs[0].Num) } /* MoveMessage moves a message to a different topic. @@ -654,7 +652,7 @@ func MoveMessage(ctxt ui.AmContext) (string, any) { return "error", EPOSTREF } if ctxt.FormFieldIsSet("cancel") { - return "redirect", fmt.Sprintf("/comm/%s/conf/%s/r/%d?r=%d&ac=1", comm.Alias, ctxt.GetScratch("currentAlias"), topic.Number, hdrs[0].Num) + return "redirect", fmt.Sprintf("%s/r/%d?r=%d&ac=1", ctxt.GetScratch("ConferenceLink"), topic.Number, hdrs[0].Num) } if !conf.TestPermission("Conference.Nuke", myLevel) || !conf.TestPermission("Conference.Post", myLevel) || topic.TopMessage == 0 { return "error", ENOPERM @@ -696,7 +694,7 @@ func MoveMessage(ctxt ui.AmContext) (string, any) { }) } - return "redirect", fmt.Sprintf("/comm/%s/conf/%s/r/%d", ctxt.CurrentCommunity().Alias, ctxt.GetScratch("currentAlias"), topic.Number) + return "redirect", fmt.Sprintf("%s/r/%d", ctxt.GetScratch("ConferenceLink"), topic.Number) } /* TopicManage displays the "manage topic" page. @@ -709,8 +707,8 @@ func MoveMessage(ctxt ui.AmContext) (string, any) { func TopicManage(ctxt ui.AmContext) (string, any) { comm := ctxt.CurrentCommunity() topic := ctxt.GetScratch("currentTopic").(*database.Topic) - ctxt.VarMap().Set("backlink", fmt.Sprintf("/comm/%s/conf/%s/r/%d", comm.Alias, ctxt.GetScratch("currentAlias"), topic.Number)) - opsLink := fmt.Sprintf("/comm/%s/conf/%s/op/%d", comm.Alias, ctxt.GetScratch("currentAlias"), topic.Number) + ctxt.VarMap().Set("backlink", fmt.Sprintf("%s/r/%d", ctxt.GetScratch("ConferenceLink"), topic.Number)) + opsLink := fmt.Sprintf("%s/op/%d", ctxt.GetScratch("ConferenceLink"), topic.Number) ctxt.VarMap().Set("opsLink", opsLink) ctxt.VarMap().Set("topicName", topic.Name) @@ -750,7 +748,6 @@ func TopicSetSubscribe(ctxt ui.AmContext) (string, any) { if ctxt.CurrentUser().IsAnon { return "error", ENOPERM } - comm := ctxt.CurrentCommunity() topic := ctxt.GetScratch("currentTopic").(*database.Topic) flag, err := topic.IsSubscribed(ctxt.Ctx(), ctxt.CurrentUser()) if err != nil { @@ -760,7 +757,7 @@ func TopicSetSubscribe(ctxt ui.AmContext) (string, any) { if err != nil { return "error", err } - return "redirect", fmt.Sprintf("/comm/%s/conf/%s/op/%d/manage", comm.Alias, ctxt.GetScratch("currentAlias"), topic.Number) + return "redirect", fmt.Sprintf("%s/op/%d/manage", ctxt.GetScratch("ConferenceLink"), topic.Number) } /* TopicRemoveBozo removes filtering from a specified user in the topic. @@ -771,7 +768,6 @@ func TopicSetSubscribe(ctxt ui.AmContext) (string, any) { * Data as a parameter for the command string. */ func TopicRemoveBozo(ctxt ui.AmContext) (string, any) { - comm := ctxt.CurrentCommunity() topic := ctxt.GetScratch("currentTopic").(*database.Topic) bozoUid, err := strconv.Atoi(ctxt.URLParam("uid")) if err != nil { @@ -781,5 +777,5 @@ func TopicRemoveBozo(ctxt ui.AmContext) (string, any) { if err != nil { return "error", err } - return "redirect", fmt.Sprintf("/comm/%s/conf/%s/op/%d/manage", comm.Alias, ctxt.GetScratch("currentAlias"), topic.Number) + return "redirect", fmt.Sprintf("%s/op/%d/manage", ctxt.GetScratch("ConferenceLink"), topic.Number) } diff --git a/conferenceadmin.go b/conferenceadmin.go index 3a5eb92..1afc933 100644 --- a/conferenceadmin.go +++ b/conferenceadmin.go @@ -99,7 +99,7 @@ func EditConference(ctxt ui.AmContext) (string, any) { } button := dlg.WhichButton(ctxt) if button == "cancel" { - return "redirect", fmt.Sprintf("/comm/%s/conf/%s/manage", comm.Alias, ctxt.GetScratch("currentAlias")) + return "redirect", fmt.Sprintf("%s/manage", ctxt.GetScratch("ConferenceLink")) } else if button != "update" { dlg.SetCommunity(comm) dlg.SetConference(conf, ctxt.GetScratch("currentAlias").(string)) @@ -128,7 +128,7 @@ func EditConference(ctxt ui.AmContext) (string, any) { return dlg.RenderError(ctxt, err.Error()) } - return "redirect", fmt.Sprintf("/comm/%s/conf/%s/manage", comm.Alias, ctxt.GetScratch("currentAlias")) + return "redirect", fmt.Sprintf("%s/manage", ctxt.GetScratch("ConferenceLink")) } /* ConferenceAliasForm displays the form for managing conference aliases. @@ -148,8 +148,8 @@ func ConferenceAliasForm(ctxt ui.AmContext) (string, any) { ctxt.VarMap().Set("newAlias", "") ctxt.VarMap().Set("confName", conf.Name) - ctxt.VarMap().Set("backLink", fmt.Sprintf("/comm/%s/conf/%s/manage", comm.Alias, ctxt.GetScratch("currentAlias"))) - ctxt.VarMap().Set("selfLink", fmt.Sprintf("/comm/%s/conf/%s/aliases", comm.Alias, ctxt.GetScratch("currentAlias"))) + ctxt.VarMap().Set("backLink", fmt.Sprintf("%s/manage", ctxt.GetScratch("ConferenceLink"))) + ctxt.VarMap().Set("selfLink", fmt.Sprintf("%s/aliases", ctxt.GetScratch("ConferenceLink"))) ctxt.SetFrameTitle(fmt.Sprintf("Manage Conference Aliases: %s", conf.Name)) if ctxt.HasParameter("del") { @@ -184,8 +184,8 @@ func ConferenceAliasAdd(ctxt ui.AmContext) (string, any) { } ctxt.VarMap().Set("confName", conf.Name) - ctxt.VarMap().Set("backLink", fmt.Sprintf("/comm/%s/conf/%s/manage", comm.Alias, ctxt.GetScratch("currentAlias"))) - ctxt.VarMap().Set("selfLink", fmt.Sprintf("/comm/%s/conf/%s/aliases", comm.Alias, ctxt.GetScratch("currentAlias"))) + ctxt.VarMap().Set("backLink", fmt.Sprintf("%s/manage", ctxt.GetScratch("ConferenceLink"))) + ctxt.VarMap().Set("selfLink", fmt.Sprintf("%s/aliases", ctxt.GetScratch("ConferenceLink"))) ctxt.SetFrameTitle(fmt.Sprintf("Manage Conference Aliases: %s", conf.Name)) newAlias := ctxt.FormField("na") @@ -241,8 +241,8 @@ func ConferenceMembers(ctxt ui.AmContext) (string, any) { // Set the first batch of page variables. ctxt.VarMap().Set("commName", comm.Name) ctxt.VarMap().Set("confName", conf.Name) - ctxt.VarMap().Set("backLink", fmt.Sprintf("/comm/%s/conf/%s/manage", comm.Alias, ctxt.GetScratch("currentAlias"))) - ctxt.VarMap().Set("selfLink", fmt.Sprintf("/comm/%s/conf/%s/members", comm.Alias, ctxt.GetScratch("currentAlias"))) + ctxt.VarMap().Set("backLink", fmt.Sprintf("%s/manage", ctxt.GetScratch("ConferenceLink"))) + ctxt.VarMap().Set("selfLink", fmt.Sprintf("%s/members", ctxt.GetScratch("ConferenceLink"))) ctxt.VarMap().Set("roleList", database.AmRoleList("Conference.UserLevels")) ctxt.SetFrameTitle(fmt.Sprintf("Membership in Conference: %s", conf.Name)) @@ -381,7 +381,6 @@ func ConferenceMembers(ctxt ui.AmContext) (string, any) { * Data as a parameter for the command string. */ func ConfCustomForm(ctxt ui.AmContext) (string, any) { - comm := ctxt.CurrentCommunity() conf := ctxt.GetScratch("currentConference").(*database.Conference) myLevel := ctxt.GetScratch("levelInConference").(uint16) if !conf.TestPermission("Conference.Change", myLevel) { @@ -394,7 +393,7 @@ func ConfCustomForm(ctxt ui.AmContext) (string, any) { } ctxt.VarMap().Set("confName", conf.Name) - ctxt.VarMap().Set("selfLink", fmt.Sprintf("/comm/%s/conf/%s/custom", comm.Alias, ctxt.GetScratch("currentAlias"))) + ctxt.VarMap().Set("selfLink", fmt.Sprintf("%s/custom", ctxt.GetScratch("ConferenceLink"))) ctxt.VarMap().Set("topText", topBlock) ctxt.VarMap().Set("bottomText", bottomBlock) ctxt.SetFrameTitle(fmt.Sprintf("Customize Conference: %s", conf.Name)) @@ -409,7 +408,6 @@ func ConfCustomForm(ctxt ui.AmContext) (string, any) { * Data as a parameter for the command string. */ func ConfCustom(ctxt ui.AmContext) (string, any) { - comm := ctxt.CurrentCommunity() conf := ctxt.GetScratch("currentConference").(*database.Conference) myLevel := ctxt.GetScratch("levelInConference").(uint16) if !conf.TestPermission("Conference.Change", myLevel) { @@ -429,7 +427,7 @@ func ConfCustom(ctxt ui.AmContext) (string, any) { if err != nil { return "error", err } - return "redirect", fmt.Sprintf("/comm/%s/conf/%s/manage", comm.Alias, ctxt.GetScratch("currentAlias")) + return "redirect", fmt.Sprintf("%s/manage", ctxt.GetScratch("ConferenceLink")) } /* ConfReports displays conference activity reports. @@ -440,7 +438,6 @@ func ConfCustom(ctxt ui.AmContext) (string, any) { * Data as a parameter for the command string. */ func ConfReports(ctxt ui.AmContext) (string, any) { - comm := ctxt.CurrentCommunity() conf := ctxt.GetScratch("currentConference").(*database.Conference) myLevel := ctxt.GetScratch("levelInConference").(uint16) if !conf.TestPermission("Conference.Read", myLevel) { @@ -448,7 +445,7 @@ func ConfReports(ctxt ui.AmContext) (string, any) { } ctxt.VarMap().Set("confName", conf.Name) - ctxt.VarMap().Set("selfLink", fmt.Sprintf("/comm/%s/conf/%s/activity", comm.Alias, ctxt.GetScratch("currentAlias"))) + ctxt.VarMap().Set("selfLink", fmt.Sprintf("%s/activity", ctxt.GetScratch("ConferenceLink"))) if ctxt.HasParameter("r") { // generate a report @@ -504,7 +501,7 @@ func ConfReports(ctxt ui.AmContext) (string, any) { return "error", err } ctxt.VarMap().Set("topics", topicList) - ctxt.VarMap().Set("backLink", fmt.Sprintf("/comm/%s/conf/%s/manage", comm.Alias, ctxt.GetScratch("currentAlias"))) + ctxt.VarMap().Set("backLink", fmt.Sprintf("%s/manage", ctxt.GetScratch("ConferenceLink"))) ctxt.SetFrameTitle(fmt.Sprintf("Conference Reports: %s", conf.Name)) return "framed", "conf_reports.jet" } @@ -518,7 +515,6 @@ func ConfReports(ctxt ui.AmContext) (string, any) { * Data as a parameter for the command string. */ func ConferenceEmailForm(ctxt ui.AmContext) (string, any) { - comm := ctxt.CurrentCommunity() conf := ctxt.GetScratch("currentConference").(*database.Conference) myLevel := ctxt.GetScratch("levelInConference").(uint16) if !conf.TestPermission("Conference.EMailParticipants", myLevel) { @@ -531,7 +527,7 @@ func ConferenceEmailForm(ctxt ui.AmContext) (string, any) { } ctxt.VarMap().Set("topics", topics) ctxt.VarMap().Set("confName", conf.Name) - ctxt.VarMap().Set("selfLink", fmt.Sprintf("/comm/%s/conf/%s/email", comm.Alias, ctxt.GetScratch("currentAlias"))) + ctxt.VarMap().Set("selfLink", fmt.Sprintf("%s/email", ctxt.GetScratch("ConferenceLink"))) ctxt.VarMap().Set("porl", 0).Set("top", 0).Set("xday", false) ctxt.VarMap().Set("day", 7).Set("subj", "").Set("pb", "") ctxt.SetFrameTitle(fmt.Sprintf("Conference E-Mail: %s", conf.Name)) @@ -555,7 +551,7 @@ func ConferenceEmail(ctxt ui.AmContext) (string, any) { // Handle button presses. if ctxt.FormFieldIsSet("cancel") { - return "redirect", fmt.Sprintf("/comm/%s/conf/%s/manage", comm.Alias, ctxt.GetScratch("currentAlias")) + return "redirect", fmt.Sprintf("%s/manage", ctxt.GetScratch("ConferenceLink")) } else if !ctxt.FormFieldIsSet("send") { return "error", EBUTTON } @@ -646,7 +642,7 @@ func ConferenceEmail(ctxt ui.AmContext) (string, any) { log.Infof("ConferenceEmail delivery completed in %s", elapsed) }) - return "redirect", fmt.Sprintf("/comm/%s/conf/%s/manage", comm.Alias, ctxt.GetScratch("currentAlias")) + return "redirect", fmt.Sprintf("%s/manage", ctxt.GetScratch("ConferenceLink")) } /* ConferenceExportForm displays the form for exporting data from a conference. @@ -657,7 +653,6 @@ func ConferenceEmail(ctxt ui.AmContext) (string, any) { * Data as a parameter for the command string. */ func ConferenceExportForm(ctxt ui.AmContext) (string, any) { - comm := ctxt.CurrentCommunity() conf := ctxt.GetScratch("currentConference").(*database.Conference) myLevel := ctxt.GetScratch("levelInConference").(uint16) if !conf.TestPermission("Conference.Change", myLevel) { @@ -671,7 +666,7 @@ func ConferenceExportForm(ctxt ui.AmContext) (string, any) { ctxt.VarMap().Set("topics", topics) ctxt.VarMap().Set("confName", conf.Name) - ctxt.VarMap().Set("selfLink", fmt.Sprintf("/comm/%s/conf/%s/export", comm.Alias, ctxt.GetScratch("currentAlias"))) + ctxt.VarMap().Set("selfLink", fmt.Sprintf("%s/export", ctxt.GetScratch("ConferenceLink"))) ctxt.SetFrameTitle(fmt.Sprintf("Export Messages: %s", conf.Name)) return "framed", "conf_export.jet" } @@ -684,7 +679,6 @@ func ConferenceExportForm(ctxt ui.AmContext) (string, any) { * Data as a parameter for the command string. */ func ConferenceExport(ctxt ui.AmContext) (string, any) { - comm := ctxt.CurrentCommunity() conf := ctxt.GetScratch("currentConference").(*database.Conference) myLevel := ctxt.GetScratch("levelInConference").(uint16) if !conf.TestPermission("Conference.Change", myLevel) { @@ -692,7 +686,7 @@ func ConferenceExport(ctxt ui.AmContext) (string, any) { } if ctxt.FormFieldIsSet("cancel") { - return "redirect", fmt.Sprintf("/comm/%s/conf/%s/manage", comm.Alias, ctxt.GetScratch("currentAlias")) + return "redirect", fmt.Sprintf("%s/manage", ctxt.GetScratch("ConferenceLink")) } else if !ctxt.FormFieldIsSet("export") { return "error", EBUTTON } @@ -765,15 +759,16 @@ func ConferenceImport(ctxt ui.AmContext) (string, any) { return "error", ENOPERM } + ctxt.VarMap().Set("confName", conf.Name) + ctxt.VarMap().Set("selfLink", fmt.Sprintf("%s/import", ctxt.GetScratch("ConferenceLink"))) + ctxt.SetFrameTitle("Import Messages: " + conf.Name) + if ctxt.Verb() == "GET" { - ctxt.VarMap().Set("confName", conf.Name) - ctxt.VarMap().Set("selfLink", fmt.Sprintf("/comm/%s/conf/%s/import", comm.Alias, ctxt.GetScratch("currentAlias"))) - ctxt.SetFrameTitle("Import Messages: " + conf.Name) return "framed", "conf_import.jet" } if ctxt.FormFieldIsSet("cancel") { - return "redirect", fmt.Sprintf("/comm/%s/conf/%s/manage", comm.Alias, ctxt.GetScratch("currentAlias")) + return "redirect", fmt.Sprintf("%s/manage", ctxt.GetScratch("ConferenceLink")) } else if !ctxt.FormFieldIsSet("import") { return "error", EBUTTON } @@ -786,27 +781,18 @@ func ConferenceImport(ctxt ui.AmContext) (string, any) { mode = exports.VCIFTopicMatchNum default: ctxt.VarMap().Set("errorMessage", "Invalid matching parameter.") - ctxt.VarMap().Set("confName", conf.Name) - ctxt.VarMap().Set("selfLink", fmt.Sprintf("/comm/%s/conf/%s/import", comm.Alias, ctxt.GetScratch("currentAlias"))) - ctxt.SetFrameTitle("Import Messages: " + conf.Name) return "framed", "conf_import.jet" } importData, err := ctxt.FormFile("idata") if err != nil { ctxt.VarMap().Set("errorMessage", err.Error()) - ctxt.VarMap().Set("confName", conf.Name) - ctxt.VarMap().Set("selfLink", fmt.Sprintf("/comm/%s/conf/%s/import", comm.Alias, ctxt.GetScratch("currentAlias"))) - ctxt.SetFrameTitle("Import Messages: " + conf.Name) return "framed", "conf_import.jet" } start := time.Now() f, err := importData.Open() if err != nil { ctxt.VarMap().Set("errorMessage", err.Error()) - ctxt.VarMap().Set("confName", conf.Name) - ctxt.VarMap().Set("selfLink", fmt.Sprintf("/comm/%s/conf/%s/import", comm.Alias, ctxt.GetScratch("currentAlias"))) - ctxt.SetFrameTitle("Import Messages: " + conf.Name) return "framed", "conf_import.jet" } topics, posts, scroll, err := exports.VCIFImportMessages(ctxt.Ctx(), f, comm, conf, mode, ctxt.FormFieldIsSet("create"), ctxt.CurrentUser(), ctxt.RemoteIP()) @@ -814,13 +800,10 @@ func ConferenceImport(ctxt ui.AmContext) (string, any) { log.Infof("import messages operation completed in %v", time.Since(start)) if err != nil { ctxt.VarMap().Set("errorMessage", err.Error()) - ctxt.VarMap().Set("confName", conf.Name) - ctxt.VarMap().Set("selfLink", fmt.Sprintf("/comm/%s/conf/%s/import", comm.Alias, ctxt.GetScratch("currentAlias"))) - ctxt.SetFrameTitle("Import Messages: " + conf.Name) return "framed", "conf_import.jet" } - ctxt.VarMap().Set("backLink", fmt.Sprintf("/comm/%s/conf/%s/manage", comm.Alias, ctxt.GetScratch("currentAlias"))) + ctxt.VarMap().Set("backLink", fmt.Sprintf("%s/manage", ctxt.GetScratch("ConferenceLink"))) ctxt.VarMap().Set("headline", fmt.Sprintf("Processed %d topic(s) and added %d new post(s).", topics, posts)) ctxt.VarMap().Set("scroll", scroll) ctxt.SetFrameTitle("Import Results") @@ -858,8 +841,8 @@ func DeleteConference(ctxt ui.AmContext) (string, any) { // Set up to display the message box. mbox.SetMessage(fmt.Sprintf(`You are about to delete the conference "%s" from the "%s" community!`, conf.Name, comm.Name)) - mbox.SetLink("no", fmt.Sprintf("/comm/%s/conf/%s/manage", ctxt.CurrentCommunity().Alias, ctxt.GetScratch("currentAlias"))) - mbox.SetLink("yes", fmt.Sprintf("/comm/%s/conf/%s/delete", ctxt.CurrentCommunity().Alias, ctxt.GetScratch("currentAlias"))) + mbox.SetLink("no", fmt.Sprintf("%s/manage", ctxt.GetScratch("ConferenceLink"))) + mbox.SetLink("yes", fmt.Sprintf("%s/delete", ctxt.GetScratch("ConferenceLink"))) return mbox.Render(ctxt) } @@ -901,9 +884,12 @@ func CreateConference(ctxt ui.AmContext) (string, any) { if err != nil { return "error", err } + var urlbuf strings.Builder + urlbuf.WriteString(ctxt.GetScratch("CommunityLink").(string)) + urlbuf.WriteString("/conf") button := dlg.WhichButton(ctxt) if button == "cancel" { - return "redirect", fmt.Sprintf("/comm/%s/conf", comm.Alias) + return "redirect", urlbuf.String() } else if button != "create" { dlg.SetCommunity(comm) return dlg.RenderError(ctxt, "invalid button pressed") @@ -917,7 +903,9 @@ func CreateConference(ctxt ui.AmContext) (string, any) { return dlg.RenderError(ctxt, err.Error()) } log.Infof("Created conference '%s'", conf.Name) - return "redirect", fmt.Sprintf("/comm/%s/conf/%s", comm.Alias, alias) + urlbuf.WriteString("/") + urlbuf.WriteString(alias) + return "redirect", urlbuf.String() } /* ManageConferenceList displays the list for managing conferences. diff --git a/find.go b/find.go index ceaf3d7..cf469fb 100644 --- a/find.go +++ b/find.go @@ -345,12 +345,11 @@ func FindPostsPageCommunity(ctxt ui.AmContext) (string, any) { * Data as a parameter for the command string. */ func FindPostsPageConference(ctxt ui.AmContext) (string, any) { - comm := ctxt.CurrentCommunity() conf := ctxt.GetScratch("currentConference").(*database.Conference) ctxt.VarMap().Set("scope", "conference") ctxt.VarMap().Set("entityName", conf.Name) - ctxt.VarMap().Set("backlink", fmt.Sprintf("/comm/%s/conf/%s", comm.Alias, ctxt.GetScratch("currentAlias"))) - ctxt.VarMap().Set("postlink", fmt.Sprintf("/comm/%s/conf/%s/find", comm.Alias, ctxt.GetScratch("currentAlias"))) + ctxt.VarMap().Set("backlink", ctxt.GetScratch("ConferenceLink").(string)) + ctxt.VarMap().Set("postlink", fmt.Sprintf("%s/find", ctxt.GetScratch("ConferenceLink"))) return commonFindGetBackend(ctxt) } @@ -362,12 +361,11 @@ func FindPostsPageConference(ctxt ui.AmContext) (string, any) { * Data as a parameter for the command string. */ func FindPostsPageTopic(ctxt ui.AmContext) (string, any) { - comm := ctxt.CurrentCommunity() topic := ctxt.GetScratch("currentTopic").(*database.Topic) ctxt.VarMap().Set("scope", "topic") ctxt.VarMap().Set("entityName", topic.Name) - ctxt.VarMap().Set("backlink", fmt.Sprintf("/comm/%s/conf/%s/r/%d", comm.Alias, ctxt.GetScratch("currentAlias"), topic.Number)) - ctxt.VarMap().Set("postlink", fmt.Sprintf("/comm/%s/conf/%s/op/%d/find", comm.Alias, ctxt.GetScratch("currentAlias"), topic.Number)) + ctxt.VarMap().Set("backlink", fmt.Sprintf("%s/r/%d", ctxt.GetScratch("ConferenceLink"), topic.Number)) + ctxt.VarMap().Set("postlink", fmt.Sprintf("%s/op/%d/find", ctxt.GetScratch("ConferenceLink"), topic.Number)) return commonFindGetBackend(ctxt) } @@ -438,8 +436,8 @@ func FindPostsConference(ctxt ui.AmContext) (string, any) { conf := ctxt.GetScratch("currentConference").(*database.Conference) ctxt.VarMap().Set("scope", "conference") ctxt.VarMap().Set("entityName", conf.Name) - ctxt.VarMap().Set("backlink", fmt.Sprintf("/comm/%s/conf/%s", comm.Alias, ctxt.GetScratch("currentAlias"))) - ctxt.VarMap().Set("postlink", fmt.Sprintf("/comm/%s/conf/%s/find", comm.Alias, ctxt.GetScratch("currentAlias"))) + ctxt.VarMap().Set("backlink", ctxt.GetScratch("ConferenceLink").(string)) + ctxt.VarMap().Set("postlink", fmt.Sprintf("%s/find", ctxt.GetScratch("ConferenceLink"))) return commonFindPostBackend(ctxt, comm, conf, nil) } @@ -456,7 +454,7 @@ func FindPostsTopic(ctxt ui.AmContext) (string, any) { topic := ctxt.GetScratch("currentTopic").(*database.Topic) ctxt.VarMap().Set("scope", "topic") ctxt.VarMap().Set("entityName", topic.Name) - ctxt.VarMap().Set("backlink", fmt.Sprintf("/comm/%s/conf/%s/r/%d", comm.Alias, ctxt.GetScratch("currentAlias"), topic.Number)) - ctxt.VarMap().Set("postlink", fmt.Sprintf("/comm/%s/conf/%s/op/%d/find", comm.Alias, ctxt.GetScratch("currentAlias"), topic.Number)) + ctxt.VarMap().Set("backlink", fmt.Sprintf("%s/r/%d", ctxt.GetScratch("ConferenceLink"), topic.Number)) + ctxt.VarMap().Set("postlink", fmt.Sprintf("%s/op/%d/find", ctxt.GetScratch("ConferenceLink"), topic.Number)) return commonFindPostBackend(ctxt, comm, conf, topic) } diff --git a/invites.go b/invites.go index a540468..c229734 100644 --- a/invites.go +++ b/invites.go @@ -59,7 +59,7 @@ func InviteToConference(ctxt ui.AmContext) (string, any) { ctxt.SetFrameTitle("Send Invitation") ctxt.VarMap().Set("title", "Send Conference Invitation") ctxt.VarMap().Set("subtitle", conf.Name) - ctxt.VarMap().Set("backlink", fmt.Sprintf("/comm/%s/conf/%s/manage", comm.Alias, ctxt.GetScratch("currentAlias"))) + ctxt.VarMap().Set("backlink", fmt.Sprintf("%s/manage", ctxt.GetScratch("ConferenceLink"))) ctxt.VarMap().Set("cid", fmt.Sprintf("%d", comm.Id)) ctxt.VarMap().Set("confid", fmt.Sprintf("%d", conf.ConfId)) return "framed", "invite.jet" @@ -83,7 +83,7 @@ func InviteToTopic(ctxt ui.AmContext) (string, any) { ctxt.SetFrameTitle("Send Invitation") ctxt.VarMap().Set("title", "Send Topic Invitation") ctxt.VarMap().Set("subtitle", topic.Name) - ctxt.VarMap().Set("backlink", fmt.Sprintf("/comm/%s/conf/%s/op/%d/manage", comm.Alias, ctxt.GetScratch("currentAlias"), topic.Number)) + ctxt.VarMap().Set("backlink", fmt.Sprintf("%s/op/%d/manage", ctxt.GetScratch("ConferenceLink"), topic.Number)) ctxt.VarMap().Set("cid", fmt.Sprintf("%d", comm.Id)) ctxt.VarMap().Set("confid", fmt.Sprintf("%d", conf.ConfId)) ctxt.VarMap().Set("topicid", fmt.Sprintf("%d", topic.TopicId))