Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added GeSHi Caching and Binary file download.

  • Loading branch information...
commit 796781d2fdb7249fe7fd7c773b74537756d99389 1 parent b2901bd
@xanmanning xanmanning authored
View
4 README.markdown
@@ -36,6 +36,10 @@ Icons now included from http://www.famfamfam.com/lab/icons/silk/
...
### Notes
+#### Maintenance:
+Should you require a cleanup of the cache, delete everything in the .temp/cache folder.
+ * ``cd .temp/cache ; rm -r *``
+
#### Code/Variables:
(just for understanding code; doing cleanup)
View
2  config.php
@@ -46,6 +46,7 @@
/* The directory where repo directories reside (Trailing slash) */
$CONFIG['repo_directory'] = "/var/user/";
+ $CONFIG['repo_directory'] = "/home/xan/git/";
/* The suffix, that can be used for complementing the repo directory,
* useful when you are using nonbare repositories, then:
@@ -57,6 +58,7 @@
/* The path to GeSHi (geshi.php). Can be relative. */
$CONFIG['geshi_directory'] = "/path/to/geshi.php";
+ $CONFIG['geshi_directory'] = "/home/xan/www/PasteBin/geshi/geshi.php";
/* GeSHi line styles. (Produces tiger striping) */
$CONFIG['geshi_linea_style'] = 'background: #FFFFFF;';
View
79 git.php
@@ -223,9 +223,55 @@
/* The following are images and need to be displayed as such! */
'.png' => 'image', # PNG Image
'.jpg' => 'image', # JPEG Image
-'.jpeg' => 'image', # JPEG Image
+'.jpeg' => 'image', # JPEG Image
'.gif' => 'image', # GIF Image
-'.bmp' => 'image' # Bitmap Image
+'.bmp' => 'image', # Bitmap Image
+
+/* The following are needing to be downloaded! */
+'.pdf' => 'download',
+'.doc' => 'download',
+'.xls' => 'download',
+'.ppt' => 'download',
+'.pps' => 'download',
+'.odt' => 'download',
+'.ods' => 'download',
+'.odp' => 'download',
+'.odg' => 'download',
+'.odp' => 'download',
+'.zip' => 'download',
+'.7z' => 'download',
+'.tar.gz' => 'download',
+'.tar' => 'download',
+'.gz' => 'download',
+'.rar' => 'download',
+'.iso' => 'download',
+'.exe' => 'download',
+'.msi' => 'download',
+'.dwg' => 'download',
+'.dmg' => 'download',
+'.skp' => 'download',
+'.psd' => 'download',
+'.psb' => 'download',
+'.pdd' => 'download',
+'.psp' => 'download',
+'.xcf' => 'download',
+'.bz2' => 'download',
+'.bzip' => 'download',
+'.xpi' => 'download',
+'.ace' => 'download',
+'.flac' => 'download',
+'.flv' => 'download',
+'.mkv' => 'download',
+'.m4a' => 'download',
+'.mp3' => 'download',
+'.wma' => 'download',
+'.wmv' => 'download',
+'.ogg' => 'download',
+'.oda' => 'download',
+'.odv' => 'download',
+'.bin' => 'download',
+'.mp4' => 'download',
+'.swf' => 'download'
);
if (!isset($git_embed) && $git_embed != true) {
@@ -339,18 +385,31 @@ function html_blob($proj, $blob) {
exec($cmd, &$out);
$out = "<pre>" . htmlspecialchars(implode("\n", $out)) . "</pre>";
echo $out;
- } elseif($ext == "image") {
+ } elseif($ext == "download") {
+ //echo "download";
+ echo "<div id=\"download_blob\"><span class=\"strong\">" . $name . "</span> | " . $blob . " | <a href=\"" . sanitized_url() . "dl=dlfile&p=" . $proj . "&h=" . $blob . "&n=" . $name . "\">download</a></div>";
+ } elseif($ext == "image") {
//echo "image";
echo "<a href=\"" . sanitized_url() . "dl=image&p=" . $proj . "&b=" . $blob . "&n=" . $name . "\"><img src=\"" . sanitized_url() . "dl=image&p=" . $proj . "&b=" . $blob . "&n=" . $name . "\" id=\"image_blob\" /></a>";
} else {
//echo "highlight";
- $result = 0;
- $cmd = "GIT_DIR=" . escapeshellarg($repopath . $CONFIG['repo_suffix']) . " git cat-file blob " . escapeshellarg($blob) .
- " 2>&1";
- exec($cmd, &$out);
- $out = implode("\n", $out);
- $out = geshi_highlight($out, $ext);
- $out = geshi_style() . $out;
+ $geshiCache = $CONFIG['cache_directory'] . $proj . "/blob-" . $blob;
+ if(!file_exists($geshiCache)) {
+ $cmd = "GIT_DIR=" . escapeshellarg($repopath . $CONFIG['repo_suffix']) . " git cat-file blob " . escapeshellarg($blob) .
+ " 2>&1";
+ exec($cmd, &$out);
+ $out = implode("\n", $out);
+ $out = geshi_highlight($out, $ext);
+ $out = geshi_style() . $out;
+ $fp = fopen($geshiCache, "w");
+ fwrite($fp, $out);
+ fclose($fp);
+ chmod($geshiCache, 0666);
+ } else {
+ $fp = fopen($geshiCache, "r");
+ $out = fread($fp, filesize($geshiCache) + 1024);
+ fclose($fp);
+ }
echo $out;
}
echo "</div>\n";
View
5 gitstyle.css
@@ -15,8 +15,8 @@ div.optiontable .descol { text-align: right; width: 30%; }
div.optiontable .valcol { text-align: left; width: 70%; }
div.optiontable img { vertical-align: middle; }
div.imgtable table { padding: 10px 17px 10px 10px; border: 1px solid #E4E4E4; font-size: 1px; table-layout: auto; margin-top: 25px; }
-div.imgtable tags { color: #009900; background-color: #FFFF00; }
-div.imgtable branches { color: #CC6600; background-color: #99FF99; }
+div.imgtable tags { color: #009900; background-color: #FFFF00; padding: 3px 0px; }
+div.imgtable branches { color: #CC6600; background-color: #99FF99; padding: 3px 0px; }
div.imgtable img { border: 0px; display: block; }
div.imgtable .inl img { border: 0px; display: inline; }
div.imgtable .inl td { height: auto; vertical-align: middle; font-size: 2px; line-height: 3px; }
@@ -27,6 +27,7 @@ div#git-description > table { margin-top: 15px; }
div.gitbrowse > table td { padding: 5px 5px 5px 25px; }
img#image_blob { max-width: 600px; height: auto; }
img#image_blob { max-height: 600px; width: auto; }
+span.strong { font-weight: bold; }
tr:hover { background-color: #FFFFE1; }
div.gitbrowse a.blob { text-decoration: none; }
div.gitcode { padding: 10px; }
View
25 html_helpers.php
@@ -382,18 +382,19 @@ function write_img_png($imgptr) {
$img['git_logo']['name'] = "git-logo.png";
$img['git_logo']['bin'] = "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52" .
- "\x00\x00\x00\x48\x00\x00\x00\x1b\x04\x03\x00\x00\x00\x2d\xd9\xd4" .
- "\x2d\x00\x00\x00\x18\x50\x4c\x54\x45\xff\xff\xff\x60\x60\x5d\xb0" .
- "\xaf\xaa\x00\x80\x00\xce\xcd\xc7\xc0\x00\x00\xe8\xe8\xe6\xf7\xf7" .
- "\xf6\x95\x0c\xa7\x47\x00\x00\x00\x73\x49\x44\x41\x54\x28\xcf\x63" .
- "\x48\x67\x20\x04\x4a\x5c\x18\x0a\x08\x2a\x62\x53\x61\x20\x02\x08" .
- "\x0d\x69\x45\xac\xa1\xa1\x01\x30\x0c\x93\x60\x36\x26\x52\x91\xb1" .
- "\x01\x11\xd6\xe1\x55\x64\x6c\x6c\xcc\x6c\x6c\x0c\xa2\x0c\x70\x2a" .
- "\x62\x06\x2a\xc1\x62\x1d\xb3\x01\x02\x53\xa4\x08\xe8\x00\x03\x18" .
- "\x26\x56\x11\xd4\xe1\x20\x97\x1b\xe0\xb4\x0e\x35\x24\x71\x29\x82" .
- "\x99\x30\xb8\x93\x0a\x11\xb9\x45\x88\xc1\x8d\xa0\xa2\x44\x21\x06" .
- "\x27\x41\x82\x40\x85\xc1\x45\x89\x20\x70\x01\x00\xa4\x3d\x21\xc5" .
- "\x12\x1c\x9a\xfe\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82";
+ "\x00\x00\x00\x48\x00\x00\x00\x1b\x04\x03\x00\x00\x00\x2d\xd9\xd4" .
+ "\x2d\x00\x00\x00\x01\x73\x52\x47\x42\x00\xae\xce\x1c\xe9\x00\x00" .
+ "\x00\x18\x50\x4c\x54\x45\xff\xff\xff\x60\x60\x5d\xb0\xaf\xaa\x00" .
+ "\x80\x00\xce\xcd\xc7\xc0\x00\x00\xe8\xe8\xe6\xf7\xf7\xf6\x95\x0c" .
+ "\xa7\x47\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00" .
+ "\x0b\x13\x01\x00\x9a\x9c\x18\x00\x00\x00\x07\x74\x49\x4d\x45\x07" .
+ "\xda\x06\x1d\x02\x05\x39\x73\xb4\x47\x28\x00\x00\x00\x4b\x49\x44" .
+ "\x41\x54\x28\xcf\x63\x60\x18\x05\x44\x83\xd0\xd0\x50\x38\x86\x01" .
+ "\x63\x03\xe2\x14\x31\x1b\x13\x61\x01\x5e\x45\xcc\xc6\xc6\x06\x40" .
+ "\x04\xa4\xf0\xa8\x02\x2a\x31\xc0\x62\x9d\x31\x12\xa6\x48\x11\xc8" .
+ "\x72\x18\x26\x56\x11\xc4\xe1\x60\x97\xe3\xb6\x0e\x4b\x48\x62\x2a" .
+ "\x62\x36\x36\x1e\x4d\x85\xe4\x00\x00\x57\x98\x17\x05\x03\x18\xd1" .
+ "\xd4\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82";
if(!isset($img[$imgptr]['name'])) {
$img[$imgptr]['name'] = $imgptr . ".png";
Please sign in to comment.
Something went wrong with that request. Please try again.