forked from OctoLinker/OctoLinker
-
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
1 parent
b0b0dbf
commit 4363b55
Showing
26 changed files
with
111 additions
and
106 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
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 @@ | ||
import 'babel-polyfill'; | ||
import OctoLinker from './octo-linker.js'; | ||
|
||
const octoLinker = new OctoLinker(); | ||
octoLinker.init(); |
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
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 @@ | ||
export default function (enable = false) { | ||
if (!enable) { | ||
return; | ||
} | ||
|
||
document.body.classList.add('octo-linker-debug'); | ||
} |
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,45 @@ | ||
import injection from 'github-injection'; | ||
import BlobReader from '../packages/blob-reader'; | ||
import clickHandler from './click-handler'; | ||
import getPluginsForBlobType from './plugin-manager.js'; | ||
import debugMode from './debug-mode.js'; | ||
|
||
function initialize(self) { | ||
debugMode(true); | ||
clickHandler(); | ||
|
||
self._blobReader = new BlobReader(); | ||
} | ||
|
||
function run(self) { | ||
if (!self._blobReader.hasBlobs()) { | ||
return false; | ||
} | ||
|
||
console.time('total'); | ||
|
||
self._blobReader.read(); | ||
|
||
self._blobReader.forEach((blob) => { | ||
const pluginsForType = getPluginsForBlobType(blob.type); | ||
if (!pluginsForType) { | ||
return; | ||
} | ||
|
||
pluginsForType.forEach((plugin) => { | ||
plugin.parseBlob(blob); | ||
}); | ||
}); | ||
|
||
console.timeEnd('total'); | ||
} | ||
|
||
export default class OctoLinkerCore { | ||
constructor() { | ||
initialize(this); | ||
} | ||
|
||
init() { | ||
injection(window, run.bind(null, this)); | ||
} | ||
} |
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,34 @@ | ||
import LinkResolver from './plugins/link-resolver'; | ||
import ManifestNPM from './plugins/manifest-npm'; | ||
import ManifestGemfile from './plugins/manifest-gemfile'; | ||
|
||
const plugins = [ | ||
LinkResolver, | ||
ManifestNPM, | ||
ManifestGemfile, | ||
]; | ||
|
||
function generateCache() { | ||
const list = new Map(); | ||
|
||
plugins.forEach((PluginClass) => { | ||
const pluginInstance = new PluginClass(); | ||
|
||
pluginInstance.blobTypes().forEach((type) => { | ||
const caller = list.get(type) || []; | ||
caller.push(pluginInstance); | ||
|
||
if (!list.has(type)) { | ||
list.set(type, caller); | ||
} | ||
}); | ||
}); | ||
|
||
return list; | ||
} | ||
|
||
const cache = generateCache(); | ||
|
||
export default function (pluginName) { | ||
return cache.get(pluginName); | ||
} |
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
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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
2 changes: 1 addition & 1 deletion
2
packages/helper-click-handler/test.js → test/click-handler.test.js
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
packages/helper-replace-keywords/test.js → test/wrap-keyword.js
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