implemented "front end" of invites for community/conference/topic, including common view template

This commit is contained in:
2026-01-29 23:14:24 -07:00
parent 84d734578b
commit a0064b37a5
6 changed files with 162 additions and 3 deletions
+93
View File
@@ -0,0 +1,93 @@
/*
* 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/.
*/
// Package main contains the high-level Amsterdam logic.
package main
import (
"fmt"
"net/http"
"git.erbosoft.com/amy/amsterdam/database"
"git.erbosoft.com/amy/amsterdam/ui"
)
/* InviteToCommunity displays the community invitation form.
* 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 InviteToCommunity(ctxt ui.AmContext) (string, any, error) {
if ctxt.CurrentUser().IsAnon {
ctxt.SetRC(http.StatusForbidden)
return ui.ErrorPage(ctxt, ENOPERM)
}
comm := ctxt.CurrentCommunity()
ctxt.VarMap().Set("amsterdam_pageTitle", "Send Invitation")
ctxt.VarMap().Set("title", "Send Community Invitation")
ctxt.VarMap().Set("subtitle", comm.Name)
ctxt.VarMap().Set("backlink", fmt.Sprintf("/comm/%s/profile", comm.Alias))
ctxt.VarMap().Set("cid", fmt.Sprintf("%d", comm.Id))
return "framed_template", "invite.jet", nil
}
/* InviteToConference displays the conference invitation form.
* 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 InviteToConference(ctxt ui.AmContext) (string, any, error) {
if ctxt.CurrentUser().IsAnon {
ctxt.SetRC(http.StatusForbidden)
return ui.ErrorPage(ctxt, ENOPERM)
}
comm := ctxt.CurrentCommunity()
conf := ctxt.GetScratch("currentConference").(*database.Conference)
ctxt.VarMap().Set("amsterdam_pageTitle", "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", comm.Alias, ctxt.GetScratch("currentAlias")))
ctxt.VarMap().Set("cid", fmt.Sprintf("%d", comm.Id))
ctxt.VarMap().Set("confid", fmt.Sprintf("%d", conf.ConfId))
return "framed_template", "invite.jet", nil
}
/* InviteToTopic displays the topic invitation form.
* 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 InviteToTopic(ctxt ui.AmContext) (string, any, error) {
if ctxt.CurrentUser().IsAnon {
ctxt.SetRC(http.StatusForbidden)
return ui.ErrorPage(ctxt, ENOPERM)
}
comm := ctxt.CurrentCommunity()
conf := ctxt.GetScratch("currentConference").(*database.Conference)
topic := ctxt.GetScratch("currentTopic").(*database.Topic)
ctxt.VarMap().Set("amsterdam_pageTitle", "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/r/%d", comm.Alias, ctxt.GetScratch("currentAlias"), 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))
return "framed_template", "invite.jet", nil
}
+3
View File
@@ -89,6 +89,7 @@ func setupEcho() *echo.Echo {
commGroup.POST("/unjoin", ui.AmWrap(UnjoinCommunityConfirm))
commGroup.GET("/members", ui.AmWrap(MemberList))
commGroup.POST("/members", ui.AmWrap(MemberSearch))
commGroup.GET("/invite", ui.AmWrap(InviteToCommunity))
commGroup.GET("/admin", ui.AmWrap(CommunityAdminMenu))
commGroup.GET("/admin/profile", ui.AmWrap(CommunityProfileForm))
commGroup.POST("/admin/profile", ui.AmWrap(EditCommunityProfile))
@@ -103,6 +104,7 @@ func setupEcho() *echo.Echo {
confGroup.POST("/new_topic", ui.AmWrap(NewTopic))
confGroup.GET("/manage", ui.AmWrap(ConfManage))
confGroup.GET("/hotlist", ui.AmWrap(AddToHotlist))
confGroup.GET("/invite", ui.AmWrap(InviteToConference))
confGroup.GET("/r/:topic", ui.AmWrap(ReadPosts), ui.SetTopic)
confGroup.POST("/r/:topic", ui.AmWrap(PostInTopic), ui.SetTopic)
opsGroup := confGroup.Group("/op/:topic", ui.SetTopic)
@@ -117,6 +119,7 @@ func setupEcho() *echo.Echo {
opsGroup.POST("/move/:msg", ui.AmWrap(MoveMessage))
opsGroup.GET("/manage", ui.AmWrap(TopicManage))
opsGroup.GET("/subscribe", ui.AmWrap(TopicSetSubscribe))
opsGroup.GET("/invite", ui.AmWrap(InviteToTopic))
opsGroup.GET("/rmbozo/:uid", ui.AmWrap(TopicRemoveBozo))
return e
+1 -1
View File
@@ -41,7 +41,7 @@
{{ end }}
{{ if isset(canInvite) }}
<div class="text-center">
<a href="/TODO/comm/{{ commAlias }}/invite"
<a href="/comm/{{ commAlias }}/invite"
class="inline-block bg-blue-600 hover:bg-blue-700 text-white px-4 py-1 rounded text-xs font-medium transition-colors">
Invite
</a>
+63
View File
@@ -0,0 +1,63 @@
{*
* 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">{{ title }}:</h1>
<span class="text-blue-800 text-xl font-bold ml-2">{{ subtitle | raw }}</span>
<hr class="border-2 border-gray-400 w-4/5 mt-2 mb-2">
</div>
<!-- Invitation Form -->
<div class="max-w-3xl">
<form method="POST" action="TODO">
<input type="hidden" name="backlink" value="{{ backlink }}"/>
{{ if isset(cid) }}
<input type="hidden" name="cid" value="{{ cid }}"/>
{{ end }}
{{ if isset(confid) }}
<input type="hidden" name="confid" value="{{ confid }}"/>
{{ end }}
{{ if isset(topicid) }}
<input type="hidden" name="topicid" value="{{ topicid }}"/>
{{ end }}
<div class="bg-gray-50 p-6 rounded-lg space-y-4">
<div>
<label for="addr" class="block text-black text-sm font-medium mb-2">Send to:</label>
<div class="flex items-center gap-4">
<input type="text" id="addr" name="addr" size="37" maxlength="255" value="" placeholder="Enter an E-mail address..."
class="flex-1 px-3 py-2 border border-gray-300 rounded font-mono focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
</div>
</div>
<!-- Message -->
<div>
<div class="flex justify-between items-center mb-2">
<label for="msg" class="text-black text-sm font-medium">Personal message to be added to invitation:</label>
</div>
<textarea id="msg" name="msg" wrap="soft" rows="7" cols="51"
placeholder="Enter your message here..."
class="w-full px-3 py-2 border border-gray-300 rounded font-mono text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"></textarea>
</div>
<!-- Action Buttons -->
<div class="flex justify-center gap-4 pt-4">
<button type="submit" name="send"
class="bg-green-600 hover:bg-green-700 text-white px-6 py-2 rounded font-medium transition-colors">
Send E-Mail
</button>
<button type="submit" name="cancel"
class="bg-red-600 hover:bg-red-700 text-white px-6 py-2 rounded font-medium transition-colors">
Cancel
</button>
</div>
</div>
</form>
</div>
</div>
+1 -1
View File
@@ -47,7 +47,7 @@
You may send an invitation via E-mail to outside individuals to join this community and read this conference.
</div>
<div class="mb-4">
<a class="text-blue-700 hover:text-blue-900 text-sm font-bold" href="/TODO/{{ urlStem }}/invite">Click here to send an invitation</a>
<a class="text-blue-700 hover:text-blue-900 text-sm font-bold" href="{{ urlStem }}/invite">Click here to send an invitation</a>
</div>
{{ end }}
+1 -1
View File
@@ -50,7 +50,7 @@
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>
<a class="text-blue-700 hover:text-blue-900 text-sm font-bold" href="{{ opsLink }}/invite">Click here to send an invitation</a>
</div>
{{ end }}