Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelsboost committed Mar 14, 2024
1 parent 563a8af commit 4a25e0c
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 89 deletions.
73 changes: 31 additions & 42 deletions go/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -157124,21 +157124,19 @@ ${"-".repeat(err.pos)}^`;
? `<script type="module" src="js/dom-console.js" defer></script>`
: "";

let libraryTags = '';
const libraries = project.libraries;
libraries.forEach(library => {
if (library.endsWith('.js')) {
libraryTags += `<script src="${library}" defer></script>
`;
} else if (library.endsWith('.css')) {
libraryTags += `<link rel="stylesheet" href="${library}">
`;
} else {
// Assuming it's a Google font
libraryTags += `<link href="${library}" rel="stylesheet">
`;
}
});
// Iterate over each library
let scriptTags = '';
let cssTags = '';
project.libraries.forEach(library => {
if (library.endsWith('.js')) {
scriptTags += `<script src="${library}" defer></script>\n `;
} else if (library.endsWith('.css')) {
cssTags += `<link rel="stylesheet" href="${library}">\n`;
} else {
// Assuming it's a Google font
cssTags += `<link href="${library}" rel="stylesheet">\n`;
}
});

// render html
return `<!DOCTYPE html>
Expand All @@ -157148,15 +157146,15 @@ ${"-".repeat(err.pos)}^`;
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="${project.description}">
${libraryTags}
${cssTags}
${addConsoleCSS}
${showConsole}
<style id="kodeWeaveCSSID">${project.css}</style>
</head>
<body>
${project.html}

<script>${project.javascript}</script>
${scriptTags}<script>${project.javascript}</script>
</body>
</html>`;
};
Expand Down Expand Up @@ -157266,39 +157264,27 @@ SOFTWARE.`;

zip.file("README.md", project.markdown);
zip.file("LICENSE.md", licenseStr);
let cssBundle = '/* imports */\n';
let jsBundleFiles = "";

// Iterate over each library
let scriptTags = '';
let styleCSS = '/* imports */\n';
project.libraries.forEach(library => {
if (library.endsWith('.js')) {
jsBundleFiles += `kWExportJSFiles.importJS("${library}");\n `;
scriptTags += `<script src="${library}" defer></script>\n `;
} else if (library.endsWith('.css')) {
cssBundle += `@import url('${library}');\n`;
styleCSS += `@import url('${library}');\n`;
} else {
cssBundle += `@import url('${library}');\n`;
// Assuming it's a Google font
styleCSS += `@import url('${library}');\n`;
}
});

// add project css after libraries have been added in a single css file
cssBundle += project.css;
styleCSS += project.css;

zip.file("css/index.css", project.css);
zip.file("css/bundle.css", cssBundle);
zip.file("css/style.css", styleCSS);
zip.file("js/index.js", project.javascript);
zip.file("js/bundle.js", `const kWExportJSFiles = {
importJS: url => {
let script = document.createElement("script");
script.src = url;
script.setAttribute("defer", "");
document.head.appendChild(script);
},

init: () => {
${jsBundleFiles}
setTimeout(() => kWExportJSFiles.importJS("js/index.js"), 100);
}
};

kWExportJSFiles.init();`);
zip.file("index.html", `<!DOCTYPE html>
<html lang="en-US">
<head>
Expand All @@ -157319,12 +157305,12 @@ kWExportJSFiles.init();`);
<meta property="og:type" content="website" />
<meta property="og:title" content="${project.title}" />
<meta property="og:description" content="${project.description}" />
<link rel="stylesheet" href="css/bundle.css">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
${project.html}

<script src="js/bundle.js"></script>
${scriptTags}<script src="js/index.js"></script>
</body>
</html>`);

