Rmoved trash.sh.
[scripts.git] / dirtohtml.sh
1 #!/bin/bash
2
3 #########################################################################
4 # This program is free software: you can redistribute it and/or modify  #
5 # it under the terms of the version 3 of the GNU General Public License #
6 # as published by the Free Software Foundation.                         #
7 #                                                                       #
8 # This program is distributed in the hope that it will be useful, but   #
9 # WITHOUT ANY WARRANTY; without even the implied warranty of            #
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      #
11 # General Public License for more details.                              #
12 #                                                                       #
13 # You should have received a copy of the GNU General Public License     #
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.  #
15 #                                                                       #
16 # Written by and Copyright (C) Francois Fleuret                         #
17 # Contact <francois@fleuret.org> for comments & bug reports             #
18 #########################################################################
19
20 function error () {
21     echo $1 1>&2
22     exit 1
23 }
24
25 ## Header ############################################################
26
27 cat <<EOF
28 <?xml version="1.0" encoding="utf-8"?>
29 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
30
31 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
32
33 <head>
34 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
35 <title></title>
36 </head>
37
38 <body>
39
40 EOF
41
42 ## Body ##############################################################
43
44 echo "<h1>Directory content</h1>"
45
46 echo
47
48 echo "<pre>"
49
50 for d in $(find . -maxdepth 1 -type d -name "[^.]?*" | sort); do
51     echo "<a href=\"${d}\">${d}</a>"
52
53     # most_recent=$(find ${d} -type f -exec stat --printf="%Y %n\n" '{}' \; | sort | tail -1 | awk '{print $4}')
54
55     # if [[ ${most_recent} ]]; then
56         # date=$(date -r ${most_recent})
57     # else
58         # date=$(date -r ${d})
59     # fi
60
61     # echo "${date} <a href=\"${d}\">${d}</a>"
62 done
63
64 echo "</pre>"
65
66 echo
67
68 ## Footer ############################################################
69
70 cat <<EOF
71 </body>
72
73 </html>
74 EOF
75
76 ######################################################################