2010-04-02 41 views
3

步骤:令人惊叹的etherpad最近开源。在这里获取:http://code.google.com/p/etherpad。这是我在StackOverflow上了解的关于etherpad代码的第一个问题。如果你是etherpad开源社区的一部分,你可能想订阅the RSS feed for questions tagged 'etherpad',以防万一这种情况发生!查看最近编辑过的etherpads(注意开放源代码的etherpad代码的新“etherpad”标签!)

我的实际问题,它假定您已经EtherPad的在自己的服务器上安装:

首先,这里有一个查询,查看最近编辑垫:

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

或者,如果你想运行它从UNIX提示:

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

这是很方便,但实际上lastWriteTime得到更新,每次有人这么多的意见垫红外浏览器。我宁愿在实际上次编辑时对它们进行排序。有可能是一个奇怪的SQL查询涉及与另一个表,将显示实际上最后编辑时间的连接。有人知道那是什么吗?或者,你可以有一个脚本,它会在headRev发生变化时通知,但看起来并不是最干净的方式。

回答

1

我还没有完全想出我原来的问题的答案,但我写了一个脚本,实现类似的东西。 它的主要目的是导出我的所有垫的纯文本版本,并将它们存储在我的笔记本电脑上。 作为一个副作用,它显示哪些垫已经改变,并让我看到自上次导出版本以来的差异。它也显示哪些是新创建的。

首先,创建下面的脚本,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; 

然后运行下面的脚本,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; 
} } 

要看到垫FOO的差异,因为我最后一次取来:

diff prev/foo.txt foo.txt