[xwiki-users] How to insert name and date (signature, ~~~~)?
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/}}. meillo
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/WritingEventListenerTutori... 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
Hi, Meillo, Interesting need. Indeed it's easy to do with a macro such as {{sign user="username"/}}. Now we also support the notion of transformations. They allow to modify what gets displayed. However the modified content is not persisted. This there are 2 choices: 1) use a syntax such as ~~~ username and have a transformation generate the correct content for it 2) use a syntax such as ~~~~ without the username and this means having to save the modified content and thus add support for persistent transformations which could be something useful in general See http://rendering.xwiki.org for more details on transformations. Thanks -Vincent PS: I’ve prepared this email offline and just saw that Clemens has also responded in the meantime so my answer doesn’t take into account what Clemens has said. On 14 Oct 2014 at 20:02:35, markus schnalke ([email protected](mailto:[email protected])) 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/}}.
meillo
[2014-10-15 10:25] Clemens Klein-Robbenhaar <[email protected]>
On 10/14/2014 08:02 PM, markus schnalke wrote:
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.
Exactly.
To me this looks more like a use case for an Event Listener, e.g.:
http://platform.xwiki.org/xwiki/bin/view/DevGuide/WritingEventListenerTutori...
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) )
Thanks. I'm sure this is how it could be done. However, in the meantime, I think that using the annotation plugin/application might be the more XWiki-like way to go -- although less familiar to me it might actually be more familiar to most of the users of our wiki. Thanks for your help! meillo
Hi Markus, FTR I’ve created http://jira.xwiki.org/browse/XRENDERING-371 Thanks -Vincent On 14 Oct 2014 at 20:02:35, markus schnalke ([email protected](mailto:[email protected])) 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/}}.
meillo
participants (3)
-
Clemens Klein-Robbenhaar -
markus schnalke -
vincent@massol.net