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.
***/
// Redirect to custom page, if any
var template_custom = __page.path .. 'Custom';
if (wiki.pageexists(template_custom)) {
return template(template_custom, $);
}
var description = $0 ?? $description;
// select appropriate guide
var guide = __request.args.guide ?? 'guide';
switch(guide) {
case 'guide':
case 'troubleshooting':
case 'reference':
case 'tutorial':
case 'history':
break;
default:
// invalid key, replace with safe default
let guide = 'guide';
}
// check if we have a cached version
var cachekey = null;
if(__env.webcache && !user.seated && guide !== 'history') {
let cachekey =
site.hostname .. '-' ..
page.id .. '-' ..
wiki.recentchangestimestamp{ path: 'Template:MindTouch' } .. '-' ..
wiki.recentchangestimestamp{ pages: true, tags: true, comments: false, files: false };
if(__request.args.nocache) {
webcache.clear(cachekey);
let cachekey = null;
} else {
var cached = webcache.fetch(cachekey);
if(cached) {
<div style="display: none"> "IDF guide rendered from cache" </div>
return cached;
}
}
}
// build document
var result = (
// build list of all child pages in order of appearance
var guidepages = import('MindTouch/IDF/Functions/GuidePages', { });
var pages = guidepages.pages;
var hierarchy = guidepages.hierarchy;
var topics = guidepages.topics;
var tutorials = guidepages.tutorials;
var troubleshootings = guidepages.troubleshootings;
var references = guidepages.references;
// the guide expects to be within a <table>
<td>
<div class="mindtouch-content mindtouch-collection">
// can preload when not on history tab
var class_preload = (guide != 'history') ? 'mt-guide-preload' : '';
/*
* Master Tabs
*/
<div class="mt-control-nav">
<ul>
<li>
<a rel="custom" href=(page.uri & { guide: nil }) id="guide-guide" class=(class_preload)>
wiki.localize("MindTouch.IDF.guide");
" ";
<span class="count">"("; #topics; ")";</span>
</a>
</li>
<li>
<a rel="custom" href=(page.uri & { guide: "tutorial" }) id="guide-tutorial" class=(class_preload)>
wiki.localize("MindTouch.IDF.tutorial");
" ";
<span class="count">"("; #tutorials; ")";</span>
</a>
</li>
<li>
<a rel="custom" href=(page.uri & { guide: "reference" }) id="guide-reference" class=(class_preload)>
wiki.localize("MindTouch.IDF.reference");
" ";
<span class="count">"("; #references; ")";</span>
</a>
</li>
<li>
<a rel="custom" href=(page.uri & { guide: "troubleshooting" }) id="guide-troubleshooting" class=(class_preload)>
wiki.localize("MindTouch.IDF.troubleshooting");
" ";
<span class="count">"("; #troubleshootings; ")";</span>
</a>
</li>
<li class=(guide === "history" ? "active" : _)>
<a rel="custom" href=(page.uri & { guide: "history" }) id="guide-history">
wiki.localize("MindTouch.IDF.history");
</a>
</li>
</ul>
</div>
// all tabs except history are preloaded; render them in full, but hide with CSS
if (guide == 'history') {
<div class="page-history">
Template("MindTouch/IDF/Controls/ListChanges", {
limit: 100,
depth: 'infinity'
});
</div>
} else {
/*
* Tutorials Tab
*/
<div style='display: none;' class="guide-content" id="guide-tutorial-content">
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>
}
</div> // end tutorial
/*
* Troubleshooting Tab
*/
<div style='display: none;' id="guide-troubleshooting-content" class="guide-content">
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>
}
</div>
/*
* Reference Tab
*/
<div style='display: none;' id="guide-reference-content" class="guide-content">
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="mt-control-subnav">
<p>wiki.localize("MindTouch.IDF.reference.view");</p>
<ul>
<li><a href="#reference-feature">
wiki.localize("MindTouch.IDF.reference.feature.short");</a>
</li>
<li><a href="#reference-sample">
wiki.localize("MindTouch.IDF.reference.sample.short");</a>
</li>
</ul>
</div>
var p = [ p foreach var p in references where p.feature ];
if(#p > 0) {
<div class="subtitle" id="reference-feature">
wiki.localize("MindTouch.IDF.reference.feature");
</div>
template("MindTouch/IDF/Controls/PageListWithBreadcrumbs", {
pages: p,
heading: "h4"
});
}
var p = [ p foreach var p in references where p.sample ];
if(#p > 0) {
<div class="subtitle" id="reference-sample">
wiki.localize("MindTouch.IDF.reference.sample");
</div>
template("MindTouch/IDF/Controls/PageListWithBreadcrumbs", {
pages: p,
heading: "h4"
});
}
</div>
}
</div>
/*
* Main guide page
*/
<div class="guide-content" id="guide-guide-content">
wiki.template("MindTouch/IDF/Views/GuideContent", {
description: description,
pages: pages,
hierarchy: hierarchy
});
</div>
}
</div>
</td>
);
// keep generated document
cachekey ? webcache.store(cachekey, result, 2592000) : result;
$(function(){
$('a.mt-guide-preload').attr('href', '#').click(function() {
$('.mt-control-nav li').removeClass('active');
$('.guide-content').hide();
$('#' + $(this).attr('id') + '-content').show();
$(this).parent().addClass('active');
return false;
});
// show active tab
$('#guide-' + {{ guide }}).click();
});
#pageText table,
#pageText table td {
border: none;
}

Comments