Fix rendering of multianswers without explicit 'render'-field

This commit is contained in:
Pieter Vander Vennet 2021-01-06 01:11:07 +01:00
parent 52d9b2f452
commit a35b80afbb
11 changed files with 195 additions and 97 deletions

View file

@ -40,15 +40,22 @@ export default class MoreScreen extends UIElement {
}
const currentLocation = State.state.locationControl.data;
let path = window.location.pathname;
// Path starts with a '/' and contains everything, e.g. '/dir/dir/page.html'
path = path.substr(0, path.lastIndexOf("/"));
// Path will now contain '/dir/dir', or empty string in case of nothing
if(path === ""){
path = "."
}
let linkText =
`./${layout.id.toLowerCase()}.html?z=${currentLocation.zoom}&lat=${currentLocation.lat}&lon=${currentLocation.lon}`
`${path}/${layout.id.toLowerCase()}?z=${currentLocation.zoom}&lat=${currentLocation.lat}&lon=${currentLocation.lon}`
if (location.hostname === "localhost" || location.hostname === "127.0.0.1") {
linkText = `./index.html?layout=${layout.id}&z=${currentLocation.zoom}&lat=${currentLocation.lat}&lon=${currentLocation.lon}`
linkText = `${path}/index.html?layout=${layout.id}&z=${currentLocation.zoom}&lat=${currentLocation.lat}&lon=${currentLocation.lon}`
}
if (customThemeDefinition) {
linkText = `./index.html?userlayout=${layout.id}&z=${currentLocation.zoom}&lat=${currentLocation.lat}&lon=${currentLocation.lon}#${customThemeDefinition}`
linkText = `${path}/?userlayout=${layout.id}&z=${currentLocation.zoom}&lat=${currentLocation.lat}&lon=${currentLocation.lon}#${customThemeDefinition}`
}

View file

@ -147,13 +147,15 @@ export default class ShareScreen extends UIElement {
const url = (currentLocation ?? new UIEventSource(undefined)).map(() => {
const host = window.location.host;
let literalText = `https://${host}/${layout.id.toLowerCase()}.html`
let path = window.location.pathname;
path = path.substr(0, path.lastIndexOf("/"));
let literalText = `https://${host}${path}/${layout.id.toLowerCase()}`
const parts = Utils.NoEmpty(Utils.NoNull(optionParts.map((eventSource) => eventSource.data)));
let hash = "";
if (layoutDefinition !== undefined) {
literalText = `https://${host}/index.html`
literalText = `https://${host}${path}/`
if (layout.id.startsWith("wiki:")) {
parts.push("userlayout=" + encodeURIComponent(layout.id))
} else {