Skip to content

Commit

Permalink
Bump to electron 21 for maintainence reasons
Browse files Browse the repository at this point in the history
  • Loading branch information
raluvy95 committed Oct 28, 2022
1 parent 69a5fb7 commit de290b8
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules/
package-lock.json
data/
engine.bin
build/
28 changes: 17 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ if (process.argv.includes('--help')) {
process.exit()
}

// process.on('unhandledRejection', error => {
// console.log('unhandledRejection', error.message);
// });

let logger = null
if (process.argv.includes('--log')) { logger = require('./logger.js').log; } else { logger = require('./logger.js').nolog; }

Expand All @@ -11,7 +15,6 @@ let blocker = null
console.log('Loading libraries...')
const { BrowserWindow, BrowserView, app, ipcMain, Menu, session} = require('electron')
const { ElectronBlocker, fullLists, Request } = require("@cliqz/adblocker-electron")
const fetch = require("node-fetch")
const { promises } = require('fs');
const fs = require("fs")
const contextMenu = require('electron-context-menu');
Expand All @@ -20,6 +23,7 @@ const settings = require('./window/settings.js')
const history = require('./window/history.js')
const moremenu = require('./window/moremenu.js')
const bookmark = require('./window/bookmark.js')
const fetch = require("node-fetch")

const BOOKMARKS_TEMPLATE = [
{
Expand Down Expand Up @@ -54,6 +58,7 @@ const BOOKMARKS_TEMPLATE = [
}
]

console.log(__dirname)
if(!fs.existsSync(__dirname + '/data/')) {
// this will create necessary files upon first run
fs.mkdirSync(__dirname + '/data/')
Expand Down Expand Up @@ -114,6 +119,7 @@ class FelidaBrowser {

// Remove menu
Menu.setApplicationMenu(null)
this.mainWindow.setMenu(null)

// Create etabsView for tabs

Expand Down Expand Up @@ -238,33 +244,33 @@ class FelidaBrowser {

ipcMain.on("getListBookmarks", (event) => {
let parsed
if (fs.existsSync('./data/bookmarks.json')) {
parsed = JSON.parse(fs.readFileSync("./data/bookmarks.json"))
if (fs.existsSync(__dirname + '/data/bookmarks.json')) {
parsed = JSON.parse(fs.readFileSync(__dirname + '/data/bookmarks.json'))
} else {
parsed = BOOKMARKS_TEMPLATE
fs.appendFileSync('./data/bookmarks.json', JSON.stringify(parsed))
fs.appendFileSync(__dirname + '/data/bookmarks.json', JSON.stringify(parsed))
}
logger(parsed)
event.returnValue = parsed

})

ipcMain.on('setListBookmarks', (event, type, value='') => {
const parsed = JSON.parse(fs.readFileSync("./data/bookmarks.json"))
const parsed = JSON.parse(fs.readFileSync(__dirname + "/data/bookmarks.json"))
switch(type) {
case 'purge':
fs.writeFileSync('./data/bookmarks.json', '[]')
fs.writeFileSync(__dirname + '/data/bookmarks.json', '[]')
break
case 'change':
fs.writeFileSync('./data/bookmarks.json', JSON.stringify(value))
fs.writeFileSync(__dirname + '/data/bookmarks.json', JSON.stringify(value))
break
case 'add':
parsed.push(value)
fs.writeFileSync('./data/bookmarks.json', JSON.stringify(parsed))
fs.writeFileSync(__dirname + '/data/bookmarks.json', JSON.stringify(parsed))
break
case 'remove':
parsed.splice(parsed.findIndex(m => m.url == value), 1)
fs.writeFileSync('./data/bookmarks.json', JSON.stringify(parsed))
fs.writeFileSync(__dirname + '/data/bookmarks.json', JSON.stringify(parsed))
break
}
})
Expand Down Expand Up @@ -312,14 +318,14 @@ class FelidaBrowser {
this.updateSizes();

// log to history
fs.appendFile(`./data/history.json`, `${Date.now()}\r\n${this.tabs[this.activeTab].webContents.getTitle()}\r\n${url}\r\n`, function (err) {
fs.appendFile(`${__dirname}/data/history.json`, `${Date.now()}\r\n${this.tabs[this.activeTab].webContents.getTitle()}\r\n${url}\r\n`, function (err) {
if (err) throw err;
});
}

updateSizes() {
let size = this.mainWindow.getSize();
this.etabsView.setBounds({ x: 0, y: 0, width: size[0], height: 110 });
this.etabsView.setBounds({ x: 0, y: 0, width: size[0], height: 120 });
if (this.activeTab > -1) {
this.tabs[this.activeTab].setBounds({ x: 0, y: 110, width: size[0], height: size[1] - 110 });
}
Expand Down
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "npx electron-packager . --ignore='.gitignore'"
"build": "npx electron-packager . felida --icon ./assets/icon.png --out ./build --ignore='\\.gitignore'",
"watch": "nodemon -i ./data --exec ./run.sh"
},
"author": "raluvy95",
"dependencies": {
"@cliqz/adblocker-electron": "^1.23.2",
"@cliqz/adblocker-electron": "^1.25.1",
"draggabilly": "^3.0.0",
"electron": "^16.0.0",
"electron-context-menu": "^3.1.1",
"jquery": "^3.6.0",
"electron": "^21.2.0",
"electron-context-menu": "^3.6.0",
"jquery": "^3.6.1",
"node-fetch": "^2.6.1"
},
"type": "commonjs",
Expand All @@ -27,6 +28,7 @@
},
"homepage": "https://github.com/raluvy95/FelidaBrowser#readme",
"devDependencies": {
"electron-packager": "^15.4.0"
"electron-packager": "^17.0.0",
"nodemon": "^2.0.20"
}
}
2 changes: 1 addition & 1 deletion run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fi
if [ $# = 0 ]; then
node ./node_modules/electron/cli.js .
elif [ $1 = "--help" ]; then
VERSION=`cat package.json | jq '.version' | sed -e 's/^"//' -e 's/"$//'`
VERSION=`(cat package.json | jq '.version' | sed -e 's/^"//' -e 's/"$//') || unknown`
echo "Help command"
echo "--help = Shows this message"
echo "--log = Start in debug mode"
Expand Down

0 comments on commit de290b8

Please sign in to comment.