From 459489dedfe88de233237805e4ce4028df0af187 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Fri, 23 Oct 2020 01:33:37 +0200 Subject: [PATCH 1/5] Change order of questions for fritures --- assets/themes/fritures/fritures.json | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/assets/themes/fritures/fritures.json b/assets/themes/fritures/fritures.json index d664a55..6becab7 100644 --- a/assets/themes/fritures/fritures.json +++ b/assets/themes/fritures/fritures.json @@ -69,17 +69,16 @@ }, { "render": { - "nl": "{phone}", - "fr": "{phone}" + "nl": "

Openingsuren

{opening_hours_table(opening_hours)}", + "fr": "

Horaires

{opening_hours_table(opening_hours)}" }, "question": { - "en": "What is the phone number?", - "nl": "Wat is het telefoonnummer van deze frituur?", - "fr": "Quel est le numéro de téléphone de cette friture?" + "nl": "Wat zijn de openinguren van deze frituur?", + "fr": "Quand est ce-que ce friture ouvert?" }, "freeform": { - "key": "phone", - "type": "phone" + "key": "opening_hours", + "type": "opening_hours" } }, { @@ -98,16 +97,17 @@ }, { "render": { - "nl": "

Openingsuren

{opening_hours_table(opening_hours)}", - "fr": "

Horaires

{opening_hours_table(opening_hours)}" + "nl": "{phone}", + "fr": "{phone}" }, "question": { - "nl": "Wat zijn de openinguren van deze frituur?", - "fr": "Quand est ce-que ce friture ouvert?" + "en": "What is the phone number?", + "nl": "Wat is het telefoonnummer van deze frituur?", + "fr": "Quel est le numéro de téléphone de cette friture?" }, "freeform": { - "key": "opening_hours", - "type": "opening_hours" + "key": "phone", + "type": "phone" } }, { From b9cd30cb1f7250ba6b97a07e108f060223db550d Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Fri, 23 Oct 2020 01:50:37 +0200 Subject: [PATCH 2/5] Fix performance issues --- Logic/MetaTagging.ts | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/Logic/MetaTagging.ts b/Logic/MetaTagging.ts index 4de819b..5be7edb 100644 --- a/Logic/MetaTagging.ts +++ b/Logic/MetaTagging.ts @@ -5,12 +5,12 @@ import opening_hours from "opening_hours"; class SimpleMetaTagger { - private _f: (feature: any) => void; + private _f: (feature: any, index: number) => void; public readonly keys: string[]; public readonly doc: string; - constructor(keys: string[], doc: string, f: ((feature: any) => void)) { + constructor(keys: string[], doc: string, f: ((feature: any, index: number) => void)) { this.keys = keys; this.doc = doc; this._f = f; @@ -22,8 +22,9 @@ class SimpleMetaTagger { } addMetaTags(features: any[]) { - for (const feature of features) { - this._f(feature); + for (let i = 0; i < features.length; i++) { + let feature = features[i]; + this._f(feature, i); } } @@ -62,7 +63,7 @@ export default class MetaTagging { new SimpleMetaTagger( ["_country"], "The country code of the point", - (feature => { + ((feature, index) => { const centerPoint = GeoOperations.centerpoint(feature); const lat = centerPoint.geometry.coordinates[1]; const lon = centerPoint.geometry.coordinates[0] @@ -70,7 +71,11 @@ export default class MetaTagging { CodeGrid.getCode(lat, lon, (error, code) => { if (error === null) { feature.properties["_country"] = code; - State.state.allElements.addOrGetElement(feature).ping(); + + // There is a huge performance issue: if there are ~1000 features receiving a ping at the same time, + // The application hangs big time + // So we disable pinging all together + } else { console.warn("Could not determine country for", feature.properties.id, error); } @@ -85,6 +90,11 @@ export default class MetaTagging { if (tags["opening_hours"] !== undefined && tags["_country"] !== undefined) { + if (tags._isOpen !== undefined) { + // Already defined + return; + } + const oh = new opening_hours(tags["opening_hours"], { lat: tags._lat, lon: tags._lon, From f81de078f7ac9ad8115102b46b5eb972fad429f9 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Fri, 23 Oct 2020 02:15:58 +0200 Subject: [PATCH 3/5] Small improvements to 'createLayouts'-script --- Customizations/Layout.ts | 4 ++++ State.ts | 2 +- assets/themes/fritures/fritures.json | 4 ++-- createLayouts.ts | 9 +++++++++ index.html | 1 + 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Customizations/Layout.ts b/Customizations/Layout.ts index 70bc7dc..46252c6 100644 --- a/Customizations/Layout.ts +++ b/Customizations/Layout.ts @@ -18,6 +18,10 @@ export class Layout { public description: string | UIElement; public changesetMessage: string; public socialImage: string = ""; + /** + * Custom CSS link + */ + public customCss: string = undefined; public layers: (LayerDefinition | string)[]; public welcomeMessage: UIElement; diff --git a/State.ts b/State.ts index 43a88e0..f8e2909 100644 --- a/State.ts +++ b/State.ts @@ -23,7 +23,7 @@ export default class State { // The singleton of the global 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 public static userJourney = { diff --git a/assets/themes/fritures/fritures.json b/assets/themes/fritures/fritures.json index 6becab7..729974f 100644 --- a/assets/themes/fritures/fritures.json +++ b/assets/themes/fritures/fritures.json @@ -12,7 +12,7 @@ "fr" ], "maintainer": "", - "icon": "https://upload.wikimedia.org/wikipedia/commons/5/55/French_fries_juliane_kr_r.svg", + "icon": "./assets/themes/fritures/fries.svg", "version": "0", "startLat": 0, "startLon": 0, @@ -224,7 +224,7 @@ } ], "icon": { - "render": "https://upload.wikimedia.org/wikipedia/commons/5/55/French_fries_juliane_kr_r.svg" + "render": "./assets/themes/fritures/fries.svg" }, "width": { "render": "8" diff --git a/createLayouts.ts b/createLayouts.ts index 6032827..4bd7f59 100644 --- a/createLayouts.ts +++ b/createLayouts.ts @@ -1,6 +1,7 @@ import {UIElement} from "./UI/UIElement"; // We HAVE to mark this while importing UIElement.runningFromConsole = true; + import {AllKnownLayouts} from "./Customizations/AllKnownLayouts"; import {Layout} from "./Customizations/Layout"; 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 ogImage = layout.socialImage; + let customCss = ""; + if (layout.customCss !== undefined && layout.customCss !== "") { + customCss = ` @@ -214,6 +220,9 @@ function createLandingPage(layout: Layout) { let output = template .replace(`./manifest.manifest`, `./${enc(layout.id)}.webmanifest`) .replace("", og) + .replace(/.+?<\/title>/, `<title>${ogTitle}`) + .replace("Loading MapComplete, hang on...", `Loading MapComplete theme ${ogTitle}...`) + .replace("", customCss) .replace(``, ``); diff --git a/index.html b/index.html index ec97707..130f182 100644 --- a/index.html +++ b/index.html @@ -12,6 +12,7 @@ + From 950c69dd5e601a507dcbecd3b7243b6c2e132769 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Fri, 23 Oct 2020 02:25:58 +0200 Subject: [PATCH 4/5] Add french fries icon --- README.md | 5 +- assets/themes/fritures/fries.svg | 156 +++++++++++++++++++++++++++++++ 2 files changed, 160 insertions(+), 1 deletion(-) create mode 100644 assets/themes/fritures/fries.svg diff --git a/README.md b/README.md index fe481cd..6b7313b 100644 --- a/README.md +++ b/README.md @@ -188,4 +188,7 @@ Forest icon via https://www.onlinewebfonts.com/icon/498112, CC BY Statistics icon via https://www.onlinewebfonts.com/icon/197818 Chronometer (on monitoring_station.svg): ANTU chronometer -https://commons.wikimedia.org/w/index.php?title=Antu_chronometer&action=edit&redlink=1 \ No newline at end of file +https://commons.wikimedia.org/w/index.php?title=Antu_chronometer + +Fries icon: +https://commons.wikimedia.org/wiki/File:French_fries_juliane_kr_r.svg \ No newline at end of file diff --git a/assets/themes/fritures/fries.svg b/assets/themes/fritures/fries.svg new file mode 100644 index 0000000..09550da --- /dev/null +++ b/assets/themes/fritures/fries.svg @@ -0,0 +1,156 @@ + + + + + + + French Fries + + + + food + + + + + Open Clip Art Library + + + + + Juliane Krug + + + + + Juliane Krug + + + + image/svg+xml + + + en + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 28e40d08ae505a6bae6f534e57fd360fb1d41276 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Fri, 23 Oct 2020 02:26:14 +0200 Subject: [PATCH 5/5] Small fix to Public Holiday input --- UI/Input/OpeningHours/PublicHolidayInput.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/UI/Input/OpeningHours/PublicHolidayInput.ts b/UI/Input/OpeningHours/PublicHolidayInput.ts index c17baf9..3676f1f 100644 --- a/UI/Input/OpeningHours/PublicHolidayInput.ts +++ b/UI/Input/OpeningHours/PublicHolidayInput.ts @@ -30,7 +30,7 @@ export default class PublicHolidayInput extends InputElement { ); this._dropdown = dropdown.SetStyle("display:inline-block;"); this._mode = dropdown.GetValue(); - this.ListenTo(dropdown.GetValue()); + this.ListenTo(this._mode); const start = new TextField({ placeholder: "starthour", @@ -117,7 +117,7 @@ export default class PublicHolidayInput extends InputElement { if(str === "PH open"){ return { - mode: "open" + mode: " " } }