added user agreement page

This commit is contained in:
2025-09-25 12:37:17 -06:00
parent 201e549630
commit 3a4d6151f6
6 changed files with 63 additions and 3 deletions
+19 -2
View File
@@ -47,8 +47,12 @@ func (*AmCLI) Version() string {
// AmConfig holds the configuration of the application as read from YAML.
type AmConfig struct {
Site struct {
Title string `yaml:"title"`
TopRefresh int `yaml:"topRefresh"`
Title string `yaml:"title"`
TopRefresh int `yaml:"topRefresh"`
UserAgreement struct {
Title string `yaml:"title"`
Text string `yaml:"text"`
} `yaml:"userAgreement"`
} `yaml:"site"`
Database struct {
Driver string `yaml:"driver"`
@@ -90,6 +94,13 @@ func overlayString(loaded string, defaulted string) string {
return loaded
}
func overlayInt(loaded int, defaulted int) int {
if loaded != 0 {
return loaded
}
return defaulted
}
/* overlayConfig takes two configuration structures and overlays them to create the third.
* Parameters:
* dest - Points to the destination copnfiguration structure.
@@ -98,7 +109,13 @@ func overlayString(loaded string, defaulted string) string {
*/
func overlayConfig(dest *AmConfig, loaded *AmConfig, defaults *AmConfig) {
dest.Site.Title = overlayString(loaded.Site.Title, defaults.Site.Title)
dest.Site.TopRefresh = overlayInt(loaded.Site.TopRefresh, defaults.Site.TopRefresh)
dest.Site.UserAgreement.Title = overlayString(loaded.Site.UserAgreement.Title, defaults.Site.UserAgreement.Title)
dest.Site.UserAgreement.Text = overlayString(loaded.Site.UserAgreement.Text, defaults.Site.UserAgreement.Text)
dest.Database.Driver = overlayString(loaded.Database.Driver, defaults.Database.Driver)
dest.Database.Dsn = overlayString(loaded.Database.Dsn, defaults.Database.Dsn)
dest.Rendering.TemplateDir = overlayString(loaded.Rendering.TemplateDir, defaults.Rendering.TemplateDir)
dest.Rendering.CookieKey = overlayString(loaded.Rendering.CookieKey, defaults.Rendering.CookieKey)
}
// SetupConfig loads the command line arguments, loads the config file, and prepares GlobalConfig.
+4
View File
@@ -9,6 +9,10 @@
site:
title: "Amsterdam Web Communities System"
topRefresh: 300
userAgreement:
title: "Amsterdam User Agreement"
text: >
Text of this agreement is TBD.
database:
driver: "mysql"
dsn: "amsdb:x00yes2k@tcp(localhost)/amsterdam?parseTime=true&loc=Local"
+13
View File
@@ -27,3 +27,16 @@ func LoginForm(ctxt ui.AmContext) (string, any, error) {
}
return ui.ErrorPage(ctxt, err)
}
/* NewAccountUserAgreement renders the Amsterdam user agreement for new accounts.
* 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 NewAccountUserAgreement(ctxt ui.AmContext) (string, any, error) {
ctxt.VarMap().Set("amsterdam_pageTitle", "New Account User Agreement")
return "framed_template", "agreement.jet", nil
}
+1
View File
@@ -43,6 +43,7 @@ func setupEcho() *echo.Echo {
e.GET("/", ui.AmWrap(TopPage))
e.GET("/about", ui.AmWrap(AboutPage))
e.GET("/login", ui.AmWrap(LoginForm))
e.GET("/newacct", ui.AmWrap(NewAccountUserAgreement))
return e
}
+25
View File
@@ -0,0 +1,25 @@
{*
* 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/.
*}
<div class="flex">
<div class="flex-1 p-4">
<div class="mb-8">
<h1 class="text-blue-800 text-4xl font-bold mb-2">{{ GlobalConfig.Site.UserAgreement.Title }}</h1>
<hr class="border-2 border-gray-400 w-4/5 mb-4">
<p class="text-black text-sm mb-4">
{{ GlobalConfig.Site.UserAgreement.Text | raw }}
</p>
<div class="flex justify-center gap-4 mt-6">
<button type="button" class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded font-medium transition-colors"
onclick="window.location.assign('/TODO/newacct2')">I Accept</button>
<button type="button" class="bg-red-600 hover:bg-red-700 text-white px-6 py-2 rounded font-medium transition-colors"
onclick="window.location.assign('/')">I Decline</button>
</div>
</div>
</div>
</div>
+1 -1
View File
@@ -61,7 +61,7 @@
<span class="mx-2">-</span>
<a href="/login" class="text-yellow-300 hover:text-yellow-400">Log In</a>
<span class="mx-2">|</span>
<a href="/TODO/newaccount" class="text-yellow-300 hover:text-yellow-400">Create Account</a>
<a href="/newacct" class="text-yellow-300 hover:text-yellow-400">Create Account</a>
{{ else }}
You are logged in as <b>{{ .CurrentUser().Username }}</b>
<span class="mx-2">-</span>