diff --git a/README.md b/README.md index d7da482..f5393a6 100644 --- a/README.md +++ b/README.md @@ -84,16 +84,16 @@ To develop: 0. Make a fork and clone the repository. 1. Install `npm`. Linux: `sudo apt install npm` (or your favourite package manager), Windows: install nodeJS: https://nodejs.org/en/download/ -2. Run `npm install` to install the dependencies -3. Run `npm run start` to host a local testversion at http://localhost:1234/index.html -4. By default, the 'bookcases'-theme is loaded. In order to load another theme, use `layout=themename` or `userlayout=true#`. Note that the custom URLs (e.g. `bookcases.html`, `aed.html`, ...) _don't_ exist on the development version. (These are automatically generated from a template on the server). +2. Run `npm install` to install the package dependencies +3. Run `npm run generate` to generate some additional dependencies +4. Run `npm run start` to host a local testversion at http://localhost:1234/index.html +5. By default, the 'bookcases'-theme is loaded. In order to load another theme, use `layout=themename` or `userlayout=true#`. Note that the custom URLs (e.g. `bookcases.html`, `aed.html`, ...) _don't_ exist on the development version. (These are automatically generated from a template on the server). To deploy: 0. `rm -rf dist/` to remove the local build -1. `ts-node createLayouts.ts` to generate the custom htmls, (such as `aed.html`, `bookcases.html`) -2. `npm run build` -3. copy the entire `dist` folder to where you host your website. Visiting `index.html` gives you the website +1. `npm run build` +2. Copy the entire `dist` folder to where you host your website. Visiting `index.html` gives you the website ## Translating MapComplete diff --git a/State.ts b/State.ts index c4faf55..f9772fe 100644 --- a/State.ts +++ b/State.ts @@ -22,7 +22,7 @@ export default class State { // The singleton of the global state public static state: State; - public static vNumber = "0.1.3-rc1"; + public static vNumber = "0.1.3-rc2+g"; // The user journey states thresholds when a new feature gets unlocked public static userJourney = { diff --git a/Svg.ts b/Svg.ts index 4850a0c..1907610 100644 --- a/Svg.ts +++ b/Svg.ts @@ -104,11 +104,16 @@ export default class Svg { public static help_svg() { return new FixedUiElement(Svg.help);} public static help_ui() { return new FixedUiElement(Svg.help_img);} - public static home = " " + public static home = " " public static home_img = Img.AsImageElement(Svg.home) public static home_svg() { return new FixedUiElement(Svg.home);} public static home_ui() { return new FixedUiElement(Svg.home_img);} + public static home_white_bg = " image/svg+xml " + public static home_white_bg_img = Img.AsImageElement(Svg.home_white_bg) + public static home_white_bg_svg() { return new FixedUiElement(Svg.home_white_bg);} + public static home_white_bg_ui() { return new FixedUiElement(Svg.home_white_bg_img);} + public static josm_logo = " JOSM Logotype 2019 image/svg+xml JOSM Logotype 2019 2019-08-05 Diamond00744 Public Domain " public static josm_logo_img = Img.AsImageElement(Svg.josm_logo) public static josm_logo_svg() { return new FixedUiElement(Svg.josm_logo);} diff --git a/UI/CustomGenerator/CustomGeneratorPanel.ts b/UI/CustomGenerator/CustomGeneratorPanel.ts index d8c1999..a7c1189 100644 --- a/UI/CustomGenerator/CustomGeneratorPanel.ts +++ b/UI/CustomGenerator/CustomGeneratorPanel.ts @@ -105,10 +105,9 @@ export default class CustomGeneratorPanel extends UIElement { } if (ud.csCount <= State.userJourney.themeGeneratorReadOnlyUnlock) { return new Combine([ - "

Too little experience/h3>", - `Creating your own (readonly) themes can only be done if you have more then ${State.userJourney.themeGeneratorReadOnlyUnlock} changesets made`, - `Making a theme including survey options can be done at ${State.userJourney.themeGeneratorFullUnlock} changesets`, - this.loginButton + "

Too little experience

", + `

Creating your own (readonly) themes can only be done if you have more then ${State.userJourney.themeGeneratorReadOnlyUnlock} changesets made

`, + `

Making a theme including survey options can be done at ${State.userJourney.themeGeneratorFullUnlock} changesets

