From 456c496fcf650adb944d00399b1715de2c8016ca Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 19 Dec 2005 19:09:43 +0000 Subject: [PATCH] Adding support for user-customizable file types --- includes/file_types.php | 63 +++++++++++++++++++++++++++++++++++++++++ view.php | 6 +++- 2 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 includes/file_types.php diff --git a/includes/file_types.php b/includes/file_types.php new file mode 100644 index 0000000..58b8024 --- /dev/null +++ b/includes/file_types.php @@ -0,0 +1,63 @@ + array(GESHI LANGUAGE, EXTERNAL MIME TYPE, REQUIRES DOWNLOAD) +// +// EXTENSION = the extension of the file, sans period (.) +// GESHI LANGUAGE = language file that GeSHi syntax highlighter should use when displyaing this file; +// not specifying this will result in plain text +// EXTERNAL MIME TYPE = if the file isn't source code, but an image, zip, or other type of binary file, +// what MIME-type should be sent when viewing the file? +// note: if you specify this for non-binary files, it will do weird things +// REQUIRES DOWNLOAD = some binary files, like images, can be displayed inline; however ZIP files and other +// binary files that can't be displayed inline should have this set to TRUE so that +// a link will be displayed to allow the user to download the file + +define('MIMES_GESHI_LANGUAGE', 0); +define('MIMES_EXTERNAL_MIME', 1); +define('MIMES_REQUIRES_DOWNLOAD', 2); + +$filetypes = array( + 'php' => array('php', '', false), + 'htm' => array('html4strict', '', false), + 'html' => array('html4strict', '', false), + 'sql' => array('sql', '', false), + 'xml' => array('xml', '', false), + 'js' => array('javascript', '', false), + 'h' => array('c', '', false), + 'c' => array('c', '', false), + 'cpp' => array('c', '', false), + 'm' => array('objc', '', false), + 'css' => array('css', '', false), + 'java' => array('java', '', false) +); + +/*=====================================================================*\ +|| ################################################################### +|| # $HeadURL$ +|| # $Id$ +|| ################################################################### +\*=====================================================================*/ +?> \ No newline at end of file diff --git a/view.php b/view.php index 939c2ec..f70a8f6 100644 --- a/view.php +++ b/view.php @@ -53,10 +53,14 @@ $logmsg['message_clean'] = nl2br(htmlspecialchars($logmsg['message'])); $catdata = $data = implode("\n", $viewsvn->svn->cat($repos, $relpath, $viewsvn->paths->fetch_rev_num())); +// get language information +require_once('./includes/file_types.php'); +$language = $filetypes[ $funct->fetch_extension($relpath) ]; + // initialize GeSHi $mtstart = microtime(); require_once('./includes/geshi/geshi.php'); -$geshi = new Geshi($catdata, 'php'); +$geshi = new Geshi($catdata, $language[MIMES_GESHI_LANGUAGE]); // use CSS $geshi->enable_classes(); -- 2.22.5