Commit b01d93d4 authored by ManiacTwister's avatar ManiacTwister
Browse files

first commit

parents
/vendor
composer.phar
composer.lock
.DS_Store
lib-cov
*.seed
*.log
*.csv
*.dat
*.out
*.pid
*.gz
pids
logs
results
build
node_modules
/vendor
composer.phar
composer.lock
.DS_Store
<?php
/*
* Paste Highlighter
* Copyright (C) 2014 ManiacTwister
*
* Ace editor Copyright (c) 2010, Ajax.org B.V.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
require 'vendor/autoload.php';
$loop = new React\EventLoop\StreamSelectLoop();
$dnode = new DNode\DNode($loop);
$dnode->connect("/tmp/pastehighlight", function($remote, $connection) {
// Remote is a proxy object that provides us all methods
// from the server
$remote->highlight("<?php echo 'test'; ?>", "php", function($css, $html, $err=false) use ($connection) {
if($err !== false) {
echo $err."\n";
$connection->end();
return;
}
echo "<html><body>\n" .
"<style type='text/css' media='screen'>\n" .
$css.
"</style>\n" .
utf8_decode($html) .
'</body></html>';
// Once we have the result we can close the connection
$connection->end();
});
});
$loop->run();
\ No newline at end of file
{
"name": "maniactwister/pastehighlight",
"description": "Paste highlighter client",
"license": "GPL",
"authors": [
{
"name": "ManiacTwister"
}
],
"repositories": [
{
"type":"vcs",
"url":"https://github.com/ManiacTwister/dnode-php.git"
}
],
"require": {
"php": ">=5.3.0",
"dnode/dnode": "dev-master#ae00a3bb5a6df67bc6de7f8507359135d06a41ef"
},
"autoload": {
"psr-0": {
"Monolog": "src"
}
}
}
{
"name": "pastehighlighter",
"description": "Highlighting for paste.maniactwister.de",
"author": "ManiacTwister",
"version": "0.1",
"dependencies": {
"ace": "git://github.com/ajaxorg/ace.git",
"amd-loader": ">= 0.0.5",
"dnode": ">= 1.2.x",
"jsdom": ">=0.8.x"
},
"engine": "node 0.4.1"
}
\ No newline at end of file
/*
* Paste Highlighter
* Copyright (C) 2014 ManiacTwister
*
* Ace editor Copyright (c) 2010, Ajax.org B.V.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
require("amd-loader");
require("ace/lib/ace/test/mockdom");
var highlighter = require("ace/lib/ace/ext/static_highlight");
var theme = require("ace/lib/ace/theme/monokai");
var dnode = require('dnode');
var server = dnode({
highlight: function (code, language, cb) {
if(!language.match(/^[a-z0-9]+$/i)) {
cb(false, false, "Hacking attempt.");
return;
}
var JavaScriptMode = require("ace/lib/ace/mode/"+language).Mode;
var highlighted = highlighter.render(code.toString("utf8"), new JavaScriptMode(), theme);
cb(highlighted.css, highlighted.html);
}
});
server.listen('/tmp/pastehighlight');
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment