MDN/Archives/Kuma/Scripting: Difference between revisions

no edit summary
(Created page with "== Overview == The mission of the Kuma wiki is to replace MindTouch. One of the advanced features of MindTouch is [http://developer.mindtouch.com/en/docs/DekiScript DekiScript]...")
 
No edit summary
Line 31: Line 31:
* Sandboxed server-side JavaScript filter service (node.js)
* Sandboxed server-side JavaScript filter service (node.js)
* Plentiful and intelligent HTTP-based caching
* Plentiful and intelligent HTTP-based caching
== DekiScript samples ==
Here's some inline script excerpted from [https://developer.mozilla.org/en/Firefox_9_for_developers en/Firefox_9_for_developers]:<pre>
    <li>The <code>value</code> attribute of {{HTMLElement("li")}} now can be
    negative as specified in HTML5. Previously negative values were converted
    to 0.</li>
</pre>
Here's the source of [http://developer-dev.mozilla.org/Template:HTMLElement Template:HTMLElement], a commonly used script:<pre>
    /* accepts as input one required parameter: HTML element to create a xref to */
    var uri = uri.parts(Page.uri);
    var lang = string.tolower(uri.path[0]);
    if (string.contains(lang, "project") || string.contains(lang, "Project")) {
      let lang = string.substr(lang, 8);
    }
    /* fall back to page.language on a user page */
    else if (string.StartsWith(lang, "user:")) {
      let lang = page.language;
    }
    var name = $0;
    var sectionname = "Element";
    if (!string.compare("es", string.tolower(lang))) {
      let sectionname = "Elemento";
    }
    if (args.title) {
      let name = args.title;
    }
    var dest = lang .. '/' .. 'HTML/' .. sectionname .. '/' .. name;
    var destEng = 'en/HTML/Element/' .. name;
    if (wiki.pageExists(dest)) { /* the page exists */
      <code>(web.link(wiki.uri(dest), '<' .. name .. '>'))</code>;
    } else if (lang == 'zh_tw' && wiki.pageExists(destEng)){
      /* the MozTW community consider links to English pages better than red ones.
        I'll write about this to mozilla.dev.mdc later */ 
      <code>(web.link(wiki.uri(destEng), '<' .. name .. '>'))</code>;
    } else { /* the page doesn't exist */
      var targeturi = "https://developer.mozilla.org/Article_not_found?uri=" .. dest;
      <code><a rel=('internal') href=(targeturi) class=('new')>web.text('<' .. name .. '>')</a></code>
    }
</pre>


== Miscellaneous notes ==
== Miscellaneous notes ==
Confirmed users
920

edits