added management of conference custom HTML blocks
This commit is contained in:
@@ -377,6 +377,65 @@ func ConferenceMembers(ctxt ui.AmContext) (string, any) {
|
||||
return "framed", "conf_members.jet"
|
||||
}
|
||||
|
||||
/* ConfCustomForm displays the form for editing the conference's custom HTML blocks.
|
||||
* Parameters:
|
||||
* ctxt - The AmContext for the request.
|
||||
* Returns:
|
||||
* Command string dictating what to be rendered.
|
||||
* Data as a parameter for the command string.
|
||||
*/
|
||||
func ConfCustomForm(ctxt ui.AmContext) (string, any) {
|
||||
comm := ctxt.CurrentCommunity()
|
||||
conf := ctxt.GetScratch("currentConference").(*database.Conference)
|
||||
myLevel := ctxt.GetScratch("levelInConference").(uint16)
|
||||
if !conf.TestPermission("Conference.Change", myLevel) {
|
||||
return "error", ENOPERM
|
||||
}
|
||||
|
||||
topBlock, bottomBlock, err := conf.GetCustomBlocks(ctxt.Ctx())
|
||||
if err != nil {
|
||||
return "error", err
|
||||
}
|
||||
|
||||
ctxt.VarMap().Set("confName", conf.Name)
|
||||
ctxt.VarMap().Set("selfLink", fmt.Sprintf("/comm/%s/conf/%s/custom", comm.Alias, ctxt.GetScratch("currentAlias")))
|
||||
ctxt.VarMap().Set("topText", topBlock)
|
||||
ctxt.VarMap().Set("bottomText", bottomBlock)
|
||||
ctxt.SetFrameTitle(fmt.Sprintf("Customize Conference: %s", conf.Name))
|
||||
return "framed", "conf_custom.jet"
|
||||
}
|
||||
|
||||
/* ConfCustom modifies or removes the conference's custom HTML blocks.
|
||||
* Parameters:
|
||||
* ctxt - The AmContext for the request.
|
||||
* Returns:
|
||||
* Command string dictating what to be rendered.
|
||||
* Data as a parameter for the command string.
|
||||
*/
|
||||
func ConfCustom(ctxt ui.AmContext) (string, any) {
|
||||
comm := ctxt.CurrentCommunity()
|
||||
conf := ctxt.GetScratch("currentConference").(*database.Conference)
|
||||
myLevel := ctxt.GetScratch("levelInConference").(uint16)
|
||||
if !conf.TestPermission("Conference.Change", myLevel) {
|
||||
return "error", ENOPERM
|
||||
}
|
||||
|
||||
var err error
|
||||
if ctxt.FormFieldIsSet("cancel") {
|
||||
err = nil
|
||||
} else if ctxt.FormFieldIsSet("remove") {
|
||||
err = conf.RemoveCustomBlocks(ctxt.Ctx())
|
||||
} else if ctxt.FormFieldIsSet("update") {
|
||||
err = conf.SetCustomBlocks(ctxt.Ctx(), ctxt.FormField("tx"), ctxt.FormField("bx"))
|
||||
} else {
|
||||
return "error", EBUTTON
|
||||
}
|
||||
if err != nil {
|
||||
return "error", err
|
||||
}
|
||||
return "redirect", fmt.Sprintf("/comm/%s/conf/%s/manage", comm.Alias, ctxt.GetScratch("currentAlias"))
|
||||
}
|
||||
|
||||
/* CreateConferenceForm displays the dialog for creating a new conference.
|
||||
* Parameters:
|
||||
* ctxt - The AmContext for the request.
|
||||
|
||||
@@ -624,6 +624,56 @@ func (c *Conference) Fixseen(ctx context.Context, u *User) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetCustomBlocks gets the custom HTML blocks for the conference.
|
||||
func (c *Conference) GetCustomBlocks(ctx context.Context) (string, string, error) {
|
||||
row := amdb.QueryRowContext(ctx, "SELECT htmltop, htmlbottom FROM confcustom WHERE confid = ?", c.ConfId)
|
||||
var topBlock, bottomBlock string
|
||||
err := row.Scan(&topBlock, &bottomBlock)
|
||||
switch err {
|
||||
case nil:
|
||||
return topBlock, bottomBlock, nil
|
||||
case sql.ErrNoRows:
|
||||
err = nil
|
||||
}
|
||||
return "", "", err
|
||||
}
|
||||
|
||||
// SetCustomBlocks sets the custom HTML blocks for this conference.
|
||||
func (c *Conference) SetCustomBlocks(ctx context.Context, topBlock, bottomBlock string) error {
|
||||
success := false
|
||||
tx := amdb.MustBegin()
|
||||
defer func() {
|
||||
if !success {
|
||||
tx.Rollback()
|
||||
}
|
||||
}()
|
||||
row := tx.QueryRowContext(ctx, "SELECT COUNT(*) FROM confcustom WHERE confid = ?", c.ConfId)
|
||||
ct := 0
|
||||
err := row.Scan(&ct)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if ct == 0 {
|
||||
_, err = tx.ExecContext(ctx, "INSERT INTO confcustom (confid, htmltop, htmlbottom) VALUES (?, ?, ?)", c.ConfId, topBlock, bottomBlock)
|
||||
} else {
|
||||
_, err = tx.ExecContext(ctx, "UPDATE confcustom SET htmltop = ?, htmlbottom = ? WHERE confid = ?", topBlock, bottomBlock, c.ConfId)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err = tx.Commit(); err != nil {
|
||||
return err
|
||||
}
|
||||
success = true
|
||||
return nil
|
||||
}
|
||||
|
||||
// RemoveCustomBlocks removes the custom HTML blocks from this conference.
|
||||
func (c *Conference) RemoveCustomBlocks(ctx context.Context) error {
|
||||
_, err := amdb.ExecContext(ctx, "DELETE FROM confcustom WHERE confid = ?", c.ConfId)
|
||||
return err
|
||||
}
|
||||
|
||||
/* AmGetConference returns a conference given its ID.
|
||||
* Parameters:
|
||||
* ctx - Standard Go context value.
|
||||
|
||||
@@ -119,6 +119,8 @@ func setupEcho() *echo.Echo {
|
||||
fn = ui.AmWrap(ConferenceMembers)
|
||||
confGroup.GET("/members", fn)
|
||||
confGroup.POST("/members", fn)
|
||||
confGroup.GET("/custom", ui.AmWrap(ConfCustomForm))
|
||||
confGroup.POST("/custom", ui.AmWrap(ConfCustom))
|
||||
confGroup.GET("/hotlist", ui.AmWrap(AddToHotlist))
|
||||
confGroup.GET("/invite", ui.AmWrap(InviteToConference))
|
||||
confGroup.GET("/r/:topic", ui.AmWrap(ReadPosts), ui.SetTopic)
|
||||
|
||||
+1
-1
@@ -98,7 +98,7 @@ menudefs:
|
||||
- text: "Manage Conference Members"
|
||||
link: "/comm/[CID]/conf/[CONFID]/members"
|
||||
- text: "Customize Conference Appearance"
|
||||
link: "/TODO/comm/[CID]/conf/[CONFID]/custom"
|
||||
link: "/comm/[CID]/conf/[CONFID]/custom"
|
||||
- text: "Conference Activity Reports"
|
||||
link: "/TODO/comm/[CID]/conf/[CONFID]/activity"
|
||||
- text: "Conference E-Mail"
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
{*
|
||||
* 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">
|
||||
<!-- Page Title -->
|
||||
<div class="mb-6">
|
||||
<div class="flex items-baseline gap-3 mb-2">
|
||||
<h1 class="text-blue-800 text-4xl font-bold">Customize Conference:</h1>
|
||||
<h2 class="text-blue-800 text-2xl font-bold">{{ confName }}</h2>
|
||||
</div>
|
||||
<hr class="border-2 border-gray-400 w-4/5 mb-6">
|
||||
</div>
|
||||
|
||||
<!-- Customize Form -->
|
||||
<form method="POST" action="{{ selfLink }}">
|
||||
|
||||
<div class="max-w-5xl space-y-6">
|
||||
<!-- Top HTML Block -->
|
||||
<div class="bg-gray-50 border border-gray-300 rounded-lg p-6">
|
||||
<label class="block text-gray-800 font-semibold mb-3 flex items-center gap-2">
|
||||
<span class="text-xl">📄</span>
|
||||
Custom HTML block to appear at top of Topic List/Posts pages:
|
||||
</label>
|
||||
<textarea name="tx" rows="7"
|
||||
class="w-full border border-gray-300 rounded px-4 py-3 font-mono text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 resize-y"
|
||||
placeholder="Enter custom HTML here...">{{ topText | raw }}</textarea>
|
||||
<p class="mt-2 text-xs text-gray-600">
|
||||
💡 This content will appear at the top of conference pages, before the topic list.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- Bottom HTML Block -->
|
||||
<div class="bg-gray-50 border border-gray-300 rounded-lg p-6">
|
||||
<label class="block text-gray-800 font-semibold mb-3 flex items-center gap-2">
|
||||
<span class="text-xl">📄</span>
|
||||
Custom HTML block to appear at bottom of Topic List/Posts pages:
|
||||
</label>
|
||||
<textarea name="bx" rows="7"
|
||||
class="w-full border border-gray-300 rounded px-4 py-3 font-mono text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 resize-y"
|
||||
placeholder="Enter custom HTML here...">{{ bottomText | raw }}</textarea>
|
||||
<p class="mt-2 text-xs text-gray-600">
|
||||
💡 This content will appear at the bottom of conference pages, after the topic list.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- Action Buttons -->
|
||||
<div class="flex justify-between items-center pt-4 border-t border-gray-300">
|
||||
<div class="flex gap-3">
|
||||
<button type="submit" name="update"
|
||||
class="bg-blue-600 hover:bg-blue-700 text-white font-bold px-6 py-3 rounded-lg transition-colors shadow-md hover:shadow-lg flex items-center gap-2">
|
||||
<span class="text-xl">💾</span>
|
||||
Update
|
||||
</button>
|
||||
<button type="submit" name="cancel"
|
||||
class="bg-gray-600 hover:bg-gray-700 text-white font-bold px-6 py-3 rounded-lg transition-colors shadow-md hover:shadow-lg flex items-center gap-2">
|
||||
<span class="text-xl">✗</span>
|
||||
Cancel
|
||||
</button>
|
||||
</div>
|
||||
<div>
|
||||
<button type="submit" name="remove"
|
||||
class="bg-red-600 hover:bg-red-700 text-white font-bold px-6 py-3 rounded-lg transition-colors shadow-md hover:shadow-lg flex items-center gap-2">
|
||||
<span class="text-xl">🗑️</span>
|
||||
Remove
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Help Info Box -->
|
||||
<div class="bg-blue-50 border-l-4 border-blue-400 p-4 rounded">
|
||||
<div class="flex items-start">
|
||||
<span class="text-2xl mr-3">ℹ️</span>
|
||||
<div class="text-sm text-blue-900">
|
||||
<p class="font-bold mb-1">About Custom HTML Blocks:</p>
|
||||
<p>You can add custom HTML to enhance your conference pages. These blocks will be inserted at the specified locations on all topic list
|
||||
and posts pages within this conference.</p>
|
||||
<p class="mt-2"><strong>Note:</strong> Use the "Remove" button to clear all custom HTML blocks from this conference.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
Reference in New Issue
Block a user