Merge branch 'develop'

This commit is contained in:
Pieter Vander Vennet 2024-01-07 18:23:12 +01:00
commit be0154bfe5
86 changed files with 1669 additions and 512 deletions

View file

@ -284,7 +284,7 @@ async function generateCsp(
if (typeof sv.needsUrls === "function") {
return
}
apiUrls.push(...sv.needsUrls)
apiUrls.push(...(sv.needsUrls ?? []))
})
const usedSpecialVisualisations = ValidationUtils.getSpecialVisualisationsWithArgs(layoutJson)
@ -292,7 +292,7 @@ async function generateCsp(
if (typeof usedSpecialVisualisation === "string") {
continue
}
const neededUrls = usedSpecialVisualisation.func.needsUrls
const neededUrls = usedSpecialVisualisation.func.needsUrls ?? []
if (typeof neededUrls === "function") {
apiUrls.push(...neededUrls(usedSpecialVisualisation.args))
}

View file

@ -4,6 +4,10 @@ import { Review } from "mangrove-reviews-typescript"
import { parse } from "csv-parse"
import { Feature, FeatureCollection, Point } from "geojson"
/**
* To be run from the repository root, e.g.
* vite-node scripts/generateReviewsAnalysis.ts -- ~/Downloads/mangrove.reviews_1704031255.csv
*/
export default class GenerateReviewsAnalysis extends Script {
constructor() {
super("Analyses a CSV-file with Mangrove reviews")
@ -104,6 +108,11 @@ export default class GenerateReviewsAnalysis extends Script {
}
async main(args: string[]): Promise<void> {
if (args.length === 0) {
console.log(
"Usage: enter file path of mangrove.reviews_timestamp.csv as first argument"
)
}
const datapath = args[0] ?? "../MapComplete-data/mangrove.reviews_1674234503.csv"
await this.analyze(datapath)
}

View file

@ -28,3 +28,15 @@ studio.mapcomplete.org {
to http://127.0.0.1:1235
}
}
bounce.mapcomplete.org {
reverse_proxy {
to http://127.0.0.1:1236
}
}
mapcomplete.osm.be {
reverse_proxy {
to http://127.0.0.1:1236
}
}

View file

@ -0,0 +1,45 @@
import * as http from "node:http"
/**
* Redirect people from
* "mapcomplete.osm.be/path?query=parameter#id" to "mapcomplete.org/path?query=parameter#id"
*/
const PORT = 1236
const CORS = "http://localhost:1234,https://mapcomplete.org,https://dev.mapcomplete.org"
async function redirect(req: http.IncomingMessage, res: http.ServerResponse) {
try {
console.log(
req.method + " " + req.url,
"from:",
req.headers.origin,
new Date().toISOString()
)
res.setHeader(
"Access-Control-Allow-Headers",
"Origin, X-Requested-With, Content-Type, Accept"
)
res.setHeader("Access-Control-Allow-Origin", req.headers.origin ?? "*")
if (req.method === "OPTIONS") {
res.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE, UPDATE")
res.writeHead(204, { "Content-Type": "text/html" })
res.end()
return
}
console.log("Request url:", req.url)
const oldUrl = new URL("https://127.0.0.1:8080" + req.url)
const newUrl = "https://mapcomplete.org" + oldUrl.pathname + oldUrl.search + oldUrl.hash
res.writeHead(301, { "Content-Type": "text/html", Location: newUrl })
res.write("Moved permantently")
res.end()
} catch (e) {
console.error(e)
}
}
http.createServer(redirect).listen(PORT)
console.log(
`Server started at http://127.0.0.1:${PORT}/, the time is ${new Date().toISOString()}, version from package.json is`
)