<% #main %>
<h1>
   <% response.title %>
   <% members.link add ' ' class='uk-icon-button uk-icon-plus uk-text-middle' %>
</h1>
<% members.link . <% gettext All %> %>
<% members.link subscribers <% gettext Subscribers %> prefix='| ' %>
<% members.link contributors <% gettext Contributors %> prefix="| " %>
<% members.link managers <% gettext Managers %> prefix="| " %>
<% members.link owners <% gettext Owners %> prefix="| " %>
<% response.pager %>
<table class='uk-table uk-table-striped uk-table-hover uk-table-condensed'>
   <thead>
      <tr>
         <td><% gettext Name %></td>
         <td><% gettext Role %></td>
         <td><% gettext Subscribed %></td>
         <td></td>
      </tr>
   </thead>
   <tbody>
      <% response.list %>
   </tbody>
</table>
<% response.pager %>

<% #login %>
<h1><% response.title %></h1>
<form class='uk-form uk-form-stacked' id="login" method="post" action="<% response.action %>">
   <input type="hidden" name="digest" id="digest" />
   <div class='uk-form-row'>
      <label class='uk-form-label' for='name'>
         <% gettext Username %>
      </label>
      <div class='uk-form-controls'>
         <input name="name" id="name" tabindex=1 value="<% request.name encoding="form" %>" class='uk-width-1-2' required>
         <button class='uk-button uk-button-link'>
            <% members.link register <% gettext "Not registered yet\?" %> tabindex=6 %>
         </button>
      </div>
   </div>
   <div class='uk-form-row'>
      <label class='uk-form-label' for='password'>
         <% gettext Password %>
      </label>
      <div class='uk-form-controls uk-form-password uk-width-1-2'>
         <input type="password" name="password" id="password" class='uk-width-1-1' tabindex=2 required>
         <a href='' class='uk-form-password-toggle' data-uk-form-password="{
            lblHide: '<% gettext Hide %>'
         }"><% gettext Show %></a>
      </div>
      <button class='uk-button uk-button-link'>
         <% members.link reset <% gettext 'Password forgotten\?' %> tabindex="7" %>
      </button>
   </div>
   <div class='uk-form-row'>
      <label class='uk-form-label' for='remember'>
         <input type="checkbox" id="remember" name="remember" tabindex="3" <% if <% request.remember %> is on then 'checked="checked"' %> >
         <% gettext "Remember Login" %>
      </label>
   </div>
   <div class='uk-form-row'>
      <fieldset>
         <legend><% gettext Connections %></legend>
         <% trail Connect prefix='' suffix='' %>
      </fieldset>
   </div>
   <div class='uk-form-row'>
      <input hidden name='login' value='1'>
      <button class='uk-button uk-button-primary' type="submit" tabindex=4>
         <% gettext Login context=verb %>
      </button>
      <a href="" class="uk-button uk-button-link cancel" tabindex=5><% gettext Cancel %></a>
   </div>
</form>
<script type="text/javascript">
$(function() {
   $("form#login").on('submit', function (event) {
      var name = $("#name").val();
      $.ajax({
         async: false,
         url: '<% members.href salt.txt %>',
         data: "user=" + encodeURIComponent(name),
         dataType: "text",
         cache: false,
         error: function() { /* ... */ },
         success: function(salt, status, xhr) {
            var password = $("#password").val();
            var token = "<% session.token %>";
            $("input:password").val("");
            $("#digest").val($.md5($.md5(password + salt) + token));
         }
      });
      return true;
   });
});
</script>

<% #register %>
<h1><% response.title %></h1>
<form class='uk-form uk-form-stacked' id="register" method="post" action="<% response.action %>">
   <input type="hidden" name="hash" id="hash" />
   <div class='uk-form-row'>
      <label class='uk-form-label' for='name'>
         <% gettext Username %>
      </label>
      <div class='uk-form-controls'>
         <input type="text" name="name" id="name" maxlength=25 value="<% request.name encoding="form" %>" class=uk-width-1-2>
      </div>
   </div>
   <div class='uk-form-row'>
      <label class='uk-form-label' for='email'>
         <% gettext e-mail %>
      </label>
      <div class='uk-form-controls'>
         <input type="email" name="email" id="email" value="<% request.email encoding="form" %>" class=uk-width-1-2>
      </div>
   </div>
   <div class='uk-form-row'>
      <label class='uk-form-label' for='password'>
         <% gettext Password %>
      </label>
      <div class='uk-form-controls uk-form-password uk-width-1-2'>
         <input type="password" name="password" id="password" class='uk-width-1-1' tabindex=2>
         <a href='' class='uk-form-password-toggle' data-uk-form-password="{
            lblHide: '<% gettext Hide %>'
         }"><% gettext Show %></a>
      </div>
   </div>
   <div class='uk-form-row uk-margin-top'>
      <button class='uk-button uk-button-primary' type="submit" id="submit" name="register" value="1">
         <% gettext Register %>
      </button>
      <a href="" class="uk-button uk-button-link cancel"><% gettext Cancel %></a>
   </div>
