From c6c2a99da1119a4b8f8ddcca0b625f8430bfde10 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 19 Dec 2005 18:50:45 +0000 Subject: [PATCH] Checking in the GeSHi stuff that's now working --- templates/default/code2.css | 69 +++++++++++++++++++++++++++++++++++++ templates/default/view.tpl | 2 +- view.php | 51 +++++++++++++++------------ 3 files changed, 99 insertions(+), 23 deletions(-) create mode 100644 templates/default/code2.css diff --git a/templates/default/code2.css b/templates/default/code2.css new file mode 100644 index 0000000..a483d69 --- /dev/null +++ b/templates/default/code2.css @@ -0,0 +1,69 @@ +/* GeSHi (c) Nigel McNie 2004 (http://qbnz.com/highlighter) */ + +/* Key Words I (if, do, while, etc.) */ +.code .kw1 +{ + color: #468; + font-weight: bold; +} + +/* Key Words II (null, true, false, etc.) */ +.code .kw2 +{ + color: #000; + font-weight: bold; +} + + +/* Built-in Functions */ +.code .kw3 +{ + color: #900; + font-weight: bold; +} + +/* Data Types (int, bool, etc) */ +.code .kw4 +{ + color: #000; + font-weight: bold; +} + +/* Comments */ +.code .co1, .code .co2, .code .coMULTI +{ + color: #998; + font-style: italic; +} + +/* Strings */ +.code .st0 +{ + color: #b84; +} + +/* Methods */ +.code .me0 +{ + color: #900; +} + +/* Standard text without highlighting (default) */ +.code .de1, .code .de2 +{ +} + +/* Escaped characters */ +.code .es0 +{ +} + +/* Symbols [ ( { } ) ] */ +.code .br0 +{ +} + +/* Numbers */ +.code .nu0 +{ +} \ No newline at end of file diff --git a/templates/default/view.tpl b/templates/default/view.tpl index 75aebcd..08b21c6 100644 --- a/templates/default/view.tpl +++ b/templates/default/view.tpl @@ -2,7 +2,7 @@ $doctype $headinclude - + {@"View"} diff --git a/view.php b/view.php index c1889a6..939c2ec 100644 --- a/view.php +++ b/view.php @@ -53,33 +53,40 @@ $logmsg['message_clean'] = nl2br(htmlspecialchars($logmsg['message'])); $catdata = $data = implode("\n", $viewsvn->svn->cat($repos, $relpath, $viewsvn->paths->fetch_rev_num())); -$f = fopen(($name = '/tmp/enscript-write-viewsvn-temp-' . time()), 'w'); -fwrite($f, $catdata); -fclose($f); - -$catdata = implode("\n", $viewsvn->shell->exec($viewsvn->paths->enscript . ' --color -h -q --language=html -p - --pretty-print=html ' . $name)); - -$colors = array( - 'comment' => 'B22222', - 'keyword' => '5F9EA0', - 'type' => '228B22', - 'string' => 'BC8F8F', - 'func' => '0000FF', - 'prep' => 'B8860B', - 'lang' => 'A020F0', - 'var' => 'DA706D' -); +// initialize GeSHi +$mtstart = microtime(); +require_once('./includes/geshi/geshi.php'); +$geshi = new Geshi($catdata, 'php'); + +// use CSS +$geshi->enable_classes(); -foreach ($colors AS $class => $color) +// header +$geshi->set_header_type(GESHI_HEADER_NONE); + +// disable links +$urls = array_keys($geshi->language_data['URLS']); +foreach ($urls AS $key) { - $catdata = preg_replace('##i', '', $catdata); + $geshi->set_url_for_keyword_group($key, ''); } -$catdata = preg_replace('##i', '', $catdata); -$catdata = preg_replace('#<(/?)b>#i', '<\1strong>', $catdata); -$catdata = substr($catdata, strpos($catdata, ''), strpos($catdata, '') - strpos($catdata, '')); +// css info +$geshi->set_overall_class('code'); + +// don't do anything stupid +$geshi->set_case_keywords(GESHI_CAPS_NO_CHANGE); + +// encoding +$geshi->set_encoding('UTF-8'); + +// tab width +$geshi->set_tab_width(5); + +// parse the code +$catdata = $geshi->parse_code(); -unlink($name); +$viewsvn->debug("time in GeSHi = " . $funct->fetch_microtime_diff($mtstart)); // ################################################################### -- 2.43.5