Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91488132
mkhtmlindex.sh
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Nov 11, 14:59
Size
2 KB
Mime Type
text/x-shellscript
Expires
Wed, Nov 13, 14:59 (2 d)
Engine
blob
Format
Raw Data
Handle
22270009
Attached To
rLAMMPS lammps
mkhtmlindex.sh
View Options
#!/bin/bash
if [ $# -lt 1 ]
then
echo "usage: $0 <list of directory trees to be indexed>"
exit 1
fi
for d in $(find "$@" -type d -print)
do \
dir=$(basename $d)
uplink=index.html
[ $dir == windows ] && uplink=windows.html
# index file header
cat > "$d/index.html" <<EOF
<html>
<head><title>LAMMPS-ICMS Binaries Repository: $d</title>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-12573382-3']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body style="font-family: mono, fixed, sans; margin-bottom: 2%; margin-top: 2%; margin-left: 5%; margin-right: 5%;">
<h1>LAMMPS-ICMS Binaries Repository: $d</h1>
<h2>Contents of $dir</h2>
<hr>
<table>
<tbody>
<tr><th>[DIR]</th><th></th><th align="left"> <a href="../${uplink}">(Up one level)</a></th></tr>
EOF
# first all directory entries
for e in $(/bin/ls -1 "$d")
do [ "$e" = "repodata" ] && continue
[ "$e" = "drpms" ] && continue
[ "$e" = "cache" ] && continue
if [ -d "$d/$e" ]
then
echo '<tr><td>[DIR]</td><td></td>' >> "$d/index.html"
echo "<td> <a href=\"$e/index.html\"> $e</a></td></tr>" >> "$d/index.html"
fi
done
# then all file entries
for e in $(/bin/ls -1r "$d")
do [ "$e" = "index.html" ] && continue
if [ -f "$d/$e" ]
then
echo '<tr><td>' >> "$d/index.html"
ls -lh "$d/$e" | cut -d \ -f 6-7 >> "$d/index.html"
echo "</td><td> <a href=\"$e\"> $e</a></td></tr>" >> "$d/index.html"
fi
done
# footer
cat >> "$d/index.html" <<EOF
</table>
</body>
</html>
EOF
done
Event Timeline
Log In to Comment