Skip to content

Commit

Permalink
Merge branch 'GovertDev' into feature/reuse-simplyedit
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoxolotl authored Jun 7, 2024
2 parents 7c0a205 + bc75e19 commit 38d7cc9
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 29 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# name: Release app
# on:
# workflow_dispatch:
# jobs:
# build:
# strategy:
# matrix:
# os:
# [
# { name: 'linux', image: 'ubuntu-latest' },
# { name: 'windows', image: 'windows-latest' },
# { name: 'macos', image: 'macos-latest' },
# ]
# runs-on: ${{ matrix.os.image }}
# steps:
# - name: Github checkout
# uses: actions/checkout@v4
# - name: Use Node.js
# uses: actions/setup-node@v4
# with:
# node-version: 20
# - run: npm ci
# - name: Publish app
# env:
# GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
# run: npm run publish
41 changes: 34 additions & 7 deletions forge.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,44 @@ const { FuseV1Options, FuseVersion } = require('@electron/fuses');
module.exports = {
packagerConfig: {
asar: true,
icon: '/simplycode/camil_512x512.png',
},
rebuildConfig: {},
makers: [
{
name: '@electron-forge/maker-squirrel',
config: {},
config: {
bin: 'simply-code',
icon:path.join(__dirname, '/simplycode/camil_192x192.png'),
}
},
{
name: '@electron-forge/maker-zip',
platforms: ['darwin'],
name: '@electron-forge/maker-dmg',
config: {
bin: 'simply-code',
icon:path.join(__dirname, '/simplycode/camil_192x192.png'),
},
},
{
name: '@electron-forge/maker-deb',
config: {},
config: {
bin: 'simply-code',
options: {
icon:path.join(__dirname, '/simplycode/camil_192x192.png'),
},
}
},
{
name: '@electron-forge/maker-rpm',
config: {},
},
config: {
bin: 'simply-code',
icon:path.join(__dirname, '/simplycode/camil_192x192.png'),
}
}
],
plugins: [
{
name: '@electron-forge/plugin-auto-unpack-natives',
name: '@SimplyEdit/simplycode-electron/tree/electron-forge-github-actions',
config: {},
},
// Fuses are used to enable/disable various Electron functionality
Expand All @@ -41,4 +56,16 @@ module.exports = {
[FuseV1Options.OnlyLoadAppFromAsar]: true,
}),
],
publishers: [
{
name: 'simply-code',
config: {
repository: {
owner: 'Govert Combée',
name: 'simply-code'
},
prerelease: true
}
}
]
};
43 changes: 23 additions & 20 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ const createWindow = () => {
preload: path.join(__dirname, 'preload.js'),
webSecurity: false,
allowRunningInsecureContent : true
}
},
icon: path.join(__dirname, '/simplycode/camil_512x512.png')

})

win.loadURL('simplycode://index.html')
Expand All @@ -32,7 +34,8 @@ const createSecondWindow = (dataDir) => {
preload: path.join(__dirname, 'preload.js'),
webSecurity: false,
allowRunningInsecureContent : true
}
},
icon: path.join(__dirname,'/simplycode/camil_512x512.png')
})

win2.loadURL('simplyapp://generated.html')
Expand Down Expand Up @@ -100,10 +103,7 @@ protocol.registerSchemesAsPrivileged([
secure: true,
supportFetchAPI: true
}
}
])

protocol.registerSchemesAsPrivileged([
},
{
scheme: 'simplyapp',
privileges: {
Expand Down Expand Up @@ -133,6 +133,8 @@ async function createComponentFile(componentPath, filecontent){
}

app.whenReady().then(() => {
if (require('electron-squirrel-startup') === true) app.quit(); // prevents Squirrel.Windows from launching your app multiple times during the installation/updating/uninstallation.

protocol.handle('simplycode', (request) => {
let componentPath = new URL(request.url).pathname
console.log(componentPath)
Expand Down Expand Up @@ -196,6 +198,7 @@ app.whenReady().then(() => {
} else {
var target = __dirname + '/simplycode' + componentDirectory + '\/' + componentName;
if(fs.existsSync(target)) {

if (fs.lstatSync(target).isDirectory()) {
// Do the recursive read thing;
} else {
Expand All @@ -211,8 +214,6 @@ app.whenReady().then(() => {
break
}
}


})

protocol.handle('simplyapp', (request) => {
Expand All @@ -222,27 +223,33 @@ 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 {
var target = dataDir + componentDirectory + '\/' + componentName;
if(fs.existsSync(target)) {
const filestuff = fs.readFileSync(target)

return new Response(filestuff, {
// headers: { 'content-type': 'text/html' }
})
Expand All @@ -260,11 +267,8 @@ app.whenReady().then(() => {
}
}
break
}




}
}
})

if (process.argv[1]) {
Expand All @@ -275,11 +279,12 @@ app.whenReady().then(() => {
console.log(dataDir);
if (!dataDir.match(/\/$/)) {
dataDir += "/";
console.log(dataDir);
}
createWindow()
createSecondWindow(dataDir)

app.on('activate', () => {
app.on('activate', () => { // needed for macos
if (BrowserWindow.getAllWindows().length === 0) {
if (process.argv[1]) {
dataDir = path.resolve(process.argv[1]);
Expand All @@ -293,8 +298,6 @@ app.whenReady().then(() => {
createSecondWindow(dataDir)
}
})


})

app.on('window-all-closed', () => {
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
"start": "electron-forge start",
"package": "electron-forge package",
"make": "electron-forge make",
"postinstall": "scripts/post-install.sh"
"postinstall": "scripts/post-install.sh",
"publish": "electron-forge publish"
},
"productName": "simply-code",
"keywords": [
"javascript",
"html",
Expand All @@ -25,8 +27,9 @@
"@electron-forge/maker-zip": "^7.4.0",
"@electron-forge/plugin-auto-unpack-natives": "^7.4.0",
"@electron-forge/plugin-fuses": "^7.4.0",
"@electron-forge/publisher-github": "^7.4.0",
"@electron/fuses": "^1.8.0",
"electron": "^30.0.2"
"electron": "^30.0.9"
},
"dependencies": {
"electron-squirrel-startup": "^1.0.1",
Expand Down

0 comments on commit 38d7cc9

Please sign in to comment.