<!DOCTYPE html>
<html>
<head>
<% htmlbasepath = Plug.HTML.html_escape(basepath) %><meta charset="utf-8">
<title>Index of <%= htmlbasepath %></title>
<style type="text/css">
  td  { font-family: monospace; padding: 2px 3px; text-align: left;
        vertical-align: bottom; white-space: pre; }
  td:first-child { text-align: left; padding: 2px 10px 2px 3px; }
        table { border: 0; }
  #filetype { text-align: right; }
  #filesize { text-align: right; }
</style>
<base href="<%= htmlbasepath %>">
</head> 
<body>
<h1>Index of <%= htmlbasepath %></h1>
<%
  # Trim path if the path is at the top level
  trimmedpath = case htmlbasepath do
    "/" -> ""
    other -> other
  end
%>
<table>
<tr>
  <td></td>
  <td><a href="<%= trimmedpath %>/?sort=<%= map_sortopt["name"] %>">Name</a></td>
  <td><a href="<%= trimmedpath %>/?sort=<%= map_sortopt["mtime"] %>">Last Modified</a></td>
  <td id="filesize"><a href="<%= trimmedpath %>/?sort=<%= map_sortopt["size"] %>">Size</a></td>
</tr>
<tr><th colspan="4"><hr/></th></tr>
<%=
  # Do not show "parent directory" if the path is at the top level
  if trimmedpath !== "" do
"""
<tr><td id=\"filetype\">[..]</td>
  <td><a href=\"#{trimmedpath}/..\">Parent Directory</a></td>
  <td></td><td></td>
</tr>
"""
  else ""
  end %>
