mirror of
https://github.com/hrfee/jfa-go.git
synced 2026-01-18 16:47:42 +01:00
userpage: use window.pages.MyAccount instead of
window.location.pathname fixes #418 hopefully.
This commit is contained in:
16
config.go
16
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"
|
||||
}
|
||||
|
||||
@@ -541,7 +541,7 @@
|
||||
<span class="button ~critical @low unfocused" id="logout-button">{{ .strings.logout }}</span>
|
||||
{{ if .userPageEnabled }}
|
||||
<div class="">
|
||||
<a class="button ~info" href="{{ .pages.Base }}{{ .pages.MyAccount }}"><i class="ri-account-circle-fill mr-2"></i>{{ .strings.myAccount }}</a>
|
||||
<a class="button ~info" href="{{ .pages.Base }}{{ .pages.MyAccount }}/"><i class="ri-account-circle-fill mr-2"></i>{{ .strings.myAccount }}</a>
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user