Mercurial > repos > yating-l > hubarchivecreator
diff templates/display.txt @ 0:f493979f1408 draft default tip
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
author | yating-l |
---|---|
date | Wed, 21 Dec 2016 12:13:04 -0500 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/display.txt Wed Dec 21 12:13:04 2016 -0500 @@ -0,0 +1,52 @@ +<%namespace name="os" module="os"/> +<html> + <body> + <p> + The following has been generated by Hub Archive Creator: + </p> + <ul> + ${print_tree(walkable_tree)} + </ul> + </body> +</html> + +<%def name="print_tree(tree)"> + % if len(tree) == 0: + ## We do nothing, we are called by a leaf + ## If we are there, this is not normal though + ## TODO: Manage the error + return + % else: + % for vertex in tree: + % if len(tree[vertex][0]) > 0: + <li> + ${vertex} + </li> + <ul> + ${print_tree(tree[vertex][0])} + </ul> + % else: + <li> + <a href="${tree[vertex][1]}">${vertex}</a> + </li> + % endif + % endfor + % endif +</%def> + +<%doc> + def recurse_print_tree(tree, level): + if len(tree) == 0: + return + + for vertex in tree: + composite_name = vertex + bullet_point = '<li><a href="{0}>{0}</a></li>'.format(composite_name) + rval.append(bullet_point) + # Parent, so need to create a sub <ul> + if len(tree[vertex]) > 0: + rval.append('<ul>') + print_tree(tree[vertex], level+1) + rval.append('</ul>') + +</%doc> \ No newline at end of file