simple.html.j2 2.16 KB
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8"/>
    <title>Ldap</title>
    <style type="text/css">
      ul {
        list-style-type: none;
      }
      ul.attributes {
        border: 1px solid black;
        font-weight: normal;
        display: none;
        padding: 5px;
        margin: 0;
      }
      ul.childs {
        display: none;
      }
      button {
        cursor: pointer;
        background-color: rgba(0,0,0,0);
        border: none;
        color: black;
        padding: 2px;
        text-align: center;
        text-decoration: none;
        display: inline-block;
        font-size: 16px;
      }
      span.linked {
        font-weight: bold;
        cursor: pointer;
      }
    </style>
  </head>

  <body>
    <h1>Ldap</h1>

    <script language="Javascript">
      function toggle(e, cls) {
        attr = e.parentElement.getElementsByClassName(cls)[0];
        if(attr.style.display == 'block')
          attr.style.display = 'none';
        else
          attr.style.display = 'block';
      }
    </script>

    <ul class="tree">
    {% set depth=0 -%}
    {% for d in ldaptree.hirarchy -%}
    {% if depth>=d[0] and depth!=0 -%}
    <ul class="childs" {% if depth < 3 -%}style="display: block;"{% endif -%}>
    </ul>
    </li>
    {% endif -%}
    {% if depth < d[0] -%}
    {% set depth=d[0] -%}
    <ul class="childs" {% if depth < 3 -%}style="display: block;"{% endif -%}>
    {% endif -%}
    {% if depth > d[0] -%}
    {% for i in range(depth-d[0]) -%}
    </ul>
    </li>
    {% endfor -%}
    {% set depth=d[0] -%}
    {% endif -%}
    <li>
      <span {% if ldaptree.childs(d[2]) -%}class="linked"{% endif -%}
        onclick="toggle(this, 'childs')">dn: {{ d[2]|e }}</span>
      <button onclick="toggle(this, 'attributes')">[Attributes]</button>
      <ul class="attributes">
    {% for k in ldaptree.node(d[2]).keys() -%}
    {% if ldaptree.node(d[2]) is string -%}
    <li>{{ k }}: {{ ldaptree.node(d[2])[k]|e }}</li>
    {% else -%}
    {% for v in ldaptree.node(d[2])[k] -%}
    <li>{{ k }}: {{ v|e }}</li>
    {% endfor -%}
    {% endif -%}
    {% endfor -%}
      </ul>
    {% endfor -%}
    </ul>
  </body>
</html>
<!-- vim: set et ts=2 sw=2: -->