From 8be1273f8c5015e9276331c09f961c2ff72803b0 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 19 Dec 2005 07:09:13 +0000 Subject: [PATCH] Basic enscript processing is now working --- templates/default/code.css | 108 +++++++++++++++++++++++++++++++++++++ templates/default/view.tpl | 1 + view.php | 30 ++++++++++- 3 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 templates/default/code.css diff --git a/templates/default/code.css b/templates/default/code.css new file mode 100644 index 0000000..891e240 --- /dev/null +++ b/templates/default/code.css @@ -0,0 +1,108 @@ +.code-block { + border: 1px dotted #d7d7d7; + margin: 1em 0; + padding: .3em; + overflow: auto +} +.image-file { background: #eee; padding: .3em } +.image-file img { background: url(../imggrid.png) } + +/* Default */ +.css_default, .c_default, .code_default, .pl_default, .p_default, +.hphp_default, .yaml_default, .code-block span { + font-family: monospace; +} + +/* Comments */ +.code-comment, .css_comment, .c_comment, .c_commentdoc, .c_commentline, +.c_commentlinedoc, .h_comment,.pl_commentline, .p_commentblock, +.p_commentline, .hphp_commentblock, .hphp_commentline, +.yaml_comment { + color: #998; + font-style: italic; +} + +/* Language keyword */ +.code-keyword, .pl_word { color: #789; font-weight: bold } + +/* Type */ +.code-type, .c_word, .c_word2, .p_classname, .hphp_classname{ + color: #468; + font-weight: bold; +} + +/* Function */ +.code-func, .p_defname { + color: #900; + font-weight: bold; + border-bottom: none; +} + +/* Pre-processor */ +.code-prep, .c_preprocessor, .pl_preprocessor, .yaml_identifier { + color: #999; + font-weight: bold; +} + +/* Language construct */ +.code-lang, .p_word { color: #000; font-weight: bold } + +/* String */ +.code-string, .c_string, .c_stringeol, .css_doublestring, .css_singlestring, +.h_singlestring, .h_doublestring, .pl_string, .pl_string_q, .pl_string_qq, +.pl_string_qr, .pl_string_qw, .pl_string_qx, .pl_backticks, .pl_character, +.p_string, .p_stringeol, .hphp_string, .hphp_stringeol, .hphp_triple, +.hphp_tripledouble, .p_character, .p_triple, .p_tripledouble { + color: #b84; + font-weight: normal; +} + +/* Variable name */ +.code-var { color: #f9f } + +/* SilverCity-specific styles */ +.css_id, .css_class, .css_pseudoclass, .css_tag { color: #900000 } +.css_directive { color: #009000; font-weight: bold } +.css_important { color: blue } +.css_operator { color: #000090; font-weight: bold } +.css_tag { font-weight: bold } +.css_unknown_identifier, .css_unknown_pseudoclass { color: red } +.css_value { color: navy } +.c_commentdockeyword { color: navy; font-weight: bold } +.c_commentdockeyworderror { color: red; font-weight: bold } +.c_character, .c_regex, .c_uuid, .c_verbatim { color: olive } +.c_number { color: #099 } +.h_asp { color: #ff0 } +.h_aspat { color: #ffdf00 } +.h_attribute { color: teal } +.h_attributeunknown { color: red } +.h_cdata { color: #ffdf00 } +.h_entity { color: purple } +.h_number { color: #099 } +.h_other { color: purple } +.h_script, .h_tag, .h_tagend { color: navy } +.h_tagunknown { color: red } +.h_xmlend, .h_xmlstart { color: blue } +.pl_datasection { color: olive } +.pl_error { color: red; font-weight: bold } +.pl_hash { color: #000 } +.pl_here_delim, .pl_here_q, .pl_here_qq, .pl_here_qx, .pl_longquote { color: olive } +.pl_number { color: #099 } +.pl_pod { font-style: italic } +.pl_regex, .pl_regsubst { color: olive } +.p_number { color: #099 } +.hphp_character { color: olive } +.hphp_defname { color: #099; font-weight: bold } +.hphp_number { color: #099 } +.hphp_word { color: navy; font-weight: bold } +.yaml_document { color: gray; font-style: italic } +.yaml_keyword { color: #808 } +.yaml_number { color: #800 } +.yaml_reference { color: #088 } +.v_comment { color: gray; font-style: italic } +.v_commentline, .v_commentlinebang { color: red; font-style: italic } +.v_number, .v_preprocessor { color: #099 } +.v_string, .v_stringeol { color: olive } +.v_user{ color: blue; font-weight: bold } +.v_word, .v_word3 { color: navy; font-weight: bold } +.v_word2 { color: green; font-weight: bold } diff --git a/templates/default/view.tpl b/templates/default/view.tpl index 37bc24f..75aebcd 100644 --- a/templates/default/view.tpl +++ b/templates/default/view.tpl @@ -2,6 +2,7 @@ $doctype $headinclude + {@"View"} diff --git a/view.php b/view.php index 0d05e4f..c1889a6 100644 --- a/view.php +++ b/view.php @@ -51,7 +51,35 @@ unset($logmsg['files']); $logmsg['message_clean'] = nl2br(htmlspecialchars($logmsg['message'])); -$catdata = $viewsvn->svn->format(implode("\n", $viewsvn->svn->cat($repos, $relpath, $viewsvn->paths->fetch_rev_num()))); +$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' +); + +foreach ($colors AS $class => $color) +{ + $catdata = preg_replace('##i', '', $catdata); +} +$catdata = preg_replace('##i', '', $catdata); +$catdata = preg_replace('#<(/?)b>#i', '<\1strong>', $catdata); + +$catdata = substr($catdata, strpos($catdata, ''), strpos($catdata, '') - strpos($catdata, '')); + +unlink($name); // ################################################################### -- 2.43.5