diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d948b7..3f6531d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +# nvatom + +## 0.1.0 +- Rename `notational-velocity` to `nvatom` +- Copy `notational-velocity` settings/notes on initialization + +---- +# notational-velocity + ## 0.3.0 - Fix the bug that the default note directory is within packages directory. If it happens, it **deletes** all of existing notes. If you read this before updating the package, please check your note directory before updating it. diff --git a/README.md b/README.md index 1cc00e4..1d7bff3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Notational Velocity for Atom +*`notational-velocity` package is renamed to `nvatom` package due to a fatal bug. For more info, refer [migration section](#migration).* + [![Build Status][3]][4] [Notational Velocity][1] is an application that stores and retrieves notes. @@ -26,13 +28,13 @@ We do believe Notational Velocity is the precursor of the famous note-taking app ## Settings -To configure your note directory, set `notational-velocity.directory`: +To configure your note directory, set `nvatom.directory`: * Open your `~/.atom/config.cson` file from the menu: *Atom > Open Your Config* * Append the following lines: ```cson - 'notational-velocity': + 'nvatom': directory: '/path/to/your/notes' ``` @@ -52,9 +54,17 @@ You can also override `cmd-l` if you want to keep your muscle memory from Notati 'atom-text-editor': 'cmd-l': 'unset!' 'atom-workspace': - 'cmd-l': 'notational-velocity:toggle' + 'cmd-l': 'nvatom:toggle' ``` +## Migration + +v0.1.0 under published package name `notational-velocity` had a fatal bug that sets the default value of its note directory under package directory. Since package directory is overwritten when the user updates `notational-velocity` package. For more information, refer [#25][6]. + +To resolve this problem, we renamed our package name to `nvatom`. Users who have the old `notational-velocity` need to **install `nvatom` package first**, activate the package to automatically migrate the existing notes, and then delete `notational-velocity` package. + +Since keymaps overlap with `notational-velocity`, follow the menu *Packages > nvAtom > Toggle* to activate this package. + ## References - [Notational Velocity](http://notational.net/) @@ -69,3 +79,4 @@ You can also override `cmd-l` if you want to keep your muscle memory from Notati [3]: https://travis-ci.org/seongjaelee/notational-velocity.svg?branch=master [4]: https://travis-ci.org/seongjaelee/notational-velocity [5]: https://cloud.githubusercontent.com/assets/948301/7246990/2e2b4c6e-e7b9-11e4-93b0-57954e011e81.gif +[6]: https://github.com/seongjaelee/notational-velocity/issues/25 diff --git a/keymaps/notational-velocity.cson b/keymaps/notational-velocity.cson index ccb401c..19c1d36 100644 --- a/keymaps/notational-velocity.cson +++ b/keymaps/notational-velocity.cson @@ -8,4 +8,4 @@ # For more detailed documentation see # https://atom.io/docs/latest/advanced/keymaps 'atom-workspace': - 'alt-cmd-l': 'notational-velocity:toggle' + 'alt-cmd-l': 'nvatom:toggle' diff --git a/lib/notational-velocity-view.coffee b/lib/notational-velocity-view.coffee index b3a9c98..789599c 100644 --- a/lib/notational-velocity-view.coffee +++ b/lib/notational-velocity-view.coffee @@ -9,8 +9,8 @@ class NotationalVelocityView extends SelectListView initialize: (state) -> @initializedAt = new Date() super - @addClass('notational-velocity from-top overlay') - @rootDirectory = atom.config.get('notational-velocity.directory') + @addClass('nvatom from-top overlay') + @rootDirectory = atom.config.get('nvatom.directory') if !fs.existsSync(@rootDirectory) throw new Error("The given directory #{@rootDirectory} does not exist. " + "Set the note directory to the existing one from Settings.") diff --git a/lib/notational-velocity.coffee b/lib/notational-velocity.coffee index 132ecd5..7be81c7 100644 --- a/lib/notational-velocity.coffee +++ b/lib/notational-velocity.coffee @@ -8,7 +8,7 @@ module.exports = title: 'Note Directory' description: 'The directory to archive notes' type: 'string' - default: path.join(process.env.ATOM_HOME, 'notational-velocity-notes') + default: path.join(process.env.ATOM_HOME, 'nvatom-notes') notationalVelocityView: null @@ -21,7 +21,7 @@ module.exports = # Register command that toggles this view @subscriptions.add atom.commands.add 'atom-workspace', - 'notational-velocity:toggle': => @createView(state).toggle() + 'nvatom:toggle': => @createView(state).toggle() handleBeforeUnload = @autosaveAll.bind(this) window.addEventListener('beforeunload', handleBeforeUnload, true) @@ -62,23 +62,47 @@ module.exports = @autosave(paneItem) for paneItem in atom.workspace.getPaneItems() ensureNoteDirectory: -> - noteDirectory = atom.config.get('notational-velocity.directory') + noteDirectory = atom.config.get('nvatom.directory') packagesDirectory = path.join(process.env.ATOM_HOME, 'packages') - defaultNoteDirectory = path.join(packagesDirectory, 'notational-velocity', 'notebook') + defaultNoteDirectory = path.join(packagesDirectory, 'nvatom', 'notebook') if noteDirectory.startsWith(packagesDirectory) - storageDirectory = path.join(packagesDirectory, 'storage') - throw new Error(""" - The note directory (#{noteDirectory}) should NOT nest under #{packagesDirectory}. - It is likely that you updated the package to a newer version from v0.1.0. - It is likely that the note directory is overwritten. - Unfortunately, I couldn't find a way to recover overwritten notes. - You might recover partial notes from #{storageDirectory}. - I am extremely sorry. - - Seongjae Lee""") + throw new Error('Note directory #{noteDirectory} cannot reside within atom packages directory. Please change its value from package settings.') + # Initialize note directory. if !fs.existsSync(noteDirectory) - fs.makeTreeSync(noteDirectory) - fs.copySync(defaultNoteDirectory, noteDirectory) + @tryMigrateFromNotationalVelocity() + noteDirectory = atom.config.get('nvatom.directory') + if !fs.existsSync(noteDirectory) + fs.makeTreeSync(noteDirectory) + fs.copySync(defaultNoteDirectory, noteDirectory) return fs.realpathSync(noteDirectory) + + tryMigrateFromNotationalVelocity: -> + prevNoteDirectory = atom.config.get('notational-velocity.directory') + currNoteDirectory = atom.config.get('nvatom.directory') + packagesDirectory = path.join(process.env.ATOM_HOME, 'packages') + defaultNoteDirectory = path.join(packagesDirectory, 'nvatom', 'notebook') + + # notational-velocity does not exist. + if prevNoteDirectory == undefined + return + + atom.notifications.addInfo('Migrating from notational-velocity package...') + + if !fs.existsSync(prevNoteDirectory) + atom.notifications.addError('notational-velocity.directory #{prevNoteDirectory} does not exists. Migration process is failed.') + return + + alert(prevNoteDirectory) + alert(currNoteDirectory) + + if prevNoteDirectory.startsWith(packagesDirectory) + fs.makeTreeSync(currNoteDirectory) + fs.copySync(prevNoteDirectory, currNoteDirectory) + else + if path.join(process.env.ATOM_HOME, 'nvatom-notes') == currNoteDirectory + atom.config.set('nvatom.directory', prevNoteDirectory) + + atom.notifications.addInfo('Finished migration.') diff --git a/menus/notational-velocity.cson b/menus/notational-velocity.cson index 1a33578..01e2e90 100644 --- a/menus/notational-velocity.cson +++ b/menus/notational-velocity.cson @@ -3,11 +3,11 @@ { 'label': 'Packages' 'submenu': [ - 'label': 'Notational Velocity' + 'label': 'nvAtom' 'submenu': [ { 'label': 'Toggle' - 'command': 'notational-velocity:toggle' + 'command': 'nvatom:toggle' } ] ] diff --git a/package.json b/package.json index 6d26a1a..fce539c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "notational-velocity", + "name": "nvatom", "main": "./lib/notational-velocity", - "version": "0.3.0", + "version": "0.0.0", "private": true, "contributors": [ "Seongjae Lee ", @@ -10,7 +10,7 @@ ], "description": "Notational Velocity for Atom", "activationCommands": { - "atom-workspace": "notational-velocity:toggle" + "atom-workspace": "nvatom:toggle" }, "repository": "https://github.com/seongjaelee/notational-velocity", "license": "MIT", diff --git a/spec/notational-velocity-spec.coffee b/spec/notational-velocity-spec.coffee index cfd9e22..ec9a75f 100644 --- a/spec/notational-velocity-spec.coffee +++ b/spec/notational-velocity-spec.coffee @@ -1,31 +1,31 @@ path = require 'path' -describe "NotationalVelocity", -> - defaultDirectory = atom.config.get('notational-velocity.directory') +describe "nvAtom", -> + defaultDirectory = atom.config.get('nvatom.directory') activationPromise = null workspaceElement = null beforeEach -> workspaceElement = atom.views.getView(atom.workspace) - activationPromise = atom.packages.activatePackage('notational-velocity') - atom.config.set('notational-velocity.directory', 'testdata') + activationPromise = atom.packages.activatePackage('nvatom') + atom.config.set('nvatom.directory', 'testdata') afterEach -> - atom.config.set('notational-velocity.directory', defaultDirectory) + atom.config.set('nvatom.directory', defaultDirectory) - describe "when the notational-velocity:toggle event is triggered", -> + describe "when the nvatom:toggle event is triggered", -> it "attaches and then detaches the view", -> - expect(workspaceElement.querySelector('.notational-velocity')).not.toExist() + expect(workspaceElement.querySelector('.nvatom')).not.toExist() # This is an activation event, triggering it will cause the package to be activated. - atom.commands.dispatch workspaceElement, 'notational-velocity:toggle' + atom.commands.dispatch workspaceElement, 'nvatom:toggle' waitsForPromise -> activationPromise runs -> - expect(workspaceElement.querySelector('.notational-velocity')).toExist() - atom.commands.dispatch workspaceElement, 'notational-velocity:toggle' + expect(workspaceElement.querySelector('.nvatom')).toExist() + atom.commands.dispatch workspaceElement, 'nvatom:toggle' it "checks if we banned the default directory under packages directory", -> atom.notifications.clear() @@ -34,11 +34,11 @@ describe "NotationalVelocity", -> atom.packages.activatePackage('notifications') runs -> - defaultNoteDirectory = path.join(process.env.ATOM_HOME, 'packages', 'notational-velocity', 'notebook') - atom.config.set('notational-velocity.directory', defaultNoteDirectory) + noteDirectoryUnderPackageDirectory = path.join(process.env.ATOM_HOME, 'packages', 'nvatom', 'notebook') + atom.config.set('nvatom.directory', noteDirectoryUnderPackageDirectory) # This is an activation event, triggering it will cause the package to be activated. - atom.commands.dispatch workspaceElement, 'notational-velocity:toggle' + atom.commands.dispatch workspaceElement, 'nvatom:toggle' waitsForPromise -> activationPromise diff --git a/styles/notational-velocity.less b/styles/notational-velocity.less index 116cfaa..d4eb29d 100644 --- a/styles/notational-velocity.less +++ b/styles/notational-velocity.less @@ -4,7 +4,7 @@ // for a full listing of what's available. @import "ui-variables"; -.notational-velocity { +.nvatom { li { text-overflow: ellipsis; overflow-x: hidden;