forked from MapComplete/MapComplete
Themes: move generated themes into assets, remove known_themes, support pruning of borrowed icons
This commit is contained in:
parent
310b973846
commit
ee64d84d27
18 changed files with 431 additions and 400 deletions
|
@ -5,6 +5,7 @@ import { AllSharedLayers } from "./AllSharedLayers"
|
|||
import Constants from "../Models/Constants"
|
||||
import ScriptUtils from "../../scripts/ScriptUtils"
|
||||
import { readFileSync } from "fs"
|
||||
import { LayerConfigJson } from "../Models/ThemeConfig/Json/LayerConfigJson"
|
||||
|
||||
/**
|
||||
* Somewhat of a dictionary, which lazily parses needed themes
|
||||
|
@ -14,14 +15,14 @@ export class AllKnownLayoutsLazy {
|
|||
private readonly dict: Map<string, ThemeConfig> = new Map()
|
||||
|
||||
constructor(includeFavouriteLayer = true) {
|
||||
const paths = ScriptUtils.readDirRecSync("./src/assets/generated/themes/",1)
|
||||
const paths = ScriptUtils.readDirRecSync("./public/assets/generated/themes/",1)
|
||||
|
||||
for (const path of paths) {
|
||||
const themeConfigJson = <ThemeConfigJson> JSON.parse(readFileSync(path, "utf8"))
|
||||
for (const layerId of Constants.added_by_default) {
|
||||
if (layerId === "favourite" && favourite.id) {
|
||||
if (includeFavouriteLayer) {
|
||||
themeConfigJson.layers.push(favourite)
|
||||
themeConfigJson.layers.push(<LayerConfigJson> favourite)
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
|
|
@ -7,12 +7,9 @@ export class AllSharedLayers {
|
|||
public static sharedLayers: Map<string, LayerConfig> = AllSharedLayers.getSharedLayers()
|
||||
public static getSharedLayersConfigs(): Map<string, LayerConfigJson> {
|
||||
const sharedLayers = new Map<string, LayerConfigJson>()
|
||||
for (const layer of (known_layers).layers) {
|
||||
for (const layer of known_layers["layers"]) {
|
||||
if(layer.id === undefined){
|
||||
console.error("Layer without id! "+JSON.stringify(layer).slice(0,80), known_layers.layers.length)
|
||||
continue
|
||||
}else{
|
||||
console.log("Loaded",layer.id)
|
||||
}
|
||||
sharedLayers.set(layer.id, <any> layer)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue