Skip to content

Commit 82da6f2

Browse files
committed
First release
1 parent 0ab46e3 commit 82da6f2

File tree

10 files changed

+289
-27
lines changed

10 files changed

+289
-27
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
node_modules
55
Thumbs.db
66
.DS_Store
7-
out
7+
dist

assets/images/icon.icns

153 KB
Binary file not shown.

assets/images/icon.ico

25.6 KB
Binary file not shown.

assets/images/landing-bg.jpg

41.1 KB
Loading

assets/images/[email protected]

112 KB
Loading

gulpfile.js

Lines changed: 72 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,82 @@
1-
var gulp = require('gulp');
1+
var rimraf = require('rimraf');
2+
var clgulp = require('clgulp');
3+
var gulp = clgulp(require('gulp'));
4+
var util = clgulp.util;
25
var electron = require('gulp-atom-electron');
6+
var symdest = require('gulp-symdest');
7+
var zip = require('gulp-vinyl-zip');
38
var extend = require('util')._extend;
9+
var appdmg = require('appdmg');
10+
var release = require('gulp-github-release');
411

512
var electronOptions = {
6-
version: '0.28.2',
7-
winIcon: 'node_modules/classets/images/icon_large.ico',
8-
darwinIcon: 'node_modules/classets/images/icon_large.icns',
13+
version: '0.34.2',
14+
winIcon: 'assets/images/icon.ico',
15+
darwinIcon: 'assets/images/icon.icns',
916
};
1017

