问题
I am building a wiki-like website, and am wondering how to implement the file versioning to create articles history. I would like to be able, when someone edits a file, to be able to display which parts were edited, and to revert back to a previous file if necessary.
EDIT: Thank you for your responses. I started to go through them, and then I realized my post was not very precise. So I may add that I am using Java as a development language (Groovy through Grails to be precise). Also, the application I am building is not only a Wiki. It does plenty of other stuff but some parts should be editable by several users. So I am looking for the best candidate for that particular job.
回答1:
I would just look at how ikiwiki or gitit are implemented (Perl and Haskell, respectively) as both are able to use Git as a backend.
As to ikiwiki (I'm using it for my intranet wiki at work) it saves page sources (wiki formatting) as plain files, and after each save (or git push
from the outside) it "compiles" the site to a set of static pages. It uses make
-style approach for compiling the site though so ony the changed pages are rebuilt.
回答2:
Speaking of Git, what you need is already implemented in the forms of git blame and git checkout.
Even though you could use those commands to get the job done, you would probably be better off with libgit2 which is basically all the functionality you need, but as a library instead of executables.
回答3:
You may want to have a look at Gollum, Github's git-powered wiki engine.
来源:https://stackoverflow.com/questions/11071810/wiki-file-versioning