Skip to content

Commit

Permalink
needed to bundle a partof the registerSchemesAsPrivileged
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoxolotl committed Jun 3, 2024
1 parent 61fd341 commit 35e476a
Showing 1 changed file with 33 additions and 28 deletions.
61 changes: 33 additions & 28 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,7 @@ protocol.registerSchemesAsPrivileged([
secure: true,
supportFetchAPI: true
}
}
])

protocol.registerSchemesAsPrivileged([
},
{
scheme: 'simplyapp',
privileges: {
Expand Down Expand Up @@ -204,20 +201,22 @@ app.whenReady().then(() => {
})
} else {
var target = __dirname + '/simplycode' + componentDirectory + '\/' + componentName;
if (fs.lstatSync(target).isDirectory()) {
// Do the recursive read thing;
if (fs.existsSync(target)){
if (fs.lstatSync(target).isDirectory()) {
// Do the recursive read thing;
} else {
const filestuff = fs.readFileSync(__dirname + '/simplycode' + componentDirectory + '\/' + componentName)
return new Response(filestuff, {
// headers: { 'content-type': 'text/html' }
})
}
} else {
const filestuff = fs.readFileSync(__dirname + '/simplycode' + componentDirectory + '\/' + componentName)
return new Response(filestuff, {
// headers: { 'content-type': 'text/html' }
})
return new Response('"Not found"', { status: 404})
}
}
break
}
}


})

protocol.handle('simplyapp', (request) => {
Expand All @@ -227,57 +226,63 @@ app.whenReady().then(() => {
componentPath = componentPath.substring(0, (componentPath.length - 1))
}

let pathicles = componentPath.split('\/');
let pathicles = componentPath.split('\/'); // also splits on an empty string

let componentName = pathicles.pop();
let componentDirectory = pathicles.join('/');
pathicles.shift();

if (pathicles[0] == ''){
pathicles.shift()
}

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

switch (request.method){
default:
if(componentPath.endsWith('\/')){
componentPath = componentPath.substring(0, (componentPath.length - 1))
}
}

if (!componentPath || componentPath === "/") {
const filestuff = fs.readFileSync(dataDir + '/generated.html')
return new Response(filestuff, {
// headers: { 'content-type': 'text/html' }
})
} else {
const filestuff = fs.readFileSync(dataDir + componentDirectory + '\/' + componentName)
return new Response(filestuff, {
// headers: { 'content-type': 'text/html' }
})
} else {{
if (fs.existsSync(dataDir + componentDirectory + '\/' + componentName)){
const filestuff = fs.readFileSync(dataDir + componentDirectory + '\/' + componentName)
return new Response(filestuff, {
// headers: { 'content-type': 'text/html' }
})
} else {
return new Response('"Not found"', { status: 404})
}
}
break
}




}
}
})

dataDir = dialog.showOpenDialogSync({properties: ['openDirectory']})[0];
console.log(dataDir);
if (!dataDir.match(/\/$/)) {
dataDir += "/";
console.log(dataDir);
}
createWindow()
createSecondWindow(dataDir)

app.on('activate', () => { // needed for macos
if (BrowserWindow.getAllWindows().length === 0) {
dataDir = dialog.showOpenDialogSync({properties: ['openDirectory']})[0];
console.log('were here')
console.log(dataDir)
if (!dataDir.match(/\/$/)) {
dataDir += "/";
}
createWindow()
createSecondWindow(dataDir)
}
})


})

app.on('window-all-closed', () => {
Expand Down

0 comments on commit 35e476a

Please sign in to comment.