journalduhacker/app/views/users/tree.html.erb
2014-01-04 03:14:41 -05:00

38 lines
1 KiB
Plaintext

<div class="box wide">
<p><strong>Users (<%= @user_count %>)</strong></p>
<ul class="root">
<% subtree = @users_by_parent[nil] %>
<% ancestors = [] %>
<% while subtree %>
<% if (user = subtree.pop) %>
<li>
<a href="/u/<%= user.username %>"
<%= (Time.now - user.created_at < 7.days ? raw("style=\"color: green;\"") :
"") %>><%= user.username %></a>&nbsp;(<%= user.karma %>)
<% if user.is_admin? %>
(administrator)
<% elsif user.is_moderator? %>
(moderator)
<% end %>
<% if (children = @users_by_parent[user.id]) %>
<% # drill down deeper in the tree %>
<% ancestors << subtree %>
<% subtree = children %>
<ul class="user_tree">
<% else %>
</li>
<% end %>
<% else %>
<% # climb back out %>
<% subtree = ancestors.pop %>
<% if subtree %>
</ul></li>
<% end %>
<% end %>
<% end %>
</ul>
</div>