On 10/14/2014 08:02 PM, markus schnalke wrote:
Hoi,
in Mediawiki it's possible to insert one's name and the current
date quite easily with four tilde characters: ~~~~.
Is it possible to do this in a convenient way in Xwiki, as well?
And if so, how?
I think it should be possible by creating a macro. However, I
would appreciate if inserting the signature would be a simpler
tag than: {{sign/}}.
A macro has the disadvantage that it is evaluated every time the page is rendered,
and it will not "remember" when it has been inserted.
What you want here is something that is evaluated when the page is saved,
remembering the author / current date when saving.
To me this looks more like a use case for an Event Listener, e.g.:
http://platform.xwiki.org/xwiki/bin/view/DevGuide/WritingEventListenerTutor…
You will have to replace
docSource.setContent(docSource.content + "\n\nSome extra content...")
in the tutorial by something like:
docSource.setContent(docSource.content.replaceAll('~~~~',xcontext.user + '
' + docSource.date) )
(A nicer formatting is left as an excercise ...)
Btw, using ~~~~ as signature marker causes the problems because the tilde is already used
as the escape-character.
E.g. people using the wysiwyg-editor might get surprising results - e.g. typing in
'~~' will already result in '~~~~' in the wiki text
as the WYSIWYG editor will escape the tilde. Depending on how surprise resistant your
users are, you might want to use some other "magic placeholder".
Clemens