Add a warning if a logo for a theme is not square
This commit is contained in:
parent
62b646da99
commit
5d884a97f9
3 changed files with 47 additions and 4 deletions
20
package-lock.json
generated
20
package-lock.json
generated
|
@ -23,6 +23,7 @@
|
|||
"@types/papaparse": "^5.3.1",
|
||||
"@types/prompt-sync": "^4.1.0",
|
||||
"@types/wikidata-sdk": "^6.1.0",
|
||||
"@types/xml2js": "^0.4.9",
|
||||
"country-language": "^0.1.7",
|
||||
"email-validator": "^2.0.4",
|
||||
"escape-html": "^1.0.3",
|
||||
|
@ -53,7 +54,8 @@
|
|||
"togpx": "^0.5.4",
|
||||
"tslint": "^6.1.3",
|
||||
"wikibase-sdk": "^7.14.0",
|
||||
"wikidata-sdk": "^7.14.0"
|
||||
"wikidata-sdk": "^7.14.0",
|
||||
"xml2js": "^0.4.23"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/polyfill": "^7.10.4",
|
||||
|
@ -3313,6 +3315,14 @@
|
|||
"wikidata-sdk": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/xml2js": {
|
||||
"version": "0.4.9",
|
||||
"resolved": "https://registry.npmjs.org/@types/xml2js/-/xml2js-0.4.9.tgz",
|
||||
"integrity": "sha512-CHiCKIihl1pychwR2RNX5mAYmJDACgFVCMT5OArMaO3erzwXVcBqPcusr+Vl8yeeXukxZqtF8mZioqX+mpjjdw==",
|
||||
"dependencies": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/abab": {
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://registry.npmjs.org/abab/-/abab-2.0.5.tgz",
|
||||
|
@ -19297,6 +19307,14 @@
|
|||
"wikidata-sdk": "*"
|
||||
}
|
||||
},
|
||||
"@types/xml2js": {
|
||||
"version": "0.4.9",
|
||||
"resolved": "https://registry.npmjs.org/@types/xml2js/-/xml2js-0.4.9.tgz",
|
||||
"integrity": "sha512-CHiCKIihl1pychwR2RNX5mAYmJDACgFVCMT5OArMaO3erzwXVcBqPcusr+Vl8yeeXukxZqtF8mZioqX+mpjjdw==",
|
||||
"requires": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"abab": {
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://registry.npmjs.org/abab/-/abab-2.0.5.tgz",
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
"@types/papaparse": "^5.3.1",
|
||||
"@types/prompt-sync": "^4.1.0",
|
||||
"@types/wikidata-sdk": "^6.1.0",
|
||||
"@types/xml2js": "^0.4.9",
|
||||
"country-language": "^0.1.7",
|
||||
"email-validator": "^2.0.4",
|
||||
"escape-html": "^1.0.3",
|
||||
|
@ -94,7 +95,8 @@
|
|||
"togpx": "^0.5.4",
|
||||
"tslint": "^6.1.3",
|
||||
"wikibase-sdk": "^7.14.0",
|
||||
"wikidata-sdk": "^7.14.0"
|
||||
"wikidata-sdk": "^7.14.0",
|
||||
"xml2js": "^0.4.23"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/polyfill": "^7.10.4",
|
||||
|
|
|
@ -6,6 +6,8 @@ import Constants from "../Models/Constants";
|
|||
import * as all_known_layouts from "../assets/generated/known_layers_and_themes.json"
|
||||
import {LayoutConfigJson} from "../Models/ThemeConfig/Json/LayoutConfigJson";
|
||||
import LayoutConfig from "../Models/ThemeConfig/LayoutConfig";
|
||||
import xml2js from 'xml2js';
|
||||
import {exec} from "child_process";
|
||||
|
||||
const sharp = require('sharp');
|
||||
const template = readFileSync("theme.html", "utf8");
|
||||
|
@ -35,7 +37,7 @@ async function createIcon(iconPath: string, size: number) {
|
|||
readFileSync(newname);
|
||||
return newname; // File already exists - nothing to do
|
||||
} catch (e) {
|
||||
// Errors are normal here if this file exists
|
||||
// Errors are normal here if this file does not exists
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -60,7 +62,28 @@ async function createManifest(layout: LayoutConfig) {
|
|||
|
||||
let icon = layout.icon;
|
||||
if (icon.endsWith(".svg") || icon.startsWith("<svg") || icon.startsWith("<?xml")) {
|
||||
// This is an svg. Lets create the needed pngs!
|
||||
// This is an svg. Lets create the needed pngs and do some checkes!
|
||||
|
||||
{
|
||||
const svgResult = await xml2js.parseStringPromise(readFileSync(icon, "UTF8"))
|
||||
const svg = svgResult.svg
|
||||
const width: string = svg.$.width;
|
||||
const height: string = svg.$.height;
|
||||
if(width !== height){
|
||||
console.warn("WARNING: the icon for theme "+layout.id+" is not square. Please square the icon at "+icon+"\n Width = "+width, "height =", height)
|
||||
/* const process = exec("inkscape " + icon, ((error, stdout, stderr) => {
|
||||
console.log("Inkscape: ", stdout)
|
||||
if (error !== null) {
|
||||
console.error(error)
|
||||
}
|
||||
if (stderr !== "") {
|
||||
console.error(stderr)
|
||||
}
|
||||
}))//*/
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let path = layout.icon;
|
||||
if (layout.icon.startsWith("<")) {
|
||||
|
|
Loading…
Reference in a new issue