Small improvements to 'createLayouts'-script

This commit is contained in:
Pieter Vander Vennet 2020-10-23 02:15:58 +02:00
parent b9cd30cb1f
commit f81de078f7
5 changed files with 17 additions and 3 deletions

View file

@ -18,6 +18,10 @@ export class Layout {
public description: string | UIElement; public description: string | UIElement;
public changesetMessage: string; public changesetMessage: string;
public socialImage: string = ""; public socialImage: string = "";
/**
* Custom CSS link
*/
public customCss: string = undefined;
public layers: (LayerDefinition | string)[]; public layers: (LayerDefinition | string)[];
public welcomeMessage: UIElement; public welcomeMessage: UIElement;

View file

@ -23,7 +23,7 @@ export default class State {
// The singleton of the global state // The singleton of the global state
public static state: State; public static state: State;
public static vNumber = "0.1.0g"; public static vNumber = "0.1.1";
// The user journey states thresholds when a new feature gets unlocked // The user journey states thresholds when a new feature gets unlocked
public static userJourney = { public static userJourney = {

View file

@ -12,7 +12,7 @@
"fr" "fr"
], ],
"maintainer": "", "maintainer": "",
"icon": "https://upload.wikimedia.org/wikipedia/commons/5/55/French_fries_juliane_kr_r.svg", "icon": "./assets/themes/fritures/fries.svg",
"version": "0", "version": "0",
"startLat": 0, "startLat": 0,
"startLon": 0, "startLon": 0,
@ -224,7 +224,7 @@
} }
], ],
"icon": { "icon": {
"render": "https://upload.wikimedia.org/wikipedia/commons/5/55/French_fries_juliane_kr_r.svg" "render": "./assets/themes/fritures/fries.svg"
}, },
"width": { "width": {
"render": "8" "render": "8"

View file

@ -1,6 +1,7 @@
import {UIElement} from "./UI/UIElement"; import {UIElement} from "./UI/UIElement";
// We HAVE to mark this while importing // We HAVE to mark this while importing
UIElement.runningFromConsole = true; UIElement.runningFromConsole = true;
import {AllKnownLayouts} from "./Customizations/AllKnownLayouts"; import {AllKnownLayouts} from "./Customizations/AllKnownLayouts";
import {Layout} from "./Customizations/Layout"; import {Layout} from "./Customizations/Layout";
import {readFileSync, writeFile, writeFileSync} from "fs"; import {readFileSync, writeFile, writeFileSync} from "fs";
@ -206,6 +207,11 @@ function createLandingPage(layout: Layout) {
const ogDescr = Translations.W(layout.description ?? "Easily add and edit geodata with OpenStreetMap")?.InnerRender(); const ogDescr = Translations.W(layout.description ?? "Easily add and edit geodata with OpenStreetMap")?.InnerRender();
const ogImage = layout.socialImage; const ogImage = layout.socialImage;
let customCss = "";
if (layout.customCss !== undefined && layout.customCss !== "") {
customCss = `<link rel='stylesheet" href=${layout.customCss}"/>`
}
const og = ` const og = `
<meta property="og:image" content="${ogImage ?? './assets/add.svg'}"> <meta property="og:image" content="${ogImage ?? './assets/add.svg'}">
<meta property="og:title" content="${ogTitle}"> <meta property="og:title" content="${ogTitle}">
@ -214,6 +220,9 @@ function createLandingPage(layout: Layout) {
let output = template let output = template
.replace(`./manifest.manifest`, `./${enc(layout.id)}.webmanifest`) .replace(`./manifest.manifest`, `./${enc(layout.id)}.webmanifest`)
.replace("<!-- $$$OG-META -->", og) .replace("<!-- $$$OG-META -->", og)
.replace(/<title>.+?<\/title>/, `<title>${ogTitle}</title>`)
.replace("Loading MapComplete, hang on...", `Loading MapComplete theme <i>${ogTitle}</i>...`)
.replace("<!-- $$$CUSTOM-CSS -->", customCss)
.replace(`<link rel="icon" href="assets/add.svg" sizes="any" type="image/svg+xml">`, .replace(`<link rel="icon" href="assets/add.svg" sizes="any" type="image/svg+xml">`,
`<link rel="icon" href="${layout.icon}" sizes="any" type="image/svg+xml">`); `<link rel="icon" href="${layout.icon}" sizes="any" type="image/svg+xml">`);

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" href="./css/slideshow.css"/> <link rel="stylesheet" href="./css/slideshow.css"/>
<link rel="stylesheet" href="./css/mobile.css"/> <link rel="stylesheet" href="./css/mobile.css"/>
<link rel="stylesheet" href="./css/openinghourstable.css"/> <link rel="stylesheet" href="./css/openinghourstable.css"/>
<!-- $$$CUSTOM-CSS -->
<link rel="manifest" href="./manifest.manifest"> <link rel="manifest" href="./manifest.manifest">
<link rel="icon" href="assets/add.svg" sizes="any" type="image/svg+xml"> <link rel="icon" href="assets/add.svg" sizes="any" type="image/svg+xml">