Commit adc5d02d6ec05cc826a92cbf285617fe330add27
- Diff rendering mode:
- inline
- side by side
README
(2 / 1)
|   | |||
| 31 | 31 | ------------ | |
| 32 | 32 | * Put the WiGit dir in some place where the webserver can find it | |
| 33 | 33 | * 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 | ||
| 35 | 36 | * Surf to the wigit URL, and you should start by editing the front page | |
| 36 | 37 | ||
| 37 | 38 | For URL rewriting, change the SCRIPT_URL to be the base URL prefix (as |
config.php.sample
(22 / 7)
|   | |||
| 1 | 1 | <?php | |
| 2 | // Location of the Git binary | ||
| 2 | 3 | $GIT = "/usr/local/git/bin/git"; | |
| 3 | $BASE_URL = "/~remko/wigit"; | ||
| 4 | 4 | ||
| 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) | ||
| 5 | 12 | $SCRIPT_URL = "$BASE_URL/index.php?r="; | |
| 6 | #$SCRIPT_URL = "$BASE_URL"; | ||
| 13 | //$SCRIPT_URL = "$BASE_URL"; | ||
| 7 | 14 | ||
| 8 | //$TITLE = "WiGit"; | ||
| 9 | //$DEFAULT_PAGE = "Home"; | ||
| 10 | $CSS = "$BASE_URL/wigit.css"; | ||
| 15 | // Title of the wiki | ||
| 16 | $TITLE = "WiGit"; | ||
| 11 | 17 | ||
| 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"; | ||
| 13 | 21 | ||
| 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. | ||
| 15 | 30 | $AUTHORS = array( | |
| 16 | 31 | "remko" => "Remko Tronçon <git@el-tramo.be>", | |
| 17 | 32 | "guest" => "Guest <guest@el-tramo.be>" |
index.php
(23 / 24)
|   | |||
| 25 | 25 | ||
| 26 | 26 | function getGitHistory($file = "") { | |
| 27 | 27 | $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); | ||
| 29 | 30 | $history = array(); | |
| 31 | $historyItem = array(); | ||
| 30 | 32 | foreach ($output as $line) { | |
| 31 | 33 | $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 | ); | ||
| 37 | 47 | } | |
| 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 | } | ||
| 53 | 52 | } | |
| 54 | 53 | return $history; | |
| 55 | 54 | } | |
| … | … | ||
| 112 | 112 | $umask = $oldUMask; | |
| 113 | 113 | // FIXME: The -1 is a hack to avoid 'commit' on an unchanged repo to | |
| 114 | 114 | // fail. | |
| 115 | if ($result != 0 && $result != 1) { | ||
| 115 | if ($result != 0) { | ||
| 116 | 116 | // FIXME: HTMLify these strings | |
| 117 | 117 | print "<h1>Error</h1>\n<pre>\n"; | |
| 118 | 118 | print "$" . $gitCommand . "\n"; | |
| … | … | ||
| 161 | 161 | // FIXME: Do not apply this in <pre> and <notextile> blocks. | |
| 162 | 162 | ||
| 163 | 163 | // 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); | ||
| 165 | 165 | ||
| 166 | 166 | // WikiLinkify | |
| 167 | 167 | $text = preg_replace('@\[([A-Z]\w+)\]@', '<a href="' . $SCRIPT_URL . '/$1">$1</a>', $text); | |
| … | … | ||
| 293 | 293 | $author = addslashes(getAuthorForUser(getUser())); | |
| 294 | 294 | if (!git("init")) { return; } | |
| 295 | 295 | 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; } | ||
| 297 | 297 | if (!git("gc")) { return; } | |
| 298 | 298 | header("Location: " . getViewURL($wikiPage)); | |
| 299 | 299 | return; |

