Difference between revisions of "Wiki2html"

From VNUML-WIKI
Jump to: navigation, search
(vnuml-clean-web script)
Line 45: Line 45:
 
# get a list of files, excluding directories
 
# get a list of files, excluding directories
 
FILES=`ls -F1 | sed -e 's/.*\///'`
 
FILES=`ls -F1 | sed -e 's/.*\///'`
 +
 +
 +
# Options?
 +
DOCONLY="no"
 +
NODOCINTRO="no"
 +
while :
 +
do
 +
    case $# in
 +
        0)      break;;
 +
        *)      case "$1" in
 +
 +
                    "--doc-only")
 +
                        DOCONLY="yes"
 +
                        shift
 +
                        ;;
 +
 +
                    "--without-docintro")
 +
                        NODOCINTRO="yes"
 +
                        shift
 +
                        ;;
 +
 +
                    *)
 +
                        echo "Error: unknown command line option (\"$1\")"
 +
                        exit 1
 +
                        ;;
 +
 +
                    "") break;;
 +
 +
                esac
 +
    esac
 +
done
 +
 +
echo "DOCONLY=$DOCONLY"
 +
echo "NODOCINTRO=$NODOCINTRO"
  
 
# Process each file
 
# Process each file
Line 58: Line 92:
 
     gsub("<!-- BEGINTOOLBOX -->.*<!-- ENDTOOLBOX -->", "", $0);
 
     gsub("<!-- BEGINTOOLBOX -->.*<!-- ENDTOOLBOX -->", "", $0);
 
     print $0
 
     print $0
   }' > $X
+
   }' | \
 +
  sed -e '/Redirected from/ d' \
 +
  > $X
  
   if [ "$1" == "--doc-only" ]; then
+
   if [ "$DOCONLY" == "yes" ]; then
 
     # Remove navigation menu
 
     # Remove navigation menu
 
     cp $X $X.tmp
 
     cp $X $X.tmp
Line 72: Line 108:
 
     }' > $X
 
     }' > $X
 
   fi
 
   fi
 +
 +
  if [ "$NODOCINTRO" == "yes" ]; then
 +
      # Removes Introduction entry in Documentation menu
 +
      cp $X $X.tmp
 +
 +
      cat $X.tmp | \
 +
      sed -e '/n-Introduction/ d' | sed -e '/n-Documentation/ d'  \
 +
      > $X
 +
 +
  fi
 +
 
   rm $X.tmp
 
   rm $X.tmp
  
Line 82: Line 129:
 
echo ".editsection { visibility: hidden }" >> $CSSFILE
 
echo ".editsection { visibility: hidden }" >> $CSSFILE
 
cd ../../index.php
 
cd ../../index.php
 
</pre>
 
 
Old version:
 
 
<pre>
 
#!/bin/bash
 
 
for X in *
 
do
 
  echo "Filtering file $X"
 
  cp $X $X.tmp
 
  cat $X.tmp                                        | \
 
  sed -e '/BEGINMENU/,/ENDMENU/d'                  | \
 
  sed -e '/BEGINSEARCH/,/ENDSEARCH/d'              | \
 
  sed -e '/BEGINPERSONALTOOLS/,/ENDPERSONALTOOLS/d' | \
 
  sed -e '/BEGINTOOLBOX2/,/ENDTOOLBOX2/d'          | \
 
  sed -e 's/<span class="editsection">.*]<\/span>//g' \
 
    > $X
 
  rm $X.tmp
 
 
done
 
 
</pre>
 
</pre>

Revision as of 13:06, 24 May 2007

How to generate a local copy of the documentation in html starting from the VNUML wiki

Tested on Suse linux, although it should work on any distribution.

  1. Download and install htttrack from http://www.httrack.com/
  2. Get a copy of VNUML wiki:
  3.  mkdir vnumlweb
     cd vnumlweb
     httrack http://www.dit.upm.es/vnumlwiki/   
     # Note: Don't forget the  "/" at the end of the URL!
    
  4. Create a script named vnuml-clean-web with the content shown below.
  5. Execute that script on the directory where the main files reside, that is:
  6.  cd www.dit.upm.es/vnuml
     cd index.php
     vnuml-clean-web
    

    Use "--doc-only" option if you want to eliminate the "Navigation" menu on the left side of the pages.

  7. Delete the auxiliary files httrack generates in upper directory (it seems they are not needed):
  8.  cd ..
     rm index????*.{html,css,php} opensearch_desc.php 
    
  9. Load the index.html file in www.dit.upm.es/vnuml directory and you will have access to the local copy of the documentation.

vnuml-clean-web script

#!/bin/bash

# get a list of files, excluding directories
FILES=`ls -F1 | sed -e 's/.*\///'`


# Options?
DOCONLY="no"
NODOCINTRO="no"
while :
do
    case $# in
        0)      break;;
        *)      case "$1" in

                    "--doc-only")
                        DOCONLY="yes"
                        shift
                        ;;

                    "--without-docintro")
                        NODOCINTRO="yes"
                        shift
                        ;;

                    *)
                        echo "Error: unknown command line option (\"$1\")"
                        exit 1
                        ;;

                    "") break;;

                 esac
    esac
done

echo "DOCONLY=$DOCONLY"
echo "NODOCINTRO=$NODOCINTRO"

# Process each file
for X in $FILES
do
  echo "Filtering file $X"
  cp $X $X.tmp
  cat $X.tmp | \
  awk 'BEGIN {RS="" } {
    gsub("<!-- BEGINMENU -->.*<!-- ENDMENU -->", "", $0);
    gsub("<!-- BEGINSEARCH -->.*<!-- ENDSEARCH -->", "", $0);
    gsub("<!-- BEGINPERSONALTOOLS -->.*<!-- ENDPERSONALTOOLS -->", "", $0);
    gsub("<!-- BEGINTOOLBOX -->.*<!-- ENDTOOLBOX -->", "", $0);
    print $0
  }' | \
  sed -e '/Redirected from/ d' \
  > $X

  if [ "$DOCONLY" == "yes" ]; then
    # Remove navigation menu
    cp $X $X.tmp
    cat $X.tmp | \
    awk 'BEGIN {RS="" } {
      # delete navigation sidebar
      gsub("<div class=\047portlet\047 id=\047p-navigation\047>.*<!-- ENDSIDEBAR p-navigation -->", "", $0);
      # change image link from Main_Page to Docintro.html
      gsub("<a href=\"Main_Page.html\" id=\"home\"><i>Home</i></a>", "<a href=\"Docintro.html\" id=\"home\"><i>Home</i></a>", $0);
      print $0
    }' > $X
  fi

  if [ "$NODOCINTRO" == "yes" ]; then
      # Removes Introduction entry in Documentation menu
      cp $X $X.tmp

      cat $X.tmp | \
      sed -e '/n-Introduction/ d' | sed -e '/n-Documentation/ d'  \
      > $X

  fi

  rm $X.tmp

done

cd ../skins/fratman_enhanced
# get css file name
CSSFILE=`ls main????.css`
echo "Changing style sheet: $CSSFILE"
echo ".editsection { visibility: hidden }" >> $CSSFILE
cd ../../index.php