commit d38f11be66b60a42a7c96d9ace3b7300ce049cdf Author: Seong Jae Lee Date: Sat Nov 8 10:20:46 2014 -0800 Initialize a package using Atom's package generator diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ade14b9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.DS_Store +npm-debug.log +node_modules diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..c3d858c --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +## 0.1.0 - First Release +* Every feature added +* Every bug fixed diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..7ce8c08 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,20 @@ +Copyright (c) 2014 + +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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..61595cd --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# notational-velocity package + +A short description of your package. + +![A screenshot of your spankin' package](https://f.cloud.github.com/assets/69169/2290250/c35d867a-a017-11e3-86be-cd7c5bf3ff9b.gif) diff --git a/keymaps/notational-velocity.cson b/keymaps/notational-velocity.cson new file mode 100644 index 0000000..189248b --- /dev/null +++ b/keymaps/notational-velocity.cson @@ -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': + 'ctrl-alt-o': 'notational-velocity:toggle' diff --git a/lib/notational-velocity-view.coffee b/lib/notational-velocity-view.coffee new file mode 100644 index 0000000..9a1b60a --- /dev/null +++ b/lib/notational-velocity-view.coffee @@ -0,0 +1,43 @@ +fs = require 'fs' + +module.exports = +class NotationalVelocityView + constructor: (serializeState) -> + # Create root element + @element = document.createElement('div') + @element.classList.add('notational-velocity', 'overlay', 'from-top') + + # Create message element + message = document.createElement('div') + message.textContent = "The NotationalVelocity package is Alive! It's ALIVE!" + message.classList.add('message') + @element.appendChild(message) + + # Register command that toggles this view + atom.commands.add 'atom-workspace', 'notational-velocity:toggle': => @toggle() + + # Returns an object that can be retrieved when package is activated + serialize: -> + + # Tear down any state and detach + destroy: -> + @element.remove() + + # Toggle the visibility of this view + toggle: -> + console.log 'NotationalVelocityView was toggled!' + + @readdir() + + if @element.parentElement? + @element.remove() + else + atom.workspaceView.append(@element) + + # read filenames in a specific directory + readdir: -> + fs.readdir '.', (error, filenames) => + if error + throw error + for filename in filenames + console.log filename diff --git a/lib/notational-velocity.coffee b/lib/notational-velocity.coffee new file mode 100644 index 0000000..d4810b0 --- /dev/null +++ b/lib/notational-velocity.coffee @@ -0,0 +1,13 @@ +NotationalVelocityView = require './notational-velocity-view' + +module.exports = + notationalVelocityView: null + + activate: (state) -> + @notationalVelocityView = new NotationalVelocityView(state.notationalVelocityViewState) + + deactivate: -> + @notationalVelocityView.destroy() + + serialize: -> + notationalVelocityViewState: @notationalVelocityView.serialize() diff --git a/menus/notational-velocity.cson b/menus/notational-velocity.cson new file mode 100644 index 0000000..a6a7ed7 --- /dev/null +++ b/menus/notational-velocity.cson @@ -0,0 +1,22 @@ +# See https://atom.io/docs/latest/creating-a-package#menus for more details +'context-menu': + 'atom-text-editor': [ + { + 'label': 'Toggle notational-velocity' + 'command': 'notational-velocity:toggle' + } + ] +'menu': [ + { + 'label': 'Packages' + 'submenu': [ + 'label': 'notational-velocity' + 'submenu': [ + { + 'label': 'Toggle' + 'command': 'notational-velocity:toggle' + } + ] + ] + } +] diff --git a/package.json b/package.json new file mode 100644 index 0000000..9e873c1 --- /dev/null +++ b/package.json @@ -0,0 +1,16 @@ +{ + "name": "notational-velocity", + "main": "./lib/notational-velocity", + "version": "0.0.0", + "description": "A short description of your package", + "activationCommands": { + "atom-workspace": "notational-velocity:toggle" + }, + "repository": "https://github.com/atom/notational-velocity", + "license": "MIT", + "engines": { + "atom": ">0.50.0" + }, + "dependencies": { + } +} diff --git a/spec/notational-velocity-spec.coffee b/spec/notational-velocity-spec.coffee new file mode 100644 index 0000000..f7cf96f --- /dev/null +++ b/spec/notational-velocity-spec.coffee @@ -0,0 +1,30 @@ +{WorkspaceView} = require 'atom' +NotationalVelocity = require '../lib/notational-velocity' + +# 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 "NotationalVelocity", -> + activationPromise = null + + beforeEach -> + atom.workspaceView = new WorkspaceView + activationPromise = atom.packages.activatePackage('notational-velocity') + + describe "when the notational-velocity:toggle event is triggered", -> + it "attaches and then detaches the view", -> + expect(atom.workspaceView.find('.notational-velocity')).not.toExist() + + # This is an activation event, triggering it will cause the package to be + # activated. + atom.commands.dispatch atom.workspaceView.element, 'notational-velocity:toggle' + + waitsForPromise -> + activationPromise + + runs -> + expect(atom.workspaceView.find('.notational-velocity')).toExist() + atom.commands.dispatch atom.workspaceView.element, 'notational-velocity:toggle' + expect(atom.workspaceView.find('.notational-velocity')).not.toExist() diff --git a/spec/notational-velocity-view-spec.coffee b/spec/notational-velocity-view-spec.coffee new file mode 100644 index 0000000..2fae1fd --- /dev/null +++ b/spec/notational-velocity-view-spec.coffee @@ -0,0 +1,5 @@ +NotationalVelocityView = require '../lib/notational-velocity-view' + +describe "NotationalVelocityView", -> + it "has one valid test", -> + expect("life").toBe "easy" diff --git a/stylesheets/notational-velocity.less b/stylesheets/notational-velocity.less new file mode 100644 index 0000000..c7cfa1a --- /dev/null +++ b/stylesheets/notational-velocity.less @@ -0,0 +1,8 @@ +// The ui-variables file is provided by base themes provided by Atom. +// +// See https://github.com/atom/atom-dark-ui/blob/master/stylesheets/ui-variables.less +// for a full listing of what's available. +@import "ui-variables"; + +.notational-velocity { +}