Skip to content

Commit

Permalink
Merge pull request #18 from SimplyEdit/main
Browse files Browse the repository at this point in the history
resync to main
  • Loading branch information
Hoxolotl authored Nov 22, 2024
2 parents 7015003 + 4d51135 commit 4e9067b
Show file tree
Hide file tree
Showing 36 changed files with 16,271 additions and 13,580 deletions.
2 changes: 1 addition & 1 deletion forge.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = {
makers: [
{
name: '@electron-forge/maker-squirrel',
platforms: ['linux', 'windows'],
platforms: ['windows'],
config: {
bin: 'simplycode',
}
Expand Down
24 changes: 17 additions & 7 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ function readRecursive(componentPath) {
componentPath = componentPath.substring(0, (componentPath.length - 1))
}
const pathicles = componentPath.split('\/');
if (pathicles[0] == ''){
pathicles.shift()
}
const componentName = pathicles.pop();
const componentDirectory = pathicles.join('/');

Expand Down Expand Up @@ -222,8 +225,10 @@ app.whenReady().then(() => {

let pathicles = componentPath.split('\/');
let componentName = pathicles.pop();
if (pathicles[0] == ''){
pathicles.shift()
}
let componentDirectory = pathicles.join('/');
pathicles.shift();

if(pathicles[0] === "api") {
pathicles.shift();
Expand Down Expand Up @@ -290,12 +295,12 @@ app.whenReady().then(() => {
// headers: { 'content-type': 'text/html' }
})
} else {
var target = __dirname + '/simplycode' + componentDirectory + '\/' + componentName;
var target = __dirname + '/simplycode/' + componentDirectory + '\/' + componentName;
if(fs.existsSync(target)) {
if (fs.lstatSync(target).isDirectory()) {
// Do the recursive read thing;
} else {
const filestuff = fs.readFileSync(__dirname + '/simplycode' + componentDirectory + '\/' + componentName)
const filestuff = fs.readFileSync(__dirname + '/simplycode/' + componentDirectory + '\/' + componentName)
return new Response(filestuff, {
// headers: { 'content-type': 'text/html' }
})
Expand Down Expand Up @@ -323,7 +328,6 @@ app.whenReady().then(() => {
if (pathicles[0] == ''){
pathicles.shift()
}

let componentDirectory = pathicles.join('/');

switch (request.method){
Expand Down Expand Up @@ -361,20 +365,26 @@ app.whenReady().then(() => {

} else {
var target = dataDir + componentDirectory + '\/' + componentName;
let headers = {};
if (componentName.match(/\.svg$/)) {
headers = {
'content-type' : 'image/svg+xml'
}
}
if(fs.existsSync(target)) {
const filestuff = fs.readFileSync(target)
return new Response(filestuff, {
// headers: { 'content-type': 'text/html' }
headers: headers
})
} else {
if (
(componentPath.indexOf("/js/simply") === 0) ||
(componentPath.indexOf("/simply") === 0) ||
(componentPath.indexOf("/hope") === 0)
) {
const filestuff = fs.readFileSync(__dirname + '/simplycode' + componentDirectory + '\/' + componentName)
const filestuff = fs.readFileSync(__dirname + '/simplycode/' + componentDirectory + '\/' + componentName)
return new Response(filestuff, {
// headers: { 'content-type': 'text/html' }
headers: headers
})
}
return new Response("Not found", {"status" : 404})
Expand Down
Loading

0 comments on commit 4e9067b

Please sign in to comment.