added the Manage Topic page and strengthened some link conditions for anonymous user

This commit is contained in:
2026-01-28 15:19:18 -07:00
parent ead2b37f08
commit 928a19d600
8 changed files with 137 additions and 21 deletions
+20 -14
View File
@@ -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)
+30
View File
@@ -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
}
+6
View File
@@ -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 {
+4 -1
View File
@@ -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
+1
View File
@@ -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
}
+66
View File
@@ -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/.
*}
<div class="p-4">
<!-- Top Title -->
<div class="mb-2">
<h1 class="text-blue-800 text-4xl font-bold inline">Manage Topic:</h1>
<span class="text-blue-800 text-xl font-bold ml-2">{{ topicName | raw }}</span>
<hr class="border-2 border-gray-400 w-4/5 mt-2 mb-2">
</div>
<!-- Backlink -->
<div class="mb-4">
<a class="text-blue-700 hover:text-blue-900 text-sm font-medium" href="{{ backlink }}">Return to Topic</a>
</div>
<!-- Subscription -->
<div class="mb-1 font-bold text-sm">Topic Subscription:</div>
<div class="mb-4 font-medium text-sm">
{{ 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 }}
</div>
<div class="mb-4">
<a class="text-blue-700 hover:text-blue-900 text-sm font-bold" href="/TODO/{{ opsLink }}/subscribe">
{{ if subscribed }}
Click Here To Stop Subscribing To This Topic
{{ else }}
Click Here To Start Subscribing To This Topic
{{ end }}
</a>
</div>
{{ if canInvite }}
<!-- Invite header -->
<div class="mb-2">
<h1 class="text-blue-800 text-4xl font-bold inline">Send Invitation</h1>
<hr class="border-2 border-gray-400 w-4/5 mt-2 mb-2">
</div>
<!-- Invite text and link -->
<div class="mb-4 text-black text-sm">
You may send an invitation via E-mail to outside individuals to join this community and read this topic.
</div>
<div class="mb-4">
<a class="text-blue-700 hover:text-blue-900 text-sm font-bold" href="/TODO/{{ opsLink }}/invite">Click here to send an invitation</a>
</div>
{{ end }}
<!-- Filtered Users -->
<div class="mb-2">
<h1 class="text-blue-800 text-4xl font-bold inline">Filtered Users</h1>
<hr class="border-2 border-gray-400 w-4/5 mt-2 mb-6">
</div>
{{ if len(bozos) > 0 }}
{{ end }}
</div>
+4 -2
View File
@@ -36,8 +36,10 @@
{{ end }}
<a href="/TODO"
class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded text-sm font-medium transition-colors">Find</a>
<a href="/TODO"
class="bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded text-sm font-medium transition-colors">Manage</a>
{{ if !isAnon }}
<a href="{{ topicListLink }}/op/{{ topicNum }}/manage"
class="bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded text-sm font-medium transition-colors">Manage</a>
{{ end }}
</div>
<div class="flex gap-2 flex-wrap">
{{ if canStick }}
+6 -4
View File
@@ -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
</a>
<a href="{{ urlStem }}/manage"
class="bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded text-sm font-medium transition-colors">
Manage
</a>
{{ if !isAnon }}
<a href="{{ urlStem }}/manage"
class="bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded text-sm font-medium transition-colors">
Manage
</a>
{{ end }}
{{ if showHotlist }}
<a href="{{ urlStem }}/hotlist"
class="bg-orange-600 hover:bg-orange-700 text-black px-4 py-2 rounded text-sm font-medium transition-colors">