Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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