mirror of
https://github.com/hrfee/jfa-go.git
synced 2026-03-18 21:50:33 +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
|
var matrixEnabled = false
|
||||||
|
|
||||||
// URL subpaths. Ignore the "Current" field.
|
// 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{}
|
var PAGES = PagePaths{}
|
||||||
|
|
||||||
func (app *appContext) GetPath(sect, key string) (fs.FS, string) {
|
func (app *appContext) GetPath(sect, key string) (fs.FS, string) {
|
||||||
@@ -58,9 +59,12 @@ func FixFullURL(v string) string {
|
|||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
func FormatSubpath(path string) string {
|
func FormatSubpath(path string, removeSingleSlash bool) string {
|
||||||
if path == "/" {
|
if path == "/" {
|
||||||
return ""
|
if removeSingleSlash {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return path
|
||||||
}
|
}
|
||||||
return strings.TrimSuffix(path, "/")
|
return strings.TrimSuffix(path, "/")
|
||||||
}
|
}
|
||||||
@@ -140,10 +144,10 @@ func (app *appContext) loadConfig() error {
|
|||||||
app.MustSetURLPath("url_paths", "admin", "")
|
app.MustSetURLPath("url_paths", "admin", "")
|
||||||
app.MustSetURLPath("url_paths", "user_page", "/my/account")
|
app.MustSetURLPath("url_paths", "user_page", "/my/account")
|
||||||
app.MustSetURLPath("url_paths", "form", "/invite")
|
app.MustSetURLPath("url_paths", "form", "/invite")
|
||||||
PAGES.Base = FormatSubpath(app.config.Section("ui").Key("url_base").String())
|
PAGES.Base = FormatSubpath(app.config.Section("ui").Key("url_base").String(), true)
|
||||||
PAGES.Admin = FormatSubpath(app.config.Section("url_paths").Key("admin").String())
|
PAGES.Admin = FormatSubpath(app.config.Section("url_paths").Key("admin").String(), true)
|
||||||
PAGES.MyAccount = FormatSubpath(app.config.Section("url_paths").Key("user_page").String())
|
PAGES.MyAccount = FormatSubpath(app.config.Section("url_paths").Key("user_page").String(), true)
|
||||||
PAGES.Form = FormatSubpath(app.config.Section("url_paths").Key("form").String())
|
PAGES.Form = FormatSubpath(app.config.Section("url_paths").Key("form").String(), true)
|
||||||
if !(app.config.Section("user_page").Key("enabled").MustBool(true)) {
|
if !(app.config.Section("user_page").Key("enabled").MustBool(true)) {
|
||||||
PAGES.MyAccount = "disabled"
|
PAGES.MyAccount = "disabled"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -541,7 +541,7 @@
|
|||||||
<span class="button ~critical @low unfocused" id="logout-button">{{ .strings.logout }}</span>
|
<span class="button ~critical @low unfocused" id="logout-button">{{ .strings.logout }}</span>
|
||||||
{{ if .userPageEnabled }}
|
{{ if .userPageEnabled }}
|
||||||
<div class="">
|
<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>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ export class PageManager {
|
|||||||
private _overridePushState = () => {
|
private _overridePushState = () => {
|
||||||
const pushState = window.history.pushState;
|
const pushState = window.history.pushState;
|
||||||
window.history.pushState = function (data: any, __: string, _: string | URL) {
|
window.history.pushState = function (data: any, __: string, _: string | URL) {
|
||||||
|
console.debug("Pushing state", arguments);
|
||||||
pushState.apply(window.history, arguments);
|
pushState.apply(window.history, arguments);
|
||||||
let ev = { state: data as string } as PopStateEvent;
|
let ev = { state: data as string } as PopStateEvent;
|
||||||
window.onpopstate(ev);
|
window.onpopstate(ev);
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ interface userWindow extends GlobalWindow {
|
|||||||
|
|
||||||
declare var window: userWindow;
|
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"));
|
const theme = new ThemeManager(document.getElementById("button-theme"));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user