Be less strict on images of unofficial themes
This commit is contained in:
parent
6b1ec7d754
commit
f339fff04d
2 changed files with 8 additions and 5 deletions
|
@ -5,15 +5,18 @@ import * as metapaths from "../../../assets/layoutconfigmeta.json";
|
||||||
import * as tagrenderingmetapaths from "../../../assets/tagrenderingconfigmeta.json";
|
import * as tagrenderingmetapaths from "../../../assets/tagrenderingconfigmeta.json";
|
||||||
|
|
||||||
export class ExtractImages extends Conversion<LayoutConfigJson, string[]> {
|
export class ExtractImages extends Conversion<LayoutConfigJson, string[]> {
|
||||||
constructor() {
|
private _isOfficial: boolean;
|
||||||
|
constructor(isOfficial: boolean) {
|
||||||
super("Extract all images from a layoutConfig using the meta paths",[],"ExctractImages");
|
super("Extract all images from a layoutConfig using the meta paths",[],"ExctractImages");
|
||||||
|
this._isOfficial = isOfficial;
|
||||||
}
|
}
|
||||||
|
|
||||||
convert(json: LayoutConfigJson, context: string): { result: string[], errors: string[] } {
|
convert(json: LayoutConfigJson, context: string): { result: string[], errors: string[], warnings: string[] } {
|
||||||
const paths = metapaths["default"] ?? metapaths
|
const paths = metapaths["default"] ?? metapaths
|
||||||
const trpaths = tagrenderingmetapaths["default"] ?? tagrenderingmetapaths
|
const trpaths = tagrenderingmetapaths["default"] ?? tagrenderingmetapaths
|
||||||
const allFoundImages = []
|
const allFoundImages = []
|
||||||
const errors = []
|
const errors = []
|
||||||
|
const warnings = []
|
||||||
for (const metapath of paths) {
|
for (const metapath of paths) {
|
||||||
if (metapath.typeHint === undefined) {
|
if (metapath.typeHint === undefined) {
|
||||||
continue
|
continue
|
||||||
|
@ -38,7 +41,7 @@ export class ExtractImages extends Conversion<LayoutConfigJson, string[]> {
|
||||||
const fromPath = Utils.CollectPath(trpath.path, foundImage)
|
const fromPath = Utils.CollectPath(trpath.path, foundImage)
|
||||||
for (const img of fromPath) {
|
for (const img of fromPath) {
|
||||||
if (typeof img !== "string") {
|
if (typeof img !== "string") {
|
||||||
errors.push("Found an image path that is not a path at " + context + "." + metapath.path.join(".") + ": " + JSON.stringify(img))
|
(this._isOfficial ? errors: warnings).push("Found an image path that is not a path at " + context + "." + metapath.path.join(".") + ": " + JSON.stringify(img))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
allFoundImages.push(...fromPath.filter(i => typeof i === "string"))
|
allFoundImages.push(...fromPath.filter(i => typeof i === "string"))
|
||||||
|
@ -53,7 +56,7 @@ export class ExtractImages extends Conversion<LayoutConfigJson, string[]> {
|
||||||
|
|
||||||
const splitParts = [].concat(...Utils.NoNull(allFoundImages).map(img => img.split(";")))
|
const splitParts = [].concat(...Utils.NoNull(allFoundImages).map(img => img.split(";")))
|
||||||
.map(img => img.split(":")[0])
|
.map(img => img.split(":")[0])
|
||||||
return {result: Utils.Dedup(splitParts), errors};
|
return {result: Utils.Dedup(splitParts), errors, warnings};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ class ValidateTheme extends DesugaringStep<LayoutConfigJson> {
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// Check images: are they local, are the licenses there, is the theme icon square, ...
|
// Check images: are they local, are the licenses there, is the theme icon square, ...
|
||||||
const images = new ExtractImages().convertStrict(json, "validation")
|
const images = new ExtractImages(this._isBuiltin).convertStrict(json, "validation")
|
||||||
const remoteImages = images.filter(img => img.indexOf("http") == 0)
|
const remoteImages = images.filter(img => img.indexOf("http") == 0)
|
||||||
for (const remoteImage of remoteImages) {
|
for (const remoteImage of remoteImages) {
|
||||||
errors.push("Found a remote image: " + remoteImage + " in theme " + json.id + ", please download it.")
|
errors.push("Found a remote image: " + remoteImage + " in theme " + json.id + ", please download it.")
|
||||||
|
|
Loading…
Reference in a new issue