2 if (!$User->admin('edit')) {
3 require '403.inc.html';
7 $hash = ltrim($Page->path, '/');
12 $this->title = "Wijzigingen in ".strtoupper($hash);
13 print "<h2>{$this->title}</h2>\n";
16 . "--word-diff=porcelain --no-prefix --pretty='%H%n%at\t%an\t%w(0,0,1)%B' "
17 . escapeshellarg($hash);
18 $log = popen($gitcmd, 'r');
19 if (!$log or strpos(fgets($log), $hash) !== 0) {
20 $Page->place['warn'] = "Kon inhoud niet ophalen met <code>$gitcmd</code>";
24 # read metadata and commit message
25 list ($atime, $author, $msg) = explode("\t", fgets($log), 3);
26 while ( $line = fgets($log) ) {
28 fgets($log); // assume another empty line
31 $msg .= substr($line, 1);
36 printf('<small class="date">%s • %s</small>',
37 htmlspecialchars($author), strftime('%F %H:%M', $atime)
39 print "\n".nl2br(htmlspecialchars($msg));
44 white-space: pre-wrap;
45 white-space: break-spaces;
46 font-family: monospace;
48 td:first-of-type.change,
51 text-decoration: none;
53 td:last-of-type.change,
56 text-decoration: none;
66 print '<table class="diff">';
67 while ( $line = fgets($log) ) {
68 preg_match(isset($ln) ? '/^(\W|\S+ )(.*)/' : '/^(\S+ )(.*)/', $line, $part);
69 $body = htmlspecialchars($part[2]);
73 if (preg_match('/^--git (.+) (.*)/', $part[2], $diffhead)) {
74 $row = "$diffhead[1]";
75 if ($diffhead[1] !== $diffhead[2]) {
76 $row .= " → $diffhead[2]";
86 if (preg_match('/^[-](\d+)(?:,\d+)? [+](\d+)(?:,\d+)? @@/', $part[2], $diffstart)) {
87 array_shift($diffstart);
91 $ln = ['?', '?']; # unrecognised diff header
93 print '<tr class="head"><td colspan="4">'.$row.'</tr>'."\n";
96 $col[0] .= "<del>$body</del>";
99 $col[1] .= "<ins>$body</ins>";
108 foreach ($col as $i => $line) {
113 printf('<th>%s</th><td%s>%s</td>',
115 $col[0] == $col[1] ? '' : ' class="change"',