Skip to content

Commit 342e006

Browse files
committed
Adding icons, auto updates, and ip detection
1 parent e00a59b commit 342e006

File tree

10 files changed

+107
-31
lines changed

10 files changed

+107
-31
lines changed

Icon.icns

198 KB
Binary file not shown.

IconTemplate.png

1.36 KB
Loading

IconTemplate@2x.png

2.2 KB
Loading

auto_updater.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"url": "https://github.com/dfmcphee/simple-proxy/releases/download/0.0.2/SimpleProxy-v0.0.2.zip",
3+
"name": "v0.0.2",
4+
"notes": "Better IP detection and icons.",
5+
"pub_date": "2015-10-21T12:29:53+01:00"
6+
}

components/Settings.js

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ let ipc = require('ipc');
22
let React = require('react');
33
let ReactDOM = require('react-dom');
44

5-
function validPort(port) {
6-
return (port > 1023 && port < 65536)
7-
}
8-
95
let Settings = React.createClass({
106
getInitialState: function() {
117
return {
@@ -14,14 +10,18 @@ let Settings = React.createClass({
1410
};
1511
},
1612

13+
validPort: function(port) {
14+
return (port > 1023 && port < 65536)
15+
},
16+
1717
portChanged: function(event) {
1818
this.setState({
1919
port: parseInt(event.target.value) || 0
2020
});
2121
},
2222

23-
saveSettings: function() {
24-
if (validPort(this.state.port)) {
23+
save: function() {
24+
if (this.validPort(this.state.port)) {
2525
this.props.saveSettings(this.state.port);
2626
}
2727
else {
@@ -50,10 +50,17 @@ let Settings = React.createClass({
5050
{error}
5151
</section>
5252
<footer className="toolbar toolbar-footer">
53-
<div className="toolbar-actions">
54-
<button className="btn btn-primary pull-right" onClick={this.saveSettings}>
55-
Save
56-
</button>
53+
<div className="actions">
54+
<div className="actions__left">
55+
<button className="btn btn-default" onClick={this.props.cancelSettings}>
56+
Cancel
57+
</button>
58+
</div>
59+
<div className="actions__right">
60+
<button className="btn btn-primary" onClick={this.save}>
61+
Save
62+
</button>
63+
</div>
5764
</div>
5865
</footer>
5966
</div>

components/SimpleProxy.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,26 @@ let SimpleProxy = React.createClass({
4343
openSettings: function() {
4444
this.setState({
4545
settingsOpen: true
46-
})
46+
});
4747
},
4848

4949
saveSettings: function(port) {
5050
this.setState({
5151
settingsOpen: false,
5252
port: port
53-
})
53+
});
54+
},
55+
56+
cancelSettings: function() {
57+
this.setState({
58+
settingsOpen: false
59+
});
5460
},
5561

5662
render: function() {
5763
if (this.state.settingsOpen) {
5864
return (
59-
<Settings saveSettings={this.saveSettings} />
65+
<Settings saveSettings={this.saveSettings} cancelSettings={this.cancelSettings} />
6066
);
6167
}
6268
else {

index.css

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,20 @@ body {
55
margin: 0;
66
height: 100%;
77
width: 100%;
8+
color: #505050;
89
}
910

1011
body {
11-
font-family: -apple-system, 'Helvetica Neue', Helvetica, sans-serif;
1212
font-size: 24px;
1313
font-weight: 100;
14+
font-family: 'SF UI Text', 'Lucida Grande', 'Segoe UI', Ubuntu, Cantarell, sans-serif;
15+
letter-spacing: 0.03em;
1416
}
1517

1618
input,
1719
button {
18-
font-family: -apple-system, 'Helvetica Neue', Helvetica, sans-serif;
20+
font-weight: 100;
21+
letter-spacing: 0.05em;
1922
}
2023

2124
input:focus,
@@ -55,7 +58,7 @@ button:focus {
5558

5659
.controls__button {
5760
flex: 1 1 auto;
58-
height: 38px;
61+
height: 42px;
5962
border: none;
6063
}
6164

@@ -88,7 +91,29 @@ button:focus {
8891
flex: 1 1 auto;
8992
font-size: 24px;
9093
margin: 0;
94+
}
95+
96+
.actions {
97+
display: flex;
98+
}
99+
100+
.actions__left {
101+
flex: 1 1 auto;
102+
font-size: 24px;
103+
margin: 0;
91104
padding: 0;
105+
margin-left: 4px;
106+
}
107+
108+
.actions__right {
109+
flex: 0 0 auto;
110+
font-size: 24px;
111+
margin: 0;
112+
margin-right: 4px;
113+
}
114+
115+
.btn-primary.pull-right {
116+
margin-top: 10px;
92117
}
93118

94119
/* Info */

index.js

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
'use strict';
22
const app = require('app');
33
const BrowserWindow = require('browser-window');
4+
const NativeImage = require('native-image');
5+
const gh_releases = require('electron-gh-releases');
6+
const ip = require('ip');
47

58
// report crashes to the Electron project
6-
require('crash-reporter').start();
9+
//require('crash-reporter').start();
710

811
// adds debug features like hotkeys for triggering dev tools and reload
9-
require('electron-debug')();
12+
// require('electron-debug')();
1013

1114
let setup = require('proxy');
1215
let http = require('http');
@@ -19,18 +22,21 @@ let server;
1922
let mb = menubar({
2023
preloadWindow: true,
2124
width: 400,
22-
height: 180
25+
height: 180,
26+
icon: app.getAppPath() + '/IconTemplate.png'
2327
});
2428

2529
mb.on('ready', function ready () {
2630
console.log('app is ready')
2731
//mb.window.openDevTools();
2832
});
2933

34+
mb.on('show', function() {
35+
mb.window.webContents.send('set-ip', ip.address());
36+
});
37+
3038
ipc.on('connect', function(event) {
31-
dns.lookup(require('os').hostname(), function (err, address, fam) {
32-
event.sender.send('set-ip', address);
33-
});
39+
event.sender.send('set-ip', ip.address());
3440
});
3541

3642
ipc.on('start-proxy', function(event, port) {
@@ -46,3 +52,25 @@ ipc.on('stop-proxy', function(event, port) {
4652
console.log('proxy stopped')
4753
});
4854
});
55+
56+
let options = {
57+
repo: 'dfmcphee/simple-proxy',
58+
currentVersion: app.getVersion()
59+
};
60+
61+
let update = new gh_releases(options, function(auto_updater) {
62+
// Auto updater event listener
63+
auto_updater.on('update-downloaded', function(e, rNotes, rName, rDate, uUrl, quitAndUpdate) {
64+
// Install the update
65+
console.log('Update downloaded.');
66+
quitAndUpdate()
67+
})
68+
});
69+
70+
// Check for updates
71+
update.check(function (err, status) {
72+
if (!err && status) {
73+
console.log('Update downloading.');
74+
update.download()
75+
}
76+
});

package.json

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,41 @@
11
{
22
"name": "simple-proxy",
3-
"productName": "Simple Proxy",
4-
"version": "0.0.1",
3+
"productName": "SimpleProxy",
4+
"version": "0.0.2",
55
"description": "A simple reverse proxy for OS X.",
66
"license": "MIT",
7-
"repository": "dfmcphee/simple-proxy",
7+
"repository": {
8+
"url": "dfmcphee/simple-proxy"
9+
},
810
"author": {
911
"name": "Dominic McPhee",
10-
"email": "dominic.mcphee@gmail.com",
12+
"email": "dominic.mcphee@shopify.com",
1113
"url": "dfmcphee.com"
1214
},
1315
"engines": {
1416
"node": ">=4"
1517
},
16-
"electronVersion": "0.33.3",
18+
"electronVersion": "0.34.0",
1719
"main": "index.js",
1820
"scripts": {
1921
"start": "electron .",
20-
"build": "electron-packager . SimpleProxy --out=dist --ignore='^/dist$' --prune --asar --all --platform=darwin --arch=x64 --version=0.33.8"
22+
"build": "electron-packager . $npm_package_productName --out=dist --platform=darwin --arch=x64 icon=Icon.icns --ignore='^/dist$' --version=$npm_package_electronVersion --sign=U7937AY495 --overwrite"
2123
},
2224
"keywords": [
2325
"electron-app"
2426
],
2527
"dependencies": {
2628
"babel": "^5.8.23",
2729
"electron-debug": "^0.2.1",
30+
"electron-gh-releases": "^1.0.1",
31+
"ip": "^1.0.1",
2832
"menubar": "^2.2.1",
2933
"proxy": "^0.2.3",
3034
"react": "^0.14.0",
3135
"react-dom": "^0.14.0"
3236
},
3337
"devDependencies": {
34-
"electron-packager": "^5.0.0",
35-
"electron-prebuilt": "^0.33.3"
38+
"electron-packager": "^5.1.0",
39+
"electron-prebuilt": "^0.34.0"
3640
}
3741
}

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ $ npm start
2323
$ npm run build
2424
```
2525

26-
Builds the app for OS X, Linux, and Windows, using [electron-packager](https://github.com/maxogden/electron-packager).
26+
Builds the app for OS X using [electron-packager](https://github.com/maxogden/electron-packager).

0 commit comments

Comments
 (0)