Commit adc5d02d6ec05cc826a92cbf285617fe330add27

Fixed a bug in history.
README
(2 / 1)
  
3131------------
3232* Put the WiGit dir in some place where the webserver can find it
3333* Make sure there's a 'data' subdir, and that it is writable by the webserver
34* Edit config.php to reflect your local settings
34* Copy config.php.sample to config.php, and edit config.php to reflect your
35 local settings
3536* Surf to the wigit URL, and you should start by editing the front page
3637
3738For URL rewriting, change the SCRIPT_URL to be the base URL prefix (as
  
11<?php
2 // Location of the Git binary
23 $GIT = "/usr/local/git/bin/git";
3 $BASE_URL = "/~remko/wigit";
44
5 // Base URL of the wigit instalation. This will be prepended to all links
6 // to internal files.
7 $BASE_URL = "/wigit";
8
9 // The script to which all requests should be passed. The default is
10 // $BASE_URL/index.php?r= , which should work on all installations. If you
11 // want to use pretty URLs, set this to $BASE_URL. (see README)
512 $SCRIPT_URL = "$BASE_URL/index.php?r=";
6 #$SCRIPT_URL = "$BASE_URL";
13 //$SCRIPT_URL = "$BASE_URL";
714
8 //$TITLE = "WiGit";
9 //$DEFAULT_PAGE = "Home";
10 $CSS = "$BASE_URL/wigit.css";
15 // Title of the wiki
16 $TITLE = "WiGit";
1117
12 //$DATA_DIR = "data";
18 // Home page. This page is linked in the navigation bar, and is the default
19 // page that will be opened.
20 $DEFAULT_PAGE = "Home";
1321
14 //$DEFAULT_AUTHOR = 'Anonymous <anonymous@wigit>';
22 // Dir that contains the data files (i.e. the Git repository). This directory
23 // must be writable by the web server.
24 $DATA_DIR = "data";
25
26 // The default author of the git commits.
27 $DEFAULT_AUTHOR = 'Anonymous <anonymous@wigit>';
28
29 // Set the mappings from HTTP username to Git commit author.
1530 $AUTHORS = array(
1631 "remko" => "Remko Tronçon <git@el-tramo.be>",
1732 "guest" => "Guest <guest@el-tramo.be>"
index.php
(23 / 24)
  
2525
2626 function getGitHistory($file = "") {
2727 $output = array();
28 git("log --pretty=format:'%H>%T>%an>%ae>%aD>%s' -- $file", $output);
28 // FIXME: Find a better way to find the files that changed than --name-only
29 git("log --name-only --pretty=format:'%H>%T>%an>%ae>%aD>%s' -- $file", $output);
2930 $history = array();
31 $historyItem = array();
3032 foreach ($output as $line) {
3133 $logEntry = explode(">", $line, 6);
32
33 // Find out which file was edited
34 $treeOutput = array();
35 if (!git("ls-tree ". $logEntry[1], $treeOutput) || sizeof($treeOutput) == 0) {
36 continue;
34 if (sizeof($logEntry) > 1) {
35 // Populate history structure
36 $historyItem = array(
37 "author" => $logEntry[2],
38 "email" => $logEntry[3],
39 "linked-author" => (
40 $logEntry[3] == "" ?
41 $logEntry[2]
42 : "<a href=\"mailto:$logEntry[3]\">$logEntry[2]</a>"),
43 "date" => $logEntry[4],
44 "message" => $logEntry[5],
45 "commit" => $logEntry[0]
46 );
3747 }
38 $page = end(split("\x09", $treeOutput[0]));
39
40 // Populate history structure
41 $history[] = array(
42 "author" => $logEntry[2],
43 "email" => $logEntry[3],
44 "linked-author" => (
45 $logEntry[3] == "" ?
46 $logEntry[2]
47 : "<a href=\"mailto:$logEntry[3]\">$logEntry[2]</a>"),
48 "date" => $logEntry[4],
49 "message" => $logEntry[5],
50 "page" => $page,
51 "commit" => $logEntry[0]
52 );
48 else if (!isset($historyItem["page"])) {
49 $historyItem["page"] = $line;
50 $history[] = $historyItem;
51 }
5352 }
5453 return $history;
5554 }
112112 $umask = $oldUMask;
113113 // FIXME: The -1 is a hack to avoid 'commit' on an unchanged repo to
114114 // fail.
115 if ($result != 0 && $result != 1) {
115 if ($result != 0) {
116116 // FIXME: HTMLify these strings
117117 print "<h1>Error</h1>\n<pre>\n";
118118 print "$" . $gitCommand . "\n";
161161 // FIXME: Do not apply this in <pre> and <notextile> blocks.
162162
163163 // Linkify
164 $text = preg_replace('@[^:](https?://([-\w\.]+)+(:\d+)?(/([-\w/_\.]*(\?\S+)?)?)?)@', '<a href="$1">$1</a>', $text);
164 $text = preg_replace('@([^:])(https?://([-\w\.]+)+(:\d+)?(/([-\w/_\.]*(\?\S+)?)?)?)@', '$1<a href="$2">$2</a>', $text);
165165
166166 // WikiLinkify
167167 $text = preg_replace('@\[([A-Z]\w+)\]@', '<a href="' . $SCRIPT_URL . '/$1">$1</a>', $text);
293293 $author = addslashes(getAuthorForUser(getUser()));
294294 if (!git("init")) { return; }
295295 if (!git("add $wikiPage")) { return; }
296 if (!git("commit --message='$commitMessage' --author='$author'")) { return; }
296 if (!git("commit --allow-empty --no-verify --message='$commitMessage' --author='$author'")) { return; }
297297 if (!git("gc")) { return; }
298298 header("Location: " . getViewURL($wikiPage));
299299 return;