dongwen7187
dongwen7187
2010-12-06 01:16
浏览 27
已采纳

协作脚本 - 跟踪用户贡献

I am developing a collaboration tool in PHP and MySQL, and I wanted to ask what would be the most efficent way to do the following; say I have a block of text, that will get edited by different users. I need to record each change, and when the changed text is viewed, the text changed by particular user should be highlighted (possibly with css and/or jQuery).

I am not looking for a particular code snippet (and you can see that my question is fairly vaugue), but I was hoping to get an idea how to go around this particular problem.

As always cheers for all suggestions.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • doushou3814
    doushou3814 2010-12-06 22:01
    已采纳

    Ok so I've came up with a solution, when user submits the new text, run diff on it, and register the lines that has been changed. Those will be stored in a mysql table with user id, the string that diff returns and it's respective line number. This way I can return the original text, return the changed strings for particular user, and use regex to highlight it.

    点赞 评论
  • dsuoedtom207012191
    dsuoedtom207012191 2010-12-06 01:22

    One way to do this, if you're using git for version control, would by to use the git blame command. It'll show you, line by line, who changed what, at what time, and in what commit. Here's some documentation, and here's a gui. I prefer to run this from the command line with

    git blame path/to/filename.m
    

    If you don't use git, and want to learn a bit more, you might check out the Git Community Book.

    点赞 评论
  • doutao1282
    doutao1282 2010-12-06 02:35

    If you are going to build it from scratch, then I have an idea. You can create a table 'Event', in which you record every changes made to your document.

    The table includes 3 concepts: "modified time", "who modify" and "what changes". The "what changes" is the main problem here. In my opinion, since you are very likely need to support "revert" ability, you should save all the version of documents. So in "what changes", you only need 2 columns: "before_change_text_link" which refers to the file before changing, and "after_change_text_link" which refers to the file after changing . By that way, you can record all the changes.

    You can then highlight the changes made by different users by jQuery/css, with some comparing text procedure at server.

    点赞 评论

相关推荐