chore: automated housekeeping...

This commit is contained in:
Pieter Vander Vennet 2024-09-02 12:48:15 +02:00
parent c10fecb7e8
commit f5d7686c98
234 changed files with 3493 additions and 2482 deletions

View file

@ -81,7 +81,7 @@ export default class FeatureSwitchState extends OsmConnectionFeatureSwitches {
const legacyRewrite: Record<string, string | string[]> = {
"fs-userbadge": "fs-enable-login",
"fs-layers": ["fs-filter", "fs-background"]
"fs-layers": ["fs-filter", "fs-background"],
}
for (const key in legacyRewrite) {
@ -251,17 +251,20 @@ export default class FeatureSwitchState extends OsmConnectionFeatureSwitches {
this.backgroundLayerId = QueryParameters.GetQueryParameter(
"background",
layoutToUse?.defaultBackgroundId,
["When set, load this raster layer (or a layer of this category) as background layer instead of using the default background. This is as if the user opened the background selection menu and selected the layer with the given id or category.",
[
"When set, load this raster layer (or a layer of this category) as background layer instead of using the default background. This is as if the user opened the background selection menu and selected the layer with the given id or category.",
"Most raster layers are based on the [editor layer index](https://github.com/osmlab/editor-layer-index)",
"#### Selecting a category",
"If one of the following values is used, this parameter will be interpreted as a _category_ instead of the id of a specific layer. The best layer of this category will be used. Supported categories are those from the editor layer index and are:",
eliCategory.map(c => "- " + c).join("\n"),
eliCategory.map((c) => "- " + c).join("\n"),
"#### Selecting a specific layer",
"One can use the [ID of an ELI-layer](./ELI-overview.md) or use one of the global, builtin layers:",
MarkdownUtils.list(AvailableRasterLayers.globalLayers.map(global =>
global.properties.id+(global.properties.best ? " ⭐" : "")
))
MarkdownUtils.list(
AvailableRasterLayers.globalLayers.map(
(global) => global.properties.id + (global.properties.best ? " ⭐" : "")
)
),
].join("\n\n")
)
}

View file

@ -92,7 +92,7 @@ export default class UserRelatedState {
this.showAllQuestionsAtOnce = UIEventSource.asBoolean(
this.osmConnection.GetPreference("show-all-questions", "false", {
documentation:
"Either 'true' or 'false'. If set, all questions will be shown all at once"
"Either 'true' or 'false'. If set, all questions will be shown all at once",
})
)
this.language = this.osmConnection.GetPreference("language")
@ -112,7 +112,7 @@ export default class UserRelatedState {
undefined,
{
documentation:
"The ID of a layer or layer category that MapComplete uses by default"
"The ID of a layer or layer category that MapComplete uses by default",
}
)
@ -120,12 +120,12 @@ export default class UserRelatedState {
"preferences-add-new-mode",
"button_click_right",
{
documentation: "How adding a new feature is done"
documentation: "How adding a new feature is done",
}
)
this.imageLicense = this.osmConnection.GetPreference("pictures-license", "CC0", {
documentation: "The license under which new images are uploaded"
documentation: "The license under which new images are uploaded",
})
this.installedUserThemes = this.InitInstalledUserThemes()
this.translationMode = this.initTranslationMode()
@ -144,7 +144,6 @@ export default class UserRelatedState {
this.language.syncWith(Locale.language)
}
private initTranslationMode(): UIEventSource<"false" | "true" | "mobile" | undefined | string> {
const translationMode: UIEventSource<undefined | "true" | "false" | "mobile" | string> =
this.osmConnection.GetPreference("translation-mode", "false")
@ -164,7 +163,6 @@ export default class UserRelatedState {
}
})
return translationMode
}
private static initUserSettingsState(): LayerConfig {
@ -177,13 +175,13 @@ export default class UserRelatedState {
public GetUnofficialTheme(id: string):
| {
id: string
icon: string
title: any
shortDescription: any
definition?: any
isOfficial: boolean
}
id: string
icon: string
title: any
shortDescription: any
definition?: any
isOfficial: boolean
}
| undefined {
console.log("GETTING UNOFFICIAL THEME")
const pref = this.osmConnection.GetLongPreference("unofficial-theme-" + id)
@ -208,8 +206,8 @@ export default class UserRelatedState {
} catch (e) {
console.warn(
"Removing theme " +
id +
" as it could not be parsed from the preferences; the content is:",
id +
" as it could not be parsed from the preferences; the content is:",
str
)
pref.setData(null)
@ -239,7 +237,7 @@ export default class UserRelatedState {
icon: layout.icon,
title: layout.title.translations,
shortDescription: layout.shortDescription.translations,
definition: layout["definition"]
definition: layout["definition"],
})
)
}
@ -279,13 +277,13 @@ export default class UserRelatedState {
id: "home",
"user:home": "yes",
_lon: homeLonLat[0],
_lat: homeLonLat[1]
_lat: homeLonLat[1],
},
geometry: {
type: "Point",
coordinates: homeLonLat
}
}
coordinates: homeLonLat,
},
},
]
})
return new StaticFeatureSource(feature)
@ -306,7 +304,7 @@ export default class UserRelatedState {
_applicationOpened: new Date().toISOString(),
_supports_sharing:
typeof window === "undefined" ? "no" : window.navigator.share ? "yes" : "no",
_iframe: Utils.isIframe ? "yes" : "no"
_iframe: Utils.isIframe ? "yes" : "no",
})
for (const key in Constants.userJourney) {
@ -359,18 +357,18 @@ export default class UserRelatedState {
const zenLinks: { link: string; id: string }[] = Utils.NoNull([
hasMissingTheme
? {
id: "theme:" + layout.id,
link: LinkToWeblate.hrefToWeblateZen(
language,
"themes",
layout.id
)
}
id: "theme:" + layout.id,
link: LinkToWeblate.hrefToWeblateZen(
language,
"themes",
layout.id
),
}
: undefined,
...missingLayers.map((id) => ({
id: "layer:" + id,
link: LinkToWeblate.hrefToWeblateZen(language, "layers", id)
}))
link: LinkToWeblate.hrefToWeblateZen(language, "layers", id),
})),
])
const untranslated_count = untranslated.length
amendedPrefs.data["_translation_total"] = "" + total

