I am writing a Web application that has a user interface for editing documents. What is the best way to implement a history feature like Wikipedia’s where edits to a document can be viewed?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well you will have to store the current document and archive changes to compare. Typically the main document is the one in the database then older versions on save are saved to another archive database or service.
Then you can pull the latest and the latest archived version and compare it with a diff algorithm.
Python has a diff algorithm tool difflib: http://docs.python.org/library/difflib.html
Also a directory and file compare tool: http://docs.python.org/library/filecmp.html#module-filecmp
Many other languages also have diff algorithm implementations.
You can just store the deltas on change and recreate like a Berkley DB like Subversion but I recommend for simplicity just save a copy of the content then compare each of the latest, or the ones the user selects.