滚动您自己的明文 Wiki(数据库内的 Wiki)
有人知道用于创建类似 wiki 的数据存储的 API(最好是 PHP,但我对任何语言都感兴趣)?
关于滚动您自己的纯文本 wiki 的任何资源怎么样? 其他纯文本 wiki 如何处理文本文件的格式?
我知道我可以使用 Markdown 或 Textile 进行格式化。 但我最感兴趣的是如何处理多用户编辑的明文存储。
我正在编写一个主要由数据库驱动的 Web 应用程序。 我希望该数据库的至少一个文本字段采用类似 wiki 的格式。 具体来说,该文本可以由多个用户编辑,并且能够回滚到任何版本。 想想 Last.FM 的 wiki/bio 部分(几乎整个网站都具有严格的结构)通过数据库(每个艺术家的这一部分除外)。
到目前为止,我将 MediaWiki 拆开并将其插入数据库的方法似乎有点矫枉过正。 我认为推出我自己的纯文本 wiki 并将此文件存储在数据库的相应文本字段中会更容易。
Anyone know of an API (php preferable but I'd be interested in any language) for creating wiki-like data storage?
How about any resources on rolling your own plaintext wiki? How do other plaintext wikis handle the format of the text file?
I understand I can use Markdown or Textile for the formatting. But what I'm most interested in is how to approach the plaintext storage of multi-user edits.
I'm writing a web application that is primarily database driven. I want at least one text field of this database to be in a wiki-like format. Specifically, this text can be edited by multiple users with the ability to roll back to any version. Think the wiki/bio section of Last.FM (almost the entire site is strictly structured by a database except for this one section per artist).
So far, my approach of taking apart MediaWiki and wedging it into a database seems like overkill. I'm thinking it would be much easier to roll my own plaintext wiki, and store this file in the database's appropriate text field.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
所以,基本上这是“如何在数据库中版本化文本信息”。
嗯,最简单的方法就是复制数据。
简而言之,创建一个保存数据“旧版本”的“版本”表,并将其链接回主表。
每当您更新原始文档时,您都会将旧文本值复制到此表中,复制用户并更改日期并更改版本。
如果您的数据库支持这些,您甚至可以在触发器中执行此操作。
此方法的缺点是它是数据的完整副本(因此,如果您有一个大文档,则版本会保持很大)。 您可以通过使用 diff(1) 和 patch(1) 之类的东西来缓解这种情况。
例如:
然后您可以将该 diff 文件存储为“版本 1”。
为了从版本 2 恢复版本 1,您需要获取版本 2 数据,使用 diff 文件数据对其运行补丁,这样您就可以得到 v1.1 版本。
如果要从 v3 转到 v1,则需要执行两次(一次获取 v2,然后再次获取 v1)。
这会减轻您的存储负担,但会增加您的处理能力(显然),因此您必须判断要如何执行此操作。
So, basically this is a "how do I version text information in my DB".
Well, the simplest way is simply copying the data.
Simply, create a "version" table that holds "old versions" of the data, and link it back to your main table.
Whenever you update your original document, you copy the old text value in to this table, copy the user and change date and bump the version.
You could even do this in a trigger if your DB supports those.
Faults with this method are that its a full copy of the data (so if you have a large document, the version stay large). You can mitigate that by using something like diff(1) and patch(1).
For example:
Then you can store that difffile as "version 1".
In order to recover version 1 from version 2, you grab the version 2 data, run patch on it using the diff file data, and that gives you v1.
If you want to go from v3 to v1, you need to do this twice (once to get v2, and then again to get v1).
This lowers your storage burden, but increases your processing (obviously), so you'll have to judge how you want to do this.
威尔的巨大答案是正确的,但我认为可以总结一下:您需要存储版本,然后您需要存储元数据(谁在什么时候存储数据)。
但你的问题是关于类似 Wiki 版本控制的资源。 我没有(好吧,一个: 威尔的回答上面)。 不过,关于Wiki的存储,我有一个。 查看来自 DokuWiki 的比较矩阵。 我知道。 您在想“我关心不同 Wiki 使用什么品牌的 DB?” 因为 DokuWiki 使用纯文本文件。 你可以打开它们,它们确实很简单。 所以这是一种方法,他们有一些有趣的论据来解释为什么 DBMS 不是最好的方法。 它们甚至不保存太多元数据:大部分内容都是通过平面文件本身完成的。
DokuWiki 对您的意义在于,也许这是一个相对简单的问题(取决于您想要解决它的程度:)
Will's huge answer is right on, but can be summed up, I think: you need to store the versions, and then you need to store the metadata (who what when of the data).
But your question was about resources on Wiki-like versioning. I have none (well, one: Will's answer above). However, about the storage of Wikis, I have one. Check out the comparison matrix from DokuWiki. I know. You're thinking "what do I care what brand of DB different Wikis use?" Because DokuWiki uses plain text files. You can open them and they are indeed plain. So that's one approach, and they've got some interesting arguments as to why DBMS are not the best way to go. They don't even hold much metadata: most of the stuff is done through the flat files themselves.
The point of the DokuWiki for you is that maybe it's a relatively simple problem (depending on how well you want to solve it :)
以下是 WikiMatrix 上所有 12 个 wiki 的列表,这些 wiki 用 PHP 编写,并使用文本文件进行存储。 也许其中一个有一种可以适应数据库的存储方法:
http://www.wikimatrix.org/search.php?sid=1760
Here's a list of all 12 wikis on WikiMatrix that are written in PHP and do their storage using text files. Perhaps one of them will have a storage method you can adapt into the database:
http://www.wikimatrix.org/search.php?sid=1760
听起来您本质上只是在寻找版本控制。 如果是这种情况,您可能需要研究 diff 算法。
这是维基百科 Diff 页面。
我做了一个快速的 php diff google 搜索,但没有什么真正突出的例子,因为我只有基本的 PHP 知识。
It sounds like you are essentially just looking for version control. If that is the case, you may want to look into a diff algorithm.
Here is the Wikipedia Diff page.
I did a quick php diff google search, but nothing really stood out as a decent example, since I only have basic PHP knowledge.