查看最近编辑etherpads(注意,开源代码EtherPad的新“EtherPad的”标签!)
-
24-09-2019 - |
题
规定的:该惊人 EtherPad的最近开源。在这里获得: http://code.google.com/p/etherpad 。这是第一个问题,我知道StackOverflow上关于EtherPad的代码。如果你的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的变动,但似乎并不像做最彻底的方法。
解决方案
我还没有完全想通了,回答我原来的问题,但我写了实现类似的脚本。 它的主要目的是导出所有我垫的纯文本版本,并将它们存储在我的笔记本电脑。 作为一个副作用,它让我看到这片已经改变,让我看到自上次出口版本差异。 它还哪些被新创建的节目。
首先,创建下面的脚本,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自上次我拿来它:
diff prev/foo.txt foo.txt
不隶属于 StackOverflow