From: Jean Privat Date: Thu, 3 Dec 2015 02:09:44 +0000 (-0500) Subject: nitiwiki: add root_href if the wiki need it X-Git-Tag: v0.8~58^2~1 X-Git-Url: http://nitlanguage.org nitiwiki: add root_href if the wiki need it Signed-off-by: Jean Privat --- diff --git a/contrib/nitiwiki/src/wiki_html.nit b/contrib/nitiwiki/src/wiki_html.nit index 1288d3c..ab79f09 100644 --- a/contrib/nitiwiki/src/wiki_html.nit +++ b/contrib/nitiwiki/src/wiki_html.nit @@ -189,10 +189,7 @@ redef class WikiArticle fun load_template(template_file: String): TemplateString do var tpl = wiki.load_template(template_file) if tpl.has_macro("ROOT_URL") then - var root_dir = dhref.relpath("") - # Avoid issues if the macro is just followed by a `/` (as with url prefix) - if root_dir == "" then root_dir = "." - tpl.replace("ROOT_URL", root_dir) + tpl.replace("ROOT_URL", root_href) end return tpl end diff --git a/contrib/nitiwiki/src/wiki_links.nit b/contrib/nitiwiki/src/wiki_links.nit index 89cc55a..c1785b2 100644 --- a/contrib/nitiwiki/src/wiki_links.nit +++ b/contrib/nitiwiki/src/wiki_links.nit @@ -103,6 +103,14 @@ redef class WikiEntry # Relative path to the directory `self` from the target root_url fun dir_href: String do return href.dirname + # Relative path to the root url from `self` + fun root_href: String do + var root_dir = dir_href.relpath("") + # Avoid issues if used as a macro just followed by a `/` (as with url prefix) + if root_dir == "" then root_dir = "." + return root_dir + end + # A relative `href` to `self` from the page `context`. # # Should be used to navigate between documents.