Expand Down Expand Up @@ -157706,7 +157692,10 @@ kWExportJSFiles.init();`);
}

// Update settings
autoupdate.checked = (project.settings.autoupdate) ? false : false;
if (autoupdate.checked) {
autoupdate.checked = false;
run.classList.toggle('hidden', autoupdate.checked);
}
toggleconsole.checked = (project.settings.console) ? true : false;
document.getElementById("fz").value = project.settings.fontSize;
document.getElementById("projectTitle").value = project.title;
Expand Down
74 changes: 28 additions & 46 deletions go/editor.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -637,21 +637,19 @@ const app = {
? `<script type="module" src="js/dom-console.js" defer></script>`
: "";

let libraryTags = '';
const libraries = project.libraries;
libraries.forEach(library => {
if (library.endsWith('.js')) {
libraryTags += `<script src="${library}" defer></script>
`;
} else if (library.endsWith('.css')) {
libraryTags += `<link rel="stylesheet" href="${library}">
`;
} else {
// Assuming it's a Google font
libraryTags += `<link href="${library}" rel="stylesheet">
`;
}
});
// Iterate over each library
let scriptTags = '';
let cssTags = '';
project.libraries.forEach(library => {
if (library.endsWith('.js')) {
scriptTags += `<script src="${library}" defer></script>\n `;
} else if (library.endsWith('.css')) {
cssTags += `<link rel="stylesheet" href="${library}">\n`;
} else {
// Assuming it's a Google font
cssTags += `<link href="${library}" rel="stylesheet">\n`;
}
});

// render html
return `<!DOCTYPE html>
Expand All @@ -661,15 +659,15 @@ const app = {
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="${project.description}">
${libraryTags}
${cssTags}
${addConsoleCSS}
${showConsole}
<style id="kodeWeaveCSSID">${project.css}</style>
</head>
<body>
${project.html}
<script>${project.javascript}</script>
${scriptTags}<script>${project.javascript}</script>
</body>
</html>`;
};
Expand Down Expand Up @@ -781,44 +779,25 @@ SOFTWARE.`;
zip.file("LICENSE.md", licenseStr);

// Iterate over each library
let libraryTags = '';
let cssBundle = '/* imports */\n';
let jsBundleFiles = "";
let scriptTags = '';
let styleCSS = '/* imports */\n';
project.libraries.forEach(library => {
if (library.endsWith('.js')) {
libraryTags += `<script src="${library}" defer></script>\n`;
jsBundleFiles += `kWExportJSFiles.importJS("${library}");\n `;
scriptTags += `<script src="${library}" defer></script>\n `;
} else if (library.endsWith('.css')) {
libraryTags += `<link rel="stylesheet" href="${library}">\n`;
cssBundle += `@import url('${library}');\n`;
styleCSS += `@import url('${library}');\n`;
} else {
// Assuming it's a Google font
libraryTags += `<link href="${library}" rel="stylesheet">\n`;
cssBundle += `@import url('${library}');\n`;
styleCSS += `@import url('${library}');\n`;
}
});

// add project css after libraries have been added in a single css file
cssBundle += project.css;
styleCSS += project.css;

zip.file("css/index.css", project.css);
zip.file("css/bundle.css", cssBundle);
zip.file("css/style.css", styleCSS);
zip.file("js/index.js", project.javascript);
zip.file("js/bundle.js", `const kWExportJSFiles = {
importJS: url => {
let script = document.createElement("script");
script.src = url;
script.setAttribute("defer", "");
document.head.appendChild(script);
},
init: () => {
${jsBundleFiles}
setTimeout(() => kWExportJSFiles.importJS("js/index.js"), 100);
}
};
kWExportJSFiles.init();`);
zip.file("index.html", `<!DOCTYPE html>
<html lang="en-US">
<head>
Expand All @@ -839,12 +818,12 @@ kWExportJSFiles.init();`);
<meta property="og:type" content="website" />
<meta property="og:title" content="${project.title}" />
<meta property="og:description" content="${project.description}" />
<link rel="stylesheet" href="css/bundle.css">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
${project.html}
<script src="js/bundle.js"></script>
${scriptTags}<script src="js/index.js"></script>
</body>
</html>`);

Expand Down Expand Up @@ -1230,7 +1209,10 @@ kWExportJSFiles.init();`);
}

