[xwiki-users] Writing JS with Velocity
Another newbie question, I'm afraid. I have a simple Glossary application that I've written, and I've managed to figure out how to write a velocity script to retrieve all of the glossary terms and put them into a JSON array. The problem is, the velocity script output is being html encoded and sent to the browser as text, including the enclosing <script> blocks. If I wrap the whole thing in {{html}} macro calls, the velocity script doesn't run. If I just enclose the <script> opening and closing tags in their own {{html}} macro call, the calls fail. What am I missing here? How do I get velocity script to render as HTML/JS? Yours, David Baltusavich ------------------------------ <http://www.synatree.com> 1001 State Street, Suite 1123 Erie, PA 16501 (814) 422-5887 (321) 800-8733
Add ?xpage=plain&outputSyntax=plain to your URL Envoyé de mon iPhone Le 25 juil. 2012 à 00:06, David Baltusavich <[email protected]> a écrit :
Another newbie question, I'm afraid.
I have a simple Glossary application that I've written, and I've managed to figure out how to write a velocity script to retrieve all of the glossary terms and put them into a JSON array. The problem is, the velocity script output is being html encoded and sent to the browser as text, including the enclosing <script> blocks. If I wrap the whole thing in {{html}} macro calls, the velocity script doesn't run. If I just enclose the <script> opening and closing tags in their own {{html}} macro call, the calls fail.
What am I missing here? How do I get velocity script to render as HTML/JS?
Yours,
David Baltusavich ------------------------------
<http://www.synatree.com> 1001 State Street, Suite 1123 Erie, PA 16501 (814) 422-5887 (321) 800-8733 _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
Ok, that works great. So I'm hoping to wire up this Glossary App plus the JSON to a highlighting script written in JS, the idea is that the words that appear in the glossary will be highlighted on any wiki page in which they appear. Not knowing much about velocity at all, I figured this could be implemented by parsing the body of the wiki content in search of any matching words/phrases, and mark them up with <abbr> tags, tooltips, etc. In order for this to work I need to be able to add some custom JS to each page on the wiki, which I am guessing I can do by modifying the skin, and using your helpful link trick to load the latest JSON into my highlighting script. Ludovic, since you are obviously intimately familiar with XWiki, is there a better (server-side) way to achieve a glossary or acronym database functionality? Again I'm looking to dynamically add links to existing wiki content based on a set of words and definitions that appear in an XWiki app. If not, the JS method should work fine but of course the parse operation has to happen on every page load, which is inefficient. Yours, David Baltusavich ------------------------------ <http://www.synatree.com> 1001 State Street, Suite 1123 Erie, PA 16501 (814) 422-5887 (321) 800-8733 On Tue, Jul 24, 2012 at 7:15 PM, Ludovic Dubost <[email protected]> wrote:
Add ?xpage=plain&outputSyntax=plain to your URL
Envoyé de mon iPhone
Le 25 juil. 2012 à 00:06, David Baltusavich <[email protected]> a écrit :
Another newbie question, I'm afraid.
I have a simple Glossary application that I've written, and I've managed to figure out how to write a velocity script to retrieve all of the glossary terms and put them into a JSON array. The problem is, the velocity script output is being html encoded and sent to the browser as text, including the enclosing <script> blocks. If I wrap the whole thing in {{html}} macro calls, the velocity script doesn't run. If I just enclose the <script> opening and closing tags in their own {{html}} macro call, the calls fail.
What am I missing here? How do I get velocity script to render as HTML/JS?
Yours,
David Baltusavich ------------------------------
<http://www.synatree.com> 1001 State Street, Suite 1123 Erie, PA 16501 (814) 422-5887 (321) 800-8733 _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
David, have you looked at JSX? I do not know it well but I think that's an easier way to do thing than modifying the skin. I believe you can embed additional JS for a page or for the pages of a space by adding particular objects to pages. paul Le 25 juil. 2012 à 05:54, David Baltusavich a écrit :
Ok, that works great.
So I'm hoping to wire up this Glossary App plus the JSON to a highlighting script written in JS, the idea is that the words that appear in the glossary will be highlighted on any wiki page in which they appear. Not knowing much about velocity at all, I figured this could be implemented by parsing the body of the wiki content in search of any matching words/phrases, and mark them up with <abbr> tags, tooltips, etc. In order for this to work I need to be able to add some custom JS to each page on the wiki, which I am guessing I can do by modifying the skin, and using your helpful link trick to load the latest JSON into my highlighting script.
Ludovic, since you are obviously intimately familiar with XWiki, is there a better (server-side) way to achieve a glossary or acronym database functionality? Again I'm looking to dynamically add links to existing wiki content based on a set of words and definitions that appear in an XWiki app.
If not, the JS method should work fine but of course the parse operation has to happen on every page load, which is inefficient.
Yours,
David Baltusavich ------------------------------
<http://www.synatree.com> 1001 State Street, Suite 1123 Erie, PA 16501 (814) 422-5887 (321) 800-8733
On Tue, Jul 24, 2012 at 7:15 PM, Ludovic Dubost <[email protected]> wrote:
Add ?xpage=plain&outputSyntax=plain to your URL
Envoyé de mon iPhone
Le 25 juil. 2012 à 00:06, David Baltusavich <[email protected]> a écrit :
Another newbie question, I'm afraid.
I have a simple Glossary application that I've written, and I've managed to figure out how to write a velocity script to retrieve all of the glossary terms and put them into a JSON array. The problem is, the velocity script output is being html encoded and sent to the browser as text, including the enclosing <script> blocks. If I wrap the whole thing in {{html}} macro calls, the velocity script doesn't run. If I just enclose the <script> opening and closing tags in their own {{html}} macro call, the calls fail.
What am I missing here? How do I get velocity script to render as HTML/JS?
Yours,
David Baltusavich ------------------------------
<http://www.synatree.com> 1001 State Street, Suite 1123 Erie, PA 16501 (814) 422-5887 (321) 800-8733 _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
2012/7/25 David Baltusavich <[email protected]>:
Ok, that works great.
So I'm hoping to wire up this Glossary App plus the JSON to a highlighting script written in JS, the idea is that the words that appear in the glossary will be highlighted on any wiki page in which they appear. Not knowing much about velocity at all, I figured this could be implemented by parsing the body of the wiki content in search of any matching words/phrases, and mark them up with <abbr> tags, tooltips, etc. In order for this to work I need to be able to add some custom JS to each page on the wiki, which I am guessing I can do by modifying the skin, and using your helpful link trick to load the latest JSON into my highlighting script.
In fact we have already this on a project, but we could not get to fully publish it as an extension. The way it was done was to generate the annotations on the server side with a script at night. This is quite easy to do as you just need to update the annotations (which are comments in recent versions) in XWIki Objects At some point this code should be published but I cannot tell when. This was found to be much more efficient than to do it in real time in JS If you want to go the JS way, use JSX
Ludovic, since you are obviously intimately familiar with XWiki, is there a better (server-side) way to achieve a glossary or acronym database functionality? Again I'm looking to dynamically add links to existing wiki content based on a set of words and definitions that appear in an XWiki app.
If not, the JS method should work fine but of course the parse operation has to happen on every page load, which is inefficient.
Yours,
David Baltusavich ------------------------------
<http://www.synatree.com> 1001 State Street, Suite 1123 Erie, PA 16501 (814) 422-5887 (321) 800-8733
On Tue, Jul 24, 2012 at 7:15 PM, Ludovic Dubost <[email protected]> wrote:
Add ?xpage=plain&outputSyntax=plain to your URL
Envoyé de mon iPhone
Le 25 juil. 2012 à 00:06, David Baltusavich <[email protected]> a écrit :
Another newbie question, I'm afraid.
I have a simple Glossary application that I've written, and I've managed to figure out how to write a velocity script to retrieve all of the glossary terms and put them into a JSON array. The problem is, the velocity script output is being html encoded and sent to the browser as text, including the enclosing <script> blocks. If I wrap the whole thing in {{html}} macro calls, the velocity script doesn't run. If I just enclose the <script> opening and closing tags in their own {{html}} macro call, the calls fail.
What am I missing here? How do I get velocity script to render as HTML/JS?
Yours,
David Baltusavich ------------------------------
<http://www.synatree.com> 1001 State Street, Suite 1123 Erie, PA 16501 (814) 422-5887 (321) 800-8733 _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Ludovic Dubost Founder and CEO Blog: http://blog.ludovic.org/ XWiki: http://www.xwiki.com Skype: ldubost GTalk: ldubost
Thanks for the lead on JSX, I'll take a look at that. Yours, David Baltusavich ------------------------------ <http://www.synatree.com> 1001 State Street, Suite 1123 Erie, PA 16501 (814) 422-5887 (321) 800-8733 On Wed, Jul 25, 2012 at 5:30 AM, Ludovic Dubost <[email protected]> wrote:
2012/7/25 David Baltusavich <[email protected]>:
Ok, that works great.
So I'm hoping to wire up this Glossary App plus the JSON to a highlighting script written in JS, the idea is that the words that appear in the glossary will be highlighted on any wiki page in which they appear. Not knowing much about velocity at all, I figured this could be implemented by parsing the body of the wiki content in search of any matching words/phrases, and mark them up with <abbr> tags, tooltips, etc. In order for this to work I need to be able to add some custom JS to each page on the wiki, which I am guessing I can do by modifying the skin, and using your helpful link trick to load the latest JSON into my highlighting script.
In fact we have already this on a project, but we could not get to fully publish it as an extension. The way it was done was to generate the annotations on the server side with a script at night. This is quite easy to do as you just need to update the annotations (which are comments in recent versions) in XWIki Objects At some point this code should be published but I cannot tell when.
This was found to be much more efficient than to do it in real time in JS
If you want to go the JS way, use JSX
Ludovic, since you are obviously intimately familiar with XWiki, is there a better (server-side) way to achieve a glossary or acronym database functionality? Again I'm looking to dynamically add links to existing wiki content based on a set of words and definitions that appear in an XWiki app.
If not, the JS method should work fine but of course the parse operation has to happen on every page load, which is inefficient.
Yours,
David Baltusavich ------------------------------
<http://www.synatree.com> 1001 State Street, Suite 1123 Erie, PA 16501 (814) 422-5887 (321) 800-8733
On Tue, Jul 24, 2012 at 7:15 PM, Ludovic Dubost <[email protected]> wrote:
Add ?xpage=plain&outputSyntax=plain to your URL
Envoyé de mon iPhone
Le 25 juil. 2012 à 00:06, David Baltusavich <[email protected]> a écrit :
Another newbie question, I'm afraid.
I have a simple Glossary application that I've written, and I've managed to figure out how to write a velocity script to retrieve all of the glossary terms and put them into a JSON array. The problem is, the velocity script output is being html encoded and sent to the browser as text, including the enclosing <script> blocks. If I wrap the whole thing in {{html}} macro calls, the velocity script doesn't run. If I just enclose the <script> opening and closing tags in their own {{html}} macro call, the calls fail.
What am I missing here? How do I get velocity script to render as HTML/JS?
Yours,
David Baltusavich ------------------------------
<http://www.synatree.com> 1001 State Street, Suite 1123 Erie, PA 16501 (814) 422-5887 (321) 800-8733 _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Ludovic Dubost Founder and CEO Blog: http://blog.ludovic.org/ XWiki: http://www.xwiki.com Skype: ldubost GTalk: ldubost _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
participants (3)
-
David Baltusavich -
Ludovic Dubost -
Paul Libbrecht