View file

@ -1,14 +1,42 @@
import { Utils } from "../../Utils"
/** This code is autogenerated - do not edit. Edit ./assets/layers/usersettings/usersettings.json instead */
export class ThemeMetaTagging {
public static readonly themeName = "usersettings"
public static readonly themeName = "usersettings"
public metaTaggging_for_usersettings(feat: {properties: Record<string, string>}) {
Utils.AddLazyProperty(feat.properties, '_mastodon_candidate_md', () => feat.properties._description.match(/\[[^\]]*\]\((.*(mastodon|en.osm.town).*)\).*/)?.at(1) )
Utils.AddLazyProperty(feat.properties, '_d', () => feat.properties._description?.replace(/&lt;/g,'<')?.replace(/&gt;/g,'>') ?? '' )
Utils.AddLazyProperty(feat.properties, '_mastodon_candidate_a', () => (feat => {const e = document.createElement('div');e.innerHTML = feat.properties._d;return Array.from(e.getElementsByTagName("a")).filter(a => a.href.match(/mastodon|en.osm.town/) !== null)[0]?.href }) (feat) )
Utils.AddLazyProperty(feat.properties, '_mastodon_link', () => (feat => {const e = document.createElement('div');e.innerHTML = feat.properties._d;return Array.from(e.getElementsByTagName("a")).filter(a => a.getAttribute("rel")?.indexOf('me') >= 0)[0]?.href})(feat) )
Utils.AddLazyProperty(feat.properties, '_mastodon_candidate', () => feat.properties._mastodon_candidate_md ?? feat.properties._mastodon_candidate_a )
feat.properties['__current_backgroun'] = 'initial_value'
}
}
public metaTaggging_for_usersettings(feat: { properties: Record<string, string> }) {
Utils.AddLazyProperty(feat.properties, "_mastodon_candidate_md", () =>
feat.properties._description
.match(/\[[^\]]*\]\((.*(mastodon|en.osm.town).*)\).*/)
?.at(1)
)
Utils.AddLazyProperty(
feat.properties,
"_d",
() => feat.properties._description?.replace(/&lt;/g, "<")?.replace(/&gt;/g, ">") ?? ""
)
Utils.AddLazyProperty(feat.properties, "_mastodon_candidate_a", () =>
((feat) => {
const e = document.createElement("div")
e.innerHTML = feat.properties._d
return Array.from(e.getElementsByTagName("a")).filter(
(a) => a.href.match(/mastodon|en.osm.town/) !== null
)[0]?.href
})(feat)
)
Utils.AddLazyProperty(feat.properties, "_mastodon_link", () =>
((feat) => {
const e = document.createElement("div")
e.innerHTML = feat.properties._d
return Array.from(e.getElementsByTagName("a")).filter(
(a) => a.getAttribute("rel")?.indexOf("me") >= 0
)[0]?.href
})(feat)
)
Utils.AddLazyProperty(
feat.properties,
"_mastodon_candidate",
() => feat.properties._mastodon_candidate_md ?? feat.properties._mastodon_candidate_a
)
feat.properties["__current_backgroun"] = "initial_value"
}
}