Redirected from DekiScript/FAQ/How do I... Create an AJAXified Collapsible Wiki Tree
1 of 1 found this page helpful

AJAX collapsible wiki tree

    Discuss this template here

    Description

    This template produces a collapsible wiki tree.  Rather than pre-fetching the entire tree, it dynamically fetches only as much as necessary via AJAX and the Mindtouch API.  This means it loads quickly even if the full tree is very large, and makes it suitable for implementing a navigation tree for an entire wiki site.

    If you're not working with a large tree and therefore performance isn't an issue, you can also look at the non-AJAX version, "CollapsibleTree".

    This template was originally implemented by Blake Harms based on the CollapsibleTree template, and currently maintained by Neil Weinstock.

    Requirements

    Version

    Version Date Author Description
    1.8.1 12-May-2011 Neil Weinstock Fixed alphabetization error for top-level list.

    How to Install

    These instructions will help you install the template'AjaxWikiTree' on your wiki quickly and correctly.

    Perform the following steps:

    1. Copy the template source code:
      1. If the code in the "HTML Source" area below is not already visible and selected, click the "View" button to display and select it.
      2. Copy it to your clipboard (CTRL-C).
    2. Create a new template on your wiki:
      1. Select the Tools->Templates menu item on your wiki
      2. Click "New Page" button. This will open the editor on a new page with the title "Template:Page Title".
      3. Replace "Page Title" with the name of the template.
    3. Paste in the source code:
      1. In the editor, click the "View->Source" menu item to view the HTML source of the page.
      2. Select all text (CTRL-A).
      3. Paste in the template source code from the clipboard (CTRL-V).
    4. Click "Save" button.

    HTML Source for Template:AjaxWikiTree

    Parameters

    Name Type Default Description
    path str? page.path Path to the root of the tree
    slide bool? false Use "slide" effect to collapse and expand sub-trees

    Historical Notes from Blake

    NeilW wrote up his CollapsibleTree template so I immediately placed it at my root page and waited. And waited. And waited. With thousands of pages to process, it just wasn't worth the wait. Even on Chrome (which, arguably, has the fastest javascript engine). But it wasn't his fault, it was A LOT of pages. For a few pages, I would definitely recommend his template. But for a full-page structure, consider AJAX.

    There are a few modifications. For instance, you cannot use just any tree. That wouldn't make any sense. This template is for loading thousands of pages based on the wiki hierarchy asynchronously. The way the template generates the tree is by calling wiki.tree(path,1) so that it only loads the first bit.

    I considered loading the whole tree and only applying the javascript to code the subtree that was opened, but that wasn't nearly as cool. Plus, what if a page is created during the time that the tree is loaded and the javascript is run? You wouldn't get that page! Worlds would end, kittens would be murdered, and you wouldn't be up to date. For all these reasons, AJAX was chosen.

    As with all of my "applications" I began this at home just to test some things out. And because I thought it would be fun. :P I quickly realized though, that it would be very useful everywhere, so I posted it here. I think it's matured quite well. 

    Have fun and enjoy!

    Want to see more features? Have a bug to report? File them both here!

    Examples

    To show the tree starting at the current page:

    {{ AjaxWikiTree() }}
    

    To show a list from another page (As in the demo), add a parameter:

    {{ AjaxWikiTree("path/to/tree") }}
    

    Add a slide effect:

    {{ AjaxWikiTree("path/to/tree",true) }}
    

    And now, to demonstrate the RAW POWER of this template, I will attempt to load the ROOT PAGE!

    missing value for parameter 'map' (index 0) (click for details)

    That wasn't too bad.

    Was this page helpful?
    Tag page

    Files 2

    FileVersionSizeModified 
    Viewing 15 of 39 comments: view all
    @zippgunn Not sure, you may want to ask on the forums.
    Posted 21:17, 18 Aug 2009
    I finally found a workaround to get the extension to load.
    # Use SSH console
    # type in export and see if http_proxy is configured, if not,
    # type in (without speech marks) "export http_proxy=http://ip:port" (this is a CCproxy installation that piggybacks the connection through our ISA server)
    # type in "wget http://scripts.mindtouch.com/<scriptname>.xml -O /var/www/dekiwiki/bin/<scriptname>.xml"
    Replace <scriptname> with the name of the script in the manifest
    # You should see from the feedback that the file is downloaded succesfully.
    # Now change the path in the "add script" manifest box to "/var/www/dekiwiki/bin/<scriptname>.xml"
    # This should work.
    # I got this partly from here: http://forums.developer.mindtouch.co...ead.php?t=3514
    Posted 19:52, 19 Aug 2009
    Now I can't get any output using this.

    I have it set in a page exactly like it is described, but it does not display anything.
    No errors either, just a blank space where the list should be.
    Could it be to do with the icons?
    Posted 20:45, 19 Aug 2009
    @zippgunn Odd. Can you see any errors in the Javascript? Does wiki.tree() do the same thing?
    Posted 08:06, 20 Aug 2009
    Odd yes, wiki.tree() works ok.
    How can I trouble shoot the Javascript?
    Thanks for your help.
    BTW. If I deliberately foul up the {{ AjaxWikiTree() }}
    with like the wrong number of brackets it pipes up and complains, so some of it seems to be working I guess.
    Posted 12:42, 20 Aug 2009
    @zippgunn On Firefox/Google Chrome, press Ctrl>Shift>J to load the Error console/Developer tools. On Internet Explorer, look for the "Errors on page" hotlink on the bottom left of the status bar.
    Posted 18:59, 20 Aug 2009
    Anyone experienced strange rendering of URLs when using this ?
    On pages without subpages I get things like this - https://somesitename/Blah/%2FBlah%2FTest%2Fprogramme%2FJuly_2008_schedule
    It adds another Blah to the front :-(
    Posted 19:17, 15 Dec 2009
    Ho hum. Having a few problems here as well.
    Initial try was to load it as an extension, which failed. I then tried it as a script which worked better, but still gave the error: "reference to undefined name 'dekiapi':"
    I then added the namespace as dekiapi and I'm getting a the "/content/body/pre, map is not valid; expected uri: line 1, column 8" error.
    Using 9.08. Figured out how to add Unsafe content permissions. I think I managed to cut and paste the code OK and format it in a Dekiscript block. Extension/Script is flagged as running. No Javascript errors. Have cleared cache a few times. Anything else I should look at?
    Posted 23:33, 10 Jan 2010
    I've got the same issue than peripatetic, can somebody help?
    Posted 07:23, 10 Aug 2010
    This is the snippet

    content/body/pre[1], map is not valid; expected uri: line 1, column 13 (click for details)
    MindTouch.Deki.Script.DekiScriptBadTypeException: map is not valid; expected uri: line 1, column 13
    at MindTouch.Deki.Script.DekiScriptCall.Evaluate (MindTouch.Deki.Script.DekiScriptEnv env) [0x00000]
    at MindTouch.Deki.Script.Dom.DekiScriptDomExpr.Evaluate (MindTouch.Deki.Script.DekiScriptEvalContext context, System.Xml.XmlNode parent, MindTouch.Deki.Script.DekiScriptEnv env) [0x00000] edited 07:32, 10 Aug 2010
    Posted 07:32, 10 Aug 2010
    Using Mindtouch 2010 and I get the following error:

    reference to undefined name 'dekiapi' Exception of type 'MindTouch.Deki.Script.Runtime.DekiScriptUndefinedNameException' was thrown. (click for details)
    Callstack:
    at Engineering/Firmware
    at Template:SimplePoll

    MindTouch.Deki.Script.Runtime.DekiScriptUndefinedNameException: reference to undefined name 'dekiapi' Exception of type 'MindTouch.Deki.Script.Runtime.DekiScriptUndefinedNameException' was thrown.
    at MindTouch.Deki.Script.Compiler.DekiScriptExpressionEvaluation.Visit(DekiScriptVar expr, DekiScriptExpressionEvaluationState state)
    at MindTouch.Deki.Script.Expr.DekiScriptVar.VisitWith[TState,TReturn](IDekiScriptExpressionVisitor`2 visitor, TState state)
    at MindTouch.Deki.Script.Compiler.DekiScriptExpressionEvaluation.Visit(DekiScriptCall expr, DekiScriptExpressionEvaluationState state)
    at MindTouch.Deki.Script.Expr.DekiScriptCall.VisitWith[TState,TReturn](IDekiScriptExpressionVisitor`2 visitor, TState state)
    at MindTouch.Deki.Script.Compiler.DekiScriptExpressionEvaluation.Visit(DekiScriptSequence expr, DekiScriptExpressionEvaluationState state)
    at MindTouch.Deki.Script.Expr.DekiScriptSequence.VisitWith[TState,TReturn](IDekiScriptExpressionVisitor`2 visitor, TState state)
    at MindTouch.Deki.Script.Compiler.DekiScriptExpressionEvaluation.Visit(DekiScriptReturnScope expr, DekiScriptExpressionEvaluationState state)
    Posted 11:53, 3 Dec 2010
    Files collapse_icons.gif and loadinfo.net.gif are now both attached to this page. Current links to the files (cfrwiki.raritan.com) don't work.

    *Updated post to clarify statement* edited 05:51, 15 Jul 2011
    Posted 07:21, 12 Jul 2011
    @beezoboy
    Using the newest version, the gif files need to be attached to the *template page*. They're still here as well to avoid breaking the template for people using older versions.
    Posted 07:55, 14 Jul 2011
    @NEILW

    Sure. I meant the links to the actual files are dead links up top (cfrwiki.raritan.com) and "collapse_icons.gif" wasn't attached to this page. So someone trying to use the template wouldn't have been able to get the 1 of the two files with the information provided on this page. That's all. I was just trying to make it more convenient since I already had the file. Now both image files can be downloaded directly from this page to attach to a user's template.
    Posted 05:49, 15 Jul 2011
    @beezoboy
    Whooooops. Thanks for pointing that out. If I had read your original note more carefully I would have seen it then. I fixed the links.
    Posted 10:07, 15 Jul 2011
    Viewing 15 of 39 comments: view all
    You must login to post a comment.

    Copyright © 2011 MindTouch, Inc. Powered by