Skip to content
Newer
Older
100644 117 lines (72 sloc) 3.42 KB
0c00f8a @maccman update README
maccman authored
1 #MacGap
78bed5a @maccman first commit
maccman authored
2
414df37 @euforic added Native 10.8 UserNotifications
euforic authored
3 The MacGap project aims to provide HTML/JS/CSS developers an Xcode project for developing Native OSX Apps that run in OSX's WebView and take advantage of WebKit technologies. The project also exposes a basic JavaScript API for OS integration, such as display Growl notifications. The MacGap project is extremely lightweight and nimble, a blank application is about 0.3mb.
4
78bed5a @maccman first commit
maccman authored
5 ##Pre-requisites
6
013b4b9 @maccman Update README.md
maccman authored
7 MacGap works on OSX 10.6 and 10.5.
386a058 @maccman readme tweaks
maccman authored
8
1293724 @maccman make readme more obvious
maccman authored
9 Generate apps with the [macgap generator](http://github.com/maccman/macgap-rb), no compile necessary.
e502720 @maccman fix link
maccman authored
10
414df37 @euforic added Native 10.8 UserNotifications
euforic authored
11 gem install macgap
12
29403c7 @maccman Update README.md
maccman authored
13 macgap new myapp
14 macgap build myapp
414df37 @euforic added Native 10.8 UserNotifications
euforic authored
15
78bed5a @maccman first commit
maccman authored
16 ##API
17
0c00f8a @maccman update README
maccman authored
18 MacGap exposes an object called `macgap` inside JavaScript. You can use it to alter the Dock icon and display Growl notifications, amongst other things. The API is documented below:
78bed5a @maccman first commit
maccman authored
19
ed1d446 @maccman update README
maccman authored
20 App:
21
78bed5a @maccman first commit
maccman authored
22 // Quit application
0c00f8a @maccman update README
maccman authored
23 macgap.app.terminate();
78bed5a @maccman first commit
maccman authored
24
25 // Activate application (bring to front)
0c00f8a @maccman update README
maccman authored
26 macgap.app.activate();
414df37 @euforic added Native 10.8 UserNotifications
euforic authored
27
78bed5a @maccman first commit
maccman authored
28 // Hide application
0c00f8a @maccman update README
maccman authored
29 macgap.app.hide();
414df37 @euforic added Native 10.8 UserNotifications
euforic authored
30
78bed5a @maccman first commit
maccman authored
31 // Un-hide application
0c00f8a @maccman update README
maccman authored
32 macgap.app.unhide();
330437b @liamks Can change the location and size of app's window
liamks authored
33
78bed5a @maccman first commit
maccman authored
34 // System bell
0c00f8a @maccman update README
maccman authored
35 macgap.app.beep();
414df37 @euforic added Native 10.8 UserNotifications
euforic authored
36
ed1d446 @maccman update README
maccman authored
37 // Open URL in default browser
38 macgap.app.open("http://google.com");
414df37 @euforic added Native 10.8 UserNotifications
euforic authored
39
ed1d446 @maccman update README
maccman authored
40 // Launch application
41 macgap.app.launch("TextEdit");
414df37 @euforic added Native 10.8 UserNotifications
euforic authored
42
ed1d446 @maccman update README
maccman authored
43 Window:
78bed5a @maccman first commit
maccman authored
44
b606360 @liamks added new window, move and resize. Cleaned up code as well
liamks authored
45 // Open a new window
ed1d446 @maccman update README
maccman authored
46 macgap.window.open({url:"public/index2.html", width: 400, height: 300});
b606360 @liamks added new window, move and resize. Cleaned up code as well
liamks authored
47
48 // Resize window
49 macgap.window.resize({width: 400, height: 200});
50
2baa1b3 @liamks woops found another error in readme - fixed
liamks authored
51 // Move window (Bottom left is x:0 and y:0)
92f180a @liamks fixed Readme
liamks authored
52 macgap.window.move({x:0, y: 200});
414df37 @euforic added Native 10.8 UserNotifications
euforic authored
53
ed1d446 @maccman update README
maccman authored
54 Path:
414df37 @euforic added Native 10.8 UserNotifications
euforic authored
55
78bed5a @maccman first commit
maccman authored
56 // Path to application
0c00f8a @maccman update README
maccman authored
57 macgap.path.application;
414df37 @euforic added Native 10.8 UserNotifications
euforic authored
58
78bed5a @maccman first commit
maccman authored
59 // Path to application's resources
0c00f8a @maccman update README
maccman authored
60 macgap.path.resource;
414df37 @euforic added Native 10.8 UserNotifications
euforic authored
61
ed1d446 @maccman update README
maccman authored
62 Dock:
78bed5a @maccman first commit
maccman authored
63
64 // Set the Dock's badge
0c00f8a @maccman update README
maccman authored
65 macgap.dock.badge = "10";
414df37 @euforic added Native 10.8 UserNotifications
euforic authored
66
ed1d446 @maccman update README
maccman authored
67 Sound:
78bed5a @maccman first commit
maccman authored
68
69 // Play a sound
0c00f8a @maccman update README
maccman authored
70 macgap.sound.play("./my/sound.mp3")
414df37 @euforic added Native 10.8 UserNotifications
euforic authored
71
78bed5a @maccman first commit
maccman authored
72 // Play a system sound
0c00f8a @maccman update README
maccman authored
73 macgap.sound.playSystem("funk");
414df37 @euforic added Native 10.8 UserNotifications
euforic authored
74
ed1d446 @maccman update README
maccman authored
75 Growl:
78bed5a @maccman first commit
maccman authored
76
77 // Send a Growl notification
0c00f8a @maccman update README
maccman authored
78 macgap.growl.notify({
78bed5a @maccman first commit
maccman authored
79 title: "Notify",
80 content: "New Message!"
81 });
d858339 @liamks added sleep/wake events
liamks authored
82
414df37 @euforic added Native 10.8 UserNotifications
euforic authored
83 Notice:
84
85 // Send a Native User notification
86 macgap.notice.notify({
87 title: "Notify",
88 content: "New Message!"
89 });
90
d858339 @liamks added sleep/wake events
liamks authored
91 Events:
92
93 //Mac OS X on wake event.
a64c518 @liamks cleaned-up and made DRY the wake/sleep event implementation
liamks authored
94 document.addEventListener('wake', function(){console.log('Wake!!')}, true);
414df37 @euforic added Native 10.8 UserNotifications
euforic authored
95
d858339 @liamks added sleep/wake events
liamks authored
96 //Mac OS X on sleep event.
a64c518 @liamks cleaned-up and made DRY the wake/sleep event implementation
liamks authored
97 document.addEventListener('sleep', function(){console.log('Sleep!!')}, true);
414df37 @euforic added Native 10.8 UserNotifications
euforic authored
98
78bed5a @maccman first commit
maccman authored
99 ##Offline Patterns
100
414df37 @euforic added Native 10.8 UserNotifications
euforic authored
101 Desktop apps load immediately and work offline, whilst web apps have the advantage of being easily updated and remotely managed. MacGap gives you the best of both worlds via HTML5's offline APIs.
78bed5a @maccman first commit
maccman authored
102
103 First you can define a refresh tag in `index.html`, which will immediately forward your WebView to a given address.
104
105 <meta http-equiv="refresh" content="0;url=http://example.com">
106
386a058 @maccman readme tweaks
maccman authored
107 Then use [HTML5 offline APIs](http://www.w3.org/TR/html5/offline.html) to cache your application locally. The first time your application launches, it'll download all the remote resources for use offline. Then during subsequent launches the locally cached resources will be used, and the application will fully function offline. If your remote application changes, then the cache manifest will be updated and application re-cached.
0c00f8a @maccman update README
maccman authored
108
109 ##Attributes
110
1293724 @maccman make readme more obvious
maccman authored
111 MacGap was forked/ported from Phonegap-mac. It's under the same license (MIT).
112
113 ##Custom Build
114
115 To build, make sure you have installed the latest Mac OSX Core Library. Download at [http://developer.apple.com/](http://developer.apple.com/).
116
117 Just clone the repository and build in Xcode. The file `public/index.html` is loaded on startup.
Something went wrong with that request. Please try again.