From 93d99abb57b6d97868f9b281145e8bb136f108b9 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Wed, 2 Dec 2015 21:09:44 -0500 Subject: [PATCH] nitiwiki: add root_href if the wiki need it Signed-off-by: Jean Privat --- contrib/nitiwiki/src/wiki_html.nit | 5 +---- contrib/nitiwiki/src/wiki_links.nit | 8 ++++++++ 2 files changed, 9 insertions(+), 4 deletions(-) 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. -- 1.7.9.5