var src = expand_path(config.root_dir, config.assets_dir)
var out = expand_path(config.root_dir, config.out_dir)
if need_render(src, expand_path(out, config.assets_dir)) then
- if src.file_exists then sys.system "cp -R {src} {out}"
+ if src.file_exists then sys.system "cp -R -- {src.escape_to_sh} {out.escape_to_sh}"
end
end
if is_new then
out_full_path.mkdir
else
- sys.system "touch {out_full_path}"
+ sys.system "touch -- {out_full_path.escape_to_sh}"
end
if has_source then
- wiki.message("Render section {out_path}", 1)
+ wiki.message("Render section {name} -> {out_path}", 1)
copy_files
end
var index = self.index
if index isa WikiSectionIndex then
- wiki.message("Render auto-index for section {out_path}", 1)
+ wiki.message("Render auto-index for section {name} -> {out_path}", 1)
index.is_dirty = true
add_child index
end
var src = wiki.expand_path(dir, name)
var out = wiki.expand_path(out_full_path, name)
if not wiki.need_render(src, out) then continue
- sys.system "cp -R {src} {out_full_path}"
+ sys.system "cp -R -- {src.escape_to_sh} {out_full_path.escape_to_sh}"
end
end
redef fun render do
super
if not is_dirty and not wiki.force_render then return
- wiki.message("Render article {name}", 2)
var file = out_full_path
+ wiki.message("Render article {name} -> {file}", 1)
file.dirname.mkdir
tpl_page.write_to_file file
end
# Load a template and resolve page-related macros
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 = href.dirname.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)
+ end
return tpl
end