// Update settings
autoupdate.checked = (project.settings.autoupdate) ? false : false;
if (autoupdate.checked) {
autoupdate.checked = false;
run.classList.toggle('hidden', autoupdate.checked);
}
toggleconsole.checked = (project.settings.console) ? true : false;
document.getElementById("fz").value = project.settings.fontSize;
document.getElementById("projectTitle").value = project.title;
Expand Down
2 changes: 1 addition & 1 deletion helloerror-kodeWeave.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css"
],
"markdown": "kodeWeave\n===================\n\nkodeWeave is your on the go coding playground! Design with TailwindCSS, Pico.css or any library or framework of your choosing. See how your app or website will look and behave on a desktop.\n\nIf you've ever used jsfiddle, jsbin, dabblet, liveweave, codepen, cssdeck, cssdesk, tinkerbin, d3 playground, plunker and/or pastebin kodeWeave is the tool for you when you're away from a computer!\n\n![](https://raw.githubusercontent.com/michaelsboost/kodeWeave/main/imgs/screenshots/kodeweave.png)\n\nVersion\n-------------\n\n1.1.50\n\nLicense\n-------------\n\nMIT\n\nTech\n-------------\n\nkodeWeave uses a number of open source projects to work properly:\n\n* [Codemirror v6](http://codemirror.net/) - Awesome web-based text editor\n* [Emmet](http://emmet.io/) - Codemirror Plugin for Zen Coding\n* [Font Awesome v5](https://fontawesome.com/) - Beautiful icon library and toolkit\n* [daisyUI](https://daisyui.com/) - A Tailwind CSS Component Library (used for the toggle switch)\n* [Tailwind CSS](https://tailwindcss.com/) - A low-level CSS framework that's entirely utility-first and provides users with low-level CSS classes in PostCSS that can be used to define components and designs independently.\n* [JSZip](https://stuk.github.io/jszip/) - Package zip files locally in javascript\n* [FileSaver.js](https://github.com/eligrey/FileSaver.js/) - JSZip comes prebuilt with this. Allows us to save files locally in Javascript\n* [panzoom](https://github.com/anvaka/panzoom/) - Used to pan and zoom the canvas\n* [cdnjs](https://cdnjs.com/api) - Used to easily add the latest libraries and frameworks in the app by a single search\n* [marked](https://marked.js.org/) - Used to convert markdown to html\n\nDevelopment\n-------------\n\nWant to contribute? Great! \n\nYou can submit a pull request or simply share the project :)\n\nOf course, kodeWeave is free and open source, so you can always fork the project and have fun :)\n\n[![ko-fi](https://az743702.vo.msecnd.net/cdn/kofi2.png?v=0)](https://ko-fi.com/michaelsboost)\n\nIf kodeWeave was at all helpful for you. You can show your appreciation a few ways...\n\n1) Check out my Graphic Design Course: https://michaelsboost.com/graphicdesign \n2) Registering on my store as a customer: https://michaelsboost.com/store \n3) Buying me a coffee! http://ko-fi.com/michaelsboost \n4) Purchasing one of my t-shirts: https://michaelsboost.com/gear \n5) Purchasing any of my art: https://deviantart.com/michaelsboost/prints \n6) Donating via PayPal: https://michaelsboost.com/donate \n7) Donating via SquareCash: https://cash.me/$michaelsboost ",
"html": "<main>\n <article>\n <button id=\"sayhi\">\n say 👋\n </button>\n </article>\n</main>",
"html": "<main>\n <article>\n <button id=\"sayhi\" class=\"capitalize\">\n say 👋\n </button>\n </article>\n</main>",
"css": "",
"javascript": "sayhi.onclick = () => {\n elm.textContent = \"hello 👋\";\n};"
}

0 comments on commit 4a25e0c

Please sign in to comment.