landed Find Posts in Community/Conference/Topic

This commit is contained in:
2026-02-01 14:42:32 -07:00
parent 64faf9ec4d
commit 2c55eef7bf
5 changed files with 127 additions and 6 deletions
+4 -4
View File
@@ -20,7 +20,7 @@ _(italicized items can be deferred)_
- System Audit Logs
- Import User Accounts
- Conferences list:
- Find
- ~~Find~~
- Manage (reorder/show/hide/delete)
- Create New
- Community Admin Menu:
@@ -35,8 +35,8 @@ _(italicized items can be deferred)_
- _Policy page_
- Member List: Export
- HTML reference for post boxes
- Posts view:
- Find
- ~~Posts view:~~
- ~~Find~~
- ~~Manage:~~
- ~~Subscribe to Topic~~
- ~~Send invite~~
@@ -56,7 +56,7 @@ _(italicized items can be deferred)_
- ~~Manage on Conference Hotlist sidebox~~
- Sidebox configuration
- Topics view:
- Find
- ~~Find~~
- Manage:
- ~~Set pseud~~
- ~~Fixseen~~
+118
View File
@@ -305,6 +305,7 @@ func Find(ctxt ui.AmContext) (string, any, error) {
return "framed_template", "find.jet", nil
}
// commonFindGetBackend is the common "back end" function for Find Posts in Community/Conference/Topic.
func commonFindGetBackend(ctxt ui.AmContext) (string, any, error) {
ofs := 0
p := ctxt.Parameter("ofs")
@@ -320,6 +321,14 @@ func commonFindGetBackend(ctxt ui.AmContext) (string, any, error) {
return "framed_template", "find_posts.jet", nil
}
/* FindPostsPageCommunity renders the page for finding posts in a community.
* 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 FindPostsPageCommunity(ctxt ui.AmContext) (string, any, error) {
comm := ctxt.CurrentCommunity()
ctxt.VarMap().Set("scope", "community")
@@ -329,6 +338,14 @@ func FindPostsPageCommunity(ctxt ui.AmContext) (string, any, error) {
return commonFindGetBackend(ctxt)
}
/* FindPostsPageConference renders the page for finding posts in a conference.
* 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 FindPostsPageConference(ctxt ui.AmContext) (string, any, error) {
comm := ctxt.CurrentCommunity()
conf := ctxt.GetScratch("currentConference").(*database.Conference)
@@ -339,6 +356,14 @@ func FindPostsPageConference(ctxt ui.AmContext) (string, any, error) {
return commonFindGetBackend(ctxt)
}
/* FindPostsPageTopic renders the page for finding posts in a topic.
* 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 FindPostsPageTopic(ctxt ui.AmContext) (string, any, error) {
comm := ctxt.CurrentCommunity()
topic := ctxt.GetScratch("currentTopic").(*database.Topic)
@@ -348,3 +373,96 @@ func FindPostsPageTopic(ctxt ui.AmContext) (string, any, error) {
ctxt.VarMap().Set("postlink", fmt.Sprintf("/comm/%s/conf/%s/op/%d/find", comm.Alias, ctxt.GetScratch("currentAlias"), topic.Number))
return commonFindGetBackend(ctxt)
}
// commonFindPostBackend is the common "back end" function for Find Posts in Community/Conference/Topic.
func commonFindPostBackend(ctxt ui.AmContext, comm *database.Community, conf *database.Conference, topic *database.Topic) (string, any, error) {
term := ctxt.FormField("term")
ctxt.VarMap().Set("term", term)
ctxt.VarMap().Set("amsterdam_pageTitle", "Find Posts")
ofs, _ := ctxt.FormFieldInt("ofs")
if ctxt.FormFieldIsSet("search") {
ofs = 0
} else if ctxt.FormFieldIsSet("prev") {
ofs -= 1
} else if ctxt.FormFieldIsSet("next") {
ofs += 1
}
ctxt.VarMap().Set("ofs", ofs)
listMax := int(ctxt.Globals().MaxSearchPage)
var numResults int
postlist, total, err := database.AmSearchPosts(ctxt.Ctx(), term, ctxt.CurrentUser(), ofs*listMax, listMax, comm, conf, topic)
if err == nil {
numResults = len(postlist)
ctxt.VarMap().Set("resultList", postlist)
} else {
ctxt.VarMap().Set("errorMessage", err.Error())
return "framed_template", "find_posts.jet", nil
}
if numResults == 0 {
ctxt.VarMap().Set("resultHeader", "Search Results: (None)")
} else {
ctxt.VarMap().Set("resultHeader", fmt.Sprintf("Search Results: Displaying %d-%d of %d",
ofs*listMax+1, ofs*listMax+numResults, total))
if ofs > 0 {
ctxt.VarMap().Set("resultShowPrev", true)
}
if ofs*listMax+numResults < total {
ctxt.VarMap().Set("resultShowNext", true)
}
}
return "framed_template", "find_posts.jet", nil
}
/* FindPostsCommunity finds posts in a community.
* 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 FindPostsCommunity(ctxt ui.AmContext) (string, any, error) {
comm := ctxt.CurrentCommunity()
ctxt.VarMap().Set("scope", "community")
ctxt.VarMap().Set("entityName", comm.Name)
ctxt.VarMap().Set("backlink", fmt.Sprintf("/comm/%s/conf", comm.Alias))
ctxt.VarMap().Set("postlink", fmt.Sprintf("/comm/%s/find", comm.Alias))
return commonFindPostBackend(ctxt, comm, nil, nil)
}
/* FindPostsConference finds posts in a conference.
* 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 FindPostsConference(ctxt ui.AmContext) (string, any, error) {
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")))
return commonFindPostBackend(ctxt, comm, conf, nil)
}
/* FindPostsTopic finds posts in a topic.
* 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 FindPostsTopic(ctxt ui.AmContext) (string, any, error) {
comm := ctxt.CurrentCommunity()
conf := ctxt.GetScratch("currentConference").(*database.Conference)
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))
return commonFindPostBackend(ctxt, comm, conf, topic)
}
+3
View File
@@ -92,6 +92,7 @@ func setupEcho() *echo.Echo {
commGroup.POST("/members", ui.AmWrap(MemberSearch))
commGroup.GET("/invite", ui.AmWrap(InviteToCommunity))
commGroup.GET("/find", ui.AmWrap(FindPostsPageCommunity))
commGroup.POST("/find", ui.AmWrap(FindPostsCommunity))
commGroup.GET("/admin", ui.AmWrap(CommunityAdminMenu))
commGroup.GET("/admin/profile", ui.AmWrap(CommunityProfileForm))
commGroup.POST("/admin/profile", ui.AmWrap(EditCommunityProfile))
@@ -105,6 +106,7 @@ func setupEcho() *echo.Echo {
confGroup.GET("/new_topic", ui.AmWrap(NewTopicForm))
confGroup.POST("/new_topic", ui.AmWrap(NewTopic))
confGroup.GET("/find", ui.AmWrap(FindPostsPageConference))
confGroup.POST("/find", ui.AmWrap(FindPostsConference))
confGroup.GET("/manage", ui.AmWrap(ConfManage))
confGroup.POST("/pseud", ui.AmWrap(SetPseud))
confGroup.GET("/fixseen", ui.AmWrap(ConfFixseen))
@@ -114,6 +116,7 @@ func setupEcho() *echo.Echo {
confGroup.POST("/r/:topic", ui.AmWrap(PostInTopic), ui.SetTopic)
opsGroup := confGroup.Group("/op/:topic", ui.SetTopic)
opsGroup.GET("/find", ui.AmWrap(FindPostsPageTopic))
opsGroup.POST("/find", ui.AmWrap(FindPostsTopic))
opsGroup.GET("/hide", ui.AmWrap(HideTopic))
opsGroup.GET("/freeze", ui.AmWrap(FreezeTopic))
opsGroup.GET("/archive", ui.AmWrap(ArchiveTopic))
+1 -1
View File
@@ -201,7 +201,7 @@
<div class="text-sm text-black font-bold">{{ resultHeader }}</div>
</div>
{{ if isset(resultList) }}
{{ if mode == "PST" }}
{{ if mode == "PST" && len(resultList) > 0 }}
<div class="overflow-x-auto">
<div class="bg-white border border-gray-300 rounded-lg overflow-hidden">
<table class="w-full">
+1 -1
View File
@@ -79,7 +79,7 @@
<div class="flex justify-between items-center mb-4">
<div class="text-sm text-black font-bold">{{ resultHeader }}</div>
</div>
{{ if isset(resultList) }}
{{ if isset(resultList) && len(resultList) > 0 }}
<div class="overflow-x-auto">
<div class="bg-white border border-gray-300 rounded-lg overflow-hidden">
<table class="w-full">