Develop and test on the browser, deploy as a mac app. It's your web app on steroids, with cheese and bacon. Using AppBurger you wrap your existing code in a native mac app and do stuff like this:
// A Cheese burger coming up!
document.addEventListener('load', function() {
// Order no. 1 is ready!
Burger.setDockIcon('img/icon.png');
Burger.setWindowHeight(500);
Burger.centerWindow();
Burger.setWindowTitle('Hello Cheese Burger!');
var data;
if (Burger.isRunningOnBrowser()){
alert('Welcome, can I take your order?');
Burger.showOpenDialog(function(files){
if (files){
order = Burger.readFile(files[0]);
cookBurger(order);
Burger.sendNotification('Order', 'Coming up!');
}
});
}else{
data = callSomeApiViaAjax();
}
}, false);
AppBurger has access to the file system so this app has the ability to generate itself. With it you get apps like this:
To install AppBurger fork the repo or download it. Run the project on xcode and any mac 10.7+. That's it, you now have the AppBurgerGenerator app which you will use to generate your app.
Once you have the AppBurgerGenerator running simply put your app name, bundle identifier and destination folder and press generate. That's it, go to the destination directory and open the generated project on xcode and start developing (while you eat a delicious burger). AppBurger is an app that can reproduce itself, it's an AppBurger invasion!
AppBurger has several configuration settings which you can tweak on config.plist. These are:
- showDockIcon[YES, NO]: Shows the apps icon in the dock
- enableStatusBarMenu[YES, NO]: Shows a status bar menu item for the app
- allowWindowResize[YES, NO]: Allows the user to resize the window, this allows the OS to save the last window position and size. This will be overridden by startWidth and startHeight setting
- allowWebkitDebug[YES, NO]: Shows "Inspect element" menu on right click
- splashScreenImage[path/to/file]: Image used as splash screen while webview is loading
- splashBackgroundColor[#RRGGBB]: No need to explain this one
- startPage[path, url]: Path used as start up page, defaults to index.html
- startWith[int]: Width of window at start up
- startHeight[int]: Height of window at start up
To capture the burgerready event, set up a listener for that event. This event is triggered once the native app architecture is ready. Keep in mind that you can also use the standard DOM load event which is recommended to avoid cross device compatibility headaches.
document.addEventListener('burgerready', function() {
// your burger is ready
}, false);
document.addEventListener('load', function() {
// DOM is ready
}, false);
This method returns true if the AppBurger instance is running on the browser, false otherwise. This delicious feature is useful to have the same codebase working on the app and on the browser which promotes code reusability and makes debugging easier.
if (Burger.isRunningOnBrowser()){
// do browser stuff
}else{
// do native app stuff
}
Calling this method quits the app.
Burger.quit(); // you quitter...
Calling this method shows the app icon on the dock.
Burger.showDockIcon();
Calling this method hides the app icon on the dock.
Burger.hideDockIcon();
Calling this method sets the app icon to the png image specified on iconPath.
// set an icon to an image inside /www
Burger.setDockIcon('img/icon.png');
// set an icon to an image from the web
Burger.setDockIcon('http://www.cool.com/image.png');
Calling this method bounces the icon on the dock calling the user's attention (Use with care).
Burger.bounceDockIcon();
Get data stored in NSUserDefaults corresponding to key.
var storedName = Burger.getUserData('name');
Set data stored in NSUserDefaults corresponding to key with value.
Burger.setUserData('name', 'AppBurger');
Disables the close window button.
Burger.disableCloseWindowButton();
Enables the close window button.
Burger.enableCloseWindowButton();
Disables the minimize window button.
Burger.disableMinimizeWindowButton();
Enables the minimize window button.
Burger.enableMinimizeWindowButton();
Disables the zoom window button.
Burger.disableZoomWindowButton();
Enables the zoom window button.
Burger.enableZoomWindowButton();
Hides the close window button.
Burger.hideCloseWindowButton();
Shows the close window button.
Burger.showCloseWindowButton();
Hides the minimize window button.
Burger.hideMinimizeWindowButton();
Shows the minimize window button.
Burger.showMinimizeWindowButton();
Hides the zoom window button.
Burger.hideZoomWindowButton();
Shows the zoom window button.
Burger.showZoomWindowButton();
Minimizes the window.
Burger.minimizeWindow();
Unminimizes the window.
Burger.unminimizeWindow();
Centers the window on screen.
Burger.centerWindow();
Resizes the window with all dimensions in pixels.
Burger.resizeWindow(30,20, 400, 550);
Sets the window x position.
Burger.setWindowX(30);
Sets the window y position.
Burger.setWindowY(30);
Sets the window width.
Burger.setWindowWidth(300);
Sets the window height.
Burger.setWindowHeight(600);
Locks the window size and disables resize by the user.
Burger.disableWindowResize();
Unlocks the window size and enables resize by the user.
Burger.enableWindowResize();
Hides the window titlebar, with this you can achieve chromeless windows.
Burger.hideWindowTitleBar();
Shows the window titlebar.
Burger.showWindowTitleBar();
Sets the window title.
Burger.setWindowTitle('Hello AppBurger!');
Gets the window title.
var title = Burger.getWindowTitle();
By default, all AppBurger apps place a menu on the status bar. With this method you can add menu items that call javascript callbacks.
Burger.addStatusBarItem('click me', function(){
alert('You clicked me');
});
Removes a status bar menu item identified by it's label.
Burger.removeStatusBarItem('click me');
Sets the icon for the status bar menu beside the clock.
Burger.setStatusBarIcon('img/statusIcon.png', 'img/active.png');
Sets the label for the status bar menu beside the clock.
Burger.setStatusBarLabel('My Burger');
Gets the path to the www/ folder of your app.
var rootPath = Burger.getWebRootPath();
Gets the path to the NSBundle folder of your app.
var bundlePath = Burger.getAppPath();
Gets the path to the Application Support folder of your app.
var appFilesPath = Burger.getAppSupportPath();
Gets the current working directory of your app.
var currentDir = Burger.getCwd();
Sets the current working directory of your app.
Burger.setCwd('/Users/burger/Documents/');
Checks if the specified path is a directory.
if (Burger.isDir('/Users/burger/Documents/')){
// do stuff in dir
}
Checks if the specified path is a file.
if (Burger.isFile('/Users/burger/Documents/recipe.txt')){
// do stuff with file
}
Iterates over the files inside the specified directory.
var files = Burger.readDir('/Users/burger/Documents/');
for (var i in files){
console.log(i + ': ' + files[i]);
}
Makes the requested directory with intermediate directories.
Burger.makeDir('Path/to/new/dir');
// if to/ and new/ don't exist, they will also be created
Deletes the requested directory.
Burger.deleteDir('Path/to/new/dir');
Reads the file's content.
var content = Burger.readFile('/Users/burger/Documents/recipe.txt');
Writes a file. Existing files will be replaced.
var recipe = 'Bread, meat, lettuce, tomato and ketchup';
Burger.writeFile('/Users/burger/Documents/recipe.txt', recipe);
Deletes a file.
Burger.deleteFile('/Users/burger/Documents/recipe.txt');
Copy a file.
var from = '/Users/burger/Downloads/recipe.txt',
to = '/Users/burger/Documents/recipe.txt';
Burger.copyFile(from, to);
Move a file.
var from = '/Users/burger/Downloads/recipe.txt',
to = '/Users/burger/Documents/recipe.txt';
Burger.move(from, to);
Downloads a file.
var url = 'http://www.site.com/file.zip',
to = '/Users/burger/Downloads/recipe.zip';
Burger.download(url, to);
Unzips a file.
var source = '/Users/burger/Downloads/recipe.zip',
to = '/Users/burger/Documents/recipe';
Burger.copyFile(source, to);
Sends a notification to the user.
Burger.sendNotification('hello', 'meeting at 10', true);
Opens the save file dialog panel.
Burger.showSaveDialog(function(path){
if (path){
Burger.writeFile(path, 'your recipe...');
}
}, 'recipe.txt');
Opens the open file dialog panel.
Burger.showOpenDialog(function(files){
if (files){
var txt = Burger.readFile(files[0]);
}
}, false, true, false);
AppBurger is a version 0.3 experiment by Juan Camilo Estela