Initial dependencies and entry points

This commit is contained in:
onbjerg committed 2015-08-20 19:42:03 +02:00
1 parent 5f34f8780a
commit 2ccfef5940
6 files changed
+194

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
module.exports = window.App = App
var EventEmitter = require('events').EventEmitter
var h = require('virtual-dom/h')
var inherits = require('inherits')
inherits(App, EventEmitter)
function App (el, currentWindow) {
var self = this
if (!(self instanceof App)) return new App(el)
self._notifications = 0
self.currentWindow = currentWindow
}
App.prototype.render = function () {
var self = this
return h('div.layout')
}
App.prototype.isFocused = function () {
if (this.currentWindow) {
return this.currentWindow.isFocused()
}
return true
}
+40
View File
@@ -0,0 +1,40 @@
module.exports = Desktop
var inherits = require('util').inherits
var App = require('./app.js')
var remote = require('remote')
var app = remote.require('app')
var shell = require('shell')
var currentWindow = remote.getCurrentWindow()
inherits(Desktop, App)
function Desktop () {
if (!(this instanceof Desktop)) return new Desktop()
App.call(this, document.body, currentWindow)
var self = this
// clear notifications on focus.
currentWindow.on('focus', function () {
self.setBadge(false)
})
this.on('setBadge', this.setBadge.bind(this))
this.on('openUrl', function (url) {
shell.openExternal(url)
})
}
Desktop.prototype.setBadge = function (num) {
if (!app.dock) return
if (num === false) {
return app.dock.setBadge('')
} else if (num == null) {
this._notifications++
} else {
this._notifications = num
}
app.dock.setBadge(this._notifications.toString())
}
+17
View File
@@ -0,0 +1,17 @@
<html>
<head>
<title>minimal.</title>
<link rel="stylesheet" href="dist/app.css" charset="utf-8">
</head>
<body>
<script>
if (typeof require !== 'function') {
// We're in a web environment
// TODO(onbjerg): Actually do stuff here
} else {
// If we're in an electron environment
require('./desktop.js')()
}
</script>
</body>
</html>
+22
View File
@@ -0,0 +1,22 @@
var BrowserWindow = require('browser-window')
var path = require('path')
var INDEX = 'file://' + path.join(__dirname, 'index.html')
var app = require('app')
app.on('ready', appReady)
var mainWindow
function appReady () {
mainWindow = new BrowserWindow({
width: 800,
height: 600,
title: 'minimal.'
})
mainWindow.loadUrl(INDEX)
mainWindow.on('closed', function () {
mainWindow = null
})
}
+37
View File
@@ -0,0 +1,37 @@
{
"name": "minimal",
"version": "1.0.0",
"description": "A beautiful and modern IRC client",
"main": "index.js",
"bugs": {
"url": "https://github.com/onbjerg/minimal/issues"
},
"homepage": "https://github.com/onbjerg/minimal#readme",
"scripts": {
"test": "standard",
"start": "electron index.js",
"package": "node pkg.js"
},
"repository": {
"type": "git",
"url": "https://github.com/onbjerg/minimal.git"
},
"keywords": [
"irc",
"chat",
"friends",
"discussion",
"communication",
"minimalism"
],
"author": "onbjerg",
"license": "GPL-2.0",
"devDependencies": {
"electron-packager": "^5.0.2",
"electron-prebuilt": "^0.30.4",
"standard": "^5.1.0"
},
"dependencies": {
"virtual-dom": "^2.1.1"
}
}
+50
View File
@@ -0,0 +1,50 @@
#!/usr/bin/env node
// Thanks to moose-team/friends!
var os = require('os')
var pkgjson = require('./package.json')
var path = require('path')
var sh = require('shelljs')
var appVersion = pkgjson.version
var appName = pkgjson.name
var electronPackager = './node_modules/.bin/electron-packager'
var electronVersion = '0.26.0'
var icon = 'static/Icon.icns'
if (process.argv[2] === '--all') {
// Build for all platforms
var archs = ['ia32', 'x64']
var platforms = ['linux', 'win32', 'darwin']
platforms.forEach(function (plat) {
archs.forEach(function (arch) {
pack(plat, arch)
})
})
} else {
// Build for current platform only
pack(os.platform(), os.arch())
}
function pack (plat, arch) {
var outputPath = path.join('.', 'pkg', appVersion, plat, arch)
sh.exec('./node_modules/.bin/rimraf ' + outputPath)
// There is no darwin ia32 electron
if (plat === 'darwin' && arch === 'ia32') return
var cmd = electronPackager + ' . ' + appName +
' --platform=' + plat +
' --arch=' + arch +
' --version=' + electronVersion +
' --app-version' + appVersion +
' --icon=' + icon +
' --out=' + outputPath +
' --prune' +
' --ignore=pkg' // Ignore the pkg directory or hilarity will ensue
console.log(cmd)
sh.exec(cmd)
}