Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/treetrek.git
M DiffPage.php
3636
      $this->renderBreadcrumbs();
3737
38
      // Fix 1: Redact email address
39
      $author = $headers['author'] ?? 'Unknown';
40
      $author = preg_replace('/<[^>]+>/', '<email>', $author);
41
3842
      echo '<div class="commit-details">';
3943
      echo '<div class="commit-header">';
4044
      echo '<h1 class="commit-title">' . htmlspecialchars(trim($msg)) . '</h1>';
4145
      echo '<div class="commit-info">';
42
      echo '<div class="commit-info-row"><span class="commit-info-label">Author</span><span class="commit-author">' . htmlspecialchars($headers['author'] ?? 'Unknown') . '</span></div>';
46
      echo '<div class="commit-info-row"><span class="commit-info-label">Author</span><span class="commit-author">' . htmlspecialchars($author) . '</span></div>';
4347
      echo '<div class="commit-info-row"><span class="commit-info-label">Commit</span><span class="commit-info-value">' . $this->hash . '</span></div>';
48
4449
      if (isset($headers['parent'])) {
45
          $repoUrl = '?repo=' . urlencode($this->currentRepo['safe_name']);
50
          // Fix 2: Use '&' instead of '?' because parameters (action & hash) already exist
51
          $repoUrl = '&repo=' . urlencode($this->currentRepo['safe_name']);
4652
          echo '<div class="commit-info-row"><span class="commit-info-label">Parent</span><span class="commit-info-value">';
4753
          echo '<a href="?action=commit&hash=' . $headers['parent'] . $repoUrl . '" class="parent-link">' . substr($headers['parent'], 0, 7) . '</a>';
...
7985
        echo '<div class="diff-binary">Binary files differ</div>';
8086
    } else {
81
        echo '<div class="diff-content">';
82
        echo '<table><tbody>';
87
      echo '<div class="diff-content">';
88
      echo '<table><tbody>';
8389
84
        foreach ($change['hunks'] as $line) {
85
            if (isset($line['t']) && $line['t'] === 'gap') {
86
                echo '<tr class="diff-gap"><td colspan="3">...</td></tr>';
87
                continue;
88
            }
90
      foreach ($change['hunks'] as $line) {
91
          if (isset($line['t']) && $line['t'] === 'gap') {
92
              echo '<tr class="diff-gap"><td colspan="3">...</td></tr>';
93
              continue;
94
          }
8995
90
            $class = 'diff-ctx';
91
            $char = ' ';
92
            if ($line['t'] === '+') { $class = 'diff-add'; $char = '+'; }
93
            if ($line['t'] === '-') { $class = 'diff-del'; $char = '-'; }
96
          $class = 'diff-ctx';
97
          $char = ' ';
98
          if ($line['t'] === '+') { $class = 'diff-add'; $char = '+'; }
99
          if ($line['t'] === '-') { $class = 'diff-del'; $char = '-'; }
94100
95
            echo '<tr class="' . $class . '">';
96
            echo '<td class="diff-num" data-num="' . $line['no'] . '"></td>';
97
            echo '<td class="diff-num" data-num="' . $line['nn'] . '"></td>';
98
            echo '<td class="diff-code"><span class="diff-marker">' . $char . '</span>' . htmlspecialchars($line['l']) . '</td>';
99
            echo '</tr>';
100
        }
101
        echo '</tbody></table>';
102
        echo '</div>';
101
          echo '<tr class="' . $class . '">';
102
          echo '<td class="diff-num" data-num="' . $line['no'] . '"></td>';
103
          echo '<td class="diff-num" data-num="' . $line['nn'] . '"></td>';
104
          echo '<td class="diff-code"><span class="diff-marker">' . $char . '</span>' . htmlspecialchars($line['l']) . '</td>';
105
          echo '</tr>';
106
      }
107
108
      echo '</tbody></table>';
109
      echo '</div>';
103110
    }
104111
    echo '</div>';
105112
  }
106113
107114
  private function renderBreadcrumbs() {
108
    $repoUrl = '?repo=' . urlencode( $this->currentRepo['safe_name'] );
115
    $safeName = urlencode($this->currentRepo['safe_name']);
116
109117
    $crumbs = [
110118
      '<a href="?">Repositories</a>',
111
      '<a href="' . $repoUrl . '">' . htmlspecialchars($this->currentRepo['name']) . '</a>',
112
      '<a href="?action=commits' . $repoUrl . '">Commits</a>',
119
      '<a href="?repo=' . $safeName . '">' . htmlspecialchars($this->currentRepo['name']) . '</a>',
120
      // Fix 3: Use '&' separator for the repo parameter
121
      '<a href="?action=commits&repo=' . $safeName . '">Commits</a>',
113122
      substr($this->hash, 0, 7)
114123
    ];