</form>
<script type="text/javascript">
$(function() {
   $("form#register").submit(function() {
      var token = "<% session.token %>";
      var password = $("#password").val();
      var passwordConfirm = $("#passwordConfirm").val();
      $("input:password").val("");
      // Check both passwords but let the server do the error handling
      if (!password || !passwordConfirm) {
         return true;
      } else if (password !== passwordConfirm) {
         $("#password").val(0);
         $("#passwordConfirm").val(1);
         return true;
      }
      var hash = $.md5(password + token);
      $("#hash").val(hash);
      return true;
   });
});
</script>

<% #reset %>
<h1><% response.title %></h1>
<div class='uk-text-small'>
   <% gettext "Enter your username and the e-mail address you have used when you registered. You will then receive a confirmation e-mail containing further instructions." %>
</div>
<form class='uk-margin-top uk-form uk-form-stacked' id="login" method="post" action="<% response.action %>">
   <div class='uk-form-row'>
      <label class='uk-form-label' for='username'>
         <% gettext Username %>
      </label>
      <input type="text" name="name" id="name" tabindex="1" value="<% request.name encoding="form" %>" class='uk-width-1-2'>
   </div>
   <div class='uk-form-row'>
      <label class='uk-form-label' for='email'>
         <% gettext E-mail %>
      </label>
      <input type="email" name="email" id="email" tabindex="2" value="<% request.email encoding="form" %>" class='uk-width-1-2'>
   </div>
   <div class='uk-form-row uk-margin-top'>
      <button class='uk-button uk-button-primary' type="submit" id="submit" name="reset" value="1" tabindex="4"><% gettext "Send Request" %></button>
      <a href="" class="uk-button uk-button-link cancel"><% gettext Cancel %></a>
   </div>
</form>

<% #password %>
<h1><% response.title %></h1>
<form class='uk-form uk-form-stacked' id="login" method="post" action="<% response.action %>">
   <div class='uk-form-row'>
      <div class='uk-form-controls uk-form-password uk-width-1-2'>
         <input type="password" name="password" id="password" class='uk-width-1-1'>
         <a href='' class='uk-form-password-toggle' data-uk-form-password="{
            lblHide: '<% gettext Hide %>'
         }"><% gettext Show %></a>
      </div>
   </div>
   <div class='uk-form-row'>
      <button class='uk-button uk-button-primary' type="submit" id="submit" name="save" value="1" tabindex="4"><% gettext Save %></button>
      <a href="" class="uk-button uk-button-link cancel"><% gettext Cancel %></a>
   </div>
</form>

<% #add %>
<h1><% response.title %></h1>
<form class='uk-form uk-form-stacked' method='post' action='<% response.action %>'>
   <div class='uk-form-row'>
      <div class='uk-form-label'>
         <% gettext Username %>
         <i class='uk-icon-info-circle uk-text-muted' data-uk-tooltip="{pos: 'bottom'}" title='<% gettext 'You can use the asterisk * as wildcard.' %>'></i>
      </div>
      <div class='uk-form-controls'>
         <input type='text' name='term' id='term' value='<% request.term encoding='form' %>' class='uk-width-1-2' required>
         <button class='uk-button uk-button-primary' type='submit' id='submit' name='Find' value='1'>
            <% gettext Find %>
         </button>
         <a href='<% members.href %>' class='uk-button uk-button-link'><% gettext Cancel %></a>
      </div>
   </div>
</form>
<p>
   <% if <% response.count %> is null then '' else <% ngettext 'Showing {0} result' 'Showing {0} results' <% response.count %> suffix=. %> %>
</p>
<% response.result %>

<% #results %>
<table class='uk-table uk-table-striped uk-table-hover uk-table-condensed'>
   <thead>
      <tr>
         <td><% gettext Name %></td>
         <td><% gettext Registered %></td>
         <td></td>
      </tr>
   </thead>
   <tbody>
      <% param.result %>
   </tbody>
</table>

<% #result %>
<tr>
   <td class='uk-text-bold'><% param.name %></td>
   <td><% param.created %></td>
   <td class='uk-text-right'>
      <a href='?name=<% param.name encoding=form %>'><i class='uk-icon-plus'></i></a>
   </td>
</tr>
