Chora fixes from CVS HEAD.
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 7 Jan 2009 06:23:59 +0000 (23:23 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 7 Jan 2009 06:23:59 +0000 (23:23 -0700)
chora/annotate.php
chora/diff.php
chora/templates/annotate/footer.inc [deleted file]
chora/templates/annotate/header.inc
chora/templates/annotate/line.inc
chora/templates/diff/hr/header.inc
chora/templates/directory/file.inc
chora/templates/log/rev.inc
chora/themes/screen.css

index 9f76e0a..27ca666 100644 (file)
@@ -39,9 +39,6 @@ $revMap = $fl->revs;
 sort($revMap);
 $rrevMap = array_flip($revMap);
 
-/* Keep track of any revision we encounter in the following loop. */
-$revList = array();
-
 require CHORA_TEMPLATES . '/common-header.inc';
 require CHORA_TEMPLATES . '/menu.inc';
 require CHORA_TEMPLATES . '/headerbar.inc';
@@ -49,25 +46,20 @@ require CHORA_TEMPLATES . '/annotate/header.inc';
 
 /* Use this counter so that we can give each tooltip object a unique
  * id attribute (which we use to set the tooltip text later). */
-foreach ($lines as $line) {
+while (list(,$line) = each($lines)) {
     $lineno = $line['lineno'];
-    $prevAuthor = $author;
     $author = Chora::showAuthorName($line['author']);
-    if ($prevAuthor != $author) {
-        $style = (++$style % 2);
-    }
+    $prevRev = $rev;
     $rev = $line['rev'];
-    $prev = isset($revMap[$rrevMap[$rev] - 1]) ? $revMap[$rrevMap[$rev] - 1] : null;
-    if (!isset($revList[$rev])) {
-        $revList[$rev] = $fl->logs[$rev];
-    }
-    if (!is_null($prev) && !isset($revList[$prev])) {
-        $revList[$prev] = $fl->logs[$prev];
+    if ($prevRev != $rev) {
+        $style = (++$style % 2);
     }
+    $prev = (isset($rrevMap[$rev]) && isset($revMap[$rrevMap[$rev] - 1]))
+        ? $revMap[$rrevMap[$rev] - 1]
+        : null;
     $line = Text::htmlAllSpaces($line['line']);
     include CHORA_TEMPLATES . '/annotate/line.inc';
     ++$i;
 }
 
-require CHORA_TEMPLATES . '/annotate/footer.inc';
 require $registry->get('templates', 'horde') . '/common-footer.inc';
index 91ec239..8fcc55c 100644 (file)
@@ -13,8 +13,8 @@ require_once dirname(__FILE__) . '/lib/base.php';
 
 /* Spawn the repository and file objects */
 $fl = $VC->getFileObject($where, $cache);
-$rev_ob = $VC->getRevisionObject();
 Chora::checkError($fl);
+$rev_ob = $VC->getRevisionObject();
 
 /* Initialise the form variables correctly. */
 $r1 = Util::getFormData('r1');
diff --git a/chora/templates/annotate/footer.inc b/chora/templates/annotate/footer.inc
deleted file mode 100644 (file)
index db7876d..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-</tbody>
-</table>
-<script type="text/javascript">
-//<![CDATA[
-function setRevisionLogTitles()
-{
-    var revisionLogMap = [];
-    <?php
-    foreach ($revList as $lg) {
-        // The code below attempts to account for the following:
-        //   1) log text with line breaks.
-        //   2) log text with inline HTML.
-        $logmsg = Text_Filter::filter($lg->log, 'text2html', array('parselevel' => TEXT_HTML_NOHTML, 'charset' => NLS::getCharset(), 'class' => ''));
-
-        // The above function converts newlines to HTML, and we don't
-        // want to escape those. Since the entire text is enclosed in
-        // single-quotes in JavaScipt, it should suffice to simply
-        // escape those. Everything else is already escaped.
-        $logmsg = str_replace('</', '<\/',
-            '<strong>' . $lg->rev . '</strong> ' .
-            '&lt;' . Chora::showAuthorName($lg->queryAuthor(), true) . '&gt; ' .
-            '<strong>' . sprintf(_("%s ago"), Chora::readableTime($lg->date, true)) . '</strong>' .
-            '<br />' .
-            str_replace(array("'", "\n"), array('&#039;', '\n'), $logmsg));
-        echo "revisionLogMap['" . $lg->rev . "'] = '$logmsg';\n";
-    }
-    ?>
-
-    var links = document.getElementsByTagName('A');
-    for (var i = 0; i < links.length; ++i) {
-        var rx = RegExp('^p?rev_([0-9.]+)_\\d+$').exec(links[i].id);
-        if (!rx) {
-            continue;
-        }
-        links[i].setAttribute('title', revisionLogMap[rx[1]]);
-    }
-
-    ToolTips.attachBehavior();
-}
-addEvent(window, 'load', setRevisionLogTitles);
-//]]>
-</script>
index 9036d2c..626de48 100644 (file)
@@ -4,7 +4,6 @@
   <th class="rightAlign"><?php echo _("#") ?></th>
   <th><?php echo _("Author") ?></th>
   <th><?php echo _("Rev") ?></th>
-  <th><?php echo _("Prev") ?></th>
   <th><?php echo _("Line") ?></th>
  </tr>
 </thead>
index d6da97b..a7d6718 100644 (file)
@@ -1,7 +1,17 @@
  <tr id="l<?php echo $lineno ?>">
-  <td class="rightAlign"><?php echo $lineno ?></td>
-  <td class="author"><?php echo $author ?></td>
-  <td class="rev"><a id="rev_<?php echo $rev . '_' . $i ?>" href="<?php echo Chora::url('co', $where, array('r' => $rev)) ?>" title="<?php echo $rev ?>"><?php echo $rev_ob->abbrev($rev) ?></a></td>
-  <td class="rev"><?php if ($prev): ?><a id="prev_<?php echo $prev . '_' . $i ?>" href="<?php echo Chora::url('annotate', $where, array('rev' => $prev)) . '#l' . $lineno ?>" title="<?php echo $prev ?>"><?php echo $rev_ob->abbrev($prev) ?></a><?php else: ?>&nbsp;<?php endif; ?></td>
-  <td class="item<?php echo $style ?>"><tt><?php echo (trim($line) != '') ? $line : '&nbsp;' ?></tt></td>
+  <td class="rightAlign">
+    <?php echo $lineno ?>
+  </td>
+  <td class="author">
+    <?php echo $author ?>
+  </td>
+  <td class="rev">
+    <a id="rev_<?php echo $rev . '_' . $i ?>" href="<?php echo Chora::url('co', $where, array('r' => $rev)) ?>" title="<?php echo htmlspecialchars($rev) ?>"><?php echo htmlspecialchars($rev_ob->abbrev($rev)) ?></a>
+<?php if ($prev): ?>
+    <a href="<?php echo Chora::url('diff', $where, array('r1' => $prev, 'r2' => $rev)) ?>" title="<?php echo sprintf(_("Diff to %s"), htmlspecialchars($prev)) ?>"><?php echo Horde::img('diff.png') ?></a>
+<?php endif; ?>
+  </td>
+  <td class="item<?php echo $style ?>">
+   <tt><?php echo (trim($line) != '') ? $line : '&nbsp;' ?></tt>
+  </td>
  </tr>
index f64c6f8..6360fc2 100644 (file)
@@ -45,7 +45,7 @@
    <?php if (!empty($val['branchName'])): ?><li><?php echo _("Branch:") ?> <strong><a href="<?php echo Chora::url('', $where, array('onb' => $val['branchRev'])) ?>"><?php echo $val['branchName'] ?></a></strong></li><?php endif; ?>
    <?php if (!empty($val['tags'])): ?><li class="tags"><?php echo _("Tags:") ?> <?php echo implode(', ', $val['tags']) ?></li><?php endif; ?>
   </ul>
-  <a href="<?php echo Chora::url('co', $where, array('r' => $val['rev'])) ?>" title="<?php echo $val['rev'] ?>"><?php echo $rev_ob->abbrev($val['rev']) ?></a>: <?php echo $val['msg'] ?>
+  <a href="<?php echo Chora::url('co', $where, array('r' => $val['rev'])) ?>" title="<?php echo htmlspecialchars($val['rev']) ?>"><?php echo htmlspecialchars($rev_ob->abbrev($val['rev'])) ?></a>: <?php echo $val['msg'] ?>
   <div class="diffclear"></div>
  </div>
 <?php endforeach; ?>
@@ -53,8 +53,8 @@
 <?php endif; ?>
 <thead>
 <tr>
- <th><a href="<?php echo Chora::url('co', $where, array('r' => $r1)) ?>" title="<?php echo $r1 ?>"><?php printf(_("Version %s"), $abbrev_r1) ?></a></th>
- <th><a href="<?php echo Chora::url('co', $where, array('r' => $r2)) ?>" title="<?php echo $r2 ?>"><?php printf(_("Version %s"), $abbrev_r2) ?></a></th>
+ <th><a href="<?php echo Chora::url('co', $where, array('r' => $r1)) ?>" title="<?php echo htmlspecialchars($r1) ?>"><?php printf(_("Version %s"), htmlspecialchars($abbrev_r1)) ?></a></th>
+ <th><a href="<?php echo Chora::url('co', $where, array('r' => $r2)) ?>" title="<?php echo htmlspecialchars($r2) ?>"><?php printf(_("Version %s"), htmlspecialchars($abbrev_r2)) ?></a></th>
 </tr>
 </thead>
 <tbody>
index 3ab7c28..67452b9 100644 (file)
   <td>
    <strong>
 <?php if ($conf['filename_linkto'] == 'revlog'): ?>
-    <a href="<?php echo Chora::url('co', $fileName, array('r' => $head)) ?>" title="<?php echo $head ?>">
+    <a href="<?php echo Chora::url('co', $fileName, array('r' => $head)) ?>" title="<?php echo htmlspecialchars($head) ?>">
 <?php else: ?>
-    <a href="<?php echo $url ?>" title="<?php echo $head ?>">
+    <a href="<?php echo $url ?>" title="<?php echo htmlspecialchars($head) ?>">
 <?php endif; ?>
-<?php echo $rev_ob->abbrev($head) ?></a></strong>
+<?php echo htmlspecialchars($rev_ob->abbrev($head)) ?></a></strong>
   </td>
 <?php else: ?>
   <td>
@@ -31,7 +31,7 @@
 <?php endif; ?>
    <?php echo $name ?>
   </td>
-  <td><strong><?php echo $rev_ob->abbrev($head) ?></strong></td>
+  <td><strong><?php echo htmlspecialchars($rev_ob->abbrev($head)) ?></strong></td>
 <?php endif; ?>
   <td><?php echo $author ?></td>
   <td sortval="<?php echo (int)$date ?>">
index 3d013c0..855377f 100644 (file)
@@ -5,7 +5,7 @@
   <?php endif ?>
   <a href="<?php echo Chora::url('diff', $where, array('r1' => 0, 'r2' => $rev)) ?>" class="sdiff" title="<?php echo _("Show changes to the selected revision") ?>" onclick="revlog_sdiff(this);"><?php echo Horde::img('diff.png') ?></a>
  </td>
- <td><a href="<?php echo $textUrl ?>" title="<?php echo $rev ?>"><?php echo $rev_ob->abbrev($rev) . '</a>'; if ($branchName) echo ' <span class="branch">' . Horde::link(Chora::url('', $where, array('onb' => $branchRev))) . htmlspecialchars($branchName) . '</a></span>'; if (!empty($lg->lines)) echo ' <small>(' . sprintf('%s lines', $lg->lines) . ')</small>'; ?></td>
+ <td><a href="<?php echo $textUrl ?>" title="<?php echo htmlspecialchars($rev) ?>"><?php echo htmlspecialchars($rev_ob->abbrev($rev)) . '</a>'; if ($branchName) echo ' <span class="branch">' . Horde::link(Chora::url('', $where, array('onb' => $branchRev))) . htmlspecialchars($branchName) . '</a></span>'; if (!empty($lg->lines)) echo ' <small>(' . sprintf('%s lines', $lg->lines) . ')</small>'; ?></td>
  <td class="ago" sortval="<?php echo (int)$lg->date ?>"><a title="<?php echo $readableDate ?>"><?php echo $commitDate ?></a></td>
  <td class="author"><?php echo $author ?></td>
  <td class="log">
index c134f52..d0dfbd6 100644 (file)
@@ -221,6 +221,8 @@ table.annotate .author {
 }
 table.annotate .rev {
     background: #fee;
+    padding-right: 2px;
+    white-space: nowrap;
 }
 
 /* Diff styles. */