diff options
author | Kris Maglione <maglione.k@gmail.com> | 2011-01-24 15:31:44 -0500 |
---|---|---|
committer | Kris Maglione <maglione.k@gmail.com> | 2011-01-24 15:31:44 -0500 |
commit | 282bc0e3fa3b8b413ea4a12d90709d64a3aee106 (patch) | |
tree | b8580db84a311cd2fe135822068421843733bac1 /common | |
parent | ef75a4c4142bd4c37d7080a10cb25b3888c86624 (diff) | |
download | pentadactyl-282bc0e3fa3b8b413ea4a12d90709d64a3aee106.tar.gz |
Add horribly formatted :help versions page.
--HG--
extra : transplant_source : %C3%C4%DAw9%B5%A8%3B%03y%9F%91X%1A%0Fk%14%B0%9F%02
Diffstat (limited to 'common')
-rw-r--r-- | common/content/dactyl.js | 66 |
1 files changed, 64 insertions, 2 deletions
diff --git a/common/content/dactyl.js b/common/content/dactyl.js index f05f893e..332f5672 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -619,8 +619,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { }); // Process plugin help entries. - XML.ignoreWhiteSpace = false; - XML.prettyPrinting = false; + XML.ignoreWhiteSpace = XML.prettyPrinting = false; let body = XML(); for (let [, context] in Iterator(plugins.contexts)) @@ -654,6 +653,69 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { </document>.toXMLString())); fileMap["plugins"] = function () ['text/xml;charset=UTF-8', help]; + fileMap["versions"] = function () { + let NEWS = util.httpGet(config.addon.getResourceURI("NEWS").spec).responseText; + + let re = util.regexp(<![CDATA[ + ^ (?P<space> \s*) + (?P<char> [-*+]) \x20 + (?P<content> .*\n + (?: \1\x20\x20.*\n | \s*\n)* ) + | + (?P<par> + (?: ^ [^\S\n]* + (?:[^-*+\s] | [-*+]\S) + .*\n + )+ + ) + | + (?: ^ [^\S\n]* \n) + + ]]>, "gmy"); + + default xml namespace = NS; + function rec(text, level) { + let res = <></>; + let list, space; + + for (let match in re.iterate(text)) { + if (match.char) { + if (!list) + res += list = <ul/>; + list.* += <li>{rec(match.content.replace(RegExp("^" + match.space, "gm"), ""), level + 1)}</li>; + } + else if (match.par) { + list = null; + if (level == 0 && /^.*:\n$/.test(match.par)) + res += <h2>{template.linkifyHelp(match.par.slice(0, -1), true)}</h2>; + else { + let [, a, b] = /^(IMPORTANT:?)?([^]*)/.exec(match.par); + res += <p>{ + a ? <hl key="HelpWarning">{a}</hl> : "" + }{ + template.linkifyHelp(b, true) + }</p>; + } + } + } + return res; + } + + XML.prettyPrinting = XML.ignoreWhitespace = false; + return ["application/xml", + '<?xml version="1.0"?>\n' + + '<?xml-stylesheet type="text/xsl" href="dactyl://content/help.xsl"?>\n' + + '<!DOCTYPE document SYSTEM "resource://dactyl-content/dactyl.dtd">\n' + + unescape(encodeURI( // UTF-8 handling hack. + <document xmlns={NS} + name="versions" title={config.appName + " Versions"}> + <h1 tag="versions">Versions</h1> + <toc start="2"/> + + {rec(NEWS, 0)} + </document>.toXMLString())) + ] + } + default xml namespace = NS; overlayMap["index"] = function () ['text/xml;charset=UTF-8', |