This patch adds pkgbuild syntax highlighting using geshi.

Requisites: GeShi, the latest version the better, works with all versions

http://sourceforge.net/projects/geshi/files/geshi/GeSHi%201.0.8.9/GeSHi-1.0.8.9.tar.gz/download

You don't need the whole extension, just: 

geshi.php -> lib/geshi.php
bash.php  -> lib/geshi/bash.php

Best Regard.
From 10ba3fa656bc4c59fc6d82f67dbed772e900dc47 Mon Sep 17 00:00:00 2001
From: Manuel Tortosa <manutort...@gmail.com>
Date: Wed, 29 Sep 2010 13:28:49 +0200
Subject: [PATCH 2/2] Add PKGBUILD syntax highligh with GeShi

---
 web/html/pkgbuildview.php    |   25 +++++++++++++++++++++++++
 web/template/pkg_details.php |    2 +-
 2 files changed, 26 insertions(+), 1 deletions(-)
 create mode 100644 web/html/pkgbuildview.php

diff --git a/web/html/pkgbuildview.php b/web/html/pkgbuildview.php
new file mode 100644
index 0000000..1cc5d21
--- /dev/null
+++ b/web/html/pkgbuildview.php
@@ -0,0 +1,25 @@
+<?php
+set_include_path(get_include_path() . PATH_SEPARATOR . 'lib/');
+
+// Getting variables
+if (!empty($HTTP_POST_VARS)) extract($HTTP_POST_VARS);
+if (!empty($HTTP_GET_VARS)) extract($HTTP_GET_VARS);
+
+include('aur.inc');
+include_once 'geshi.php'; 
+
+$file = file_get_contents($pkgbuild, FILE_USE_INCLUDE_PATH); 
+$language = 'bash';
+
+html_header();
+
+echo "<div class='pgbox'>";
+	echo "<div class='pgboxbody'>";
+		$geshi = new GeSHi($file, $language);
+		$geshi->set_header_type(GESHI_HEADER_DIV);
+		echo "<span class='f4'>".$geshi->parse_code()."</span>";
+	echo "</div>";
+echo "</div>";
+
+html_footer(AUR_VERSION);
+?>
diff --git a/web/template/pkg_details.php b/web/template/pkg_details.php
index 9c76ab3..4c263de 100644
--- a/web/template/pkg_details.php
+++ b/web/template/pkg_details.php
@@ -66,7 +66,7 @@ $submitted_time = ($row["SubmittedTS"] == 0) ? "(unknown)" : gmdate("r", intval(
 <?php
 		if ($row['LocationID'] == 2) {
 			$urlpath = URL_DIR . $row['Name'] . '/' . $row['Name'];
-			print "<a href='$urlpath.tar.gz'>".__("Tarball")."</a> :: <a href='$urlpath'>".__("Files")."</a> :: <a href='$urlpath/PKGBUILD'>PKGBUILD</a></span>";
+			print "<a href='$urlpath.tar.gz'>".__("Tarball")."</a> :: <a href='$urlpath'>".__("Files")."</a> :: <a href='pkgbuildview.php?pkgbuild=$urlpath/PKGBUILD'>PKGBUILD</a></span>";
 		}
 
 		if ($row["OutOfDate"] == 1) {
-- 
1.7.1

Reply via email to