Difference Engine Refactoring and Improvements
I have the need to show a better diff page for a page containing an object. Since there is no generic diff for objects, I'd like to write a Diff plugin allowing to make a nice diff of any two strings passed. At the same time I'd like to start a refactoring of the current diff in the same plugin. Currently I see the following APIs: DiffPlugin // returns a list of org.suigeneris.jrcs.diff.Delta (which representd differences) getLineDiffAsList(String content1, String content2) // returns a list of org.suigeneris.jrcs.diff.Delta (which representd differences) getWordDiffAsList(String content1, String content2) // returns an HTML view of differences getLineDiffAsList(String content1, String content2) // returns an HTML view of differences getWordDiffAsList(String content1, String content2) // returns an Text view of differences getLineDiffAsList(String content1, String content2) // returns an Text view of differences getWordDiffAsList(String content1, String content2) Other APIs could be a function to get a complete diff of an XWikiDocument (includes objects, attachements), however the implementation itself should probably reside in an velocity template. There is an interesting discussion to have about how the representation of the Text and HTML views should be. Any ideas ? Another question is wether it is a good idea to put this as a plugin. I think yes since it could be use for other things than the wiki content. Ludovic -- Ludovic Dubost Blog: http://www.ludovic.org/blog/ XWiki: http://www.xwiki.com Skype: ldubost GTalk: ldubost AIM: nvludo Yahoo: ludovic
On May 1, 2007, at 3:22 PM, Ludovic Dubost wrote:
I have the need to show a better diff page for a page containing an object.
Yes I agree we really need this. Personally I'd like to set up the email plugin on xwiki.org and send the diff of the modifications to the dev list whenever someone makes a change.
Since there is no generic diff for objects, I'd like to write a Diff plugin allowing to make a nice diff of any two strings passed.
Are you talking about Object diffs or String diffs here? Or do you mean XML diff? I think we have 2 options: - Diff of Objects: Difference getDifferences(Object o1, Object o2). I guess the diff could then be the difference of object fields. This would need to be implemented for each XWiki Object. - XML difference. This is the XML representation of XWiki Objects. I don't think there are any good/simple XML diff frameworks so we would also need to implement that. I think it's better to do an Object diff as otherwise the xml diff would need to be transformed to be presented to the user and this will require extra parsing. Better to operate on Object as we already have them in our java code.
At the same time I'd like to start a refactoring of the current diff in the same plugin.
Currently I see the following APIs:
DiffPlugin // returns a list of org.suigeneris.jrcs.diff.Delta (which representd differences) getLineDiffAsList(String content1, String content2) // returns a list of org.suigeneris.jrcs.diff.Delta (which representd differences) getWordDiffAsList(String content1, String content2)
// returns an HTML view of differences getLineDiffAsList(String content1, String content2) // returns an HTML view of differences getWordDiffAsList(String content1, String content2)
// returns an Text view of differences getLineDiffAsList(String content1, String content2) // returns an Text view of differences getWordDiffAsList(String content1, String content2)
I don't understand. I would have used something like: List<Difference> getDifferences(XWikiDocument, XWikiDocument) List<Difference> getDifferences(XObject, XObject) List<Difference> getDifferences(String, String) Also, I think it's critical that in an API we should only use our own classes/interfaces and no external ones, so I think we should have our own Difference class and not use JRCS'. It could possibly wrap it if necessary.
Other APIs could be a function to get a complete diff of an XWikiDocument (includes objects, attachements), however the implementation itself should probably reside in an velocity template.
The implementation of a document difference should in the plugin I think. The plugin should only do backend stuff though and return a list of named differences. I agree it would be up to the vm files to do the presentation of it (be if for the wiki, for an email to be sent, etc).
There is an interesting discussion to have about how the representation of the Text and HTML views should be.
Yes, that's hard. I'd like to see a wiki markup diff in addition to the current HTML diff we have as I find our current diff not very good. I think we need both.
Any ideas ?
Another question is wether it is a good idea to put this as a plugin. I think yes since it could be use for other things than the wiki content.
A plugin would be good I think as it means the implementation becomes pluggable. In the future it would be transformed into a component but that's the same idea. Thanks -Vincent
Hi, Vincent Massol a écrit :
On May 1, 2007, at 3:22 PM, Ludovic Dubost wrote:
I have the need to show a better diff page for a page containing an object.
Yes I agree we really need this. Personally I'd like to set up the email plugin on xwiki.org and send the diff of the modifications to the dev list whenever someone makes a change.
Yes.. that's where the DiffAsText is usefull or DiffAsHTML when sending the email as HTML
Since there is no generic diff for objects, I'd like to write a Diff plugin allowing to make a nice diff of any two strings passed.
Are you talking about Object diffs or String diffs here? Or do you mean XML diff?
I think we have 2 options: - Diff of Objects: Difference getDifferences(Object o1, Object o2). I guess the diff could then be the difference of object fields. This would need to be implemented for each XWiki Object. - XML difference. This is the XML representation of XWiki Objects. I don't think there are any good/simple XML diff frameworks so we would also need to implement that.
I think it's better to do an Object diff as otherwise the xml diff would need to be transformed to be presented to the user and this will require extra parsing. Better to operate on Object as we already have them in our java code.
I'm talking about Object Diff.. We already have a diff of objects but it was not differentiating the text inside the fields. Now it is doing this..
At the same time I'd like to start a refactoring of the current diff in the same plugin.
Currently I see the following APIs:
DiffPlugin // returns a list of org.suigeneris.jrcs.diff.Delta (which representd differences) getLineDiffAsList(String content1, String content2) // returns a list of org.suigeneris.jrcs.diff.Delta (which representd differences) getWordDiffAsList(String content1, String content2)
// returns an HTML view of differences getLineDiffAsList(String content1, String content2) // returns an HTML view of differences getWordDiffAsList(String content1, String content2)
// returns an Text view of differences getLineDiffAsList(String content1, String content2) // returns an Text view of differences getWordDiffAsList(String content1, String content2)
I don't understand. I would have used something like:
List<Difference> getDifferences(XWikiDocument, XWikiDocument) List<Difference> getDifferences(XObject, XObject) List<Difference> getDifferences(String, String)
Ok.. I can look at changing these APIs. However the return of getDifferences(XWikiDocument,XWikiDocument) or getDifferences(XObject, XObject) can be quite complex in terms of Java structure. Currently we have similar functions in XWikiDocument (getObjectDiff, getMetaDataDiff, getContentDiff). I'm not completely sure we should move them to the DiffPlugin. I have a first prototype of the DiffPlugin (with only strings API) and with that I was able to do a complete diff page for a document (including Objects and MetaData) Check http://jira.xwiki.org/jira/browse/XWIKI-1162 for the DiffPlugin patch..
Also, I think it's critical that in an API we should only use our own classes/interfaces and no external ones, so I think we should have our own Difference class and not use JRCS'. It could possibly wrap it if necessary.
The wrapping would require quite a lot of cloning work. The result of the JRCS engine is a Delta object which contains a list of Chunks which contains a list of Strings. These objects are quite plain. I would not see what to do except completely cloning them and write a copy function from JRCS to XWiki.
Other APIs could be a function to get a complete diff of an XWikiDocument (includes objects, attachements), however the implementation itself should probably reside in an velocity template.
The implementation of a document difference should in the plugin I think. The plugin should only do backend stuff though and return a list of named differences. I agree it would be up to the vm files to do the presentation of it (be if for the wiki, for an email to be sent, etc).
Ok.. That will deprecate a few functions in XWikiDocument. So the plugin functions should set a few objects un the context representing the diff. The template would then present these different diffs in a nice way.
There is an interesting discussion to have about how the representation of the Text and HTML views should be.
Yes, that's hard. I'd like to see a wiki markup diff in addition to the current HTML diff we have as I find our current diff not very good. I think we need both.
I don't think you understood exactly what I mean by Text and HTML view. They are both Wiki markup diff but rendered in Text or HTML. A HTML-Diff is more complex as there are risks of failing to generate a valid markup. I think we should stick to Wiki Markup diff. Ludovic
Any ideas ?
Another question is wether it is a good idea to put this as a plugin. I think yes since it could be use for other things than the wiki content.
A plugin would be good I think as it means the implementation becomes pluggable. In the future it would be transformed into a component but that's the same idea.
Thanks -Vincent
------------------------------------------------------------------------
-- You receive this message as a subscriber of the [email protected] mailing list. To unsubscribe: mailto:[email protected] For general help: mailto:[email protected]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
-- Ludovic Dubost Blog: http://www.ludovic.org/blog/ XWiki: http://www.xwiki.com Skype: ldubost GTalk: ldubost AIM: nvludo Yahoo: ludovic
On May 2, 2007, at 10:13 AM, Ludovic Dubost wrote: [snip]
Since there is no generic diff for objects, I'd like to write a Diff plugin allowing to make a nice diff of any two strings passed.
Are you talking about Object diffs or String diffs here? Or do you mean XML diff?
I think we have 2 options: - Diff of Objects: Difference getDifferences(Object o1, Object o2). I guess the diff could then be the difference of object fields. This would need to be implemented for each XWiki Object. - XML difference. This is the XML representation of XWiki Objects. I don't think there are any good/simple XML diff frameworks so we would also need to implement that.
I think it's better to do an Object diff as otherwise the xml diff would need to be transformed to be presented to the user and this will require extra parsing. Better to operate on Object as we already have them in our java code. I'm talking about Object Diff.. We already have a diff of objects but it was not differentiating the text inside the fields. Now it is doing this..
ok we're in line then. I thought you were talking about some text diff because the api belows only takes strings.
At the same time I'd like to start a refactoring of the current diff in the same plugin.
Currently I see the following APIs:
DiffPlugin // returns a list of org.suigeneris.jrcs.diff.Delta (which representd differences) getLineDiffAsList(String content1, String content2) // returns a list of org.suigeneris.jrcs.diff.Delta (which representd differences) getWordDiffAsList(String content1, String content2)
// returns an HTML view of differences getLineDiffAsList(String content1, String content2) // returns an HTML view of differences getWordDiffAsList(String content1, String content2)
// returns an Text view of differences getLineDiffAsList(String content1, String content2) // returns an Text view of differences getWordDiffAsList(String content1, String content2)
I don't understand. I would have used something like:
List<Difference> getDifferences(XWikiDocument, XWikiDocument) List<Difference> getDifferences(XObject, XObject) List<Difference> getDifferences(String, String)
Ok.. I can look at changing these APIs. However the return of getDifferences(XWikiDocument,XWikiDocument) or getDifferences (XObject, XObject) can be quite complex in terms of Java structure.
Without thinking a lot about it, I would see something like this for the Difference object: - Context information (String). This would be the property for example when comparing 2 objects. It could be "page" when comparing the content of a page, etc. - Old value (String). - New value (String). - Location: some information where the change appears, possibly also the text surrounding the difference, etc I think we need both StringDifference and ObjectDifference which both implement Difference, so getDifferences(XWikiDocument, XWikiDocument) would return a list of both, getDifferences(XObject, XObject) would return a list of ObjectDifference and getDifferences(String, String) a list of StringDifference.
Currently we have similar functions in XWikiDocument (getObjectDiff, getMetaDataDiff, getContentDiff). I'm not completely sure we should move them to the DiffPlugin.
I have a first prototype of the DiffPlugin (with only strings API) and with that I was able to do a complete diff page for a document (including Objects and MetaData)
Check http://jira.xwiki.org/jira/browse/XWIKI-1162 for the DiffPlugin patch..
I will... I'm trying to focus on the WYSIWYG editor today and the RC4 release but I'll try to find some time.
Also, I think it's critical that in an API we should only use our own classes/interfaces and no external ones, so I think we should have our own Difference class and not use JRCS'. It could possibly wrap it if necessary.
The wrapping would require quite a lot of cloning work. The result of the JRCS engine is a Delta object which contains a list of Chunks which contains a list of Strings. These objects are quite plain. I would not see what to do except completely cloning them and write a copy function from JRCS to XWiki.
What about the Difference object as summarily described above? If internally we have JRCS objects, we could always construct our own Difference object, no? I think it's really much safer from an API point of view as we're not convinced we'll stay with JRCS I think. Also (and even more importantly) the interface is meant so that someone else can implement a different diff algorithm. I'm not sure it would be good to force them to use JRCS objects, especially as we don't control JRCS.
Other APIs could be a function to get a complete diff of an XWikiDocument (includes objects, attachements), however the implementation itself should probably reside in an velocity template.
The implementation of a document difference should in the plugin I think. The plugin should only do backend stuff though and return a list of named differences. I agree it would be up to the vm files to do the presentation of it (be if for the wiki, for an email to be sent, etc).
Ok.. That will deprecate a few functions in XWikiDocument. So the plugin functions should set a few objects un the context representing the diff. The template would then present these different diffs in a nice way.
I haven't looked at the current API. I guess we could keep a XWikiDocument getDifferences(XWikiDocument) api in XWikiDocument. It would use the Diff plugin.
There is an interesting discussion to have about how the representation of the Text and HTML views should be.
Yes, that's hard. I'd like to see a wiki markup diff in addition to the current HTML diff we have as I find our current diff not very good. I think we need both.
I don't think you understood exactly what I mean by Text and HTML view. They are both Wiki markup diff but rendered in Text or HTML. A HTML-Diff is more complex as there are risks of failing to generate a valid markup. I think we should stick to Wiki Markup diff.
We're talking about the same thing. I also prefer a wiki markup diff. I was under the impression that the current diff representation was a rendered version of the textual diff. -Vincent
Any ideas ?
Another question is wether it is a good idea to put this as a plugin. I think yes since it could be use for other things than the wiki content.
A plugin would be good I think as it means the implementation becomes pluggable. In the future it would be transformed into a component but that's the same idea.
Thanks -Vincent
Vincent Massol a écrit :
On May 2, 2007, at 10:13 AM, Ludovic Dubost wrote:
[snip]
I don't understand. I would have used something like:
List<Difference> getDifferences(XWikiDocument, XWikiDocument) List<Difference> getDifferences(XObject, XObject) List<Difference> getDifferences(String, String)
Ok.. I can look at changing these APIs. However the return of getDifferences(XWikiDocument,XWikiDocument) or getDifferences(XObject, XObject) can be quite complex in terms of Java structure.
Without thinking a lot about it, I would see something like this for the Difference object:
- Context information (String). This would be the property for example when comparing 2 objects. It could be "page" when comparing the content of a page, etc. - Old value (String). - New value (String). - Location: some information where the change appears, possibly also the text surrounding the difference, etc
I think we need both StringDifference and ObjectDifference which both implement Difference, so getDifferences(XWikiDocument, XWikiDocument) would return a list of both, getDifferences(XObject, XObject) would return a list of ObjectDifference and getDifferences(String, String) a list of StringDifference.
We already have a glimpse of this in the current code public class ObjectDiff extends Object public class MetaDataDiff extends Object and we have some function which construct a JRCS Delta object with 2 strings.. I don't think we necessarly need more than that because which you seem to ask would move presentation decisions inside the APIs or would make the API results more complex than actually needed. We could still do it with the current APIs. We could add a ContentDiff object and implement a Diff interface for all three objects This interface would have a function to return a "presented" diff for Objects, MetaData and Content. All three would rely on a velocity template for the presentation (diffcontent.vm diffmetadata.vm diffobject.vm) This would simplify the default changes page which would only call the 3 diffs with the parameters.. The ContentDiff object could have some constructors to decide wether the Diff is Wiki or Rendered, if it's showing changes only or the whole document..
Also, I think it's critical that in an API we should only use our own classes/interfaces and no external ones, so I think we should have our own Difference class and not use JRCS'. It could possibly wrap it if necessary.
The wrapping would require quite a lot of cloning work. The result of the JRCS engine is a Delta object which contains a list of Chunks which contains a list of Strings. These objects are quite plain. I would not see what to do except completely cloning them and write a copy function from JRCS to XWiki.
What about the Difference object as summarily described above? If internally we have JRCS objects, we could always construct our own Difference object, no? I think it's really much safer from an API point of view as we're not convinced we'll stay with JRCS I think. Also (and even more importantly) the interface is meant so that someone else can implement a different diff algorithm. I'm not sure it would be good to force them to use JRCS objects, especially as we don't control JRCS. What the JRCS objects contain we need to make a great diff presentation.. The object is not that simple and I don't see how it would be different.. It's only good for a text diff.
I haven't looked at the current API. I guess we could keep a XWikiDocument getDifferences(XWikiDocument) api in XWikiDocument. It would use the Diff plugin.
I'm not sure what to do with the current APIs in XWikiDocument. Some are still useful but could be moved to the DiffPlugin. Some would now be hidden as private methods in the DiffPlugin..
We're talking about the same thing. I also prefer a wiki markup diff. I was under the impression that the current diff representation was a rendered version of the textual diff.
Yes currently it's the case. I think it can often break display. There are URL params to change the behavior.. In the new skin they are no links anymore to switch to wiki view for example. Ludovic -- Ludovic Dubost Blog: http://www.ludovic.org/blog/ XWiki: http://www.xwiki.com Skype: ldubost GTalk: ldubost AIM: nvludo Yahoo: ludovic
participants (2)
-
Ludovic Dubost -
Vincent Massol