Initial commit: saint-malo navigation quiz
Build and Push Docker Image / build (push) Failing after 5m2s

This commit is contained in:
2026-06-11 10:04:44 +02:00
commit c3cc578d1c
10 changed files with 1861 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
node_modules
npm-debug.log
.git
.gitignore
.dockerignore
.gitea
Dockerfile
README.md
data/
tiles/
+42
View File
@@ -0,0 +1,42 @@
name: Build and Push Docker Image
on:
push:
branches:
- main
env:
REGISTRY: 192.168.1.240:5000
IMAGE_NAME: seaguesser
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: |
network=host
buildkitd-config-inline: |
[registry."192.168.1.240:5000"]
http = true
insecure = true
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
- name: Trigger Watchtower update
run: |
curl -X POST "http://192.168.1.240:8080/v1/update" \
-H "Authorization: Bearer ${{ secrets.WATCHTOWER_TOKEN }}" \
|| echo "Watchtower trigger failed (maybe not configured)"
+5
View File
@@ -0,0 +1,5 @@
node_modules/
data/points.json
tiles/
.DS_Store
*.log
+15
View File
@@ -0,0 +1,15 @@
FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
COPY server.js ./
COPY public/ ./public/
RUN mkdir -p data tiles
EXPOSE 4242
CMD ["node", "server.js"]
+834
View File
@@ -0,0 +1,834 @@
{
"name": "saint-malo-quiz",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "saint-malo-quiz",
"version": "1.0.0",
"dependencies": {
"express": "^4.18.2",
"sql.js": "^1.12.0"
}
},
"node_modules/accepts": {
"version": "1.3.8",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
"integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==",
"license": "MIT",
"dependencies": {
"mime-types": "~2.1.34",
"negotiator": "0.6.3"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/array-flatten": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==",
"license": "MIT"
},
"node_modules/body-parser": {
"version": "1.20.5",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.5.tgz",
"integrity": "sha512-3grm+/2tUOvu2cjJkvsIxrv/wVpfXQW4PsQHYm7yk4vfpu7Ekl6nEsYBoJUL6qDwZUx8wUhQ8tR2qz+ad9c9OA==",
"license": "MIT",
"dependencies": {
"bytes": "~3.1.2",
"content-type": "~1.0.5",
"debug": "2.6.9",
"depd": "2.0.0",
"destroy": "~1.2.0",
"http-errors": "~2.0.1",
"iconv-lite": "~0.4.24",
"on-finished": "~2.4.1",
"qs": "~6.15.1",
"raw-body": "~2.5.3",
"type-is": "~1.6.18",
"unpipe": "~1.0.0"
},
"engines": {
"node": ">= 0.8",
"npm": "1.2.8000 || >= 1.4.16"
}
},
"node_modules/bytes": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
"integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/call-bind-apply-helpers": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
"integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"function-bind": "^1.1.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/call-bound": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz",
"integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.2",
"get-intrinsic": "^1.3.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/content-disposition": {
"version": "0.5.4",
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
"integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==",
"license": "MIT",
"dependencies": {
"safe-buffer": "5.2.1"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/content-type": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz",
"integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/cookie": {
"version": "0.7.2",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz",
"integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/cookie-signature": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.7.tgz",
"integrity": "sha512-NXdYc3dLr47pBkpUCHtKSwIOQXLVn8dZEuywboCOJY/osA0wFSLlSawr3KN8qXJEyX66FcONTH8EIlVuK0yyFA==",
"license": "MIT"
},
"node_modules/debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"license": "MIT",
"dependencies": {
"ms": "2.0.0"
}
},
"node_modules/depd": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
"integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/destroy": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz",
"integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==",
"license": "MIT",
"engines": {
"node": ">= 0.8",
"npm": "1.2.8000 || >= 1.4.16"
}
},
"node_modules/dunder-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
"integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.1",
"es-errors": "^1.3.0",
"gopd": "^1.2.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
"integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==",
"license": "MIT"
},
"node_modules/encodeurl": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz",
"integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/es-define-property": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
"integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-errors": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-object-atoms": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz",
"integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/escape-html": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
"integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==",
"license": "MIT"
},
"node_modules/etag": {
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
"integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/express": {
"version": "4.22.2",
"resolved": "https://registry.npmjs.org/express/-/express-4.22.2.tgz",
"integrity": "sha512-IuL+Elrou2ZvCFHs18/CIzy2Nzvo25nZ1/D2eIZlz7c+QUayAcYoiM2BthCjs+EBHVpjYjcuLDAiCWgeIX3X1Q==",
"license": "MIT",
"dependencies": {
"accepts": "~1.3.8",
"array-flatten": "1.1.1",
"body-parser": "~1.20.5",
"content-disposition": "~0.5.4",
"content-type": "~1.0.4",
"cookie": "~0.7.1",
"cookie-signature": "~1.0.6",
"debug": "2.6.9",
"depd": "2.0.0",
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"finalhandler": "~1.3.1",
"fresh": "~0.5.2",
"http-errors": "~2.0.0",
"merge-descriptors": "1.0.3",
"methods": "~1.1.2",
"on-finished": "~2.4.1",
"parseurl": "~1.3.3",
"path-to-regexp": "~0.1.12",
"proxy-addr": "~2.0.7",
"qs": "~6.15.1",
"range-parser": "~1.2.1",
"safe-buffer": "5.2.1",
"send": "~0.19.0",
"serve-static": "~1.16.2",
"setprototypeof": "1.2.0",
"statuses": "~2.0.1",
"type-is": "~1.6.18",
"utils-merge": "1.0.1",
"vary": "~1.1.2"
},
"engines": {
"node": ">= 0.10.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/finalhandler": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.2.tgz",
"integrity": "sha512-aA4RyPcd3badbdABGDuTXCMTtOneUCAYH/gxoYRTZlIJdF0YPWuGqiAsIrhNnnqdXGswYk6dGujem4w80UJFhg==",
"license": "MIT",
"dependencies": {
"debug": "2.6.9",
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"on-finished": "~2.4.1",
"parseurl": "~1.3.3",
"statuses": "~2.0.2",
"unpipe": "~1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/forwarded": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
"integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/fresh": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
"integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/function-bind": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/get-intrinsic": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
"integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.2",
"es-define-property": "^1.0.1",
"es-errors": "^1.3.0",
"es-object-atoms": "^1.1.1",
"function-bind": "^1.1.2",
"get-proto": "^1.0.1",
"gopd": "^1.2.0",
"has-symbols": "^1.1.0",
"hasown": "^2.0.2",
"math-intrinsics": "^1.1.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/get-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",
"integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
"license": "MIT",
"dependencies": {
"dunder-proto": "^1.0.1",
"es-object-atoms": "^1.0.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/gopd": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
"integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/has-symbols": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
"integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/hasown": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz",
"integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==",
"license": "MIT",
"dependencies": {
"function-bind": "^1.1.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/http-errors": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz",
"integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==",
"license": "MIT",
"dependencies": {
"depd": "~2.0.0",
"inherits": "~2.0.4",
"setprototypeof": "~1.2.0",
"statuses": "~2.0.2",
"toidentifier": "~1.0.1"
},
"engines": {
"node": ">= 0.8"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/iconv-lite": {
"version": "0.4.24",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
"integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
"license": "MIT",
"dependencies": {
"safer-buffer": ">= 2.1.2 < 3"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
"license": "ISC"
},
"node_modules/ipaddr.js": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
"integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
"license": "MIT",
"engines": {
"node": ">= 0.10"
}
},
"node_modules/math-intrinsics": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
"integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
"integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/merge-descriptors": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz",
"integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/methods": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
"integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
"license": "MIT",
"bin": {
"mime": "cli.js"
},
"engines": {
"node": ">=4"
}
},
"node_modules/mime-db": {
"version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime-types": {
"version": "2.1.35",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"license": "MIT",
"dependencies": {
"mime-db": "1.52.0"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
"license": "MIT"
},
"node_modules/negotiator": {
"version": "0.6.3",
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
"integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/object-inspect": {
"version": "1.13.4",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz",
"integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/on-finished": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
"integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==",
"license": "MIT",
"dependencies": {
"ee-first": "1.1.1"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/parseurl": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
"integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/path-to-regexp": {
"version": "0.1.13",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.13.tgz",
"integrity": "sha512-A/AGNMFN3c8bOlvV9RreMdrv7jsmF9XIfDeCd87+I8RNg6s78BhJxMu69NEMHBSJFxKidViTEdruRwEk/WIKqA==",
"license": "MIT"
},
"node_modules/proxy-addr": {
"version": "2.0.7",
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
"integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
"license": "MIT",
"dependencies": {
"forwarded": "0.2.0",
"ipaddr.js": "1.9.1"
},
"engines": {
"node": ">= 0.10"
}
},
"node_modules/qs": {
"version": "6.15.2",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.15.2.tgz",
"integrity": "sha512-Rzq0KEyX/w/tEybncDgdkZrJgVUsUMk3xjh3t5bv3S1HTAtg+uOYt72+ZfwiQwKdysThkTBdL/rTi6HDmX9Ddw==",
"license": "BSD-3-Clause",
"dependencies": {
"side-channel": "^1.1.0"
},
"engines": {
"node": ">=0.6"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/range-parser": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
"integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/raw-body": {
"version": "2.5.3",
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.3.tgz",
"integrity": "sha512-s4VSOf6yN0rvbRZGxs8Om5CWj6seneMwK3oDb4lWDH0UPhWcxwOWw5+qk24bxq87szX1ydrwylIOp2uG1ojUpA==",
"license": "MIT",
"dependencies": {
"bytes": "~3.1.2",
"http-errors": "~2.0.1",
"iconv-lite": "~0.4.24",
"unpipe": "~1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"license": "MIT"
},
"node_modules/safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
"license": "MIT"
},
"node_modules/send": {
"version": "0.19.2",
"resolved": "https://registry.npmjs.org/send/-/send-0.19.2.tgz",
"integrity": "sha512-VMbMxbDeehAxpOtWJXlcUS5E8iXh6QmN+BkRX1GARS3wRaXEEgzCcB10gTQazO42tpNIya8xIyNx8fll1OFPrg==",
"license": "MIT",
"dependencies": {
"debug": "2.6.9",
"depd": "2.0.0",
"destroy": "1.2.0",
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"fresh": "~0.5.2",
"http-errors": "~2.0.1",
"mime": "1.6.0",
"ms": "2.1.3",
"on-finished": "~2.4.1",
"range-parser": "~1.2.1",
"statuses": "~2.0.2"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/send/node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
"license": "MIT"
},
"node_modules/serve-static": {
"version": "1.16.3",
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.3.tgz",
"integrity": "sha512-x0RTqQel6g5SY7Lg6ZreMmsOzncHFU7nhnRWkKgWuMTu5NN0DR5oruckMqRvacAN9d5w6ARnRBXl9xhDCgfMeA==",
"license": "MIT",
"dependencies": {
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"parseurl": "~1.3.3",
"send": "~0.19.1"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/setprototypeof": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
"integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==",
"license": "ISC"
},
"node_modules/side-channel": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz",
"integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"object-inspect": "^1.13.3",
"side-channel-list": "^1.0.0",
"side-channel-map": "^1.0.1",
"side-channel-weakmap": "^1.0.2"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-list": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz",
"integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"object-inspect": "^1.13.4"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-map": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz",
"integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==",
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.2",
"es-errors": "^1.3.0",
"get-intrinsic": "^1.2.5",
"object-inspect": "^1.13.3"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-weakmap": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz",
"integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==",
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.2",
"es-errors": "^1.3.0",
"get-intrinsic": "^1.2.5",
"object-inspect": "^1.13.3",
"side-channel-map": "^1.0.1"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/sql.js": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/sql.js/-/sql.js-1.14.1.tgz",
"integrity": "sha512-gcj8zBWU5cFsi9WUP+4bFNXAyF1iRpA3LLyS/DP5xlrNzGmPIizUeBggKa8DbDwdqaKwUcTEnChtd2grWo/x/A==",
"license": "MIT"
},
"node_modules/statuses": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz",
"integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/toidentifier": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
"integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==",
"license": "MIT",
"engines": {
"node": ">=0.6"
}
},
"node_modules/type-is": {
"version": "1.6.18",
"resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
"integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
"license": "MIT",
"dependencies": {
"media-typer": "0.3.0",
"mime-types": "~2.1.24"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/unpipe": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
"integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/utils-merge": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
"integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==",
"license": "MIT",
"engines": {
"node": ">= 0.4.0"
}
},
"node_modules/vary": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
"integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
}
}
}
+14
View File
@@ -0,0 +1,14 @@
{
"name": "saint-malo-quiz",
"version": "1.0.0",
"description": "Quiz de navigation - Baie de Saint-Malo",
"main": "server.js",
"scripts": {
"start": "node server.js",
"dev": "node --watch server.js"
},
"dependencies": {
"sql.js": "^1.12.0",
"express": "^4.18.2"
}
}
+296
View File
@@ -0,0 +1,296 @@
const SAINT_MALO = [48.649, -2.025];
const CATEGORY_ICONS = {
'bouée': '🟢', 'pointe': '📍', 'plage': '🏖', 'île': '🏝',
'port': '⚓', 'fort': '🏰', 'chenal': '🔵', 'anse': '🌊',
'rocher': '⬛', 'autre': '📌'
};
let map, mode = 'quiz', points = [];
const editMarkers = new Map();
// Quiz state
let quizQueue = [], quizCurrent = null, quizScore = 0, quizTotal = 0;
let quizAnswered = false;
let userMarker = null, correctMarker = null, feedbackLine = null;
let pendingLatLng = null;
async function init() {
const status = await fetch('/api/status').then(r => r.json());
map = L.map('map', { center: SAINT_MALO, zoom: 12 });
const src = status.hasMbtiles ? `MBTiles local (${status.name || 'SHOM'})` : 'SHOM en ligne';
document.getElementById('tiles-status').textContent = `🗺 ${src}`;
L.tileLayer('/tiles/{z}/{x}/{y}', {
minZoom: 6, maxZoom: 17, attribution: '© SHOM'
}).addTo(map);
map.on('click', onMapClick);
await loadPoints();
setMode('quiz');
}
// ── Mode ────────────────────────────────────────────────────────────────────
function setMode(newMode) {
mode = newMode;
document.getElementById('btn-quiz').classList.toggle('active', mode === 'quiz');
document.getElementById('btn-edit').classList.toggle('active', mode === 'edit');
document.getElementById('quiz-panel').style.display = mode === 'quiz' ? 'flex' : 'none';
document.getElementById('edit-panel').style.display = mode === 'edit' ? 'flex' : 'none';
document.getElementById('map').classList.toggle('edit-cursor', mode === 'edit');
clearFeedback();
renderEditMarkers();
if (mode === 'quiz') startQuiz();
}
// ── Map click ────────────────────────────────────────────────────────────────
function onMapClick(e) {
if (mode === 'edit') {
pendingLatLng = e.latlng;
openModal(null);
} else if (mode === 'quiz' && quizCurrent && !quizAnswered) {
submitAnswer(e.latlng);
}
}
// ── Points API ───────────────────────────────────────────────────────────────
async function loadPoints() {
points = await fetch('/api/points').then(r => r.json());
document.getElementById('points-count').textContent = points.length;
renderPointsList();
renderEditMarkers();
}
async function saveNewPoint(data) {
const pt = await fetch('/api/points', {
method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data)
}).then(r => r.json());
return pt;
}
async function updatePoint(id, data) {
await fetch(`/api/points/${id}`, {
method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data)
});
}
async function deletePoint(id) {
if (!confirm('Supprimer ce point ?')) return;
await fetch(`/api/points/${id}`, { method: 'DELETE' });
await loadPoints();
}
// ── Edit markers ─────────────────────────────────────────────────────────────
function makeIcon(category) {
return L.divIcon({
html: `<div class="map-pin">${CATEGORY_ICONS[category] || '📌'}</div>`,
className: '', iconSize: [24, 24], iconAnchor: [12, 12]
});
}
function renderEditMarkers() {
editMarkers.forEach(m => map.removeLayer(m));
editMarkers.clear();
if (mode !== 'edit') return;
points.forEach(p => {
const m = L.marker([p.lat, p.lng], { icon: makeIcon(p.category) })
.bindTooltip(p.name, { direction: 'top' })
.on('click', e => { L.DomEvent.stopPropagation(e); openModal(p); })
.addTo(map);
editMarkers.set(p.id, m);
});
}
// ── Points list (edit panel) ──────────────────────────────────────────────────
function renderPointsList() {
const list = document.getElementById('points-list');
if (points.length === 0) {
list.innerHTML = '<div class="empty-list">Aucun point encore.</div>';
return;
}
list.innerHTML = points.map(p => `
<div class="point-item">
<span style="font-size:1.1rem;flex-shrink:0">${CATEGORY_ICONS[p.category] || '📌'}</span>
<div class="point-item-info">
<div class="point-item-name">${escHtml(p.name)}</div>
<div class="point-item-cat">${p.category}</div>
</div>
<div class="point-item-actions">
<button class="btn-icon" title="Centrer" onclick="flyTo('${p.id}')">🎯</button>
<button class="btn-icon" title="Modifier" onclick="openModal(getPoint('${p.id}'))">✏️</button>
<button class="btn-icon del" title="Supprimer" onclick="deletePoint('${p.id}')">🗑</button>
</div>
</div>
`).join('');
}
function getPoint(id) { return points.find(p => p.id === id); }
function flyTo(id) {
const p = getPoint(id);
if (p) map.flyTo([p.lat, p.lng], 14);
}
function escHtml(s) {
return s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
}
// ── Modal ────────────────────────────────────────────────────────────────────
function openModal(point) {
document.getElementById('modal-title').textContent = point ? 'Modifier le point' : 'Ajouter un point';
document.getElementById('point-id').value = point?.id || '';
document.getElementById('point-lat').value = point ? point.lat : (pendingLatLng?.lat || '');
document.getElementById('point-lng').value = point ? point.lng : (pendingLatLng?.lng || '');
document.getElementById('point-name').value = point?.name || '';
document.getElementById('point-category').value = point?.category || 'bouée';
document.getElementById('point-hint').value = point?.hint || '';
document.getElementById('modal-overlay').style.display = 'flex';
setTimeout(() => document.getElementById('point-name').focus(), 50);
}
function closeModal() {
document.getElementById('modal-overlay').style.display = 'none';
pendingLatLng = null;
}
function handleOverlayClick(e) {
if (e.target === document.getElementById('modal-overlay')) closeModal();
}
document.getElementById('point-form').addEventListener('submit', async e => {
e.preventDefault();
const id = document.getElementById('point-id').value;
const data = {
name: document.getElementById('point-name').value.trim(),
category: document.getElementById('point-category').value,
hint: document.getElementById('point-hint').value.trim(),
lat: parseFloat(document.getElementById('point-lat').value),
lng: parseFloat(document.getElementById('point-lng').value)
};
if (id) await updatePoint(id, data);
else await saveNewPoint(data);
closeModal();
await loadPoints();
});
// ── Quiz ─────────────────────────────────────────────────────────────────────
function startQuiz() {
clearFeedback();
if (points.length === 0) {
show('quiz-empty'); hide('quiz-question'); hide('quiz-end');
return;
}
quizQueue = shuffle([...points]);
quizScore = 0;
quizTotal = 0;
hide('quiz-empty');
show('quiz-question');
hide('quiz-feedback');
nextQuestion();
}
function nextQuestion() {
clearFeedback();
quizAnswered = false;
if (quizQueue.length === 0) {
quizQueue = shuffle([...points]);
}
quizCurrent = quizQueue.shift();
quizTotal++;
document.getElementById('quiz-name').textContent = quizCurrent.name;
document.getElementById('quiz-category').textContent = quizCurrent.category;
document.getElementById('quiz-hint').textContent = quizCurrent.hint || '';
document.getElementById('quiz-instruction').style.display = 'block';
hide('quiz-feedback');
updateScoreDisplay();
}
function submitAnswer(latlng) {
if (!quizCurrent || quizAnswered) return;
quizAnswered = true;
const correct = L.latLng(quizCurrent.lat, quizCurrent.lng);
const distM = latlng.distanceTo(correct);
const distNm = distM / 1852;
// User click marker
userMarker = L.circleMarker(latlng, {
radius: 8, color: '#f39c12', fillColor: '#f39c12', fillOpacity: 0.85, weight: 2
}).addTo(map);
// Correct location marker
correctMarker = L.circleMarker(correct, {
radius: 8, color: '#2ecc71', fillColor: '#2ecc71', fillOpacity: 0.85, weight: 2
}).bindTooltip(quizCurrent.name, { permanent: true, direction: 'top', offset: [0, -10] }).addTo(map);
// Dashed line
feedbackLine = L.polyline([latlng, correct], {
color: '#fff', weight: 1.5, dashArray: '5 5', opacity: 0.4
}).addTo(map);
// Scoring
let pts, label, color;
if (distNm < 0.1) { pts = 100; label = '⭐ Excellent !'; color = 'var(--green)'; }
else if (distNm < 0.5) { pts = 80; label = '👍 Très bien'; color = 'var(--green)'; }
else if (distNm < 1.0) { pts = 60; label = '👌 Bien'; color = 'var(--yellow)'; }
else if (distNm < 3.0) { pts = 30; label = '🤔 Passable'; color = 'var(--orange)'; }
else { pts = 0; label = '❌ À revoir'; color = 'var(--red)'; }
quizScore += pts;
updateScoreDisplay();
const distStr = distNm < 0.1 ? `${Math.round(distM)} m` : `${distNm.toFixed(2)} Nm`;
document.getElementById('feedback-distance').textContent = `Distance : ${distStr}`;
document.getElementById('feedback-label').textContent = label;
document.getElementById('feedback-label').style.color = color;
document.getElementById('quiz-instruction').style.display = 'none';
show('quiz-feedback');
// Fit both points in view
map.fitBounds(L.latLngBounds([latlng, correct]).pad(0.4), { maxZoom: 14 });
}
function clearFeedback() {
if (userMarker) { map.removeLayer(userMarker); userMarker = null; }
if (correctMarker) { map.removeLayer(correctMarker); correctMarker = null; }
if (feedbackLine) { map.removeLayer(feedbackLine); feedbackLine = null; }
}
function updateScoreDisplay() {
document.getElementById('score-value').textContent = quizScore;
const remaining = quizQueue.length;
document.getElementById('quiz-progress').textContent =
`${quizTotal} / ${quizTotal + remaining} questions`;
}
// ── Utils ────────────────────────────────────────────────────────────────────
function show(id) { document.getElementById(id).style.display = ''; }
function hide(id) { document.getElementById(id).style.display = 'none'; }
function shuffle(arr) { return arr.sort(() => Math.random() - 0.5); }
document.addEventListener('keydown', e => {
if (e.code === 'Space' || e.code === 'Enter') {
if (mode === 'quiz' && quizAnswered) { e.preventDefault(); nextQuestion(); }
}
});
init();
+101
View File
@@ -0,0 +1,101 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Saint-Malo — Quiz Navigation</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="app">
<header id="topbar">
<div id="logo">⚓ Saint-Malo Quiz</div>
<div id="mode-toggle">
<button id="btn-quiz" class="active" onclick="setMode('quiz')">Quiz</button>
<button id="btn-edit" onclick="setMode('edit')">Éditer</button>
</div>
<div id="tiles-status"></div>
</header>
<div id="main">
<div id="map"></div>
<!-- Quiz panel -->
<div id="quiz-panel" class="panel">
<div id="quiz-empty">
<div class="empty-icon">🧭</div>
<p>Aucun point à quizzer.<br>Passez en mode <strong>Éditer</strong> pour ajouter des points.</p>
</div>
<div id="quiz-question" style="display:none">
<div id="quiz-score">
<span id="score-value">0</span> pts
<span id="quiz-progress"></span>
</div>
<div id="quiz-prompt">Où se trouve…</div>
<div id="quiz-name"></div>
<div id="quiz-category"></div>
<div id="quiz-hint"></div>
<div id="quiz-instruction">Cliquez sur la carte</div>
<div id="quiz-feedback">
<div id="feedback-distance"></div>
<div id="feedback-label"></div>
<button id="btn-next" onclick="nextQuestion()">Question suivante →</button>
</div>
</div>
</div>
<!-- Edit panel -->
<div id="edit-panel" class="panel" style="display:none">
<div class="panel-header">
<span>Points (<span id="points-count">0</span>)</span>
<span class="panel-hint">Cliquez sur la carte pour ajouter</span>
</div>
<div id="points-list"></div>
</div>
</div>
</div>
<!-- Modal ajout/édition -->
<div id="modal-overlay" style="display:none" onclick="handleOverlayClick(event)">
<div id="modal">
<h3 id="modal-title">Ajouter un point</h3>
<form id="point-form">
<input type="hidden" id="point-id">
<input type="hidden" id="point-lat">
<input type="hidden" id="point-lng">
<div class="form-group">
<label>Nom</label>
<input type="text" id="point-name" required placeholder="ex : Pointe du Meinga" autocomplete="off">
</div>
<div class="form-group">
<label>Catégorie</label>
<select id="point-category">
<option value="bouée">🟢 Bouée</option>
<option value="pointe">📍 Pointe / Cap</option>
<option value="plage">🏖 Plage</option>
<option value="île">🏝 Île / Îlot</option>
<option value="port">⚓ Port / Quai</option>
<option value="fort">🏰 Fort / Monument</option>
<option value="chenal">🔵 Chenal / Passe</option>
<option value="anse">🌊 Anse / Baie</option>
<option value="rocher">⬛ Rocher / Écueil</option>
<option value="autre">📌 Autre</option>
</select>
</div>
<div class="form-group">
<label>Indice (affiché pendant le quiz)</label>
<input type="text" id="point-hint" placeholder="ex : au nord de Dinard" autocomplete="off">
</div>
<div class="form-actions">
<button type="button" class="btn-cancel" onclick="closeModal()">Annuler</button>
<button type="submit" class="btn-primary">Enregistrer</button>
</div>
</form>
</div>
</div>
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
<script src="app.js"></script>
</body>
</html>
+417
View File
@@ -0,0 +1,417 @@
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
--bg: #0a1628;
--surface: #0d1f3c;
--border: #1e3a5f;
--blue: #4a9ece;
--blue-dark: #3a8abe;
--text: #e8f4f8;
--muted: #8ab4cc;
--dim: #4a6a82;
--green: #2ecc71;
--yellow: #f39c12;
--orange: #e67e22;
--red: #e74c3c;
}
body {
font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
background: var(--bg);
color: var(--text);
height: 100vh;
overflow: hidden;
}
#app { display: flex; flex-direction: column; height: 100vh; }
/* Topbar */
#topbar {
display: flex;
align-items: center;
gap: 16px;
padding: 0 16px;
height: 50px;
background: var(--surface);
border-bottom: 1px solid var(--border);
flex-shrink: 0;
z-index: 10;
}
#logo {
font-size: 1rem;
font-weight: 700;
color: var(--blue);
letter-spacing: 0.3px;
white-space: nowrap;
}
#mode-toggle {
display: flex;
background: var(--bg);
border-radius: 6px;
padding: 3px;
gap: 2px;
}
#mode-toggle button {
padding: 4px 14px;
border: none;
border-radius: 4px;
background: transparent;
color: var(--muted);
cursor: pointer;
font-size: 0.85rem;
transition: all 0.15s;
}
#mode-toggle button.active {
background: var(--blue);
color: #fff;
font-weight: 600;
}
#tiles-status {
margin-left: auto;
font-size: 0.72rem;
color: var(--dim);
white-space: nowrap;
}
/* Main layout */
#main {
display: flex;
flex: 1;
overflow: hidden;
}
#map { flex: 1; }
#map.edit-cursor { cursor: crosshair !important; }
/* Panel */
.panel {
width: 270px;
min-width: 270px;
background: var(--surface);
border-left: 1px solid var(--border);
display: flex;
flex-direction: column;
overflow: hidden;
}
/* Quiz panel */
#quiz-empty, #quiz-end {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
flex: 1;
padding: 24px 20px;
text-align: center;
gap: 12px;
color: var(--muted);
font-size: 0.875rem;
line-height: 1.6;
}
.empty-icon { font-size: 2.5rem; }
#quiz-end { gap: 16px; }
#final-score {
font-size: 2rem;
font-weight: 700;
color: var(--blue);
}
#btn-restart {
padding: 10px 20px;
background: var(--blue);
color: #fff;
border: none;
border-radius: 6px;
cursor: pointer;
font-size: 0.875rem;
font-weight: 600;
}
#quiz-question {
display: flex;
flex-direction: column;
padding: 16px;
gap: 6px;
flex: 1;
}
#quiz-score {
font-size: 0.78rem;
color: var(--dim);
display: flex;
align-items: center;
gap: 6px;
padding-bottom: 6px;
border-bottom: 1px solid var(--border);
}
#score-value {
font-size: 1rem;
font-weight: 700;
color: var(--blue);
}
#quiz-progress { margin-left: auto; }
#quiz-prompt {
font-size: 0.78rem;
color: var(--muted);
margin-top: 10px;
text-transform: uppercase;
letter-spacing: 0.5px;
}
#quiz-name {
font-size: 1.5rem;
font-weight: 700;
line-height: 1.2;
color: var(--text);
}
#quiz-category {
font-size: 0.75rem;
color: var(--blue);
font-weight: 500;
}
#quiz-hint {
font-size: 0.8rem;
color: var(--dim);
font-style: italic;
min-height: 16px;
}
#quiz-instruction {
margin-top: 8px;
font-size: 0.82rem;
color: var(--muted);
background: rgba(74,158,206,0.08);
border: 1px dashed var(--border);
border-radius: 6px;
padding: 8px 12px;
text-align: center;
}
#quiz-feedback {
display: none;
flex-direction: column;
gap: 8px;
margin-top: 10px;
padding-top: 12px;
border-top: 1px solid var(--border);
}
#feedback-distance {
font-size: 0.9rem;
color: var(--muted);
}
#feedback-label {
font-size: 1.5rem;
font-weight: 700;
}
#btn-next {
width: 100%;
padding: 10px;
background: var(--blue);
color: #fff;
border: none;
border-radius: 6px;
cursor: pointer;
font-size: 0.875rem;
font-weight: 600;
transition: background 0.15s;
}
#btn-next:hover { background: var(--blue-dark); }
/* Edit panel */
.panel-header {
padding: 12px 16px;
border-bottom: 1px solid var(--border);
display: flex;
flex-direction: column;
gap: 2px;
font-size: 0.85rem;
font-weight: 600;
flex-shrink: 0;
}
.panel-hint {
font-size: 0.75rem;
color: var(--dim);
font-weight: 400;
}
#points-list {
flex: 1;
overflow-y: auto;
padding: 8px;
display: flex;
flex-direction: column;
gap: 4px;
}
#points-list::-webkit-scrollbar { width: 4px; }
#points-list::-webkit-scrollbar-track { background: transparent; }
#points-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.point-item {
display: flex;
align-items: center;
gap: 8px;
background: var(--bg);
border-radius: 6px;
padding: 8px 10px;
font-size: 0.8rem;
}
.point-item-info { flex: 1; min-width: 0; }
.point-item-name {
font-weight: 600;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
color: var(--text);
}
.point-item-cat {
font-size: 0.7rem;
color: var(--dim);
margin-top: 1px;
}
.point-item-actions {
display: flex;
gap: 2px;
flex-shrink: 0;
}
.btn-icon {
background: none;
border: none;
color: var(--dim);
cursor: pointer;
font-size: 0.95rem;
padding: 3px 5px;
border-radius: 4px;
transition: all 0.1s;
line-height: 1;
}
.btn-icon:hover { background: var(--border); color: var(--text); }
.btn-icon.del:hover { background: rgba(231,76,60,0.15); color: var(--red); }
.empty-list {
font-size: 0.8rem;
color: var(--dim);
text-align: center;
padding: 20px;
}
/* Modal */
#modal-overlay {
position: fixed;
inset: 0;
background: rgba(0,0,0,0.65);
display: flex;
align-items: center;
justify-content: center;
z-index: 1000;
}
#modal {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 10px;
padding: 22px 24px;
width: 340px;
max-width: 90vw;
}
#modal h3 {
margin-bottom: 18px;
color: var(--blue);
font-size: 1rem;
}
.form-group { margin-bottom: 12px; }
.form-group label {
display: block;
font-size: 0.78rem;
color: var(--muted);
margin-bottom: 4px;
}
.form-group input,
.form-group select {
width: 100%;
padding: 8px 10px;
background: var(--bg);
border: 1px solid var(--border);
border-radius: 6px;
color: var(--text);
font-size: 0.875rem;
transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus {
outline: none;
border-color: var(--blue);
}
.form-group select option { background: var(--bg); }
.form-actions {
display: flex;
gap: 8px;
justify-content: flex-end;
margin-top: 18px;
}
.form-actions button {
padding: 8px 16px;
border-radius: 6px;
cursor: pointer;
font-size: 0.85rem;
transition: all 0.15s;
}
.btn-cancel {
background: transparent;
border: 1px solid var(--border);
color: var(--muted);
}
.btn-cancel:hover { border-color: var(--muted); }
.btn-primary {
background: var(--blue);
border: 1px solid var(--blue);
color: #fff;
font-weight: 600;
}
.btn-primary:hover { background: var(--blue-dark); }
/* Map markers */
.map-pin {
font-size: 20px;
line-height: 1;
text-align: center;
filter: drop-shadow(0 1px 3px rgba(0,0,0,0.6));
cursor: pointer;
}
+127
View File
@@ -0,0 +1,127 @@
const express = require('express');
const https = require('https');
const path = require('path');
const fs = require('fs');
const app = express();
app.use(express.json());
app.use(express.static(path.join(__dirname, 'public')));
const POINTS_FILE = path.join(__dirname, 'data', 'points.json');
const TILES_DIR = path.join(__dirname, 'tiles');
const SHOM_BASE = 'https://services.data.shom.fr/clevisu/wmts?layer=RASTER_MARINE_3857_WMTS&style=normal&tilematrixset=3857&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image%2Fpng';
const SHOM_HEADERS = {
'Referer': 'https://data.shom.fr',
'Origin': 'https://data.shom.fr',
'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/114.0',
'Accept': 'image/png'
};
let db = null;
let mbtilesMeta = {};
let tileStmt = null;
async function initMbtiles() {
try {
const files = fs.readdirSync(TILES_DIR).filter(f => f.endsWith('.mbtiles'));
if (files.length === 0) return;
const initSqlJs = require('sql.js');
const SQL = await initSqlJs();
const buf = fs.readFileSync(path.join(TILES_DIR, files[0]));
db = new SQL.Database(buf);
db.each('SELECT name, value FROM metadata', [], (row) => {
mbtilesMeta[row.name] = row.value;
});
tileStmt = db.prepare(
'SELECT tile_data FROM tiles WHERE zoom_level=? AND tile_column=? AND tile_row=?'
);
console.log(`✓ MBTiles : ${files[0]} (zoom ${mbtilesMeta.minzoom}${mbtilesMeta.maxzoom})`);
} catch (e) {
console.log('Pas de MBTiles local, utilisation du flux SHOM en ligne.');
}
}
function proxyShom(z, x, y, res) {
const url = `${SHOM_BASE}&TileMatrix=${z}&TileCol=${x}&TileRow=${y}`;
https.get(url, { headers: SHOM_HEADERS }, (upstream) => {
if (upstream.statusCode !== 200) return res.status(upstream.statusCode).end();
res.set('Content-Type', 'image/png');
res.set('Cache-Control', 'public, max-age=86400');
upstream.pipe(res);
}).on('error', () => res.status(502).end());
}
initMbtiles().then(startServer);
app.get('/api/status', (req, res) => {
res.json({
hasMbtiles: !!db,
name: mbtilesMeta.name || null,
minZoom: parseInt(mbtilesMeta.minzoom) || 6,
maxZoom: parseInt(mbtilesMeta.maxzoom) || 17
});
});
app.get('/tiles/:z/:x/:y', (req, res) => {
const z = parseInt(req.params.z);
const x = parseInt(req.params.x);
const y = parseInt(req.params.y);
if (tileStmt) {
const tmsY = (1 << z) - 1 - y;
try {
tileStmt.bind([z, x, tmsY]);
if (!tileStmt.step()) { tileStmt.reset(); return proxyShom(z, x, y, res); }
const row = tileStmt.getAsObject();
tileStmt.reset();
const fmt = mbtilesMeta.format || 'png';
res.set('Content-Type', fmt === 'jpg' || fmt === 'jpeg' ? 'image/jpeg' : 'image/png');
res.set('Cache-Control', 'public, max-age=86400');
res.send(Buffer.from(row.tile_data));
} catch (e) {
tileStmt.reset();
proxyShom(z, x, y, res);
}
} else {
proxyShom(z, x, y, res);
}
});
function loadPoints() {
if (!fs.existsSync(POINTS_FILE)) return [];
try { return JSON.parse(fs.readFileSync(POINTS_FILE, 'utf8')); }
catch { return []; }
}
function savePoints(pts) {
fs.writeFileSync(POINTS_FILE, JSON.stringify(pts, null, 2));
}
app.get('/api/points', (req, res) => res.json(loadPoints()));
app.post('/api/points', (req, res) => {
const pts = loadPoints();
const pt = { id: `${Date.now()}-${Math.random().toString(36).slice(2, 7)}`, ...req.body };
pts.push(pt);
savePoints(pts);
res.json(pt);
});
app.put('/api/points/:id', (req, res) => {
const pts = loadPoints();
const i = pts.findIndex(p => p.id === req.params.id);
if (i === -1) return res.status(404).json({ error: 'Not found' });
pts[i] = { ...pts[i], ...req.body };
savePoints(pts);
res.json(pts[i]);
});
app.delete('/api/points/:id', (req, res) => {
savePoints(loadPoints().filter(p => p.id !== req.params.id));
res.json({ ok: true });
});
function startServer() {
app.listen(4242, () => console.log('\n⚓ Saint-Malo Quiz → http://localhost:4242\n'));
}