From cce9207a3533f583b72aef02c97f7d74967551a2 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Sat, 22 Aug 2020 03:15:42 +0200 Subject: [PATCH] Fixed the build --- Customizations/AllKnownLayouts.ts | 2 +- Customizations/LayerDefinition.ts | 7 +- Customizations/Layers/BikeCafes.ts | 2 +- Customizations/Layers/BikeParkings.ts | 2 +- Customizations/Layers/ClimbingTree.ts | 2 +- Customizations/Layers/DrinkingWater.ts | 2 +- Customizations/Layouts/ClimbingTrees.ts | 2 +- Customizations/Layouts/Groen.ts | 2 +- Customizations/Layouts/MetaMap.ts | 3 +- Customizations/Layouts/StreetWidth.ts | 3 +- Customizations/Questions/FixedText.ts | 3 +- Customizations/Questions/NameInline.ts | 3 +- UI/Image/ImageCarousel.ts | 4 + assets/themes/aed/aed.svg | 8 ++ assets/themes/nature/tree.svg | 129 ++++++++++++++++++ createLayouts.ts | 29 ++-- deploy.sh | 3 +- package.json | 6 +- Customizations/tsconfig.json => tsconfig.json | 0 19 files changed, 183 insertions(+), 29 deletions(-) create mode 100644 assets/themes/aed/aed.svg create mode 100644 assets/themes/nature/tree.svg rename Customizations/tsconfig.json => tsconfig.json (100%) diff --git a/Customizations/AllKnownLayouts.ts b/Customizations/AllKnownLayouts.ts index af3b2d2..6a08c93 100644 --- a/Customizations/AllKnownLayouts.ts +++ b/Customizations/AllKnownLayouts.ts @@ -35,7 +35,7 @@ export class AllKnownLayouts { new Artworks(), new Smoothness(), new Groen(), - + /* new Toilets(), */ diff --git a/Customizations/LayerDefinition.ts b/Customizations/LayerDefinition.ts index 51f11ea..1656da3 100644 --- a/Customizations/LayerDefinition.ts +++ b/Customizations/LayerDefinition.ts @@ -2,6 +2,7 @@ import {Tag, TagsFilter} from "../Logic/TagsFilter"; import {UIElement} from "../UI/UIElement"; import {TagDependantUIElementConstructor} from "./UIElementConstructor"; import {TagRenderingOptions} from "./TagRenderingOptions"; +import Translation from "../UI/i18n/Translation"; export interface Preset { tags: Tag[], @@ -21,7 +22,7 @@ export class LayerDefinition { /*** * This is shown under the 'add new' button to indicate what kind of feature one is adding. */ - description: string | UIElement + description: string | Translation /** * These tags are added whenever a new point is added by the user on the map. @@ -94,8 +95,8 @@ export class LayerDefinition { static WAYHANDLING_CENTER_AND_WAY = 2; constructor(id: string, options: { - name: string | UIElement, - description: string | UIElement, + name: string | Translation, + description: string | Translation, presets: Preset[], icon: string, minzoom: number, diff --git a/Customizations/Layers/BikeCafes.ts b/Customizations/Layers/BikeCafes.ts index b518c88..19a65cb 100644 --- a/Customizations/Layers/BikeCafes.ts +++ b/Customizations/Layers/BikeCafes.ts @@ -61,7 +61,7 @@ export default class BikeCafes extends LayerDefinition { return { color: "#00bb00", icon: { - iconUrl: self.icon, + iconUrl: "./assets/bike/cafe.svg", iconSize: [50, 50], iconAnchor: [25,50] } diff --git a/Customizations/Layers/BikeParkings.ts b/Customizations/Layers/BikeParkings.ts index 4aed3bb..b5c7d28 100644 --- a/Customizations/Layers/BikeParkings.ts +++ b/Customizations/Layers/BikeParkings.ts @@ -49,7 +49,7 @@ export default class BikeParkings extends LayerDefinition { return { color: "#00bb00", icon: { - iconUrl: self.icon, + iconUrl: "./assets/bike/parking.svg", iconSize: [50, 50], iconAnchor: [25,50] } diff --git a/Customizations/Layers/ClimbingTree.ts b/Customizations/Layers/ClimbingTree.ts index e664302..f423f1a 100644 --- a/Customizations/Layers/ClimbingTree.ts +++ b/Customizations/Layers/ClimbingTree.ts @@ -11,7 +11,7 @@ export class ClimbingTree extends LayerDefinition { super("climbingtree"); const t = Translations.t.climbingTrees.layer; this.title = new FixedText(t.title); - const icon = "assets/walkbybrussels/tree.svg"; + const icon = "./assets/themes/nature/tree.svg"; this.icon = icon; this.description = t.description; this.style = (tags) => { diff --git a/Customizations/Layers/DrinkingWater.ts b/Customizations/Layers/DrinkingWater.ts index 6266b97..e7fd086 100644 --- a/Customizations/Layers/DrinkingWater.ts +++ b/Customizations/Layers/DrinkingWater.ts @@ -54,7 +54,7 @@ export class DrinkingWater extends LayerDefinition { return { color: "#00bb00", icon: { - iconUrl: self.icon, + iconUrl: "./assets/bike/drinking_water.svg", iconSize: [50, 50], iconAnchor: [25,50] } diff --git a/Customizations/Layouts/ClimbingTrees.ts b/Customizations/Layouts/ClimbingTrees.ts index fabf8e8..8618b29 100644 --- a/Customizations/Layouts/ClimbingTrees.ts +++ b/Customizations/Layouts/ClimbingTrees.ts @@ -15,7 +15,7 @@ export class ClimbingTrees extends Layout { 4.3688, Translations.t.climbingTrees.layout.welcome ); - this.icon = "./assets/walkbybrussels/tree.svg" + this.icon = "./assets/themes/nature/tree.svg" this.hideFromOverview = true; } } \ No newline at end of file diff --git a/Customizations/Layouts/Groen.ts b/Customizations/Layouts/Groen.ts index 986cfcc..ba0d605 100644 --- a/Customizations/Layouts/Groen.ts +++ b/Customizations/Layouts/Groen.ts @@ -52,7 +52,7 @@ export class Groen extends Layout { "" ); - this.icon = "assets/groen.svg" + this.icon = "./assets/groen.svg" this.locationContains = ["buurtnatuur.be"] this.socialImage = "assets/BuurtnatuurFront.jpg" this.description = "Met deze tool kan je natuur in je buurt in kaart brengen en meer informatie geven over je favoriete plekje" diff --git a/Customizations/Layouts/MetaMap.ts b/Customizations/Layouts/MetaMap.ts index 6486e9b..6a4b7d3 100644 --- a/Customizations/Layouts/MetaMap.ts +++ b/Customizations/Layouts/MetaMap.ts @@ -1,5 +1,4 @@ import {Layout} from "../Layout"; -import * as Layer from "../Layers/Bookcases"; import {Map} from "../Layers/Map"; export class MetaMap extends Layout{ @@ -15,6 +14,6 @@ export class MetaMap extends Layout{ "

Open Map Map

\n" + "This map is a map of physical maps, as known by OpenStreetMap."); - this.icon = "assets/osm-logo-buggy-attr.svg" + this.icon = "./assets/osm-logo-buggy-attr.svg" } } \ No newline at end of file diff --git a/Customizations/Layouts/StreetWidth.ts b/Customizations/Layouts/StreetWidth.ts index 9ae9573..8f3aeb7 100644 --- a/Customizations/Layouts/StreetWidth.ts +++ b/Customizations/Layouts/StreetWidth.ts @@ -1,5 +1,4 @@ import {Layout} from "../Layout"; -import * as Layer from "../Layers/Bookcases"; import {Widths} from "../Layers/Widths"; export class StreetWidth extends Layout{ @@ -85,7 +84,7 @@ export class StreetWidth extends Layout{ "
  • Laat toeristen verplicht parkeren onder het zand; een (fiets)taxi kan hen naar hun hotel brengen
  • " + "
  • Voorzie in elke straat enkele parkeerplaatsen voor kortparkeren. Zo kunnen leveringen, iemand afzetten,... gebeuren zonder dat er een fietspad of een straat geblokkeerd wordt
  • " + ""); - this.icon = "assets/bug.svg"; + this.icon = "./assets/bug.svg"; this.enableSearch = false; this.enableUserBadge = false; this.enableAdd = false; diff --git a/Customizations/Questions/FixedText.ts b/Customizations/Questions/FixedText.ts index 5884532..dfa7079 100644 --- a/Customizations/Questions/FixedText.ts +++ b/Customizations/Questions/FixedText.ts @@ -1,8 +1,9 @@ import {UIElement} from "../../UI/UIElement"; import {TagRenderingOptions} from "../TagRenderingOptions"; +import Translation from "../../UI/i18n/Translation"; export default class FixedText extends TagRenderingOptions { - constructor(category: string | UIElement) { + constructor(category: string | Translation) { super({ mappings: [ { diff --git a/Customizations/Questions/NameInline.ts b/Customizations/Questions/NameInline.ts index 4e687f3..12c6097 100644 --- a/Customizations/Questions/NameInline.ts +++ b/Customizations/Questions/NameInline.ts @@ -2,11 +2,12 @@ import {And, Tag} from "../../Logic/TagsFilter"; import {UIElement} from "../../UI/UIElement"; import Translations from "../../UI/i18n/Translations"; import {TagRenderingOptions} from "../TagRenderingOptions"; +import Translation from "../../UI/i18n/Translation"; export class NameInline extends TagRenderingOptions{ - constructor(category: string | UIElement ) { + constructor(category: string | Translation ) { super({ question: "", diff --git a/UI/Image/ImageCarousel.ts b/UI/Image/ImageCarousel.ts index 0f9f19c..e4cfcfb 100644 --- a/UI/Image/ImageCarousel.ts +++ b/UI/Image/ImageCarousel.ts @@ -29,6 +29,10 @@ export class ImageCarouselConstructor implements TagDependantUIElementConstructo return new ImageCarousel(dependencies.tags); } + GetContent(tags: any): string { + return undefined; + } + } export class ImageCarousel extends TagDependantUIElement { diff --git a/assets/themes/aed/aed.svg b/assets/themes/aed/aed.svg new file mode 100644 index 0000000..04d23c1 --- /dev/null +++ b/assets/themes/aed/aed.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/assets/themes/nature/tree.svg b/assets/themes/nature/tree.svg new file mode 100644 index 0000000..0b5a595 --- /dev/null +++ b/assets/themes/nature/tree.svg @@ -0,0 +1,129 @@ + + + + + + + + + image/svg+xml + + + + + Openclipart + + + Oak Tree + 2013-11-13T14:27:32 + Oak tree in black and white + https://openclipart.org/detail/188718/oak-tree-by-iggyoblomov-188718 + + + IggyOblomov + + + + + forest + nature + oak + oak tree + quercus + tree + trees + vegetation + + + + + + + + + + + diff --git a/createLayouts.ts b/createLayouts.ts index 55db89a..efb2e5e 100644 --- a/createLayouts.ts +++ b/createLayouts.ts @@ -1,6 +1,11 @@ import {UIElement} from "./UI/UIElement"; // We HAVE to mark this while importing UIElement.runningFromConsole = true; + +import {TagRendering} from "./Customizations/TagRendering"; + +TagRendering.injectFunction(); + import {AllKnownLayouts} from "./Customizations/AllKnownLayouts"; import {Layout} from "./Customizations/Layout"; import {readFileSync, writeFile, writeFileSync} from "fs"; @@ -8,6 +13,7 @@ import Locale from "./UI/i18n/Locale"; import svg2img from 'promise-svg2img'; import Translation from "./UI/i18n/Translation"; import Translations from "./UI/i18n/Translations"; +import {TagRenderingOptions} from "./Customizations/TagRenderingOptions"; console.log("Building the layouts") @@ -88,6 +94,8 @@ function createIcon(iconPath: string, size: number) { } + console.log("Creating icon ", name, newname) + svg2img(iconPath, // @ts-ignore {width: size, height: size, preserveAspectRatio: true}) @@ -95,21 +103,23 @@ function createIcon(iconPath: string, size: number) { console.log("Writing icon", newname) writeFileSync(newname, buffer); }).catch((error) => { - console.log("ERROR", error) + console.log("ERROR while writing" + iconPath, error) }); return newname; } function createManifest(layout: Layout, relativePath: string) { - const name = layout.name; + const name = layout.name; const icons = []; - if (layout.icon.endsWith(".svg")) { + let icon = layout.icon; + console.log(icon) + if (icon.endsWith(".svg")) { // This is an svg. Lets create the needed pngs! const sizes = [72, 96, 120, 128, 144, 152, 180, 192, 384, 512]; for (const size of sizes) { - const name = createIcon(layout.icon, size); + const name = createIcon(icon, size); icons.push({ src: name, sizes: size + "x" + size, @@ -117,7 +127,7 @@ function createManifest(layout: Layout, relativePath: string) { }) } icons.push({ - src: layout.icon, + src: icon, sizes: "513x513", type: "image/svg" }) @@ -126,7 +136,7 @@ function createManifest(layout: Layout, relativePath: string) { throw "Icon is not an svg for " + layout.name } const ogTitle = Translations.W(layout.title).InnerRender(); - const ogDescr = Translations.W(layout.description).InnerRender(); + const ogDescr = Translations.W(layout.description ?? "").InnerRender(); const manif = { name: name, @@ -147,7 +157,7 @@ function createLandingPage(layout: Layout) { Locale.language.setData(layout.supportedLanguages[0]); const ogTitle = Translations.W(layout.title).InnerRender(); - const ogDescr = Translations.W(layout.description).InnerRender(); + const ogDescr = Translations.W(layout.description ?? "").InnerRender(); const ogImage = layout.socialImage; const og = ` @@ -183,10 +193,11 @@ for (const layoutName in all) { writeFile(manifestLocation, manif, err); const landing = createLandingPage(layout); - console.log("Generating html-file for ",layout.name) + console.log("Generating html-file for ", layout.name) writeFile(enc(layout.name) + ".html", landing, err) console.log("done") } -console.log("COunting all translations") + +console.log("Counting all translations") Translations.CountTranslations(); console.log("All done!") \ No newline at end of file diff --git a/deploy.sh b/deploy.sh index cc8a8db..87c63dc 100755 --- a/deploy.sh +++ b/deploy.sh @@ -4,13 +4,14 @@ ts-node createLayouts.ts npm run build rm -rf /home/pietervdvn/git/pietervdvn.github.io/MapComplete/* cp -r dist/* /home/pietervdvn/git/pietervdvn.github.io/MapComplete/ -./clean.sh + cd /home/pietervdvn/git/pietervdvn.github.io/MapComplete/ git add . git commit -m "New mapcomplete version" git push +cd - # clean up the mess we made # rm *.js # rm Logic/*.js diff --git a/package.json b/package.json index faa9ab2..f10d3c9 100644 --- a/package.json +++ b/package.json @@ -7,14 +7,14 @@ "staticPath": [ { "staticPath": "tiles", - "staticOutDir": "tiles/" + "staticOutDir": "./tiles/" } ] }, "scripts": { - "start": "parcel *.html UI/** Logic/** assets/**/* assets/**/**/* assets/* vendor/* vendor/*/*", + "start": "parcel *.html UI/** Logic/** assets/** a vendor/* vendor/*/*", "generate": "ts-node createLayouts.ts", - "build": "rm -rf dist/ && parcel build --public-url ./ *.html assets/* assets/**/* assets/**/**/* vendor/* vendor/*/*", + "build": "rm -rf dist/ && parcel build --public-url ./ *.html assets/** assets/**/** assets/**/**/** vendor/* vendor/*/*", "clean": "./clean.sh", "test": "echo \"Error: no test specified\" && exit 1" }, diff --git a/Customizations/tsconfig.json b/tsconfig.json similarity index 100% rename from Customizations/tsconfig.json rename to tsconfig.json