% This LaTeX document was generated using the LaTeX backend of PlDoc,
% The SWI-Prolog documentation system



\subsection{library(http/http_dirindex): HTTP directory listings}

\label{sec:httpdirindex}

\begin{tags}
    \tag{To be done}
Provide more options (sorting, selecting columns, hiding files)
\end{tags}

This module provides a simple API to generate an index for a physical
directory. The index can be customised by overruling the dirindex.css
CSS file and by defining additional rules for icons using the hook
\qpredref{http}{file_extension_icon}{2}.\vspace{0.7cm}

\begin{description}
    \predicate[det]{http_reply_dirindex}{3}{+DirSpec, +Options, +Request}
Provide a directory listing for \arg{Request}, assuming it is an index
for the physical directrory Dir. If the request-path does not
end with /, first return a moved (301 Moved Permanently) reply.

The calling conventions allows for direct calling from
\predref{http_handler}{3}.

    \dcg[det]{directory_index}{2}{+Dir, +Options}
Show index for a directory. \arg{Options} processed:

\begin{description}
    \termitem{order_by}{+Field}
Sort the files in the directory listing by \arg{Field}. \arg{Field}
is one of \const{name} (default), \const{size} or \const{time}.
    \termitem{order}{+AscentDescent}
Sorting order. Default is \const{ascending}. The altenative is
\const{descending}
\end{description}

\qpredicate[nondet,multifile]{http}{mime_type_icon}{2}{+MimeType, -IconName}Multi-file hook predicate that can be used to associate icons to
files listed by \predref{http_reply_dirindex}{3}. The actual icon file is
located by \verb$absolute_file_name(icons(IconName), Path, [])$.

\begin{tags}
    \tag{See also}
\predref{serve_files_in_directory}{2} serves the images.
\end{tags}
\end{description}

