AppBurger

Fork me on GitHub

Native Mac Apps in HTML, CSS and Javascript

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);

Hungry?

Download your Burger now! (v 0.3)

AppBurger has access to the file system so this app has the ability to generate itself. With it you get apps like this:

Installation

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.

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!

Burger API Menu

Config$Free

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

OnLoad$Free

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);

isRunningOnBrowser()$Free

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
}

quit()$Free

Calling this method quits the app.


Burger.quit(); // you quitter...

showDockIcon()$Free

Calling this method shows the app icon on the dock.


Burger.showDockIcon();

hideDockIcon()$Free

Calling this method hides the app icon on the dock.


Burger.hideDockIcon();

setDockIcon(iconPath)$Free

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');

bounceDockIcon()$Free

Calling this method bounces the icon on the dock calling the user's attention (Use with care).


Burger.bounceDockIcon();

getUserData(key)$Free

Get data stored in NSUserDefaults corresponding to key.


var storedName = Burger.getUserData('name');

setUserData(key, value)$Free

Set data stored in NSUserDefaults corresponding to key with value.


Burger.setUserData('name', 'AppBurger');

disableCloseWindowButton()$Free

Disables the close window button.


Burger.disableCloseWindowButton();

enableCloseWindowButton()$Free

Enables the close window button.


Burger.enableCloseWindowButton();

disableMinimizeWindowButton()$Free

Disables the minimize window button.


Burger.disableMinimizeWindowButton();

enableMinimizeWindowButton()$Free

Enables the minimize window button.


Burger.enableMinimizeWindowButton();

disableZoomWindowButton()$Free

Disables the zoom window button.


Burger.disableZoomWindowButton();

enableZoomWindowButton()$Free

Enables the zoom window button.


Burger.enableZoomWindowButton();

hideCloseWindowButton()$Free

Hides the close window button.


Burger.hideCloseWindowButton();

showCloseWindowButton()$Free

Shows the close window button.


Burger.showCloseWindowButton();

hideMinimizeWindowButton()$Free

Hides the minimize window button.


Burger.hideMinimizeWindowButton();

showMinimizeWindowButton()$Free

Shows the minimize window button.


Burger.showMinimizeWindowButton();

hideZoomWindowButton()$Free

Hides the zoom window button.


Burger.hideZoomWindowButton();

showZoomWindowButton()$Free

Shows the zoom window button.


Burger.showZoomWindowButton();

minimizeWindow()$Free

Minimizes the window.


Burger.minimizeWindow();

unminimizeWindow()$Free

Unminimizes the window.


Burger.unminimizeWindow();

centerWindow()$Free

Centers the window on screen.


Burger.centerWindow();

resizeWindow(x, y, width, height)$Free

Resizes the window with all dimensions in pixels.


Burger.resizeWindow(30,20, 400, 550);

setWindowX(x)$Free

Sets the window x position.


Burger.setWindowX(30);

setWindowY(y)$Free

Sets the window y position.


Burger.setWindowY(30);

setWindowWidth(w)$Free

Sets the window width.


Burger.setWindowWidth(300);

setWindowHeight(h)$Free

Sets the window height.


Burger.setWindowHeight(600);

disableWindowResize()$Free

Locks the window size and disables resize by the user.


Burger.disableWindowResize();

enableWindowResize()$Free

Unlocks the window size and enables resize by the user.


Burger.enableWindowResize();

hideWindowTitleBar()$Free

Hides the window titlebar, with this you can achieve chromeless windows.


Burger.hideWindowTitleBar();

showWindowTitleBar()$Free

Shows the window titlebar.


Burger.showWindowTitleBar();

setWindowTitle(title)$Free

Sets the window title.


Burger.setWindowTitle('Hello AppBurger!');

getWindowTitle(title)$Free

Gets the window title.


var title = Burger.getWindowTitle();

addStatusBarItem(label, callback)$Free

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');
});

removeStatusBarItem(label)$Free

Removes a status bar menu item identified by it's label.


Burger.removeStatusBarItem('click me');

setStatusBarIcon(iconPath, activeIconPath)$Free

Sets the icon for the status bar menu beside the clock.


Burger.setStatusBarIcon('img/statusIcon.png', 'img/active.png');

setStatusBarLabel(label)$Free

Sets the label for the status bar menu beside the clock.


Burger.setStatusBarLabel('My Burger');

getWebRootPath()$Free

Gets the path to the www/ folder of your app.


var rootPath = Burger.getWebRootPath();

getAppPath()$Free

Gets the path to the NSBundle folder of your app.


var bundlePath = Burger.getAppPath();

getAppSupportPath()$Free

Gets the path to the Application Support folder of your app.


var appFilesPath = Burger.getAppSupportPath();

getCwd()$Free

Gets the current working directory of your app.


var currentDir = Burger.getCwd();

setCwd(path)$Free

Sets the current working directory of your app.


Burger.setCwd('/Users/burger/Documents/');

isDir(path)$Free

Checks if the specified path is a directory.


if (Burger.isDir('/Users/burger/Documents/')){
    // do stuff in dir
}

isFile(path)$Free

Checks if the specified path is a file.


if (Burger.isFile('/Users/burger/Documents/recipe.txt')){
    // do stuff with file
}

readDir(path)$Free

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]);
}

makeDir(path)$Free

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

deleteDir(path)$Free

Deletes the requested directory.


Burger.deleteDir('Path/to/new/dir');

readFile(path)$Free

Reads the file's content.


var content = Burger.readFile('/Users/burger/Documents/recipe.txt');

writeFile(path, data)$Free

Writes a file. Existing files will be replaced.


var recipe = 'Bread, meat, lettuce, tomato and ketchup';
Burger.writeFile('/Users/burger/Documents/recipe.txt', recipe);

deleteFile(path)$Free

Deletes a file.


Burger.deleteFile('/Users/burger/Documents/recipe.txt');

copyFile(from, to)$Free

Copy a file.


var from = '/Users/burger/Downloads/recipe.txt',
    to = '/Users/burger/Documents/recipe.txt';
Burger.copyFile(from, to);

move(from, to)$Free

Move a file.


var from = '/Users/burger/Downloads/recipe.txt',
    to = '/Users/burger/Documents/recipe.txt';
Burger.move(from, to);

download(url, to)$Free

Downloads a file.


var url = 'http://www.site.com/file.zip',
    to = '/Users/burger/Downloads/recipe.zip';
Burger.download(url, to);

unzip(source, to)$Free

Unzips a file.


var source = '/Users/burger/Downloads/recipe.zip',
    to = '/Users/burger/Documents/recipe';
Burger.copyFile(source, to);

sendNotification(title, message, sound)$Free

Sends a notification to the user.


Burger.sendNotification('hello', 'meeting at 10', true);

showSaveDialog(callback, filename)$Free

Opens the save file dialog panel.


Burger.showSaveDialog(function(path){
    if (path){
        Burger.writeFile(path, 'your recipe...');
    }
}, 'recipe.txt');

showOpenDialog(callback, allowDirs, allowFiles, allowMultiple)$Free

Opens the open file dialog panel.


Burger.showOpenDialog(function(files){
    if (files){
        var txt = Burger.readFile(files[0]);
    }
}, false, true, false);

Still Hungry?

Download your Burger now! (v 0.3)

About

AppBurger is a version 0.3 experiment by Juan Camilo Estela