build_html_user_index.sh 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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\">
  45. <hr class=\"header\">
  46. <h2>GRASS GIS $GRASSVERSION Reference Manual</h2>
  47. <p>Geographic Resources Analysis Support System, commonly referred to as
  48. <a href=\"https://grass.osgeo.org\">GRASS</a>,
  49. is a Geographic Information System (GIS) used for geospatial data management
  50. and analysis, image processing, graphics/maps production, spatial modeling,
  51. and visualization. GRASS is currently used in academic and commercial settings
  52. around the world, as well as by many governmental agencies and environmental
  53. consulting companies.</p>
  54. <p>This reference manual details the use of modules distributed with
  55. Geographic Resources Analysis Support System (GRASS), an open source (GNU
  56. GPL'ed), image processing and geographic information system (GIS).</p>
  57. " >> $1
  58. }
  59. write_html_footer()
  60. {
  61. # $1: filename
  62. echo "<hr class=\"header\">" >> $1
  63. 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
  64. echo "&copy; 2003-2008 <a href=\"https://grass.osgeo.org\">GRASS Development Team</a></p>" >> $1
  65. echo "</body>" >> $1
  66. echo "</html>" >> $1
  67. }
  68. FULLINDEX=addon_index.html
  69. ################
  70. echo "Rebuilding Addon HTML manual pages index..."
  71. #copy over CSS:
  72. cp -f "$GISBASE/docs/html/grassdocs.css" "$HTMLDIR/"
  73. #copy over GRASS logo:
  74. cp -f "$GISBASE/docs/html/grass_logo.png" "$HTMLDIR/"
  75. cp -f "$GISBASE/docs/html/grass_icon.png" "$HTMLDIR/"
  76. #process all global HTML pages:
  77. if [ -d "$HTMLDIRG" ] ; then
  78. cd "$HTMLDIRG"
  79. #get list of available GRASS modules:
  80. CMDLISTG=`ls -1 *.*.html 2> /dev/null | grep -v index.html | cut -d'.' -f1 | sort -u`
  81. else
  82. CMDLISTG=""
  83. fi
  84. #process all user HTML pages:
  85. cd "$HTMLDIR"
  86. # don't really need to delete these, as removed global modules won't get indexed,
  87. # though old symlinks will accumulate. I'm just worried about wildcard deletes.
  88. #rm -f global_*.html
  89. #get list of available GRASS modules:
  90. CMDLIST=`ls -1 *.*.html 2> /dev/null | grep -v index.html | cut -d'.' -f1 | sort -u`
  91. #write main index:
  92. #echo "Generating HTML manual pages index (help system)..."
  93. write_html_header $FULLINDEX "GRASS GIS $GRASSVERSION Addon Reference Manual" 1
  94. echo "<p>Command guide:</p>" >> $FULLINDEX
  95. echo "<table border=0>" >> $FULLINDEX
  96. echo "<tr><td>&nbsp;&nbsp;d.* </td><td>display commands</td><td>&nbsp;&nbsp;ps.* </td><td>postscript commands</td></tr>" >> $FULLINDEX
  97. echo "<tr><td>&nbsp;&nbsp;db.* </td><td>database commands</td><td>&nbsp;&nbsp;r.* </td><td>raster commands</td></tr>" >> $FULLINDEX
  98. echo "<tr><td>&nbsp;&nbsp;g.* </td><td>general commands</td><td>&nbsp;&nbsp;r3.* </td><td>raster3D commands</td></tr>" >> $FULLINDEX
  99. echo "<tr><td>&nbsp;&nbsp;i.* </td><td>imagery commands</td><td>&nbsp;&nbsp;v.* </td><td>vector commands</td></tr>" >> $FULLINDEX
  100. echo "<tr><td>&nbsp;&nbsp;m.* </td><td>miscellaneous commands</td></tr>" >> $FULLINDEX
  101. echo "</table>" >> $FULLINDEX
  102. # global commands:
  103. echo "<h3>Global addon command index:</h3>" >> $FULLINDEX
  104. echo "<table>" >> $FULLINDEX
  105. if [ "$CMDLISTG" = "" ] ; then
  106. echo "<tr><td valign=\"top\"><td>[There are no global addon help pages.]</td></tr>" >> $FULLINDEX
  107. else
  108. for i in $CMDLISTG
  109. do
  110. cd "$HTMLDIRG"
  111. CMDLISTI="`ls -1 $i.*.html`"
  112. cd "$HTMLDIR"
  113. for i in $CMDLISTI
  114. do
  115. BASENAME=`basename $i .html`
  116. SHORTDESC="`cat "$HTMLDIRG/$i" | awk '/NAME/,/SYNOPSIS/' | grep '<em>' | cut -d'-' -f2- | sed 's+^ ++g' | grep -vi 'SYNOPSIS' | head -n 1`"
  117. # echo "<tr><td valign=\"top\"><a href=\"$HTMLDIRG/$i\">$BASENAME</a></td> <td>$SHORTDESC</td></tr>" >> $FULLINDEX
  118. # make them local to user to simplify page links
  119. echo "<tr><td valign=\"top\"><a href=\"global_$i\">$BASENAME</a></td> <td>$SHORTDESC</td></tr>" >> $FULLINDEX
  120. ln -sf "$HTMLDIRG/$i" global_$i
  121. done
  122. done
  123. fi
  124. echo "</table>" >> $FULLINDEX
  125. # user commands:
  126. echo "<h3>User addon command index:</h3>" >> $FULLINDEX
  127. echo "<table>" >> $FULLINDEX
  128. if [ "$CMDLIST" = "" ] ; then
  129. echo "<tr><td valign=\"top\"><td>[There are no user addon help pages.]</td></tr>" >> $FULLINDEX
  130. else
  131. for i in $CMDLIST
  132. do
  133. for i in `ls -1 $i.*.html`
  134. do
  135. BASENAME=`basename $i .html`
  136. SHORTDESC="`cat $i | awk '/NAME/,/SYNOPSIS/' | grep '<em>' | cut -d'-' -f2- | sed 's+^ ++g' | grep -vi 'SYNOPSIS' | head -n 1`"
  137. echo "<tr><td valign="top"><a href=\"$i\">$BASENAME</a></td> <td>$SHORTDESC</td></tr>" >> $FULLINDEX
  138. done
  139. done
  140. fi
  141. echo "</table>" >> $FULLINDEX
  142. write_html_footer $FULLINDEX
  143. # done full index
  144. # user redirects to app dir for main index files
  145. for i in index full_index display database general imagery misc postscript raster raster3D vector
  146. do
  147. echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">
  148. <html>
  149. <head>
  150. <title></title>
  151. <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">
  152. <meta http-equiv=\"Refresh\" content=\"0; $GISBASE/docs/html/$i.html\">
  153. </head>
  154. <body>
  155. </body>
  156. </html>" > $i.html
  157. done
  158. # add Help Viewer links in user docs folder
  159. mkdir -p $HOME/Library/Documentation/Help/
  160. ln -sfh ../../GRASS/$GRASS_MMVER/Modules/docs/html $HOME/Library/Documentation/Help/GRASS-$GRASS_MMVER-addon
  161. ln -sfh $GISBASE/docs/html $HOME/Library/Documentation/Help/GRASS-$GRASS_MMVER