From 928a19d60012f81ade6ce84b758f00ec0aecae6e Mon Sep 17 00:00:00 2001 From: Amy Gale Ruth Bowersox Date: Wed, 28 Jan 2026 15:19:18 -0700 Subject: [PATCH] added the Manage Topic page and strengthened some link conditions for anonymous user --- conference.go | 34 +++++++++++--------- conference_ops.go | 30 ++++++++++++++++++ database/topic.go | 6 ++++ docs/MISSINGFUNCS.md | 5 ++- main.go | 1 + ui/views/manage_topic.jet | 66 +++++++++++++++++++++++++++++++++++++++ ui/views/posts.jet | 6 ++-- ui/views/topiclist.jet | 10 +++--- 8 files changed, 137 insertions(+), 21 deletions(-) create mode 100644 ui/views/manage_topic.jet diff --git a/conference.go b/conference.go index 817a6b6..c675ab5 100644 --- a/conference.go +++ b/conference.go @@ -98,13 +98,24 @@ func Topics(ctxt ui.AmContext) (string, any, error) { return ui.ErrorPage(ctxt, err) } - hotlistTest, err := database.AmIsInHotlist(ctxt.Ctx(), ctxt.CurrentUser(), comm.Id, conf.ConfId) - if err != nil { - return ui.ErrorPage(ctxt, err) + var hotlistTest bool = false + if !ctxt.CurrentUser().IsAnon { + hotlistTest, err = database.AmIsInHotlist(ctxt.Ctx(), ctxt.CurrentUser(), comm.Id, conf.ConfId) + if err != nil { + return ui.ErrorPage(ctxt, err) + } } - traverser := ui.NewTopicTraverser(topics) - ctxt.SetSession("topic.traverser", traverser) + // create the "read new" URL + urlStem := fmt.Sprintf("/comm/%s/conf/%s", comm.Alias, ctxt.GetScratch("currentAlias")) + if !ctxt.CurrentUser().IsAnon { + traverser := ui.NewTopicTraverser(topics) + ctxt.SetSession("topic.traverser", traverser) + firstTopic := traverser.FirstTopic() + if firstTopic >= 1 { + ctxt.VarMap().Set("urlReadNew", fmt.Sprintf("%s/r/%d", urlStem, firstTopic)) + } + } tz := prefs.Location() loc := prefs.Localizer() @@ -113,15 +124,9 @@ func Topics(ctxt ui.AmContext) (string, any, error) { fdate[i] = loc.Strftime("%x %X", t.LastUpdate.In(tz)) } - // create the "read new" URL - urlStem := fmt.Sprintf("/comm/%s/conf/%s", comm.Alias, ctxt.GetScratch("currentAlias")) - firstTopic := traverser.FirstTopic() - if firstTopic >= 1 { - ctxt.VarMap().Set("urlReadNew", fmt.Sprintf("%s/r/%d", urlStem, firstTopic)) - } - - ctxt.VarMap().Set("canCreate", conf.TestPermission("Conference.Create", myLevel)) - ctxt.VarMap().Set("showHotlist", !hotlistTest) + ctxt.VarMap().Set("isAnon", ctxt.CurrentUser().IsAnon) + ctxt.VarMap().Set("canCreate", !ctxt.CurrentUser().IsAnon && conf.TestPermission("Conference.Create", myLevel)) + ctxt.VarMap().Set("showHotlist", !ctxt.CurrentUser().IsAnon && !hotlistTest) ctxt.VarMap().Set("conferenceName", conf.Name) ctxt.VarMap().Set("urlBack", fmt.Sprintf("/comm/%s/conf", comm.Alias)) ctxt.VarMap().Set("urlStem", urlStem) @@ -572,6 +577,7 @@ func ReadPosts(ctxt ui.AmContext) (string, any, error) { } // Render the output. + ctxt.VarMap().Set("isAnon", ctxt.CurrentUser().IsAnon) ctxt.VarMap().Set("topicName", topic.Name) ctxt.VarMap().Set("lastRead", lastRead) ctxt.VarMap().Set("pageSize", ctxt.Globals().PostsPerPage) diff --git a/conference_ops.go b/conference_ops.go index 7591614..8f8a7fb 100644 --- a/conference_ops.go +++ b/conference_ops.go @@ -238,3 +238,33 @@ func HideMessage(ctxt ui.AmContext) (string, any, error) { } 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), nil } + +/* TopicManage displays the "manage topic" page. + * Parameters: + * ctxt - The AmContext for the request. + * Returns: + * Command string dictating what to be rendered. + * Data as a parameter for the command string. + * Standard Go error status. + */ +func TopicManage(ctxt ui.AmContext) (string, any, error) { + 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("opsLink", opsLink) + ctxt.VarMap().Set("topicName", topic.Name) + + // Get the invitation flag. + member, _, _, err := comm.Membership(ctxt.Ctx(), ctxt.CurrentUser()) + if err != nil { + return ui.ErrorPage(ctxt, err) + } + ctxt.VarMap().Set("canInvite", member) + + ctxt.VarMap().Set("subscribed", false) // TODO + ctxt.VarMap().Set("bozos", make([]string, 0)) // TODO + + ctxt.VarMap().Set("amsterdam_pageTitle", "Manage Topic: "+topic.Name) + return "framed_template", "manage_topic.jet", nil +} diff --git a/database/topic.go b/database/topic.go index 3b4803c..10b8a80 100644 --- a/database/topic.go +++ b/database/topic.go @@ -80,6 +80,9 @@ func (t *Topic) GetPost(ctx context.Context, num int32) (*PostHeader, error) { // GetLastRead returns the "last read" message for a user on a topic. func (t *Topic) GetLastRead(ctx context.Context, u *User) (int32, error) { + if u.IsAnon { + return -1, nil + } row := amdb.QueryRowContext(ctx, "SELECT last_message FROM topicsettings WHERE topicid = ? AND uid = ?", t.TopicId, u.Uid) var rc int32 = -1 err := row.Scan(&rc) @@ -91,6 +94,9 @@ func (t *Topic) GetLastRead(ctx context.Context, u *User) (int32, error) { // SetLastRead sets the "last read" message for a user on a topic. func (t *Topic) SetLastRead(ctx context.Context, u *User, postNum int32) error { + if u.IsAnon { + return nil + } rs, err := amdb.ExecContext(ctx, "UPDATE topicsettings SET last_message = ?, last_read = NOW() WHERE topicid = ? AND uid = ?", postNum, t.TopicId, u.Uid) if err == nil { diff --git a/docs/MISSINGFUNCS.md b/docs/MISSINGFUNCS.md index efc8074..7cd0486 100644 --- a/docs/MISSINGFUNCS.md +++ b/docs/MISSINGFUNCS.md @@ -32,7 +32,10 @@ _(italicized items can be deferred)_ - HTML reference for post boxes - Posts view: - Find - - Manage + - Manage: + - Subscribe to Topic + - Send invite + - Filtered Users (list/remove) - Stick/Unstick - Freeze/Unfreeze - Archive/Unarchive diff --git a/main.go b/main.go index 900d898..2c8af31 100644 --- a/main.go +++ b/main.go @@ -108,6 +108,7 @@ func setupEcho() *echo.Echo { opsGroup := confGroup.Group("/op/:topic", ui.SetTopic) opsGroup.GET("/hide", ui.AmWrap(HideTopic)) opsGroup.GET("/hide/:msg", ui.AmWrap(HideMessage)) + opsGroup.GET("/manage", ui.AmWrap(TopicManage)) return e } diff --git a/ui/views/manage_topic.jet b/ui/views/manage_topic.jet new file mode 100644 index 0000000..96982bb --- /dev/null +++ b/ui/views/manage_topic.jet @@ -0,0 +1,66 @@ +{* + * Amsterdam Web Communities System + * Copyright (c) 2025-2026 Erbosoft Metaverse Design Solutions, All Rights Reserved + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + *} +
+ +
+

Manage Topic:

+ {{ topicName | raw }} +
+
+ + + + + +
Topic Subscription:
+
+ {{ if subscribed }} + You are currently subscribed to this topic, and will receive all new posts to that topic via E-mail. + {{ else }} + You are not currently subscribed to this topic. When you subscribe to a topic, you will receive all new posts to that topic via E-mail. + {{ end }} +
+ + + {{ if canInvite }} + +
+

Send Invitation

+
+
+ + +
+ You may send an invitation via E-mail to outside individuals to join this community and read this topic. +
+ + {{ end }} + + +
+

Filtered Users

+
+
+ + {{ if len(bozos) > 0 }} + {{ end }} + +
diff --git a/ui/views/posts.jet b/ui/views/posts.jet index 4825ae5..c0a980d 100644 --- a/ui/views/posts.jet +++ b/ui/views/posts.jet @@ -36,8 +36,10 @@ {{ end }} Find - Manage + {{ if !isAnon }} + Manage + {{ end }}
{{ if canStick }} diff --git a/ui/views/topiclist.jet b/ui/views/topiclist.jet index 791d688..ba85df9 100644 --- a/ui/views/topiclist.jet +++ b/ui/views/topiclist.jet @@ -36,10 +36,12 @@ class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded text-sm font-medium transition-colors"> Find - - Manage - + {{ if !isAnon }} + + Manage + + {{ end }} {{ if showHotlist }}