From cdbf1c25230aa4d8796ce666e194e078a15fbed6 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Wed, 7 Jan 2009 17:50:33 -0700 Subject: [PATCH] Chora updates from CVS HEAD. Mainly dealing with adding AJAX log retrieval to annotate page. --- chora/annotate.php | 41 +++++++++++++++++++++++++---------- chora/docs/CHANGES | 10 +++------ chora/js/annotate.js | 1 + chora/js/src/annotate.js | 23 ++++++++++++++++++++ chora/templates/annotate/header.inc | 1 + chora/templates/annotate/line.inc | 8 ++++++- chora/templates/common-header.inc | 5 +++++ chora/themes/graphics/log.png | Bin 0 -> 152 bytes chora/themes/silver/graphics/log.png | Bin 0 -> 152 bytes 9 files changed, 70 insertions(+), 19 deletions(-) create mode 100644 chora/js/annotate.js create mode 100644 chora/js/src/annotate.js create mode 100644 chora/themes/graphics/log.png create mode 100644 chora/themes/silver/graphics/log.png diff --git a/chora/annotate.php b/chora/annotate.php index 27ca66689..1ae747e25 100644 --- a/chora/annotate.php +++ b/chora/annotate.php @@ -10,12 +10,11 @@ */ 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 = '' . _("Author") . ': ' . Chora::showAuthorName($log->queryAuthor(), true) . '
' . + '' . _("Date") . ': ' . Chora::formatDate($log->queryDate()) . '

' . + 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('%s | %s', 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; diff --git a/chora/docs/CHANGES b/chora/docs/CHANGES index 36d5db58d..62e391e49 100644 --- a/chora/docs/CHANGES +++ b/chora/docs/CHANGES @@ -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 ). [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 index 000000000..f0f1e8e3c --- /dev/null +++ b/chora/js/annotate.js @@ -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 index 000000000..c9a0f9637 --- /dev/null +++ b/chora/js/src/annotate.js @@ -0,0 +1,23 @@ +/** + * Chora annotate.php javascript code. + * + * @author Michael Slusarz + * + * 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)); +}); diff --git a/chora/templates/annotate/header.inc b/chora/templates/annotate/header.inc index 626de4866..9036d2c4a 100644 --- a/chora/templates/annotate/header.inc +++ b/chora/templates/annotate/header.inc @@ -4,6 +4,7 @@ + diff --git a/chora/templates/annotate/line.inc b/chora/templates/annotate/line.inc index a7d671856..42d773bf3 100644 --- a/chora/templates/annotate/line.inc +++ b/chora/templates/annotate/line.inc @@ -6,9 +6,15 @@ - abbrev($rev)) ?> + abbrev($rev)) ?> "> + + + + + + abbrev($prev)) ?> diff --git a/chora/templates/common-header.inc b/chora/templates/common-header.inc index b1662bcb0..3615f53ac 100644 --- a/chora/templates/common-header.inc +++ b/chora/templates/common-header.inc @@ -11,6 +11,11 @@ if (!empty($refresh_time) && ($refresh_time > 0) && !empty($refresh_url)) { echo "\n"; } +if (Util::nonInputVar('js_vars')) { + require_once 'Horde/Serialize.php'; + echo '\n"; +} Horde::includeScriptFiles(); ?> diff --git a/chora/themes/graphics/log.png b/chora/themes/graphics/log.png new file mode 100644 index 0000000000000000000000000000000000000000..b83aa6b286aa1cff063551ed1007de6d32e6bc87 GIT binary patch literal 152 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJe}GSjE0At!X*qW6*#H0kfoz@B z6>LC?u_VYZn8D%MjWi&~+|$J|q~g}ren&0_1)jqt&;I9c3%bdtG|xvedExY}tdfUc uSexAv?N(XGbiqcdCU1@s*Pq-))l7Q*OaZHkPbC74VDNPHb6Mw<&;$UwRW5J< literal 0 HcmV?d00001 diff --git a/chora/themes/silver/graphics/log.png b/chora/themes/silver/graphics/log.png new file mode 100644 index 0000000000000000000000000000000000000000..b83aa6b286aa1cff063551ed1007de6d32e6bc87 GIT binary patch literal 152 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJe}GSjE0At!X*qW6*#H0kfoz@B z6>LC?u_VYZn8D%MjWi&~+|$J|q~g}ren&0_1)jqt&;I9c3%bdtG|xvedExY}tdfUc uSexAv?N(XGbiqcdCU1@s*Pq-))l7Q*OaZHkPbC74VDNPHb6Mw<&;$UwRW5J< literal 0 HcmV?d00001 -- 2.11.0