diff --git a/docs/tutorial/quick-start.md b/docs/tutorial/quick-start.md index 8e3051786c..7cee03da4c 100644 --- a/docs/tutorial/quick-start.md +++ b/docs/tutorial/quick-start.md @@ -41,11 +41,10 @@ But unlike node-webkit, you could not do native GUI related operations in web pages, instead you need to do them on the browser side by sending messages or use the easy [remote](../api/renderer/remote.md) module. + ## Write your first atom-shell app -### The architecture of an app - -Generally, an app of atom-shell should contains at least following files: +Generally, an atom-shell app would be like this: ```text app/ @@ -61,20 +60,21 @@ this: ```json { - "name" : "atom", + "name" : "your-app", "version" : "0.1.0", "main" : "main.js" } ``` -The `main.js` will be executed, and in which you should do the initialization -work. To give the developers more power, atom-shell works by exposing -necessary Content APIs in javascript, so developers can precisely control -every piece of the app. An example of `main.js` is: +The `main.js` should create windows and handle system events, and an typical +example is: ```javascript var app = require('app'); // Module to control application life. -var Window = require('window'); // Module to create native browser window. +var BrowserWindow = require('browser-window'); // Module to create native browser window. + +// Report crashes to our server. +require('crash-reporter').start(); // Keep a global reference of the window object, if you don't, the window will // be closed automatically when the javascript object is GCed. @@ -82,27 +82,20 @@ var mainWindow = null; // Quit when all windows are closed. app.on('window-all-closed', function() { - app.terminate(); + if (process.platform != 'darwin') + app.quit(); }); // This method will be called when atom-shell has done everything // initialization and ready for creating browser windows. app.on('ready', function() { - // Create the browser window, - mainWindow = new Window({ width: 800, height: 600 }); + // Create the browser window. + mainWindow = new BrowserWindow({width: 800, height: 600}); + // and load the index.html of the app. mainWindow.loadUrl('file://' + __dirname + '/index.html'); - // Catch the event when web page in the window changes its title. - mainWindow.on('page-title-updated', function(event, title) { - // Prevent the default behaviour of 'page-title-updated' event. - event.preventDefault(); - - // Add a prefix for the window's original title. - this.setTitle('Atom Shell - ' + title); - }); - - // Hook to when the window is closed. + // Emitted when the window is closed. mainWindow.on('closed', function() { // Dereference the window object, usually you would store windows // in an array if your app supports multi windows, this is the time @@ -112,14 +105,52 @@ app.on('ready', function() { }); ``` -Finally the `index.html` is the web page you want to show, in fact you -actually don't need to provide it, you can just make the window load url of a -remote page. +Finally the `index.html` is the web page you want to show: -### Package your app in atom-shell +```html + + +
+