0.1.6
- cleanup per network folder for playworks converter - loosen mraid checker file and folder scanning
This commit is contained in:
@@ -139,6 +139,11 @@ openOutBtn.addEventListener('click', () => {
|
||||
if (outputDir) fetch('/api/open', { method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify({ url: outputDir }) });
|
||||
});
|
||||
|
||||
function outputDisplayName(file) {
|
||||
const parts = file.split(/[\\\\/]/).filter(Boolean);
|
||||
return parts.slice(-2).join('/');
|
||||
}
|
||||
|
||||
document.getElementById('convert').addEventListener('click', async () => {
|
||||
const networks = [...document.querySelectorAll('.net-cb')].filter(c => c.checked).map(c => c.dataset.tag);
|
||||
statusEl.textContent = 'Converting...';
|
||||
@@ -170,7 +175,7 @@ document.getElementById('convert').addEventListener('click', async () => {
|
||||
const detail = document.createElement('span');
|
||||
if (r.ok) {
|
||||
detail.className = 'res-file';
|
||||
detail.textContent = r.file.split(/[\\\\/]/).pop();
|
||||
detail.textContent = outputDisplayName(r.file);
|
||||
} else {
|
||||
detail.className = 'res-err';
|
||||
detail.textContent = r.error || 'Unknown error';
|
||||
@@ -242,22 +247,51 @@ func convertPlayworksNetwork(htmlSrc string, opts playworksConvertOptions, netwo
|
||||
transformed := transformPlayworksHTML(htmlSrc, network)
|
||||
baseName := playworksSourceBaseName(opts.SourcePath)
|
||||
htmlFileName := fmt.Sprintf("%s_%s.html", baseName, network)
|
||||
outputDir := filepath.Join(opts.OutputDir, playworksNetworkOutputFolder(network))
|
||||
if err := os.MkdirAll(outputDir, 0755); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if playworksNeedsZip(network) {
|
||||
zipPath := filepath.Join(opts.OutputDir, fmt.Sprintf("%s_%s.zip", baseName, network))
|
||||
zipPath := filepath.Join(outputDir, fmt.Sprintf("%s_%s.zip", baseName, network))
|
||||
if err := createSingleFileZip([]byte(transformed), "index.html", zipPath); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return zipPath, nil
|
||||
}
|
||||
|
||||
outPath := filepath.Join(opts.OutputDir, htmlFileName)
|
||||
outPath := filepath.Join(outputDir, htmlFileName)
|
||||
if err := os.WriteFile(outPath, []byte(transformed), 0644); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return outPath, nil
|
||||
}
|
||||
|
||||
func playworksNetworkOutputFolder(network string) string {
|
||||
switch network {
|
||||
case "al":
|
||||
return "Applovin"
|
||||
case "is":
|
||||
return "Ironsource"
|
||||
case "un":
|
||||
return "Unity"
|
||||
case "fb":
|
||||
return "Facebook"
|
||||
case "gg":
|
||||
return "GoogleAds"
|
||||
case "mo":
|
||||
return "Moloco"
|
||||
case "vu":
|
||||
return "Vungle"
|
||||
case "mtg":
|
||||
return "Mintegral"
|
||||
case "tt":
|
||||
return "TikTok"
|
||||
default:
|
||||
return network
|
||||
}
|
||||
}
|
||||
|
||||
func playworksNeedsZip(network string) bool {
|
||||
return network == "gg" || network == "vu" || network == "mtg"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user