Remove maintainer and version fields

This commit is contained in:
pietervdvn 2022-08-22 14:46:55 +02:00
parent 7be371f24a
commit 8f1d63b20a
6 changed files with 27 additions and 29 deletions

View file

@ -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"

View file

@ -18,7 +18,7 @@ export class UpdateLegacyLayer extends DesugaringStep<LayerConfigJson | string |
// Reuse of an already existing layer; return as-is
return {result: json, errors: [], warnings: []}
}
let config = {...json};
let config = {...json};
if (config["overpassTags"]) {
config.source = config.source ?? {
@ -123,16 +123,17 @@ export class UpdateLegacyLayer extends DesugaringStep<LayerConfigJson | string |
class UpdateLegacyTheme extends DesugaringStep<LayoutConfigJson> {
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<LayoutConfigJson> {
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<LayoutConfigJson> {
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()))
);
}
}

View file

@ -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.
*

View file

@ -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()
{

View file

@ -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),

View file

@ -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