├── CHANGELOG.md ├── spec ├── magento-snippets-view-spec.coffee └── magento-snippets-spec.coffee ├── styles └── magento-snippets.less ├── snippets ├── basic-php.cson └── generic.cson ├── magento-snippets.cson ├── keymaps └── magento-snippets.cson ├── menus └── magento-snippets.cson ├── lib ├── magento-snippets-view.coffee └── magento-snippets.coffee ├── package.json ├── README.md └── LICENSE.md /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.1.0 - First Release 2 | * Every feature added 3 | * Every bug fixed 4 | -------------------------------------------------------------------------------- /spec/magento-snippets-view-spec.coffee: -------------------------------------------------------------------------------- 1 | MagentoSnippetsView = require '../lib/magento-snippets-view' 2 | 3 | describe "MagentoSnippetsView", -> 4 | it "has one valid test", -> 5 | expect("life").toBe "easy" 6 | -------------------------------------------------------------------------------- /styles/magento-snippets.less: -------------------------------------------------------------------------------- 1 | // The ui-variables file is provided by base themes provided by Atom. 2 | // 3 | // See https://github.com/atom/atom-dark-ui/blob/master/styles/ui-variables.less 4 | // for a full listing of what's available. 5 | @import "ui-variables"; 6 | 7 | .magento-snippets { 8 | } 9 | -------------------------------------------------------------------------------- /snippets/basic-php.cson: -------------------------------------------------------------------------------- 1 | ".text.php:not(.source)": 2 | 3 | "Debug with Zend Framework": 4 | "prefix": "Zend_Debug" 5 | "body": """ 6 | Zend_Debug::dump(${1:$thing_to_debug}, 'debug')$2 7 | """ 8 | "Debug in traditional var_dump": 9 | "prefix": "var_dump" 10 | "body": """ 11 | var_dump(${1:$thing_to_debug})$2 12 | """ 13 | -------------------------------------------------------------------------------- /magento-snippets.cson: -------------------------------------------------------------------------------- 1 | # Keybindings require three things to be fully defined: A selector that is 2 | # matched against the focused element, the keystroke and the command to 3 | # execute. 4 | # 5 | # Below is a basic keybinding which registers on all platforms by applying to 6 | # the root workspace element. 7 | 8 | # For more detailed documentation see 9 | # https://atom.io/docs/latest/behind-atom-keymaps-in-depth 10 | 'atom-workspace': 11 | 'ctrl-alt-o': 'magento-snippets:toggle' 12 | -------------------------------------------------------------------------------- /keymaps/magento-snippets.cson: -------------------------------------------------------------------------------- 1 | # Keybindings require three things to be fully defined: A selector that is 2 | # matched against the focused element, the keystroke and the command to 3 | # execute. 4 | # 5 | # Below is a basic keybinding which registers on all platforms by applying to 6 | # the root workspace element. 7 | 8 | # For more detailed documentation see 9 | # https://atom.io/docs/latest/behind-atom-keymaps-in-depth 10 | 'atom-workspace': 11 | 'ctrl-alt-o': 'magento-snippets:toggle' 12 | -------------------------------------------------------------------------------- /menus/magento-snippets.cson: -------------------------------------------------------------------------------- 1 | # See https://atom.io/docs/latest/hacking-atom-package-word-count#menus for more details 2 | 'context-menu': 3 | 'atom-text-editor': [ 4 | { 5 | 'label': 'Toggle magento-snippets' 6 | 'command': 'magento-snippets:toggle' 7 | } 8 | ] 9 | 'menu': [ 10 | { 11 | 'label': 'Packages' 12 | 'submenu': [ 13 | 'label': 'magento-snippets' 14 | 'submenu': [ 15 | { 16 | 'label': 'Toggle' 17 | 'command': 'magento-snippets:toggle' 18 | } 19 | ] 20 | ] 21 | } 22 | ] 23 | -------------------------------------------------------------------------------- /lib/magento-snippets-view.coffee: -------------------------------------------------------------------------------- 1 | module.exports = 2 | class MagentoSnippetsView 3 | constructor: (serializedState) -> 4 | # Create root element 5 | @element = document.createElement('div') 6 | @element.classList.add('magento-snippets') 7 | 8 | # Create message element 9 | message = document.createElement('div') 10 | message.textContent = "The MagentoSnippets package is Alive! It's ALIVE!" 11 | message.classList.add('message') 12 | @element.appendChild(message) 13 | 14 | # Returns an object that can be retrieved when package is activated 15 | serialize: -> 16 | 17 | # Tear down any state and detach 18 | destroy: -> 19 | @element.remove() 20 | 21 | getElement: -> 22 | @element 23 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "magento-tools", 3 | "main": "./lib/magento-snippets", 4 | "version": "0.0.3", 5 | "author": { 6 | "name": "Rafael Corrêa Gomes", 7 | "email": "rafaelcgstz@gmail.com", 8 | "url": "rafaelstz.github.io" 9 | }, 10 | "bugs": { 11 | "url": "https://github.com/rafaelstz/atom-magento-tools/issues" 12 | }, 13 | "description": "Magento Tools is perfect for those who want to be fast and practical in Magento development.", 14 | "keywords": [ 15 | "magento", 16 | "snippet", 17 | "cms", 18 | "Framework", 19 | "Zend" 20 | ], 21 | "activationCommands": { 22 | "atom-workspace": "magento-snippets:toggle" 23 | }, 24 | "repository": "https://github.com/rafaelstz/atom-magento-tools", 25 | "license": "MIT", 26 | "engines": { 27 | "atom": ">=0.174.0 <2.0.0" 28 | }, 29 | "dependencies": {} 30 | } 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Magento Tools [![Package Atom](https://img.shields.io/badge/Package-Atom-blue.svg)](https://atom.io/packages/magento-tools) [![Version 0.0.2](https://img.shields.io/badge/Release-0.0.2-green.svg)](https://github.com/rafaelstz/atom-magento-tools/releases) 2 | 3 | 4 | Ideal for developing Magento themes, get hints of the main functions, classes and methods. This plugin will greatly facilitate the development, mainly on the frontend. He suggests methods, built-in functions and classes Magento quickly and easily, it besides being open has a very simple way of contribution to customize your way. 5 | 6 | 7 | ##Contribute and Suggestions 8 | 9 | If you have something to improve these plugin, please create a [issue](https://github.com/rafaelstz/atom-magento-tools/issues). 10 | 11 | 12 | ![Suggestions](https://f.cloud.github.com/assets/69169/2290250/c35d867a-a017-11e3-86be-cd7c5bf3ff9b.gif) 13 | 14 | ## LICENSE 15 | (c) MIT 2015 - 2016, [Rafael Corrêa Gomes](https://github.com/rafaelstz) 16 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Rafael Corrêa Gomes 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/magento-snippets.coffee: -------------------------------------------------------------------------------- 1 | MagentoSnippetsView = require './magento-snippets-view' 2 | {CompositeDisposable} = require 'atom' 3 | 4 | module.exports = MagentoSnippets = 5 | magentoSnippetsView: null 6 | modalPanel: null 7 | subscriptions: null 8 | 9 | activate: (state) -> 10 | @magentoSnippetsView = new MagentoSnippetsView(state.magentoSnippetsViewState) 11 | @modalPanel = atom.workspace.addModalPanel(item: @magentoSnippetsView.getElement(), visible: false) 12 | 13 | # Events subscribed to in atom's system can be easily cleaned up with a CompositeDisposable 14 | @subscriptions = new CompositeDisposable 15 | 16 | # Register command that toggles this view 17 | @subscriptions.add atom.commands.add 'atom-workspace', 'magento-snippets:toggle': => @toggle() 18 | 19 | deactivate: -> 20 | @modalPanel.destroy() 21 | @subscriptions.dispose() 22 | @magentoSnippetsView.destroy() 23 | 24 | serialize: -> 25 | magentoSnippetsViewState: @magentoSnippetsView.serialize() 26 | 27 | toggle: -> 28 | console.log 'MagentoSnippets was toggled!' 29 | 30 | if @modalPanel.isVisible() 31 | @modalPanel.hide() 32 | else 33 | @modalPanel.show() 34 | -------------------------------------------------------------------------------- /snippets/generic.cson: -------------------------------------------------------------------------------- 1 | ".text.php:not(.source)": 2 | 3 | "Magento Base URL": 4 | "prefix": "mg-baseurl" 5 | "body": """$this->getBaseUrl($1)$2""" 6 | 7 | "Magento Skin URL": 8 | "prefix": "mg-skinurl" 9 | "body": """$this->getSkinUrl()$2""" 10 | 11 | "Magento Child Html": 12 | "prefix": "mg-childhtml" 13 | "body": """$this->getChildHtml($1)$2""" 14 | 15 | "Magento Escape Html": 16 | "prefix": "mg-escapeHtml" 17 | "body": """$this->escapeHtml($1)$2""" 18 | 19 | "Magento Helper": 20 | "prefix": "mg-helper" 21 | "body": """Mage::helper($1)$2""" 22 | 23 | "Magento CMS Block": 24 | "prefix": "mg-cms-block" 25 | "body": """ 26 | $this->getLayout()->createBlock('cms/block')->setBlockId('$1')->toHtml()$2 27 | """ 28 | 29 | "Magento Admin Variable": 30 | "prefix": "mg-admin-var" 31 | "body": """ 32 | Mage::getModel('core/variable')->loadByCode('$1')->getValue('')$2 33 | """ 34 | 35 | "Magento Product Type": 36 | "prefix": "mg-product-type" 37 | "body": """ 38 | $_product->getTypeId('$1')$2 39 | """ 40 | 41 | "Magento Translate": 42 | "prefix": "mg-this" 43 | "body": """ 44 | $this->__('$1')$2 45 | """ 46 | 47 | "Magento Attribute Text": 48 | "prefix": "mg-attr-text" 49 | "body": """ 50 | $_product->getAttributeText('$1')$2 51 | """ 52 | 53 | "Magento Secure URL": 54 | "prefix": "mg-secure-url" 55 | "body": """ 56 | $this->getUrl('$1'),array('_secure'=>true)$2 57 | """ 58 | 59 | "Magento Formartted Price": 60 | "prefix": "mg-formatted-price" 61 | "body": """ 62 | $Mage::helper('core')->currency(${1:$finalPrice}, true, false)$2 63 | """ 64 | 65 | "Magento Store Insformation": 66 | "prefix": "mg-store-info" 67 | "body": """ 68 | Mage::getStoreConfig('general/store_information/$1')$2 69 | """ 70 | 71 | "Magento load product by name": 72 | "prefix": "mg-load-product-by-name" 73 | "body": """ 74 | $_product = Mage::getModel('catalog/product')->loadByAttribute('${1:name}', '${2:emerald earring}');$3 75 | """ 76 | 77 | "Magento load category by name": 78 | "prefix": "mg-load-category-by-name" 79 | "body": """ 80 | $_product = Mage::getModel('catalog/category')->loadByAttribute('${1:name}', '${2:Ruby Ring}');$3 81 | """ 82 | 83 | "Magento load product by Id": 84 | "prefix": "mg-load-product-by-id" 85 | "body": """ 86 | $_product = Mage::getModel('catalog/product')->loadByAttribute('${1:sku}', '${2:Eram18j4}');$3 87 | """ 88 | -------------------------------------------------------------------------------- /spec/magento-snippets-spec.coffee: -------------------------------------------------------------------------------- 1 | MagentoSnippets = require '../lib/magento-snippets' 2 | 3 | # Use the command `window:run-package-specs` (cmd-alt-ctrl-p) to run specs. 4 | # 5 | # To run a specific `it` or `describe` block add an `f` to the front (e.g. `fit` 6 | # or `fdescribe`). Remove the `f` to unfocus the block. 7 | 8 | describe "MagentoSnippets", -> 9 | [workspaceElement, activationPromise] = [] 10 | 11 | beforeEach -> 12 | workspaceElement = atom.views.getView(atom.workspace) 13 | activationPromise = atom.packages.activatePackage('magento-snippets') 14 | 15 | describe "when the magento-snippets:toggle event is triggered", -> 16 | it "hides and shows the modal panel", -> 17 | # Before the activation event the view is not on the DOM, and no panel 18 | # has been created 19 | expect(workspaceElement.querySelector('.magento-snippets')).not.toExist() 20 | 21 | # This is an activation event, triggering it will cause the package to be 22 | # activated. 23 | atom.commands.dispatch workspaceElement, 'magento-snippets:toggle' 24 | 25 | waitsForPromise -> 26 | activationPromise 27 | 28 | runs -> 29 | expect(workspaceElement.querySelector('.magento-snippets')).toExist() 30 | 31 | magentoSnippetsElement = workspaceElement.querySelector('.magento-snippets') 32 | expect(magentoSnippetsElement).toExist() 33 | 34 | magentoSnippetsPanel = atom.workspace.panelForItem(magentoSnippetsElement) 35 | expect(magentoSnippetsPanel.isVisible()).toBe true 36 | atom.commands.dispatch workspaceElement, 'magento-snippets:toggle' 37 | expect(magentoSnippetsPanel.isVisible()).toBe false 38 | 39 | it "hides and shows the view", -> 40 | # This test shows you an integration test testing at the view level. 41 | 42 | # Attaching the workspaceElement to the DOM is required to allow the 43 | # `toBeVisible()` matchers to work. Anything testing visibility or focus 44 | # requires that the workspaceElement is on the DOM. Tests that attach the 45 | # workspaceElement to the DOM are generally slower than those off DOM. 46 | jasmine.attachToDOM(workspaceElement) 47 | 48 | expect(workspaceElement.querySelector('.magento-snippets')).not.toExist() 49 | 50 | # This is an activation event, triggering it causes the package to be 51 | # activated. 52 | atom.commands.dispatch workspaceElement, 'magento-snippets:toggle' 53 | 54 | waitsForPromise -> 55 | activationPromise 56 | 57 | runs -> 58 | # Now we can test for view visibility 59 | magentoSnippetsElement = workspaceElement.querySelector('.magento-snippets') 60 | expect(magentoSnippetsElement).toBeVisible() 61 | atom.commands.dispatch workspaceElement, 'magento-snippets:toggle' 62 | expect(magentoSnippetsElement).not.toBeVisible() 63 | --------------------------------------------------------------------------------