refactored package, added keymaps and menus

This commit is contained in:
Donald Pipowitch 2014-03-04 08:07:45 +01:00
parent aa82d27d2e
commit bb9d241ebb
10 changed files with 87 additions and 34 deletions

1
.gitattributes vendored
View File

@ -1 +0,0 @@
* text=auto

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
.DS_Store
npm-debug.log npm-debug.log
node_modules node_modules

20
LICENSE
View File

@ -1,20 +0,0 @@
The MIT License (MIT)
Copyright (c) 2014 donaldpipowitch
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

22
LICENSE.md Normal file
View File

@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2014 Donald Pipowitch
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -1,14 +1,12 @@
# Beautify # atom-beautify package
[Atom package](https://github.com/einars/js-beautify)
> [Beautify](https://github.com/mishoo/UglifyJS2) HTML, CSS and Javascript in Atom.
[Beautify](https://github.com/einars/js-beautify) HTML, CSS and Javascript in Atom.
## Usage ## Usage
Open the Command Palette, and type `Beautify`. This will beautify JS, HTML or CSS files. It will only beautify selected text, if a selection is found - if not, the whole file will be beautified. Open the Command Palette, and type `Beautify`. This will beautify JS, HTML or CSS files. It will only beautify selected text, if a selection is found - if not, the whole file will be beautified.
You can also type `ctrl-alt-b` as a shortcut or click `Packages > Beautify` in the menu.
## License ## License

View File

@ -0,0 +1,11 @@
# Keybindings require three things to be fully defined: A selector that is
# matched against the focused element, the keystroke and the command to
# execute.
#
# Below is a basic keybinding which registers on all platforms by applying to
# the root workspace element.
# For more detailed documentation see
# https://atom.io/docs/latest/advanced/keymaps
'.workspace .editor:not(.mini)':
'ctrl-alt-b': 'beautify'

14
menus/atom-beautify.cson Normal file
View File

@ -0,0 +1,14 @@
# See https://atom.io/docs/latest/creating-a-package#menus for more details
'context-menu':
'.workspace .editor:not(.mini)':
'Enable atom-beautify': 'beautify'
'menu': [
{
'label': 'Packages'
'submenu': [
'label': 'Beautify'
'command': 'beautify'
]
}
]

View File

@ -1,22 +1,21 @@
{ {
"name": "beautify", "name": "atom-beautify",
"main": "./lib/atom-beautify",
"version": "0.0.0", "version": "0.0.0",
"private": true,
"description": "Beautify HTML, CSS and Javascript in Atom", "description": "Beautify HTML, CSS and Javascript in Atom",
"license": "MIT", "activationEvents": ["beautify"],
"repository": "https://github.com/donaldpipowitch/atom-beautify", "repository": "https://github.com/donaldpipowitch/atom-beautify",
"activationEvents": [ "license": "MIT",
"beautify"
],
"author": { "author": {
"name": "Donald Pipowitch", "name": "Donald Pipowitch",
"email": "pipo@senaeh.de", "email": "pipo@senaeh.de",
"url": "https://github.com/donaldpipowitch" "url": "https://github.com/donaldpipowitch"
}, },
"engines": { "engines": {
"atom": ">=0.50.0" "atom": ">0.50.0"
}, },
"dependencies": {}, "dependencies": {
"devDependencies": {
"js-beautify": "~1.4.2" "js-beautify": "~1.4.2"
} }
} }

View File

@ -0,0 +1,29 @@
AtomBeautify = require '../lib/atom-beautify'
# Use the command `window:run-package-specs` (cmd-alt-ctrl-p) to run specs.
#
# To run a specific `it` or `describe` block add an `f` to the front (e.g. `fit`
# or `fdescribe`). Remove the `f` to unfocus the block.
describe "AtomBeautify", ->
activationPromise = null
beforeEach ->
atom.workspaceView = new WorkspaceView
activationPromise = atom.packages.activatePackage('atomBeautify')
# describe "when the beautify event is triggered", ->
# it "attaches and then detaches the view", ->
# expect(atom.workspaceView.find('.atom-beautify')).not.toExist()
#
# # This is an activation event, triggering it will cause the package to be
# # activated.
# atom.workspaceView.trigger 'beautify'
#
# waitsForPromise ->
# activationPromise
#
# runs ->
# expect(atom.workspaceView.find('.atom-beautify')).toExist()
# atom.workspaceView.trigger 'beautify'
# expect(atom.workspaceView.find('.atom-beautify')).not.toExist()