You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by ks...@apache.org on 2018/07/12 19:18:26 UTC

svn commit: r1835768 - /openoffice/devtools/scripts/auto-index.sh

Author: kschenk
Date: Thu Jul 12 19:18:26 2018
New Revision: 1835768

URL: http://svn.apache.org/viewvc?rev=1835768&view=rev
Log:
New version of directory index script.


Modified:
    openoffice/devtools/scripts/auto-index.sh

Modified: openoffice/devtools/scripts/auto-index.sh
URL: http://svn.apache.org/viewvc/openoffice/devtools/scripts/auto-index.sh?rev=1835768&r1=1835767&r2=1835768&view=diff
==============================================================================
--- openoffice/devtools/scripts/auto-index.sh (original)
+++ openoffice/devtools/scripts/auto-index.sh Thu Jul 12 19:18:26 2018
@@ -6,22 +6,73 @@
 # usage: auto-index [dir] [filetype] [title]
 if [ $# -eq 0 ]; then
 	echo "Parameters: [directory to process] [filetypes to process] [title for index page]"
-	echo "[directory to process is MANDATORY]"
-exit;
+	echo "[directory to process] is mandatory"
+	echo "No parameters given: using current directory with html files and default title"
 fi
+FILETYPE="html"
+TITLE=$1
+if [ $2 ]; then FILETYPE = $2;  fi
+if [ $3 ]; then TITLE = $3;  fi
+
 cd $1
+echo "Now in " $1 
+read -p "OK?..."
 
-rm index.html;
+rm -f index.html
 
-INDEX=`ls -1 *.$2 | sed "s/^.*/      <li\>\<a\ href=\"&\"\>&\<\\/a\>\<\\/li\>/"`
-echo "<html>
-  <head><title>Index of $3</title></head>
+# Header info
+# begin new index page
+echo "
+ <html>
+  <head><title>Index of ${TITLE}</title></head>
   <body>
-    <h2>Index of $3</h2>
-    <hr>
-    <ui>
-$INDEX
-    <ui>
+    <h2>Index of ${TITLE}</h2>
+    <hr> " > TOP
+echo "Done with HEADER"
+
+
+# pick up directory entries first into DIR_INDEX array
+
+DIR_INDEX=$(ls -1 -d */ | sed -r "s/(^.*)\/$/<li\>\<a href=\"\1\">\1\<\\/a>\<\\/li\>/")
+echo "Done with DIR_INDEX"
+
+
+if [ "$DIR_INDEX" != "" ]; then
+echo "<ul style=\"list-style-type:square; font-size: 120%; font-weight:bold; text-transform:uppercase;\">
+	${DIR_INDEX}
+</ul>" >> TOP
+ 
+fi
+
+
+FILES=""
+# process plain html files in their own sub list
+FILES=`ls -1 *.${FILETYPE} 2>/dev/null | sed -r "s/^.*/      <li\>\<a\ href=\"&\"\>&\<\\/a\>\<\\/li\>/"`
+
+if [ "$FILES" != "" ]; then
+# print 
+echo "
+<ul>
+	 ${FILES} 
+</ul>" > BOTTOM
+fi
+
+
+
+echo "
   </body>
-</html>" > index.html;
+</html>" >> BOTTOM
+
+#Prepend header and dir info 
+TOP=${HEADER}${DIR_INDEX}
+
+cat TOP BOTTOM >> index.html 
+
+rm -f TOP BOTTOM
+
+
+
+
+
+