forked from MapComplete/MapComplete
		
	Cleaning up log messages, cleaning svg files
This commit is contained in:
		
							parent
							
								
									d05fbeb919
								
							
						
					
					
						commit
						387d8d4dc1
					
				
					 4 changed files with 785 additions and 888 deletions
				
			
		| 
						 | 
					@ -64,7 +64,6 @@ export class FromJSON {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static LayoutFromJSON(json: LayoutConfigJson): Layout {
 | 
					    public static LayoutFromJSON(json: LayoutConfigJson): Layout {
 | 
				
			||||||
        console.log(json)
 | 
					 | 
				
			||||||
        const tr = FromJSON.Translation;
 | 
					        const tr = FromJSON.Translation;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const layers = json.layers.map(FromJSON.Layer);
 | 
					        const layers = json.layers.map(FromJSON.Layer);
 | 
				
			||||||
| 
						 | 
					@ -115,7 +114,6 @@ export class FromJSON {
 | 
				
			||||||
            return undefined;
 | 
					            return undefined;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        const transl = new Translation(tr);
 | 
					        const transl = new Translation(tr);
 | 
				
			||||||
        transl.addCallback(latest => console.log("tr callback changed to", latest));
 | 
					 | 
				
			||||||
        return transl;
 | 
					        return transl;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,6 +11,7 @@
 | 
				
			||||||
   viewBox="0 0 98 122"
 | 
					   viewBox="0 0 98 122"
 | 
				
			||||||
   height="122"
 | 
					   height="122"
 | 
				
			||||||
   width="98">
 | 
					   width="98">
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
  <defs
 | 
					  <defs
 | 
				
			||||||
     id="defs17" />
 | 
					     id="defs17" />
 | 
				
			||||||
  <metadata
 | 
					  <metadata
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
		 Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB  | 
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							| 
		 Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 45 KiB  | 
| 
						 | 
					@ -13,17 +13,13 @@ import Translations from "./UI/i18n/Translations";
 | 
				
			||||||
import {TagRendering} from "./UI/TagRendering";
 | 
					import {TagRendering} from "./UI/TagRendering";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TagRendering.injectFunction();
 | 
					TagRendering.injectFunction();
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
console.log("Building the layouts")
 | 
					console.log("Building the layouts")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
function enc(str: string): string {
 | 
					function enc(str: string): string {
 | 
				
			||||||
    return encodeURIComponent(str.toLowerCase());
 | 
					    return encodeURIComponent(str.toLowerCase());
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function validate(layout: Layout) {
 | 
					function validate(layout: Layout) {
 | 
				
			||||||
    console.log("Validationg ", layout.id)
 | 
					 | 
				
			||||||
    const translations: Translation[] = [];
 | 
					    const translations: Translation[] = [];
 | 
				
			||||||
    const queue: any[] = [layout]
 | 
					    const queue: any[] = [layout]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -52,7 +48,6 @@ function validate(layout: Layout) {
 | 
				
			||||||
            const txt = translation.translations[ln];
 | 
					            const txt = translation.translations[ln];
 | 
				
			||||||
            const isMissing = txt === undefined || txt === "" || txt.toLowerCase().indexOf("todo") >= 0;
 | 
					            const isMissing = txt === undefined || txt === "" || txt.toLowerCase().indexOf("todo") >= 0;
 | 
				
			||||||
            if (isMissing) {
 | 
					            if (isMissing) {
 | 
				
			||||||
                console.log(`Missing or suspicious ${ln}-translation for '`, translation.txt, ":", txt)
 | 
					 | 
				
			||||||
                missing[ln]++
 | 
					                missing[ln]++
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                present[ln]++;
 | 
					                present[ln]++;
 | 
				
			||||||
| 
						 | 
					@ -60,7 +55,7 @@ function validate(layout: Layout) {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    console.log("Translation completenes for", layout.id);
 | 
					    console.log("Translation completenes for theme", layout.id);
 | 
				
			||||||
    for (const ln of layout.supportedLanguages) {
 | 
					    for (const ln of layout.supportedLanguages) {
 | 
				
			||||||
        const amiss = missing[ln];
 | 
					        const amiss = missing[ln];
 | 
				
			||||||
        const ok = present[ln];
 | 
					        const ok = present[ln];
 | 
				
			||||||
| 
						 | 
					@ -129,9 +124,7 @@ function createIcon(iconPath: string, size: number) {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    console.log("Creating icon ", name, newname)
 | 
					    console.log("Creating icon ", name, newname)
 | 
				
			||||||
 | 
					 | 
				
			||||||
    try {
 | 
					    try {
 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        svg2img(iconPath,
 | 
					        svg2img(iconPath,
 | 
				
			||||||
            // @ts-ignore
 | 
					            // @ts-ignore
 | 
				
			||||||
            {width: size, height: size, preserveAspectRatio: true})
 | 
					            {width: size, height: size, preserveAspectRatio: true})
 | 
				
			||||||
| 
						 | 
					@ -155,7 +148,6 @@ function createManifest(layout: Layout, relativePath: string) {
 | 
				
			||||||
    const icons = [];
 | 
					    const icons = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let icon = layout.icon;
 | 
					    let icon = layout.icon;
 | 
				
			||||||
    console.log(icon)
 | 
					 | 
				
			||||||
    if (icon.endsWith(".svg")) {
 | 
					    if (icon.endsWith(".svg")) {
 | 
				
			||||||
        // This is an svg. Lets create the needed pngs!
 | 
					        // This is an svg. Lets create the needed pngs!
 | 
				
			||||||
        const sizes = [72, 96, 120, 128, 144, 152, 180, 192, 384, 512];
 | 
					        const sizes = [72, 96, 120, 128, 144, 152, 180, 192, 384, 512];
 | 
				
			||||||
| 
						 | 
					@ -240,16 +232,13 @@ for (const layoutName in all) {
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
    const layout = all[layoutName];
 | 
					    const layout = all[layoutName];
 | 
				
			||||||
    validate(layout)
 | 
					    validate(layout)
 | 
				
			||||||
    console.log("Generating manifest")
 | 
					 | 
				
			||||||
    const manif = JSON.stringify(createManifest(layout, "/MapComplete"));
 | 
					    const manif = JSON.stringify(createManifest(layout, "/MapComplete"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const manifestLocation = encodeURIComponent(layout.id.toLowerCase()) + ".webmanifest";
 | 
					    const manifestLocation = encodeURIComponent(layout.id.toLowerCase()) + ".webmanifest";
 | 
				
			||||||
    writeFile(manifestLocation, manif, err);
 | 
					    writeFile(manifestLocation, manif, err);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const landing = createLandingPage(layout);
 | 
					    const landing = createLandingPage(layout);
 | 
				
			||||||
    console.log("Generating html-file for ", layout.id)
 | 
					 | 
				
			||||||
    writeFile(enc(layout.id) + ".html", landing, err)
 | 
					    writeFile(enc(layout.id) + ".html", landing, err)
 | 
				
			||||||
    console.log("done")
 | 
					 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    wikiPage += "\n\n"+generateWikiEntry(layout);
 | 
					    wikiPage += "\n\n"+generateWikiEntry(layout);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue