Small fixes

This commit is contained in:
Pieter Vander Vennet 2021-04-23 17:22:01 +02:00
parent 5c0e3662c1
commit 3e3da25edb
18 changed files with 263 additions and 103 deletions

View file

@ -1,4 +1,3 @@
import {UIElement} from "../UIElement";
import Combine from "../Base/Combine";
import Translations from "../i18n/Translations";
import Attribution from "./Attribution";
@ -8,9 +7,8 @@ import LayoutConfig from "../../Customizations/JSON/LayoutConfig";
import {FixedUiElement} from "../Base/FixedUiElement";
import * as licenses from "../../assets/generated/license_info.json"
import SmallLicense from "../../Models/smallLicense";
import {Icon} from "leaflet";
import Img from "../Base/Img";
import {Utils} from "../../Utils";
import Link from "../Base/Link";
/**
* The attribution panel shown on mobile
@ -48,12 +46,25 @@ export default class AttributionPanel extends Combine {
return undefined;
}
const sources =Utils.NoNull(Utils.NoEmpty(license.sources))
return new Combine([
`<img src='${iconPath}' style="width: 50px; height: 50px; margin-right: 0.5em;">`,
new Combine([
new FixedUiElement(license.authors.join("; ")).SetClass("font-bold"),
new Combine([license.license, license.sources.length > 0 ? " - " : "",
...license.sources.map(link => `<a href='${link}' target="_blank">${new URL(link).hostname}</a> `)]).SetClass("block")
new Combine([license.license,
sources.length > 0 ? " - " : "",
... sources.map(lnk => {
let sourceLinkContent = lnk;
try{
sourceLinkContent = new URL(lnk).hostname
}catch{
console.error("Not a valid URL:", lnk)
}
return new Link(sourceLinkContent, lnk, true);
})
]
).SetClass("block")
]).SetClass("flex flex-col")
]).SetClass("flex")
}

View file

@ -117,6 +117,12 @@ export class SubstitutedTranslation extends UIElement {
}
}
// Let's to a small sanity check to help the theme designers:
if(template.search(/{[^}]+\([^}]*\)}/) >= 0){
// Hmm, we might have found an invalid rendering name
console.warn("Found a suspicious special rendering value in: ", template, " did you mean one of: ", SpecialVisualizations.specialVisualizations.map(sp => sp.funcName+"()").join(", "))
}
// IF we end up here, no changes have to be made - except to remove any resting {}
return [new FixedUiElement(template.replace(/{.*}/g, ""))];
}

View file

@ -20,6 +20,7 @@ export class Translation extends UIElement {
for (const translationsKey in translations) {
count++;
if (typeof (translations[translationsKey]) != "string") {
console.error("Non-string object in translation: ", translations[translationsKey])
throw "Error in an object depicting a translation: a non-string object was found. (" + context + ")\n You probably put some other section accidentally in the translation"
}
}