Guide

From $1

    Table of contents
    No headers
    /***
        USAGE:
    
        Guide(description)
            Show a content guide that organizes the tree rooted at the guide pages into types of pages (topics, tutorials, troubleshooting and reference).
    
        PARAMETERS:
    
        description : str
            Description of what this guide covers.
    
    ***/
    
    var description = $0 ?? $description;
    
    // build list of all child pages in order of appearance
    var common_parents = page.parents;
    var tree = wiki.tree();
    var pageids = [ xml.num(id) foreach var id in tree["//@pageid"] ];
    var pages = {
        (p.id): p .. {
            parents: list.splice(p.parents, 0, #common_parents),
            topic: #[ t foreach var t in tags where string.startswith(t.value, 'article:topic') ] > 0,
            tutorial: #[ t foreach var t in tags where string.startswith(t.value, 'article:task-tutorial') ] > 0,
            troubleshooting: #[ t foreach var t in tags where string.startswith(t.value, 'article:task-troubleshooting') ] > 0,
            reference: #[ t foreach var t in tags where string.startswith(t.value, 'article:reference') ] > 0,
            beginner: #[ t foreach var t in tags where string.endswith(t.value, 'beginner') ] > 0,
            intermediate: #[ t foreach var t in tags where string.endswith(t.value, 'intermediate') ] > 0,
            advanced: #[ t foreach var t in tags where string.endswith(t.value, 'advanced') ] > 0
        } foreach
            var id in pageids,
            var p = wiki.getpage(id),
            var tags = p.tags
    };
    var topics = [ p foreach var id in pageids, var p = pages[id], if p.topic ];
    var tutorials = [ p foreach var id in pageids, var p = pages[id], if p.tutorial ];
    var troubleshootings = [ p foreach var id in pageids, var p = pages[id], if p.troubleshooting ];
    var references = [ p foreach var id in pageids, var p = pages[id], if p.reference ];
    
    <div class="mindtouch-content mindtouch-collection">
        var guide = __request.args.guide ?? 'guide';
        
        /* 
         * Master Tabs
         */
        <div class="mt-control-nav">
            <ul>
                <li class=(guide == "guide" ? "active" : "")>
                    <a rel="custom" href=(page.uri & { guide: nil })>
                        wiki.localize("MindTouch.IDF.guide"); 
                        " ";
                        <span class="count">"("; #topics; ")";</span>
                    </a>
                </li>
                <li class=(guide == "tutorial" ? "active" : "")>
                    <a rel="custom" href=(page.uri & { guide: "tutorial" })>
                        wiki.localize("MindTouch.IDF.tutorial"); 
                        " ";
                        <span class="count">"("; #tutorials; ")";</span>
                    </a>
                </li>
                <li class=(guide == "reference" ? "active" : "")>
                    <a rel="custom" href=(page.uri & { guide: "reference" })>
                        wiki.localize("MindTouch.IDF.reference"); 
                        " ";
                        <span class="count">"("; #references; ")";</span>
                    </a>
                </li>
                <li class=(guide == "troubleshooting" ? "active" : "")>
                    <a rel="custom" href=(page.uri & { guide: "troubleshooting" })>
                        wiki.localize("MindTouch.IDF.troubleshooting"); 
                        " ";
                        <span class="count">"("; #troubleshootings; ")";</span>
                    </a>
                </li>
            </ul>
        </div>
        switch(guide) {
        
        /*
         * Tutorials Tab
         */
        case 'tutorial':
            if(#tutorials == 0) {
                <div class="mt-control-nocontent">
                    <p class="nocontent-title">wiki.localize("MindTouch.IDF.tutorial.empty");</p>
                    <p>wiki.localize("MindTouch.IDF.tutorial.text");</p>
                </div>
            } else {
                <div class="mt-control-pagelist">        
                    <div class="mt-control-subnav">
                        <p>wiki.localize("MindTouch.IDF.tutorial.view");</p>
                        <ul>
                            <li><a href="#tutorial-beginner">
                                wiki.localize("MindTouch.IDF.tutorial.beginner.short");</a>
                            </li>
                            <li><a href="#tutorial-intermediate">
                                wiki.localize("MindTouch.IDF.tutorial.intermediate.short");</a>
                            </li>
                            <li><a href="#tutorial-advanced">
                                wiki.localize("MindTouch.IDF.tutorial.advanced.short");</a>
                            </li>
                        </ul>
                    </div>
                    
                    var p = [ p foreach var p in tutorials where p.beginner ];
                    if(#p > 0) {
                        <div class="subtitle" id="tutorial-beginner">
                            wiki.localize("MindTouch.IDF.tutorial.beginner");
                        </div>
                        template("MindTouch/IDF/Controls/PageListWithBreadcrumbs", {
                            pages: p,
                            heading: "h4"
                        });
                    }
                    
                    var p = [ p foreach var p in tutorials where p.intermediate ];
                    if(#p > 0) {
                        <div class="subtitle" id="tutorial-intermediate">
                            wiki.localize("MindTouch.IDF.tutorial.intermediate");
                        </div>
                        template("MindTouch/IDF/Controls/PageListWithBreadcrumbs", {
                            pages: p,
                            heading: "h4"
                        });
                    }
                    
                    var p = [ p foreach var p in tutorials where p.advanced ];
                    if(#p > 0) {
                        <div class="subtitle" id="tutorial-advanced"> 
                            wiki.localize("MindTouch.IDF.tutorial.advanced"); 
                        </div>
                        template("MindTouch/IDF/Controls/PageListWithBreadcrumbs", {
                            pages: p,
                            heading: "h4"
                        });
                    }
                </div>
            }
        
        /*
         * Troubleshooting Tab
         */
        case 'troubleshooting':
            if(#troubleshootings == 0) {
                <div class="mt-control-nocontent">
                    <p class="nocontent-title">wiki.localize("MindTouch.IDF.troubleshooting.empty");</p>
                    <p>wiki.localize("MindTouch.IDF.troubleshooting.text");</p>
                </div>
            } else {
                <div class="mt-control-pagelist">
                <div class="subtitle">
                     wiki.localize("MindTouch.IDF.troubleshooting.subtitle"); 
                </div>
                template("MindTouch/IDF/Controls/PageListWithBreadcrumbs", {
                    pages: troubleshootings
                });
                </div>
            }
        
        /*
         * Reference Tab
         */
        case 'reference':
            if(#references == 0) {
               <div class="mt-control-nocontent">
                    <p class="nocontent-title">wiki.localize("MindTouch.IDF.reference.empty");</p>
                    <p>wiki.localize("MindTouch.IDF.reference.text");</p>
                </div>
            } else {
                <div class="mt-control-pagelist">
                    <div class="subtitle">
                         wiki.localize("MindTouch.IDF.reference.subtitle"); 
                    </div>
                    template("MindTouch/IDF/Controls/PageListWithBreadcrumbs", {
                        pages: references
                    });
                </div>
            }
        
        /*
         * Main guide page
         */
        default:
            <div class="page-guide">
            
                // show the guide description
                <div class="mt-control-guide-description">
                    if(description is xml) {
                        xml.html(description["//*[@id='guide-description']"]);
                    } else {
                        description;
                    }
                </div>
                
                // show related pages
                <div class="page-seealso">
                    wiki.template("MindTouch/IDF/SeeAlso", { parents: false });
                </div>
                
                // show topic tree
                if(#topics > 0) {
                    <div class="mt-control-page-list">
                        <div class="mt-control-page-subtitle">wiki.localize("MindTouch.IDF.topic.tree")</div>
                        <div class="mt-control-page-listcontent">
                        foreach(var p in pages where p.topic) {
                            <div style=("margin-left: " .. web.size(30 * (#p.parents - 1)))>
                                web.link(p.uri, p.title);
                            </div>
                        }
                        </div>
                    </div>
                } else {
                    <div class="mt-control-nocontent">
                        <p class="nocontent-title">wiki.localize("MindTouch.IDF.topic.empty");</p>
                        <p>wiki.localize("MindTouch.IDF.topic.text");</p>
                        <div class="action">
                            wiki.create{template: "MindTouch/IDF/Pages/Feature_Page", label: wiki.localize("MindTouch.IDF.topic.action")}; 
                        </div>
                    </div>
                }
            </div>
        }
    </div>
    Tags: (Edit tags)
    • No tags
     
    Comments (0)
    You must login to post a comment.

     
    Powered by MindTouch 2010
    Admin