adding smarter error recovery and reformatted the unjoin page
This commit is contained in:
+18
-1
@@ -15,6 +15,7 @@ import (
|
||||
"fmt"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
@@ -59,6 +60,7 @@ type AmContext interface {
|
||||
IsMember() bool
|
||||
IsMemberLocked() bool
|
||||
LeftMenu() string
|
||||
Locator() string
|
||||
OutputType() string
|
||||
Parameter(string) string
|
||||
QueryParamInt(string, int) int
|
||||
@@ -239,11 +241,14 @@ func (c *amContext) FormFile(name string) (*multipart.FileHeader, error) {
|
||||
return c.echoContext.FormFile(name)
|
||||
}
|
||||
|
||||
// emptyMap is the return from FrameMetadata if the specified selector is not present.
|
||||
var emptyMap map[string]string = make(map[string]string)
|
||||
|
||||
// FrameMetadata returns the frame metadata for a specified type.
|
||||
func (c *amContext) FrameMetadata(selector int) map[string]string {
|
||||
rmap, ok := c.frameMeta[selector]
|
||||
if !ok {
|
||||
rmap = make(map[string]string)
|
||||
rmap = emptyMap
|
||||
}
|
||||
return rmap
|
||||
}
|
||||
@@ -296,6 +301,18 @@ func (c *amContext) LeftMenu() string {
|
||||
}
|
||||
}
|
||||
|
||||
// Locator returns the current URL path minus the scheme and host, so it's a site-relative locator.
|
||||
func (c *amContext) Locator() string {
|
||||
tmp := url.URL{
|
||||
Path: c.echoContext.Request().URL.Path,
|
||||
RawPath: c.echoContext.Request().URL.RawPath,
|
||||
RawQuery: c.echoContext.Request().URL.RawQuery,
|
||||
Fragment: c.echoContext.Request().URL.Fragment,
|
||||
RawFragment: c.echoContext.Request().URL.RawFragment,
|
||||
}
|
||||
return tmp.String()
|
||||
}
|
||||
|
||||
// OutputType returns the MIME output type set for the current operation.
|
||||
func (c *amContext) OutputType() string {
|
||||
return c.outputType
|
||||
|
||||
@@ -70,6 +70,9 @@ func AmSendPageData(ctxt echo.Context, amctxt AmContext, command string, data an
|
||||
}
|
||||
amctxt.SetFrameTitle("Internal Server Error")
|
||||
amctxt.VarMap().Set("error", message)
|
||||
if tmp := amctxt.GetSession("lastKnownGood"); tmp != nil {
|
||||
amctxt.VarMap().Set("recovery", tmp)
|
||||
}
|
||||
command = "framed"
|
||||
data = "error.jet"
|
||||
case "ipban":
|
||||
@@ -148,6 +151,9 @@ func AmWrap(myfunc PageFunc) echo.HandlerFunc {
|
||||
|
||||
// Exec the wrapped function.
|
||||
command, arg := myfunc(ctxt)
|
||||
if command != "error" && command != "ipban" {
|
||||
ctxt.SetSession("lastKnownGood", ctxt.Locator())
|
||||
}
|
||||
if err := ctxt.SaveSession(); err != nil {
|
||||
c.Logger().Errorf("Session save error: %v", err)
|
||||
return err
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@
|
||||
<!-- BEGIN DIALOG {{ __dialog.Name }} -->
|
||||
<div class="p-4">
|
||||
<div class="mb-6">
|
||||
<div class=" flex items-baseline gap-2">
|
||||
<div class="flex items-baseline gap-2">
|
||||
<h1 class="text-blue-800 text-4xl font-bold mb-2">{{ __dialog.Title }}</h1>
|
||||
{{ if __dialog.Subtitle != "" }}
|
||||
<span class="text-blue-800 text-2xl font-bold ml-2">{{ __dialog.Subtitle }}</span>
|
||||
|
||||
+13
-5
@@ -25,11 +25,19 @@
|
||||
|
||||
<!-- Action Buttons -->
|
||||
<div class="flex gap-4 justify-center">
|
||||
<a href="/"
|
||||
class="bg-gray-600 hover:bg-gray-700 text-white font-bold px-8 py-3 rounded-lg text-lg transition-colors shadow-lg hover:shadow-xl flex items-center gap-2">
|
||||
<span class="text-xl">↩️</span>
|
||||
Return to Home Page
|
||||
</a>
|
||||
{{ if isset(recovery) }}
|
||||
<a href="{{ recovery }}"
|
||||
class="bg-blue-600 hover:bg-blue-700 text-white font-bold px-8 py-3 rounded-lg text-lg transition-colors shadow-lg hover:shadow-xl flex items-center gap-2">
|
||||
<span class="text-xl">↩️</span>
|
||||
Go Back
|
||||
</a>
|
||||
{{ else }}
|
||||
<a href="/"
|
||||
class="bg-gray-600 hover:bg-gray-700 text-white font-bold px-8 py-3 rounded-lg text-lg transition-colors shadow-lg hover:shadow-xl flex items-center gap-2">
|
||||
<span class="text-xl">↩️</span>
|
||||
Return to Home Page
|
||||
</a>
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+41
-26
@@ -1,6 +1,6 @@
|
||||
{*
|
||||
* Amsterdam Web Communities System
|
||||
* Copyright (c) 2025 Erbosoft Metaverse Design Solutions, All Rights Reserved
|
||||
* 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
|
||||
@@ -8,34 +8,49 @@
|
||||
*}
|
||||
<div class="p-4">
|
||||
<div class="mb-6">
|
||||
<h1 class="text-blue-800 text-4xl font-bold mb-2">Unjoin Community</h1>
|
||||
<span class="text-blue-800 text-2xl font-bold ml-2">{{ comm.Name }}</span>
|
||||
<div class="flex items-baseline gap-2">
|
||||
<h1 class="text-blue-800 text-4xl font-bold mb-2">Unjoin Community:</h1>
|
||||
<span class="text-blue-800 text-2xl font-bold ml-2">{{ comm.Name }}</span>
|
||||
</div>
|
||||
<hr class="border-2 border-gray-400 w-4/5 mb-4">
|
||||
</div>
|
||||
|
||||
<div class="bg-yellow-50 p-6 rounded-lg">
|
||||
<div class="space-y-4">
|
||||
<h2 class="text-lg font-bold text-black mb-4">⚠️ Warning</h2>
|
||||
<p class="text-black">
|
||||
You are about to unjoin the {{ comm.Name }} community.
|
||||
{{ if comm.MembersOnly }}
|
||||
You will lose access to all content of the community, as well as the ability to interact with
|
||||
the community as a whole.
|
||||
{{ else }}
|
||||
You will lose the ability to interact with the community's members and content.
|
||||
{{ end }}
|
||||
</p>
|
||||
<p class="text-black">Please confirm if you wish to proceed.</p>
|
||||
</div>
|
||||
<div class="flex justify-center gap-4 mt-6">
|
||||
<form method="POST" action="/comm/{{ comm.Alias }}/unjoin">
|
||||
<button type="submit" name="cancel"
|
||||
class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded font-medium transition-colors">Cancel</button>
|
||||
<button type="submit" name="unjoin"
|
||||
class="bg-red-600 hover:bg-red-700 text-white px-6 py-2 rounded font-medium transition-colors">
|
||||
Unjoin {{ comm.Name }}
|
||||
</button>
|
||||
</form>
|
||||
<div class="max-w-2xl w-full">
|
||||
<div class="bg-white border-2 border-red-600 rounded-lg shadow-2xl overflow-hidden">
|
||||
<!-- Dialog Header -->
|
||||
<div class="bg-red-600 px-6 py-4">
|
||||
<h1 class="text-white text-2xl font-bold text-center flex items-center justify-center gap-3">
|
||||
<span class="text-3xl">⚠️</span> Warning <span class="text-3xl">⚠️</span>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<!-- Dialog Body -->
|
||||
<div class="px-8 py-8">
|
||||
<div class="text-center mb-8">
|
||||
<p class="text-gray-800 text-lg leading-relaxed">
|
||||
You are about to unjoin the <span class="text-red-800 font-bold">{{ comm.Name }}</span> community.
|
||||
{{ if comm.MembersOnly }}
|
||||
You will lose access to all content of the community, as well as the ability to interact with
|
||||
the community as a whole.
|
||||
{{ else }}
|
||||
You will lose the ability to interact with the community's members and content.
|
||||
{{ end }}
|
||||
</p>
|
||||
<p class="text-gray-800 text-lg font-bold mt-4">Are you sure you want to do this?</p>
|
||||
</div>
|
||||
|
||||
<!-- Action Buttons -->
|
||||
<div class="flex gap-4 justify-center">
|
||||
<form method="POST" action="/comm/{{ comm.Alias }}/unjoin">
|
||||
<button type="submit" name="cancel"
|
||||
class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded font-medium transition-colors">✗ Cancel</button>
|
||||
<button type="submit" name="unjoin"
|
||||
class="bg-red-600 hover:bg-red-700 text-white px-6 py-2 rounded font-medium transition-colors">
|
||||
↗️ Unjoin {{ comm.Name }}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user