diff --git a/config.go b/config.go index b1991ae..444b23f 100644 --- a/config.go +++ b/config.go @@ -25,6 +25,7 @@ var discordEnabled = false var matrixEnabled = false // URL subpaths. Ignore the "Current" field. +// IMPORTANT: When linking straight to a page, rather than appending further to the URL (like accessing an API route), append a /. var PAGES = PagePaths{} func (app *appContext) GetPath(sect, key string) (fs.FS, string) { @@ -58,9 +59,12 @@ func FixFullURL(v string) string { return v } -func FormatSubpath(path string) string { +func FormatSubpath(path string, removeSingleSlash bool) string { if path == "/" { - return "" + if removeSingleSlash { + return "" + } + return path } return strings.TrimSuffix(path, "/") } @@ -140,10 +144,10 @@ func (app *appContext) loadConfig() error { app.MustSetURLPath("url_paths", "admin", "") app.MustSetURLPath("url_paths", "user_page", "/my/account") app.MustSetURLPath("url_paths", "form", "/invite") - PAGES.Base = FormatSubpath(app.config.Section("ui").Key("url_base").String()) - PAGES.Admin = FormatSubpath(app.config.Section("url_paths").Key("admin").String()) - PAGES.MyAccount = FormatSubpath(app.config.Section("url_paths").Key("user_page").String()) - PAGES.Form = FormatSubpath(app.config.Section("url_paths").Key("form").String()) + PAGES.Base = FormatSubpath(app.config.Section("ui").Key("url_base").String(), true) + PAGES.Admin = FormatSubpath(app.config.Section("url_paths").Key("admin").String(), true) + PAGES.MyAccount = FormatSubpath(app.config.Section("url_paths").Key("user_page").String(), true) + PAGES.Form = FormatSubpath(app.config.Section("url_paths").Key("form").String(), true) if !(app.config.Section("user_page").Key("enabled").MustBool(true)) { PAGES.MyAccount = "disabled" } diff --git a/html/admin.html b/html/admin.html index b2dda34..eb56251 100644 --- a/html/admin.html +++ b/html/admin.html @@ -541,7 +541,7 @@ {{ if .userPageEnabled }}
{{ end }} diff --git a/ts/modules/pages.ts b/ts/modules/pages.ts index cc29c9a..d2a6910 100644 --- a/ts/modules/pages.ts +++ b/ts/modules/pages.ts @@ -24,6 +24,7 @@ export class PageManager { private _overridePushState = () => { const pushState = window.history.pushState; window.history.pushState = function (data: any, __: string, _: string | URL) { + console.debug("Pushing state", arguments); pushState.apply(window.history, arguments); let ev = { state: data as string } as PopStateEvent; window.onpopstate(ev); diff --git a/ts/user.ts b/ts/user.ts index 29d6e1d..8034bd9 100644 --- a/ts/user.ts +++ b/ts/user.ts @@ -24,7 +24,8 @@ interface userWindow extends GlobalWindow { declare var window: userWindow; -const basePath = window.location.pathname.replace("/password/reset", ""); +// const basePath = window.location.pathname.replace("/password/reset", ""); +const basePath = window.pages.MyAccount; const theme = new ThemeManager(document.getElementById("button-theme"));