Vladimir Konrad wrote:
Hello,
I just started to use xwiki (and I am quite new to wikis but understand
their basic concepts), and in the process, developed a bit of code which
I would like to share (add to the code snippets on the xwiki).
I have a user account on the
xwiki.org and can log in.
Every time I use the "Add Snippet" button, it opens the form to name
the page (which I fill in), then there is a form with large window where
I suppose the programming code is to go (this large window
ends with {/pre}).
But, every time I put the code into the form (even starting it with
{pre}), the code never shows in the preview (it is a velocity code
snippet BTW).
So the question is, would you please explain to me how am I supposed to
add the code snippet to xwiki.org? Pointers to documentation welcome.
Kind regards,
Vlad
PS: This is obviously a combination of me being a beginner at
xwiki and not understanding what stuff is expected of me where,
when adding the code snippet.
Inside XWiki all code is real code and gets executed, unless you
specifically prevent it from being executed.
Code snippets normally go inside a {code} macro, like this:
{code}
#set($var = 1)
{code}
This will prevent the code from being executed, and it will place it
inside a box that highlights code snippets.
Another way is to escape special characters one by one, as in:
\#set(\$var = 1)
This will also prevent the code from being executed, but it will simply
display it inline, as normal text.
About snippets on
code.xwiki.org, the large textarea is not just for the
code, but as the full document content. If you look at other snippets,
you will see that they have quite a lot of prose around the code,
explaining how it works and what it does. The same should be true for
your snippets: document it so that it is really useful. Then put the
code inside {code} blocks.
Thanks for using and contributing to XWiki, and happy usage.
--
Sergiu Dumitriu
http://purl.org/net/sergiu/