build_html_user_index.sh 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. #!/bin/sh
  2. #generates user addon HTML man pages docs/html/index.html
  3. # Markus Neteler, 2003, 2004, 2005, 2006
  4. # William Kyngesburye:
  5. # This one builds the addon index, from both the global
  6. # /Library/GRASS/$GRASS_MMVER/Modules and the user's
  7. # $HOME/Library/$GRASS_MMVER/GRASS/Modules
  8. # Each is in their own section, in the same index file.
  9. #
  10. # global help pages are symlinked to the user dir, so user doesn't need perms
  11. # to write there for redirects.
  12. # main and section indexes from GRASS.app are redirected from user dir, not
  13. # symlinked, so relative paths stay valid.
  14. ############# nothing to configure below ############
  15. # $1 is current path to GRASS.app/Contents/MacOS, defaults to /Applications
  16. if [ "$1" != "" ] ; then
  17. GISBASE=$1
  18. else
  19. GISBASE="/Applications/GRASS-$GRASS_MMVER.app/Contents/MacOS"
  20. fi
  21. GRASS_MMVER=`cut -d . -f 1-2 "$GISBASE/etc/VERSIONNUMBER"`
  22. GRASSVERSION=`cat "$GISBASE/etc/VERSIONNUMBER"`
  23. HTMLDIR="$GISBASE_USER/Modules/docs/html"
  24. HTMLDIRG="$GISBASE_SYSTEM/Modules/docs/html"
  25. write_html_header()
  26. {
  27. # $1: filename
  28. # $2: page title
  29. # $3: is it main index
  30. echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">
  31. <html>
  32. <head>
  33. <title>$2</title>
  34. <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">
  35. <meta name=\"Author\" content=\"GRASS Development Team\">" > $1
  36. if [ "$3" ] ; then
  37. echo " <meta name=\"AppleTitle\" content=\"$2\">
  38. <meta name=\"AppleIcon\" content=\"GRASS-$GRASS_MMVER/grass_icon.png\">
  39. <meta name=\"robots\" content=\"anchors\">" >> $1
  40. fi
  41. echo " <link rel=\"stylesheet\" href=\"grassdocs.css\" type=\"text/css\">
  42. </head>
  43. <body bgcolor=\"#FFFFFF\">
  44. <img src=\"grass_logo.png\" alt=\"GRASS logo\"><hr align=center size=6 noshade>
  45. <h2>GRASS GIS $GRASSVERSION Reference Manual</h2>
  46. <p>Geographic Resources Analysis Support System, commonly referred to as
  47. <a href=\"http://grass.osgeo.org\">GRASS</a>,
  48. is a Geographic Information System (GIS) used for geospatial data management
  49. and analysis, image processing, graphics/maps production, spatial modeling,
  50. and visualization. GRASS is currently used in academic and commercial settings
  51. around the world, as well as by many governmental agencies and environmental
  52. consulting companies.</p>
  53. <p>This reference manual details the use of modules distributed with
  54. Geographic Resources Analysis Support System (GRASS), an open source (GNU
  55. GPL'ed), image processing and geographic information system (GIS).</p>
  56. " >> $1
  57. }
  58. write_html_footer()
  59. {
  60. # $1: filename
  61. echo "<hr>" >> $1
  62. echo "<p><a href=\"$GISBASE/docs/html/index.html\">Help Index</a> | <a href=\"$GISBASE/docs/html/full_index.html\">Full Index</a> | <a href=\"$HTMLDIR/addon_index.html\">Addon Index</a><br>" >> $1
  63. echo "&copy; 2003-2008 <a href=\"http://grass.osgeo.org\">GRASS Development Team</a></p>" >> $1
  64. echo "</body>" >> $1
  65. echo "</html>" >> $1
  66. }
  67. FULLINDEX=addon_index.html
  68. ################
  69. echo "Rebuilding Addon HTML manual pages index..."
  70. #copy over CSS:
  71. cp -f "$GISBASE/docs/html/grassdocs.css" "$HTMLDIR/"
  72. #copy over GRASS logo:
  73. cp -f "$GISBASE/docs/html/grass_logo.png" "$HTMLDIR/"
  74. cp -f "$GISBASE/docs/html/grass_icon.png" "$HTMLDIR/"
  75. #process all global HTML pages:
  76. if [ -d "$HTMLDIRG" ] ; then
  77. cd "$HTMLDIRG"
  78. #get list of available GRASS modules:
  79. CMDLISTG=`ls -1 *.*.html 2> /dev/null | grep -v index.html | cut -d'.' -f1 | sort -u`
  80. else
  81. CMDLISTG=""
  82. fi
  83. #process all user HTML pages:
  84. cd "$HTMLDIR"
  85. # don't really need to delete these, as removed global modules won't get indexed,
  86. # though old symlinks will accumulate. I'm just worried about wildcard deletes.
  87. #rm -f global_*.html
  88. #get list of available GRASS modules:
  89. CMDLIST=`ls -1 *.*.html 2> /dev/null | grep -v index.html | cut -d'.' -f1 | sort -u`
  90. #write main index:
  91. #echo "Generating HTML manual pages index (help system)..."
  92. write_html_header $FULLINDEX "GRASS GIS $GRASSVERSION Addon Reference Manual" 1
  93. echo "<p>Command guide:</p>" >> $FULLINDEX
  94. echo "<table border=0>" >> $FULLINDEX
  95. echo "<tr><td>&nbsp;&nbsp;d.* </td><td>display commands</td><td>&nbsp;&nbsp;ps.* </td><td>postscript commands</td></tr>" >> $FULLINDEX
  96. echo "<tr><td>&nbsp;&nbsp;db.* </td><td>database commands</td><td>&nbsp;&nbsp;r.* </td><td>raster commands</td></tr>" >> $FULLINDEX
  97. echo "<tr><td>&nbsp;&nbsp;g.* </td><td>general commands</td><td>&nbsp;&nbsp;r3.* </td><td>raster3D commands</td></tr>" >> $FULLINDEX
  98. echo "<tr><td>&nbsp;&nbsp;i.* </td><td>imagery commands</td><td>&nbsp;&nbsp;v.* </td><td>vector commands</td></tr>" >> $FULLINDEX
  99. echo "<tr><td>&nbsp;&nbsp;m.* </td><td>miscellaneous commands</td></tr>" >> $FULLINDEX
  100. echo "</table>" >> $FULLINDEX
  101. # global commands:
  102. echo "<h3>Global addon command index:</h3>" >> $FULLINDEX
  103. echo "<table>" >> $FULLINDEX
  104. if [ "$CMDLISTG" = "" ] ; then
  105. echo "<tr><td valign=\"top\"><td>[There are no global addon help pages.]</td></tr>" >> $FULLINDEX
  106. else
  107. for i in $CMDLISTG
  108. do
  109. cd "$HTMLDIRG"
  110. CMDLISTI="`ls -1 $i.*.html`"
  111. cd "$HTMLDIR"
  112. for i in $CMDLISTI
  113. do
  114. BASENAME=`basename $i .html`
  115. SHORTDESC="`cat "$HTMLDIRG/$i" | awk '/NAME/,/SYNOPSIS/' | grep '<em>' | cut -d'-' -f2- | sed 's+^ ++g' | grep -vi 'SYNOPSIS' | head -n 1`"
  116. # echo "<tr><td valign=\"top\"><a href=\"$HTMLDIRG/$i\">$BASENAME</a></td> <td>$SHORTDESC</td></tr>" >> $FULLINDEX
  117. # make them local to user to simplify page links
  118. echo "<tr><td valign=\"top\"><a href=\"global_$i\">$BASENAME</a></td> <td>$SHORTDESC</td></tr>" >> $FULLINDEX
  119. ln -sf "$HTMLDIRG/$i" global_$i
  120. done
  121. done
  122. fi
  123. echo "</table>" >> $FULLINDEX
  124. # user commands:
  125. echo "<h3>User addon command index:</h3>" >> $FULLINDEX
  126. echo "<table>" >> $FULLINDEX
  127. if [ "$CMDLIST" = "" ] ; then
  128. echo "<tr><td valign=\"top\"><td>[There are no user addon help pages.]</td></tr>" >> $FULLINDEX
  129. else
  130. for i in $CMDLIST
  131. do
  132. for i in `ls -1 $i.*.html`
  133. do
  134. BASENAME=`basename $i .html`
  135. SHORTDESC="`cat $i | awk '/NAME/,/SYNOPSIS/' | grep '<em>' | cut -d'-' -f2- | sed 's+^ ++g' | grep -vi 'SYNOPSIS' | head -n 1`"
  136. echo "<tr><td valign="top"><a href=\"$i\">$BASENAME</a></td> <td>$SHORTDESC</td></tr>" >> $FULLINDEX
  137. done
  138. done
  139. fi
  140. echo "</table>" >> $FULLINDEX
  141. write_html_footer $FULLINDEX
  142. # done full index
  143. # user redirects to app dir for main index files
  144. for i in index full_index display database general imagery misc postscript raster raster3D vector
  145. do
  146. echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">
  147. <html>
  148. <head>
  149. <title></title>
  150. <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">
  151. <meta http-equiv=\"Refresh\" content=\"0; $GISBASE/docs/html/$i.html\">
  152. </head>
  153. <body>
  154. </body>
  155. </html>" > $i.html
  156. done
  157. # add Help Viewer link in user docs folder
  158. ln -sfh ../../GRASS/$GRASS_MMVER/Modules/docs/html $HOME/Library/Documentation/Help/GRASS-$GRASS_MMVER