` ]).Render(); } return this.mainPanel.Render() diff --git a/UI/Input/ValidatedTextField.ts b/UI/Input/ValidatedTextField.ts index 0071ab3..9c9e23c 100644 --- a/UI/Input/ValidatedTextField.ts +++ b/UI/Input/ValidatedTextField.ts @@ -103,7 +103,7 @@ export default class ValidatedTextField { "A geographical direction, in degrees. 0° is north, 90° is east, ... Will return a value between 0 (incl) and 360 (excl)", (str) => { str = "" + str; - return str !== undefined && str.indexOf(".") < 0 && !isNaN(Number(str)) && Number(str) > 0 && Number(str) <= 360 + return str !== undefined && str.indexOf(".") < 0 && !isNaN(Number(str)) && Number(str) >= 0 && Number(str) <= 360 },str => str, (value) => { return new DirectionInput(value); diff --git a/UI/UserBadge.ts b/UI/UserBadge.ts index 6a84fb3..f733d9b 100644 --- a/UI/UserBadge.ts +++ b/UI/UserBadge.ts @@ -96,11 +96,11 @@ export class UserBadge extends UIElement { if (user.home !== undefined) { const icon = L.icon({ - iconUrl: Img.AsData(Svg.home), - iconSize: [20, 20], - iconAnchor: [10, 10] + iconUrl: Img.AsData(Svg.home_white_bg), + iconSize: [30, 30], + iconAnchor: [15, 15] }); - L.marker([user.home.lat, user.home.lon], {icon: icon}).addTo(State.state.bm.map); + L.marker([user.home.lat, user.home.lon], {icon: icon}).addTo(State.state.bm.map) } const settings = diff --git a/assets/svg/home.svg b/assets/svg/home.svg index c27eb53..ca3ede2 100644 --- a/assets/svg/home.svg +++ b/assets/svg/home.svg @@ -1,6 +1,6 @@ - \ No newline at end of file diff --git a/assets/svg/home_white_bg.svg b/assets/svg/home_white_bg.svg new file mode 100644 index 0000000..59babf8 --- /dev/null +++ b/assets/svg/home_white_bg.svg @@ -0,0 +1,29 @@ + +image/svg+xml + + + \ No newline at end of file diff --git a/clean.sh b/clean.sh deleted file mode 100755 index e9b039e..0000000 --- a/clean.sh +++ /dev/null @@ -1,29 +0,0 @@ -#! /bin/bash - -# clean up the mess we made - # rm *.js - # rm Logic/*.js - # rm Logic/*.js - # rm Logic/*/*.js - # rm Logic/*/*/*.js - # rm UI/*.js - # rm UI/*/*.js - # rm UI/*/*/*.js - # rm Customizations/*.js - # rm Customizations/*/*.js - # rm Customizations/*/*/*.js - -rm *.webmanifest - -# rm assets/generated/* - -for f in ./*.html; do - if [[ "$f" == "./index.html" ]] || [[ "$f" == "./land.html" ]] || [[ "$f" == "./test.html" ]] || [[ "$f" == "./preferences.html" ]] || [[ "$f" == "./customGenerator.html" ]] - then - echo "Not removing $f" - else - rm $f - fi -done - -rm -rf .cache \ No newline at end of file diff --git a/createLayouts.ts b/createLayouts.ts index b4736f3..2b7c380 100644 --- a/createLayouts.ts +++ b/createLayouts.ts @@ -5,7 +5,7 @@ Img.runningFromConsole = true; UIElement.runningFromConsole = true; import {AllKnownLayouts} from "./Customizations/AllKnownLayouts"; -import {readFileSync, writeFile, writeFileSync} from "fs"; +import {existsSync, mkdirSync, readFileSync, writeFile, writeFileSync} from "fs"; import Locale from "./UI/i18n/Locale"; import svg2img from 'promise-svg2img'; import Translations from "./UI/i18n/Translations"; @@ -250,6 +250,12 @@ let wikiPage = "{|class=\"wikitable sortable\"\n" + "! Name, link !! Genre !! Covered region !! Language !! Description !! Free materials !! Image\n" + "|-"; + +const generatedDir = "./assets/generated"; +if (! existsSync(generatedDir)) { + mkdirSync(generatedDir) +} + for (const layoutName in all) { if (blacklist.indexOf(layoutName.toLowerCase()) >= 0) { console.log(`Skipping a layout with name${layoutName}, it is on the blacklist`); @@ -275,7 +281,7 @@ for (const layoutName in all) { wikiPage += "|}" -writeFile("./assets/generated/wikiIndex", wikiPage, (err) => { +writeFile(generatedDir + "/wikiIndex", wikiPage, (err) => { if (err !== null) { console.log("Could not save wikiindex", err); } diff --git a/deploy.sh b/deploy.sh deleted file mode 100755 index 222470c..0000000 --- a/deploy.sh +++ /dev/null @@ -1,42 +0,0 @@ -#! /bin/bash - -cd assets/ && wget https://osmlab.github.io/editor-layer-index/imagery.geojson --output-document=editor-layer-index.json -cd .. - -mkdir -p assets/generated -ts-node createLayouts.ts || { echo 'Creating layouts failed' ; exit 1; } -find -name '*.png' | parallel optipng '{}' -npm run build || { echo 'Npm build failed' ; exit 1; } - -rm -rf .cache - -if [[ $1 == "groen" ]] -then - echo "DEPLOYING TO BUURTNATUUR!" - mv /home/pietervdvn/git/buurtnatuur.github.io/CNAME /home/pietervdvn/git/ - mv /home/pietervdvn/git/buurtnatuur.github.io/.git /home/pietervdvn/git/ - rm -rf /home/pietervdvn/git/buurtnatuur.github.io/* - cp -r dist/* /home/pietervdvn/git/buurtnatuur.github.io/ - mv /home/pietervdvn/git/CNAME /home/pietervdvn/git/buurtnatuur.github.io/ - mv /home/pietervdvn/git/.git /home/pietervdvn/git/buurtnatuur.github.io/ - cd /home/pietervdvn/git/buurtnatuur.github.io/ -elif [[ $1 == "production" ]] -then - echo "DEPLOYING TO MAPCOMPLETE" - rm -rf /home/pietervdvn/git/pietervdvn.github.io/MapComplete/* - cp -r dist/* /home/pietervdvn/git/pietervdvn.github.io/MapComplete/ - cd /home/pietervdvn/git/pietervdvn.github.io/MapComplete/ -else - echo "Testversion deploy" - rm -rf /home/pietervdvn/git/pietervdvn.github.io/Staging/* - cp -r dist/* /home/pietervdvn/git/pietervdvn.github.io/Staging/ - cd /home/pietervdvn/git/pietervdvn.github.io/Staging/ -fi - -git add * -git commit -am "New mapcomplete version" -git push -cd - -./clean.sh - -echo "DEPLOYED $1" diff --git a/package.json b/package.json index e4a5655..92ce89b 100644 --- a/package.json +++ b/package.json @@ -13,10 +13,20 @@ ] }, "scripts": { - "start": "parcel *.html UI/** Logic/** assets/** vendor/* vendor/*/*", - "generate": "ts-node createLayouts.ts", - "build": "rm -rf dist/ && ts-node generateIncludedImages.ts && parcel build --public-url ./ *.html assets/** assets/**/** assets/**/**/** vendor/* vendor/*/*", - "test": "ts-node test/*" + "start": "parcel *.html UI/** Logic/** assets/** assets/**/** assets/**/**/** vendor/* vendor/*/*", + "test": "ts-node test/*", + "generate:editor-layer-index": "cd assets/ && wget https://osmlab.github.io/editor-layer-index/imagery.geojson --output-document=editor-layer-index.json", + "generate:images": "ts-node generateIncludedImages.ts", + "generate:layouts": "ts-node createLayouts.ts", + "optimize-images": "cd assets/generated/ && find -name '*.png' -exec optipng '{}' \\; && echo 'PNGs are optimized'", + "generate": "npm run generate:images && npm run generate:layouts && npm run generate:editor-layer-index", + "build": "rm -rf dist/ npm run generate && parcel build --public-url ./ *.html assets/** assets/**/** assets/**/**/** vendor/* vendor/*/*", + "prepare-deploy": "npm run generate && npm run build && rm -rf .cache", + "deploy:staging": "npm run prepare-deploy && rm -rf /home/pietervdvn/git/pietervdvn.github.io/Staging/* && cp -r dist/* /home/pietervdvn/git/pietervdvn.github.io/Staging/ && cd /home/pietervdvn/git/pietervdvn.github.io/ && git add * && git commit -m 'New MapComplete Version' && git push && cd - && npm run clean", + "deploy:production": "npm run prepare-deploy && npm run optimize-images && rm -rf /home/pietervdvn/git/pietervdvn.github.io/MapComplete/* && cp -r dist/* /home/pietervdvn/git/pietervdvn.github.io/MapComplete/ && cd /home/pietervdvn/git/pietervdvn.github.io/ && git add * && git commit -m 'New MapComplete Version' && git push && cd - && npm run clean", + + "clean": "rm *.webmanifest && find *.html | grep -v \"\\(index\\|land\\|test\\|preferences\\|customGenerator\\).html\" | xargs rm" + }, "keywords": [ "OpenStreetMap",