added the Manage Topic page and strengthened some link conditions for anonymous user
This commit is contained in:
+20
-14
@@ -98,13 +98,24 @@ func Topics(ctxt ui.AmContext) (string, any, error) {
|
|||||||
return ui.ErrorPage(ctxt, err)
|
return ui.ErrorPage(ctxt, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
hotlistTest, err := database.AmIsInHotlist(ctxt.Ctx(), ctxt.CurrentUser(), comm.Id, conf.ConfId)
|
var hotlistTest bool = false
|
||||||
if err != nil {
|
if !ctxt.CurrentUser().IsAnon {
|
||||||
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
traverser := ui.NewTopicTraverser(topics)
|
// create the "read new" URL
|
||||||
ctxt.SetSession("topic.traverser", traverser)
|
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()
|
tz := prefs.Location()
|
||||||
loc := prefs.Localizer()
|
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))
|
fdate[i] = loc.Strftime("%x %X", t.LastUpdate.In(tz))
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the "read new" URL
|
ctxt.VarMap().Set("isAnon", ctxt.CurrentUser().IsAnon)
|
||||||
urlStem := fmt.Sprintf("/comm/%s/conf/%s", comm.Alias, ctxt.GetScratch("currentAlias"))
|
ctxt.VarMap().Set("canCreate", !ctxt.CurrentUser().IsAnon && conf.TestPermission("Conference.Create", myLevel))
|
||||||
firstTopic := traverser.FirstTopic()
|
ctxt.VarMap().Set("showHotlist", !ctxt.CurrentUser().IsAnon && !hotlistTest)
|
||||||
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("conferenceName", conf.Name)
|
ctxt.VarMap().Set("conferenceName", conf.Name)
|
||||||
ctxt.VarMap().Set("urlBack", fmt.Sprintf("/comm/%s/conf", comm.Alias))
|
ctxt.VarMap().Set("urlBack", fmt.Sprintf("/comm/%s/conf", comm.Alias))
|
||||||
ctxt.VarMap().Set("urlStem", urlStem)
|
ctxt.VarMap().Set("urlStem", urlStem)
|
||||||
@@ -572,6 +577,7 @@ func ReadPosts(ctxt ui.AmContext) (string, any, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Render the output.
|
// Render the output.
|
||||||
|
ctxt.VarMap().Set("isAnon", ctxt.CurrentUser().IsAnon)
|
||||||
ctxt.VarMap().Set("topicName", topic.Name)
|
ctxt.VarMap().Set("topicName", topic.Name)
|
||||||
ctxt.VarMap().Set("lastRead", lastRead)
|
ctxt.VarMap().Set("lastRead", lastRead)
|
||||||
ctxt.VarMap().Set("pageSize", ctxt.Globals().PostsPerPage)
|
ctxt.VarMap().Set("pageSize", ctxt.Globals().PostsPerPage)
|
||||||
|
|||||||
@@ -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
|
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
|
||||||
|
}
|
||||||
|
|||||||
@@ -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.
|
// GetLastRead returns the "last read" message for a user on a topic.
|
||||||
func (t *Topic) GetLastRead(ctx context.Context, u *User) (int32, error) {
|
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)
|
row := amdb.QueryRowContext(ctx, "SELECT last_message FROM topicsettings WHERE topicid = ? AND uid = ?", t.TopicId, u.Uid)
|
||||||
var rc int32 = -1
|
var rc int32 = -1
|
||||||
err := row.Scan(&rc)
|
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.
|
// SetLastRead sets the "last read" message for a user on a topic.
|
||||||
func (t *Topic) SetLastRead(ctx context.Context, u *User, postNum int32) error {
|
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 = ?",
|
rs, err := amdb.ExecContext(ctx, "UPDATE topicsettings SET last_message = ?, last_read = NOW() WHERE topicid = ? AND uid = ?",
|
||||||
postNum, t.TopicId, u.Uid)
|
postNum, t.TopicId, u.Uid)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|||||||
@@ -32,7 +32,10 @@ _(italicized items can be deferred)_
|
|||||||
- HTML reference for post boxes
|
- HTML reference for post boxes
|
||||||
- Posts view:
|
- Posts view:
|
||||||
- Find
|
- Find
|
||||||
- Manage
|
- Manage:
|
||||||
|
- Subscribe to Topic
|
||||||
|
- Send invite
|
||||||
|
- Filtered Users (list/remove)
|
||||||
- Stick/Unstick
|
- Stick/Unstick
|
||||||
- Freeze/Unfreeze
|
- Freeze/Unfreeze
|
||||||
- Archive/Unarchive
|
- Archive/Unarchive
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ func setupEcho() *echo.Echo {
|
|||||||
opsGroup := confGroup.Group("/op/:topic", ui.SetTopic)
|
opsGroup := confGroup.Group("/op/:topic", ui.SetTopic)
|
||||||
opsGroup.GET("/hide", ui.AmWrap(HideTopic))
|
opsGroup.GET("/hide", ui.AmWrap(HideTopic))
|
||||||
opsGroup.GET("/hide/:msg", ui.AmWrap(HideMessage))
|
opsGroup.GET("/hide/:msg", ui.AmWrap(HideMessage))
|
||||||
|
opsGroup.GET("/manage", ui.AmWrap(TopicManage))
|
||||||
|
|
||||||
return e
|
return e
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
@@ -36,8 +36,10 @@
|
|||||||
{{ end }}
|
{{ end }}
|
||||||
<a href="/TODO"
|
<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>
|
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"
|
{{ if !isAnon }}
|
||||||
class="bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded text-sm font-medium transition-colors">Manage</a>
|
<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>
|
||||||
<div class="flex gap-2 flex-wrap">
|
<div class="flex gap-2 flex-wrap">
|
||||||
{{ if canStick }}
|
{{ if canStick }}
|
||||||
|
|||||||
@@ -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">
|
class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded text-sm font-medium transition-colors">
|
||||||
Find
|
Find
|
||||||
</a>
|
</a>
|
||||||
<a href="{{ urlStem }}/manage"
|
{{ if !isAnon }}
|
||||||
class="bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded text-sm font-medium transition-colors">
|
<a href="{{ urlStem }}/manage"
|
||||||
Manage
|
class="bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded text-sm font-medium transition-colors">
|
||||||
</a>
|
Manage
|
||||||
|
</a>
|
||||||
|
{{ end }}
|
||||||
{{ if showHotlist }}
|
{{ if showHotlist }}
|
||||||
<a href="{{ urlStem }}/hotlist"
|
<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">
|
class="bg-orange-600 hover:bg-orange-700 text-black px-4 py-2 rounded text-sm font-medium transition-colors">
|
||||||
|
|||||||
Reference in New Issue
Block a user