11-
gulp.task('default', function() {
12-
return gulp.src(['main.js', 'package.json', 'preload.js'])
18+
var src = [
19+
'package.json',
20+
'src/*',
21+
'node_modules/spellchecker/**/*',
22+
];
23+
24+
gulp.task('clean', function(cb) {
25+
rimraf('./dist', cb);
26+
});
27+
28+
gulp.task('clean:osx', function(cb) {
29+
rimraf('./dist/osx', cb);
30+
});
31+
32+
gulp.task('build:osx', ['clean:osx'], function() {
33+
return gulp.src(src, {
34+
base: '.'
35+
})
1336
.pipe(electron(extend({
1437
platform: 'darwin',
1538
}, electronOptions)))
16-
.pipe(electron.zfsdest('out/classeur-darwin.zip'));
39+
.pipe(symdest('dist/osx'))
40+
.pipe(zip.dest('dist/osx/classeur-osx.zip'));
41+
});
42+
43+
gulp.task('pack:osx', ['build:osx'], function(cb) {
44+
var ee = appdmg({
45+
target: 'dist/osx/classeur-osx.dmg',
46+
basepath: __dirname,
47+
specification: {
48+
title: 'Classeur',
49+
background: 'assets/images/landing-bg.jpg',
50+
icon: 'assets/images/icon.icns',
51+
'icon-size': 80,
52+
contents: [{
53+
x: 450,
54+
y: 242,
55+
type: 'link',
56+
path: '/Applications'
57+
}, {
58+
x: 190,
59+
y: 242,
60+
type: 'file',
61+
path: 'dist/osx/Classeur.app'
62+
}]
63+
}
64+
});
65+
ee.on('progress', function(info) {
66+
info.title && util.log(info.title);
67+
});
68+
ee.on('finish', cb);
69+
ee.on('error', cb);
70+
});
71+
72+
gulp.task('publish:osx', function() {
73+
gulp.src([
74+
'dist/osx/classeur-osx.zip',
75+
'dist/osx/classeur-osx.dmg'
76+
])
77+
.pipe(release({
78+
owner: 'classeur',
79+
repo: 'clelectron',
80+
manifest: require('./package.json')
81+
}));
1782
});

package.json

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,43 @@
11
{
22
"name": "Classeur",
3-
"version": "0.1.0",
4-
"description": "",
5-
"main": "main.js",
3+
"version": "1.0.0",
4+
"main": "src/main.js",
65
"scripts": {
76
"start": "electron .",
7+
"clean": "rm -rf ./dist",
8+
"clean:osx": "rm -rf ./dist/osx",
9+
"clean:win": "rm -rf ./dist/win",
10+
"build": "npm run clean && npm run build:osx && npm run build:win",
11+
"build:osx": "npm run clean:osx && electron-packager ./ Classeur --out=dist --overwrite --platform=darwin --arch=x64 --version=0.34.2 --icon=./assets/images/icon.icns",
12+
"pack:osx": "npm run build:osx && electron-builder \"dist/Classeur-darwin-x64/Classeur.app\" --platform=osx --out=\"dist/osx\" --config=packager.json",
813
"test": "echo \"Error: no test specified\" && exit 1"
914
},
10-
"author": "",
15+
"author": "Benoit Schweblin",
1116
"license": "ISC",
1217
"devDependencies": {
18+
"appdmg": "^0.3.5",
19+
"classets": "github:classeur/classets#master",
20+
"clgulp": "^1.0.4",
21+
"electron-builder": "^2.0.2",
22+
"electron-packager": "^5.1.1",
1323
"electron-prebuilt": "^0.34.0",
14-
"classets": "classeur/classets.git#master",
1524
"gulp": "^3.9.0",
16-
"gulp-atom-electron": "^0.12.0"
25+
"gulp-atom-electron": "^1.0.0",
26+
"gulp-github-release": "^1.0.3",
27+
"gulp-symdest": "^1.0.0",
28+
"gulp-vinyl-zip": "^1.1.1",
29+
"rimraf": "^2.4.3"
1730
},
1831
"dependencies": {
1932
"spellchecker": "^3.1.2"
20-
}
33+
},
34+
"repository": {
35+
"type": "git",
36+
"url": "git+https://github.com/classeur/clelectron.git"
37+
},
38+
"bugs": {
39+
"url": "https://github.com/classeur/clelectron/issues"
40+
},
41+
"homepage": "https://github.com/classeur/clelectron#readme",
42+
"description": ""
2143
}

main.js renamed to src/main.js

Lines changed: 76 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,27 @@ var dialog = require('dialog');
55
var Menu = require('menu');
66
var shell = require('shell');
77
var BrowserWindow = require('browser-window');
8+
var os = require('os');
9+
var autoUpdater = require('auto-updater');
810

9-
app.on('window-all-closed', function() {
10-
if (process.platform != 'darwin') {
11-
app.quit();
12-
}
13-
});
11+
var applySettings, settings, settingsFilePath = path.join(app.getPath('userData'), 'settings.json');
12+
try {
13+
settings = JSON.parse(fs.readFileSync(settingsFilePath));
14+
} catch (e) {
15+
settings = {
16+
appUrl: 'https://app.classeur.io'
17+
};
18+
}
1419

15-
var appUri = 'http://localhost:11583';
20+
if (process.platform === 'darwin') {
21+
var platform = os.platform() + '_' + os.arch();
22+
var version = app.getVersion();
23+
autoUpdater.setFeedUrl('http://download.classeur.io/update/' + platform + '/' + version);
24+
}
1625

1726
function checkUrl(url) {
1827
url = typeof url === 'string' ? url : url.getUrl();
19-
return url.slice(0, appUri.length) === appUri;
28+
return url.slice(0, settings.appUrl.length) === settings.appUrl;
2029
}
2130

2231
function checkOrigin(cb) {
@@ -84,6 +93,7 @@ ClasseurCtx.prototype.clean = function() {
8493
};
8594

8695
var lastWindowOffset = 0;
96+
8797
function createWindow(cb) {
8898
var browserWindow = new BrowserWindow({
8999
width: 1050,
@@ -99,8 +109,8 @@ function createWindow(cb) {
99109
browserWindow.webContents.classeurCtx = classeurCtx;
100110

101111
windows[browserWindow.id] = browserWindow;
102-
browserWindow.loadUrl(appUri);
103-
browserWindow.openDevTools();
112+
browserWindow.loadUrl(settings.appUrl);
113+
// browserWindow.openDevTools();
104114
browserWindow.on('closed', function() {
105115
classeurCtx.clean();
106116
delete windows[browserWindow.id];
@@ -120,6 +130,25 @@ function createWindow(cb) {
120130
return browserWindow;
121131
}
122132

133+
var settingsWindow;
134+
135+
function openSettingsWindow() {
136+
if (settingsWindow) {
137+
settingsWindow.show();
138+
return;
139+
}
140+
settingsWindow = new BrowserWindow({
141+
width: 320,
142+
height: 160,
143+
resizable: false,
144+
title: 'Settings',
145+
});
146+
settingsWindow.on('closed', function() {
147+
settingsWindow = undefined;
148+
});
149+
settingsWindow.loadUrl('file://' + __dirname + '/settings.html');
150+
}
151+
123152
function openFile(browserWindow, path) {
124153
browserWindow.webContents.classeurCtx.watchFile(path);
125154
browserWindow.focus();
@@ -159,10 +188,10 @@ function newFileDialog() {
159188
var isReady, openWhenReady;
160189
app.on('open-file', function(evt, path) {
161190
evt.preventDefault();
162-
if(isReady) {
191+
if (isReady) {
163192
return createWindow(function(browserWindow) {
164-
openFile(browserWindow, path);
165-
});
193+
openFile(browserWindow, path);
194+
});
166195
}
167196
openWhenReady = path;
168197
});
@@ -171,6 +200,15 @@ app.on('activate-with-no-open-windows', function() {
171200
createWindow();
172201
});
173202

203+
app.on('window-all-closed', function() {
204+
if (applySettings) {
205+
applySettings = false;
206+
createWindow();
207+
} else if (process.platform != 'darwin') {
208+
app.quit();
209+
}
210+
});
211+
174212
var ipc = require('ipc');
175213
ipc.on('getVersion', checkOrigin(function(evt) {
176214
var classeurCtx = evt.sender.classeurCtx;
@@ -196,17 +234,43 @@ ipc.on('saveFile', checkOrigin(function(evt, file) {
196234
}
197235
}));
198236

237+
ipc.on('getSettings', function(evt) {
238+
evt.sender.send('settings', settings);
239+
});
240+
241+
ipc.on('setSettings', function(evt, data) {
242+
settings = data;
243+
fs.writeFileSync(settingsFilePath, JSON.stringify(data));
244+
settingsWindow && settingsWindow.destroy();
245+
applySettings = true;
246+
Object.keys(windows).forEach(function(id) {
247+
windows[id].destroy();
248+
});
249+
});
250+
199251
function onReady() {
200252
var template = [{
201253
label: 'Classeur',
202254
submenu: [{
255+
label: 'New window',
256+
click: function() {
257+
createWindow();
258+
}
259+
}, {
260+
type: 'separator'
261+
}, {
203262
label: 'New local file',
204263
click: newFileDialog
205264
}, {
206265
label: 'Open local file',
207266
click: openFileDialog
208267
}, {
209268
type: 'separator'
269+
}, {
270+
label: 'Settings',
271+
click: openSettingsWindow
272+
}, {
273+
type: 'separator'
210274
}, {
211275
label: 'Hide Classeur',
212276
accelerator: 'Command+H',
File renamed without changes.

0 commit comments

Comments
 (0)