DanKeshet/RecentChangesCode

From Wikipedia

< DanKeshet

HomePage | Recent changes | View source | Discuss this page | Page history | Log in |

Printable version | Disclaimers | Privacy policy

The code. See DanKeshet for more detail.

--- wiki.pl     Mon Feb 12 17:50:25 2001
+++ wiki.new.pl Tue Aug 14 19:34:37 2001
@@ -438,9 +438,16 @@
 sub [[DoRc]] {
   my ($fileData, $rcline, $i, $daysago, $lastTs, $ts, $idOnly);
   my (@fullrc, $status, $old[[FileData]], $firstTs, $errorText);
+  my ($temp, $page, %pgLinks);
   my $starttime = 0;
   my $showbar = 0;
 
+  if ($page = &[[GetParam]]("page", "")) {
+    foreach $temp (&[[GetPageLinks]]($page)) {
+      $pgLinks{$temp}=1;
+    }
+  }
+
   if (&[[GetParam]]("from", 0)) {
     $starttime = &[[GetParam]]("from", 0);
     print "<h2>Updates since ", &[[TimeToText]]($starttime), "</h2>\n";
@@ -500,9 +507,11 @@
   foreach $i (@[[RcDays]]) {
     print " | "  if $showbar;
     $showbar = 1;
-    print &[[ScriptLink]]("action=rc&days=$i", "$i day" . (($i != 1)?"s":""));
+    print &[[ScriptLink]]("action=rc&days=$i" . ($page ? "&page=$page" : ""), 
+                      "$i day" . (($i != 1)?"s":""));
+
   }
-  print "<br>" . &[[ScriptLink]]("action=rc&from=$lastTs",
+  print "<br>" . &[[ScriptLink]]("action=rc&from=$lastTs" . ($page ? "&page=$page" : ""),
                              "List new changes starting from");
   print " " . &[[TimeToText]]($lastTs), "<br>\n";
 
@@ -521,6 +530,24 @@
     ($ts) = split(/$FS3/, $fullrc[$i]);
     last if ($ts >= $starttime);
   }
+  # Later consider an end-time limit (items older than X)
+  splice(@fullrc, 0, $i);  # Remove items before index $i
+
+  # If we're using page-specific RC 
+  if ($page) {
+    for ($i = 0; $i < @fullrc ; $i++) {
+      ($ts, $temp) = split(/$FS3/, $fullrc[$i]);
+      splice(@fullrc, $i, 1) unless ($pgLinks{$temp});   
+    } 
+  }
+  
+  if (! @fullrc) {
+    print "<br><strong>No updates", $page ? " on $page" : "", " since ", &[[TimeToText]]($starttime),
+          "</strong><br>\n";
+  } else {
+    print &[[GetRcHtml]](@fullrc);
+  }  
+
   if ($i == @fullrc) {
     print "<br><strong>No updates since ", &[[TimeToText]]($starttime),
           "</strong><br>\n";
@@ -811,6 +838,11 @@
   return &[[ScriptLink]]("action=editprefs", "Preferences");
 }
 
+sub [[GetPageRecentChanges]] {
+  my $page = shift;    
+  return &[[ScriptLink]]("action=rc&page=$page", "Recent Changes (Local)");
+}
+
 sub [[GetRandomLink]] {
   return &[[ScriptLink]]("action=random", "Random Page");
 }
@@ -987,6 +1019,7 @@
   }
   $bartext .= " | " . &[[GetPageLink]]("$RCName");
   $bartext .= " | " . &[[GetPrefsLink]]();
+  $bartext .= " | " . &[[GetPageRecentChanges]]($id);
   if (&[[GetParam]]("linkrandom", 0)) {
     $bartext .= " | " . &[[GetRandomLink]]();
   }
@@ -2875,20 +2908,13 @@
 
 sub [[GetFullLinkList]] {
   my ($name, $unique, $sort, $exists, $empty, $link, $search);
-  my ($pagelink, $interlink, $urllink);
   my (@found, @links, @newlinks, @pglist, %pgExists, %seen);
 
   $unique = &[[GetParam]]("unique", 1);
   $sort = &[[GetParam]]("sort", 1);
-  $pagelink = &[[GetParam]]("page", 1);
-  $interlink = &[[GetParam]]("inter", 0);
-  $urllink = &[[GetParam]]("url", 0);
   $exists = &[[GetParam]]("exists", 2);
   $empty = &[[GetParam]]("empty", 0);
   $search = &[[GetParam]]("search", "");
-  if (($interlink == 2) || ($urllink == 2)) {
-    $pagelink = 0;
-  }
 
   %pgExists = ();
   @pglist = &[[AllPagesList]]();
@@ -2901,7 +2927,7 @@
     if ($unique != 2) {
       %seen = ();
     }
-    @links = &[[GetPageLinks]]($name, $pagelink, $interlink, $urllink);
+    @links = &[[GetPageLinks]]($name);
 
     foreach $link (@links) {
       $seen{$link}++;
@@ -2932,8 +2958,16 @@
 }
 
 sub [[GetPageLinks]] {
-  my ($name, $pagelink, $interlink, $urllink) = @_;
+  my ($pagelink, $interlink, $urllink);
+  my ($name) = shift;
   my ($text, @links);
+
+  $pagelink = &[[GetParam]]("page", 1);
+  $interlink = &[[GetParam]]("inter", 0);
+  $urllink = &[[GetParam]]("url", 0);
+  if (($interlink == 2) || ($urllink == 2)) {
+    $pagelink = 0;
+  }
 
   @links = ();
   &[[OpenPage]]($name);