forked from MapComplete/MapComplete
Refactoring: use theme
instead of layout
in a lot of places
This commit is contained in:
parent
9427083939
commit
bdc9ba52a6
104 changed files with 445 additions and 449 deletions
|
@ -3,8 +3,8 @@ import Locale from "../src/UI/i18n/Locale"
|
|||
import Translations from "../src/UI/i18n/Translations"
|
||||
import { Translation } from "../src/UI/i18n/Translation"
|
||||
import all_known_layouts from "../src/assets/generated/known_themes.json"
|
||||
import { LayoutConfigJson } from "../src/Models/ThemeConfig/Json/LayoutConfigJson"
|
||||
import LayoutConfig from "../src/Models/ThemeConfig/LayoutConfig"
|
||||
import { ThemeConfigJson } from "../src/Models/ThemeConfig/Json/ThemeConfigJson"
|
||||
import ThemeConfig from "../src/Models/ThemeConfig/ThemeConfig"
|
||||
import xml2js from "xml2js"
|
||||
import ScriptUtils from "./ScriptUtils"
|
||||
import { Utils } from "../src/Utils"
|
||||
|
@ -100,7 +100,7 @@ class GenerateLayouts extends Script {
|
|||
return newname
|
||||
}
|
||||
|
||||
async createSocialImage(layout: LayoutConfig, template: "" | "Wide"): Promise<string> {
|
||||
async createSocialImage(layout: ThemeConfig, template: "" | "Wide"): Promise<string> {
|
||||
if (!layout.icon.endsWith(".svg")) {
|
||||
console.warn(
|
||||
"Not creating a social image for " +
|
||||
|
@ -160,7 +160,7 @@ class GenerateLayouts extends Script {
|
|||
}
|
||||
|
||||
async createManifest(
|
||||
layout: LayoutConfig,
|
||||
layout: ThemeConfig,
|
||||
alreadyWritten: string[]
|
||||
): Promise<{
|
||||
manifest: any
|
||||
|
@ -319,8 +319,8 @@ class GenerateLayouts extends Script {
|
|||
}
|
||||
|
||||
async generateCsp(
|
||||
layout: LayoutConfig,
|
||||
layoutJson: LayoutConfigJson,
|
||||
layout: ThemeConfig,
|
||||
layoutJson: ThemeConfigJson,
|
||||
options: {
|
||||
scriptSrcs: string[]
|
||||
}
|
||||
|
@ -441,8 +441,8 @@ class GenerateLayouts extends Script {
|
|||
}
|
||||
|
||||
async createLandingPage(
|
||||
layout: LayoutConfig,
|
||||
layoutJson: LayoutConfigJson,
|
||||
layout: ThemeConfig,
|
||||
layoutJson: ThemeConfigJson,
|
||||
whiteIcons,
|
||||
alreadyWritten
|
||||
) {
|
||||
|
@ -456,7 +456,7 @@ class GenerateLayouts extends Script {
|
|||
.replace(/"/g, '\\"')
|
||||
let ogImage = layout.socialImage
|
||||
let twitterImage = ogImage
|
||||
if (ogImage === LayoutConfig.defaultSocialImage && layout.official) {
|
||||
if (ogImage === ThemeConfig.defaultSocialImage && layout.official) {
|
||||
try {
|
||||
ogImage = (await this.createSocialImage(layout, "")) ?? layout.socialImage
|
||||
twitterImage = (await this.createSocialImage(layout, "Wide")) ?? layout.socialImage
|
||||
|
@ -573,7 +573,7 @@ class GenerateLayouts extends Script {
|
|||
)
|
||||
}
|
||||
|
||||
async createIndexFor(theme: LayoutConfig) {
|
||||
async createIndexFor(theme: ThemeConfig) {
|
||||
const filename = "index_" + theme.id + ".ts"
|
||||
|
||||
const imports = [
|
||||
|
@ -628,18 +628,18 @@ class GenerateLayouts extends Script {
|
|||
"theme",
|
||||
]
|
||||
// @ts-ignore
|
||||
const all: LayoutConfigJson[] = all_known_layouts.themes
|
||||
const all: ThemeConfigJson[] = all_known_layouts.themes
|
||||
const args = process.argv
|
||||
const theme = args[2]
|
||||
if (theme !== undefined) {
|
||||
console.warn("Only generating layout " + theme)
|
||||
}
|
||||
for (const i in all) {
|
||||
const layoutConfigJson: LayoutConfigJson = all[i]
|
||||
const layoutConfigJson: ThemeConfigJson = all[i]
|
||||
if (theme !== undefined && layoutConfigJson.id !== theme) {
|
||||
continue
|
||||
}
|
||||
const layout = new LayoutConfig(layoutConfigJson, true)
|
||||
const layout = new ThemeConfig(layoutConfigJson, true)
|
||||
const layoutName = layout.id
|
||||
if (blacklist.indexOf(layoutName.toLowerCase()) >= 0) {
|
||||
console.log(`Skipping a layout with name ${layoutName}, it is on the blacklist`)
|
||||
|
@ -668,7 +668,7 @@ class GenerateLayouts extends Script {
|
|||
}
|
||||
|
||||
const { manifest } = await this.createManifest(
|
||||
new LayoutConfig({
|
||||
new ThemeConfig({
|
||||
icon: "./assets/svg/mapcomplete_logo.svg",
|
||||
id: "index",
|
||||
layers: [],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue