对 github 的每行注释等功能进行建模

发布于 2024-11-03 05:39:39 字数 714 浏览 1 评论 0原文

我正在构建一个系统,允许用户创建内容并编辑该内容,同时保持对所有以前版本的访问。在某种程度上,您可以考虑 StackOverflow 如何允许人们发布问题,然后编辑问题,并且仍然可以查看所有以前的版本。

但是,我的用户需要能够选择内容中的文本并向该特定文本添加评论。因此,他们可以针对内容中的特定单词或短语并向其附加评论,而不是向整个内容块添加评论(如 SO 中)。

当我显示内容 blob 时,我需要显示曾经添加到其中的所有评论,无论当前版本包含什么。因此,如果附加评论的单词或短语已被删除,我仍然需要显示该评论,尽管该评论可能以某种方式表明它未附加在当前版本中。

Github 有一项功能,允许成员向特定的源代码行添加注释。这非常接近我想要做的事情。然而,我相信在 Github 中,评论仅附加到该文件的特定版本。该文件的未来版本将不会显示该注释。

像Microsoft Word这样的软件也有这样的功能。但我的应用程序将是一个具有用户之间协作功能的网络应用程序,因此多个用户可以对任何给定内容发表评论。

我正在考虑使用 CouchDB 或 MongoDB 等 NoSQL 解决方案来存储内容和评论。另一种选择是使用 git 来维护内容 blob 和版本控制,但我不确定在哪里存储评论信息。

关于如何最好地建模和存储此类信息有什么建议吗?评论如何引用内容中的单词或短语?如何最好地知道当前版本中的文本是否附加了评论?

I'm building a system that allows users to create content and edit that content, while maintaining access to all previous versions. In a way, you could think about how StackOverflow allows people to post a question, then edit the question, and still view all previous versions.

However, my users need to be be able to select text in the content and add a comment to that particular text. So instead of adding a comment to an entire blob of content (like in SO), they can target a specific word or phrase in the content and attach a comment to it.

When I display a content blob, I need to show all comments that were ever added to it, regardless of what the current version contains. So if the word or phrase a comment was attached to has been removed, I still need to show the comment, although that comment might indicate somehow that it is not attached in the current version.

Github has a feature that allows members to add a comment to a specific line of source code. This is a fairly close approximation to what I'm wanting to do. However, I believe in Github, the comment is attached only to a specific version of that file. Future versions of that file won't show that comment.

Software like Microsoft Word has features like this too. But my application will be a webapp with collaborative features amongst users, so multiple users can comment on any given content.

I'm considering using a NoSQL solution like CouchDB or MongoDB to store the blobs of content and the comments. Another option is to use git to maintain the content blobs and versioning, but I'm unsure where I'd store the comment information.

Any suggestions on how to best model and store this type of information? How would a comment reference words or phrases in the content? How to best know when a comment is attached to text in the current version or not?

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

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

发布评论

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

评论(1

冷情 2024-11-10 05:39:39

您可以以一种方式进行建模,其中您有一个文件(或任何其他可以保存元数据的合适对象,例如在数据库中),用于用户所做的每条评论,并创建特定的命名约定,在其中组合评论的文件名被注释的文件、blob 的 SHA1 以及每个文件的多个注释的索引。因此,对于每个文件 foo,您可能会得到类似的内容:

foo-blob1-0
foo-blob1-1
foo-blob1-2
foo-blob1-3
foo-blob2-0
..
foo-blobm-0
..
foo-blobm-n

当提交文件的新修订版时,将会有一个新的 blob(或者可能会再次出现旧的 blob,因为由于添加了文件,该文件的先前版本可能是相同的)并删除文本)以便人们可以发表评论。对象显然还需要知道所评论文本的范围。

You could model in a way where you have a file (or any other suitable object that can hold meta data, e.g. in a database) for each comment made by a user, and create a certain naming convention where you combine the file name of the file being commented on, the SHA1 of the blob and an index for multiple comments on each file. So for each file foo, you could have something like:

foo-blob1-0
foo-blob1-1
foo-blob1-2
foo-blob1-3
foo-blob2-0
..
foo-blobm-0
..
foo-blobm-n

When a new revision of the file has been commited there will be a new blob (or possibly an old blob showing up again, since previous versions of the file might be identical due to add and remove of text) that people can comment on. The objects obviously also need to know the range of the text being commented on.

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