diff --git a/Docs/theme-template.json b/Docs/theme-template.json index d3482666c..6690b4cfa 100644 --- a/Docs/theme-template.json +++ b/Docs/theme-template.json @@ -6,8 +6,7 @@ "#5": "If you don't know how to run a webserver: go to https://www.base64encode.org/ , copy paste this entire document in the 'encode' field and encode it;", "#6": "Then, go to https://mapcomplete.osm.be/theme?userlayout=true#your-base64-encoded-file", "id": "template", - "maintainer": "Write your name here", - "version": "2022-03-12", + "credits": "Write your name here (or remove everything)", "title": { "en": "Title of your theme", "#1": "You can add extra languages here (and in all translation blocks), but make sure 'en' is everywhere" diff --git a/Models/ThemeConfig/Conversion/LegacyJsonConvert.ts b/Models/ThemeConfig/Conversion/LegacyJsonConvert.ts index dc25f2afc..4a779da3c 100644 --- a/Models/ThemeConfig/Conversion/LegacyJsonConvert.ts +++ b/Models/ThemeConfig/Conversion/LegacyJsonConvert.ts @@ -18,7 +18,7 @@ export class UpdateLegacyLayer extends DesugaringStep { constructor() { - super("Small fixes in the theme config", ["roamingRenderings"],"UpdateLegacyTheme"); + super("Small fixes in the theme config", ["roamingRenderings"], "UpdateLegacyTheme"); } convert(json: LayoutConfigJson, context: string): { result: LayoutConfigJson; errors: string[]; warnings: string[] } { const oldThemeConfig = {...json} - - if(oldThemeConfig.socialImage === ""){ + + if (oldThemeConfig.socialImage === "") { delete oldThemeConfig.socialImage } - + + if (oldThemeConfig["roamingRenderings"] !== undefined) { if (oldThemeConfig["roamingRenderings"].length == 0) { @@ -148,6 +149,21 @@ class UpdateLegacyTheme extends DesugaringStep { oldThemeConfig.layers = Utils.NoNull(oldThemeConfig.layers) delete oldThemeConfig["language"] + delete oldThemeConfig["version"] + + if (oldThemeConfig["maintainer"] !== undefined) { + + console.log("Maintainer: ", oldThemeConfig["maintainer"], "credits: ", oldThemeConfig["credits"]) + if (oldThemeConfig.credits === undefined) { + oldThemeConfig["credits"] = oldThemeConfig["maintainer"] + delete oldThemeConfig["maintainer"] + } else if (oldThemeConfig["maintainer"].toLowerCase().trim() === "mapcomplete") { + delete oldThemeConfig["maintainer"] + } else if (oldThemeConfig["maintainer"].toLowerCase().trim() === "") { + delete oldThemeConfig["maintainer"] + } + } + return { errors: [], warnings: [], @@ -161,7 +177,7 @@ export class FixLegacyTheme extends Fuse { super( "Fixes a legacy theme to the modern JSON format geared to humans. Syntactic sugars are kept (i.e. no tagRenderings are expandend, no dependencies are automatically gathered)", new UpdateLegacyTheme(), - new On("layers",new Each( new UpdateLegacyLayer())) + new On("layers", new Each(new UpdateLegacyLayer())) ); } } diff --git a/Models/ThemeConfig/Json/LayoutConfigJson.ts b/Models/ThemeConfig/Json/LayoutConfigJson.ts index c767029ed..08f4e895d 100644 --- a/Models/ThemeConfig/Json/LayoutConfigJson.ts +++ b/Models/ThemeConfig/Json/LayoutConfigJson.ts @@ -31,18 +31,7 @@ export interface LayoutConfigJson { * Who helped to create this theme and should be attributed? */ credits?: string; - - /** - * Who does maintain this preset? - */ - maintainer: string; - - /** - * A version number, either semantically or by date. - * Should be sortable, where the higher value is the later version - */ - version: string; - + /** * Only used in 'generateLayerOverview': if present, every translation will be checked to make sure it is fully translated. * diff --git a/Models/ThemeConfig/LayoutConfig.ts b/Models/ThemeConfig/LayoutConfig.ts index e0c917d5a..5af307ea0 100644 --- a/Models/ThemeConfig/LayoutConfig.ts +++ b/Models/ThemeConfig/LayoutConfig.ts @@ -10,9 +10,7 @@ import ExtraLinkConfig from "./ExtraLinkConfig"; export default class LayoutConfig { public static readonly defaultSocialImage = "assets/SocialImage.png" public readonly id: string; - public readonly maintainer: string; public readonly credits?: string; - public readonly version: string; public readonly language: string[]; public readonly title: Translation; public readonly shortDescription: Translation; @@ -76,9 +74,7 @@ export default class LayoutConfig { } } const context = this.id - this.maintainer = json.maintainer; this.credits = json.credits; - this.version = json.version; this.language = json.mustHaveLanguage ?? Array.from(Object.keys(json.title)); this.usedImages = Array.from(new ExtractImages(official, undefined).convertStrict(json, "while extracting the images of " + json.id + " " + context ?? "")).sort() { diff --git a/UI/BigComponents/CopyrightPanel.ts b/UI/BigComponents/CopyrightPanel.ts index 16e6b1eb7..983c5482c 100644 --- a/UI/BigComponents/CopyrightPanel.ts +++ b/UI/BigComponents/CopyrightPanel.ts @@ -146,8 +146,8 @@ export default class CopyrightPanel extends Combine { const iconAttributions = layoutToUse.usedImages.map(CopyrightPanel.IconAttribution) let maintainer: BaseUIElement = undefined - if (layoutToUse.maintainer !== undefined && layoutToUse.maintainer !== "" && layoutToUse.maintainer.toLowerCase() !== "mapcomplete") { - maintainer = t.themeBy.Subs({author: layoutToUse.maintainer}) + if (layoutToUse.credits !== undefined && layoutToUse.credits !== "") { + maintainer = t.themeBy.Subs({author: layoutToUse.credits}) } const contributions = new ContributorCount(state).Contributors @@ -190,7 +190,6 @@ export default class CopyrightPanel extends Combine { new Title(t.attributionTitle), t.attributionContent, maintainer, - new FixedUiElement(layoutToUse.credits), dataContributors, CopyrightPanel.CodeContributors(contributors, t.codeContributionsBy), CopyrightPanel.CodeContributors(translators, t.translatedBy), diff --git a/scripts/lint.ts b/scripts/lint.ts index 8575bdc7a..6416b2f9f 100644 --- a/scripts/lint.ts +++ b/scripts/lint.ts @@ -1,10 +1,9 @@ import ScriptUtils from "./ScriptUtils"; -import {mkdirSync, writeFileSync} from "fs"; +import {writeFileSync} from "fs"; import {FixLegacyTheme, UpdateLegacyLayer} from "../Models/ThemeConfig/Conversion/LegacyJsonConvert"; import Translations from "../UI/i18n/Translations"; import {Translation} from "../UI/i18n/Translation"; import {LayerConfigJson} from "../Models/ThemeConfig/Json/LayerConfigJson"; -import {LayoutConfigJson} from "../Models/ThemeConfig/Json/LayoutConfigJson"; /* * This script reads all theme and layer files and reformats them inplace