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 xwiki-dev(a)objectweb.org mailing list.
To unsubscribe: mailto:xwiki-dev-unsubscribe@objectweb.org
For general help: mailto:sympa@objectweb.org?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