Chora updates from CVS HEAD.
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 8 Jan 2009 00:50:33 +0000 (17:50 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 8 Jan 2009 00:51:34 +0000 (17:51 -0700)
Mainly dealing with adding AJAX log retrieval to annotate page.

chora/annotate.php
chora/docs/CHANGES
chora/js/annotate.js [new file with mode: 0644]
chora/js/src/annotate.js [new file with mode: 0644]
chora/templates/annotate/header.inc
chora/templates/annotate/line.inc
chora/templates/common-header.inc
chora/themes/graphics/log.png [new file with mode: 0644]
chora/themes/silver/graphics/log.png [new file with mode: 0644]

index 27ca666..1ae747e 100644 (file)
  */
 
 require_once dirname(__FILE__) . '/lib/base.php';
-require_once 'Horde/Text/Filter.php';
 
 /* Spawn the file object. */
 $fl = $VC->getFileObject($where, $cache);
-$rev_ob = $VC->getRevisionObject();
 Chora::checkError($fl);
+$rev_ob = $VC->getRevisionObject();
 
 /* Retrieve the desired revision from the GET variable. */
 $rev = Util::getFormData('rev', '1.1');
@@ -23,6 +22,20 @@ if (!$VC->isValidRevision($rev)) {
     Chora::fatal(sprintf(_("Revision %s not found"), $rev), '404 Not Found');
 }
 
+switch (Util::getFormData('actionID')) {
+case 'log':
+    if (isset($fl->logs[$rev])) {
+        $log = $fl->logs[$rev];
+        $out = '<em>' . _("Author") . ':</em> ' . Chora::showAuthorName($log->queryAuthor(), true) . '<br />' .
+            '<em>' . _("Date") . ':</em> ' . Chora::formatDate($log->queryDate()) . '<br /><br />' .
+            Chora::formatLogMessage($log->queryLog());
+    } else {
+        $out = '';
+    }
+    echo $out;
+    exit;
+}
+
 $ann = &$VC->getAnnotateObject($fl);
 Chora::checkError($lines = $ann->doAnnotate($rev));
 
@@ -31,19 +44,22 @@ $extraLink = sprintf('<a href="%s">%s</a> | <a href="%s">%s</a>',
                      Chora::url('co', $where, array('r' => $rev)), _("View"),
                      Chora::url('co', $where, array('r' => $rev, 'p' => 1)), _("Download"));
 
-$author = '';
-$i = $style = 0;
+Horde::addScriptFile('prototype.js', 'chora', true);
+Horde::addScriptFile('annotate.js', 'chora', true);
 
-/* Map of revisions for finding the previous revision to a change. */
-$revMap = $fl->revs;
-sort($revMap);
-$rrevMap = array_flip($revMap);
+$js_vars = array(
+    'ANNOTATE_URL' => Util::addParameter(Horde::applicationUrl('annotate.php'), array('actionID' => 'log', 'f' => $where, 'rev' => ''), null, false),
+    'loading_text' => _("Loading...")
+);
 
 require CHORA_TEMPLATES . '/common-header.inc';
 require CHORA_TEMPLATES . '/menu.inc';
 require CHORA_TEMPLATES . '/headerbar.inc';
 require CHORA_TEMPLATES . '/annotate/header.inc';
 
+$author = '';
+$i = $style = 0;
+
 /* Use this counter so that we can give each tooltip object a unique
  * id attribute (which we use to set the tooltip text later). */
 while (list(,$line) = each($lines)) {
@@ -54,9 +70,12 @@ while (list(,$line) = each($lines)) {
     if ($prevRev != $rev) {
         $style = (++$style % 2);
     }
-    $prev = (isset($rrevMap[$rev]) && isset($revMap[$rrevMap[$rev] - 1]))
-        ? $revMap[$rrevMap[$rev] - 1]
-        : null;
+
+    $prev_key = array_search($rev, $fl->revs);
+    $prev = isset($fl->revs[$prev_key + 1])
+            ? $fl->revs[$prev_key + 1]
+            : null;
+
     $line = Text::htmlAllSpaces($line['line']);
     include CHORA_TEMPLATES . '/annotate/line.inc';
     ++$i;
index 36d5db5..62e391e 100644 (file)
@@ -1,7 +1,9 @@
 --------
-v2.1-cvs
+v3.0-git
 --------
 
+[mms] Move log entries in annotate screen to an AJAX request.
+[mms] Add support for git repositories.
 [jan] Add Italian translation (Fabio Pedretti <fabio.pedretti@ing.unibs.it>).
 [cjh] Allow configuring which views the file name and latest revision number
       link to (jon@spriggs.org.uk, Request #6690).
@@ -31,12 +33,6 @@ v2.1-cvs
       accessibility support.
 
 
-----------
-v2.0.3-cvs
-----------
-
-
-
 ------
 v2.0.2
 ------
diff --git a/chora/js/annotate.js b/chora/js/annotate.js
new file mode 100644 (file)
index 0000000..f0f1e8e
--- /dev/null
@@ -0,0 +1 @@
+var Chora_Annotate={showLog:function(d){var c=d.findElement("SPAN").hide(),b=c.up("TD").down("A").readAttribute("id").slice(4,-2),a=new Element("TD",{colspan:5}).insert(Chora.loading_text);c.up("TR").insert({after:new Element("TR").insert(a)});new Ajax.Updater(a,Chora.ANNOTATE_URL+b)}};document.observe("dom:loaded",function(){$$(".logdisplay").invoke("observe","click",Chora_Annotate.showLog.bindAsEventListener(Chora_Annotate))});
\ No newline at end of file
diff --git a/chora/js/src/annotate.js b/chora/js/src/annotate.js
new file mode 100644 (file)
index 0000000..c9a0f96
--- /dev/null
@@ -0,0 +1,23 @@
+/**
+ * Chora annotate.php javascript code.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ */
+
+var Chora_Annotate = {
+    showLog: function(e) {
+        var elt = e.findElement('SPAN').hide(),
+            rev = elt.up('TD').down('A').readAttribute('id').slice(4, -2),
+            newelt = new Element('TD', { colspan: 5 }).insert(Chora.loading_text);
+        elt.up('TR').insert({ after: new Element('TR').insert(newelt) });
+
+        new Ajax.Updater(newelt, Chora.ANNOTATE_URL + rev);
+    }
+};
+
+document.observe('dom:loaded', function() {
+    $$('.logdisplay').invoke('observe', 'click', Chora_Annotate.showLog.bindAsEventListener(Chora_Annotate));
+});
index 626de48..9036d2c 100644 (file)
@@ -4,6 +4,7 @@
   <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 a7d6718..42d773b 100644 (file)
@@ -6,9 +6,15 @@
     <?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>
+    <a id="rev_<?php echo htmlspecialchars($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>
+    <span class="logdisplay"><?php echo Horde::img('log.png') ?></span>
+<?php endif; ?>
+  </td>
+  <td class="rev">
+<?php if ($prev): ?>
+    <a id="prev_<?php echo htmlspecialchars($prev) . '_' . $i ?>" href="<?php echo Chora::url('annotate', $where, array('rev' => $prev)) . '#l' . $lineno ?>" title="<?php echo htmlspecialchars($prev) ?>"><?php echo htmlspecialchars($rev_ob->abbrev($prev)) ?></a>
 <?php endif; ?>
   </td>
   <td class="item<?php echo $style ?>">
index b1662bc..3615f53 100644 (file)
@@ -11,6 +11,11 @@ if (!empty($refresh_time) && ($refresh_time > 0) && !empty($refresh_url)) {
     echo "<meta http-equiv=\"refresh\" content=\"$refresh_time;url=$refresh_url\">\n";
 }
 
+if (Util::nonInputVar('js_vars')) {
+    require_once 'Horde/Serialize.php';
+    echo '<script type="text/javascript">//<![CDATA[' . "\n" .
+       'var Chora = ' . Horde_Serialize::serialize($js_vars, SERIALIZE_JSON, NLS::getCharset()) . ";\n//]]></script>\n";
+}
 Horde::includeScriptFiles();
 
 ?>
diff --git a/chora/themes/graphics/log.png b/chora/themes/graphics/log.png
new file mode 100644 (file)
index 0000000..b83aa6b
Binary files /dev/null and b/chora/themes/graphics/log.png differ
diff --git a/chora/themes/silver/graphics/log.png b/chora/themes/silver/graphics/log.png
new file mode 100644 (file)
index 0000000..b83aa6b
Binary files /dev/null and b/chora/themes/silver/graphics/log.png differ