从广泛的角度来看,如何创建像 37signals 这样的写板?
我正处于 Rails 的初级阶段,想要构建类似 37Signals 写板 这样的东西,这样我就可以学习并感到“有成就” " 但不知道从哪里开始以下部分:
- 是 Markdown 格式的文本 作为原始文本存储在数据库中?
- 每个编辑/版本是否存储为原始降价 数据库中的文本?
- 最重要的是怎么做 我们找出两者的差异 或更多版本?有一套吗 算法?
I am at the beginning stages of rails and wanted to build something like 37Signals write board just so I can learn and feel "accomplished" but don't know where to begin on the following segments:
- is the markdown formatted text
stored as raw text in DB? - is each edit/version stored as raw markdown
text in DB? - most importantly how do
we find out the differences in two
or more versions? is there a set
algorithm for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
虽然我显然无法回答 37Signals 到底是如何实现的,但这是我的想法:
由于写板支持编辑以格式化形式存储 Markdown,这意味着每当有人编辑 Markdown 时,您都必须恢复将格式化的 html 转为 markdown。我非常怀疑这是否是一个好主意,尽管有人可能会争辩说,如果编辑与不编辑的比率非常小,那么将 Markdown 存储为格式化的性能优势(因为您不必将 Markdown 转换为 html)将是一个巨大的优势。您还可以选择将两个版本都存储在数据库中,或者仅将格式化版本存储在缓存中。
由于书写板可能变得相当大,您可能会存储每个版本的差异(参见 3.)以及完整的最新版本。这样,每当显示写板时,您都可以获取完整的最新版本,而不必从差异构建它,同时您可以通过不以完整形式存储每个修订来节省空间。
你可以使用diff,这是在vcs中完成的,比如svn和git , diff 为您提供两个文本文件之间的差异:更改、插入和删除了哪些字符。
While I obviously can't answer as to how exactly it's implemented at 37Signals this is my thoughts:
Since the writeboard supports editing storing the markdown in a formatted form would mean that whenever someone were to edit the markdown you would have to revert the formatted html to markdown. I highly doubt this would be a good idear though one could argue that if the edit-to-no-edit ratio is very small the performance benefits (since you don't have to transform the markdown to html) of having the markdown stored formatted would be a hugh advantage. You could also choose to have both version in the database or the formatted version in cache only.
Since writeboards can get pretty big you would probably store the diff (see 3.) of each versions along with the complete latests version. This way whenever displaying the writeboard you can take the complete latests version and you won't have to build it from diffs and at the same time you save space by not storing each revision in complete form.
You could use a diff, this is what is done in vcs' like svn and git, the diff gives you the difference between two text-files: which characters were changed, inserted and removed.