diff --git a/Customizations/JSON/TagRenderingConfigJson.ts b/Customizations/JSON/TagRenderingConfigJson.ts index 30bbf5c..ec12afb 100644 --- a/Customizations/JSON/TagRenderingConfigJson.ts +++ b/Customizations/JSON/TagRenderingConfigJson.ts @@ -4,6 +4,8 @@ export interface TagRenderingConfigJson { /** * Renders this value. Note that "{key}"-parts are substituted by the corresponding values of the element. * If neither 'textFieldQuestion' nor 'mappings' are defined, this text is simply shown as default value. + * + * Note that this is a HTML-interpreted value, so you can add links as e.g. {website} */ render?: string | any, diff --git a/scripts/createLayouts.ts b/scripts/createLayouts.ts index 9a5857c..7f92f69 100644 --- a/scripts/createLayouts.ts +++ b/scripts/createLayouts.ts @@ -75,29 +75,6 @@ function validate(layout: LayoutConfig) { } -function generateWikiEntry(layout: LayoutConfig) { - if (layout.hideFromOverview) { - return ""; - } - const languages = layout.language.map(ln => `{{#language:${ln}|en}}`).join(", ") - let auth = "Yes"; - if (layout.maintainer !== "" && layout.maintainer !== "MapComplete") { - auth = `Yes, by ${layout.maintainer};` - } - return `{{service_item -|name= [https://mapcomplete.osm.be/${layout.id} ${layout.id}] -|region= Worldwide -|lang= ${languages} -|descr= A MapComplete theme: ${Translations.W(layout.description) - .InnerRender() - .replace(".*<\/a>/, "]]") - } -|material= {{yes|[https://mapcomplete.osm.be/ ${auth}]}} -|image= MapComplete_Screenshot.png -|genre= POI, editor, ${layout.id} -}}` -} const alreadyWritten = [] @@ -245,11 +222,6 @@ if (!existsSync(generatedDir)) { const blacklist = ["", "test", ".", "..", "manifest", "index", "land", "preferences", "account", "openstreetmap", "custom"] const all = AllKnownLayouts.allSets; -let wikiPage = "{|class=\"wikitable sortable\"\n" + - "! Name, link !! Genre !! Covered region !! Language !! Description !! Free materials !! Image\n" + - "|-"; - - for (const layoutName in all) { if (blacklist.indexOf(layoutName.toLowerCase()) >= 0) { console.log(`Skipping a layout with name${layoutName}, it is on the blacklist`); @@ -270,16 +242,9 @@ for (const layoutName in all) { // Create a landing page for the given theme createLandingPage(layout).then(landing => { writeFile(enc(layout.id) + ".html", landing, err) - wikiPage += "\n" + generateWikiEntry(layout); }); } -wikiPage += "\n|}" -writeFile(generatedDir + "/wikiIndex", wikiPage, (err) => { - if (err !== null) { - console.log("Could not save wikiindex", err); - } -}); createManifest(new LayoutConfig({ icon: "./assets/svg/mapcomplete_logo.svg", id: "index", diff --git a/scripts/createWikiPage.ts b/scripts/createWikiPage.ts new file mode 100644 index 0000000..dbbf1ca --- /dev/null +++ b/scripts/createWikiPage.ts @@ -0,0 +1,49 @@ +import {Utils} from "../Utils"; +Utils.runningFromConsole = true; +import {writeFile} from "fs"; +import LayoutConfig from "../Customizations/JSON/LayoutConfig"; +import Translations from "../UI/i18n/Translations"; +import {AllKnownLayouts} from "../Customizations/AllKnownLayouts"; + + +function generateWikiEntry(layout: LayoutConfig) { + if (layout.hideFromOverview) { + return ""; + } + const languages = layout.language.map(ln => `{{#language:${ln}|en}}`).join(", ") + let auth = "Yes"; + if (layout.maintainer !== "" && layout.maintainer !== "MapComplete") { + auth = `Yes, by ${layout.maintainer};` + } + return `{{service_item +|name= [https://mapcomplete.osm.be/${layout.id} ${layout.id}] +|region= Worldwide +|lang= ${languages} +|descr= A MapComplete theme: ${Translations.W(layout.description) + .InnerRender() + .replace(".*<\/a>/, "]]") + } +|material= {{yes|[https://mapcomplete.osm.be/ ${auth}]}} +|image= MapComplete_Screenshot.png +|genre= POI, editor, ${layout.id} +}}` +} +let wikiPage = "{|class=\"wikitable sortable\"\n" + + "! Name, link !! Genre !! Covered region !! Language !! Description !! Free materials !! Image\n" + + "|-"; + +for (const layout of AllKnownLayouts.layoutsList) { + if(layout.hideFromOverview){ + continue; + } + wikiPage += "\n" + generateWikiEntry(layout); +} + +wikiPage += "\n|}" + +writeFile("Docs/wikiIndex.txt", wikiPage, (err) => { + if (err !== null) { + console.log("Could not save wikiindex", err); + } +}); \ No newline at end of file