DokuWiki

It's better when it's simple

User Tools

Site Tools


tips:offline-dokuwiki.sh

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Last revisionBoth sides next revision
tips:offline-dokuwiki.sh [2011-09-07 15:23] – very useful script - thank you 87.162.84.91tips:offline-dokuwiki.sh [2013-01-20 10:35] – [script] 79.192.205.84
Line 36: Line 36:
 ===== installation ===== ===== installation =====
  
-==== script ==== +==== Script ==== 
-download the following script and make it executable +Download the following script and make it executable: 
-<file bash offline-dokuwiki.sh> +[[https://raw.github.com/vonloxley/offline-dokuwiki/master/offline-dokuwiki.sh|offline-dokuwiki]].
-#!/bin/sh +
-# authorsamlt +
-# 20110221 +
- +
-# default values +
-DEF_HOSTNAME=mydoku.wiki.lan +
-#DEF_LOCATION=path/to/start +
-DEF_LOCATION=fullindex +
-USERNAME= +
-PASSWORD= +
-PROTO=http +
-DEF_DEPTH=2 +
-ADDITIONNAL_WGET_OPTS=${AWO} +
-PROGNAME=${0##*/+
- +
-show_help() { +
-   cat<<EOT +
- +
-NAME +
-   $PROGNAME: make an offline export of a dokuwiki documentation +
- +
-SYNOPSIS +
-   $PROGNAME options +
- +
-OPTIONS +
-   --login      username +
-   --passwd     password +
-   --ms-filenames +
-   --https +
-   --depth      number +
-   --hostname   doku.host.tld +
-   --location   path/to/start +
- +
-NOTES +
-   if not specified on the command line +
-      * username and password are empty +
-      * hostname defaults to '$DEF_HOSTNAME' +
-      * location defaults to '$DEF_LOCATION' +
- +
-EOT +
-+
- +
-while $# -gt 0 ]; do +
-   case "$1" in +
-      --login) +
-         shift +
-         USERNAME=$1 +
-         ;; +
-      --passwd) +
-         shift +
-         PASSWORD=$1 +
-         ;; +
-      --hostname) +
-         shift +
-         HOSTNAME=$1 +
-         ;; +
-      --depth) +
-         shift +
-         DEPTH=$1 +
-         ;; +
-      --location) +
-         shift +
-         LOCATION=$1 +
-         ;; +
-      --https+
-         PROTO=https +
-         ;; +
-      --ms-filenames) +
-         ADDITIONNAL_WGET_OPTS="$ADDITIONNAL_WGET_OPTS --restrict-file-names=windows" +
-         ;; +
-      --help) +
-         show_help +
-         exit +
-         ;; +
-   esac +
-   shift +
-done +
- +
-: ${DEPTH:=$DEF_DEPTH} +
-: ${HOSTNAME:=$DEF_HOSTNAME} +
-: ${LOCATION:=$DEF_LOCATION} +
- +
-PREFIX="$(date +'%Y%m%d')-$HOSTNAME" +
- +
-echo "[WGET] downloading: start: http://$HOSTNAME/$LOCATION (login/passwd=${USERNAME:-empty}/${PASSWORD:-empty})" +
-wget  --no-verbose \ +
-      --recursive \ +
-      --level="$DEPTH"+
-      --execute robots=off \ +
-      --no-parent \ +
-      --page-requisites \ +
-      --convert-links \ +
-      --http-user="$USERNAME"+
-      --http-password="$PASSWORD"+
-      --auth-no-challenge \ +
-      --adjust-extension \ +
-      --exclude-directories=_detail,_export \ +
-      --reject="feed.php*,*do=backlink.html,*do=edit.html,*do=index.html,*indexer.php?id=*"+
-      --directory-prefix="$PREFIX"+
-      --no-host-directories \ +
-      $ADDITIONNAL_WGET_OPTS \ +
-      "$PROTO://$HOSTNAME/$LOCATION" +
- +
- +
-echo +
-echo "[SED] fixing links(href...) in the HTML sources" +
-sed -i -e 's#href="\([^:]\+:\)#href="./\1#g' \ +
-       -e "s#\(indexmenu_\S\+\.config\.urlbase='\)[^']\+'#\1./'#"+
-       -e "s#\(indexmenu_\S\+\.add('[^']\+\)#\1.html#"+
-       -e "s#\(indexmenu_\S\+\.add([^,]\+,[^,]\+,[^,]\+,[^,]\+,'\)\([^']\+\)'#\1./\2.html'#"+
-       ${PREFIX}/*.html +
- +
-</file> +
- +
- +
 ==== fullindex (optional) ==== ==== fullindex (optional) ====
  
tips/offline-dokuwiki.sh.txt · Last modified: 2013-01-20 10:39 by 79.192.205.84

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki