Template:DekiScript:Page

  • Revision slug: Template:DekiScript:Page
  • Revision title: Template:DekiScript:Page
  • Revision id: 337503
  • Created:
  • Creator: trevorh
  • Is current revision? No
  • Comment

Revision Content

<% module.exports = buildAPI({ initialize: function (options) { BaseAPI.prototype.initialize.call(this, options); // Incomplete list of Page vars, but probably good enough. // See also: <http: dekiscript="" developer.mindtouch.com="" docs="" en="" page="" reference="" wiki_functions_and_variables=""> this.setVars({ date: new Date(env.modified), id: env.id, language: env.locale, name: env.slug, path: env.path, tags: env.tags, title: env.title, uri: env.url }); }, // http://developer.mindtouch.com/en/docs/DekiScript/Reference/Wiki_Functions_and_Variables/Page.Subpages // Optional path, defaults to current page // Optional depth. Number of levels of children to include, 0 is the path page // Optional self, defaults to false. Include the path page in the results subpages: function (path, depth, self) { var url = ''; if (path) { var p = kuma.url.parse(env.url, true); url = p.protocol + '//' + p.host + encodeURI(path) + '$children'; } else { url = env.url + '$children'; } if(depth != '') { url += '?depth=' + depth; } var mdn = require('MDN:Common'); var subpages = mdn.fetchJSONResource(url); var result = []; if (subpages != null) { if (!self) { result = subpages.subpages || []; } else { result = [subpages]; } } return result; } }); %></http:>

Revision Source

<% module.exports = buildAPI({
    
    initialize: function (options) {
        BaseAPI.prototype.initialize.call(this, options);
        
        // Incomplete list of Page vars, but probably good enough.
        // See also: <http://developer.mindtouch.com/en/docs/DekiScript/Reference/Wiki_Functions_and_Variables/Page>
        this.setVars({
            date: new Date(env.modified),
            id: env.id,
            language: env.locale,
            name: env.slug,
            path: env.path,
            tags: env.tags,
            title: env.title,
            uri: env.url
        });
    },

    // http://developer.mindtouch.com/en/docs/DekiScript/Reference/Wiki_Functions_and_Variables/Page.Subpages
    // Optional path, defaults to current page
    // Optional depth. Number of levels of children to include, 0 is the path page
    // Optional self, defaults to false. Include the path page in the results
    subpages: function (path, depth, self) {
        var url = '';
        if (path) {
            var p = kuma.url.parse(env.url, true);
            url = p.protocol + '//' + p.host + encodeURI(path) + '$children';
        } else {
            url = env.url + '$children';
        }
        if(depth != '') {
            url += '?depth=' + depth;
        }
        var mdn = require('MDN:Common');
        var subpages = mdn.fetchJSONResource(url);
        var result = [];
        if (subpages != null) {
            if (!self) {
                result = subpages.subpages || [];
            } else {
                result = [subpages];
            }
        }
        return result;
    }
    
}); %>
Revert to this revision