A png, of course
This commit is contained in:
parent
d3b748b873
commit
50b8638408
1 changed files with 14 additions and 15 deletions
|
@ -1,6 +1,5 @@
|
||||||
// We HAVE to mark this while importing
|
// We HAVE to mark this while importing
|
||||||
import {Utils} from "../Utils";
|
import {Utils} from "../Utils";
|
||||||
|
|
||||||
Utils.runningFromConsole = true;
|
Utils.runningFromConsole = true;
|
||||||
|
|
||||||
import LayoutConfig from "../Customizations/JSON/LayoutConfig";
|
import LayoutConfig from "../Customizations/JSON/LayoutConfig";
|
||||||
|
@ -11,7 +10,6 @@ import {Translation} from "../UI/i18n/Translation";
|
||||||
import Constants from "../Models/Constants";
|
import Constants from "../Models/Constants";
|
||||||
import * as all_known_layouts from "../assets/generated/known_layers_and_themes.json"
|
import * as all_known_layouts from "../assets/generated/known_layers_and_themes.json"
|
||||||
import {LayoutConfigJson} from "../Customizations/JSON/LayoutConfigJson";
|
import {LayoutConfigJson} from "../Customizations/JSON/LayoutConfigJson";
|
||||||
|
|
||||||
const sharp = require('sharp');
|
const sharp = require('sharp');
|
||||||
|
|
||||||
|
|
||||||
|
@ -59,7 +57,7 @@ async function createManifest(layout: LayoutConfig) {
|
||||||
|
|
||||||
Translation.forcedLanguage = "en"
|
Translation.forcedLanguage = "en"
|
||||||
const icons = [];
|
const icons = [];
|
||||||
|
|
||||||
|
|
||||||
let icon = layout.icon;
|
let icon = layout.icon;
|
||||||
if (icon.endsWith(".svg") || icon.startsWith("<svg") || icon.startsWith("<?xml")) {
|
if (icon.endsWith(".svg") || icon.startsWith("<svg") || icon.startsWith("<?xml")) {
|
||||||
|
@ -86,13 +84,14 @@ async function createManifest(layout: LayoutConfig) {
|
||||||
sizes: "513x513",
|
sizes: "513x513",
|
||||||
type: "image/svg"
|
type: "image/svg"
|
||||||
})
|
})
|
||||||
} else if (icon.endsWith(".png")) {
|
} else if (icon.endsWith(".png")){
|
||||||
icons.push({
|
icons.push({
|
||||||
src: icon,
|
src: icon,
|
||||||
sizes: "513x513",
|
sizes: "513x513",
|
||||||
type: "image/svg"
|
type: "image/png"
|
||||||
})
|
})
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
console.log(icon)
|
console.log(icon)
|
||||||
throw "Icon is not an svg for " + layout.id
|
throw "Icon is not an svg for " + layout.id
|
||||||
}
|
}
|
||||||
|
@ -143,15 +142,15 @@ async function createLandingPage(layout: LayoutConfig, manifest) {
|
||||||
icon = `./assets/generated/${layout.id}_icon.svg`
|
icon = `./assets/generated/${layout.id}_icon.svg`
|
||||||
writeFileSync(icon, layout.icon);
|
writeFileSync(icon, layout.icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
const apple_icons = []
|
const apple_icons = []
|
||||||
for (const icon of manifest.icons) {
|
for (const icon of manifest.icons) {
|
||||||
if (icon.type !== "image/png") {
|
if(icon.type !== "image/png"){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
apple_icons.push(`<link rel="apple-touch-icon" sizes="${icon.sizes}" href="${icon.src}">`)
|
apple_icons.push(`<link rel="apple-touch-icon" sizes="${icon.sizes}" href="${icon.src}">`)
|
||||||
}
|
}
|
||||||
|
|
||||||
let themeSpecific = [
|
let themeSpecific = [
|
||||||
`<title>${ogTitle}</title>`,
|
`<title>${ogTitle}</title>`,
|
||||||
`<link rel="manifest" href="${enc(layout.id)}.webmanifest">`,
|
`<link rel="manifest" href="${enc(layout.id)}.webmanifest">`,
|
||||||
|
@ -184,9 +183,9 @@ if (!existsSync(generatedDir)) {
|
||||||
|
|
||||||
const blacklist = ["", "test", ".", "..", "manifest", "index", "land", "preferences", "account", "openstreetmap", "custom"]
|
const blacklist = ["", "test", ".", "..", "manifest", "index", "land", "preferences", "account", "openstreetmap", "custom"]
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const all: LayoutConfigJson[] = all_known_layouts.themes;
|
const all : LayoutConfigJson[] = all_known_layouts.themes;
|
||||||
for (const i in all) {
|
for (const i in all) {
|
||||||
const layoutConfigJson: LayoutConfigJson = all[i]
|
const layoutConfigJson : LayoutConfigJson = all[i]
|
||||||
const layout = new LayoutConfig(layoutConfigJson, true, "generating layouts")
|
const layout = new LayoutConfig(layoutConfigJson, true, "generating layouts")
|
||||||
const layoutName = layout.id
|
const layoutName = layout.id
|
||||||
if (blacklist.indexOf(layoutName.toLowerCase()) >= 0) {
|
if (blacklist.indexOf(layoutName.toLowerCase()) >= 0) {
|
||||||
|
@ -202,13 +201,13 @@ for (const i in all) {
|
||||||
const manif = JSON.stringify(manifObj, undefined, 2);
|
const manif = JSON.stringify(manifObj, undefined, 2);
|
||||||
const manifestLocation = encodeURIComponent(layout.id.toLowerCase()) + ".webmanifest";
|
const manifestLocation = encodeURIComponent(layout.id.toLowerCase()) + ".webmanifest";
|
||||||
writeFile(manifestLocation, manif, err);
|
writeFile(manifestLocation, manif, err);
|
||||||
|
|
||||||
// Create a landing page for the given theme
|
// Create a landing page for the given theme
|
||||||
createLandingPage(layout, manifObj).then(landing => {
|
createLandingPage(layout, manifObj).then(landing => {
|
||||||
writeFile(enc(layout.id) + ".html", landing, err)
|
writeFile(enc(layout.id) + ".html", landing, err)
|
||||||
});
|
});
|
||||||
}).catch(e => console.log("Could not generate the manifest: ", e))
|
}).catch(e => console.log("Could not generate the manifest: ", e))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
createManifest(new LayoutConfig({
|
createManifest(new LayoutConfig({
|
||||||
|
@ -220,9 +219,9 @@ createManifest(new LayoutConfig({
|
||||||
startLat: 0,
|
startLat: 0,
|
||||||
startLon: 0,
|
startLon: 0,
|
||||||
startZoom: 0,
|
startZoom: 0,
|
||||||
title: {en: "MapComplete"},
|
title: {en:"MapComplete"},
|
||||||
version: Constants.vNumber,
|
version: Constants.vNumber,
|
||||||
description: {en: "A thematic map viewer and editor based on OpenStreetMap"}
|
description: {en:"A thematic map viewer and editor based on OpenStreetMap"}
|
||||||
})).then(manifObj => {
|
})).then(manifObj => {
|
||||||
const manif = JSON.stringify(manifObj, undefined, 2);
|
const manif = JSON.stringify(manifObj, undefined, 2);
|
||||||
writeFileSync("index.manifest", manif)
|
writeFileSync("index.manifest", manif)
|
||||||
|
|
Loading…
Reference in a new issue