Skip to content
This repository has been archived by the owner on Feb 25, 2022. It is now read-only.

Commit

Permalink
Notifications, spacing log
Browse files Browse the repository at this point in the history
  • Loading branch information
moruzerinho6 committed Mar 5, 2021
1 parent 59b3982 commit 45369dc
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 13 deletions.
62 changes: 55 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"@ibm/plex": "^5.1.3",
"caller-id": "^0.1.0",
"ini-parser": "^0.0.2",
"node-notifier": "^9.0.0",
"simple-node-logger": "^18.12.24"
},
"scripts": {
Expand Down
8 changes: 8 additions & 0 deletions pageFiles/themes/moondance/assets/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ const warn = (arg) => {
window.api.send('toMain', ['logWarn', arg])
}

/**
* Sends a notification to the OS.
* @param {any} arg - The notify message string or object.
*/
const notify = (arg) => {
window.api.send('toMain', ['notification', arg])
}
/**
*
* @param {string} page
Expand Down Expand Up @@ -193,6 +200,7 @@ generateFiles.onclick = (() => {
})
*/
}
notify('HTML files fully generated!')
})
/**
*
Expand Down
21 changes: 18 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const callerId = require('caller-id')
const logger = require('simple-node-logger').createSimpleFileLogger({ logFilePath: path.join(__dirname, '../logs/info.txt') })
const translation = parser.parseFileSync(path.join(__dirname, '../translated.ini'))
const template = require('../template.json')
const notifier = require('node-notifier')

let mainWindow;

Expand Down Expand Up @@ -78,21 +79,21 @@ ipcMain.on("toMain", (event, args) => {
if (args.length === 2) {
info('Recieved a call to Main')
if (args[0] === 'writeFile') {
info(`Writing a file, arguments: ${[args[1][0], args[1][1]].join(', ')}`)
info(`Writing a file, arguments: \n\n ${[args[1][0], args[1][1]].join(', ')}\n\n`)
fs.writeFileSync(args[1][0], args[1][1])
}

if (args[0] === 'mkdir') {
info(`Writing a directory to ${args[1]}`)
fs.mkdir(args[1], { recursive: true }, err => {
if (err) warn(`Error while writing a directory, error: ${err}`)
if (err) warn(`Error while writing a directory, error: \n\n${err}\n\n`)
})
}

if (args[0] === 'rename') {
info(`Renaming (or moving) ${args[1][0]} to ${args[1][1]}`)
fs.rename(args[1][0], args[1][1], (err) => {
if (err) warn(`Error while writing a renaming, error: ${err}`)
if (err) warn(`Error while writing a renaming, error: \n\n${err}\n\n`)
})
}

Expand All @@ -103,8 +104,22 @@ ipcMain.on("toMain", (event, args) => {
if (args[0] === 'logwarn') {
warn(args[1])
}

if (args[0] === 'notification') {
if (typeof args[1] === 'string') {
notifier.notify({
title: "Tiny-Webini",
message: args[1],
icon: './tinyFoxes.png'
})
return
}

notifier.notify(args[1])
}
return
}

if (args === 'translationUpdate') {
info('An translation update was requested, updating translation.')
mainWindow.webContents.send('fromMain', ['translationUpdate', parser.parseFileSync(path.join(__dirname, '../translated.ini'))])
Expand Down
4 changes: 2 additions & 2 deletions template.json
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@
},
{
"type": "p",
"content": "hastagUseful",
"content": "hashtagUseful",
"jumpLine": true
},
{
Expand Down Expand Up @@ -1567,7 +1567,7 @@
{
"type": "h3",
"jumpLine": true,
"content": "Thirdstyle"
"content": "ThirdStyle"
},
{
"type": "div",
Expand Down
Binary file added tinyFoxes.ico
Binary file not shown.
Binary file added tinyFoxes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion translated.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[Common]
LanguageCode=pt
LanguageCode=en

[NotFound-text]
pageNotFound=Page not found
Expand Down

0 comments on commit 45369dc

Please sign in to comment.