2
2
mirror of https://github.com/Llewellynvdm/nativefier.git synced 2024-12-22 18:18:55 +00:00

Updated to support setting of window dimensions using the cli, and updated documentation

This commit is contained in:
Jia Hao 2015-07-06 10:31:09 +08:00
parent 3b815dd1ba
commit 4ddf10a108
6 changed files with 27 additions and 21 deletions

View File

@ -63,11 +63,17 @@ version-string should contain a hash of the application metadata to be embed
- ProductName
- InternalName
badge if the target app should show badges in the OSX dock on receipt of desktop notifications
width window width (default=1280)
height window height (default=800)
```
See [electron-packager](https://github.com/maxogden/electron-packager) for more details.
### Icon
On OSX, the icon parameter should be a path to an `.icns` file. [iConvertIcons](https://iconverticons.com/online/) can be used to convert `.pngs`, though it can be quite cumbersome.
#### OSX Dock Badge
To retrieve the `.icns` file from the downloaded file, extract it first and press File > Get Info. Then select the icon in the top left corner of the info window and press `⌘-C`. Open Preview and press File > New from clipboard and save the `.icns` file. It took me a while to figure out how to do that and question why a `.icns` file was not simply provided in the downloaded archive.
### OSX Dock Badge
On OSX, it is desired for the App dock icon to show a badge on the receipt of a desktop notification.
@ -91,7 +97,6 @@ Creating an native wrapper for Facebook Messenger with the following arguments:
$ nativefier Messenger http://messenger.com --platform=darwin --arch=x64 --version=0.29.1 --overwrite --badge
```
## Todo
## Issues
- Set the app icon from a url in the CLI
- Set the app window dimensions from the CLI
- Better workaround for desktop notifications and OSX dock badges

View File

@ -15,8 +15,8 @@ ipc.on('params', function(message) {
webView.setAttribute('id', 'webView');
webView.setAttribute('src', appArgs.targetUrl);
webView.setAttribute('autosize', 'on');
webView.setAttribute('minwidth', '600');
webView.setAttribute('minheight', '800');
webView.setAttribute('minwidth', '100');
webView.setAttribute('minheight', '100');
webView.addEventListener('new-window', function(e) {
require('shell').openExternal(e.url);

View File

@ -12,6 +12,8 @@ require('crash-reporter').start();
var mainWindow = null;
var appArgs = JSON.parse(fs.readFileSync(APP_ARGS_FILE_PATH, 'utf8'));
app.on('window-all-closed', function() {
if (process.platform != 'darwin') {
app.quit();
@ -21,8 +23,8 @@ app.on('window-all-closed', function() {
app.on('ready', function() {
mainWindow = new BrowserWindow(
{
width: 1280,
height: 800,
width: appArgs.width || 1280,
height: appArgs.height || 800,
'web-preferences': {
javascript: true,
plugins: true,
@ -33,16 +35,8 @@ app.on('ready', function() {
//mainWindow.openDevTools();
mainWindow.webContents.on('did-finish-load', function() {
fs.readFile(APP_ARGS_FILE_PATH, 'utf8', function (error, data) {
if (error) {
console.error('Error reading app config file: ' + error);
} else {
console.log(data);
mainWindow.webContents.send('params', data);
}
})
mainWindow.webContents.send('params', JSON.stringify(appArgs));
});
// if the window is focused, clear the badge

2
cli.js
View File

@ -32,7 +32,7 @@ if (!validator.isURL(args.target)) {
process.exit(1);
}
tempDir(args.name, args.target, args.badge, function (error, appDir) {
tempDir(args.name, args.target, args.badge, args.width, args.height, function (error, appDir) {
if (error) {
console.error(error);

View File

@ -18,9 +18,12 @@ var ncp = require('ncp').ncp;
*
* @param {string} name
* @param {string} targetURL
* @param {boolean} badge
* @param width
* @param height
* @param {tempDirCallback} callback
*/
module.exports = function (name, targetURL, badge, callback) {
module.exports = function (name, targetURL, badge, width, height, callback) {
var tempDir = temp.path();
ncp(__dirname + '/app', tempDir, function (error) {
@ -33,7 +36,9 @@ module.exports = function (name, targetURL, badge, callback) {
var appArgs = {
name: name,
targetUrl: targetURL,
badge: badge
badge: badge,
width: width,
height: height
};
fs.writeFileSync(tempDir + '/targetUrl.txt', JSON.stringify(appArgs));

View File

@ -35,4 +35,6 @@ version-string should contain a hash of the application metadata to be embed
- ProductVersion
- ProductName
- InternalName
badge if the target app should show badges in the OSX dock on receipt of desktop notifications
badge if the target app should show badges in the OSX dock on receipt of desktop notifications
width window width (default=1280)
height window height (default=800)