查看最近编辑的 etherpad

发布于 2024-08-28 01:44:22 字数 972 浏览 6 评论 0原文

Prescript:令人惊叹的 etherpad 最近开源了。在此获取:http://code.google.com/p/etherpad。这是我在 StackOverflow 上了解到的关于 etherpad 代码的第一个问题。如果您是 etherpad 开源社区的一员,您可能需要订阅标记为“etherpad”的问题的 RSS 提要< /a> 以防万一这种情况流行起来!

我的实际问题,假设您在自己的服务器上安装了 etherpad:

首先,这是一个查看最近编辑的 pad 的查询:

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"

这很方便,但是每次有人在浏览器中查看 pad 时,lastWriteTime 实际上都会更新。我宁愿按上次实际编辑的时间对垫进行排序。可能有一个奇特的 SQL 查询涉及与另一个表的联接,该表将显示实际的上次编辑时间。有谁知道那是什么?或者,您可以有一个脚本来通知 headRev 何时发生变化,但这似乎不是最干净的方法。

Prescript: The amazing etherpad was recently open sourced. Get it here: http://code.google.com/p/etherpad. This is the first question that I know of on StackOverflow about the etherpad code. If you're part of the etherpad open source community, you might want to subscribe to the RSS feed for questions tagged 'etherpad' just in case this catches on!

My actual question, which assumes you have etherpad installed on your own server:

First, here's a query to view recently edited pads:

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"

That's handy, however lastWriteTime actually gets updated every time someone so much as views a pad in their browser. I'd rather sort the pads by when they were actually last edited. There's probably a fancy SQL query involving a join with another table that would show actual last edit time. Does anyone know what that is? Alternatively, you could have a script that notices when headRev changes but that doesn't seem like the cleanest way to do it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦在深巷 2024-09-04 01:44:22

我还没有完全弄清楚原来问题的答案,但我编写了一个实现类似功能的脚本。
它的主要目的是导出我所有平板的纯文本版本并将它们存储在我的笔记本电脑上。
作为副作用,它会向我显示哪些焊盘已更改,并让我看到自上次导出版本以来的差异。
它还显示哪些是新创建的。

首先,在托管 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

I haven't quite figured out the answer to my original question but I wrote a script that achieves something similar.
It's main purpose is to export plain text versions of all my pads and store them on my laptop.
As a side effect it shows me which pads have changed and lets me see a diff since the last exported version.
It also shows which ones were newly created.

First, create the following script, padlist.pl, on the server that hosts your etherpad instance:

#!/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;

Then run the following script, fetchall.pl, on your local machine.
It will suck down snapshots of all your pads and tell you which ones have changed and which have newly appeared.

#!/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;
} }

To see a diff of pad foo since the last time I fetched it:

diff prev/foo.txt foo.txt
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文