diff --git a/Logic/DetermineLayout.ts b/Logic/DetermineLayout.ts index 4fae151d3..36233b73b 100644 --- a/Logic/DetermineLayout.ts +++ b/Logic/DetermineLayout.ts @@ -126,7 +126,7 @@ export default class DetermineLayout { .AttachTo("centermessage"); } - private static prepCustomTheme(json: any, sourceUrl?: string): LayoutConfig { + private static prepCustomTheme(json: any, sourceUrl?: string, forceId?: string): LayoutConfig { if(json.layers === undefined && json.tagRenderings !== undefined){ const iconTr = json.mapRendering.map(mr => mr.icon).find(icon => icon !== undefined) @@ -161,6 +161,7 @@ export default class DetermineLayout { json = new PrepareTheme(converState).convertStrict(json, "While preparing a dynamic theme") console.log("The layoutconfig is ", json) + json.id = forceId ?? json.id return new LayoutConfig(json, false, { definitionRaw: JSON.stringify(raw, null, " "), @@ -178,9 +179,13 @@ export default class DetermineLayout { let parsed = await Utils.downloadJson(link) try { - parsed.id = link; + let forcedId = parsed.id + const url = new URL(link) + if(!(url.hostname === "localhost" || url.hostname === "127.0.0.1")){ + forcedId = link; + } console.log("Loaded remote link:", link) - return DetermineLayout.prepCustomTheme(parsed, link) + return DetermineLayout.prepCustomTheme(parsed, link, forcedId); } catch (e) { console.error(e) DetermineLayout.ShowErrorOnCustomTheme( diff --git a/Models/ThemeConfig/Conversion/FixImages.ts b/Models/ThemeConfig/Conversion/FixImages.ts index cdda7ff46..f58294cbb 100644 --- a/Models/ThemeConfig/Conversion/FixImages.ts +++ b/Models/ThemeConfig/Conversion/FixImages.ts @@ -205,6 +205,11 @@ export class FixImages extends DesugaringStep { let relative = url.protocol + "//" + url.host + url.pathname relative = relative.substring(0, relative.lastIndexOf("/")) const self = this; + + if(relative.endsWith("assets/generated/themes")){ + warnings.push("Detected 'assets/generated/themes' as relative URL. I'm assuming that you are loading your file for the MC-repository, so I'm rewriting all image links as if they were absolute instead of relative") + relative = absolute + } function replaceString(leaf: string) { if (self._knownImages.has(leaf)) { diff --git a/Models/ThemeConfig/Conversion/LegacyJsonConvert.ts b/Models/ThemeConfig/Conversion/LegacyJsonConvert.ts index 5d9ae5862..dc25f2afc 100644 --- a/Models/ThemeConfig/Conversion/LegacyJsonConvert.ts +++ b/Models/ThemeConfig/Conversion/LegacyJsonConvert.ts @@ -100,7 +100,7 @@ export class UpdateLegacyLayer extends DesugaringStep any), travelledPath: string[] = []) { + public static WalkPath(path: string[], object: any, replaceLeaf: ((leaf: any, travelledPath: string[]) => any), travelledPath: string[] = []) : void { + if(object == null){ + return; + } + const head = path[0] if (path.length === 1) { // We have reached the leaf