From 89da7e84566bbba0753081cbf2c67c52944821f6 Mon Sep 17 00:00:00 2001 From: Amy Gale Ruth Bowersox Date: Sun, 19 Oct 2025 17:12:53 -0600 Subject: [PATCH] first landing of the Find page, including the four tabs and session memory of the selected tab --- find.go | 57 +++++++++++ main.go | 1 + ui/amcontext.go | 19 ++++ ui/views/find.jet | 233 +++++++++++++++++++++++++++++++++++++++++++++ ui/views/frame.jet | 2 +- 5 files changed, 311 insertions(+), 1 deletion(-) create mode 100644 find.go create mode 100644 ui/views/find.jet diff --git a/find.go b/find.go new file mode 100644 index 0000000..1735e26 --- /dev/null +++ b/find.go @@ -0,0 +1,57 @@ +/* + * Amsterdam Web Communities System + * Copyright (c) 2025 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 "git.erbosoft.com/amy/amsterdam/ui" + +/* FindPage renders the Amsterdam "Find" 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 FindPage(ctxt ui.AmContext) (string, any, error) { + mode := "" + p := ctxt.Parameter("mode") + if p != "" { + mode = p + } else if ctxt.IsSession("find.mode") { + x := ctxt.GetSession("find.mode") + if xx, ok := x.(string); ok { + mode = xx + } + } + if mode == "" { + mode = "COM" + } + switch mode { + case "COM": + ctxt.VarMap().Set("field", "name") + ctxt.VarMap().Set("oper", "st") + ctxt.VarMap().Set("term", "") + case "USR": + ctxt.VarMap().Set("field", "name") + ctxt.VarMap().Set("oper", "st") + ctxt.VarMap().Set("term", "") + case "CAT": + ctxt.VarMap().Set("oper", "st") + ctxt.VarMap().Set("term", "") + case "PST": + ctxt.VarMap().Set("term", "") + } + + ctxt.VarMap().Set("mode", mode) + ctxt.VarMap().Set("amsterdam_pageTitle", "Find") + ctxt.SetLeftMenu("top") + ctxt.SetSession("find.mode", mode) + return "framed_template", "find.jet", nil +} diff --git a/main.go b/main.go index b139d17..c3a7c3d 100644 --- a/main.go +++ b/main.go @@ -64,6 +64,7 @@ func setupEcho() *echo.Echo { e.POST("/profile", ui.AmWrap(EditProfile)) e.GET("/profile_photo", ui.AmWrap(ProfilePhotoForm)) e.POST("/profile_photo", ui.AmWrap(ProfilePhoto)) + e.GET("/find", ui.AmWrap(FindPage)) e.GET("/user/:uname", ui.AmWrap(ShowProfile)) e.POST("/quick_email", ui.AmWrap(QuickEMail)) e.GET("/sysadmin", ui.AmWrap(SysAdminMenu)) diff --git a/ui/amcontext.go b/ui/amcontext.go index d22525f..ee2f2ae 100644 --- a/ui/amcontext.go +++ b/ui/amcontext.go @@ -61,6 +61,9 @@ type AmContext interface { SetRC(int) GetScratch(string) any SetScratch(string, any) + GetSession(string) any + SetSession(string, any) + IsSession(string) bool TestPermission(string) bool URLParam(string) string URLParamInt(string) (int, error) @@ -357,6 +360,22 @@ func (c *amContext) SetScratch(name string, val any) { c.scratchpad[name] = val } +// GetSession returns a session variable. +func (c *amContext) GetSession(name string) any { + return c.session.Values["x."+name] +} + +// SetSession sets a session variable. +func (c *amContext) SetSession(name string, value any) { + c.session.Values["x."+name] = value +} + +// IsSession tests to see whether a session value is set. +func (c *amContext) IsSession(name string) bool { + _, ok := c.session.Values["x."+name] + return ok +} + // TestPermission tests the current user against permissions. func (c *amContext) TestPermission(perm string) bool { return database.AmTestPermission(perm, c.effectiveLevel) diff --git a/ui/views/find.jet b/ui/views/find.jet new file mode 100644 index 0000000..d97c958 --- /dev/null +++ b/ui/views/find.jet @@ -0,0 +1,233 @@ +{* + * Amsterdam Web Communities System + * Copyright (c) 2025 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/. + *} +
+ +
+
+

Find:

+ +
+
+
+ + +
+
+ + + +
+ {{ if mode == "COM" }} +

Find Communities:

+ {{ else if mode == "USR" }} +

Find Users:

+ {{ else if mode == "CAT" }} +

Find Categories:

+ {{ else if mode == "PST" }} +

Find Posts:

+ {{ end }} + +
+ {{ if mode == "COM" || mode == "USR" }} + +
+ {{ if mode == "COM" }} + Display all communities whose + {{ else if mode == "USR" }} + Display all users whose + {{ end }} + +
+ + +
+ + +
+ {{ else if mode == "CAT" }} + + +
+ Display all categories whose name + +
+ +
+ +
+ {{ else if mode == "PST" }} + + + +
+ Keywords: + +
+ {{ end }} + + +
+ +
+
+
+
+
+ + + {{ if mode == "COM" }} +
+
+ +

Category: Top

+ +
+

Subcategories:

+ +
+
+ 🟣 + Arts +
+
+ 🟣 + Business +
+
+ 🟣 + Computers +
+
+ 🟣 + Games +
+
+ 🟣 + Health +
+
+ 🟣 + Home +
+
+ 🟣 + News +
+
+ 🟣 + Recreation +
+
+ 🟣 + Reference and Education +
+
+ 🟣 + Regional +
+
+ 🟣 + Science +
+
+ 🟣 + Shopping +
+
+ 🟣 + Society +
+
+ 🟣 + Sports +
+
+ 🟣 + System +
+
+ 🟣 + Unclassified +
+
+
+
+ {{ end }} +
diff --git a/ui/views/frame.jet b/ui/views/frame.jet index b042adb..34a32e6 100644 --- a/ui/views/frame.jet +++ b/ui/views/frame.jet @@ -41,7 +41,7 @@
Help | - Find + Find