├── LICENSE ├── lib └── ionic.coffee ├── package.json ├── readme.md └── stylesheets └── ionic.css /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Nicholas Gartmann 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /lib/ionic.coffee: -------------------------------------------------------------------------------- 1 | {$, ScrollView, View, Task, File} = require 'atom' 2 | url = require "url" 3 | http = require("http") 4 | 5 | 6 | class WebBrowserPreviewView extends ScrollView 7 | @content: (params) -> 8 | @iframe outlet: "frame", class: "iphone", src: params.url, sandbox: "allow-same-origin allow-scripts" 9 | getTitle: -> 10 | "Ionic: Preview" 11 | initialize: (params) -> 12 | me = $(@) 13 | @url = params.url 14 | @.on 'load', -> 15 | $(window).on 'resize', -> 16 | height = me[0].parentNode?.scrollHeight 17 | if height? and height < me.height() 18 | me.css("transform", "scale(" + ((height - 100) / me.height()) + ")") 19 | else 20 | me.css("transform", "none") 21 | 22 | go: -> 23 | me = $(@) 24 | @.src = @url 25 | height = me[0].parentNode?.scrollHeight 26 | if height? and height < me.height() 27 | me.css("transform", "scale(" + ((height - 100) / me.height()) + ")") 28 | else 29 | me.css("transform", "none") 30 | 31 | me.css("display", "block") 32 | 33 | 34 | 35 | module.exports = 36 | activate: -> 37 | atom.workspaceView.command "ionic:preview", => 38 | atom.workspace.open "ionic://localhost:8100", split: "right" 39 | 40 | atom.workspace.registerOpener (uri) -> 41 | try 42 | {protocol, host, pathname} = url.parse(uri) 43 | catch 44 | return 45 | 46 | return unless protocol is "ionic:" 47 | 48 | uri = url.parse(uri) 49 | uri.protocol = "http:" 50 | 51 | preview = new WebBrowserPreviewView(url: uri.format()) 52 | 53 | http.get(uri.format(), -> 54 | preview.go() 55 | atom.workspace.activateNextPane() 56 | ).on('error', -> 57 | atom.workspace.destroyActivePaneItem() 58 | alert("You have to start the ionic server first!") 59 | ) 60 | 61 | return preview 62 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ionic-atom", 3 | "main": "./lib/ionic", 4 | "version": "0.3.1", 5 | "license": "MIT", 6 | "description": "View your ionic apps right in your editor.", 7 | "repository": "https://github.com/RokkinCat/ionic-atom", 8 | "engines": { 9 | "atom": ">0.108.0" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Ionic Atom 2 | 3 | Preview a live version of your [Ionic](http://www.ionicframework.com) application 4 | in an atom pane. 5 | 6 | ![](http://i.imgur.com/hiiSpXm.png) 7 | 8 | ## Getting Started 9 | 10 | In your terminal: 11 | ```bash 12 | apm install ionic-atom 13 | ionic serve -b 14 | ``` 15 | 16 | Then hit `Cmd + Shift + P` in atom and use the command `Ionic: Preview` 17 | 18 | (note: if you don't see `Ionic: Preview` in the list you may need to restart atom) 19 | 20 | This will open a new pane with your app displayed in it. 21 | 22 | ## TODO 23 | * Get a license up (go ahead and use it for whatever) 24 | * Test on windows 25 | * Auto-start the ionic server 26 | * Better access to dev logs 27 | * CONTRIBUTE.md 28 | * Specs 29 | -------------------------------------------------------------------------------- /stylesheets/ionic.css: -------------------------------------------------------------------------------- 1 | .iphone { 2 | width: 320px; 3 | height: 568px; 4 | margin: auto; 5 | border: none; 6 | display: none; 7 | } 8 | --------------------------------------------------------------------------------