nitiwiki: add `trail:` command to collect trails
authorJean Privat <jean@pryen.org>
Wed, 11 Nov 2015 16:16:19 +0000 (11:16 -0500)
committerJean Privat <jean@pryen.org>
Wed, 11 Nov 2015 20:29:50 +0000 (15:29 -0500)
Signed-off-by: Jean Privat <jean@pryen.org>

contrib/nitiwiki/src/wiki_links.nit

index 40f747c..03f21ca 100644 (file)
@@ -17,6 +17,7 @@ module wiki_links
 
 import wiki_base
 import markdown::wikilinks
+import ordered_tree
 
 redef class Nitiwiki
        # Looks up a WikiEntry by its `name`.
@@ -86,6 +87,12 @@ redef class Nitiwiki
                end
                return entry
        end
+
+       # Trails between pages
+       #
+       # Trails are represented as a forest of entries.
+       # This way it is possible to represent a flat-trail as a visit of a tree.
+       var trails = new OrderedTree[WikiEntry]
 end
 
 redef class WikiEntry
@@ -268,6 +275,11 @@ class NitiwikiDecorator
                        if target != null then
                                if name == null then name = target.title
                                link = target.href_from(context)
+
+                               if command == "trail" then
+                                       if target isa WikiSection then target = target.index
+                                       wiki.trails.add(context, target)
+                               end
                        else
                                wiki.message("Warning: unknown wikilink `{link}` (in {context.src_path.as(not null)})", 0)
                                v.add "class=\"broken\" "