Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed a bug in history.

  • Loading branch information...
commit adc5d02d6ec05cc826a92cbf285617fe330add27 1 parent bc06008
Remko Tronçon authored
Showing with 47 additions and 32 deletions.
  1. +2 −1  README
  2. +22 −7 config.php.sample
  3. +23 −24 index.php
3  README
View
@@ -31,7 +31,8 @@ Installation
------------
* Put the WiGit dir in some place where the webserver can find it
* Make sure there's a 'data' subdir, and that it is writable by the webserver
-* Edit config.php to reflect your local settings
+* Copy config.php.sample to config.php, and edit config.php to reflect your
+ local settings
* Surf to the wigit URL, and you should start by editing the front page
For URL rewriting, change the SCRIPT_URL to be the base URL prefix (as
29 config.php.sample
View
@@ -1,17 +1,32 @@
<?php
+ // Location of the Git binary
$GIT = "/usr/local/git/bin/git";
- $BASE_URL = "/~remko/wigit";
+ // Base URL of the wigit instalation. This will be prepended to all links
+ // to internal files.
+ $BASE_URL = "/wigit";
+
+ // The script to which all requests should be passed. The default is
+ // $BASE_URL/index.php?r= , which should work on all installations. If you
+ // want to use pretty URLs, set this to $BASE_URL. (see README)
$SCRIPT_URL = "$BASE_URL/index.php?r=";
- #$SCRIPT_URL = "$BASE_URL";
+ //$SCRIPT_URL = "$BASE_URL";
+
+ // Title of the wiki
+ $TITLE = "WiGit";
+
+ // Home page. This page is linked in the navigation bar, and is the default
+ // page that will be opened.
+ $DEFAULT_PAGE = "Home";
- //$TITLE = "WiGit";
- //$DEFAULT_PAGE = "Home";
- $CSS = "$BASE_URL/wigit.css";
+ // Dir that contains the data files (i.e. the Git repository). This directory
+ // must be writable by the web server.
+ $DATA_DIR = "data";
- //$DATA_DIR = "data";
+ // The default author of the git commits.
+ $DEFAULT_AUTHOR = 'Anonymous <anonymous@wigit>';
- //$DEFAULT_AUTHOR = 'Anonymous <anonymous@wigit>';
+ // Set the mappings from HTTP username to Git commit author.
$AUTHORS = array(
"remko" => "Remko Tronçon <git@el-tramo.be>",
"guest" => "Guest <guest@el-tramo.be>"
47 index.php
View
@@ -25,31 +25,30 @@
function getGitHistory($file = "") {
$output = array();
- git("log --pretty=format:'%H>%T>%an>%ae>%aD>%s' -- $file", $output);
+ // FIXME: Find a better way to find the files that changed than --name-only
+ git("log --name-only --pretty=format:'%H>%T>%an>%ae>%aD>%s' -- $file", $output);
$history = array();
+ $historyItem = array();
foreach ($output as $line) {
$logEntry = explode(">", $line, 6);
-
- // Find out which file was edited
- $treeOutput = array();
- if (!git("ls-tree ". $logEntry[1], $treeOutput) || sizeof($treeOutput) == 0) {
- continue;
+ if (sizeof($logEntry) > 1) {
+ // Populate history structure
+ $historyItem = array(
+ "author" => $logEntry[2],
+ "email" => $logEntry[3],
+ "linked-author" => (
+ $logEntry[3] == "" ?
+ $logEntry[2]
+ : "<a href=\"mailto:$logEntry[3]\">$logEntry[2]</a>"),
+ "date" => $logEntry[4],
+ "message" => $logEntry[5],
+ "commit" => $logEntry[0]
+ );
+ }
+ else if (!isset($historyItem["page"])) {
+ $historyItem["page"] = $line;
+ $history[] = $historyItem;
}
- $page = end(split("\x09", $treeOutput[0]));
-
- // Populate history structure
- $history[] = array(
- "author" => $logEntry[2],
- "email" => $logEntry[3],
- "linked-author" => (
- $logEntry[3] == "" ?
- $logEntry[2]
- : "<a href=\"mailto:$logEntry[3]\">$logEntry[2]</a>"),
- "date" => $logEntry[4],
- "message" => $logEntry[5],
- "page" => $page,
- "commit" => $logEntry[0]
- );
}
return $history;
}
@@ -113,7 +112,7 @@ function git($command, &$output = "") {
$umask = $oldUMask;
// FIXME: The -1 is a hack to avoid 'commit' on an unchanged repo to
// fail.
- if ($result != 0 && $result != 1) {
+ if ($result != 0) {
// FIXME: HTMLify these strings
print "<h1>Error</h1>\n<pre>\n";
print "$" . $gitCommand . "\n";
@@ -162,7 +161,7 @@ function wikify($text) {
// FIXME: Do not apply this in <pre> and <notextile> blocks.
// Linkify
- $text = preg_replace('@[^:](https?://([-\w\.]+)+(:\d+)?(/([-\w/_\.]*(\?\S+)?)?)?)@', '<a href="$1">$1</a>', $text);
+ $text = preg_replace('@([^:])(https?://([-\w\.]+)+(:\d+)?(/([-\w/_\.]*(\?\S+)?)?)?)@', '$1<a href="$2">$2</a>', $text);
// WikiLinkify
$text = preg_replace('@\[([A-Z]\w+)\]@', '<a href="' . $SCRIPT_URL . '/$1">$1</a>', $text);
@@ -294,7 +293,7 @@ function getRawData() {
$author = addslashes(getAuthorForUser(getUser()));
if (!git("init")) { return; }
if (!git("add $wikiPage")) { return; }
- if (!git("commit --message='$commitMessage' --author='$author'")) { return; }
+ if (!git("commit --allow-empty --no-verify --message='$commitMessage' --author='$author'")) { return; }
if (!git("gc")) { return; }
header("Location: " . getViewURL($wikiPage));
return;
Please sign in to comment.
Something went wrong with that request. Please try again.