forked from MapComplete/MapComplete
Better tag rewriting, add icons, add bicycle rental theme
This commit is contained in:
parent
1dcb3897e4
commit
9594868e83
23 changed files with 389 additions and 117 deletions
|
@ -14,6 +14,8 @@ import Title from "../UI/Base/Title";
|
|||
import Minimap from "../UI/Base/Minimap";
|
||||
import {QueryParameters} from "../Logic/Web/QueryParameters";
|
||||
import QueryParameterDocumentation from "../UI/QueryParameterDocumentation";
|
||||
import ScriptUtils from "./ScriptUtils";
|
||||
import List from "../UI/Base/List";
|
||||
|
||||
function WriteFile(filename, html: BaseUIElement, autogenSource: string[]): void {
|
||||
|
||||
|
@ -50,6 +52,53 @@ WriteFile("./Docs/CalculatedTags.md", new Combine([new Title("Metatags", 1),
|
|||
WriteFile("./Docs/SpecialInputElements.md", ValidatedTextField.HelpText(), ["ValidatedTextField.ts"]);
|
||||
WriteFile("./Docs/BuiltinLayers.md", AllKnownLayouts.GenLayerOverviewText(), ["AllKnownLayers.ts"])
|
||||
|
||||
{
|
||||
var layers = ScriptUtils.getLayerFiles().map(f => f.parsed)
|
||||
var builtinsPerLayer= new Map<string, string[]>();
|
||||
var layersUsingBuiltin = new Map<string /* Builtin */, string[]>();
|
||||
for (const layer of layers) {
|
||||
if(layer.tagRenderings === undefined){
|
||||
continue
|
||||
}
|
||||
const usedBuiltins : string[] = []
|
||||
for (const tagRendering of layer.tagRenderings) {
|
||||
if(typeof tagRendering === "string"){
|
||||
usedBuiltins.push(tagRendering)
|
||||
continue
|
||||
}
|
||||
if(tagRendering["builtin"] !== undefined){
|
||||
const builtins = tagRendering["builtin"]
|
||||
if(typeof builtins === "string"){
|
||||
usedBuiltins.push(builtins)
|
||||
}else{
|
||||
usedBuiltins.push(...builtins)
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const usedBuiltin of usedBuiltins) {
|
||||
var using = layersUsingBuiltin.get(usedBuiltin)
|
||||
if(using === undefined){
|
||||
layersUsingBuiltin.set(usedBuiltin, [layer.id])
|
||||
}else{
|
||||
using.push(layer.id)
|
||||
}
|
||||
}
|
||||
|
||||
builtinsPerLayer.set(layer.id, usedBuiltins)
|
||||
}
|
||||
|
||||
const docs = new Combine([
|
||||
new Title("Index of builtin TagRendering" ,1),
|
||||
new Title("Existing builtin tagrenderings", 2),
|
||||
... Array.from(layersUsingBuiltin.entries()).map(([builtin, usedByLayers]) =>
|
||||
new Combine([
|
||||
new Title(builtin),
|
||||
new List(usedByLayers)
|
||||
]).SetClass("flex flex-col")
|
||||
)
|
||||
]).SetClass("flex flex-col")
|
||||
WriteFile("./Docs/BuiltinIndex.md", docs, ["assets/layers/*.json"])
|
||||
}
|
||||
|
||||
Minimap.createMiniMap = _ => {
|
||||
console.log("Not creating a minimap, it is disabled");
|
||||
|
@ -58,12 +107,12 @@ Minimap.createMiniMap = _ => {
|
|||
|
||||
|
||||
const dummyLayout = new LayoutConfig({
|
||||
language: ["en"],
|
||||
id: ">theme<",
|
||||
maintainer: "pietervdvn",
|
||||
version: "0",
|
||||
title: "<theme>",
|
||||
title: {en:"<theme>"},
|
||||
description: "A theme to generate docs with",
|
||||
socialImage: "./assets/SocialImage.png",
|
||||
startLat: 0,
|
||||
startLon: 0,
|
||||
startZoom: 0,
|
||||
|
|
|
@ -228,7 +228,7 @@ function compileTranslationsFromWeblate() {
|
|||
* @param objects
|
||||
* @param target
|
||||
*/
|
||||
function generateTranslationsObjectFrom(objects: { path: string, parsed: { id: string } }[], target: string) {
|
||||
function generateTranslationsObjectFrom(objects: { path: string, parsed: { id: string } }[], target: string): string[] {
|
||||
const tr = new TranslationPart();
|
||||
|
||||
for (const layerFile of objects) {
|
||||
|
@ -257,6 +257,7 @@ function generateTranslationsObjectFrom(objects: { path: string, parsed: { id: s
|
|||
|
||||
writeFileSync(`langs/${target}/${lang}.json`, json)
|
||||
}
|
||||
return langs
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -398,11 +399,14 @@ if (!themeOverwritesWeblate) {
|
|||
} else {
|
||||
console.log("Ignore weblate")
|
||||
}
|
||||
generateTranslationsObjectFrom(ScriptUtils.getLayerFiles(), "layers")
|
||||
generateTranslationsObjectFrom(ScriptUtils.getThemeFiles().filter(th => th.parsed.mustHaveLanguage === undefined), "themes")
|
||||
|
||||
const l1 = generateTranslationsObjectFrom(ScriptUtils.getLayerFiles(), "layers")
|
||||
const l2 = generateTranslationsObjectFrom(ScriptUtils.getThemeFiles().filter(th => th.parsed.mustHaveLanguage === undefined), "themes")
|
||||
const l3 = generateTranslationsObjectFrom([{path: questionsPath, parsed: questionsParsed}], "shared-questions")
|
||||
|
||||
generateTranslationsObjectFrom([{path: questionsPath, parsed: questionsParsed}], "shared-questions")
|
||||
const usedLanguages = Utils.Dedup(l1.concat(l2).concat(l3)).filter(v => v !== "*")
|
||||
usedLanguages.sort()
|
||||
fs.writeFileSync("./assets/generated/used_languages.json", JSON.stringify({languages: usedLanguages}))
|
||||
|
||||
if (!themeOverwritesWeblate) {
|
||||
// Generates the core translations
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue