├── CNAME ├── _posts ├── .gitkeep ├── 2014-06-03-app-configuration.md ├── 2014-06-03-manipulating-the-menu.md ├── 2014-06-16-dock.md ├── 2014-06-03-macgap-events.md ├── 2014-06-03-clipboard.md ├── 2014-06-03-getting-started.md ├── 2014-06-03-notify.md ├── 2014-06-03-defaults.md ├── 2014-06-03-dialog.md ├── 2014-06-18-developing.md ├── 2014-06-13-contributing.md ├── 2014-06-16-sound.md ├── 2014-06-13-customising.md ├── 2014-06-03-fonts.md ├── 2014-06-16-menuItem.md ├── 2014-06-03-status-item.md ├── 2014-06-23-file.md ├── 2014-06-03-task.md ├── 2014-06-03-window.md ├── 2014-06-03-menu.md └── 2014-06-11-macgap.md ├── .gitignore ├── _includes ├── footer.html ├── header.html └── navigation.html ├── _layouts ├── page.html └── default.html ├── about.md ├── index.md ├── _config.yml ├── README.md ├── css ├── main.css └── syntax.css └── bin └── jekyll-page /CNAME: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /_posts/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | _site 2 | _pages -------------------------------------------------------------------------------- /_includes/footer.html: -------------------------------------------------------------------------------- 1 | Documentation for {{ site.title }} 2 | -------------------------------------------------------------------------------- /_includes/header.html: -------------------------------------------------------------------------------- 1 |

{{ site.title }} 2 | {% if site.subtitle %}{{ site.subtitle }}{% endif %} 3 |

4 | 5 | -------------------------------------------------------------------------------- /_posts/2014-06-03-app-configuration.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: "App Configuration" 4 | category: doc 5 | date: 2014-06-03 15:56:41 6 | order: 2 7 | --- 8 | 9 | 10 | -------------------------------------------------------------------------------- /_posts/2014-06-03-manipulating-the-menu.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: "Manipulating the Menu" 4 | category: doc 5 | date: 2014-06-03 15:57:23 6 | order: 3 7 | --- 8 | 9 | 10 | -------------------------------------------------------------------------------- /_layouts/page.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | --- 4 | 5 | 10 | 11 | {{ content }} 12 | -------------------------------------------------------------------------------- /_posts/2014-06-16-dock.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: "Dock" 4 | category: ref 5 | date: 2014-06-16 12:00:00 6 | order: 40 7 | --- 8 | 9 | # WARNING: MacGap2 code has not been finalised for this command. 10 | 11 | ## Methods 12 | 13 | ### MacGap.Dock() 14 | 15 | Set the Dock's badge 16 | 17 | ```js 18 | MacGap.Dock.addBadge("10"); 19 | ``` 20 | -------------------------------------------------------------------------------- /_posts/2014-06-03-macgap-events.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: "MacGap Events" 4 | category: doc 5 | date: 2014-06-03 15:57:43 6 | order: 4 7 | --- 8 | 9 | 10 | MacGap triggers various events on the DOM document. 11 | 12 | ### sleep 13 | 14 | ### wake 15 | 16 | ### appActivated 17 | 18 | ### userDefaultsChanged 19 | 20 | ### statusItemClick 21 | 22 | -------------------------------------------------------------------------------- /_posts/2014-06-03-clipboard.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: "Clipboard" 4 | category: ref 5 | date: 2014-06-03 15:56:11 6 | order: 30 7 | --- 8 | 9 | ## Properties 10 | 11 | 12 | ## Methods 13 | 14 | ## MacGap.Clipboard.copy(someText); 15 | 16 | 17 | 18 | ## MacGap.Clipboard.paste(); 19 | 20 | ```js 21 | var clipboard = MacGap.Clipboard.paste(); 22 | ``` 23 | -------------------------------------------------------------------------------- /_posts/2014-06-03-getting-started.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: "Getting Started" 4 | category: doc 5 | date: 2014-06-03 15:56:27 6 | order: 1 7 | --- 8 | 9 | 10 | 11 | ## Step 1 - Clone the Repository 12 | 13 | $ git clone https://github.com/MacGapProject/MacGap2.git 14 | 15 | ## Step 2 - Open the Project in Xcode 16 | $ open MacGap2/MG.xcodeproj/ 17 | 18 | ## Step 3 - Build your App by editing public/index.html in Xcode 19 | -------------------------------------------------------------------------------- /about.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: About 4 | permalink: /about/ 5 | --- 6 | 7 | This is the base Jekyll theme. You can find out more info about customizing your Jekyll theme, as well as basic Jekyll usage documentation at [jekyllrb.com](http://jekyllrb.com/) 8 | 9 | You can find the source code for the Jekyll new theme at: [github.com/jglovier/jekyll-new](https://github.com/jglovier/jekyll-new) 10 | 11 | You can find the source code for Jekyll at [github.com/jekyll/jekyll](https://github.com/jekyll/jekyll) 12 | -------------------------------------------------------------------------------- /_posts/2014-06-03-notify.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: "Notify" 4 | category: ref 5 | date: 2014-06-03 15:55:46 6 | order: 140 7 | --- 8 | 9 | # WARNING: MacGap.Notify.notify() has been deprecated and will be removed in a future release. Please use MacGap.notify() instead. 10 | 11 | Either: 12 | 13 | * send a Native User notification 14 | * trigger a modal 'sheet' 15 | 16 | ## Methods 17 | 18 | ### MacGap.Notify.notify() 19 | 20 | ```js 21 | MacGap.Notify.notify({ 22 | type: 'sheet', 23 | title: 'A title', 24 | content: 'Some content.' 25 | }); 26 | ``` 27 | 28 | 29 | -------------------------------------------------------------------------------- /_posts/2014-06-03-defaults.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: "Defaults" 4 | category: ref 5 | date: 2014-06-03 15:56:02 6 | order: 40 7 | --- 8 | 9 | 10 | Properties | description 11 | ---------- | ----------- 12 | defaults | get defined defaults as js object 13 | 14 | Methods | Arguments | description 15 | -------- | --------- | ------------ 16 | set | (string) key, (any) value, (string) type | key and value are required, if type is omitted, the value is saved as a string. 17 | get | (string) key, (string) type | type is optional, if not defined, will return the keys value as a string. Accepted types are: "string", "int", "bool", "float", "url", "object" 18 | -------------------------------------------------------------------------------- /_posts/2014-06-03-dialog.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: "Dialog" 4 | category: ref 5 | date: 2014-06-03 15:55:26 6 | order: 40 7 | --- 8 | 9 | 10 | Methods | Arguments | description 11 | -------- | --------- | ------------ 12 | openDialog | (*object*) { files: true, multiple: true, directories: true, allowedTypes: ['txt', 'doc', 'js'], callback: function() {...} } | all params are optional and default to false 13 | saveDialog | (*object*) { {title:"Sheet Title", prompt: "Button Text", message: "Sheet Message", filename: "myfile.txt", createDirs: true, allowedTypes: ['txt', 'doc', 'js'], callback: function(result) { console.log(result); }}} | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /_posts/2014-06-18-developing.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: "Developing your app" 4 | category: doc 5 | date: 2014-06-03 15:55:26 6 | order: 2 7 | --- 8 | 9 | ### Enable Developer Tools for debugging 10 | 11 | You can enable Webkit's developer tools within your MacGap application, by entering the following command into your Terminal. 12 | 13 | ``` 14 | defaults write com.MG developer 1 15 | ``` 16 | 17 | After the above has been done, you will be able to right-click anywhere in your app window and select 'Inspect Element' as you usually can in Safari. 18 | 19 | MG is the default app name in Xcode. Be sure to replace this if you have changed your app's name. 20 | -------------------------------------------------------------------------------- /_posts/2014-06-13-contributing.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: "Contributing to MacGap" 4 | category: doc 5 | date: 2014-06-13 15:56:27 6 | order: 10 7 | --- 8 | 9 | 10 | MacGap is the result of hundreds of hours of time volunteered by people like you. If you have any of the following skills we could really use your help! 11 | 12 | * JavaScript coding (help with documention, sample code, the documentation app, answers in the issue queue) 13 | 14 | * HTML / CSS (help with theming of this documentation, theming of the documentation app's CSS, the public macgap.com site) 15 | 16 | * Objective-C (help improving MacGap 2 itself, documentation, and helping on the issue queue) 17 | -------------------------------------------------------------------------------- /_posts/2014-06-16-sound.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: "Sound" 4 | category: ref 5 | date: 2014-06-16 12:00:00 6 | order: 190 7 | --- 8 | 9 | # WARNING: MacGap2 code has not been finalised for this command. 10 | 11 | ## Methods 12 | 13 | ### MacGap.Sound.play() 14 | 15 | Play a sound 16 | 17 | ```js 18 | macgap.sound.play("./my/sound.mp3") 19 | ``` 20 | 21 | ### MacGap.Sound.playSystem() 22 | 23 | Play a system sound 24 | 25 | ```js 26 | macgap.sound.playSystem("Funk"); 27 | ``` 28 | 29 | Optionally, supply a callback to run when the sound finishes playing. 30 | 31 | ```js 32 | macgap.sound.playSystem("Funk", function(){ 33 | alert('Sound finished playing'); 34 | }); 35 | ``` 36 | -------------------------------------------------------------------------------- /_includes/navigation.html: -------------------------------------------------------------------------------- 1 | 17 | -------------------------------------------------------------------------------- /_posts/2014-06-13-customising.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: "Customising your app" 4 | category: doc 5 | date: 2014-06-13 15:56:27 6 | order: 3 7 | --- 8 | 9 | 10 | ### How to change the project name in Xcode 11 | 12 | *This documentation is incomplete. Please help us by [contributing your knowledge](https://macgapproject.github.io/documentation/doc/contributing.html)* 13 | 14 | ### How to build and package your app for distribution 15 | 16 | *This documentation is incomplete. Please help us by [contributing your knowledge](https://macgapproject.github.io/documentation/doc/contributing.html)* 17 | 18 | ### Building for Mac App Store submission 19 | 20 | *This documentation is incomplete. Please help us by [contributing your knowledge](https://macgapproject.github.io/documentation/doc/contributing.html)* 21 | -------------------------------------------------------------------------------- /_posts/2014-06-03-fonts.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: "Fonts" 4 | category: ref 5 | date: 2014-06-03 15:55:53 6 | order: 60 7 | --- 8 | 9 | # WARNING: MacGap2 code has not been finalised for this command. 10 | 11 | ## Properties 12 | 13 | ### MacGap.Fonts.availableFonts 14 | 15 | Return an array of installed font names 16 | 17 | ```js 18 | MacGap.Fonts.availableFonts; 19 | ``` 20 | 21 | 22 | ### MacGap.Fonts.availableFontFamilies 23 | 24 | Return an array of installed font families 25 | 26 | ```js 27 | MacGap.Fonts.availableFontFamilies(); 28 | ``` 29 | 30 | 31 | ## Methods 32 | 33 | ### MacGap.Fonts.availableMembersOfFontFamily(fontFamily) 34 | 35 | Return the fonts in the given font family. 36 | 37 | ```js 38 | MacGap.Fonts.availableMembersOfFontFamily('Helvetica'); 39 | ``` 40 | 41 | 42 | ### MacGap.Fonts.getLineHeight(theFontName, theFontSize) 43 | 44 | Return the line height of the specified font at the specified size. 45 | 46 | ```js 47 | MacGap.Fonts.getLineHeight('Helvetica', 12); 48 | ``` 49 | -------------------------------------------------------------------------------- /index.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: "MacGap Documentation" 4 | --- 5 | 6 | # MacGap 7 | 8 | The MacGap project provides HTML/JS/CSS developers an Xcode project for developing Native OSX Apps. 9 | 10 | The project exposes a JavaScript API for OS X integration, such as displaying native OS X 10.9 notifications. The MacGap project is extremely lightweight and nimble; a blank application is about 380KB. 11 | 12 | ### Features: 13 | * open-source 14 | * tiny compiled app sizes 15 | * Mac App Store compatible 16 | * access to many Mac OS X-specific features 17 | 18 | ## Pre-requisites 19 | 20 | MacGap 2 works on OSX 10.9 and later. MacGap 1 works on OSX 10.6 and later. 21 | 22 | ## API 23 | 24 | MacGap exposes an object called `MacGap` inside JavaScript. 25 | 26 | ## Attributes 27 | 28 | MacGap was forked/ported from Phonegap-mac. It's under the same license (MIT). 29 | 30 | ## Custom Build 31 | 32 | To build, make sure you have installed the latest Mac OSX Core Library. Download at [http://developer.apple.com/](http://developer.apple.com/). 33 | 34 | Just clone the repository and build in Xcode. The file `public/index.html` is loaded on startup. 35 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | # Site title and subtitle. This is used in _includes/header.html 2 | title: 'MacGap' 3 | subtitle: 'Desktop WebKit wrapper for HTML/CSS/JS applications.' 4 | 5 | # Enable/show navigation. There are there options: 6 | # 0 - always hide 7 | # 1 - always show 8 | # 2 - show only if posts are present 9 | navigation: 2 10 | 11 | # URL to source code, used in _includes/footer.html 12 | codeurl: 'https://macgapproject.github.io/documentation/' 13 | 14 | # Default categories (in order) to appear in the navigation 15 | sections: [ 16 | ['doc', 'Documentation'], 17 | ['tut', 'Tutorial'], 18 | ['ref', 'Command Reference'], 19 | ['dev', 'Developers'], 20 | ['post', 'Posts'] 21 | ] 22 | 23 | # Keep as an empty string if served up at the root. If served up at a specific 24 | # path (e.g. on GitHub pages) leave off the trailing slash, e.g. /my-project 25 | baseurl: '/documentation' 26 | 27 | # Dates are not included in permalinks 28 | permalink: none 29 | 30 | # Syntax highlighting 31 | highlighter: 'rouge' 32 | 33 | # Since these are pages, it doesn't really matter 34 | future: true 35 | 36 | # Exclude non-site files 37 | exclude: ['bin', 'README.md'] 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Documentation for MacGap 2 2 | 3 | The documentation is available at https://macgapproject.github.io/documentation/ 4 | 5 | ### Contributing 6 | 7 | We would love your help improving this documentation: 8 | 9 | * fixing errors 10 | * adding code examples 11 | * improving wording 12 | 13 | We would also like: 14 | 15 | * CSS / HTML theming help (see https://macgapproject.github.io/documentation/ for how it looks right now) 16 | 17 | ### Getting started 18 | 19 | To contribute to the documentation, please clone this repository and submit a pull request like you would on any other repository. 20 | 21 | The documentation is generated using [Jekyll](https://github.com/jekyll/jekyll). The page for each command is inside _posts and is written in Markdown format. Filenames must follow the syntax expected by Jekyll: 22 | 23 | `YEAR-MM-DD-description.md` 24 | 25 | At the top of each documentation page is a table of metadata which Jekyll uses to automatically build the navigation menu etc. It's easiest to simply copy this from an existing page then modify it, to get this right. 26 | 27 | Jekyll automatically compiles the HTML output when the GIT repository is updated. 28 | 29 | *If you would like full write access to this repository please add an issue in the issue queue.* 30 | -------------------------------------------------------------------------------- /_posts/2014-06-16-menuItem.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: "MenuItem" 4 | category: ref 5 | date: 2014-06-16 15:54:20 6 | order: 131 7 | --- 8 | 9 | 10 | 11 | ## Properties 12 | 13 | ### MacGap.MenuItem.label 14 | 15 | gets or sets menu item's label 16 | 17 | ```js 18 | MacGap.Menu.getItem("Files").label = "File"; 19 | ``` 20 | 21 | 22 | ### MacGap.MenuItem.submenu 23 | 24 | gets or sets menu item's submenu 25 | 26 | ```js 27 | var fileMenu = MacGap.Menu.getItem("File").submenu; 28 | ``` 29 | 30 | 31 | ### MacGap.MenuItem.callback 32 | 33 | gets or sets menu item's callback function -- this is the function that will be called when the menu item is clicked 34 | 35 | ```js 36 | MacGap.Menu.getItem("File").submenu.getItem("Open").callback = function() { MacGap.Dialog.openDialog(); }; 37 | ``` 38 | 39 | 40 | ### MacGap.MenuItem.enabled 41 | 42 | enable or disable the menu item by passing true or false 43 | 44 | *note*: this *only* works for menus created with MacGap. Menu items added in Interface Builder cannot be modified this way. If you want to control enabling/disabling menu items via Javascript, use MacGap.Menu.addItem 45 | 46 | ```js 47 | MacGap.Menu.getItem("File").submenu.getItem("Open").enabled = false; 48 | ``` 49 | 50 | 51 | ## Methods 52 | 53 | ### MacGap.MenuItem.addSubmenu(title) 54 | 55 | Add a submenu with an optional title 56 | 57 | ```js 58 | MacGap.Menu.getItem("File").addSubmenu(); 59 | ``` 60 | 61 | 62 | ### MacGap.MenuItem.setKey(keys) 63 | 64 | Set menu item's key shortcut 65 | 66 | ```js 67 | MacGap.Menu.getItem("File").submenu.getItem("Open").setKey('cmd+o'); 68 | ``` 69 | 70 | 71 | ### MacGap.MenuItem.remove() 72 | 73 | Remove a menu item 74 | 75 | ``` 76 | MacGap.Menu.getItem("File").submenu.getItem("Open").remove(); 77 | ``` 78 | -------------------------------------------------------------------------------- /_posts/2014-06-03-status-item.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: "StatusItem" 4 | category: ref 5 | date: 2014-06-03 15:54:56 6 | order: 190 7 | --- 8 | 9 | Gets/sets the status items menu. 10 | 11 | ## Methods 12 | 13 | ### MacGap.StatusItem.create(configObject, callback) 14 | 15 | ######Arguments 16 | 17 | `configObject` is a Javascript object containing the following keys: 18 | `title`: a `string` 19 | `titleFontSize`: an `integer` 20 | `image`: a `string` containing the path to the image to use for the status menu item 21 | `alternateImage`: a `string` containing the path to the alternate (over/down state) image 22 | 23 | ######Description 24 | 25 | Set up a status bar menu item, or menu. 26 | 27 | ######Examples: 28 | 29 | ```js 30 | var item = MacGap.StatusItem.create({ 31 | title: 'Title', 32 | titleFontSize: 16, 33 | image:'path/to/image.png', 34 | alternateImage: 'path/to/alternateimg.png' 35 | }, function() { 36 | alert('Item clicked'); 37 | }); 38 | ``` 39 | 40 | Putting a custom menu into the status bar: 41 | 42 | ```js 43 | // Create and add a menu to the statusbar. Note that adding a menu to a status item disables any onClick events 44 | // Setting the second 'type' parameter in the create method to 'statusbar' keeps MacGap from automatically adding sub-menus to the menu items you create (this is because the status items don't have a supermenu like the main menu) 45 | var menu = MacGap.Menu.create('My Menu', 'statusbar'); 46 | 47 | // add items to the menu 48 | menu.addItem({label: 'My Menu Item', keys: '', index: 0}, function() { alert('I was clicked!'); }); 49 | menu.addItem({label: 'Another Menu Item', keys: '', index: 1}, function() { ... }); 50 | 51 | // Add the menu to the status item. 52 | MacGap.StatusItem.menu = menu; 53 | ``` 54 | -------------------------------------------------------------------------------- /_posts/2014-06-23-file.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: "File" 4 | category: ref 5 | date: 2014-06-03 15:55:53 6 | order: 63 7 | --- 8 | 9 | File read/write capability for text/string based files. 10 | 11 | ## Methods 12 | 13 | ### MacGap.File.write(filePath, fileData, fileType) 14 | 15 | ######Arguments 16 | 17 | `filePath` must be a `string` 18 | 19 | `fileData` must be a `string`, JavaScript Object, or base64 representation of an image 20 | 21 | `fileType` must be a `string` and contain one of the following values: `string`, `json` or `image` 22 | 23 | ######Description 24 | 25 | Write the provided fileData string to a file. 26 | 27 | If `fileType` is set to `json`, this method will automatically convert the JavaScript object to proper JSON before writing to the file. 28 | 29 | ######Example: 30 | 31 | ```js 32 | MacGap.File.write('path/to/file1', 'Data to save', 'string'); 33 | MacGap.File.write('path/to/file2', '{something:"else"}', 'json'); 34 | ``` 35 | 36 | 37 | ### MacGap.File.read(filePath, fileType) 38 | 39 | ######Arguments 40 | 41 | `filePath` must be a `string` 42 | 43 | `fileType` must be a `string` and contain one of the following values: `string`, `json` or `image` 44 | 45 | ######Description 46 | 47 | Read the file at the provided path. If `fileType` is set to `json`, this method will automatically convert the JSON back to a JavaScript object. 48 | 49 | ######Example: 50 | 51 | ```js 52 | var fileDataString = MacGap.File.read('/Users/myname/Desktop/textfile.txt', 'string'); 53 | ``` 54 | 55 | 56 | ### MacGap.File.exists(filePath) 57 | 58 | ######Arguments 59 | 60 | `filePath` must be a `string` 61 | 62 | ######Description 63 | 64 | Return a boolean indicating whether a file or folder exists at the provided `filePath`. 65 | 66 | Note: checking if a file exists before opening it is an anti-pattern that leaves you vulnerable to race conditions: another process may remove the file between the calls to File.exists() and File.read(). Just read the file and handle the error when it's not there. 67 | 68 | ######Example: 69 | 70 | ```js 71 | var tempDirExists = MacGap.File.exists('/tmp'); 72 | ``` 73 | -------------------------------------------------------------------------------- /css/main.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-weight: 400; 3 | font-family: 'Helvetica'; 4 | padding-top: 50px; 5 | } 6 | 7 | pre, code { 8 | border: none; 9 | border-radius: 0; 10 | background-color: #f9f9f9; 11 | font-size: 0.85em; 12 | } 13 | 14 | pre { 15 | font-size: 1em; 16 | } 17 | a, 18 | a:hover { 19 | text-decoration: none; 20 | color: #d96b5d; 21 | } 22 | code { 23 | color: inherit; 24 | } 25 | 26 | td, th { 27 | padding:6px; 28 | } 29 | thead { 30 | border-bottom:2px solid #ccc; 31 | } 32 | tbody th, tbody td { 33 | border-top:1px solid #ccc; 34 | } 35 | 36 | #header { 37 | border-bottom: 1px solid #eee; 38 | margin-bottom: 20px; 39 | } 40 | 41 | #header a:hover { 42 | text-decoration: none; 43 | } 44 | 45 | #footer { 46 | margin: 20px 0; 47 | font-size: 0.85em; 48 | color: #999; 49 | text-align: center; 50 | } 51 | #main { 52 | padding:20px; 53 | } 54 | #content > .page-header:first-child { 55 | margin-top: 0; 56 | } 57 | 58 | #content > .page-header:first-child h2 { 59 | margin-top: 0; 60 | } 61 | 62 | 63 | #navigation { 64 | font-size: 0.9em; 65 | } 66 | 67 | #navigation li a { 68 | padding-left: 10px; 69 | padding-right: 10px; 70 | } 71 | 72 | 73 | .sidebar { 74 | position: fixed; 75 | top: 51px; 76 | bottom: 0; 77 | left: 0; 78 | z-index: 1000; 79 | display: block; 80 | padding: 20px 0; 81 | overflow-x: hidden; 82 | overflow-y: auto; 83 | border-right: 1px solid #EEE; 84 | } 85 | 86 | .sidebar .nav li { 87 | padding-left: 20px; 88 | border-left: 4px solid transparent; 89 | } 90 | .sidebar .nav li:hover { 91 | background: #f1f1f1; 92 | border-color: #d96b5d; 93 | 94 | } 95 | .sidebar .nav li a { 96 | color: #949494; 97 | } 98 | .sidebar .nav li a:hover { 99 | background: none; 100 | } 101 | .sidebar .nav li.nav-header { 102 | padding-left: 10px; 103 | font-weight: bold; 104 | text-transform: uppercase; 105 | font-size: 12px; 106 | letter-spacing: 1px; 107 | } 108 | .sidebar .nav li.nav-header:hover { 109 | border-color: transparent; 110 | background: none; 111 | } 112 | .navbar-inverse { 113 | background-color: #444; 114 | border-color: #333; 115 | } 116 | 117 | .navbar-header h4 { 118 | margin-top: 13px; 119 | color: white; 120 | 121 | } 122 | .navbar-header h4 a{ 123 | color: white; 124 | letter-spacing: 1px; 125 | text-shadow: none; 126 | } 127 | -------------------------------------------------------------------------------- /_posts/2014-06-03-task.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: "Task" 4 | category: ref 5 | date: 2014-06-03 15:55:08 6 | order: 200 7 | --- 8 | 9 | ## MacGap.Task.create(path, callback) 10 | 11 | Creates a task object to execute a system command. 12 | 13 | ### Arguments 14 | 15 | | Argument | description 16 | | -------- | ----------- 17 | | path | A string path to the executable system command, '/usr/ls' or '/bin/cat' 18 | | callback | A callback function to receive the result of the command 19 | 20 | ### Callback 21 | 22 | The callback will be invoked when the task is complete. A result object will be passed to the function. 23 | 24 | | Property | description 25 | | -------- | ----------- 26 | | status | An integer, 0 for success or non-zero for 27 | | stdIn | ? 28 | | stdErr | ? 29 | | stdOut | A string representing what std out of the system command 30 | 31 | ### Example 32 | 33 | This example creates a task calling the `whoami` function to identify the current user. 34 | 35 | ```js 36 | var myTask = MacGap.Task.create('/usr/bin/whoami', function(result) { 37 | if(result.status == 0) { 38 | console.log('The current user is ', result.stdOut); 39 | } else { 40 | console.log('An error occurred retrieving the current user.'); 41 | } 42 | }); 43 | myTask.pipeOutput = true; 44 | myTask.launch(); 45 | ``` 46 | 47 | ## MacGap.Task Object 48 | 49 | The object to interface with the task. 50 | 51 | ## Properties 52 | 53 | | Propertiy name | Description 54 | | -------------- | ----------- 55 | | isRunning | is task currently running, returns boolean 56 | | waitUntilExit | primarily used as a setter, see NSTask reference for what this is 57 | | arguments | set/get arguments to pass to task. Passed arguments need to be in the form of an array, i.e. task.arguments = ['arg1', 3, 'whatever']; 58 | | environment | set's the tasks environment variables, defaults to application's 59 | | pipeOutput | converts the stdOut value to string format in the callback result object, default false 60 | 61 | ## Methods 62 | 63 | | Method name | Arguments | description 64 | | ----------- | --------- | ------------ 65 | | launch | none | launches task 66 | | terminate | none | kills currently running task 67 | 68 | ### Example 69 | 70 | This example initiates a `say` task with an argument, launches the command and terminates it if it's still running in 500ms. 71 | 72 | ```js 73 | var myTask = MacGap.Task.create('/usr/bin/say'); 74 | myTask.arguments = ['hello there']; 75 | myTask.launch(); 76 | 77 | // terminate if running too long 78 | setTimeout(function(){ 79 | if(myTask.isRunning){ 80 | myTask.terminate(); 81 | } 82 | }, 500); 83 | ``` 84 | -------------------------------------------------------------------------------- /_posts/2014-06-03-window.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: "Window" 4 | category: ref 5 | date: 2014-06-03 15:54:08 6 | order: 240 7 | --- 8 | 9 | 10 | ## Properties 11 | 12 | ### MacGap.Window.x 13 | 14 | Window's current X coordinate. 15 | 16 | *Example usage* 17 | 18 | ```js 19 | var xPos = MacGap.Window.x; 20 | ``` 21 | 22 | ### MacGap.Window.y 23 | 24 | Window's current Y coordinate. 25 | 26 | *Example usage* 27 | 28 | ```js 29 | var yPos = MacGap.Window.y; 30 | ``` 31 | 32 | 33 | ### MacGap.Window.isMaximized 34 | 35 | Is the window maximized. 36 | 37 | *Example usage* 38 | 39 | ```js 40 | var isMaximized = MacGap.Window.isMaximized; 41 | ``` 42 | 43 | ## Methods 44 | 45 | ### MacGap.Window.open(url) 46 | 47 | `url` is a string 48 | 49 | Open a new window, containing a webview loaded with the specified URL. 50 | 51 | *Example usage* 52 | 53 | ```js 54 | MacGap.Window.open('http://apple.com'); 55 | ``` 56 | 57 | ### MacGap.Window.move(x, y) 58 | 59 | `x` and `y` are integers. 60 | 61 | Move the window to the specified x, y coordinates. 62 | 63 | *Example usage* 64 | 65 | ```js 66 | MacGap.Window.move(300, 200); 67 | ``` 68 | 69 | ### MacGap.Window.resize(width, height) 70 | 71 | `width` and `height` are integers. 72 | 73 | Resize the window to the specified width and height. 74 | 75 | *Example usage* 76 | 77 | ```js 78 | MacGap.Window.resize(500, 300); 79 | ``` 80 | 81 | 82 | ### MacGap.Window.title(newTitle) 83 | 84 | `newTitle` is a string. 85 | 86 | Change the window title to newTitle. 87 | 88 | NOTE: when first opened, the window title is specified in the `config.json` configuration file. See (App Configuration)[https://macgapproject.github.io/documentation/doc/app-configuration.html]. 89 | 90 | *Example usage* 91 | 92 | ```js 93 | MacGap.Window.title('My New Window Title'); 94 | ``` 95 | 96 | 97 | ### MacGap.Window.maximize() 98 | 99 | Maximize the window. 100 | 101 | *Example usage* 102 | 103 | ```js 104 | MacGap.Window.maximize(); 105 | ``` 106 | 107 | 108 | ### MacGap.Window.minimize() 109 | 110 | Minimize the window. 111 | 112 | *Example usage* 113 | 114 | ```js 115 | MacGap.Window.minimize(); 116 | ``` 117 | 118 | 119 | ### MacGap.Window.restore() 120 | 121 | Restore a minimized window. 122 | 123 | *Example usage* 124 | 125 | ```js 126 | MacGap.Window.restore(); 127 | ``` 128 | 129 | 130 | ### MacGap.Window.toggleFullscreen() 131 | 132 | Toggle the window to and from full-screen. 133 | 134 | *Example usage* 135 | 136 | ```js 137 | // Make the window full-screen. 138 | MacGap.Window.toggleFullscreen(); 139 | 140 | // Wait 5 seconds then make the window not full-screen. 141 | window.setInterval(function(){ 142 | MacGap.Window.toggleFullscreen(); 143 | }, 5000); 144 | ``` 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | -------------------------------------------------------------------------------- /bin/jekyll-page: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'date' 4 | require 'optparse' 5 | 6 | options = { 7 | # Expects to be in the bin/ sub-directory by default 8 | :path => File.dirname(File.dirname(__FILE__)) 9 | } 10 | 11 | parser = OptionParser.new do |opt| 12 | opt.banner = 'usage: jekyll-page TITLE CATEGORY [FILENAME] [OPTIONS]' 13 | opt.separator '' 14 | opt.separator 'Options' 15 | opt.on('-e', '--edit', 'Edit the page') do |edit| 16 | options[:edit] = true 17 | end 18 | opt.on('-l', '--link', 'Relink pages') do |link| 19 | options[:link] = true 20 | end 21 | opt.on('-p PATH', '--path PATH', String, 'Path to project root') do |path| 22 | options[:path] = path 23 | end 24 | opt.separator '' 25 | end 26 | 27 | parser.parse! 28 | 29 | title = ARGV[0] 30 | category = ARGV[1] 31 | filename = ARGV[2] 32 | 33 | # Resolve any relative links 34 | BASE_DIR = File.expand_path(options[:path]) 35 | POSTS_DIR = "#{BASE_DIR}/_posts" 36 | PAGES_DIR = "#{BASE_DIR}/_pages" 37 | 38 | # Ensure the _posts directory exists (we are in the correct directory) 39 | if not Dir.exists?(POSTS_DIR) 40 | puts "#{POSTS_DIR} directory does not exists" 41 | exit 42 | end 43 | 44 | # Create _pages directory if it doesn't exist 45 | if not Dir.exists?(PAGES_DIR) 46 | Dir.mkdir(PAGES_DIR) 47 | end 48 | 49 | if options[:link] 50 | Dir.foreach(POSTS_DIR) do |name| 51 | next if name[0] == '.' 52 | nodate = name[/\d{4}-\d{2}-\d{2}-(?.*)/, 'rest'] 53 | if File.symlink?("#{PAGES_DIR}/#{nodate}") 54 | File.delete("#{PAGES_DIR}/#{nodate}") 55 | end 56 | abspath = File.absolute_path("#{POSTS_DIR}/#{name}") 57 | File.symlink(abspath, "#{PAGES_DIR}/#{nodate}") 58 | end 59 | end 60 | 61 | if not title or not category 62 | # This flag can be used by itself, exit silently if no arguments 63 | # are defined 64 | if not options[:link] 65 | puts parser 66 | end 67 | exit 68 | end 69 | 70 | if not filename 71 | filename = title.downcase.gsub(/[^a-z0-9\s]/, '').gsub(/\s+/, '-') 72 | end 73 | 74 | today=Date.today().strftime('%F') 75 | now=DateTime.now().strftime('%F %T') 76 | 77 | filepath = "#{POSTS_DIR}/#{today}-#{filename}.md" 78 | symlink = "#{PAGES_DIR}/#{filename}.md" 79 | 80 | if File.exists?(filepath) 81 | puts "File #{filepath} already exists" 82 | exit 83 | end 84 | 85 | content = < 2 | 3 | 4 | 5 | 6 | 7 | 8 | {{ site.title }}{% if page.title %} : {{ page.title }}{% endif %} 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 28 |
29 |
30 | {% assign post_count = site.posts|size %} 31 | {% if site.navigation != 0 and site.navigation == 1 or post_count > 0 %} 32 | 35 | 36 |
37 | {{ content }} 38 |
39 | {% else %} 40 |
41 | {{ content }} 42 |
43 | {% endif %} 44 |
45 | 46 |
47 | 50 |
51 |
52 | 53 | 54 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /css/syntax.css: -------------------------------------------------------------------------------- 1 | .highlight .hll { background-color: #ffffcc } 2 | .highlight { background: #ffffff; } 3 | .highlight .c { color: #888888 } /* Comment */ 4 | .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ 5 | .highlight .k { color: #008800; font-weight: bold } /* Keyword */ 6 | .highlight .cm { color: #888888 } /* Comment.Multiline */ 7 | .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ 8 | .highlight .c1 { color: #888888 } /* Comment.Single */ 9 | .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ 10 | .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ 11 | .highlight .ge { font-style: italic } /* Generic.Emph */ 12 | .highlight .gr { color: #aa0000 } /* Generic.Error */ 13 | .highlight .gh { color: #333333 } /* Generic.Heading */ 14 | .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ 15 | .highlight .go { color: #888888 } /* Generic.Output */ 16 | .highlight .gp { color: #555555 } /* Generic.Prompt */ 17 | .highlight .gs { font-weight: bold } /* Generic.Strong */ 18 | .highlight .gu { color: #666666 } /* Generic.Subheading */ 19 | .highlight .gt { color: #aa0000 } /* Generic.Traceback */ 20 | .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ 21 | .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ 22 | .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ 23 | .highlight .kp { color: #008800 } /* Keyword.Pseudo */ 24 | .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ 25 | .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ 26 | .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ 27 | .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ 28 | .highlight .na { color: #336699 } /* Name.Attribute */ 29 | .highlight .nb { color: #003388 } /* Name.Builtin */ 30 | .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ 31 | .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ 32 | .highlight .nd { color: #555555 } /* Name.Decorator */ 33 | .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ 34 | .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ 35 | .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ 36 | .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ 37 | .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ 38 | .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ 39 | .highlight .nv { color: #336699 } /* Name.Variable */ 40 | .highlight .ow { color: #008800 } /* Operator.Word */ 41 | .highlight .w { color: #bbbbbb } /* Text.Whitespace */ 42 | .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ 43 | .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ 44 | .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ 45 | .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ 46 | .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ 47 | .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ 48 | .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ 49 | .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ 50 | .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ 51 | .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ 52 | .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ 53 | .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ 54 | .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ 55 | .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ 56 | .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ 57 | .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ 58 | .highlight .vc { color: #336699 } /* Name.Variable.Class */ 59 | .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ 60 | .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ 61 | .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ 62 | --------------------------------------------------------------------------------