Go to the FreeLists Home Page Home Signup Help Login
 



[dokuwiki] || [Date Prev] [11-2006 Date Index] [Date Next] || [Thread Prev] [11-2006 Thread Index] [Thread Next]

[dokuwiki] Recent changes summary lines with multiple changes

  • From: "TNHarris" <telliamed@xxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Tue, 07 Nov 2006 18:50:32 -0500
When viewing recent changes, multiple edits to the same page will be
collapsed and only the most recent one shown. That's nice. But if the
last change was a minor edit, and has no summary, then all you see is
that minor edit, even if a more significant change had been made prior
to it.

This seems to me to be unfortunate. Particularly because I often notice
a small mistake shortly after editing a page, and correct it using a
minor edit. I think it would be more useful if the last major edit were
given preference to a later minor edit when the Recent Changes page is
displayed.

I've made an attempt at working this out. It's not very pretty. All I do
is overwrite the summary line, but this date and editor are still from a
different edit -- obviously misleading. I think a more useful solution
would be if, when there are multiple changes, the listing would say so
-- "(x changes since yyyy-mm-dd)". In the case of a minor edit, it shows
as it does now, but where the summary normally is, it prints the date
and summary of the last major edit. When there is only one change, it
displays as it does now.

-- tom
telliamed@xxxxxxxxxxx

-- 
http://www.fastmail.fm - A fast, anti-spam email service.

--- doku/inc/changelog.php      2006-11-02 21:32:08.000000000 -0500
+++ doku-tnh/inc/changelog.php  2006-11-02 21:51:11.000000000 -0500
@@ -98,7 +98,7 @@
 function getRecents($first,$num,$ns='',$flags=0){
   global $conf;
   $recent = array();
-  $count  = 0;
+  $seen = array();
 
   if(!$num)
     return $recent;
@@ -106,16 +106,21 @@
   // read all recent changes. (kept short)
   $lines = file($conf['changelog']);
 
-
   // handle lines
   for($i = count($lines)-1; $i >= 0; $i--){
-    $rec = _handleRecent($lines[$i], $ns, $flags);
+    $rec = _handleRecent($lines[$i], $ns, $flags, $seen);
     if($rec !== false) {
+      if($seen[$rec['id']]!==-1){
+        //summaries are nice, let's use them
+        $prev =& $recent[$seen[$rec['id']]];
+        if($prev['sum']==='') $prev['sum'] = $rec['sum'];
+        continue;
+      }
       if(--$first >= 0) continue; // skip first entries
+      $seen[$rec['id']] = count($recent);
       $recent[] = $rec;
-      $count++;
       // break when we have enough entries
-      if($count >= $num){ break; }
+      if(count($recent) >= $num) break;
     }
   }
 
@@ -131,22 +136,27 @@
  * @author Andreas Gohr <andi@xxxxxxxxxxxxxx>
  * @author Ben Coburn <btcoburn@xxxxxxxxxxxxx>
  */
-function _handleRecent($line,$ns,$flags){
-  static $seen  = array();         //caches seen pages and skip them
+function _handleRecent($line,$ns,$flags,&$seen){
+  //static $seen  = array();         //caches seen pages and skip them
   if(empty($line)) return false;   //skip empty lines
 
   // split the line into parts
   $recent = parseChangelogLine($line);
   if ($recent===false) { return false; }
 
-  // skip seen ones
-  if(isset($seen[$recent['id']])) return false;
+  // skip seen ones -- getRecents will deal with duplicates
+  // (but we don't have to duplicate all these checks)
+  if(isset($seen[$recent['id']])){
+    if($seen[$recent['id']] === -1) return false;
+    if($recent['type']==='e') return false;
+    return $recent;
+  }
 
   // skip minors
   if($recent['type']==='e' && ($flags & RECENTS_SKIP_MINORS)) return false;
 
   // remember in seen to skip additional sights
-  $seen[$recent['id']] = 1;
+  $seen[$recent['id']] = -1;
 
   // check if it's a hidden page
   if(isHiddenPage($recent['id'])) return false;
@@ -268,7 +278,7 @@
  *
  * For efficiency, the log lines are parsed and cached for later
  * calls to getRevisionInfo. Large changelog files are read
- * backwards in chunks untill the requested number of changelog
+ * backwards in chunks until the requested number of changelog
  * lines are recieved.
  *
  * @author Ben Coburn <btcoburn@xxxxxxxxxxxxx>




[ Home | Signup | Help | Login | Archives | Lists ]

All trademarks and copyrights within the FreeLists archives are owned by their respective owners.
Everything else ©2007 Avenir Technologies, LLC.