Skip to content

Commit

Permalink
Work
Browse files Browse the repository at this point in the history
  • Loading branch information
Xstoudi committed Sep 4, 2017
1 parent d8ac9fc commit fab0897
Show file tree
Hide file tree
Showing 19 changed files with 3,825 additions and 296 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -2,3 +2,4 @@
node_modules/**
*.log
dist/**
bin/
1,588 changes: 1,588 additions & 0 deletions build/icon.icns

Large diffs are not rendered by default.

Binary file added build/icon.ico
Binary file not shown.
Binary file added build/icons/512x512.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 38 additions & 2 deletions main.js
@@ -1,10 +1,15 @@
const { app, BrowserWindow, webContents, shell } = require('electron')
const { app, BrowserWindow, webContents, shell, autoUpdater, ipcMain } = require('electron')
const path = require('path')
const url = require('url')
const cld = require('cld')
const tldExtract = require('tld-extract')

const registerIpc = require('electron-ipc-tunnel/server').default
const rtlDetect = require('rtl-detect')

let win

function createWindow () {
function createWindow() {
win = new BrowserWindow({
width: 800,
height: 600,
Expand Down Expand Up @@ -41,3 +46,34 @@ app.on('window-all-closed', () => {
app.on('activate', () => {
if (win === null) { createWindow() }
})

// Language Detection
registerIpc('is-rtl', async (reply, [content, url]) => {
return await new Promise((resolve, reject) => {
cld.detect(content, {
isHTML: true,
tldHint: tldExtract(url).tld
}, (err, result) => {
resolve(rtlDetect.isRtlLang(result.languages[0].code))
})
})
})

// Autoupdate
autoUpdater.setFeedURL(`http://alduin-update:3000/update/${process.platform}/${app.getVersion()}}`)

registerIpc('update-waiter', async reply => {
return await new Promise(resolve => {
autoUpdater.on('update-downloaded', async event => {
console.log('resolve lel')
resolve()
})
setInterval(() => {
autoUpdater.checkForUpdates()
}, 1000)
})
})

registerIpc('update-start', async reply => {
autoUpdater.quitAndInstall()
})

0 comments on commit fab0897

Please sign in to comment.