我还没有完全弄清楚我原来的问题的答案,但我写了一个脚本来实现类似的东西。它的主要目的是导出我所有垫子的纯文本版本并将它们存储在我的笔记本电脑上。作为副作用,它向我显示了哪些焊盘发生了变化,并让我看到了自上次导出版本以来的差异。它还显示了哪些是新创建的。
首先,在托管您的 etherpad 实例的服务器上创建以下脚本padlist.pl
:
#!/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;
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;
} }
要查看自上次获取 pad foo 以来的差异:
diff prev/foo.txt foo.txt