nitiwiki: reintroduce `allow absolute wikilinks` (c2802e0b4) broken by 98a42459
authorJean Privat <jean@pryen.org>
Thu, 9 Jul 2015 15:40:57 +0000 (11:40 -0400)
committerJean Privat <jean@pryen.org>
Thu, 9 Jul 2015 17:50:08 +0000 (13:50 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

contrib/nitiwiki/src/wiki_links.nit

index 96c6fd6..d261403 100644 (file)
@@ -233,27 +233,29 @@ private class NitiwikiDecorator
                var anchor: nullable String = null
                var link = token.link
                if link == null then return
-               if link.has("#") then
-                       var parts = link.split_with("#")
-                       link = parts.first
-                       anchor = parts.subarray(1, parts.length - 1).join("#")
-               end
-               if link.has("/") then
-                       target = wiki.lookup_entry_by_path(context, link.to_s)
-               else
-                       target = wiki.lookup_entry_by_name(context, link.to_s)
-                       if target == null then
-                               target = wiki.lookup_entry_by_title(context, link.to_s)
-                       end
-               end
-               v.add "<a "
                var name = token.name
-               if target != null then
-                       if name == null then name = target.title
-                       link = target.href_from(context)
-               else
-                       wiki.message("Warning: unknown wikilink `{link}` (in {context.src_path.as(not null)})", 0)
-                       v.add "class=\"broken\" "
+               v.add "<a "
+               if not link.has_prefix("http://") and not link.has_prefix("https://") then
+                       if link.has("#") then
+                               var parts = link.split_with("#")
+                               link = parts.first
+                               anchor = parts.subarray(1, parts.length - 1).join("#")
+                       end
+                       if link.has("/") then
+                               target = wiki.lookup_entry_by_path(context, link.to_s)
+                       else
+                               target = wiki.lookup_entry_by_name(context, link.to_s)
+                               if target == null then
+                                       target = wiki.lookup_entry_by_title(context, link.to_s)
+                               end
+                       end
+                       if target != null then
+                               if name == null then name = target.title
+                               link = target.href_from(context)
+                       else
+                               wiki.message("Warning: unknown wikilink `{link}` (in {context.src_path.as(not null)})", 0)
+                               v.add "class=\"broken\" "
+                       end
                end
                v.add "href=\""
                append_value(v, link)