-
Notifications
You must be signed in to change notification settings - Fork 1
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 836901b
Showing
23 changed files
with
494 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 @@ | ||
{} |
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 @@ | ||
{ | ||
"directory": "app/bower_components" | ||
} |
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,24 @@ | ||
# EditorConfig helps developers define and maintain consistent | ||
# coding styles between different editors and IDEs | ||
# editorconfig.org | ||
|
||
root = true | ||
|
||
|
||
[*] | ||
|
||
# Change these settings to your own preference | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[*.json] | ||
indent_size = 2 | ||
|
||
# We recommend you to keep these unchanged | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
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 @@ | ||
* text=auto |
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,10 @@ | ||
node_modules | ||
temp | ||
.tmp | ||
dist | ||
.sass-cache | ||
app/bower_components | ||
test/bower_components | ||
package | ||
app/scripts | ||
|
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,24 @@ | ||
{ | ||
"node": true, | ||
"browser": true, | ||
"mocha": true, | ||
"esnext": true, | ||
"module": true, | ||
"bitwise": true, | ||
"camelcase": true, | ||
"curly": true, | ||
"eqeqeq": true, | ||
"immed": true, | ||
"indent": 2, | ||
"latedef": true, | ||
"newcap": true, | ||
"noarg": true, | ||
"quotmark": "single", | ||
"undef": true, | ||
"unused": true, | ||
"strict": true, | ||
"globals" : { | ||
"chrome": true, | ||
"crypto": true | ||
} | ||
} |
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 @@ | ||
{ | ||
"generator-mocha": {} | ||
} |
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,40 @@ | ||
# ANSI Colors chrome extension | ||
|
||
Chrome extension that converts ANSI characters to colors on the fly / on button click for the lazy ones. Does what [ansi-html-stream][ansi-html-stream] does but within browser. | ||
|
||
*Work in progress* (pressing on button currently strip ansi characters for now) :P | ||
|
||
## todo | ||
|
||
[ ] figure out how to pass data to [ansi-html-stream][ansi-html-stream] (using a stream? maybe I should find a different solution) | ||
[x] Provide ansi stripping capability [strip-ansi][strip-ansi] | ||
[ ] create an icon | ||
[ ] publish | ||
|
||
## Notes | ||
|
||
* This is mostly an attempt to use [browserify][browserify] in a chrome extensionand at least, this part seems to work eh. | ||
* PR welcome as usual | ||
|
||
Right now, hitting extension button can convert from this: | ||
``` | ||
Summary | ||
-------------[0m | ||
[0;32mSucceeded: 24[0m ([0;32mchanged=3[0m) | ||
[0;36mFailed: 0[0m | ||
[0;36m------------- | ||
Total states run: 24[0m | ||
``` | ||
to this | ||
``` | ||
Summary | ||
------------- | ||
Succeeded: 24 (changed=3) | ||
Failed: 0 | ||
------------- | ||
Total states run: 24 | ||
``` | ||
|
||
[strip-ansi]: https://github.com/chalk/strip-ansi | ||
[ansi-html-stream]: https://github.com/hughsk/ansi-html-stream | ||
[browserify]: http://browserify.org/ |
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,10 @@ | ||
{ | ||
"appName": { | ||
"message": "ansi colors chrome extension", | ||
"description": "The name of the application" | ||
}, | ||
"appDescription": { | ||
"message": "Converts ANSI excape characters to colors on current page, useful when viewing log files within chrome", | ||
"description": "The description of the application" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,35 @@ | ||
{ | ||
"name": "ansi-colors-chrome-extension", | ||
"version": "0.0.1", | ||
"manifest_version": 2, | ||
"description": "Renders ansi escape characters on current page (ex: a log file with ansi colors viewed in chrome)", | ||
"icons": { | ||
"16": "images/icon-16.png", | ||
"128": "images/icon-128.png" | ||
}, | ||
"default_locale": "en", | ||
"background": { | ||
"scripts": [ | ||
"scripts/chromereload.js", | ||
"scripts/background.js" | ||
] | ||
}, | ||
"content_scripts": [ | ||
{ | ||
"matches": ["http://*/*", "https://*/*"], | ||
"js": ["scripts/colorize.js"], | ||
"run_at": "document_end" | ||
} | ||
], | ||
"permissions": [ | ||
"file://*", | ||
"activeTab" | ||
], | ||
"browser_action": { | ||
"default_icon": { | ||
"19": "images/icon-19.png", | ||
"38": "images/icon-38.png" | ||
}, | ||
"default_title": "ansi colors chrome extension" | ||
} | ||
} |
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,18 @@ | ||
'use strict'; | ||
|
||
chrome.runtime.onInstalled.addListener(details => { | ||
console.log('previousVersion', details.previousVersion); | ||
}); | ||
|
||
chrome.tabs.onUpdated.addListener(tabId => { | ||
chrome.pageAction.show(tabId); | ||
}); | ||
|
||
// executes colorize action on button click :) | ||
chrome.browserAction.onClicked.addListener(tab => { | ||
// No tabs or host permissions needed! | ||
console.log('Turning ' + tab.url + ' red!'); | ||
chrome.tabs.executeScript({ | ||
file: 'scripts/colorize.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict'; | ||
|
||
// Reload client for Chrome Apps & Extensions. | ||
// The reload client has a compatibility with livereload. | ||
// WARNING: only supports reload command. | ||
|
||
const LIVERELOAD_HOST = 'localhost:'; | ||
const LIVERELOAD_PORT = 35729; | ||
const connection = new WebSocket('ws://' + LIVERELOAD_HOST + LIVERELOAD_PORT + '/livereload'); | ||
|
||
connection.onerror = (error) => { | ||
console.log('reload connection got error:', error); | ||
}; | ||
|
||
connection.onmessage = (e) => { | ||
if (e.data) { | ||
const data = JSON.parse(e.data); | ||
if (data && data.command === 'reload') { | ||
chrome.runtime.reload(); | ||
} | ||
} | ||
}; |
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,40 @@ | ||
'use strict'; | ||
|
||
// @see https://github.com/hughsk/ansi-html-stream | ||
var ansi = require('ansi-html-stream'); | ||
var stripAnsi = require('strip-ansi'); | ||
|
||
var fs = require('fs'); | ||
|
||
var stream = ansi({chunked: false}); | ||
|
||
// todo: find a way to get document.body.textContent as stream | ||
//console.log(document.body.textContent); | ||
|
||
// todo: move this to a button or submenu, whatever. at least this works | ||
document.body.innerText = stripAnsi(document.body.textContent); | ||
|
||
// pip document to ansi stream | ||
//documentAsStream = getDocumentAsStream(); | ||
//documentAsStream.pipe(stream); | ||
|
||
// this should be the current page | ||
var file = fs.createWriteStream('output.html', 'utf8'); | ||
|
||
stream.pipe(file, {end: false}); | ||
stream.once('end', function () { | ||
file.end('</pre>\n'); | ||
}); | ||
file.write('<pre>\n'); | ||
|
||
|
||
//documentAsStream.on('data', function (data) { | ||
// // not quite sure if I'll need to do something here | ||
// // I think pipe is the magic part here | ||
// }) | ||
// .pipe(stream) | ||
// .on('close', function () { | ||
// console.log('stream is over'); | ||
// stream.end(null) | ||
// }); | ||
|
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 @@ | ||
body { | ||
padding: 20px; | ||
} |
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,10 @@ | ||
{ | ||
"name": "ansi-colors-chrome-extension", | ||
"private": true, | ||
"version": "0.0.0", | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"chai": "^3.5.0", | ||
"mocha": "^2.4.5" | ||
} | ||
} |
Oops, something went wrong.