|
|
|
Template:MindTouch > IDF > Views > Guide
GuideVon $1
Inhaltsverzeichniskeine Gliederung/***
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;
// 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,
feature: #[ t foreach var t in tags where string.endswith(t.value, 'feature') ] > 0,
sample: #[ t foreach var t in tags where string.endswith(t.value, 'sample') ] > 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 ];
// the guide expects to be within a <table>
<td>
<div class="mindtouch-content mindtouch-collection">
var guide = __request.args.guide ?? 'guide';
// can preload when not on history tab
var class_preload = (guide != 'history') ? 'mt-guide-preload' : '';
/*
* Master Tabs
*/
<div class="mt-control-nav">
<ul>
<li class=(guide == "guide" ? "active" : "")>
<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 class=(guide == "tutorial" ? "active" : "")>
<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 class=(guide == "reference" ? "active" : "")>
<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 class=(guide == "troubleshooting" ? "active" : "")>
<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
*/
var style_tutorial = (guide == 'tutorial') ? '' : 'display: none;';
<div style=(style_tutorial) 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
*/
var style_troubleshooting = (guide == 'troubleshooting') ? '' : 'display: none;';
<div style=(style_troubleshooting) 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
*/
var style_reference = (guide == 'reference') ? '' : 'display: none;';
<div style=(style_reference) 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
*/
var style_guide = (guide == 'guide') ? '' : 'display: none;';
<div style=(style_guide) class="guide-content" id="guide-guide-content">
wiki.template("MindTouch/IDF/Views/GuideContent", {description: description, pages: pages });
</div>
} // end ajax tabs
</div>
</td>
$(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;
});
});
#pageText table,
#pageText table td {
border: none;
}
Tags: (Schlagworte bearbeiten)
|