View recently edited electronic folders (note the new "etherpad" tag for open etherpad code)!

Prescript: the awesome etherpad was recently opened. Get it here: http://code.google.com/p/etherpad . This is the first question I know about StackOverflow about etherpad code. If you are part of the etherpad open source community, you can subscribe to the RSS feed for questions tagged with "etherpad" just in case it catches! I>

My actual question is assuming etherpad is installed on your own server:

Firstly, here is a request to view recently edited folders:

SELECT id,lastWriteTime,creationTime,headRev 
  FROM PAD_SQLMETA ORDER BY lastWriteTime, headRev;

Or, if you want to run it from a unix prompt:

mysql -u root -pPASSWD etherpad -e "select id,lastWriteTime,creationTime,headRev 
  from PAD_SQLMETA order by lastWriteTime, headRev"

This is convenient, but lastWriteTimeit is actually updated every time someone views a notebook in their browser in the same way. I would prefer to sort the pillows when they were last edited. There is probably a fantastic SQL query that includes joining with another table that will show the actual time of the last edit. Does anyone know what this is? Alternatively, you can have a script that notices when headRev changes, but this doesn't seem like the cleanest way to do this.

+3
source share
1 answer

, script, - . - . , , diff . , .

script, padlist.pl , etherpad:

#!/usr/bin/env perl

$list = `mysql -u root -pPASSWD etherpad -e 
         "select id from PAD_SQLMETA order by lastWriteTime DESC, headRev DESC"`;

$list =~ s/^id\s*\n//s;  # get rid of the column header mysql adds.
print $list;

script, fetchall.pl . , .

#!/usr/bin/env perl

use LWP::Simple qw(get);
$| = 1;  # autoflush.
$server = "server.com"; # the server that hosts your etherpad instance.

$pads = `ssh $server etherpad/padlist.pl`;
@padlist = split(/\s+/, $pads);

$neednewline = 0; # printing "." for each pad where nothing to be done.
for(@padlist) {
  $ep = $_;
  $localfile = "$ep.txt";
  if(-e $localfile) { 
    $localexists = 1; 
    $localcontent = do {local (@ARGV,$/) = $localfile; <>};
  } else { $localexists = 0; }
  $livecontent = get("http://$server/ep/pad/export/$ep/latest?format=txt");
  if($livecontent ne $localcontent) {
    if($neednewline) { print "\n";  $neednewline = 0; }
    if($localexists) { 
      print "CHANGED: $ep\n"; 
      open(F, ">prev/$localfile") or die "Probably need to create 'prev' dir.";
      print F $localcontent;
      close(F);
    } else { print "NEW:     $ep\n"; }
    open(F, ">$localfile") or die;
    print F $livecontent;
    close(F);
  } else {
    print ".";
    $neednewline = 1;
} }

diff pad foo ,

diff prev/foo.txt foo.txt
+1

Source: https://habr.com/ru/post/1739646/


All Articles