r9503 - apps/gobi/trunk/code/Global

[email protected]
Newsgroups gmane.comp.java.helma.cvs
Message-ID <[email protected]>
Author: hannes
Date: 2009-02-05 15:10:57 +0100 (Thu, 05 Feb 2009)
New Revision: 9503

Modified:
   apps/gobi/trunk/code/Global/WikiMarkup.js
Log:
Fix WikiMarkup.renderLinks() to check all inherited wiki services for wiki links, and use the closest one for wiki pages that do not exist yet.

Details at http://dev.helma.org/trac/helma/changeset/9503

Modified: apps/gobi/trunk/code/Global/WikiMarkup.js
===================================================================
--- apps/gobi/trunk/code/Global/WikiMarkup.js	2009-02-05 14:09:38 UTC (rev 9502)
+++ apps/gobi/trunk/code/Global/WikiMarkup.js	2009-02-05 14:10:57 UTC (rev 9503)
@@ -116,7 +116,9 @@
     },
 
     renderLinks: function(thisPage, src) {
-        var wikiService = getService("wiki", thisPage);
+        thisPage = thisPage.isPersistent() ? thisPage : path.page;
+        var wikis = getServices("wiki", thisPage);
+        wikis.unshift(thisPage);
         src = this.replaceAllWith(src, new RegExp(this.WIKI_LINK_RE, 'i'),
             function (md) {
                 var link = WikiMarkup.parseWikiLink(md[2]);
@@ -126,15 +128,12 @@
                 if (/^((http|ftp|https):\/\/[^\s]+[\/\w])/.test(link.target)) {
                     return md[1] + Html.A({ href: link.target, "class": "externalLink" }, link.label);
                 } else {
-                    var page = thisPage.getWikiPage(link.target);
-                    if (!page && wikiService) {
-                        page = wikiService.getWikiPage(link.target);
+                    var page;
+                    for each (var wiki in wikis) {
+                        page = wiki.getWikiPage(link.target);
                     }
-                    if (page == null) {
-                        var wiki = wikiService;
-                        if (!wiki)
-                            wiki = thisPage.getParent() ? thisPage.getParent() : thisPage;
-                        var href = wiki.href("create") + "?name=" + link.target;
+                    if (!page) {
+                        var href = wikis[0].href("create") + "?name=" + link.target;
                         return md[1] + Html.A({ href: href, "class": "undefinedLink" }, link.label);
                     } else {
                         return md[1] + Html.A({ href: page.href(), "class": "wikiLink" }, link.label);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.