summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2013-08-14 16:56:14 +0200
committerFlorian Pritz <bluewind@xinu.at>2013-08-14 16:56:14 +0200
commit92c84158677f30edb8872754d92832a35420952d (patch)
treec7c14118f2f5e50de4fb36f84141b171192cd332 /application
parent0c954fc204a182b70e5a7bc22a65c61869b488a6 (diff)
Use python-ansi2html instead of cpan module
Way, way, way, way faster. Did I mention it is faster? Also we now have line numbers because we can. Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application')
-rw-r--r--application/controllers/file.php22
1 files changed, 8 insertions, 14 deletions
diff --git a/application/controllers/file.php b/application/controllers/file.php
index 573d1a5b3..2d6a8ecc4 100644
--- a/application/controllers/file.php
+++ b/application/controllers/file.php
@@ -167,22 +167,12 @@ class File extends CI_Controller {
$cached["output"] = ob_get_contents();
ob_end_clean();
- } elseif ($lexer == "ascii") {
- ob_start();
-
- echo '<table class="content"><tr>';
- echo '<td class="code"><pre class="text">'."\n";
- passthru('perl '.FCPATH.'scripts/ansi2html '.escapeshellarg($file), $cached["return_value"]);
- echo "</pre>\n";
-
- $cached["output"] = ob_get_contents();
- ob_end_clean();
} else {
- $cached = $this->_pygmentize($file, $lexer);
+ $cached = $this->_colorify($file, $lexer);
}
if ($cached["return_value"] != 0) {
- $ret = $this->_pygmentize($file, "text");
+ $ret = $this->_colorify($file, "text");
$cached["output"] = $ret["output"];
}
$this->memcachelibrary->set($filedata['hash'].'_'.$lexer, $cached, 100);
@@ -202,7 +192,7 @@ class File extends CI_Controller {
echo $this->load->view($this->var->view_dir.'/html_footer', $this->data, true);
}
- private function _pygmentize($file, $lexer)
+ private function _colorify($file, $lexer)
{
$return_value = 0;
$output = "";
@@ -211,7 +201,11 @@ class File extends CI_Controller {
$output .= '<div class="highlight"><pre>'."\n";
ob_start();
- passthru('pygmentize -F codetagify -O encoding=guess,outencoding=utf8,stripnl=False -l '.escapeshellarg($lexer).' -f html '.escapeshellarg($file), $return_value);
+ if ($lexer == "ascii") {
+ passthru('ansi2html -p < '.escapeshellarg($file), $return_value);
+ } else {
+ passthru('pygmentize -F codetagify -O encoding=guess,outencoding=utf8,stripnl=False -l '.escapeshellarg($lexer).' -f html '.escapeshellarg($file), $return_value);
+ }
$buf = ob_get_contents();
ob_end_clean();