-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3cce93c
Showing
16 changed files
with
799 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/npm-debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
This README file is located in a .codestory documentation package. | ||
You should not attempt to modify anything here. | ||
Get free Code Story Reader at http://codestoryapp.com. |
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file added
BIN
+15.6 KB
Atom Code Story plug-in.codestory/data/560f2300-355e-11e7-a2ed-2b49e3a007d9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+38 KB
Atom Code Story plug-in.codestory/data/fb020250-0715-11e7-94be-f9b7f5eb273a.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
## 0.1.0 - First Release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Copyright (c) 2016 <Your name here> | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
This Atom plug-in provides [Code Story](http://codestoryapp.com) integration: | ||
|
||
- Token highlighting, | ||
- Command-click on tokens to view in Code Story. | ||
|
||
|
||
 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"atom-workspace": { | ||
"ctrl-alt-o": "atom-codestory:toggle" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
'use babel'; | ||
|
||
import path from 'path' | ||
import { CompositeDisposable } from 'atom' | ||
import { spawn } from 'child_process' | ||
import packageConfig from './config-schema.json' | ||
import fs from 'fs' | ||
|
||
// this is what a token should look like | ||
const re = /#[a-zA-Z0-9]{5}#/g | ||
|
||
const findDocumentationUpInHierarchy = (file) => { | ||
let folder = file | ||
let documentationPath = null | ||
while (documentationPath === null && folder !== '/') { | ||
folder = path.dirname(folder) | ||
const files = fs.readdirSync(folder) | ||
files.some(file => { | ||
if (file.match(/.+\.codestory$/)) { | ||
documentationPath = path.join(folder, file) | ||
return true | ||
} | ||
}) | ||
} | ||
return documentationPath | ||
} | ||
|
||
export default { | ||
config: packageConfig, | ||
subscriptions: new CompositeDisposable(), | ||
markers: [], | ||
activate() { | ||
this.subscriptions.add(atom.workspace.observeTextEditors(editor => { | ||
this.subscriptions.add(editor.onDidChange(event => { | ||
this.highlightTokens(editor) // #9Debv# | ||
})) | ||
})) | ||
this.subscriptions.add( | ||
atom.workspace.onDidChangeActivePaneItem(() => this.highlightTokens(atom.workspace.getActiveTextEditor())) // #Hqjn6# | ||
) | ||
}, | ||
deactivate() { | ||
this.subscriptions.dispose(); | ||
}, | ||
highlightTokens(editor) { // #khGD4# | ||
if (!editor) return | ||
this.markers.forEach(m => m.destroy()) | ||
this.markers = [] | ||
editor.scan(re, (obj) => { | ||
const marker = editor.markBufferRange(obj.range) | ||
// https://atom.io/docs/api/v1.10.2/TextEditor#instance-decorateMarker | ||
const decoration = editor.decorateMarker(marker, { type: 'highlight', class: 'codestory-token' }) | ||
this.markers.push(decoration) | ||
}) | ||
}, | ||
// https://github.com/facebooknuclide/hyperclick#provider-api | ||
getProvider() { // #P4S7v# | ||
return { | ||
providerName: 'hyperclick-codestory', | ||
wordRegExp: re, | ||
getSuggestionForWord(textEditor, text, range) { | ||
if (!re.exec(text)) return null // #x8U8m# | ||
return { | ||
// The range(s) to underline as a visual cue for clicking. | ||
range, | ||
textEditor, | ||
// The function to call when the underlined text is clicked. | ||
callback: () => { | ||
const cmd = atom.config.get('codestory.codeStoryAppPath') // #MsTbt# | ||
const currentFilePath = path.join(textEditor.getDirectoryPath(), textEditor.getFileName()) | ||
const documentationPath = findDocumentationUpInHierarchy(currentFilePath) | ||
|
||
if (documentationPath) { | ||
const args = ['-p', documentationPath, '-s', text.slice(1, 6)] | ||
|
||
console.log('args', cmd, args) | ||
|
||
const p = spawn(cmd, args, { detached: true }) | ||
p.stderr.on('data', (data) => { | ||
atom.notifications.addError('Code Story', { detail: data }); | ||
}) | ||
// p.stdout.on('data', (data) => { | ||
// console.log('stdout: ' + data) // eslint-disable-line | ||
// }) | ||
// p.on('close', (code) => { | ||
// console.log('child process exited with code ' + code) // eslint-disable-line | ||
// }) | ||
p.unref() | ||
} else { | ||
atom.notifications.addError('Code Story launch error', { detail: 'No Code Story documentation could be found.' }); | ||
} | ||
}, | ||
} | ||
}, | ||
} | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"codeStoryAppPath": { | ||
"description": "Path to Code Story binary", | ||
"type": "string", | ||
"default": "/Applications/Code Story.app/Contents/MacOS/Code Story" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"context-menu": { | ||
"atom-text-editor": [ | ||
{ | ||
"label": "Toggle atom-codestory", | ||
"command": "atom-codestory:toggle" | ||
} | ||
] | ||
}, | ||
"menu": [ | ||
{ | ||
"label": "Packages", | ||
"submenu": [ | ||
{ | ||
"label": "Code Story", | ||
"submenu": [ | ||
{ | ||
"label": "Toggle", | ||
"command": "atom-codestory:toggle" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "codestory", | ||
"main": "./lib/atom-codestory", | ||
"version": "0.2.0", | ||
"description": "This Atom plug-in provides Code Story integration", | ||
"keywords": [], | ||
"repository": "https://github.com/dperetti/atom-codestory", | ||
"license": "MIT", | ||
"engines": { | ||
"atom": ">=1.0.0 <2.0.0" | ||
}, | ||
"dependencies": {}, | ||
"providedServices": { | ||
"hyperclick.provider": { | ||
"versions": { | ||
"0.0.0": "getProvider" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
'use babel'; | ||
|
||
import AtomCodestory from '../lib/atom-codestory'; | ||
|
||
// 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('AtomCodestory', () => { | ||
let workspaceElement, activationPromise; | ||
|
||
beforeEach(() => { | ||
workspaceElement = atom.views.getView(atom.workspace); | ||
activationPromise = atom.packages.activatePackage('atom-codestory'); | ||
}); | ||
|
||
describe('when the atom-codestory:toggle event is triggered', () => { | ||
it('hides and shows the modal panel', () => { | ||
// Before the activation event the view is not on the DOM, and no panel | ||
// has been created | ||
expect(workspaceElement.querySelector('.atom-codestory')).not.toExist(); | ||
|
||
// This is an activation event, triggering it will cause the package to be | ||
// activated. | ||
atom.commands.dispatch(workspaceElement, 'atom-codestory:toggle'); | ||
|
||
waitsForPromise(() => { | ||
return activationPromise; | ||
}); | ||
|
||
runs(() => { | ||
expect(workspaceElement.querySelector('.atom-codestory')).toExist(); | ||
|
||
let atomCodestoryElement = workspaceElement.querySelector('.atom-codestory'); | ||
expect(atomCodestoryElement).toExist(); | ||
|
||
let atomCodestoryPanel = atom.workspace.panelForItem(atomCodestoryElement); | ||
expect(atomCodestoryPanel.isVisible()).toBe(true); | ||
atom.commands.dispatch(workspaceElement, 'atom-codestory:toggle'); | ||
expect(atomCodestoryPanel.isVisible()).toBe(false); | ||
}); | ||
}); | ||
|
||
it('hides and shows the view', () => { | ||
// This test shows you an integration test testing at the view level. | ||
|
||
// Attaching the workspaceElement to the DOM is required to allow the | ||
// `toBeVisible()` matchers to work. Anything testing visibility or focus | ||
// requires that the workspaceElement is on the DOM. Tests that attach the | ||
// workspaceElement to the DOM are generally slower than those off DOM. | ||
jasmine.attachToDOM(workspaceElement); | ||
|
||
expect(workspaceElement.querySelector('.atom-codestory')).not.toExist(); | ||
|
||
// This is an activation event, triggering it causes the package to be | ||
// activated. | ||
atom.commands.dispatch(workspaceElement, 'atom-codestory:toggle'); | ||
|
||
waitsForPromise(() => { | ||
return activationPromise; | ||
}); | ||
|
||
runs(() => { | ||
// Now we can test for view visibility | ||
let atomCodestoryElement = workspaceElement.querySelector('.atom-codestory'); | ||
expect(atomCodestoryElement).toBeVisible(); | ||
atom.commands.dispatch(workspaceElement, 'atom-codestory:toggle'); | ||
expect(atomCodestoryElement).not.toBeVisible(); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
'use babel'; | ||
|
||
import AtomCodestoryView from '../lib/atom-codestory-view'; | ||
|
||
describe('AtomCodestoryView', () => { | ||
it('has one valid test', () => { | ||
expect('life').toBe('easy'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@import "ui-variables"; | ||
|
||
atom-text-editor.editor { | ||
.codestory-token { | ||
color: red !important; | ||
} | ||
.codestory-token .region { // #kFSgH# | ||
border-radius: 5px; | ||
background-color: #ccc; | ||
} | ||
} |